<?php
	ob_start();
session_start();
if($_SESSION['admin']=="")
{
	header("location: login.php");
}
$madeby = $_SESSION['admin'];
$pageTitle = "تشفير وصف الاختبارات";
include("../var.php");
include("header.php");
	$msg="";
$start = "";
if(isset($_GET['start'])){ $start = $_GET['start']; }
if($start == 1)
{
$con = mysqli_connect($DBHOST,$DBUSER,$DBPASS,$DBNAME) or die("Some error occurred during connection " . mysqli_error($con));
mysqli_query($con, "SET CHARACTER SET 'utf8'");
$sql = "SELECT * FROM `quiz` order by id ASC";
$res = mysqli_query($con, $sql);
			while($game = mysqli_fetch_array($res))
			{
				$desc = base64_encode($game['desc']);
				$title = base64_encode($game['title']);
				$result = base64_encode($game['result']);
				$quizid = $game['id'];
				mysqli_query($con, "UPDATE `quiz` SET `desc` = '$desc', `title` = '$title', `result` = '$result' WHERE `id` = $quizid");
			}
$sql = "SELECT * FROM `result` order by id ASC";
$res = mysqli_query($con, $sql);
			while($game = mysqli_fetch_array($res))
			{
				$desc = base64_encode($game['desc']);
				$title = base64_encode($game['title']);
				$quizid = $game['id'];
				mysqli_query($con, "UPDATE `result` SET `desc` = '$desc', `title` = '$title' WHERE `id` = $quizid");
			}
$sql = "SELECT * FROM `questions` order by id ASC";
$res = mysqli_query($con, $sql);
			while($game = mysqli_fetch_array($res))
			{
				$question = base64_encode($game['question']);
				$an1 = base64_encode($game['an1']);
				$an2 = base64_encode($game['an2']);
				$an3 = base64_encode($game['an3']);
				$quizid = $game['id'];
				mysqli_query($con, "UPDATE `questions` SET `question` = '$question', `an1` = '$an1', `an2` = '$an2', `an3` = '$an3' WHERE `id` = $quizid");
				$msg = "<font color='red'>تم التشفير , برجاء حذف هذا الملف وعدم تشغيله مرة آخرى.</font>";
			}
}
?>
<table width="100%" border="0" cellspacing="3" cellpadding="3">
	<tr>
	  <td valign="top" width="500ox">
<?
if ($msg == "")
{
?>
الضغط على ابدء الآن سيقوم بتشفير وصف جميع الاختبارات 
<br><hr>
<font color="grey">اضغط "<b>ابدء الآن</b>" مرة واحده ولا تقوم باعادة تحديث الصفحة</font><br>
<center><a href="?start=1" style="color: red">ابدء الآن</a></center>
<?
}
else{
echo $msg;
}
?>
	  </td>
</tr>
</table>
<?	include("footer.php");?>
