Location: PHPKode > projects > Nukequiz > html/modules/Nukequiz/public/NQPStartQuiz.php
<?php
/*****************************************************************/
/* Nukequiz (tm)    v 3.1.0                                		 */
/* By: Kissoftware (hide@address.com)      		     */
/* http://www.kissoftware.org.uk                           		 */
/* http://www.kissoftware.co.uk                       		     */
/* Copyright © 2003-2008 by Kissoftware         				 */
/* See Docs For Information & Credits                 			 */
/* For More information Visit Forums Or The Online Help Manual	 */
/*****************************************************************/
$result = $db->sql_query("SELECT * FROM ".$prefix."_nquiz_quiz WHERE qid='$qid'");
list($qid, $sid, $active, $iscq, $prize_desc, $sponsor, $dir, $title, $eadmin, $random, $euser, $limit, $viewanswers, $expire, $hits, $maxqnum, $points, $rate, $votes, $adminemail) = $db->sql_fetchrow($result);
$pagetitle = _NQ_NUKEQUIZ.' - '.$title;
include("header.php");
logoheader();
$logip = $_SERVER['REMOTE_ADDR'];
$userhelp = intval($nq_config['user_help']);
scorehistory();
$now = time();
if (!$expire == '0'){
if ($expire <= $now)
{
$formatdate = $nq_config['dateformat'];
$expire = date($formatdate,$expire);
$db->sql_query("UPDATE ".$prefix."_nquiz_quiz SET active='0' WHERE qid='$qid'");
$emailtemplate = $nq_config['templates'];
$reply = $nq_config['reply_email'];
$subject = ""._NQ_QEXPIRED." : $title";
$from  = "FROM:$sitename<$reply>\nContent-Type: text/html; charset=iso-8859-1\r\n";
include_once("modules/$module_name/templates/$emailtemplate/t_3.php");
mail($adminmail, $subject, $emailbody, $from);
OpenTable();
echo "<br><center><b>$title<br><br>"._NQ_QHASEXPIRED."</b>&nbsp;$expire<br>";
echo "<br>[&nbsp;<a href='modules.php?name=$module_name&amp;op=showsection&amp;sid=$sid'>"._NQ_OK."</a>&nbsp;]</center><br><br>";
CloseTable();
include('footer.php');
return;
}
}#quiz expired!!
if (is_user($user))##user entry 4 quiz
{
cookiedecode($user);
$logname = $cookie[1];
$result = $db->sql_query("SELECT user_email FROM ".$prefix."_users WHERE username='$logname'");
list($adrs) = $db->sql_fetchrow($result);
}
elseif (is_admin($admin))##admin entry 4 quiz
{
$logname = ""._NQ_ADMINISTRATOR."";
$adrs = $adminmail;
}
else {##neither user nor admin - need 2 register//substitute for guest login-addtablesifreqd
mustbereguser();
include('footer.php');
return;
}
if (intval($limit) == '1')##quiz limited to one attempt only!!
{
$result = $db->sql_query("SELECT username, qid, date FROM ".$prefix."_nquiz_scoreboard WHERE qid='$qid' AND username='$logname'");
if($db->sql_numrows($result) > '0'){
OpenTable();
$resultb = $db->sql_query("SELECT username, qid, date FROM ".$prefix."_nquiz_scoreboard WHERE qid='$qid' AND username='$logname' ORDER BY date DESC LIMIT 0,1");
if($db->sql_numrows($resultb) > '0'){
echo "<br><center>"._NQ_ALREADYCOMPLETED."<br><br>";
echo "<center><table cellpadding='3' cellspacing='3' border='0'><td align='center'><b>"._NQ_LOGGEDATTEMPT."</b></td></tr><tr>";
while(list($username, $qid, $date) = $db->sql_fetchrow($resultb)){
$formatdate = $nq_config['dateformat'];
$date = date($formatdate,$date);
echo "<td align='center'>$date</td></tr><tr>";
}
echo "</tr></table>";
}
else {
echo "<br><center>"._NQ_ALREADYCOMPLETED."<br><br>";
echo "<center><table cellpadding='3' cellspacing='3' border='0'><td align='center' colspan='2'><b>"._NQ_PREVIOUSATTEMPTS."</b></td></tr><tr>";
echo "<td align='center' colspan='2'>"._NQ_NORESULTSATP."</td></tr><tr>";
echo "</tr></table>";
}
echo ""._GOBACK."</center><br>";
if ($userhelp > '0'){
echo "<div align='right'>".quizhelp_img(_NQ_HELPUSERCOMPLETED)."&nbsp;</div><br>";
}
CloseTable();
include('footer.php');
return;
}
}
if(!$db->sql_query("INSERT INTO ".$prefix."_nquiz_scoreboard VALUES ('NULL','$logip','$now','','$logname','$adrs','$qid','0','0.00','','','00:00','$now')"))
{
die (""._NQ_DBERRORTABLE."_nquiz_scoreboard");
}
OpenTable();
echo "<br><center><b>"._NQ_WELCOME.":&nbsp;</b>$logname"
."<br><b>"._NQ_EMAIL.":&nbsp;</b>$adrs<br></center><br>"
."<center><b>&ndash;&nbsp;&ndash;&nbsp;&loz;&nbsp;&loz;&nbsp;&ndash;&nbsp;&ndash;</b></center>"
."<center><br>"._NQ_UHSELECTED."<br>"
."<br><b>&raquo;&nbsp;$title&nbsp;&laquo;</b><br><br>"
."<center><b>&ndash;&nbsp;&ndash;&nbsp;&loz;&nbsp;&loz;&nbsp;&ndash;&nbsp;&ndash;</b></center>"
."<form name='nq' action='modules.php?name=$module_name' method='post'>"
."<center><input type='hidden' name='op' value='go'>"
."<input type='hidden' name='sid' value='$sid'>"
."<input type='hidden' name='qid' value='$qid'>"
."<input type='hidden' name='logname' value='$logname'>"
."<input type='hidden' name='adrs' value='$adrs'>"
."<input type='hidden' name='starttime' value='$now'>"
."<input type='hidden' name='nquiztitle' value='$title'>";
$temp_array = mysql_fetch_array($db->sql_query("SELECT last_insert_id() FROM ".$prefix."_nquiz_scoreboard"));
$sbid = $temp_array['last_insert_id()'];
echo "<input type='hidden' name='sbid' value='$sbid'>";
$myquizimage = myquizimage("start.png");
echo "<center><input type='image' src='$myquizimage' border='0' type='submit' border='0'></center>";
echo "</form>";
echo "<br><center>"._GOBACK."</center><br>";
if ($userhelp > '0'){
echo "<div align='right'>".quizhelp_img(_NQ_HELPUSERSTARTQUIZ)."&nbsp;</div>"; 
}
CloseTable();
include('footer.php');
?>
Return current item: Nukequiz