Location: PHPKode > projects > Nukequiz > html/includes/functions_nukequiz.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	 */
/*****************************************************************/
##You May need To Edit The Colours for ForeGround & Background Dependant On Theme Font Colour
function quizhelp_img($info) {
$bgcolor='#CCOO00';
$fgcolor='#000000';
$txtcolor='#000000';
###Do Not Edit below this Line####################################################
$myquizimage = myquizimage("info.png");
return "<a href=\"javascript:void(0);\" onmouseover=\"return overlib( '$info', BELOW, LEFT, CAPTION, '&nbsp;"._NQ_HELP."', STATUS, '&nbsp;"._NQ_HELP."', WIDTH, 250, OFFSETY, 20, CAPICON, '$myquizimage', FGCOLOR, '$fgcolor', BGCOLOR, '$bgcolor', TEXTCOLOR, '$txtcolor', CAPCOLOR, '$txtcolor', BORDER, '1');\" onmouseout=\"return nd();\"><img src='$myquizimage' border='0' align='absmiddle'></a>";
}
function myquizimage($imgfile) {
global $module_name;
$ThemeSel = get_theme();
if (file_exists("themes/$ThemeSel/images/Nukequiz/$imgfile")) {
$myquizimage = "themes/$ThemeSel/images/Nukequiz/$imgfile";
} else {
$myquizimage = "modules/$module_name/images/$imgfile";
}
return($myquizimage);
}
function nqget_configs(){
global $prefix, $db;
$configresult = $db->sql_query("SELECT config_name, config_value FROM ".$prefix."_nquiz_config");
while (list($config_name, $config_value) = $db->sql_fetchrow($configresult)) {
$config[$config_name] = $config_value;
}
return $config;
}
function nqsave_config($config_name, $config_value){
global $prefix, $db;
if (!$db->sql_query("UPDATE ".$prefix."_nquiz_config SET config_value='$config_value' WHERE config_name='$config_name'")){
die (""._NQ_DBERRORTABLE."_nquiz_config");
return;
}
}
function sectionslist(){
global $prefix, $module_name, $db;
OpenTable();
echo "<br><center><b>"._NQ_GENERALINFO."</b></center>";
echo "<br><center><table border='0' cellpadding='4' cellspacing='4'><tr>";
$result = $db->sql_query("SELECT * FROM ".$prefix."_nquiz_sections");
while(list($sid, $secname, $secdesc, $secimage) = $db->sql_fetchrow($result)){
$quizzes = $db->sql_query("SELECT qid, sid, title FROM ".$prefix."_nquiz_quiz WHERE sid='$sid'");
echo "<td><center><img src='modules/$module_name/images/$secimage'></center></td>";
echo "<td>$sid</td><td>$secname</td><td>$secdes</td><td>";
while(list($qid, $sid, $title) = $db->sql_fetchrow($quizzes)){
echo "<b>&loz;&nbsp;</b>$title<br>";
}
echo "</td><tr>";
}
echo "</tr></table></center><br>";
CloseTable();
}
function installwarning(){
global $db, $prefix;
OpenTable();
echo "<br><center><br><font class='title'>"._NQ_WARNING."</font><br><br>"._NQ_GOTO."<b>&nbsp;&raquo;&nbsp;&raquo;";
echo "&nbsp;</b><a href='nqinst.php'>"._NQ_INSTALL."</a><br></center><br>";
CloseTable();
}
function logoheader(){
global $module_name;
OpenTable();
$myquizimage = myquizimage("nqlogo.png");
echo "<br><center><img src='$myquizimage'><br><br></center>";
CloseTable();
}
function copyright(){
global $module_name, $admin_file, $prefix, $nq_config, $db;
$now = time();
$install = $config['install'];
if($install == '0'){
OpenTable();
echo"<br><center><b>"._NQ_CHECK."&nbsp;:&nbsp;</b><a href='".$admin_file.".php?op=adminconfig'>"._NQ_ADMINCONFIG."</a></center><br>";
CloseTable();
}
else{
OpenTable();
$checktime = $now + 604800;
if($config['version_check'] < $now) {
$fd = fopen("http://www.kissoftware.org.uk/versions/nquiz.txt","r");
while (!feof ($fd))
{
$buffer = fgets($fd, 4096);
$lines[] = $buffer;
nqsave_config("version_new",$lines[0]);
nqsave_config("version_check",$checktime);
}
fclose ($fd);
}
$dateformat = $nq_config['dateformat'];
$checktime = date($dateformat,$nq_config['version_check']);
echo "<br><center><font class='title'>"._NQ_VERSIONCHECK."</font></center><br>";
echo "<center><table cellpadding='2' cellspacing='2' border='0'>";
echo "<tr><td align='right'>"._NQ_INSTALLEDVERSION."&nbsp;:</td><td width='50%'><b>".$nq_config['version_number']."</b></tr><tr>";
if ($nq_config['version_new'] > $nq_config['version_number']) { 
echo "<td align='right'><a href='http://www.kissoftware.org.uk' target='_blank'>"._NQ_DOWNLOADCURRENTVERSION."</a>&nbsp;:</td><td width='50%'><b>".$nq_config['version_new']."</b></td>";
}
else{
echo "<td align='right'>"._NQ_CURRENTVERSION."&nbsp;:</td><td width='50%'><b>".$nq_config['version_new']."</b></td>";
}
echo "</tr><tr><td align='right'>"._NQ_NEXTCHECKDUE."&nbsp;:</td><td width='50%'><b>$checktime</b></td>";
echo "</tr><tr><td colspan='2' align='center'>";
echo ""._NQ_FURTHERINFO."";
echo "<br><br><a href='http://www.kissoftware.org.uk/' target='_blank'><img src='modules/$module_name/images/kissoftware.png'></a>";
echo "</td></tr></table></center><br>";
CloseTable();
}
}
function mainpage() {
global $module_name;
echo "<br><center>[&nbsp;<a href='modules.php?name=$module_name'>"._NQ_QUIZINDEX."</a>&nbsp;]</center><br>";
}
function nqmenua(){
global $module_name, $admin_file, $prefix, $db;
echo "<center><table width='100%' cellpadding='1' cellspacing='1'><tr>";
echo "<td>".quizhelp_img(_NQ_HELPNQADMINHME)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nukequiz'>"._NQ_ADMINHME."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPADMINCATEDIT)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqcategoryedit'>"._NQ_ADMINHOME."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPADMINQUIZLIST)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqviewquizlist'>"._NQ_QUIZLIST."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPADMINCREATENQUIZ)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqcreatenewquiz'>"._NQ_CREATENEW."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPNQADMINQUIZLEAGUE)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqleague'>"._NQ_ADMINQUIZLEAGUERES."</a></td></tr>";
echo "</tr></table></center>";
}

