function getFiles(&$rdi, $depth = 0) { if (!is_object($rdi)) { return; } $files = array(); // order changes per machine for ($rdi->rewind(); $rdi->valid(); $rdi->next()) { if ($rdi->isDot()) { continue; } if ($rdi->isDir() || $rdi->isFile()) { $indent = ''; for ($i = 0; $i <= $depth; ++$i) { $indent .= " "; } $files[] = $indent . $rdi->current() . "\n"; if ($rdi->hasChildren()) { getFiles($rdi->getChildren(), 1 + $depth); } } } asort($files); var_dump(array_values($files)); }
function getFiles($dir, $ext, $exclude = array()) { $returnList = array(); $nextDirs = array(); if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { if (is_dir($file)) { array_push($nextDirs, $file); } else { $info = pathinfo($dir . '/' . $file); if ($info['extension'] == $ext) { $dontInclude = false; for ($l = 0; $l < count($exclude); ++$l) { if (strtolower($file) == strtolower($exclude[$l])) { $dontInclude = true; } } if (!$dontInclude) { array_push($returnList, $file); } } } } } closedir($dh); } for ($i = 0; $i < count($nextDirs); ++$i) { $newFiles = getFiles($dir . '/' . $nextDirs[$i], $ext, $exclude); for ($j = 0; $j < count($newFiles); ++$j) { array_push($returnList, $nextDirs[$i] . '/' . $newFiles[$j]); } } return $returnList; }
/** * Builds the cache of Dashlets by scanning the system */ function buildCache() { global $beanList; $dashletFiles = array(); $dashletFilesCustom = array(); getFiles($dashletFiles, 'modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/'); getFiles($dashletFilesCustom, 'custom/modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/'); $cacheDir = create_cache_directory('dashlets/'); $allDashlets = array_merge($dashletFiles, $dashletFilesCustom); $dashletFiles = array(); foreach ($allDashlets as $num => $file) { if (substr_count($file, '.meta') == 0) { // ignore meta data files $class = substr($file, strrpos($file, '/') + 1, -4); $dashletFiles[$class] = array(); $dashletFiles[$class]['file'] = $file; $dashletFiles[$class]['class'] = $class; if (is_file(preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file))) { // is there an associated meta data file? $dashletFiles[$class]['meta'] = preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file); require $dashletFiles[$class]['meta']; if (isset($dashletMeta[$class]['module'])) { $dashletFiles[$class]['module'] = $dashletMeta[$class]['module']; } } $filesInDirectory = array(); getFiles($filesInDirectory, substr($file, 0, strrpos($file, '/')), '/^.*\\/Dashlets\\/[^\\.]*\\.icon\\.(jpg|jpeg|gif|png)$/i'); if (!empty($filesInDirectory)) { $dashletFiles[$class]['icon'] = $filesInDirectory[0]; // take the first icon we see } } } write_array_to_file('dashletsFiles', $dashletFiles, $cacheDir . 'dashlets.php'); }
function getFiles(&$modx, &$results, &$filesfound, $directory, $listing = array(), $count = 0) { $dummy = $count; if (@($handle = opendir($directory))) { while ($file = readdir($handle)) { if ($file == '.' || $file == '..' || strpos($file, '.') === 0) { continue; } else { if ($h = @opendir($directory . $file . "/")) { closedir($h); $count = -1; $listing["{$file}"] = getFiles($modx, $results, $filesfound, $directory . $file . "/", array(), $count + 1); } else { $listing[$dummy] = $file; $dummy = $dummy + 1; $filesfound++; } } } } else { $results .= $modx->lexicon('import_site_failed') . " Could not open '{$directory}'.<br />"; } @closedir($handle); return $listing; }
/** * Get files under a directory recursive. * * @param string $dir * @param array $exceptions * @access private * @return array */ function getFiles($dir, $exceptions = array()) { static $files = array(); if (!is_dir($dir)) { return $files; } $dir = realpath($dir) . '/'; $entries = scandir($dir); foreach ($entries as $entry) { if ($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == 'db') { continue; } if (in_array($entry, $exceptions)) { continue; } $fullEntry = $dir . $entry; if (is_file($fullEntry)) { $files[] = $dir . $entry; } else { $nextDir = $dir . $entry; getFiles($nextDir); } } return $files; }
function getFiles($fileName, &$updateTime = 0, $url = '', $levels = 100, $types = array('jpg', 'png', 'gif', 'jpeg', 'css', 'js')) { if (empty($fileName) || !$levels) { return false; } $files = array(); if (is_file($fileName)) { $updateTime = getMax(filectime($fileName), $updateTime); $files[] = $url; } else { if ($dir = @opendir($fileName)) { while (($file = readdir($dir)) !== false) { if (in_array($file, array('.', '..'))) { continue; } if (is_dir($fileName . '/' . $file)) { $files2 = getFiles($fileName . '/' . $file, $updateTime, $url . '/' . $file, $levels - 1); if ($files2) { $files = array_merge($files, $files2); } } else { $updateTime = getMax(filectime($fileName . '/' . $file), $updateTime); $type = end(explode(".", $file)); if (in_array($type, $types)) { $files[] = $url . '/' . $file; } } } } } @closedir($dir); // echo date("Y-m-d H:i:s",$updateTime).'<hr>'; return $files; }
function nm_get_languages() { $languages = array(); $files = getFiles(NMLANGPATH); foreach ($files as $file) { if (isFile($file, NMLANGPATH, 'php')) { $lang = basename($file, '.php'); $languages[$lang] = NMLANGPATH . $file; } } ksort($languages); return $languages; }
public static function generateSitemapWithoutPing() { global $SITEURL; $filenames = getFiles(GSDATAPAGESPATH); if (count($filenames)) { foreach ($filenames as $file) { if (isFile($file, GSDATAPAGESPATH, 'xml')) { $data = getXML(GSDATAPAGESPATH . $file); if ($data->url != '404' && $data->private != 'Y') { $pagesArray[] = array('url' => (string) $data->url, 'parent' => (string) $data->parent, 'date' => (string) $data->pubDate, 'menuStatus' => (string) $data->menuStatus); } } } } $pagesSorted = subval_sort($pagesArray, 'menuStatus'); $languages = return_i18n_available_languages(); $deflang = return_i18n_default_language(); $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>'); $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance'); $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); if (count($pagesSorted)) { foreach ($pagesSorted as $page) { // set <loc> if (count($languages) > 1) { $pos = strrpos($page['url'], '_'); if ($pos !== false) { $pageLoc = find_i18n_url(substr($page['url'], 0, $pos), $page['parent'], substr($page['url'], $pos + 1)); } else { $pageLoc = find_i18n_url($page['url'], $page['parent'], $deflang); } } else { $pageLoc = find_i18n_url($page['url'], $page['parent']); } // set <lastmod> $pageLastMod = makeIso8601TimeStamp(date("Y-m-d H:i:s", strtotime($page['date']))); // set <changefreq> $pageChangeFreq = 'weekly'; // set <priority> $pagePriority = $page['menuStatus'] == 'Y' ? '1.0' : '0.5'; //add to sitemap $url_item = $xml->addChild('url'); $url_item->addChild('loc', htmlspecialchars($pageLoc)); $url_item->addChild('lastmod', $pageLastMod); $url_item->addChild('changefreq', $pageChangeFreq); $url_item->addChild('priority', $pagePriority); } } //create xml file $file = GSROOTPATH . 'sitemap.xml'; XMLsave($xml, $file); }
function loadModules() { global $ARI_ADMIN_MODULES; global $ARI_DISABLED_MODULES; global $loaded_modules; $modules_path = "./modules"; if (is_dir($modules_path)) { $filter = ".module"; $recursive_max = 1; $recursive_count = 0; $files = getFiles($modules_path, $filter, $recursive_max, $recursive_count); foreach ($files as $key => $path) { // build module object include_once $path; $path_parts = pathinfo($path); list($name, $ext) = split("\\.", $path_parts['basename']); // check for module and get rank if (class_exists($name)) { $module = new $name(); // check if admin module $found = 0; if ($ARI_ADMIN_MODULES) { $admin_modules = split(',', $ARI_ADMIN_MODULES); foreach ($admin_modules as $key => $value) { if ($name == $value) { $found = 1; break; } } } // check if disabled module $disabled = 0; if ($ARI_DISABLED_MODULES) { $disabled_modules = split(',', $ARI_DISABLED_MODULES); foreach ($disabled_modules as $key => $value) { if ($name == $value) { $disabled = 1; break; } } } // if not admin module or admin user add to module name to array if (!$disabled && (!$found || $_SESSION['ari_user']['admin'])) { $loaded_modules[$name] = $module; } } } } else { $_SESSION['ari_error'] = _("{$path} not a directory or not readable"); } }
function getFiles($dir, $subfolder = '.') { $handle = opendir($dir); $templates = array(); while ($file = readdir($handle)) { if (is_file($dir . '/' . $file) and substr($file, -3) == 'tpl') { $templates[] = $subfolder . '/' . $file; } elseif (is_dir($dir . '/' . $file) and $file != '.' && $file != '..') { $templates = array_merge($templates, getFiles($dir . '/' . $file, $subfolder . '/' . $file)); } } closedir($handle); return $templates; }
/** * Retrieves all file names from a directory * * @param string $dir_name Name of the directory from which to extract file names * @return string[] $file_list */ function getFiles($dir_name) { $dir_files = scandir($dir_name); $file_list = array(); foreach ($dir_files as $file_name) { $file = "{$dir_name}/{$file_name}"; if (is_file($file)) { $file_list[] = $file; } elseif ($file_name[0] != '.' && is_dir($file)) { $file_list = array_merge(getFiles($file), $file_list); } } return $file_list; }
public function __construct(SugarView &$view) { require_once 'include/utils/file_utils.php'; $files = array(); getFiles($files, 'custom/include/utils/DevToolKit', '/\\.php/'); foreach ($files as $file) { preg_match("/\\/(\\w+)\\.php\$/", $file, $matches); $class = $matches[1]; require_once $file; $bean = new $class($view); if ($bean->has_metadata()) { $this->toolkits[] = $bean; } } }
function getFiles($dir, &$results = array(), $filename = 'template.html') { $files = scandir($dir); foreach ($files as $key => $value) { $path = realpath($dir . '/' . $value); if (!is_dir($path)) { if ($value == $filename) { $results[] = $path; } } else { if ($value != "." && $value != "..") { getFiles($path, $results); } } } return $results; }
function getFiles($path, $base_path = null) { $path_files = array_diff(scandir($path), array('..', '.')); $files = array(); foreach ($path_files as $file) { $file_path = $path . '/' . $file; if ($file[0] == '.') { continue; } if (is_dir($file_path)) { $files = array_merge($files, getFiles($file_path, $base_path ?: $path)); } else { $files[] = $base_path ? str_replace($base_path . '/', '', $file_path) : $file_path; } } return $files; }
function getFiles($i, $pref) { $output = array(); foreach ($i as $f) { $f = $pref . '/' . $f; if (is_dir($f)) { $base = basename($f); if ($base[0] !== '.') { if ($base !== 'tests' and $base !== 'smarty' and $base !== 'tinymce' and $base !== 'smarty-plugins') { $output = array_merge($output, getFiles(scandir($f), $f)); } } } else { $output[] = $f; } } return $output; }
/** * 上传单个或多个文件 * @param int $type * $type为0:上传图片 * $type为1:上传视频 */ function uploadmulti($type) { // print_r($_FILES);die; $files = getFiles(); $path = dirname(dirname(__FILE__)); //获取upload_image的上层目录的绝对路径 if ($type == 0) { $uploadPath = $path . '/upload_image'; } else { $uploadPath = $path . '/upload_video'; } foreach ($files as $fileInfo) { $upload = new upload($fileInfo, $uploadPath, false); $dest = $upload->uploadFile(); $uploadFiles[] = $dest; } $uploadFiles = array_values(array_filter($uploadFiles)); return $uploadFiles; }
/** * 上传单个或多个文件 * @param int $type * $type为0:上传图片 * $type为1:上传视频 * $type为2:上传缩略图 */ function uploadmulti($fileName, $type) { // print_r($_FILES);die; $files = getFiles(); if ($type == 0) { $uploadPath = '../../../common/upload_image'; } elseif ($type == 1) { $uploadPath = '../../../common/upload_video'; } else { $uploadPath = '../../../common/upload_thumb'; } foreach ($files as $fileInfo) { $upload = new upload($fileName, $fileInfo, $uploadPath, false); $dest = $upload->uploadFile(); $uploadFiles[] = $dest; } $uploadFiles = array_values(array_filter($uploadFiles)); return $uploadFiles; }
function getFiles($src) { if ($handle = opendir($src)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_file("{$src}/{$file}") && eregi('.pdf', $file)) { $url = str_replace("..", $_SERVER['HTTP_HOST'], $src); echo ' <p><a href="http://' . $url . '/' . $file . '" target="_blank">' . $file . "</a></p>\n"; } else { if (is_dir("{$src}/{$file}")) { echo "\t\t\t\t\t<h2>{$file}</h2>\n"; getFiles("{$src}/{$file}"); } } } } closedir($handle); } }
function getFiles($dir) { $files = array(); $d = opendir($dir); if ($d) { while ($f = readdir($d)) { if ($f == '.' || $f == '..' || $f == '.svn' || $f == '.git') { continue; } if (is_dir($dir . '/' . $f)) { $files = array_merge($files, getFiles($dir . '/' . $f)); } else { $files[] = $dir . '/' . $f; } } closedir($d); } return $files; }
/** * Outputs a table with currently detected themes in * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function themes() { $objForm = Core_Classes_coreObj::getForm(); $objTPL = Core_Classes_coreObj::getTPL(); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl', 'table' => cmsROOT . 'modules/core/views/admin/themes/manageTable.tpl')); $dir = cmsROOT . 'themes'; $tpls = getFiles($dir); //echo dump($tpls); foreach ($tpls as $tpl) { if ($tpl['type'] !== 'dir') { continue; } $tplName = secureMe($tpl['name'], 'alphanum'); $details = $this->getDetails($tplName); //echo dump($details, $tplName); $objTPL->assign_block_vars('theme', array('NAME' => doArgs('name', 'N/A', $details), 'VERSION' => doArgs('version', '0.0', $details), 'ENABLED' => 'true', 'COUNT' => '9001', 'MODE' => doArgs('mode', 'N/A', $details), 'AUTHOR' => doArgs('author', 'N/A', $details))); } $objTPL->parse('table', false); Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Theme Management', 'CONTENT' => $objTPL->get_html('table', false), 'ICON' => 'fa-icon-user'))); }
function bm_get_cache_data() { $books = array(); $files = getFiles(BMBOOKPATH); # collect all book data foreach ($files as $file) { if (isFile($file, BMBOOKPATH, 'xml')) { $data = getXML(BMBOOKPATH . $file); $time = strtotime($data->date); while (array_key_exists($time, $books)) { $time++; } $books[$time]['slug'] = basename($file, '.xml'); $books[$time]['title'] = strval($data->title); $books[$time]['date'] = strval($data->date); $books[$time]['tags'] = strval($data->tags); $books[$time]['private'] = strval($data->private); } } krsort($books); return $books; }
function sendFile($relpath, $fileindex) { $filelist = getFiles($relpath); $filename = $filelist[$fileindex]['name']; $strFilepath = TTPDS_DIR . "/" . $relpath . "/" . $filename; $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type extension $mime = finfo_file($finfo, $strFilepath); finfo_close($finfo); if (file_exists($strFilepath)) { header('Content-Description: File Transfer'); header('Content-Type: ' . $mime); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . $filelist[$fileindex]['size']); readfile($strFilepath); exit; // needed to prevent html buffer not to be attached to file } }
function getFiles($dir) { $files = array(); if (is_dir($dir)) { $d = opendir($dir); if ($d) { while ($f = readdir($d)) { if ($f == '.' || $f == '..' || preg_match('/^\\.svn$/', $f)) { continue; } foreach (getFiles($dir . '/' . $f) as $fd) { $files[] = $fd; } } closedir($d); } } else { if (preg_match('/\\.c$/', $dir)) { $files[] = $dir; } } return $files; }
function nm_get_cache_data() { $posts = array(); $files = getFiles(NMPOSTPATH); # collect all post data foreach ($files as $file) { if (isFile($file, NMPOSTPATH, 'xml')) { $data = getXML(NMPOSTPATH . $file); $time = strtotime($data->date); while (array_key_exists($time, $posts)) { $time++; } $posts[$time]['slug'] = basename($file, '.xml'); $posts[$time]['title'] = strval($data->title); $posts[$time]['date'] = strval($data->date); $posts[$time]['tags'] = strval($data->tags); $posts[$time]['private'] = strval($data->private); $posts[$time]['image'] = strval($data->image); $posts[$time]['author'] = strval($data->author); } } krsort($posts); return $posts; }
function getFiles($dir, $file_extension) { //echo $dir; $result = array(); $excludeFilesArray = array("_files", "runner.htm", "fileArray.php"); $d = dir($dir); while ($entry = $d->read()) { if (in_array($entry, $excludeFilesArray) || substr($entry, 0, 1) == '.') { continue; } if (is_dir($dir . '/' . $entry)) { $result = array_merge($result, getFiles($dir . '/' . $entry, $file_extension)); } else { if (!in_array($entry, $excludeFilesArray) && substr_count($entry, '-') == 0) { if ($file_extension && substr($entry, -strlen($file_extension)) != $file_extension) { continue; } $result[] = $GLOBALS['urlprefix'] . '/' . (substr($dir, 0, 2) == './' ? substr($dir, 2) : $dir) . '/' . $entry; } } } $d->close(); return $result; }
<a href = empty.php><img src = "images/act.gif" width = 100px></img><br> <a href = index.php><img src = "images/index.gif" width = 100px></img><br> <a href = company.php><img src = "images/company.gif" width = 100px></img><br> <a href = contacts.php><img src = "images/contacts.gif" width = 100px></img><br> <a href = catalog.php><img src = "images/catalog.gif" width = 100px></img><br> <a href = info.php><img src = "images/info.gif" width = 100px></img><br> <a href = work.php><img src = "images/work.gif" width = 100px></img><br> <a href = friends.php><img src = "images/friends.gif" width = 100px></img><br> </td> <td valign = top rowspan = 2> <?php $count = 0; foreach (getFiles($imgDir) as $file) { $count = $count + 1; echo '<a href="' . $imgDir . $file . '" class="highslide" onclick="return hs.expand(this)">'; echo '<img src="' . $imgDir . $file . '" width="40%"/>'; echo '</a>'; } ?> <br> <?php $host = 'localhost'; $user = '******'; $pass = '******'; $db = 'unsen'; $connection = mysql_connect($host, $user, $pass); mysql_select_db($db, $connection); mysql_query("set names 'cp1251'", $connection);
function getFiles($directory, $listing = array(), $count = 0) { global $_lang; global $filesfound; $dummy = $count; if ($files = scandir($directory)) { foreach ($files as $file) { if ($file == '.' || $file == '..') { continue; } elseif ($h = @opendir($directory . $file . "/")) { closedir($h); $count = -1; $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); } elseif (strpos($file, '.htm') !== false) { $listing[$dummy] = $file; $dummy = $dummy + 1; $filesfound++; } } } else { echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; } return $listing; }
$load['plugin'] = true; include 'inc/common.php'; login_cookie_check(); exec_action('load-profile'); $showpermfail = true; // true, throw errors on failed permission attempts, else silently ignores your requests // default permissions, allow based on is user superuser and gs permission definitions $allowadd = $USR == getSuperUserId() && getDef('GSPROFILEALLOWADD', true); $allowedit = $USR == getSuperUserId() && getDef('GSPROFILEALLOWEDIT', true); // init $adding = false; // flag for doing user creation $editing = false; // flag for doing user edit $userid = $USR; $lang_array = getFiles(GSLANGPATH); $pwd1 = $error = $success = $pwd2 = $editorchck = null; $permerror = ''; if (isset($_REQUEST['add'])) { $adding = true; } else { if (isset($_GET['userid'])) { $editing = true; } } if ($adding) { if (!exec_secfilter('profile-adduser', $allowadd)) { // @secfilter profile-adduser verify profile add new user $userid = $USR; $permerror = i18n_r('ER_REQ_PROC_FAIL'); $adding = false;
/** * Folder Items * * Return the count of items within the given folder * * @param string $folder * @return int count of folder items */ function folder_items($folder) { return count(getFiles($folder)); }
* @Package: GetSimple * @Action: Creates sitemap.xml in the site's root. * *****************************************************/ // Setup inclusions $load['plugin'] = true; // Relative $relative = '../'; // Include common.php include 'inc/common.php'; // check validity of request if ($_REQUEST['s'] === $SESSIONHASH) { // Variable settings $path = $relative . 'data/pages/'; $count = "0"; $filenames = getFiles($path); if (count($filenames) != 0) { foreach ($filenames as $file) { if (isFile($file, $path, 'xml')) { $data = getXML($path . $file); $status = $data->menuStatus; $pagesArray[$count]['url'] = $data->url; $pagesArray[$count]['parent'] = $data->parent; $pagesArray[$count]['date'] = $data->pubDate; $pagesArray[$count]['private'] = $data->private; $pagesArray[$count]['menuStatus'] = $data->menuStatus; $count++; } } } $pagesSorted = subval_sort($pagesArray, 'menuStatus');