HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/nclive/wp-content/plugins/nc_plugin/nc_ssc_exam.php
<?php
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url_slug = basename($actual_link);

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

global $wpdb;
$TT_EXAM = "sp_exam";
$TT_EXAM_LINKS = "sp_exam_links";
$TT_EXAM_CATEGORY = "sp_exam_category";
$TT_EXAM_ENTITY = "sp_exam_entity";

$limit = 6;  // limit to show exam data
/******** query to get data as per category slug id **********/
$categoryDetailQuery = $wpdb->get_results("SELECT e.exam_name, e.url_slug, e.exam_summary, e.add_date, e.update_date, c.name, c.img_icon, n.name, l.entity_id, l.display_text FROM $TT_EXAM AS e LEFT JOIN $TT_EXAM_CATEGORY AS c ON e.cat_id = c.cat_id LEFT JOIN $TT_EXAM_LINKS as l on e.exam_id=l.exam_id LEFT JOIN $TT_EXAM_ENTITY as n ON n.id=l.entity_id WHERE l.status!='0' and e.status!='0' and n.status!='0' AND c.status!='0' AND c.url_slug='$url_slug' order by e.display_order desc limit 0, $limit");
$categoryCount = $wpdb->num_rows;
/******** query to get data for all category **********/
$categoryQuery = $wpdb->get_results("SELECT cat_id,name,url_slug,img_icon from $TT_EXAM_CATEGORY WHERE status='1' order by display_order ASC");
/******** query to get data for heading and navigation category **********/
$categoryData = $wpdb->get_row("SELECT cat_id,full_name, name,img_icon from $TT_EXAM_CATEGORY WHERE status='1' order by display_order ASC");
?>

<!-- ALL PAGE HEADER SECTION -->

<section class="allPageheaderSection wow fadeInDown">
  <div class="allPageheaderSectionbg"></div>
  <div class="container">
    <div class="row">
      <div class="col-md-12 col-sm-12 col-xs-12">
        <h2><?php echo $categoryData->full_name; ?> (<?php echo $categoryData->name; ?>)</h2>
        <!-- <h1>Lorem ipsum dolor sit amet consectetur adipisicing elit</h1> -->
        <p><a href="/">Home</a> / <?php echo $categoryData->name; ?></p>
      </div>
    </div>
  </div>
</section>

<!-- END ALL PAGE HEADER SECTION -->

<!-- SSC PAGE SECTION -->

<section class="NotificationPageSection SSCPageSection">
  <div class="container">
    <div class="row">
      <!-- <img class="AddsImg" src="https://sarkaripariksha.com/ticket_bck/banners/1674217078-banner.png" alt=""> -->
      <div class="col-md-4 col-sm-4 col-xs-12">
        <div class="NotificationLeftBox wow fadeInLeft">
          <h4>Search Category Exams</h4>
          <form action="">
            <i class="fas fa-search"></i>
            <input type="text" id="search_data" placeholder="Exam name, Title or etc...">
          </form>
          <hr>

          <h4>Other Categories</h4>
          <ul>
            <?php foreach ($categoryQuery as $cat) {  ?>
              <li>
                <a href="/<?php echo $cat->url_slug; ?>">
                  <?php if ($cat->img_icon != '') { ?>
                    <img src="/images/<?php echo $cat->img_icon; ?>" alt="">
                  <?php } ?>
                  <?php echo ucfirst($cat->name); ?>
                </a>
              </li>
            <?php } ?>
          </ul>
        </div>
      </div>


      <div class="col-md-8 col-sm-8 col-xs-12">
        <div class="NotificationRightBox">
          <div class="NotificationRightBoxHeader wow fadeInDown">
            <h4>Show <b><span id="countData"><?php echo $categoryCount; ?> </span> </b> Category Exams</h4> <a onclick="clearAll();" style="cursor:pointer;">Clear all</a>
          </div>
          <div id="loader" style="display:none">
            <p align="center"><i class="fa fa-spinner fa-spin"></i> Loading...</p>
          </div>

          <div id="categoryList" class="categoryList">
            <?php foreach ($categoryDetailQuery as $exam) {
              if ($exam->display_text != '') {
                $display_text = $exam->display_text;
              } else {
                $display_text = $exam->name;
              } ?>

              <div class="NotificationExamBox wow fadeInUp">
                <div class="NotificationExamFlexBox">
                  <?php if ($exam->img_icon != '') { ?>
                    <img src="/images/<?php echo $exam->img_icon; ?>" alt="">
                  <?php } ?>
                  <div class="NotificationExamBoxDetails">
                    <a href="/exam-details/<?php echo $exam->url_slug; ?>"><?php echo $exam->exam_name; ?></a>
                    <h6><?php if (strlen($exam->exam_summary) < 120) {
                          echo $exam->exam_summary;
                        } else {
                          echo substr($exam->exam_summary, 0, 120) . '...';
                        } ?></h6>
                    <p>
                      <span title="<?php echo $display_text; ?>" style="color: #ed2551;"><i class="fas fa-calendar-alt"></i> <?php echo date('jS M Y', strtotime($exam->update_date!='' ? $exam->update_date : $exam->add_date)); ?></span>
                    </p>
                  </div>
                </div>
              </div>
            <?php } ?>
          </div>

          <div class="loadmore">
            <input type="button" id="loadBtn" class="SeeMoreBtn wow fadeInUp" value="See More">
            <input type="hidden" id="data_row" value="0">
            <input type="hidden" id="data_row1" value="">
          </div>

        </div>
      </div>
    </div>
  </div>
