Location: PHPKode > projects > Nukequiz > html/modules/Nukequiz/admin/NQASaveNewQuiz.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	 */
/*****************************************************************/
if(isset($emailadmin)) $emailadmin=1; else $emailadmin=0;
if(isset($emailuser)) $emailuser=1; else $emailuser=0;
if(isset($limit)) $limit=1; else $limit=0;
if(isset($active)) $act=1; else $act=0;
if(isset($view)) $view=1; else $view=0;
if(isset($iscq)) $iscq=1; else $iscq=0;
if(isset($arq)) $arq=1; else $arq=0;
$randques = intval($randques);
$expire = $newyear."-".$newmonth."-".$newday." ".$newhour.":".$newmin.":00";
if ($expire == "0000-00-00 00:00:00") { $edate = 0; } else { $edate = strtotime($expire); }
$title = stripslashes(FixQuotes($title));
if(!$db->sql_query("INSERT INTO ".$prefix."_nquiz_quiz VALUES (NULL,'$sid','$act','$iscq','','','','$title','$emailadmin', '$randomise', '$emailuser','$limit', '$view', '$edate','0', '0', '0', '0', '0', '$adminemail')")) {
die (""._NQ_DBERRORTABLE."_nquiz_quiz");
}
$temp_array = mysql_fetch_array($db->sql_query("SELECT last_insert_id() FROM ".$prefix."_nquiz_quiz"));
$last = $temp_array['last_insert_id()'];
$imagesdir = $nq_config['images_directory'];
$newdir = nqmakedir();
$db->sql_query("UPDATE ".$prefix."_nquiz_quiz SET dir='$newdir' WHERE qid='$last'");
$old_umask = umask(0);
$path = "modules/$module_name/$imagesdir";
$main_dir = "modules/$module_name/$imagesdir";
if (!file_exists("$main_dir")) {
mkdir("$main_dir", 0777);
}
$upload_dir = "modules/$module_name/$imagesdir/$newdir";
$path = "$upload_dir";
if (!file_exists("$upload_dir")) {
mkdir("$upload_dir", 0777);
}
$thumbs_dir = "modules/$module_name/$imagesdir/$newdir/thumbs";
$path = "$upload_dir";
if (!file_exists("$thumbs_dir")) {
mkdir("$thumbs_dir", 0777);
}
$source_file = "modules/$module_name/images/index.html";
$destination_file = "modules/$module_name/$imagesdir/$newdir/index.html";
copy ($source_file, $destination_file);
$source_file = "modules/$module_name/images/th_sound.png";
$destination_file = "modules/$module_name/$imagesdir/$newdir/thumbs/th_sound.png";
copy ($source_file, $destination_file);
umask($old_umask);
//###############Add import questions if set!!
if ($arq == '1' && $randques > '0'){
$db->sql_query("UPDATE ".$prefix."_nquiz_quiz SET maxqnum='$randques' WHERE qid='$last'");
install_temp();
$totalques = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_nquiz_questions"));
$randques = $randques+5;
for ($i=1; $i <= $randques; $i++) { 
$offset = rand(0, $totalques - 1); 
$result = $db->sql_query("SELECT * FROM ".$prefix."_nquiz_questions WHERE quesid='$offset'");
list($quesid, $qid, $ismcq, $ismultiple, $isoe, $question, $sol1, $sol2, $sol3, $sol4, $answer, $points, $qexplain, $quesfile, $hitcount) = $db->sql_fetchrow($result);
$db->sql_query("INSERT INTO ".$prefix."_nquiz_temp VALUES (NULL, $qid, '$last', '$ismcq', '$ismultiple', '$isoe', '$question', '$sol1', '$sol2', '$sol3', '$sol4', '$answer', '$points', '$qexplain', '$quesfile', '0')");
}
}
Header("Location: ".$admin_file.".php?op=nqviewquizlist");
?>
Return current item: Nukequiz