403Webshell
Server IP : 104.21.80.248  /  Your IP : 172.71.28.155
Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586
User : SYSTEM ( 0)
PHP Version : 5.6.30
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /Inetpub/www/news/elearning/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Inetpub/www/news/elearning//exams_auth.php
<?php
require './configs/app_top.php';

if (isset($_POST['mode']) && $_POST['mode'] == 'start') {
  $redirectTo = "exams";

  $eid = safe_input($_POST['eid']);
  $ename = safe_input($_POST['ename']);
  $etime = safe_input($_POST['etime']);
  $eindex = safe_input($_POST['eindex']);
  $ecount = safe_input($_POST['ecount']);  
  $red = $_SERVER["HTTP_REFERER"];

  if (intval($eid) == 0) {
    $_SESSION["errorMsg"] = "กรุณาเลือกแบบทดสอบ.";
    $_SESSION["errorType"] = "danger";
    redirect($red);
    exit;
  } else if (intval($_SESSION["user_id"]) == 0) {
    $_SESSION["errorMsg"] = "กรุณาเข้าระบบก่อนทำแบบทดสอบ.";
    $_SESSION["errorType"] = "danger";
    redirect(generate_site_link("login"));
    exit;
  } else {

    $_SESSION["exam_id"] = $eid;
    $_SESSION["exam_name"] = $ename;
    $_SESSION["etime"] = $etime;
    $_SESSION["exam_start_time"] = time();


    try {

      $sql = "select `qb_id`, `qb_subject_id`, `qb_question`, `qb_option1`, `qb_option2`, `qb_option3`, `qb_option4`, `qb_answer`  "
              . "FROM " . TBL_QUESTIONS . " WHERE 1 AND qb_subject_id = :id ORDER BY RAND() LIMIT $eindex";

      $stmt = $DB->prepare($sql);
      $stmt->bindValue(":id", safe_input($eid));
      $stmt->execute();
      $qresults = $stmt->fetchAll();

      $file = "questions_temp/" . session_id() . "_" . $_SESSION["user_id"] . "_" . $eid . ".json";
      $_SESSION["exam_file_name"] = $file;
      file_put_contents($file, json_encode($qresults));
      // also unset the value of question if any
      unset($_SESSION["q_attempt"]);
      unset($_SESSION["last_exam_time"]);
    } catch (Exception $ex) {
      echo $ex->getMessage();
    }

    redirect(generate_site_link("exams"));
    exit;
  }
} else if (isset($_POST['mode']) && $_POST['mode'] == 'end') {
  $uid = safe_input($_POST['eid']);
  $st_exams_time = safe_input($_POST['st_exams_time']);
  $ct = time();
  
  // TO get exact time
  date_default_timezone_set('UTC');
  $tt = date("H:i:s", strtotime(date("Y-m-d H:i:s", $ct)) - strtotime(date("Y-m-d H:i:s", $st_exams_time))) ;
  // back to our normat timezone
  date_default_timezone_set('Asia/bangkok');
  
  $string = file_get_contents($_SESSION["exam_file_name"]);
  $results = json_decode($string, true);

  $cnt = 0;
  for ($i = 0; $i < count($results); $i++) {
    if (intval($_SESSION["q_attempt"][$results[$i]["qb_id"]]) != 0) {
      if (intval($_SESSION["q_attempt"][$results[$i]["qb_id"]]) == $results[$i]["qb_answer"]) {
        $cnt++;
      }
    }
  }
  

  $sql = "INSERT INTO " . TBL_TEST_RESULTS . " "
          . "( `tr_user_id`,`tr_subject_id`, `tr_total_question`, `tr_correct_answer`, `tr_time_taken`, `tr_exam_date` ) VALUES "
          . "(:uid, :sid, :tc,:ca, :tt, :ed)";

  try {
    $stmt = $DB->prepare($sql);
    $stmt->bindValue(":uid", intval($_SESSION["user_id"]));
    $stmt->bindValue(":sid", intval($_SESSION["exam_id"]));
    $stmt->bindValue(":tc", count($results));
    $stmt->bindValue(":ca", intval($cnt));
    $stmt->bindValue(":tt", $tt );
    $stmt->bindValue(":ed", date("Y-m-d H:i:s"));

    $stmt->execute();
    $retval = $stmt->rowCount();

    if ($retval > 0) {
      $_SESSION["errorMsg"] = "ระบบได้บันทึกข้อมูลการสอบของคุณเรียบร้อยแล้ว.";
      $_SESSION["errorType"] = "success";
    } else {
      $_SESSION["errorMsg"] = "เกิดข้อผิดพลาดในการบันทึกข้อมูล.";
      $_SESSION["errorType"] = "danger";
    }
  } catch (Exception $ex) {
    $_SESSION["errorMsg"] = $ex->getMessage();
    $_SESSION["errorType"] = "danger";
  }

  @unlink($_SESSION["exam_file_name"]);
  unset($_SESSION["exam_id"]);
  unset($_SESSION["etime"]);
  unset($_SESSION["exam_name"]);
  unset($_SESSION["exam_start_time"]);
  unset($_SESSION["exam_file_name"]);
  unset($_SESSION["q_attempt"]);

  redirect(generate_site_link("exams_results"));
}
redirect(generate_site_link("index"));
?>

Youez - 2016 - github.com/yon3zu
LinuXploit