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/content-sp/work-sp/nbq_primary_download.php
<meta http-equiv="Content-Language" content="hi">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$mType = 'sp';
$year = date("Y");
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
include_once 'config.php';
include_once 'functions.php';

session_start();

$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
$SP_EDITORS = 'csp_editors';
$SP_QUESTION = 'csp_sp_question';
$SP_MASTER_CATEGORY = 'csp_sp_master_category';
$SP_MEDIUM = 'csp_sp_medium';
$SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';
$SP_QUES_HISTORY = 'csp_sp_question_history';

$replaceArray = array(" & ", "+");
$spaceArray = array(" and ", "plus");
$topic_id = $_REQUEST['exam'];
$level = $_REQUEST['level'];
$mType = $_REQUEST['mType'];
if($mType == 'oly'){
    $photoFolder='/uploads/tet_admin_photos_oly/';
    $tinyFolder = 'tiny_mce_oly';
} else {
    $photoFolder='/uploads/tet_admin_photos_sp/';
    $tinyFolder = 'tiny_mce_sp';
}
$sec_med_code = isset($_REQUEST['viewIn']) ? $_REQUEST['viewIn'] : "1"; // medium
//$preExam = str_replace($spaceArray, $replaceArray, $topic_id);
?>
<script type="text/javascript" src="https://sarkaripariksha.com/wp-content/plugins/tet-india/files/php-treeview/jquery.js"></script>
<?php

$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$root_link = $protocol . $_SERVER['HTTP_HOST'] . '/';

$spaceArray = array(
    "<p>", "</p>", "<p>&nbsp;</p>", "<br />", "<strong>&nbsp;</strong>", "<strong></strong>", "</strong><strong>", "<p></p>", "<p class=\"Style\">&nbsp;</p>", "&nbsp;</p>", "<p>&nbsp;",
    "&nbsp;<br/><br/></p>", "<p><strong><br/></strong></p>", "<br/><br/></p>", "<p>&nbsp;&nbsp;", "<p>&nbsp;&nbsp;</p>", "<p><strong></strong></p>",
    "<p>&nbsp;&nbsp;&nbsp;</p>", "<p>&nbsp;</p>", "<br>", "&nbsp;", "<br/>", "<br >", "<p><strong><br /></strong></p>", "font-size: small;", "src=https", "wp-content/plugins/tet-india/files/tinymce_new", "https://sarkaripariksha.com/", "/wp-content/uploads/tet_admin_photos/", "http://sarkaripariksha.com/", "wp-content/plugins/tet-india/files/tinymce", "'", "http://content.grapossconnect.com//"
);

$replaceSpaceArray = array("", "", "", "", "", "", "", "", "", "</p>", "<p>", "</p>", "", "</p>", "<p>", "", "", "", "", "", "", "", "", "", "", "src=\"https", "$tinyFolder", "../", "$photoFolder", "../", "old_tinymcesp", "'", "http://content.grapossconnect.com/");

$query = "SELECT sq.question_id,sq.old_question_id, sq.medium_id, sq.no_of_option, sq.question_instruction, sq.question_statement, sq.option_1, sq.option_2, sq.option_3, sq.option_4, sq.option_5, sq.correct_answer, sq.question_solution, sq.previous_exam_year, sq.previous_exam_name, sq.exam_shift, sq.question_expiry, sq.question_type, sq.add_date, sq.status, sq.question_group, sq.last_proofread_by,sq.last_proofread_date, md.medium_name FROM $SP_QUESTION as sq left join $SP_MEDIUM as md on md.medium_id=sq.medium_id where sq.level_name='$level' and sq.medium_id='$sec_med_code' and (sq.subject_id='$topic_id' or sq.topic_id='$topic_id' or sq.sub_topic_id='$topic_id') order by CASE WHEN sq.question_group!=0 THEN sq.question_group ELSE sq.question_id END desc";
$questionList = $conn->query($query);

$fileName = $year . "-nbq-questions-primary";
$originalName = str_replace(",", "", $fileName);

