Location: PHPKode > projects > Nukequiz > html/root/nq_installer/export150-250.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	 */
/*****************************************************************/
//Language Definitions You May Want To Edit
define("_NQ_FAILED","<b><font color='#CC0000'>&nbsp;Failed</font></b>");
define("_NQ_OK","<b><font color='#00CC00'>&nbsp;Completed</font></b>");
define("_NQ_ALTERTABLE","<b>&loz;&nbsp;Alter Table&nbsp;</b>");
define("_NQ_CREATIONOF","<b>&loz;&nbsp;Creation Of Table&nbsp;</b>");
define("_NQ_DATA4","<b>&loz;&nbsp;Data For&nbsp;</b>");
define("_NQ_EXPORTED","Exported Filename");
define("_NQ_ADMIN","Nukequiz Administration");
define("_NQ_EXPORTEDNOTE","You Can Now Download Each Quiz Set By Clicking On The Link Before Proceeding");
define("_NQ_INSTALLNOTE","Then You Can Then "._GOBACK." And Use The Install Option From The Installer");
//////////////////////////////////////////////////////Do Not Edit Below
$pagetitle = "&copy;&nbsp;Nukequiz Installer";
$module_name = 'Nukequiz';
include_once("includes/functions_nukequiz.php");
include_once("archive.php");
@include("header.php");
$temp = $db->sql_query("CREATE TABLE ".$prefix."_nquiz_temp (nid int(3) NOT NULL  auto_increment, filename varchar(150) NOT NULL default '', PRIMARY KEY (nid))");
OpenTable();
echo "<center><table cellpadding='4' cellspacing='4' border='0'><tr><td align='center' colspan='3'>";
echo "<b>$pagetitle</b></td></tr><tr>";
$search = array(",", "'", "<br/>", "<br>", ";");
$replace  = array("{COMMA}" , "\'", "", "", "{SEMICOLON}");
$resulta = $db->sql_query("SELECT qid, title FROM ".$prefix."_nquiz_quiz");
while(list($qid, $title) = $db->sql_fetchrow($resulta)){
$title = str_replace($search, '', $title);
$title = str_replace(" ", "_", $title);
$oldquiz_dir = "$title";///temp export directory
if (!file_exists("$oldquiz_dir")) {
$old_umask = umask(0);
mkdir("$oldquiz_dir", 0777);
}
$qid = intval($qid);
echo "<td>$title</td>";
$export_title = str_replace(" ", "_", $title);
$fp = fopen("$title/$export_title.csv","a");
$result_ques = $db->sql_query("SELECT quesid, question, qid, answer, points, qexplain, image, sound FROM ".$prefix."_nquiz_questions WHERE qid='$qid'");
while(list($quesid, $question, $quizid, $answer, $points, $qexplain, $image, $sound) = $db->sql_fetchrow($result_ques)){
$points = intval($points);
$answer = intval($answer);
$question_id = intval($quesid);
$qexplain = ucwords(strtolower($qexplain));
$question = ucwords(strtolower($question));
$question = str_replace($search, $replace, $question);
$qexplain = str_replace($search, $replace, $qexplain);
fwrite($fp,"1,0,0,$question,");
$answers = $db->sql_query("SELECT quesid, optionText, orderid FROM ".$prefix."_nquiz_answers WHERE quesid='$question_id' ORDER BY orderid ASC");
while(list($ans_quesid, $answer_option, $oid) = $db->sql_fetchrow($answers)){
$answer_option = ucwords(strtolower($answer_option));
$answer_option = str_replace($search, $replace, $answer_option);
fwrite($fp,"$answer_option,");
}##list answers
if ($qexplain == ''){$qexplain = 'No Explanation Given';} else {$qexplain = $qexplain;}
if ($image == '' || $image=='blank.gif'){$image = 'None';} else {$image = $image;}
$imagesource_file = "modules/Nukequiz/quiz_images/$image";
$imagedestination_file = "$title/$image";
copy ($imagesource_file, $imagedestination_file);
fwrite($fp,"$answer,$points,$qexplain,$image\n");
}##list questions
fclose($fp);
echo "<td><a href='Questions_$title.zip'>Questions_$title.zip</a></td><td>&nbsp;"._NQ_OK."</td></tr>";
$db->sql_query("INSERT INTO ".$prefix."_nquiz_temp VALUES (NULL,'$title')");
}##list quiz titles
$r=$db->sql_query("SELECT filename FROM ".$prefix."_nquiz_temp");
while (list($filename) = $db->sql_fetchrow($r)){
$folderpath = "$filename";
$name ="Questions_$filename.zip";
$z = new PHPZip();
$z -> Zip($folderpath, $name); 
removeDir("$filename");
}
$db->sql_query("DROP TABLE ".$prefix."_nquiz_config");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_scoreboardhistory");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_subanswers");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_subquestions");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_compquestion");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_compresults");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_quiz");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_league");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_answers");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_sections");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_scoreboard");
$db->sql_query("DROP TABLE ".$prefix."_nquiz_questions");
echo "<td colspan='3' align='center'><b>"._NQ_EXPORTEDNOTE."</b></td></tr><tr>";
echo "<td colspan='3' align='center'><b>"._NQ_INSTALLNOTE."</b></td></tr><tr>";
echo "</td></tr></table></center>";
CloseTable();
@include("footer.php");
?>
Return current item: Nukequiz