<?php
/*
(c)wapdesire.com
*/
include("../web/config.php");
include("../web/core.php");
connectdb();
$brw = $HTTP_USER_AGENT;
$brws = explode("/",$HTTP_USER_AGENT);
$ubr = $brws[0];
$uip = getip();
$action = $_GET["action"];
$sid = $_GET["sid"];
$page = $_GET["page"];
$who = $_GET["who"];
$preview = $_GET["preview"];
$start = $_GET["start"];
$uid = getuid_sid($sid);
$nick = getnick_uid($uid);
$upload = $_GET["upload"];
$theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'"));
$bcon = connectdb();
$script = $_GET["script"];
header("Content-type: text/html; charset=ISO-8859-1");
header("Cache-Control: no-cache, must-revalidate, max-age=0");
header("Pragma: no-cache");
echo '<?xml version="1.0"?' . '>';
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
/////////////////////////////Database Error/////////////////////////////
if (!$bcon)
{
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/white_medium.css\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<img src=\"images/exit.gif\" alt=\"!\"/><br/>";
echo "<b>Error! Cannot Connect To Database...</b><br/><br/>";
echo "This error happens usually when backing up the database, please be patient...";
echo "</p>";
echo "</body>";
echo "</html>";
exit();
}
cleardata();
/////////////////////////////Ip Banned/////////////////////////////
if(isipbanned($uip,$ubr))
{
if(!isshield(getuid_sid($sid)))
{
echo "<head>";
echo "<title>Ip Block!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/white_medium.css\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
echo "<b>This IP address is blocked!!!</b><br/>";
echo "<br/>";
echo "How ever we grant a shield against IP-Ban for our great users, you can try to see if you are shielded by trying to log-in, if you kept coming to this page that means you are not shielded, so come back when the ip-ban period is over<br/><br/>";
$banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE penalty='2' AND ipadd='".$uip."' AND browserm='".$ubr."' LIMIT 1 "));
$remain = $banto[0] - time();
$rmsg = gettimemsg($remain);
echo " IP: $rmsg<br/><br/>";
echo "</p>";
echo "<p>";
echo "<form action=\"../web/login.php\" method=\"get\">";
echo "<b>UserID:</b><br/><input name=\"loguid\" format=\"*x\" maxlength=\"30\"/><br/>";
echo "<b>Password:</b><br/><input type=\"password\" name=\"logpwd\" maxlength=\"30\"/><br/>";
echo "<br/><input name=\"Login\" type=\"submit\" value=\"Submit\"></form>";
echo "<br/><br/>Not registered yet? <br/><a href=\"../web/register.php\">SignUp</a><br/>";
echo "<a href=\"../web/index.php?action=terms&sid=$sid\">Site Rules</a><br/>";
echo "</p>";
echo "<p align=\"center\">";
$onu = getnumonline();
echo "Members Inside: $onu</p>";
echo "<a href=\"../wap/index.php\">Wap 1.0(wml) Version</a></p>";
echo mobads();
echo "<div><b>©2006-2007<br/>$sitename</b></div>";
echo "</body>";
echo "</html>";
exit();
}
}
/////////////////////////////Session Expired/////////////////////////////
if(($action != "") && ($action!="terms"))
{
$uid = getuid_sid($sid);
if((islogged($sid)==false)||($uid==0))
{
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/white_medium.css\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "You are not logged in<br/>";
echo "Or Your session has been expired<br/><br/>";
echo "<a href=\"../web/index.php\">Login</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit();
}
}
/////////////////////////////Banned/////////////////////////////
if(isbanned($uid))
{
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
echo "<b>You are Banned</b><br/><br/>";
$banto = mysql_fetch_array(mysql_query("SELECT timeto, pnreas, exid FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1' OR uid='".$uid."' AND penalty='2'"));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0]- time();
$rmsg = gettimemsg($remain);
echo "<b>Time Left: </b>$rmsg<br/>";
$nick = getnick_uid($banto[2]);
echo "<b>By: </b>$nick<br/>";
echo "<b>Reason: </b>$banto[1]";
//echo "<a href=\"../web/index.php\">Login</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit();
}
/////////////////////////////QUIZ/////////////////////////////
if($action=="quiz")
{
addonline(getuid_sid($sid),"Quiz","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz</i></b></div>";
echo "<p align=\"center\">
Welcome To $sitename Quiz
</p>
<p align=\"center\">
<a href=\"./quiz.php?action=play&sid=$sid\">Play</a><br/>
<a href=\"./quiz.php?action=about&sid=$sid\">About</a><br/>
<a href=\"./quiz.php?action=winners&sid=$sid\">Top Scorers</a><br/>
<a href=\"./quiz.php?action=losers&sid=$sid\">Top Losers</a><br/>";
$count_score=mysql_fetch_array(mysql_query("SELECT count(*) from ibwf_users where total_score<'0'"));
$count_score1=$count_score[0];
$count_score=mysql_fetch_array(mysql_query("SELECT count(*) from ibwf_users where total_score>'0'"));
$count_score2=$count_score[0];
$countup=($count_score1+$count_score2);
echo "<br/>$countup people have taken part in Quiz";
if(isowner(getuid_sid($sid))){echo "<br/><a href=\"./quiz.php?action=options&sid=$sid\">Update</a>";}
echo "</p>";
echo "<center><- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////LOSERS/////////////////////////////
else if($action=="losers")
{
addonline(getuid_sid($sid),"Quiz","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz</i></b></div>";
if($page==""||$page<=0)$page=1;
$num_items=mysql_fetch_array(mysql_query("SELECT count(*) from ibwf_users where total_score<'0'"));
if(!$num_items[0])$num_items[0]=0;
echo "<center><b>$num_items[0] have failed miserably</b></center>";
echo "<p align=\"center\">\n";
$items_per_page=10;
$num_pages=ceil($num_items[0]/$items_per_page);
if($page>$num_pages)$page=$num_pages;
$limit_start=($page-1)*$items_per_page;
if($num_items[0]==0)$limit_start=0;
$sql="SELECT * FROM ibwf_users WHERE total_score<'0' ORDER BY total_score DESC LIMIT $limit_start, $items_per_page";
$items=mysql_query($sql);
echo mysql_error();
if($num_items[0]!=0){
while($item=mysql_fetch_array($items)){
echo "<i><b>".getnick_uid($item["id"])."</b></i><br/>".$item["quiz_score"]."<br/>\n";
}
}
if($page>1){
echo "<br/><a href=\"./quiz.php?action=losers&page=".($page-1)."&sid=$sid\"><-Prev</a> ";
}
if($page<$num_pages){
if($page==1)echo "<br/>";
echo "<a href=\"./quiz.php?action=losers&page=".($page+1)."&sid=$sid\">Next-></a>\n";
}
echo "<br/>$page/$num_pages</p>\n";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>";
echo "<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////WINNERS/////////////////////////////
else if($action=="winners")
{
addonline(getuid_sid($sid),"Quiz","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz</i></b></div>";
if($page==""||$page<=0)$page=1;
$num_items=mysql_fetch_array(mysql_query("SELECT count(*) from ibwf_users where total_score>'0'"));
if(!$num_items[0])$num_items[0]=0;
echo "<center><b>$num_items[0] players made the leaderboard</b></center>";
echo "<p align=\"center\">\n";
$items_per_page=10;
$num_pages=ceil($num_items[0]/$items_per_page);
if($page>$num_pages)$page=$num_pages;
$limit_start=($page-1)*$items_per_page;
if($num_items[0]==0)$limit_start=0;
$sql="SELECT * FROM ibwf_users WHERE total_score>'0' ORDER BY total_score DESC LIMIT $limit_start, $items_per_page";
$items=mysql_query($sql);
echo mysql_error();
if($num_items[0]!=0){
while($item=mysql_fetch_array($items)){
echo "<i><b>".getnick_uid($item["id"])."</b></i><br/>".$item["quiz_score"]."<br/>\n";
}
}
if($page>1){
echo "<br/><a href=\"./quiz.php?action=losers&page=".($page-1)."&sid=$sid\"><-Prev</a> ";
}
if($page<$num_pages){
if($page==1)echo "<br/>";
echo "<a href=\"./quiz.php?action=losers&page=".($page+1)."&sid=$sid\">Next-></a>\n";
}
echo "<br/>$page/$num_pages</p>\n";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>";
echo "<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////ABOUT/////////////////////////////
else if($action=="about")
{
addonline(getuid_sid($sid),"Quiz","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz</i></b></div>";
echo "<p align=\"center\">
Welcome To $sitename Quiz
</p>
<p align=\"center\">
this is a multiple choice quiz, each question has 4 possible answers.<br/><br/>
for each question you get right, you get points,
the points you get depend on the difficulty level you've selected:<br/>
<span style=\"color: blue;\"><b>easy = 10 points</b></span><br/>
<span style=\"color: green;\"><b>medium = 20 points</b></span><br/>
<span style=\"color: red;\"><b>hard = 30 points</b></span><br/>
but, each time you get a question wrong, you lose the <span style=\"color: blue;\">10</span>,
<span style=\"color: green;\">20</span> or
<span style=\"color: red;\">30</span> points depending on the difficulty level you selected,
and don't think it stops at zero, oh no, if you get your very first question wrong,
you'll need to get the next one right to return to zero.
</p>";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////PLAY/////////////////////////////
else if($action=="play")
{
addonline(getuid_sid($sid),"Quiz","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz<br/>please select level of difficulty</i></b></div>";
echo "<p align=\"center\">\n";
$row_profiles=mysql_fetch_array(mysql_query("select * from ibwf_users where id='".getuid_sid($sid)."'"));
$row_quiz=mysql_fetch_array(mysql_query("select * from ibwf_quiz"));
$score=explode("/",$row_profiles["quiz_score"]);
$score=$score[0]+$score[1]+$score[2];
$quiz_easy=$row_profiles["quiz_easy"];
$quiz_medium=$row_profiles["quiz_medium"];
$quiz_hard=$row_profiles["quiz_hard"];
if($row_quiz["switch"]==on||(isowner(getuid_sid($sid))&&$preview==yes)){
if($quiz_easy=="no")echo "<a style=\"color: blue;\" href=\"./quiz.php?action=questions&start=yes&sid=$sid&q=1&dif=easy\">easy</a><br/>\n";
else if($quiz_easy=="yes")echo "<span style=\"color: blue;\"><b>** completed **</b></span><br/>\n";
if($quiz_medium=="no")echo "<a style=\"color: green;\" href=\"./quiz.php?action=questions&start=yes&sid=$sid&q=1&dif=med\">medium</a><br/>\n";
elseif($quiz_medium=="yes")echo "<span style=\"color: green;\"><b>** completed **</b></span><br/>\n";
if($quiz_hard=="no")echo "<a style=\"color: red;\" href=\"./quiz.php?action=questions&start=yes&sid=$sid&q=1&dif=hard\">hard</a><br/>\n";
else if($quiz_hard=="yes")echo "<span style=\"color: red;\"><b>** completed **</b></span><br/>\n";
if(($quiz_hard=="yes")&&($quiz_easy=="yes")&&($quiz_medium=="yes")){
echo "<b>you have answered all the questions for this week, please try again next week!</b><br/>\n";
}
echo "<br/><b>your current score is $score</b>\n";
}else{
echo "Quiz Is Currently Turned Off Please Come Back Later\n";
}
echo "</p>\n";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////QUESTIONS/////////////////////////////
else if($action=="questions")
{
addonline(getuid_sid($sid),"Quiz","");
$row_quizusers=mysql_fetch_array(mysql_query("select * from ibwf_quizusers where uid='".getuid_sid($sid)."'"));
if($row_quizusers[$dif."_question"]!=0){$q=$row_quizusers[$dif."_next"];}
$row_quiz=mysql_fetch_array(mysql_query("SELECT * FROM ibwf_quiz WHERE difficulty='".$dif."' AND number='".$q."'"));
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz<br/>Question $q</i></b></div>";
if($start=yes){
mysql_query("insert into ibwf_quizusers set easy_question='".$q."', easy_next='".$q."', med_question='".$q."', med_next='".$q."', hard_question='".$q."', hard_next='".$q."', uid='".getuid_sid($sid)."'");
}
$question = $row_quiz["question"];
$a = $row_quiz["answer1"];
$b = $row_quiz["answer2"];
$c = $row_quiz["answer3"];
$d = $row_quiz["answer4"];
$q = $row_quiz["number"];
$quid = $row_quiz["id"];
$l = $row_quiz["difficulty"];
echo "<p align=\"center\">
<b>$question</b>
</p>
<p align=\"center\">
<i><a href=\"./quiz.php?action=answer&sid=$sid&q=$q&a=a&quid=$quid&l=$l\">$a</a></i><br/>
<i><a href=\"./quiz.php?action=answer&sid=$sid&q=$q&a=b&quid=$quid&l=$l\">$b</a></i><br/>
<i><a href=\"./quiz.php?action=answer&sid=$sid&q=$q&a=c&quid=$quid&l=$l\">$c</a></i><br/>
<i><a href=\"./quiz.php?action=answer&sid=$sid&q=$q&a=d&quid=$quid&l=$l\">$d</a></i>";
echo "</p>";
echo "<center><- <a href=\"./quiz.php?action=play&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////ANSWER/////////////////////////////
else if($action=="answer")
{
addonline(getuid_sid($sid),"Quiz","");
$row_profiles=mysql_fetch_array(mysql_query("select * from ibwf_users where id='".getuid_sid($sid)."'"));
$tmax=$row_ses["tmax"];
$totalscore=explode("/",$row_profiles["quiz_score"]);
$row_quiz=mysql_fetch_array(mysql_query("select * from ibwf_quiz where id='$quid'"));
$row_quizusers=mysql_fetch_array(mysql_query("select * from ibwf_quizusers where uid='".getuid_sid($sid)."'"));
$correct = $row_quiz["answer"];
$ga = $row_quiz["answer1"];
$gb = $row_quiz["answer2"];
$gc = $row_quiz["answer3"];
$gd = $row_quiz["answer4"];
if($a=="a")$guess="$ga";
else if($a=="b")$guess="$gb";
else if($a=="c")$guess="$gc";
else if($a=="d")$guess="$gd";
if($row_quizusers[$l."_next"]!=$q){
echo "<head>
<title>".getnick_sid($sid)."@Quiz</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">
</head>
<body>
<div><b>Cheater!</b></div>
<p align=\"center\">
<img src=\"../images/error.gif\" alt=\"[x]\"/><br/><b>Error!!!</b><br/>
You cannot reload this page to gain more points DO NOT CHEAT!
</p>\n";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>
</body>
</html>\n";
exit;
}
else if($guess=="$correct"){
mysql_query("update ibwf_quizusers set ".$l."_question='".$q."', ".$l."_next='".($q+1)."' where uid='".getuid_sid($sid)."'");
if($l=="easy")$plus="10";
else if($l=="med")$plus="20";
else if($l=="hard")$plus="30";
if($l==easy)$totalscore=($totalscore[0]+$plus)."/".$totalscore[1]."/".$totalscore[2];
else if($l==med)$totalscore=$totalscore[0]."/".($totalscore[1]+$plus)."/".$totalscore[2];
else if($l==hard)$totalscore=$totalscore[0]."/".$totalscore[1]."/".($totalscore[2]+$plus);
$total_score=explode("/",$totalscore);
mysql_query("update ibwf_users set quiz_score='".$totalscore."', total_score='".($total_score[0]+$total_score[1]+$total_score[2])."' where id='".getuid_sid($sid)."'");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Correct!</i></b></div>";
echo "<p align=\"center\">
<i>you got the right answer, $plus points were added to your score.</i><br/>";
if($q<10){
$next=$q+1;
echo "<br/><a href=\"./quiz.php?action=questions&sid=$sid&q=$next&dif=$l\">go to question $next</a><br/>";
}
else if($q==10){
if($l=="easy"){
mysql_query("update ibwf_users set quiz_easy='yes' where id='".getuid_sid($sid)."'");
}
else if($l=="med"){
mysql_query("update ibwf_users set quiz_medium='yes' where id='".getuid_sid($sid)."'");
}
else if($l=="hard"){
mysql_query("update ibwf_users set quiz_hard='yes' where id='".getuid_sid($sid)."'");
}
echo "<br/>you've completed this round.<br/>
<a href=\"./quiz.php?action=play&sid=$sid\">select difficulty</a><br/>";
}
echo "</p>";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
else
{
if($l=="easy")$plus="10";
else if($l=="med")$plus="20";
else if($l=="hard")$plus="30";
if($l==easy)$totalscore=($totalscore[0]-$plus)."/".$totalscore[1]."/".$totalscore[2];
else if($l==med)$totalscore=$totalscore[0]."/".($totalscore[1]-$plus)."/".$totalscore[2];
else if($l==hard)$totalscore=$totalscore[0]."/".$totalscore[1]."/".($totalscore[2]-$plus);
$total_score=explode("/",$totalscore);
mysql_query("update ibwf_users set quiz_score='".$totalscore."', total_score='".($total_score[0]+$total_score[1]+$total_score[2])."' where id='".getuid_sid($sid)."'");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Wrong!</i></b></div>";
echo "<p align=\"center\">
<i>your answer was wrong, $plus points were deducted from your score.</i><br/>
</p>
<p align=\"center\">
-> <a href=\"./quiz.php?action=questions&sid=$sid&q=$q&dif=$l\">try question $q again</a><br/>
</p>";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
}
/////////////////////////////OPTIONS/////////////////////////////
else if($action=="options")
{
if(!isowner(getuid_sid($sid)))
{
addonline(getuid_sid($sid),"In The Forbidden Zone","");
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<b>Permission Denied!</b><br/>";
echo "<br/>You cannot use this page...<br/>";
echo "<a href=\"./index.php?action=main&sid=$sid\">Home</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit;
}
addonline(getuid_sid($sid),"Quiz Options","");
$row_quiz=mysql_fetch_array(mysql_query("select * from ibwf_quiz"));
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz Options</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz Options</i></b></div>";
echo "<p align=\"center\">
Please select the set of questions you wish to edit<br/>
<a href=\"./quiz.php?action=edit&q=1&diff=easy&sid=$sid\" style=\"color:blue;\">easy</a><br/>
<a href=\"./quiz.php?action=edit&q=1&diff=med&sid=$sid\" style=\"color:green;\">medium</a><br/>
<a href=\"./quiz.php?action=edit&q=1&diff=hard&sid=$sid\" style=\"color:red;\">hard</a><br/>
<br/><a href=\"./quiz.php?action=play&preview=yes&sid=$sid\">preview</a><br/>
<i>lastly, you'll want to make sure ALL users can play,<br/>
when a user completes a section, it appears as *complete*, you need to click below,
after each update,
before turning the quiz back on.</i><br/>
<br/><a href=\"./quiz.php?action=reset&sid=$sid\">Reset Scores</a><br/>\n";
if($row_quiz["switch"]=="on"){
echo "<br/><b>Quiz is active<br/><a href=\"./quiz.php?action=off&sid=$sid\">turn it off?</a></b>\n";
}else{
echo "<br/><b>Quiz is not active<br/><a href=\"./quiz.php?action=on&sid=$sid\">turn it on?</a></b>\n";
}
echo "</p>\n";
echo "<center><- <a href=\"./quiz.php?action=quiz&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////RESET/////////////////////////////
else if($action=="reset")
{
if(!isowner(getuid_sid($sid)))
{
addonline(getuid_sid($sid),"In The Forbidden Zone","");
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<b>Permission Denied!</b><br/>";
echo "<br/>You cannot use this page...<br/>";
echo "<a href=\"./index.php?action=main&sid=$sid\">Home</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit;
}
addonline(getuid_sid($sid),"Quiz Options","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz Options</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz Options</i></b></div>";
$query="UPDATE ibwf_users SET quiz_easy='no'";
mysql_query($query);
$query="UPDATE ibwf_users SET quiz_medium='no'";
mysql_query($query);
$query="UPDATE ibwf_users SET quiz_hard='no'";
mysql_query($query);
$query="UPDATE ibwf_users SET quiz_score='0/0/0', total_score='0'";
mysql_query($query);
$query="delete from ibwf_quizusers where uid!=0";
mysql_query($query);
echo "<p align=\"center\">
<b>done!</b><br/>
<br/>all sections will now appear as unplayed for all users.
</p>\n";
echo "<center><- <a href=\"./quiz.php?action=options&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////QUIZ ON/////////////////////////////
else if($action=="on")
{
if(!isowner(getuid_sid($sid)))
{
addonline(getuid_sid($sid),"In The Forbidden Zone","");
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<b>Permission Denied!</b><br/>";
echo "<br/>You cannot use this page...<br/>";
echo "<a href=\"./index.php?action=main&sid=$sid\">Home</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit;
}
addonline(getuid_sid($sid),"Quiz Options","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz Options</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz Options</i></b></div>";
$query="UPDATE ibwf_quiz SET switch='on'";
mysql_query($query);
echo "<p align=\"center\">
<b>done!</b><br/>
<br/>the quiz was activated,
now all other users can participate.
</p>\n";
echo "<center><- <a href=\"./quiz.php?action=options&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////QUIZ OFF/////////////////////////////
else if($action=="off")
{
if(!isowner(getuid_sid($sid)))
{
addonline(getuid_sid($sid),"In The Forbidden Zone","");
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<b>Permission Denied!</b><br/>";
echo "<br/>You cannot use this page...<br/>";
echo "<a href=\"./index.php?action=main&sid=$sid\">Home</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit;
}
addonline(getuid_sid($sid),"Quiz Options","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz Options</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz Options</i></b></div>";
$query="UPDATE ibwf_quiz SET switch='off'";
mysql_query($query);
echo "<p align=\"center\">
<b>done!</b><br/>
<br/>the quiz was deactivated,
the link has disappeared from the main menu.
</p>\n";
echo "<center><- <a href=\"./quiz.php?action=options&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////EDIT/////////////////////////////
else if($action=="edit")
{
if(!isowner(getuid_sid($sid)))
{
addonline(getuid_sid($sid),"In The Forbidden Zone","");
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<b>Permission Denied!</b><br/>";
echo "<br/>You cannot use this page...<br/>";
echo "<a href=\"./index.php?action=main&sid=$sid\">Home</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit;
}
addonline(getuid_sid($sid),"Quiz Options","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz Options</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz Options</i></b></div>";
echo "<p align=\"center\">\n";
$query="select * FROM ibwf_quiz WHERE difficulty='$diff' AND number='$q'";
$result=mysql_query($query);
$num_rows=mysql_num_rows($result);
$row=mysql_fetch_array($result);
$question=$row["question"];
$correct=$row["answer"];
$a=$row["answer1"];
$b=$row["answer2"];
$c=$row["answer3"];
$d=$row["answer4"];
$id=$row["id"];
echo "<b>edit question $q<br/>[difficulty: $diff]</b>
</p>
<center>
<form action=\"./quiz.php?action=save&q=$q&diff=$diff&sid=$sid\" method=\"post\">
<br/>question:<br/>
<input type=\"text\" name=\"nquestion\" value=\"$question\" maxlength=\"100\"/>
<br/>correct answer:<br/>
<input type=\"text\" name=\"nright\" value=\"$correct\" maxlength=\"100\"/><br/>
<br/>one of the answers below must be the same case and spelling as the correct answer
<br/>answer 1:<br/>
<input type=\"text\" name=\"na\" value=\"$a\" maxlength=\"100\"/><br/>
answer 2:<br/>
<input type=\"text\" name=\"nb\" value=\"$b\" maxlength=\"100\"/><br/>
answer 3:<br/>
<input type=\"text\" name=\"nc\" value=\"$c\" maxlength=\"100\"/><br/>
answer 4:<br/>
<input type=\"text\" name=\"nd\" value=\"$d\" maxlength=\"100\"/><br/>
<input type=\"submit\" value=\"update\"/>
</form>
</center>\n";
echo "<center><- <a href=\"./quiz.php?action=options&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////SAVE/////////////////////////////
else if($action=="save")
{
if(!isowner(getuid_sid($sid)))
{
addonline(getuid_sid($sid),"In The Forbidden Zone","");
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<b>Permission Denied!</b><br/>";
echo "<br/>You cannot use this page...<br/>";
echo "<a href=\"./index.php?action=main&sid=$sid\">Home</a>";
echo "</p>";
echo "</body>";
echo "</html>";
exit;
}
addonline(getuid_sid($sid),"Quiz Options","");
echo "<head>";
echo "<title>".getnick_sid($sid)."@Quiz Options</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><b><i>Quiz Options</i></b></div>";
echo "<p align=\"center\">\n";
$query="UPDATE ibwf_quiz SET question='$nquestion' where number=$q AND difficulty='$diff'";
mysql_query($query);
$query="UPDATE ibwf_quiz SET answer='$nright' where number=$q AND difficulty='$diff'";
mysql_query($query);
$query="UPDATE ibwf_quiz SET answer1='$na' where number=$q AND difficulty='$diff'";
mysql_query($query);
$query="UPDATE ibwf_quiz SET answer2='$nb' where number=$q AND difficulty='$diff'";
mysql_query($query);
$query="UPDATE ibwf_quiz SET answer3='$nc' where number=$q AND difficulty='$diff'";
mysql_query($query);
$query="UPDATE ibwf_quiz SET answer4='$nd' where number=$q AND difficulty='$diff'";
mysql_query($query);
$next=($q+1);
if($next<=10){
echo "<b>done!</b><br/>
<br/>question $q was updated<br/>
<b>question:</b><br/>$nquestion<br/>
<b>right answer:</b><br/>$nright<br/>
<br/><b>answer 1:</b><br/>$na<br/>
<b>answer 2:</b><br/>$nb<br/>
<b>answer 3:</b><br/>$nc<br/>
<b>answer 4:</b><br/>$nd<br/>
<br/><a href=\"./quiz.php?action=edit&q=$next&diff=$diff&sid=$sid\">Question $next</a>\n";
}else{
echo "<b>done!</b><br/>
<br/>that was the last $diff question,
taking you back to quiz admin..<br/>
<br/><b>question:</b><br/>$nquestion<br/>
<b>right answer:</b><br/>$nright<br/>
<br/><b>answer 1:</b><br/>$na<br/>
<b>answer 2:</b><br/>$nb<br/>
<b>answer 3:</b><br/>$nc<br/>
<b>answer 4:</b><br/>$nd\n";
}
echo "<center><- <a href=\"./quiz.php?action=options&sid=$sid\">Back</a><br/>
<- <a href=\"./index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Main Menu</a></center>";
echo "</body>";
echo "</html>";
}
/////////////////////////////Error/////////////////////////////
else
{
echo "<head>";
echo "<title>Error!!!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/white_medium.css\">";
echo "</head>";
echo "<body>";
echo "<p align=\"center\">";
echo "You are not logged in<br/>";
echo "Or Your session has been expired<br/><br/>";
echo "<a href=\"../web/index.php\">Login</a>";
echo "</p>";
echo "</body>";
echo "</html>";
}
?>