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/technc/exam.php
<?php include 'header.php';

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

$host = $_SERVER['SERVER_NAME']; // domain for creating post page
$user_id = 1;
$message = '';  // for displayin error and success msgs
$POST_TABLE = "naukri_wp_posts";

include('function.php');  // to make new post page

// submit data to add exam category
if (isset($_REQUEST['postSubmit'])) {
     print_r($_REQUEST); 

    $post_title = $_REQUEST['exam_name'];
    $post_content = $_REQUEST['shortcode'];
    $post_name = $_REQUEST['post_slug'];
    $post_parent = $_REQUEST['parent_category'];

    if (empty($post_title)) {
        $message = '<div class="alert alert-danger alert-dismissible fade show"><strong>Post Name Required.</strong></div>';
    } else if (empty($post_name)) {
        $message = '<div class="alert alert-danger alert-dismissible fade show"><strong>Url SLug Email Required.</strong></div>';
    } else if (empty($post_content)) {
        $message = '<div class="alert alert-danger alert-dismissible fade show"><strong>Shortcode Required.</strong></div>';
    } else if (empty($post_parent)) {
        $message = '<div class="alert alert-danger alert-dismissible fade show"><strong>Post Parent Category Required.</strong></div>';
    } else {
        $exist_page = $db->prepare("SELECT count(ID) as countId FROM $POST_TABLE WHERE post_name = '" . $post_name . "' AND post_status='publish'");
        $exist_page->execute();
        $check_page = $exist_page->fetch(PDO::FETCH_ASSOC);
        if ($check_page['countId'] == 0) {
            createPostPages($post_title, $post_content, $post_name, $user_id, $post_parent, $host);
          
            $message = '<div class="alert alert-success"> <strong>Data submit successfully</strong></div>';
        } else {
            $message = '<div class="alert alert-danger"> <strong>Page Already Exist. Enter other name. </strong></div>';
        }
    }
}
?>
<style>
    .total_ques_div {
        background-color: white;
        border-color: #C8D5E0;
        border-image: none;
        border-style: solid;
        border-width: 1px 1px 2px;
        color: #1E598E;
        font-weight: bold;
        padding: 8px 10px;
        text-decoration: none;
    }

    .form-table td {
        padding: 0px !important;
    }

    .extLink {
        text-decoration: none;
        cursor: pointer;
    }

    .fancybox-skin {
        margin-left: 400px !important;
        width: 500px !important;
    }

    .form-table td {
        padding: 5px !important;
    }
</style>

<script type="text/javascript" charset="utf8" src="assets/js/jquery-1.4.1.min.js"></script>
<script type="text/javascript" charset="utf8" src="assets/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="assets/css/jquery.dataTables.min.css">

