Location: PHPKode > projects > Nukequiz > html/modules/Nukequiz/admin/NQAUploadQuestions.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	 */
/*****************************************************************/
$pagetitle = _NQ_ADMINUPLOADQUESTIONS;
include ("header.php");
nqmenuheader();
$upload_dir = "modules/$module_name/import/";///Upload Directory for questions import
$num_files = $nq_config['uploads'];
$size_bytes = 51200; //= 50KB.
$limitedext = array(".csv",".txt");
if (!is_dir("$upload_dir")) {
$old_umask = umask(0);
mkdir("$upload_dir", 0777);
OpenTable();
echo "<center><b>"._NQ_FOLDERCHECK."</b><br>($upload_dir)</center>";
umask($old_umask); 
CloseTable();
include("footer.php");
exit();
}
if (!is_writeable("$upload_dir")){
$old_umask = umask(0);
chmod($upload_dir, 0777);
echo "<center><b>"._NQ_FOLDERCHECK."</b><br>($upload_dir)</center>";
umask($old_umask); 
CloseTable();
include("footer.php");
exit();
}
if($submitted == '1'){
OpenTable();
echo "<br><center><font class='title'>"._NQ_UPLOADRESULTS."</font>";
echo "<br><br>[&nbsp;$upload_dir&nbsp;]<br><br></center>";
echo "<center><table cellpadding='2' cellspacing='2' border='0'><tr>";
for ($i = 1; $i <= $num_files; $i++) {
$new_file = $_FILES['file'.$i];
$file_name = $new_file['name'];
$file_name = str_replace(' ', '_', $file_name);
$file_tmp = $new_file['tmp_name'];
$file_size = $new_file['size'];
$max=quizfilesizepre($file_size);
if (!is_uploaded_file($file_tmp)) {
echo "<td><b>$i.</b></td><td colspan='3'>"._NQ_NOFILESELECTED."</td></tr>";
}else{
$ext = strrchr($file_name,'.');
if (!in_array(strtolower($ext),$limitedext)) {
echo "<td><b>$i.</b></td><td>$file_name</td><td>$max</td><td>"._NQ_ERRORFILETYPE."</td></tr>";
}else{
if ($file_size > $size_bytes){
echo "<td><b>$i.</b></td><td>$file_name</td><td>$max</td><td>"._NQ_OVERSIZE."</td></tr>";
}else{
if(file_exists($upload_dir.$file_name)){
echo "<td><b>$i.</b></td><td>$file_name</td><td>$max</td><td>"._NQ_ALEXISTSOVERWRITTEN."</td></tr>";
}else{
if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {
echo "<td><b>$i.</b></td><td>$file_name</td><td>$max</td><td>"._NQ_UPLOADSUCCESS."</td></tr>";
}else{
echo "<td><b>$i.</b></td><td colspan='3'>"._NQ_FAILED."</td></tr>";
}#
}#
}#
}#
}#
}#
echo "</table><br>";
echo "<center>[&nbsp;<a href='".$admin_file.".php?op=nquploadquestions'>"._NQ_OK."</a>&nbsp;]</center><br>";
CloseTable();
include("footer.php");
}
else{
OpenTable();
$path = "modules/$module_name/import/";
$fsize=5242880;  // In Bytes (5M quota)
$total= quizdirsize($path);
$total1= quizfilesizepre($total);
$freespace = $fsize - $total;
$freespace=quizfilesizepre($freespace);
$fsize= quizfilesizepre($fsize);
$msize= quizfilesizepre($size_bytes);
echo "<br><center>".quizhelp_img(_NQ_HELPQUIZFILESUPLOAD)."&nbsp;<b>"._NQ_UPLOADTO."</b><br><br>";
echo "<center>[&nbsp;$path&nbsp;]<br><br></center>";
echo "<form method='post' action='$_SERVER[PHP_SELF]' enctype='multipart/form-data'>";
echo "<input type='hidden' name='submitted' value='1'>";
echo "<input type='hidden' name='op' value='nquploadcompleted'>";
echo "<input type='hidden' name='title' value='$title'>";
echo "<center><table cellpadding='4' cellspacing='4' border='0'><tr>";
echo "<td colspan='2' align='center'>$total1 "._NQ_FREE." $freespace "._NQ_OUTOF." $fsize</td></tr><tr>";
echo "<td colspan='2' align='center'><b>"._NQ_ALLOWED."&nbsp;:&nbsp;</b>$limitedext[0] & $limitedext[1]";
echo "</td></tr><tr>";
echo "<td colspan='2' align='center'><b>"._NQ_MAXFSIZE." = $msize</b></td></tr><tr>";
for ($i = 1; $i <= $num_files; $i++) {
echo "<td>"._NQ_FILENAME." $i</td><td><input type='file' name=\"file". $i ."\"></td></tr><tr>";
}
echo "<td colspan='2' align='center'><input type='submit' value='"._NQ_UPLOADF."'></td>";
echo "</form></tr></table><br></center>";
CloseTable();
include("footer.php");
}
?>
Return current item: Nukequiz