function nqmenub() {
global $module_name, $admin_file, $prefix, $db;
echo "<center><table width='100%' cellpadding='1' cellspacing='1'><tr>";
echo "<td>".quizhelp_img(_NQ_HELPMAINADMIN)."</td>";
echo "<td align='left'><a href='".$admin_file.".php'>"._NQ_MAINADMIN."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPNQADMINCONFIG)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqadminconfig'>"._NQ_ADMINCONFIG."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPNQADMINQUESTIONS)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nquploadquestions'>"._NQ_ADMINUPQUIZQUESTIONS."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPNQADMINENOTICE)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqeditnotice'>"._NQ_ADMINNOTICE."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPNQADMINEXPORTQUIZDELETE)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqexportquizdelete'>"._NQ_VIEWEXPORTFILES."</a></td></tr>";
echo "<td>".quizhelp_img(_NQ_HELPADMINTOOLS)."</td>";
echo "<td align='left'><a href='".$admin_file.".php?op=nqnukequiztools'>"._NQ_ADMINTOOLS."</a></td></tr>";
echo "</tr></table></center>";
}
function nqmenuheader(){
global $module_name, $prefix, $db;
OpenTable();
echo "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:9999;\"></div>";
echo "<br><center><table width='90%' cellpadding='2' cellspacing='2' border='0'><tr>";
echo "<td colspan='2' align='center'><font class='title'>"._NQ_ADMINISTRATION."</font></td>";
if (file_exists("./nqinst.php")){
echo "</tr><tr><td colspan='2' align='center'><b><blink>&nbsp;&raquo;&nbsp;&raquo;&nbsp;"._NQ_INSTALLEXISTS."";
echo "&nbsp;&laquo;&nbsp;&laquo;&nbsp;</blink></b></td>";
}
echo "</tr><tr><td valign='top'>";
nqmenub();
echo"</td><td valign='top'>";
nqmenua();
echo"</td></tr></table></center>";
CloseTable();
}
function nqdisplayimagewin(){
global $module_name, $quizdir; 
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function displayimage(mypage, myname, w, h, scroll) {\n";
echo "var winl = (screen.width - w) / 2;\n";
echo "var wint = (screen.height - h) / 2;\n";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}\n";
echo "//  End -->\n";
echo "</script>\n";    
}
function scoreboardwin(){
global $module_name, $prefix, $db; 
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function Scoreboarddisp(mypage, myname, w, h, scroll) {\n";
echo "var winl = (screen.width - w) / 2;\n";
echo "var wint = (screen.height - h) / 2;\n";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}\n";
echo "//  End -->\n";
echo "</script>\n";    
}
function q_right(){
$myquizimage = myquizimage("yes.png");
echo "<td align='left' colspan='2'><img src='$myquizimage' align='absmiddle'></td></tr><tr>";
}
function q_wrong(){
$myquizimage = myquizimage("no.png");
echo "<td align='left' colspan='2'><img src='$myquizimage' align='absmiddle'></td></tr><tr>";
}
function mustbeuser(){
OpenTable();
echo "<br><center><font class='title'>"._NQ_MUSTBEUSER."</font></center><br><br>";
echo "<center>"._NQ_BACK."</center><br><br>";
CloseTable();
}
function mustbereguser(){
OpenTable();
echo "<br><center><font class='title'>"._NQ_MUSTBEREGUSER."</font></center><br><br>";
echo "<center>"._NQ_BACK."</center><br><br>";
CloseTable();
}
function soundwin(){
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function sounddisp(mypage, myname, w, h, scroll) {";
echo "var winl = (screen.width - w) / 2\n;";
echo "var wint = (screen.height - h) / 2\n;";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}";
echo "//  End -->\n";
echo "</script>\n";    
}
function displaytemplatewin($filename){
global $module_name; 
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function displaytemplate(mypage, myname, w, h, scroll) {\n";
echo "var winl = (screen.width - w) / 2;\n";
echo "var wint = (screen.height - h) / 2;\n";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}\n";
echo "//  End -->\n";
echo "</script>\n";    
}
function importwin(){
global $module_name, $prefix, $db; 
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function filesdisplay(mypage, myname, w, h, scroll) {\n";
echo "var winl = (screen.width - w) / 2;\n";
echo "var wint = (screen.height - h) / 2;\n";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}\n";
echo "//  End -->\n";
echo "</script>\n";    
}
function questionwin(){
global $module_name, $prefix, $db; 
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function Questiondisp(mypage, myname, w, h, scroll) {\n";
echo "var winl = (screen.width - w) / 2;\n";
echo "var wint = (screen.height - h) / 2;\n";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}\n";
echo "//  End -->\n";
echo "</script>\n";    
}
function imagewin(){
global $module_name, $prefix, $db; 
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "function imagedisp(mypage, myname, w, h, scroll) {\n";
echo "var winl = (screen.width - w) / 2;\n";
echo "var wint = (screen.height - h) / 2;\n";
echo "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''\n";
echo "win = window.open(mypage, myname, winprops)\n";
echo "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
echo "}\n";
echo "//  End -->\n";
echo "</script>\n";    
}