header("Content-type: application/vnd.ms-word");
# And then replacing wordfile.doc with what you need the filename to default to.
header("Content-Disposition: attachment;Filename=" . $originalName . ".doc");
header("Pragma: no-cache");
header("Expires: 0");
?>
<div class="row">
    <?php
    $i = 1;
    foreach ($questionList as $ql) {

        $qId = $ql['question_id'];
        $instructions = str_replace('"../', $root_link, $ql['question_instruction']);
        $instructions = str_replace('"/', $root_link, $instructions);
        $instructions = str_replace($spaceArray, $replaceSpaceArray, $instructions);

        $questions = str_replace('"../', $root_link, $ql['question_statement']);
        $questions = str_replace('"/', $root_link, $questions);
        $questions = str_replace($spaceArray, $replaceSpaceArray, $questions);

        $solution = str_replace('"../', $root_link, $ql['question_solution']);
        $solution = str_replace('"/', $root_link, $solution);
        $solution = str_replace($spaceArray, $replaceSpaceArray, $solution);

        $option1 = str_replace('"../', $root_link, $ql['option_1']);
        $option1 = str_replace('"/', $root_link, $option1);
        $option1 = str_replace($spaceArray, $replaceSpaceArray, $option1);

        $option2 = str_replace('"../', $root_link, $ql['option_2']);
        $option2 = str_replace('"/', $root_link, $option2);
        $option2 = str_replace($spaceArray, $replaceSpaceArray, $option2);

        $option3 = str_replace('"../', $root_link, $ql['option_3']);
        $option3 = str_replace('"/', $root_link, $option3);
        $option3 = str_replace($spaceArray, $replaceSpaceArray, $option3);

        $option4 = str_replace('"../', $root_link, $ql['option_4']);
        $option4 = str_replace('"/', $root_link, $option4);
        $option4 = str_replace($spaceArray, $replaceSpaceArray, $option4);

        $option5 = str_replace('"../', $root_link, $ql['option_5']);
        $option5 = str_replace('"/', $root_link, $option5);
        $option5 = str_replace($spaceArray, $replaceSpaceArray, $option5);

        $currect_ans = $ql['correct_answer'];
        $addDate = $ql['add_date'];

        // replacing cloze test blanks with question id
        $varRep = array('{$curnt}' => $i, '{$curnt+1}' => $i + 1, '{$curnt+2}' => $i + 2, '{$curnt+3}' => $i + 3, '{$curnt+4}' => $i + 4, '{$curnt+5}' => $i + 5, '{$curnt+6}' => $i + 6, '{$curnt+7}' => $i + 7, '{$curnt+8}' => $i + 8, '{$curnt+9}' => $i + 9, '{$curnt+10}' => $i + 10, '{$curnt-1}' => $i - 1, '{$curnt-2}' => $i - 2, '{$curnt-3}' => $i - 3, '{$curnt-4}' => $i - 4, '{$curnt-5}' => $i - 5, '{$curnt-6}' => $i - 6, '{$curnt-7}' => $i - 7, '{$curnt-8}' => $i - 8, '{$curnt-9}' => $i - 9, '{$curnt-10}' => $i - 10);
        // replace unneccessary spaces from ques and statement

        $getEntity = $conn->query("select m.master_id, m.master_name, s.sub_id as subject_id, s.category_name as subject, t.sub_id as topic_id, t.category_name as topic, st.sub_id as sub_topic_id, st.category_name as subtopic from $SP_QUESTION as q LEFT JOIN $SP_MASTER_CATEGORY as m ON m.master_id=q.master_id LEFT JOIN $SP_MASTER_STRUCTURE as s ON s.sub_id=q.subject_id LEFT JOIN $SP_MASTER_STRUCTURE as t ON t.sub_id=q.topic_id LEFT JOIN $SP_MASTER_STRUCTURE as st ON st.sub_id=q.sub_topic_id where q.question_id='$qId'");
        $entData = $getEntity->fetch_assoc();
        $dispEnt = $entData['master_name'] . "->" . $entData['subject'] . "->" . $entData['topic'] . "->" . $entData['subtopic'];
    ?>
        <div style="border-bottom: 2px solid #ddd;padding: 20px 10px;">
            <div class="row">
                <div style="border-right: 2px solid #ddd;padding-right: 20px;margin:0;" class="column eightcol">
                    <h5 class="ques-topic-name"><?php echo $dispEnt; ?></h5>
                    <?php if ($ql['question_instruction'] != '') { ?>
                        <h4 style="font-size: 24px;color: #444;">Instructions: </h4>
                        <p style="font-size: 18px;"><?php echo $instructions; ?></p>
                    <?php } ?>

                    <h4 style="font-size: 20px;color: #444;"><?php echo $i; ?>. Questions:</h4>
                    <p style="font-size: 18px;margin-bottom: 10px;"><?php echo strtr((str_replace('"../', $root_link, $questions)), $varRep); ?></p>
                    <div style="width: 100%;padding-bottom: 20px;">
                        <div style="width: 100%;">
                            <span class="tt_ques_lf">
                                <span class="tt_ques_lf_inn" <?php if ($correct_answer == 1) { ?>style="color:red;" <?php } ?>>(a)</span>
                            </span>
                            <label><?php echo $option1; ?></label>
                        </div>
                        <div style="width: 100%;">
                            <span class="tt_ques_lf">
                                <span class="tt_ques_lf_inn" <?php if ($correct_answer == 2) { ?>style="color:red;" <?php } ?>>(b)</span>
                            </span>
                            <label><?php echo $option2; ?></label>
                        </div>
                        <?php if ($option3 != "") { ?>
                            <div style="width: 100%;">
                                <span class="tt_ques_lf">
                                    <span class="tt_ques_lf_inn" <?php if ($correct_answer == 3) { ?>style="color:red;" <?php } ?>>(c)</span>
                                </span>
                                <label><?php echo $option3; ?></label>
                            </div>
                        <?php } ?>
                        <?php if ($option4 != "") { ?>
                            <div style="width: 100%;">
                                <span class="tt_ques_lf">
                                    <span class="tt_ques_lf_inn" <?php if ($correct_answer == 4) { ?>style="color:red;" <?php } ?>>(d)</span>
                                </span>
                                </label><?php echo $option4; ?>
                            </div>
                        <?php } ?>
                        <?php if ($option5 != "") { ?>
                            <div style="width: 100%;">
                                <span class="tt_ques_lf">
                                    <span class="tt_ques_lf_inn" <?php if ($correct_answer == 5) { ?>style="color:red;" <?php } ?>>(e)</span>
                                </span>
                                <label><?php echo $option5; ?></label>
                            </div>
                        <?php } ?>
                    </div>
                    <div style="padding: 8px 10px;background: #eeeeeebd;">
                        <h4 style="font-size: 24px;">Solution :</h4>
                        <p style="font-size: 18px;"><?php echo $solution; ?></p>
                    </div>
                </div>
            </div>
        </div>

    <?php
        $i++;
    }

    ?>
</div>
<script>
    window.close();
</script>