function get_files($directory) { // Try to open the directory if ($dir = opendir($directory)) { // Create an array for all files found $tmp = array(); // Add the files while ($file = readdir($dir)) { // Make sure the file exists if ($file != "." && $file != ".." && $file[0] != '.') { // If it's a directiry, list all files within it if (is_dir($directory . "/" . $file)) { $tmp2 = get_files($directory . "/" . $file); if (is_array($tmp2)) { $tmp = array_merge($tmp, $tmp2); } } else { if (is_readable($directory . "/" . $file)) { $filename = basename(stripslashes($file)); $pi = pathinfo($file); if (is_allowed_extension($pi["extension"])) { array_push($tmp, $directory . "/" . $file); } } } } } // Finish off the function closedir($dir); return $tmp; } }
} } if (empty($errors)) { // Let's redirect to the import interface. header('location: plog-import.php?directory=' . $zipdirkey); exit; } else { $output .= "\n\t" . '<p class="errors">' . plog_tr('There were some problems importing the files') . ':<br /><br />' . "\n"; foreach ($errors as $e) { $output .= $e['stored_filename'] . ': ' . $e['status'] . '<br />'; } $output .= '<br />' . sprintf(plog_tr('You can proceed to the <a href="%s">Import</a> section to view any files that were successfully uploaded'), 'plog-import.php') . '.</p>' . "\n"; } } } else { if (!is_allowed_extension($pi['extension'])) { $output .= "\n\t" . '<p class="errors">' . plog_tr('Plogger cannot handle this type of file') . '.</p>' . "\n"; } else { if ($_FILES['userfile']['error'] == 1) { $output .= "\n\t" . '<p class="errors">' . plog_tr('File exceeded upload filesize limit') . '!</p>' . "\n"; } else { if ($_FILES['userfile']['size'] == 0) { $output .= "\n\t" . '<p class="errors">' . plog_tr('File does not exist') . '!</p>' . "\n"; } else { if (!isset($_REQUEST['destination_radio'])) { $output .= "\n\t" . '<p class="errors">' . plog_tr('No destination album specified') . '!</p>' . "\n"; } else { if ($_REQUEST['destination_radio'] == 'new' && $_REQUEST['new_album_name'] == '') { $output .= "\n\t" . '<p class="errors">' . plog_tr('New album name not specified') . '!</p>' . "\n"; } else { if ($_REQUEST['destination_radio'] == 'new') {
if ($exttype == 'image') { $allowedExtensions = array('jpg', 'JPG', 'jpeg', 'JPEG', 'png', 'PNG'); } else { if ($exttype == 'srt') { $allowedExtensions = array('srt', 'SRT'); } } } } if (!iserror()) { if ($pro == 1 && empty($_FILES['myfile'])) { $errorcode = 13; } else { $file = $_FILES['myfile']; if (no_file_upload_error($file)) { if (is_allowed_extension($file)) { if (!filesizeexceeds($file)) { doupload($file); } } } } } /** * Check the error occur in the upload the files or not * @return boolean */ function iserror() { global $error; global $errorcode;
} else { /** Else file is moved then set error code as 4 */ $errorcode = 4; } /** Sleep 1ms */ sleep(1); } if (!iserror()) { /** Set error message, if the upload and post max size is less than the upload file size */ if ($pro == 1 && empty($_FILES['myfile'])) { $errorcode = 13; } else { /** Get upload file information */ $file = $_FILES['myfile']; /** Check whether the upload file type is in the given extension and checks its limit */ if (no_file_upload_error($file) && is_allowed_extension($file) && !filesizeexceeds()) { /** Call function to perform upload action */ doupload($file); } } } /** Script to display error message while uploading */ ?> <script language='javascript' type='text/javascript'> window.top.window.updateQueue( <?php echo balanceTags($errorcode); ?> , '<?php echo balanceTags($errormsg[$errorcode]); ?>
function get_files($directory, $get_all_files = false, $get_folders = false, $relative_path = false) { global $config; $sep = substr($directory, -1) == '/' ? '' : '/'; // Try to open the directory if ($dir = opendir($directory)) { // Create an array for all files found $tmp = array(); // Create an array for all folders found (if set) $tmp_folders = array(); // Add the files while ($file = readdir($dir)) { // Make sure the file exists if ($file != '.' && $file != '..') { if (!$get_folders) { if ($file[0] == '.') { continue; } } // If it's a directory, list all files within it if (is_dir($directory . $sep . $file)) { $tmp2 = get_files($directory . $sep . $file, $get_all_files, $get_folders, $relative_path); if (is_array($tmp2)) { if (!isset($tmp2['files'])) { $tmp = array_merge($tmp, $tmp2); } else { $tmp = array_merge($tmp, $tmp2['files']); $tmp_folders = array_merge($tmp_folders, $tmp2['folders']); } } if ($get_folders) { if (!$relative_path) { $tmp_folders[] = $directory . $sep . $file; } else { $tmp_folders[] = str_replace($relative_path, '', $directory . $sep . $file); } } } else { if (is_readable($directory . $sep . $file)) { $filename = basename(stripslashes($file)); $pi = pathinfo($file); if (is_allowed_extension($pi['extension']) || $get_all_files) { if (!$relative_path) { $tmp[] = $directory . $sep . $file; } else { $tmp[] = str_replace($relative_path, '', $directory . $sep . $file); } } } } } } // Finish off the function closedir($dir); sort($tmp); if ($get_folders) { $return = array(); // Reverse the order of folders so subfolders come first krsort($tmp_folders); $return['files'] = $tmp; $return['folders'] = $tmp_folders; return $return; } return $tmp; } }
} if (empty($errors)) { // let's redirect to the import interface. header("location: plog-import.php?directory=bda1146671668d77b2da21c84146056a"); exit; } else { $output .= '<p class="errors">'; $output .= plog_tr('There were some problems importing the files:') . '<br/><br />'; foreach ($errors as $e) { $output .= $e["stored_filename"] . ": " . $e["status"] . '<br />'; } $output .= '<br />' . sprintf(plog_tr('You can proceed to the <a href="%s">Import</a> section to view any files that were successfully uploaded.'), "plog-import.php") . '</p>'; } } } else { if (!is_allowed_extension($pi["extension"])) { $output .= '<p class="errors">' . plog_tr('Plogger cannot handle this type of file') . '</p>'; } else { if ($_FILES['userfile']['size'] == 0) { $output .= '<p class="errors">' . plog_tr('File does not exist!') . '</p>'; } else { if (!isset($_REQUEST["destination_radio"])) { $output .= '<p class="errors">' . plog_tr('No destination album specified!') . '</p>'; } else { if ($_REQUEST["destination_radio"] == "new" && $_REQUEST["new_album_name"] == "") { $output .= '<p class="errors">' . plog_tr('New album name not specified!') . '</p>'; } else { if ($_REQUEST["destination_radio"] == "new") { // Create the new album $result = add_album(mysql_escape_string($_REQUEST["new_album_name"]), NULL, $_REQUEST["collections_menu"]); $album_id = $result["id"];