public static function LoadLocales() { $loc_files = find_all_files(LOCALES_DIR); foreach ($loc_files as $loc) { // Remove ".ini" self::$m_locales[] = substr($loc, 0, -4); } }
function build_custom_css_loop() { global $config; $loop = array(); $files = find_all_files(BASE . '/templates/custom_css/', true, '.css'); foreach ($files as $file) { $name = str_ireplace(BASE . '/templates/custom_css/', '', $file); $loop[] = array('value' => $name, 'text' => $name, 'selected' => $name == $config['html']['custom_css']); } return $loop; }
/** * scan user img */ public function lostImgList() { $dir = './data/attach'; $allImgs = find_all_files($dir); $sqlImgs = D('GalleryMeta')->getField('path', true); foreach ($sqlImgs as $k => $v) { $sqlImgs[$k] = getPicPath($v); } $result = array_diff($allImgs, $sqlImgs); $data = array('imgList' => $result, 'lostDelUrl' => U('Home/Gallery/lostDel')); $this->assign($data); $this->display(); }
private function find_all_files($dir) { $root = scandir($dir); foreach ($root as $value) { if ($value == '.' || $value == '..') { continue; } if (is_file("{$dir}/{$value}")) { $result[] = "{$dir}/{$value}"; continue; } foreach (find_all_files("{$dir}/{$value}") as $value) { $result[] = $value; } } return isset($result) ? $result : []; }
public function __construct($a_dir) { // Load from dirs $plugins = find_all_dirs($a_dir); if ($plugins) { foreach ($plugins as $plugin) { $this->AppendPlugin($a_dir . "/" . $plugin, $plugin); } } // Load files $plugins = find_all_files($a_dir); if ($plugins) { foreach ($plugins as $plugin) { $this->AppendPlugin($a_dir, str_replace(PLUGIN_EXT, "", $plugin)); } } }
function find_all_files($dir) { global $deep, $id, $i_id; $root = scandir($dir, 0); $path = $dir; $id_str = ""; if ($root) { $id_str = $id . "_div_folder_node_" . $deep . "_" . $i_id; echo "<div id='" . $id_str . "' class='treeFolderView_li_div'"; if ($i_id > 0) { echo " style='display:none;'"; } echo "><ul class='treeFolderView_ul'>"; foreach ($root as $value) { if ($value === '.' || $value === '..' || $value === ".svn" || $value === "includesystem") { continue; } $i_id++; if (is_file($dir . "/" . $value)) { echo "<li class='treeFolderView_ul_li'>\n\t\t\t\t<span id='" . $id . "_ul_li_span_" . $i_id . "' class='treeFolderView_ul_li_span' onclick='return TreeFolderView_param.file_on_click(this);' onMouseMove='return TreeFolderView_param.mouse_move(this);' onMouseOut='return TreeFolderView_param.mouse_out(this);'>\n\t\t\t\t" . $value . "</span><input id='" . $id . "_ul_li_span_" . $i_id . "_input' type='hidden' value='" . substr($dir, 1) . "/" . $value . "'></li>"; continue; } $path = ""; if (is_dir($dir . "/" . $value)) { $path = $dir . "/" . $value; $id_str_in = $id . "_div_folder_node_" . ($deep + 1) . "_" . $i_id; echo "<li class='treeFolderView_ul_li' onclick='return TreeFolderView_param.folder_on_click(\"" . $id_str_in . "\",\"" . $path . "\");'>"; echo "<img id='" . $id_str_in . "_img' class='treeFolderView_li_img' src='../../../includesystem/images/close_folder.jpg'>" . $value . "</li>"; $deep++; } find_all_files($dir . "/" . $value); } $deep--; echo "</ul></div>"; } }
public static function GeneratePageData() { $page_data = array(); $page_data['id'] = self::$m_pageid; $page_data['pages'] = array(); $result = Database::Query("SELECT `id`, `name`, `template`, `default` FROM `" . DB_TBL_PAGES . "`"); do { $row = $result->GetRow(); $page_data['pages'][$row['id']] = $row; $page_data['pages'][$row['id']]['name'] = unserialize($row['name']); } while ($result->NextRow()); self::AddData(DATA_PAGE, $page_data); // Generate template data // Page templates $page_templates = find_all_files(COMPILER_TEMPLATES_DIR); foreach ($page_templates as $page_template) { $templates_data['page'][] = substr($page_template, 0, -5); } // Module templates $module_types = find_all_dirs(COMPILER_TEMPLATES_DIR . '/modules'); foreach ($module_types as $module_type) { $module_templates = find_all_files(COMPILER_TEMPLATES_DIR . '/modules/' . $module_type); foreach ($module_templates as $module_template) { $templates_data['modules'][$module_type][] = substr($module_template, 0, -5); } } self::AddData(DATA_TEMPLATES, $templates_data); }
} break; } } /******************************************************************************** * * List broken filename footprints * *********************************************************************************/ if (!$fatal_error) { try { $broken_filename_footprints = Footprint::get_broken_filename_footprints($database, $current_user, $log); $broken_filename_loop = array(); if (count($broken_filename_footprints) > 0) { // get all available files for the proposed footprint images $available_proposed_files = array_merge(find_all_files(BASE . '/img/', true), find_all_files(BASE . '/data/media/', true)); // read the PHP constant "max_input_vars" $max_input_vars = ini_get('max_input_vars') !== false ? (int) ini_get('max_input_vars') : 999999; for ($i = 0; $i < count($broken_filename_footprints); $i++) { // avoid too many post variables if ($i * 10 >= $max_input_vars) { break; } // avoid too long execution time and a huge HTML table if ($i >= 100) { break; } $footprint = $broken_filename_footprints[$i]; $proposed_filenames_loop = array(); $proposed_filenames = get_proposed_filenames($footprint->get_filename(), $available_proposed_files); if (count($proposed_filenames) > 0 && pathinfo($proposed_filenames[0], PATHINFO_FILENAME) == pathinfo($footprint->get_filename(), PATHINFO_FILENAME)) {
function find_all_files($dir) { $root = scandir($dir); foreach ($root as $value) { if ($value === '.' || $value === '..') { continue; } if (is_file("{$dir}/{$value}")) { $result[] = "{$dir}/{$value}"; continue; } if (is_array(find_all_files("{$dir}/{$value}"))) { foreach (find_all_files("{$dir}/{$value}") as $value) { $result[] = $value; } } } return $result; }
function find_all_files($dir, $deep, $name, $cat, $part, $langue, $revision) { $deep++; $root = scandir($dir); foreach ($root as $value) { if ($value === '.' || $value === '..' || $value === '.svn') { continue; } switch ($deep) { case 1: echo "<br>Revision->: "; echo $revision = $value; break; case 2: echo "<br>langue->: "; switch ($value) { case "French": $langue = 1; break; case "Korean": $langue = 2; break; case "PortugueseBrazil": $langue = 3; break; case "Romanian": $langue = 4; break; default: $langue = 1; break; } break; case 3: echo "<br>category->: "; switch ($value) { case "free": echo $cat = 2; break; case "multiword": echo $cat = 3; break; case "docs": echo $cat = NULL; break; default: echo $cat = 2; break; } break; case 4: echo "<br>partofpeech->: "; switch ($value) { case "noun": echo $part = 1; break; case "verb": echo $part = 2; break; case "adverb": echo $part = 3; break; case "adjective": echo $part = 4; break; case "prepositional_phrase": echo $part = 5; break; default: echo $part = NULL; break; } break; } if (is_file("{$dir}/{$value}")) { $result[] = "{$dir}/{$value}"; $path = "{$dir}/{$value}"; echo "Path ->: " . $path . "<br>"; $name = $value; if ($deep == 6) { insert_doc($name, $path, $langue, $cat, $part, $revision); } else { if (($deep = 5) && $cat == NULL) { insert_doc($name, $path, $langue, $cat, $part, $revision); } else { insert($name, $path, $langue, $cat, $part, $revision); } } continue; } if ($deep < 6) { foreach (find_all_files("{$dir}/{$value}", $deep, $name, $cat, $part, $langue, $revision) as $value) { $result[] = $value; // echo $value."<br>"; } } } return $result; }
public function build_site_map() { $site_map_links = []; $site_map_imgs = []; $site_map_vids = []; $time = date("Y-m-d", time()) . "T09:13:31+00:00"; // dd($time); $search_files = array_merge(find_all_files(base_path("public/site-imgs")), find_all_files(base_path("public/site-docs"))); // dd($search_files); $imgs_ext_array = ['jpg', 'gif', 'png', 'ico']; $vids_ext_array = ['flv', 'mp4', 'ogv', 'mp3']; foreach ($search_files as $file) { $file_ext = get_file_data($file)['ext']; $file_array = explode("/", $file); unset($file_array[0]); $final_file = implode("/", $file_array); if (in_array($file_ext, $imgs_ext_array)) { $site_map_imgs[] = REMOTE_SITE_URL . $final_file; } elseif (in_array($file_ext, $vids_ext_array)) { $site_map_vids[] = REMOTE_SITE_URL . $final_file; } } foreach (\sr::bulid_links_site_map() as $link) { $site_map_links[] = str_replace("localhost/ahmed-badawy.com", "ahmed-badawy.com/site", $link); } $data = ["site_map_links" => $site_map_links, "site_map_imgs" => $site_map_imgs, "site_map_vids" => $site_map_vids, "time" => $time]; // dd($data); $view = view("site-map-generator.site-map", $data)->render(); // Write the contents back to the file $file = base_path("backups/site-maps/site-map.xml"); file_put_contents($file, $view); }
function CacheLibs() { if (is_file(LIBS)) { return; } $result = find_all_files(Lib); $libs_serialize = serialize($result); $php_start = "<?php if (!defined('M5CPL'))exit; "; dir_create(LIBDIR); file_put_contents(LIBS, $php_start . " \$_libs='" . $libs_serialize . "'; return \$_libs;"); }
$noprice_parts = Part::get_noprice_parts($database, $current_user, $log); $count_of_parts_with_price = Part::get_count($database) - count($noprice_parts); // :-) $html->set_variable('parts_count_with_prices', $count_of_parts_with_price, 'integer'); $html->set_variable('parts_count_sum_value', Part::get_sum_price_instock($database, $current_user, $log, true), 'string'); $html->set_variable('parts_count', Part::get_count($database), 'integer'); $html->set_variable('parts_count_sum_instock', Part::get_sum_count_instock($database), 'integer'); $html->set_variable('categories_count', Category::get_count($database), 'integer'); $html->set_variable('footprint_count', Footprint::get_count($database), 'integer'); $html->set_variable('location_count', Storelocation::get_count($database), 'integer'); $html->set_variable('suppliers_count', Supplier::get_count($database), 'integer'); $html->set_variable('manufacturers_count', Manufacturer::get_count($database), 'integer'); $html->set_variable('devices_count', Device::get_count($database), 'integer'); $html->set_variable('attachements_count', Attachement::get_count($database), 'integer'); $html->set_variable('footprint_picture_count', count(find_all_files(BASE . '/img/footprints/', true)), 'integer'); $html->set_variable('iclogos_picture_count', count(find_all_files(BASE . '/img/iclogos/', true)), 'integer'); } catch (Exception $e) { $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red'); $fatal_error = true; } } /******************************************************************************** * * Generate HTML Output * *********************************************************************************/ $html->print_header($messages); if (!$fatal_error) { $html->print_template('statistics'); } $html->print_footer();
function update_lang_files($source, $dest) { $files = find_all_files($source); foreach ($files as $file) { extract_l10n_strings($file); } $files = scandir($dest); $ignore = array('.', '..'); // list locales $locales = array(); foreach ($files as $file) { if (in_array($file, $ignore)) { continue; } $split = explode('.', $file); if ($split[1] == 'lang') { $locales[] = $split[0]; } } foreach ($locales as $locale) { $status[$locale] = 0; $lang_file_path = $dest . '/' . $locale; Simplel10n::load($lang_file_path); ob_start(); foreach ($GLOBALS['english'] as $key => $val) { $warning = ''; $value = @Simplel10n::extractString($key); if ($value == $val[0]) { $status[$locale]++; $warning = ' ** String needs translation **'; } if ($val[1]) { echo '# Translation note: ' . $val[1] . $warning . "\n"; } elseif ($warning != '') { echo '# Translation note: ' . $warning . "\n"; } echo ";{$val['0']}\n"; echo $value . "\n\n\n"; } $content = ob_get_contents(); ob_end_clean(); file_put_contents($lang_file_path . '.lang', $content); unset($GLOBALS['locale']); } // Display a short status report header('Content-Type:text/plain'); echo "Number of English strings: " . count($GLOBALS['english']) . "\n"; echo "Your installation has these languages installed: " . implode(', ', $locales) . "\n"; foreach ($locales as $val) { echo $val . " has " . $status[$val] . " untranslated strings.\n"; } }
/** * 递归搜索文件 */ function find_all_files($dir) { $root = scandir($dir); foreach ($root as $value) { if ($value === '.' || $value === '..') { continue; } if (is_file("{$dir}/{$value}")) { if (preg_match('/_[bms]{1}/', "{$dir}/{$value}")) { continue; } else { $result[] = "{$dir}/{$value}"; continue; } } foreach (find_all_files("{$dir}/{$value}") as $value) { $result[] = $value; } } return $result; }
$INPUT_DIR = "input/"; $OUTPUT_DIR = "output/"; $FILE_FACES = $INPUT_DIR . "faces.csv"; $TILES_DIR = $INPUT_DIR . "tiles/"; $CSV_DELIMITER = ";"; $IMG_SPACE = "espace.png"; $TILE_HEIGHT_M = 12; // en mètres $TILE_HEIGHT = 777; // en pixels $TILE_WIDTH = 203; // en pixels $PNG_QUALITY = 9; // 0 = aucune compression => 9 // on récupère la liste des images contenues dans le répertoire des tiles $tiles = find_all_files($TILES_DIR); $tilesImg = array(); foreach ($tiles as $index => $filename) { if ($filename == $IMG_SPACE) { unset($tiles[$index]); } else { $tilesImg[] = imagecreatefromstring(file_get_contents($TILES_DIR . $filename)); } } // on charge l'image contenant les espaces $spaceImg = imagecreatefromstring(file_get_contents($TILES_DIR . $IMG_SPACE)); // on récupère le contenu du fichier CSV $fileContent = file_get_contents($FILE_FACES); // on extrait le contenu CSV dans un tableau $tabFaces = csv_to_array($fileContent, $CSV_DELIMITER); // génération des images
/** * @brief List all files (or all files with a specific string in the filename) in a directory * * @note This function is not case sensitive. * * @param string $directory Path to the directory (IMPORTANT: absolute UNIX path, with slash at the end! see to_unix_path()) * @param boolean $recursive If true, the file search is recursive * @param string $search_string If this is a non-empty string, only files with * that substring in the filename will be returned. * * @retval array all found filenames (incl. absolute UNIX paths, sorted alphabetically) * * @throws Exception if there was an error */ function find_all_files($directory, $recursive = false, $search_string = '') { $files = array(); if (!is_dir($directory) || mb_substr($directory, -1, 1) != '/' || !is_path_absolute_and_unix($directory, false)) { throw new Exception('"' . $directory . '" ist kein gültiges Verzeichnis!'); } $dirfiles = scandir($directory); foreach ($dirfiles as $file) { if ($file != "." && $file != ".." && $file != ".svn" && $file != ".git" && $file != ".gitignore" && $file != ".htaccess") { if (is_dir($directory . $file)) { if ($recursive) { $files = array_merge($files, find_all_files($directory . $file . '/', true, $search_string)); } } elseif ($search_string == '' || mb_substr_count(mb_strtolower($file), mb_strtolower($search_string)) > 0) { $files[] = $directory . $file; } } } return $files; }
//files list if (is_file($dir . "/" . $value) && $is_file == 1) { $li_file_id = (string) $i_f . "_" . $id . "_FileExplorer_li_td_file"; $file_string_tree .= "<li class='FileExplorer_ul_li'>"; $file_string_tree .= "<table border=0 cellpadding=1 cellspacing=0><tr>"; //Permissions of a file is determined $permiss = substr(sprintf('%o', fileperms($dir . "/" . $value)), -4); $file_string_tree .= "<td id='" . $li_file_id . "' valign='middle' onclick='return FileExplorer_param.file_on_click(\"" . $li_file_id . "\",\"" . $id . "\",\"" . $dir . "/" . $value . "\",\"" . $permiss . "\");' class='FileExplorer_ul_li_td3'>" . $value . "</td></tr></table>"; $file_string_tree .= "</li>"; $i_f++; } } } echo "<ul class='FileExplorer_ul'>"; if ($folder_string_tree != "") { echo $folder_string_tree; } if ($file_string_tree != "") { echo $file_string_tree; } echo "</ul>"; } if (isset($_POST['dir']) && trim($_POST['dir']) != "") { if ((int) $_POST['is_file'] == 1) { find_all_files(rawurldecode(htmlspecialchars($_POST['dir'], ENT_QUOTES)), 1); } else { find_all_files(rawurldecode(htmlspecialchars($_POST['dir'], ENT_QUOTES)), 0); } } else { find_all_files("../"); }
/******************************************************************************** * * Get Footprints and set all HTML variables * *********************************************************************************/ if (count($directories) > 0) { $categories_loop = array(); $categories = array(); foreach ($directories as $directory) { $categories[] = rtrim($directory, "\\/"); $categories = array_merge($categories, find_all_directories($directory, true)); } sort($categories); foreach ($categories as $category) { $pictures_loop = array(); $pictures = find_all_files($category . '/', false, '.png'); foreach ($pictures as $filename) { $pictures_loop[] = array('title' => str_replace('.png', '', basename($filename)), 'filename' => str_replace(BASE, BASE_RELATIVE, $filename)); } if (count($pictures_loop) > 0) { $categories_loop[] = array('category_name' => str_replace(BASE, '', $category), 'pictures_loop' => $pictures_loop); } } $html->set_loop('categories_loop', $categories_loop); } /******************************************************************************** * * Generate HTML Output * *********************************************************************************/ $html->print_header($messages);