"; $download = new Download; if(array_key_exists('do_choose', $_POST)) if ($_POST['do_choose'] && !strcmp($_POST['file'], "")) { _e("No file Chosen.
\n", $i18n_domain); } else if ($_POST['do_choose']) { $file = $_POST['file']; if (!$download->insert($file)) { wp_die( __('An error occurred while trying to perform the insert query.', $i18n_domain) ); } else { // successfully inserted file to upload printf( __("File added to the database: '%s'
\n", $i18n_domain), $file); } echo '
'; } else if($_POST['do_select']) { $num = $download->loadAll()->getTotalRows(); // read files from DB for($i = 0; $i < $num; $i++) { $files_db[$i]['id'] = $download->id; $files_db[$i]['file_name'] = $download->file_name; } echo "
"; // read files from $download_path // don't display files if we already added them to the database if ($handle = opendir($download_path)) { while (false !== ($file = readdir($handle))) { if(!strcmp($file, ".") || !strcmp($file, "..")) continue; $found = false; for ($i = 0; $i < $num; $i++) { if(!strcmp($files_db[$i]['file_name'], $file)) { $id = $files_db[$i]['id']; // do not display $found = true; } } if($found != true && !is_dir($file)) { // is it already in the database, and is this a directory or a file? echo "\n"; } } // end while closedir($handle); echo '
$file [" .round(((filesize($download_path . $file) / 1024) / 1024), 2). " MB]
'; } } else { echo '
'; } ?>