function viewfullimage(){
echo" <script language=\"JavaScript\">
<!-- Begin
function imgsig(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione=\"Controlla('\"+img+\"')\";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width+20;
altez=foto1.height+20;
stringa=\"width=\"+largh+\",height=\"+altez;
finestra=window.open(img,\"\",stringa);
}
//  End -->
</script>";
}


function dirlist($folderpath){
$handle=opendir($folderpath);
while (($file = readdir($handle))!==false) {	
if (substr($file,-4) == ".jpg" || substr($file,-4) == ".jpeg" || substr($file,-4) == ".png" || substr($file,-4) == ".gif" || substr($file,-4) == ".mp3" || substr($file,-4) == ".wav" || substr($file,-4) == ".mid"){
$filecount=$filecount+1;
}
}
closedir($handle);
return $filecount;
}
function addtoleague(){
global $prefix, $db;
$db->sql_query("OPTIMIZE TABLE ".$prefix."_nquiz_league");
$resulta = $db->sql_query("SELECT DISTINCT username FROM ".$prefix."_nquiz_scoreboard WHERE score >'0'");
while ($row = $db->sql_fetchrow($resulta)) {
$user = $row['username'];
$resultb = $db->sql_query("SELECT username FROM ".$prefix."_nquiz_league WHERE username='$user'");
list($username) = $db->sql_fetchrow($resultb);
if (!$username){
$adrs = $db->sql_query("SELECT email FROM ".$prefix."_nquiz_scoreboard WHERE username='$user'");
list($email) = $db->sql_fetchrow($adrs);
$counttotal = $db->sql_query("SELECT count(username) as total FROM ".$prefix."_nquiz_scoreboard WHERE username='$user'");
list($total) = $db->sql_fetchrow($counttotal);
if(!$db->sql_query("INSERT INTO ".$prefix."_nquiz_league VALUES (NULL, '$user','$email','$total','','','','','','1')")){
die (""._NQ_DBERRORTABLE."_nquiz_league");
return;
}
}
}
}
function updateleague(){
global $prefix, $db, $nq_config;
$update = time();
$last = $nq_config['league_update'];
if ($last+3600 < $update){
$j = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_nquiz_league"));
for ($i=1; $i < $j+1; $i++) {
$leagueuser = $db->sql_query("SELECT username, count FROM ".$prefix."_nquiz_league WHERE nqlid='$i'");
list($username, $count) = $db->sql_fetchrow($leagueuser);
$result = $db->sql_query("SELECT qid FROM ".$prefix."_nquiz_scoreboard WHERE username='$username'");
while ($row = $db->sql_fetchrow($result)) {
$qid = $row['qid'];
$resultpoints = $db->sql_query("SELECT points_total, maxqnum FROM ".$prefix."_nquiz_quiz WHERE qid='$qid'");
while ($row = $db->sql_fetchrow($resultpoints)) {
$point = intval($row['points_total']);
$grandtotal=$point+$grandtotal;
$ques = $row['maxqnum'];
$gquestotal=$ques+$gquestotal;
}
}
$resulttotal = $db->sql_query("SELECT sum(score) as totalscore FROM ".$prefix."_nquiz_scoreboard WHERE username='$username'");
list($totalscore) = $db->sql_fetchrow($resulttotal);
if ($totalscore == '' || $totalscore == '0'){
echo "zero scores";
}
else {
$cal = ($totalscore/$grandtotal);
$perc  =  round($cal*100,2);
$average = ($totalscore/$count);
$avg  =  round($average, 0);
$db->sql_query("UPDATE ".$prefix."_nquiz_league SET  count='$count', score = '$totalscore', average = '$avg', total ='$grandtotal', totalques='$gquestotal', perc ='$perc', updated = '1' WHERE username='$username'");
$grandtotal = $gquestotal = $perc = $average="";
}
$db->sql_query("UPDATE ".$prefix."_nquiz_config SET config_value = '$update' WHERE config_name='league_update'");
}
}
}
function quizfilesizepre($file){
$kb = 1024;         // Kilobyte
$mb = 1024 * $kb;   // Megabyte
$gb = 1024 * $mb;   // Gigabyte
$tb = 1024 * $gb;   // Terabyte
if($file < $kb) return $file." Bytes";
else if($file < $mb) return round($file/$kb,2)." KB";
else if($file < $gb) return round($file/$mb,2)." MB";
else if($file < $tb) return round($file/$gb,2)." GB";
else return round($file/$tb,2)." TB";
}
function nqsizeconv($kb){
$bytes = round($kb*1024,0);//Convert MB to Bytes ONLY
return round($bytes,0);
}
function quizdirsize($dir)
{
$dh = opendir($dir);
$size = 0;
while (($file = readdir($dh)) !== false)
{
if ($file != "." and $file != "..")
{
$path = $dir."/".$file;
if (is_dir($path))
{
$size += dirsize("$path/");
}
elseif (is_file($path))
{
$size += filesize($path);
}
}
}
closedir($dh);
return $size;
}
function nqremoveDir($path) {
if (substr($path, -1, 1) != "/") {
$path .= "/";
}
$normal_files = glob($path . "*");
$hidden_files = glob($path . "\.?*");
$all_files = array_merge($normal_files, $hidden_files);
foreach ($all_files as $file) {
if (preg_match("/(\.|\.\.)$/", $file))
{
continue;
}
if (is_file($file) === TRUE) {
unlink($file);
}
else if (is_dir($file) === TRUE) {
removeDir($file);
}
}
if (is_dir($path) === TRUE) {
rmdir($path);
}
}
function nqselectall(){
echo"
<script>
function checkedAll (id, checked) {
var el = document.getElementById(id);
for (var i = 0; i < el.elements.length; i++) {
el.elements[i].checked = checked;
}
}
</script>
";
}
function pageresults($pagenum, $totalpages, $max, $min){
global $admin_file;
$nqpagesint = ($totalpages / $pagenum);
$nqpageremain = ($totalpages % $pagenum);
if ($nqpageremain != 0) {
$nqpages = ceil($nqpagesint);
if ($totalpages < $pagenum) { $nqpageremain = 0; }
} else {
$nqpages = $nqpagesint;
}
if ($nqpages!=1 && $nqpages!=0) {
OpenTable();
$counter = 1;
$currentpage = ($max / $pagenum);
echo "<table align='center' border='0' cellpadding='2' cellspacing='2'>";
echo "<br><form action='".$admin_file.".php' method='post'>";
echo "<tr><td><b>"._NQ_SELECT."&nbsp;&nbsp;</b><select name='min' onChange='top.location.href=this.options[this.selectedIndex].value'>";
while ($counter <= $nqpages ) {
$cpage = $counter;
$mintemp = ($pagenum * $counter) - $pagenum;
if ($counter == $currentpage) {
echo "<option selected>$counter</option>";
} else {
echo "<option value='".$admin_file.".php?op=scoreboard&amp;min=$mintemp'>$counter</option>";
}
$counter++;
}
echo "</select><b>&nbsp;&nbsp;"._NQ_OF."&nbsp;$nqpages&nbsp;"._NQ_PAGES.".</b></td></tr>";
echo "</form></table>";           
CloseTable();
}
}
function pagesections($pagenum, $totalpages, $max, $min){
$nqpagesint = ($totalpages / $pagenum);
$nqpageremain = ($totalpages % $pagenum);
if ($nqpageremain != 0) {
$nqpages = ceil($nqpagesint);
if ($totalpages < $pagenum) { $nqpageremain = 0; }
} else {
$nqpages = $nqpagesint;
}
if ($nqpages!=1 && $nqpages!=0) {
OpenTable();
$counter = 1;
$currentpage = ($max / $pagenum);
echo "<center><br><table border='0' cellpadding='2' cellspacing='2'>";
echo "<tr><td><form action='modules.php?name=$module_name' method='post'>";
echo "<b>"._NQ_SELECTCAT."&nbsp;&nbsp;</b><select name='min' onChange='top.location.href=this.options[this.selectedIndex].value'>";
while ($counter <= $nqpages ) {
$cpage = $counter;
$mintemp = ($pagenum * $counter) - $pagenum;
if ($counter == $currentpage) {
echo "<option selected>$counter</option>";
} else {
echo "<option value='modules.php?name=$module_name&amp;op=nqshowsection&min=$mintemp'>$counter</option>";
}
$counter++;
}
echo "</select><b>&nbsp;&nbsp;"._NQ_OF."&nbsp;$nqpages&nbsp;"._NQ_TOTALCATS.".</b></td></tr>";
echo "</form></table><br><a href='modules.php?name=$module_name'>"._NQ_QUIZINDEX."</a></center><br>";
CloseTable();
}
}
function scorehistory(){
global $db, $prefix;
$result = $db->sql_query("SELECT sbid FROM ".$prefix."_nquiz_scoreboard WHERE score='0' AND endtime='0'");
while(list($sbid) = $db->sql_fetchrow($result)){
$db->sql_query("DELETE FROM ".$prefix."_nquiz_scoreboard WHERE sbid='$sbid'");
}
$db->sql_query("OPTIMIZE TABLE ".$prefix."_nquiz_scoreboard");
}
function pagequiz($pagenum, $totalpages, $max, $min){
global $admin_file;
$nqpagesint = ($totalpages / $pagenum);
$nqpageremain = ($totalpages % $pagenum);
if ($nqpageremain != 0) {
$nqpages = ceil($nqpagesint);
if ($totalpages < $pagenum) { $nqpageremain = 0; }
} else {
$nqpages = $nqpagesint;
}
if ($nqpages!=1 && $nqpages!=0) {
OpenTable();
$counter = 1;
$currentpage = ($max / $pagenum);
echo "<table align='center' border='0' cellpadding='2' cellspacing='2'>";
echo "<br><form action='".$admin_file.".php' method='post'>";
echo "<tr><td><b>"._NQ_SELECT."&nbsp;&nbsp;</b><select name='min' onChange='top.location.href=this.options[this.selectedIndex].value'>";
while ($counter <= $nqpages ) {
$cpage = $counter;
$mintemp = ($pagenum * $counter) - $pagenum;
if ($counter == $currentpage) {
echo "<option selected>$counter</option>";
} else {
echo "<option value='".$admin_file.".php?op=nqviewquizlist&amp;min=$mintemp'>$counter</option>";
}
$counter++;
}
echo "</select><b>&nbsp;&nbsp;"._NQ_OF."&nbsp;$nqpages&nbsp;"._NQ_PAGES.".</b></td></tr>";
echo "</form></table>";           
CloseTable();
}
}
function pageleague($pagenum, $totalpages, $max, $min){
global $admin_file;
$nqpagesint = ($totalpages / $pagenum);
$nqpageremain = ($totalpages % $pagenum);
if ($nqpageremain != 0) {
$nqpages = ceil($nqpagesint);
if ($totalpages < $pagenum) { $nqpageremain = 0; }
} else {
$nqpages = $nqpagesint;
}
if ($nqpages!=1 && $nqpages!=0) {
OpenTable();
$counter = 1;
$currentpage = ($max / $pagenum);
echo "<table align='center' border='0' cellpadding='2' cellspacing='2'>";
echo "<br><form action='".$admin_file.".php' method='post'>";
echo "<tr><td><b>"._NQ_SELECT."&nbsp;&nbsp;</b><select name='min' onChange='top.location.href=this.options[this.selectedIndex].value'>";
while ($counter <= $nqpages ) {
$cpage = $counter;
$mintemp = ($pagenum * $counter) - $pagenum;
if ($counter == $currentpage) {
echo "<option selected>$counter</option>";
} else {
echo "<option value='".$admin_file.".php?op=nqleague&amp;min=$mintemp'>$counter</option>";
}
$counter++;
}
echo "</select><b>&nbsp;&nbsp;"._NQ_OF."&nbsp;$nqpages&nbsp;"._NQ_PAGES.".</b></td></tr>";
echo "</form></table>";           
CloseTable();
}
}
function nqgdchk() {
if (extension_loaded("gd")) {
if (phpversion() >= "4.3.0") {
$gi = gd_info();
$gi1 = $gi['GD Version'];
$gi2 = $gi['FreeType Support'];
if ($gi2) { $gi2 = ""._YES.""; } else { $gi2 = ""._NO.""; }
$gi3 = $gi['T1Lib Support'];
if ($gi3) { $gi3 = ""._YES.""; } else { $gi3 = ""._NO.""; }
$gi4 = $gi['GIF Read Support'];
if ($gi4) { $gi4 = ""._YES.""; } else { $gi4 = ""._NO.""; }
$gi5 = $gi['GIF Create Support'];
if ($gi5) { $gi5 = ""._YES.""; } else { $gi5 = ""._NO.""; }
$gi6 = $gi['JPG Support'];
if ($gi6) { $gi6 = ""._YES.""; } else { $gi6 = ""._NO.""; }
$gi7 = $gi['PNG Support'];
if ($gi7) { $gi7 = ""._YES.""; } else { $gi7 = ""._NO.""; }
$gi8 = $gi['WBMP Support'];
if ($gi8) { $gi8 = ""._YES.""; } else { $gi8 = ""._NO.""; }
$gi9 = $gi['XBM Support'];
if ($gi9) { $gi9 = ""._YES.""; } else { $gi9 = ""._NO.""; }
} else { 
$gi = my_gd_info(); 
$gi1 = $gi['GD Version']; 
$gi2 = $gi['FreeType Support']; 
if ($gi2) { $gi2 = ""._YES.""; } else { $gi2 = ""._NO.""; } 
$gi3 = $gi['T1Lib Support']; 
if ($gi3) { $gi3 = ""._YES.""; } else { $gi3 = ""._NO.""; } 
$gi4 = $gi['GIF Read Support']; 
if ($gi4) { $gi4 = ""._YES.""; } else { $gi4 = ""._NO.""; } 
$gi5 = $gi['GIF Create Support']; 
if ($gi5) { $gi5 = ""._YES.""; } else { $gi5 = ""._NO.""; } 
$gi6 = $gi['JPG Support']; 
if ($gi6) { $gi6 = ""._YES.""; } else { $gi6 = ""._NO.""; } 
$gi7 = $gi['PNG Support']; 
if ($gi7) { $gi7 = ""._YES.""; } else { $gi7 = ""._NO.""; } 
$gi8 = $gi['WBMP Support']; 
if ($gi8) { $gi8 = ""._YES.""; } else { $gi8 = ""._NO.""; } 
$gi9 = $gi['XBM Support']; 
if ($gi9) { $gi9 = ""._YES.""; } else { $gi9 = ""._NO.""; } 
} 
OpenTable();
echo "<center><br><table cellspacing='1' cellpadding='3' cellspacing='3' border='0'>";
echo "<tr><td align='center' colspan='3'><font class='title'>"._NQ_GDVERCHECKER."</font></td></tr><tr>"; 
echo "<tr><td>"._NQ_GDVER."</td><td>$gi1</td></tr><tr><td>"._NQ_FREESUPPORT."</td><td>$gi2</td></tr><tr>";                  
echo "<td>T1 Lib Support</td><td>$gi3</td></tr><tr><td>"._NQ_GIFSUPPORT."</td><td>$gi4</td></tr>";
echo "<tr><td>"._NQ_GIFCREATE."</td><td>$gi5</td></tr><tr><td>"._NQ_JPGSUPPORT."</td><td>$gi6</TD>";
echo "</tr><tr><td>"._NQ_PNGSUPPORT."</td><td>$gi7</td></tr><tr>";
echo "<td>WBMP Support</td><td>$gi8</td></tr><tr><td>XBM Support</td><td>$gi9</td></tr></table><br><br>"._GOBACK."<br><br></center>";
CloseTable();
} else {
OpenTable();      	       
echo "<center><table cellspacing='1' cellpadding='3' cellspacing='2' border='0'>";
echo "<tr><td>Extension Status</td></tr><tr><td>Not-Loaded</td></tr></table><br><br>"._GOBACK."</center><br><br>";
CloseTable();	                
}
}
function nqmakedir() {
$cons = "bcdfghjklmnpqrstvwxyz";
$vocs = "aeiou";
for ($x=0; $x < 6; $x++) {
mt_srand ((double) microtime() * 1000000);
$con[$x] = substr($cons, mt_rand(0, strlen($cons)-1), 1);
$voc[$x] = substr($vocs, mt_rand(0, strlen($vocs)-1), 1);
}
mt_srand((double)microtime()*1000000);
$num1 = mt_rand(0, 9);
$num2 = mt_rand(0, 9);
$num3 = mt_rand(0, 9);
$num4 = mt_rand(0, 9);
$makedir = $num1. $con[0] . $voc[0] .$con[2] . $con[1] . $num4 . $num2 . $con[3] . $voc[3] . $con[4]. $con[1] . $num3;
return($makedir);
}
function nquizimage($module_name, $imgfile) {
$ThemeSel = get_theme();
if (file_exists("themes/$ThemeSel/images/$module_name/$imgfile")) {
$nqimage = "themes/$ThemeSel/images/$module_name/$imgfile";
} else {
if (!isset($module_name)){
$nqimage = "images/$imgfile";
}
else{
$nqimage = "modules/$module_name/images/$imgfile";
}
}
return($nqimage);
}
function install_temp(){
global $db, $prefix;
$checktable = $db->sql_fetchrow($db->sql_query("SHOW TABLES LIKE '".$prefix."_nquiz_temp'"));
if ($checktable > 0) {
$db->sql_query("DROP TABLE ".$prefix."_nquiz_temp");
}
else{
$result = $db->sql_query("CREATE TABLE ".$prefix."_nquiz_temp (quesid int(11) NOT NULL auto_increment, oqid int(10) NOT NULL default '0', qid int(10) NOT NULL default '0', ismcq int(1) NOT NULL default '0', ismultiple int(1) NOT NULL default '0', isoe int(1) NOT NULL default '0', question text NOT NULL, sol1 text NOT NULL, sol2 text NOT NULL, sol3 text NOT NULL, sol4 text NOT NULL, answer text NOT NULL, points int(5) NOT NULL default '0', qexplain text NOT NULL, file varchar(255) NOT NULL default '', hit_count int(5) NOT NULL default '0', PRIMARY KEY (quesid))");
}
}
?>
Return current item: Nukequiz