<main id="main-container">
    <div class="content content-narrow">
        <div class="row">
            <div class="col-lg-12">
                <button name="addpost" class="btn btn-info" onclick="addAllPages()" title="Add All Post For Exams">Add All Page</button>

                <h2 class="content-heading">Exam List</h2>
                <?php echo $message ; ?>
                <div id="msg"></div>
                <div class="table-responsive">
                    <table id="exam_list" class="table table-striped table-bordered dt-responsive nowrap" style="width:100%; cellspacing:0;">
                        <thead>
                            <tr>
                                <th>S.no</th>
                                <th>Status</th>
                                <th>Action </th>
                                <th>Add Page </th>
                                <th>Exam name</th>
                                <th>Post name</th>
                                <th>Url Slug</th>
                                <th>Domain name</th>
                                <th>Category</th>
                                <th>State</th>
                                <th>Type</th>
                            </tr>
                        </thead>
                    </table>
                    <script type="text/javascript">
                        jQuery(function($) {
                            jQuery('#exam_list').dataTable({
                                "dom": "Bfrtip",
                                "pagingType": "full_numbers",
                                "processing": true,
                                "serverSide": true,
                                "responsive": true,
                                "ajax": "/technc/exam_list_data.php",
                                "columns": [{
                                        "data": "id",
                                        render: function(data, type, row, meta) {
                                            return meta.row + meta.settings._iDisplayStart + 1;
                                        }
                                    },
                                    {
                                        "data": "status",
                                        render: function(data, type, row, meta) {
                                            if (row.status == '1') {
                                                return '<td><a style="cursor:pointer;" id=' + row.exam_id + ',' + row.status + ' onclick="update(id)"><span id="status">Active</span></a></td>';
                                            } else if (row.status == '0') {
                                                return '<td><a style="cursor:pointer;" id=' + row.exam_id + ',' + row.status + ' onclick="update(id)"><span id="status">Deactive</span></a></td>';
                                            }
                                        },
                                    },
                                    {
                                        "data": "action",
                                        render: function(data, type, row, meta) {
                                            var ret = '';
                                            ret += '<a href="edit.php?id=' + row.exam_id + '"><button class="btn btn-info"> Edit </button> </a><a style="cursor:pointer;" id=' + row.exam_id + '  onclick="deleteExam(id)"><button class="btn btn-danger">Delete</button></a>  ';
                                            if (row.countId == 0) {
                                                ret += ' <button name="add" class="btn btn-info" onclick="addData(' + row.exam_id + ')" data-toggle="tooltip" title="Add post for this exam">Add Page</button> ';
                                            }

                                            return ret;
                                        }
                                    },
                                    {
                                        "data": "exam_name"
                                    },
                                    {
                                        "data": "post_name"
                                    },
                                    {
                                        "data": "url_slug"
                                    },
                                    {
                                        "data": "off_web_link"
                                    },
                                    {
                                        "data": "name"
                                    },
                                    {
                                        "data": "state_name"
                                    },
                                    {
                                        "data": "type"
                                    }
                                ],
                                "order": [
                                    [0, 'desc']
                                ],
                                "bPaginate": true,
                                "iDisplayLength": 50,
                                "bProcessing": true,
                                "bServerSide": true,
                                "lengthMenu": [
                                    [50, 100, 200, 300, 1000],
                                    [50, 100, 200, 300, "All"]
                                ]
                            });
                        });
                    </script>
                </div>
            </div>
        </div>
    </div>
    <!-- --view post  detail modal------->
    <div class="modal fade" id="examModal" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content" id="exam_detail">
            </div>
        </div>
    </div>
    <!---------END post MODEL----->
    <script type="text/javascript">
        function update(id) {
            var txt;
            var r = confirm("Do you want to change status ?");
            if (r == true) {
                var str = id;
                var array = str.split(',');
                var status = array[1];
                $.ajax('status_active.php', {
                    type: 'POST', // http method
                    data: {
                        id: id
                    }, // data to submit
                    success: function(data, status, xhr) {
                        //console.log(data);
                        var update_id = data.st;

                        if (status != update_id) {
                            location.reload();
                        }
                    },
                    error: function(jqXhr, textStatus, errorMessage) {}
                });
            }
        }

        function deleteExam(id) {
            var txt;
            var r = confirm("Do you want to Delete ?");
            if (r == true) {
                $.ajax('delete_exam.php', {
                    type: 'POST', // http method
                    data: {
                        id: id
                    }, // data to submit
                    success: function(response) {
                        var obj = jQuery.parseJSON(response);
                        if (obj.status == '1') {
                            alert(obj.msg);
                            location.reload();
                        } else {
                            alert(obj.msg);
                        }
                    },
                    error: function(jqXhr, textStatus, errorMessage) {}
                });
            }
        }
    </script>
    <script>
        //  to make slug from post name
        function convertToSlug(str) {
            str = str.replace(/[`~!@#$%^&*()_\-+=\[\]{};:'"\\|\/,.<>?\sā€˜ā€™//]/g, ' ').toLowerCase(); //replace all special characters | symbols with a space     
            str = str.replace(/^\s+|\s+$/gm, ''); // trim spaces at start and end of string
            str = str.replace(/\s+/g, '-'); // replace space with dash/hyphen
            document.getElementById("post_slug").value = str;
        }

        //view
        function addData(id) {
            var site = "add_new_exam_page.php";
            jQuery.ajax({
                url: site,
                type: 'POST',
                data: {
                    id: id
                },
                success: function(data) {
                    $('#exam_detail').html(data);
                    $('#examModal').modal("show");
                }
            });
        }

        //add all pages at once
        function addAllPages() {
            var id = 'all-pages';
            var site = "add_all_page.php";
            jQuery.ajax({
                url: site,
                type: 'POST',
                data: {
                    id: id
                },
                success: function(data) {
                    console.log(data);
                    $('#msg').html(data);
                }
            });
        }
    </script>
    <?php include 'footer.php'; ?>