</section>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

<script>
    // function to highlight text
    function hightlightTxt(search_name) {
        var searchfilter = new RegExp(search_name + "(?=[^>]*<)", "ig");
        var repstr = "<mark>$&</mark>";
        $('.categoryList').html($('.categoryList').html().replace(searchfilter, repstr));
    }


    $(document).ready(function() {

        // load more button
        $(document).on('click', '#loadBtn', function() {
            var data_row = Number($('#data_row').val());
            var row_count = $('#countData').text();
            var limit = <?php echo $limit; ?>;
            var url_slug = '<?php echo $url_slug; ?>';
            data_row = data_row + limit;
            $('#data_row').val(data_row);

            var url = '/wp-content/plugins/nc_plugin/api/nc_category_data.php';
            $.ajax({
                url: url,
                type: 'POST',
                data: {
                    'data_row': data_row,
                    "id": url_slug,
                    'limit': limit
                },
                success: function(data) {
                    var rowCount = data_row + limit;
                    $('.categoryList').append(data);
                    $('#countData').html(rowCount);
                    var pagenum = $('input[name="page_count"]').val();
                    var totalnum = $('input[name="data_row_count"]').val();

                    if (parseInt(totalnum) >= parseInt(pagenum)) {
                        $("#loadBtn").show();
                    } else {
                        $("#loadBtn").hide();
                    }
                }
            });
        });

        // search data using search field 
        $('#search_data').keyup(function() {
            var trim_str = $(this).val();
            var search_name = $.trim(trim_str); 

            var searchfilter = new RegExp(search_name + "(?=[^>]*<)", "ig");
            var repstr = "<mark>$&</mark>";
            $('.categoryList').html($('.categoryList').html().replace(/(^\s+|\s+$)/g, ""));

            if (search_name != '') {
                hightlightTxt(search_name);
                if (search_name.length >= 2) {
                    searchExam(search_name);
                }
            } else {
                location.reload(true);
            }
        });

        // search function
        function searchExam(search_name) {
            var url_slug = '<?php echo $url_slug; ?>';
            var url = '/wp-content/plugins/nc_plugin/api/nc_category_data.php';
            $.ajax({
                url: url,
                type: 'POST',
                data: {
                    "id": url_slug,
                    "exam_name": search_name
                },
                beforeSend: function() {
                    $('#loader').show();
                },
                success: function(response) {
                    if (response != '') {
                        $('#loader').hide();
                        $('#categoryList').html(response);
                        var pagenum = $('input[name="page_count"]').val();
                        $('#countData').text(pagenum);
                        hightlightTxt(search_name); // function for highlighting data
                        $('#loadBtn').css("display", "none");
                    }
                }
            });
        }
    });

    // CLEAR ALL DATA FILter
    function clearAll() {
        location.reload(true);
    }
</script>

<!-- END SSC PAGE SECTION -->