function amr_ical_uninstall() { if (function_exists('delete_option')) { // delete all options we may have used over time delete_option('amr-ical-calendar_preview_url'); delete_option('amr-ical-events-version'); delete_option('amr-ical-events-list'); delete_option("amricalWidget"); delete_option("amr-ical-widget"); delete_option('amr-ical-images-to-use'); echo '<p>' . __('amr ical options deleted from database', 'amr-ical-events-list') . '</p>'; unlink(); // now look for and delete cache files in upload dir $upload_dir = wp_upload_dir(); $dir_to_delete = $upload_dir . '/ical-events-cache/'; $files = list_files($dir_to_delete); if ($files) { $files_to_delete = array_merge($files_to_delete, $files); } $deleted = $wp_filesystem->delete($dir_to_delete, true); // delete recurively echo '<p>' . __('amr ical cached ics files deleted ', 'amr-ical-events-list') . '</p>'; echo '<p>' . __('Css files may also exist. They and the css folder have not been deleted as they have been shared with other plugins.', 'amr-ical-events-list') . '</p>'; $cssdir = $upload_dir . '/css/'; $files = list_files($cssdir); foreach ($files as $i => $file) { echo '<br />' . $file; } } else { echo '<p>Wordpress Function delete_option does not exist.</p>'; return false; } }
function list_files($dir) { $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "myDB"; try { $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $dizin = opendir($dir); while ($dosya = readdir($dizin)) { if (strpos($dosya, '.') !== FALSE) { if ($dosya != "." && $dosya != "..") { $name = $dir . "/" . $dosya; $sql = "SELECT name FROM dizinler WHERE name = '" . $name . "' "; $result = $conn->query($sql); if (!($result->num_rows > 0)) { echo $name . " - bu dosya onceki veritabaninde yok kontrol etmek isteyebilirsiniz.</br>"; } } } else { if ($dosya != "." && $dosya != "..") { list_files($dir . "/" . $dosya . ""); } } } $conn->close(); } catch (Exception $e) { echo "Hata :"; } }
function list_files($dir, $follow_links) { $result = array(); if (TRUE == is_dir($dir)) { $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { if (TRUE == is_dir($dir . DIRECTORY_SEPARATOR . $file)) { $result = array_merge(list_files($dir . DIRECTORY_SEPARATOR . $file, $follow_links), $result); } else { if (TRUE == is_file($dir . DIRECTORY_SEPARATOR . $file)) { $result[] = $dir . DIRECTORY_SEPARATOR . $file; } else { if (TRUE == is_link($dir . DIRECTORY_SEPARATOR . $file)) { if (TRUE == $follow_links) { if (TRUE == is_file(readlink($dir . DIRECTORY_SEPARATOR . $file))) { $result[] = readlink($dir . DIRECTORY_SEPARATOR . $file); } else { if (TRUE == is_dir(readlink($dir . DIRECTORY_SEPARATOR . $file))) { $result = array_merge(list_files(readlink($dir . DIRECTORY_SEPARATOR . $file), $follow_links), $result); } } } } } } } } return $result; }
function list_files($dir) { $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "myDB"; try { $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $dizin = opendir($dir); while ($dosya = readdir($dizin)) { if (strpos($dosya, '.') !== FALSE) { if ($dosya != "." && $dosya != "..") { $name = $dir . "/" . $dosya; $sql = "INSERT INTO dizinler (name) VALUES ('" . $name . "')"; if ($conn->query($sql) === TRUE) { echo "OK : " . $name . "</br>"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } } else { if ($dosya != "." && $dosya != "..") { list_files($dir . "/" . $dosya . ""); } } } $conn->close(); } catch (Exception $e) { echo "Hata :"; } }
/** * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep. * The depth of the recursiveness can be controlled by the $levels param. * * @since 2.6.0 * * @param string $folder Full path to folder * @param int $levels (optional) Levels of folders to follow, Default: 100 (PHP Loop limit). * @return bool|array False on failure, Else array of files */ function list_files($folder = '', $levels = 100) { if (empty($folder)) { return false; } if (!$levels) { return false; } $files = array(); if ($dir = @opendir($folder)) { while (($file = readdir($dir)) !== false) { if (in_array($file, array('.', '..'))) { continue; } if (is_dir($folder . '/' . $file)) { $files2 = list_files($folder . '/' . $file, $levels - 1); if ($files2) { $files = array_merge($files, $files2); } else { $files[] = $folder . '/' . $file . '/'; } } else { $files[] = $folder . '/' . $file; } } } @closedir($dir); return $files; }
function get_download_files() { $base_dir = 'attachment/downloads'; $files = list_files($base_dir, "", 0, false); $retval = array(); foreach ($files as $file) { $retval[$file] = $file; } return $retval; }
function get_template_files() { $base_dir = 'include/mailtemplates'; $files = list_files($base_dir, ".tpl", 1, 0); $retval = array(); foreach ($files as $file) { $retval[$file] = $file; } return $retval; }
function get_font_files() { global $config; $base_dir = $config['homedir'] . '/include/fonts'; $files = list_files($base_dir, ".ttf", 1, 0); $retval = array(); foreach ($files as $file) { $retval[$config['homedir'] . 'include/fonts/' . $file] = $file; } return $retval; }
function get_logo_files() { $base_dir = 'images/custom_logos'; $files = list_files($base_dir, ".png", 1, 0); $files = array_merge($files, list_files($base_dir, ".jpg", 1, 0)); $files = array_merge($files, list_files($base_dir, ".gif", 1, 0)); $retval = array(); foreach ($files as $file) { $retval["custom_logos/{$file}"] = $file; } return $retval; }
/** * Constructor * Loads the spam rules from the admin/resources/spam_rules directory. * * @return Void Does not return anything. */ public function __construct() { $spam_rule_files = list_files(SENDSTUDIO_RESOURCES_DIRECTORY . '/spam_rules'); foreach ($spam_rule_files as $spam_rule) { $filename_parts = pathinfo($spam_rule); if (isset($filename_parts['extension']) && $filename_parts['extension'] == 'php') { require(SENDSTUDIO_RESOURCES_DIRECTORY . '/spam_rules/' . $spam_rule); } } $this->rules = &$GLOBALS['Spam_Rules']; }
function list_files($dir) { $result = array(); if (is_dir($dir) === TRUE) { $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { if (is_dir("{$dir}/{$file}") === TRUE) { $result = array_merge(list_files("{$dir}/{$file}"), $result); } else { $result[] = "{$dir}/{$file}"; } } } return $result; }
function list_files($dir) { $result = array(); if (TRUE === is_dir($dir)) { $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { if (TRUE === is_dir($dir . DIRECTORY_SEPARATOR . $file)) { $result = array_merge(list_files($dir . DIRECTORY_SEPARATOR . $file), $result); } else { $result[] = $dir . DIRECTORY_SEPARATOR . $file; } } } return $result; }
function list_files($dir) { $dizin = opendir($dir); while ($dosya = readdir($dizin)) { if (strpos($dosya, '.') !== FALSE) { if ($dosya != "." && $dosya != "..") { $name = $dir . "/" . $dosya; kontrolEt(file_get_contents($name), $name); } } else { if ($dosya != "." && $dosya != "..") { list_files($dir . "/" . $dosya . ""); } } } }
function upload($the_file) { global $the_path, $the_file_name; $error = validate_upload($the_file); if ($error) { form($error); } else { # cool, we can continue if (!@copy($the_file, $the_path . $the_file_name)) { form("\n<b>Error, check the path to and the permissions for the upload directory</b>"); } else { chmod($the_path . $the_file_name, 0755); list_files(); form(); } } }
/** * List files recursivly and scan them * * @return bool */ function list_files($prefix, $path, &$userdata) { if (is_dir($prefix . $path) && is_resource($handle = @opendir($prefix . $path))) { while ($name = readdir($handle)) { if (strpos($name, ".xml") !== false) { scan_file($prefix, $path . $name, $userdata); } else { if (is_dir($prefix . $path . $name) && $name !== 'CVS' && $name !== '.' && $name !== '..') { list_files($prefix, $path . $name . DIRECTORY_SEPARATOR, $userdata); } } } closedir($handle); return true; } else { return false; } }
function main($in_dir, $out_dir) { require_once __DIR__ . "/app.php"; $files_parsed = 0; $postData = new Aruna\Micropub\PostData(); foreach (list_files($in_dir) as $file) { // read post_data $in_filename = $file[0]; $out_filename = $out_dir . "/" . basename($in_filename, ".json") . ".html"; $post_data = json_decode(file_get_contents($in_filename), true); // convert mf json to viewModel $view_model = new Aruna\PostViewModel($postData->toMfArray($post_data)); // render viewModel as html $post_html = $app['twig']->render("post_" . $view_model->type() . ".html", array("post" => $view_model)); file_put_contents($out_filename, $post_html); $files_parsed += 1; } print sprintf("Processed %s files", $files_parsed); }
function list_files($dir) { if ($dh = opendir($dir)) { $files = array(); $inner_files = array(); while ($file = readdir($dh)) { if ($file != "." && $file != ".." && $file[0] != '.') { if (is_dir($dir . "/" . $file)) { $inner_files = list_files($dir . "/" . $file); if (is_array($inner_files)) { $files = array_merge($files, $inner_files); } } else { array_push($files, $dir . "/" . $file); } } } closedir($dh); return $files; } }
/** * List all files from a directory in an array * * @param string $directory The source directory * @param string $expression [optional] Regex for filtering result filenames * @param bool $recursive [optional] Boolean value if listing will be recursive * * @return array */ function list_files($directory, $expression = null, $recursive = true) { $files = array(); if (!is_dir($directory)) { return $files; } $fsentries = glob(rtrim(rtrim($directory, '/'), '\\') . '/*'); foreach ($fsentries as $path) { if (is_dir($path) && $recursive) { $files = array_merge($files, list_files($path, $expression, $recursive)); } # If current is file # if (is_file($path)) { if ($expression != null && in_array(preg_match($expression, $path), array(false, 0))) { continue; } array_push($files, realpath($path)); } } sort($files, SORT_STRING); return $files; }
/** * Function ListFiles * * Creates list of files in a given directory and all its subdirectories. * * @param string $dir * @param string $extension * * @return ... returns array with file names * ====== Additional resources on this function ====== (1) PHP scandir function (2) http://www.webmaster-talk.com/php-forum/41811-list-files-in-directory-sub-directories.html >>> The site provides the following function (below), which was slightly modified to extract only files with specified extension function ListFiles($dir) { if($dh = opendir($dir)) { $files = Array(); $inner_files = Array(); while($file = readdir($dh)) { if($file != "." && $file != ".." && $file[0] != '.') { if(is_dir($dir . "/" . $file)) { $inner_files = ListFiles($dir . "/" . $file); if(is_array($inner_files)) $files = array_merge($files, $inner_files); } else { array_push($files, $dir . "/" . $file); } } } closedir($dh); return $files; } } ====== Usage example: looping through all XML files ====== foreach (list_files('/home', 'xml') as $key=>$file){ echo $file ."<br />"; } * * */ function list_files($dir, $extension) { if ($dh = opendir($dir)) { $files = array(); $inner_files = array(); while ($file = readdir($dh)) { if ($file != "." && $file != ".." && $file[0] != '.') { if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { $inner_files = list_files($dir . DIRECTORY_SEPARATOR . $file, $extension); if (is_array($inner_files)) { $files = array_merge($files, $inner_files); } } else { if (file_extension($file) == $extension) { //add files with the specified extension array_push($files, $dir . DIRECTORY_SEPARATOR . $file); } } } } closedir($dh); return $files; } }
/** * Add a directory full of images * * @param $base string * @return array */ function add_dir($base) { $results = array(); foreach (list_files($base) as $full_path) { $short_path = str_replace($base, "", $full_path); $filename = basename($full_path); $tags = path_to_tags($short_path); $result = "{$short_path} (" . str_replace(" ", ", ", $tags) . ")... "; try { add_image($full_path, $filename, $tags); $result .= "ok"; } catch (UploadException $ex) { $result .= "failed: " . $ex->getMessage(); } $results[] = $result; } return $results; }
<div class="wrap"> <h2><?php _e('Delete Plugin(s)'); ?> </h2> <?php $files_to_delete = $plugin_info = array(); foreach ((array) $plugins as $plugin) { if ('.' == dirname($plugin)) { $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin; if ($data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin)) { $plugin_info[$plugin] = $data; } } else { //Locate all the files in that folder: $files = list_files(WP_PLUGIN_DIR . '/' . dirname($plugin)); if ($files) { $files_to_delete = array_merge($files_to_delete, $files); } //Get plugins list from that folder if ($folder_plugins = get_plugins('/' . dirname($plugin))) { $plugin_info = array_merge($plugin_info, $folder_plugins); } } } ?> <p><?php _e('Deleting the selected plugins will remove the following plugin(s) and their files:'); ?> </p> <ul>
/** * platform_launch_list_php: used to list all php files contained within $path * @param string $path The path to get all php file lists * * @return Mixed $contents Array containing the list of php files within $path */ function platform_launch_list_php($path) { platform_launch_php(PLATFORM_SANDBOX_SYSTEM_FUNCTIONS_PATH . DS . 'filesystem'); $contents = list_files($path, 'php'); return $contents; }
$have_non_network_plugins = false; $plugin_translations = wp_get_installed_translations('plugins'); foreach ((array) $plugins as $plugin) { $plugin_slug = dirname($plugin); if ('.' == $plugin_slug) { $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin; if ($data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin)) { $plugin_info[$plugin] = $data; $plugin_info[$plugin]['is_uninstallable'] = is_uninstallable_plugin($plugin); if (!$plugin_info[$plugin]['Network']) { $have_non_network_plugins = true; } } } else { // Locate all the files in that folder. $files = list_files(WP_PLUGIN_DIR . '/' . $plugin_slug); if ($files) { $files_to_delete = array_merge($files_to_delete, $files); } // Get plugins list from that folder. if ($folder_plugins = get_plugins('/' . $plugin_slug)) { foreach ($folder_plugins as $plugin_file => $data) { $plugin_info[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $data); $plugin_info[$plugin_file]['is_uninstallable'] = is_uninstallable_plugin($plugin); if (!$plugin_info[$plugin_file]['Network']) { $have_non_network_plugins = true; } } } // Add translation files. if (!empty($plugin_translations[$plugin_slug])) {
$last_message = isset($_REQUEST['last_message']) ? $_REQUEST['last_message'] : ''; // get a list of documents the user has "view" permission for // get current user's information-->department $user_obj = new User($_SESSION['uid'], $pdo); if (!$user_obj->isRoot()) { header('Location:error.php?ec=24'); } $flag = 0; if (isset($_GET['submit']) && $_GET['submit'] == 'view_checkedout') { echo PHP_EOL . '<form name="table" action="file_ops.php" method="POST">'; echo PHP_EOL . '<input name="submit" type="hidden" value="Clear Status">'; draw_header(msg('label_checked_out_files'), $last_message); $file_id_array = $user_obj->getCheckedOutFiles(); $page_url = 'file_ops.php?'; $user_perm_obj = new UserPermission($_SESSION['uid'], $pdo); $list_status = list_files($file_id_array, $user_perm_obj, $GLOBALS['CONFIG']['dataDir'], true, true); if ($list_status != -1) { echo PHP_EOL . '<BR><div class="buttons"><button class="positive" type="submit" name="submit" value="Clear Status">' . msg('button_clear_status') . '</button></div><br />'; echo PHP_EOL . '</form>'; } draw_footer(); } elseif (isset($_POST['submit']) && $_POST['submit'] == 'Clear Status') { if (isset($_POST["checkbox"])) { foreach ($_POST['checkbox'] as $cbox) { $file_id = $cbox; $file_obj = new FileData($file_id, $pdo); $file_obj->setStatus(0); } } header('Location:file_ops.php?state=2&submit=view_checkedout'); } else {
$themes = isset($_REQUEST['checked']) ? (array) $_REQUEST['checked'] : array(); if (empty($themes)) { wp_safe_redirect(add_query_arg('error', 'none', $referer)); exit; } $themes = array_diff($themes, array(get_option('stylesheet'), get_option('template'))); if (empty($themes)) { wp_safe_redirect(add_query_arg('error', 'main', $referer)); exit; } $files_to_delete = $theme_info = array(); $theme_translations = wp_get_installed_translations('themes'); foreach ($themes as $key => $theme) { $theme_info[$theme] = wp_get_theme($theme); // Locate all the files in that folder. $files = list_files($theme_info[$theme]->get_stylesheet_directory()); if ($files) { $files_to_delete = array_merge($files_to_delete, $files); } // Add translation files. $theme_slug = $theme_info[$theme]->get_stylesheet(); if (!empty($theme_translations[$theme_slug])) { $translations = $theme_translations[$theme_slug]; foreach ($translations as $translation => $data) { $files_to_delete[] = $theme_slug . '-' . $translation . '.po'; $files_to_delete[] = $theme_slug . '-' . $translation . '.mo'; } } } include ABSPATH . 'wp-admin/update.php'; $parent_file = 'themes.php';
function InitReportModules($szRootPath = "") { global $content, $gl_root_path; // Check for parameter if (strlen($szRootPath) == 0) { $szRootPath = $gl_root_path; } $szDirectory = $szRootPath . 'classes/reports/'; $aFiles = list_files($szDirectory, true); if (isset($aFiles) && count($aFiles) > 0) { foreach ($aFiles as $myFile) { // Check if file is valid msg parser! if (preg_match("/report\\.(.*?)\\.(.*?)\\.class\\.php\$/", $myFile, $out)) { // Set ParserID! $myReportCat = $out[1]; $myReportID = $out[2]; // Check if parser file include exists $szIncludeFile = $szDirectory . $myFile; if (file_exists($szIncludeFile)) { // Try to include if (include_once $szIncludeFile) { // Set ParserClassName $szReportClass = "Report_" . $myReportID; // Create Instance and get properties $tmpReport = new $szReportClass(); // Create an instance $szReportName = $tmpReport->_reportTitle; $szReportDescription = $tmpReport->_reportDescription; $szReportVersion = $tmpReport->_reportVersion; $szReportHelpArticle = $tmpReport->_reportHelpArticle; $bNeedsInit = $tmpReport->_reportNeedsInit; $bInitialized = $tmpReport->_reportInitialized; $aRequiredFieldsList = $tmpReport->GetRequiredProperties(); /* // check for required fields! if ( $tmpReport->_ClassRequiredFields != null && count($tmpParser->_ClassRequiredFields) > 0 ) { $bCustomFields = true; $aCustomFieldList = $tmpParser->_ClassRequiredFields; // print_r ( $aCustomFieldList ); } else { $bCustomFields = false; $aCustomFieldList = null; } */ // Add entry to report modules list! $content['REPORTS'][$myReportID] = array("ID" => $myReportID, "Category" => $myReportCat, "DisplayName" => $szReportName, "Description" => $szReportDescription, "ReportVersion" => $szReportVersion, "ReportHelpArticle" => $szReportHelpArticle, "NeedsInit" => $bNeedsInit, "Initialized" => $bInitialized, "ObjRef" => $tmpReport, "RequiredFieldsList" => $aRequiredFieldsList); // --- Now Search and populate savedReports | but only if DB Version is 9 or higher. if ($content['database_installedversion'] >= 9) { // --- Create SQL Query $sqlquery = " SELECT " . DB_SAVEDREPORTS . ".ID as SavedReportID, " . DB_SAVEDREPORTS . ".sourceid, " . DB_SAVEDREPORTS . ".customTitle, " . DB_SAVEDREPORTS . ".customComment, " . DB_SAVEDREPORTS . ".filterString, " . DB_SAVEDREPORTS . ".customFilters, " . DB_SAVEDREPORTS . ".outputFormat, " . DB_SAVEDREPORTS . ".outputTarget, " . DB_SAVEDREPORTS . ".outputTargetDetails, " . DB_SAVEDREPORTS . ".scheduleSettings " . " FROM `" . DB_SAVEDREPORTS . "`" . " WHERE `" . DB_SAVEDREPORTS . "`.reportid = '" . $myReportID . "' " . " ORDER BY `" . DB_SAVEDREPORTS . "`.customTitle"; // Get Views from DB now! $result = DB_Query($sqlquery); $myrows = DB_GetAllRows($result, true); if (isset($myrows) && count($myrows) > 0) { // Set to true! $content['REPORTS'][$myReportID]['HASSAVEDREPORTS'] = true; // Add all savedreports foreach ($myrows as &$mySavedReport) { // Set default properties if not set! if (!isset($mySavedReport['outputTarget']) || strlen($mySavedReport['outputTarget']) <= 0) { $mySavedReport['outputTarget'] = REPORT_TARGET_STDOUT; } // Add saved report into global array $content['REPORTS'][$myReportID]['SAVEDREPORTS'][$mySavedReport['SavedReportID']] = $mySavedReport; } } } // --- } else { // DEBUG ERROR OutputDebugMessage("InitReportModules: Failed including report file '" . $szIncludeFile . "' with error: '" . $php_errormsg . "'", DEBUG_ERROR); } } else { // DEBUG ERROR OutputDebugMessage("InitReportModules: Reportfile '" . $szIncludeFile . "' does not exist!", DEBUG_ERROR); } } } } // TODO: compare update report modules registered in database }
/** * Get a list of the profiles in the profiles folder * Profiles are named as "*.json". Add additional info, too, like * date and number of visits in the file * @uses list_files * @return type */ private function _get_profiles() { $p3_profile_dir = P3_PROFILES_PATH; $files = list_files($p3_profile_dir); $files = array_filter($files, array(&$this, '_filter_json_files')); $ret = array(); foreach ($files as $file) { $time = filemtime($file); $count = count(file($file)); $key = basename($file); $name = substr($key, 0, -5); // strip off .json $ret[] = array('filename' => basename($file), 'name' => $this->_action_links($key, $name), 'date' => date('D, M jS', $time) . ' at ' . date('g:i a', $time), 'count' => number_format($count), 'filesize' => P3_Profiler_Plugin_Admin::readable_size(filesize($file)), '_filesize' => filesize($file), '_date' => $time, '_count' => $count); } return $ret; }
/** * Wann soll das ausgeführt werden? * * Am 28. Dezember des Vorjahres (via cron -> Failures should be reported via email) * * Direkt nach Installation des Plugins (activate?) * * Manuell im Backend (Knopf im Widget? Optionen?) * * @param int $year */ public function doUpdate($date) { global $wp_filesystem; $download_url = $this->_getDownloadUrl($date); $this->_setup_WP_Filesystem($download_url); // 1) Downlaod File $tmpFile = download_url($download_url); if (is_wp_error($tmpFile)) { return $tmpFile; } // 2) Unzip to tempDir $tempDir = $this->alternate_dir . '/update-losungen-' . time() . '/'; if (!is_dir($tempDir)) { $wp_filesystem->mkdir($tempDir); } $ret = unzip_file($tmpFile, $tempDir); if (is_wp_error($ret)) { return $ret; } // 3) Search any XML File! $losungenFile = ''; foreach (list_files($tempDir) as $file) { if (substr($file, -4) == '.xml') { $losungenFile = $file; break; } } // TODO Syntax Validation of XML file if (!$losungenFile) { return new WP_Error(17000, 'In der Zip-Datei war keine Losungs-XML! (' . $download_url . ')'); } // 4) Put in the right place if (!$wp_filesystem->move($losungenFile, $this->xmlFileName('', $date), true)) { return new WP_Error(17000, 'Die XML-Datei konnte nicht geschrieben werden! (' . $this->xmlFileName('', $date) . ')'); } // 5) Finally, clean up $wp_filesystem->delete($tmpFile); $wp_filesystem->delete($tempDir, true); return file_exists($this->xmlFileName('', $date)); }
<input type="hidden" name="action" value="smush_theme"/> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('wp-smushit_smush-theme' . $theme); } ?> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" id="name" class="manage-column column-name" style="">File name</th> </tr> <tbody> <?php $theme_files = list_files($theme_path, 5); foreach ($theme_files as $file) { if (preg_match('/\\.(jpg|jpeg|png|gif)$/i', $file) < 1) { continue; } $file = str_replace(TEMPLATEPATH, '', $file); $file_url = $theme_url . $file; ?> <tr valign="middle"> <th scope="row" class="check-column"><input type="checkbox" name="smushitlink[]" value="<?php echo attribute_escape(base64_encode($file_url)); ?> " /></th> <td class="column-name"><strong><a class='row-title' href='<?php echo $file_url; ?>
function delete_file($user) { $name = get_str('name'); $dir = sandbox_dir($user); list($error, $size, $md5) = sandbox_parse_link_file("{$dir}/{$name}"); if ($error) { error_page("can't parse link file"); } $p = sandbox_physical_path($user, $md5); if (!is_file($p)) { error_page("no such physical file"); } $bused = sandbox_file_in_use($user, $name); if ($bused) { $notice = "<strong>{$name}</strong> is being used by batch(es), you can not delete it now!<br/>"; } else { $notice = "<strong>{$name}</strong> is not being used by any batch(es) and successfully deleted from your sandbox<br/>"; unlink("{$dir}/{$name}"); unlink($p); } list_files($user, $notice); //Header("Location: sandbox.php"); }