function copyr($source, $dest) { if (is_link($source)) { return symlink(readlink($source), $dest); } if (is_file($source)) { $copied = copy($source, $dest); $content = file_get_contents($dest); $content = str_replace("Forone\\Admin\\Controllers", "App\\Http\\Controllers\\Forone\\Admin\\Controllers", $content); file_put_contents($dest, $content); return $copied; } if (!is_dir($dest)) { mkdir($dest, 0777, true); } $dir = dir($source); while (false !== ($entry = $dir->read())) { if ($entry == '.' || $entry == '..') { continue; } copyr("{$source}/{$entry}", "{$dest}/{$entry}"); } $dir->close(); return true; }
public static function get_tests($root_file, $root_class, $add_skip = null) { $tests = array(); if (!isset($root_file) || !isset($root_class)) { return $tests; } $skip = array('.', '..', 'all.php'); if (is_array($add_skip)) { $skip = array_merge($skip, $add_skip); } $skip = array_flip($skip); $path_parts = pathinfo($root_file); $tests_dir = dir($path_parts['dirname']); $prefix = str_replace('_all', '', $root_class); while (($testfile = $tests_dir->read()) !== false) { if (array_key_exists($testfile, $skip)) { continue; } $path_parts = pathinfo($testfile); $test_name = str_replace('.php', '', $path_parts['filename']); $test_name = str_replace('Test', '', $test_name); if ($test_name != '') { require_once realpath(dirname($root_file)) . "/{$testfile}"; $tests[] = "{$prefix}_{$test_name}"; } } return $tests; }
function getimages($dir) { global $imagetypes; // array to hold return values; $retval = array(); // add trailing slashes if missing; if (substr($dir, -1) != "/") { $dir .= "/images/"; } // Full server path to dir $fulldir = "{$_SERVER['DOCUMENT_ROOT']}/{$dir}"; // $fulldir ="localhost/novademo-localhost/images/"; $d = @dir($fulldir) or die("getimages: Failed opening directory {$_SERVER['DOCUMENT_ROOT']}/{$dir} for reading"); while (false != ($entry = $d->read())) { // skip hidden files if ($entry[0] == ".") { continue; } // check for image files $f = escapeshellarg("{$fulldir}" . "{$entry}"); $mimetype = trim(`file -bi {$f}`); foreach ($imagetypes as $valid_type) { if (preg_match("@^{$valid_type}@", $mimetype)) { $retval[] = array('file' => "/{$dir}" . "{$entry}", 'size' => getimagesize("{$fulldir}" . "{$entry}")); break; } } } $d->close(); return $retval; }
/** * Fetch the set of available skins. * @return array of strings * @static */ static function getSkinNames() { global $wgValidSkinNames; static $skinsInitialised = false; if (!$skinsInitialised) { # Get a list of available skins # Build using the regular expression '^(.*).php$' # Array keys are all lower case, array value keep the case used by filename # wfProfileIn(__METHOD__ . '-init'); global $wgStyleDirectory; $skinDir = dir($wgStyleDirectory); # while code from www.php.net while (false !== ($file = $skinDir->read())) { // Skip non-PHP files, hidden files, and '.dep' includes $matches = array(); if (preg_match('/^([^.]*)\\.php$/', $file, $matches)) { $aSkin = $matches[1]; $wgValidSkinNames[strtolower($aSkin)] = $aSkin; } } $skinDir->close(); $skinsInitialised = true; wfProfileOut(__METHOD__ . '-init'); } return $wgValidSkinNames; }
/** * Loads ushahidi themes */ public function register() { // Array to hold all the CSS files $theme_css = array(); // 1. Load the default theme Kohana::config_set('core.modules', array_merge(array(THEMEPATH . "default"), Kohana::config("core.modules"))); $css_url = Kohana::config("cache.cdn_css") ? Kohana::config("cache.cdn_css") : url::base(); // HACK: don't include the default style.css if using the ccnz theme if (Kohana::config("settings.site_style") != "ccnz") { $theme_css[] = $css_url . "themes/default/css/style.css"; } // 2. Extend the default theme if (Kohana::config("settings.site_style") != "default") { $theme = THEMEPATH . Kohana::config("settings.site_style"); Kohana::config_set('core.modules', array_merge(array($theme), Kohana::config("core.modules"))); if (is_dir($theme . '/css')) { $css = dir($theme . '/css'); // Load all the themes css files while (($css_file = $css->read()) !== FALSE) { if (preg_match('/\\.css/i', $css_file)) { $theme_css[] = url::base() . "themes/" . Kohana::config("settings.site_style") . "/css/" . $css_file; } } } } Kohana::config_set('settings.site_style_css', $theme_css); }
/** * Function which will return the hash after passing through all folders and subfolders within it. * @param $dir - Starting folder to scan * @param $excludeFileList - List of filenames to exclude from scan * @param $excludeExtensionList - List of extensions to exclude from scan * @return Final MD5 of all files scanned. */ function getMD5Hash($dir, $excludeFileList, $excludeExtensionList) { if (!is_dir($dir)) { return false; } $fileMD5list = array(); $d = dir($dir); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..') { if (is_dir($dir . '/' . $entry)) { $fileMD5list[] = getMD5Hash($dir . '/' . $entry, $excludeFileList, $excludeExtensionList); } else { if (stripos($excludeFileList, $entry) === false) { $extension = end(explode('.', $entry)); //get the file extension if (stripos($excludeExtensionList, $extension) === false) { $fileMD5list[] = md5_file($dir . '/' . $entry); //Prepare list to MD5 only allowed } } } } } $d->close(); return md5(implode('', $fileMD5list)); //Return final MD5 of all files }
function xCopy($source, $destination, $child) { //用法: // xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,包括子目录 // xCopy("feiy","feiy2",0):拷贝feiy下的文件到 feiy2,不包括子目录 //参数说明: // $source:源目录名 // $destination:目的目录名 // $child:复制时,是不是包含的子目录 if (!is_dir($source)) { echo "Error:the {$source} is not a direction!"; return 0; } if (!is_dir($destination)) { mkdir($destination, 0777); } $handle = dir($source); while ($entry = $handle->read()) { if ($entry != "." && $entry != "..") { if (is_dir($source . "/" . $entry)) { if ($child) { xCopy($source . "/" . $entry, $destination . "/" . $entry, $child); } } else { copy($source . "/" . $entry, $destination . "/" . $entry); } } } return 1; }
/** * Get a pattern and a directory, and returns an array of filenames matching the given pattern * * @param string $file_pattern * @param string $current_dir * @param boolean $recursively * @return array An array of files matching the given pattern */ public static function getFilesMatchingPattern($file_pattern, $current_dir, $recursively = true) { $return_value = array(); if (is_readable($current_dir) && is_dir($current_dir)) { $dir = dir($current_dir); while (false !== ($file = $dir->read())) { $current_file = $current_dir . DIRECTORY_SEPARATOR . $file; $position_of_dot = strpos($file, "."); if (is_readable($current_file) && $position_of_dot !== 0) { if (is_file($current_file)) { $file_matched = array(); if (preg_match('/^' . str_replace('*', '(.+?)', $file_pattern) . '$/', $file, $file_matched)) { $return_value[strtoupper($current_file)] = $current_file; } } else { if (is_dir($current_file) && $recursively) { $return_value += self::getFilesMatchingPattern($file_pattern, $current_file); } } } } } else { throw new Exception('The directory ' . $current_dir . ' specified in the includepath does not exists or is not readable.'); } return $return_value; }
function getType() { // first, get a list of a possible parent types $templates = array(); $d = dir('include/SugarObjects/templates'); while ($filename = $d->read()) { if (substr($filename, 0, 1) != '.') { $templates[strtolower($filename)] = strtolower($filename); } } // If a custom module, then its type is determined by the parent SugarObject that it extends $type = $GLOBALS['beanList'][$this->module]; require_once $GLOBALS['beanFiles'][$type]; do { $seed = new $type(); $type = get_parent_class($seed); } while (!in_array(strtolower($type), $templates) && $type != 'SugarBean'); if ($type != 'SugarBean') { return strtolower($type); } // If a standard module then just look up its type - type is implicit for standard modules. Perhaps one day we will make it explicit, just as we have done for custom modules... $types = array('Accounts' => 'company', 'Bugs' => 'issue', 'Cases' => 'issue', 'Contacts' => 'person', 'Documents' => 'file', 'Leads' => 'person', 'Opportunities' => 'sale'); if (isset($types[$this->module])) { return $types[$this->module]; } return "basic"; }
/** * 复制文件夹(递归)到目标文件夹 **/ function xCopy($source, $destination) { if (substr($source, -1) == "/") { $source = substr($source, 0, -1); } if (substr($destination, -1) == "/") { $destination = substr($destination, 0, -1); } if (!is_dir($source)) { return 0; } if (!is_dir($destination)) { mkdir($destination, 0777); } $destination = $destination . "/" . basename($source); if (!is_dir($destination)) { mkdir($destination, 0777); } $handle = dir($source); while ($entry = $handle->read()) { if ($entry != "." && $entry != "..") { if (is_dir($source . "/" . $entry)) { xCopy($source . "/" . $entry, $destination); } else { copy($source . "/" . $entry, $destination . "/" . $entry); } } } return 1; }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $definePath = APPLICATION_PATH . '/modules/virtuemart/defines/'; $d = dir($definePath) or die("Wrong module path: {$definePath}"); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..' && !is_dir($definePath . $entry)) { require_once $definePath . $entry; } } $d->close(); // Tu dong autoload toan bo cac tai nguyen cua module // $autoLoader = new Zend_Loader_Autoloader_Resource(array( // 'basePath' => APPLICATION_PATH . '/modules/virtuemart', // 'namespace' => '', // 'resourceTypes' => array( //// 'form' => array( //// 'path' => 'admin/forms/', //// 'namespace' => 'Admin_Form_', //// ), // 'model' => array( // 'path' => 'models/', // 'namespace' => DEFAULT_VM_NAMESPACE // ), // ), // )); }
/** * recurses through the Test subdir and includes classes in each test group subdir, * then builds an array of classnames for the tests that will be run * */ public function loadTests($test_path = NULL) { $this->resetStats(); if ($test_path === NULL) { // this seems hackey. is it? dunno. $test_path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Security' . DIRECTORY_SEPARATOR . 'Test'; } $test_root = dir($test_path); while (false !== ($entry = $test_root->read())) { if (is_dir($test_root->path . DIRECTORY_SEPARATOR . $entry) && !preg_match('|^\\.(.*)$|', $entry)) { $test_dirs[] = $entry; } } // include_once all files in each test dir foreach ($test_dirs as $test_dir) { $this_dir = dir($test_root->path . DIRECTORY_SEPARATOR . $test_dir); while (false !== ($entry = $this_dir->read())) { if (!is_dir($this_dir->path . DIRECTORY_SEPARATOR . $entry) && preg_match('/[A-Za-z]+\\.php/i', $entry)) { $className = "Zend_Environment_Security_Test_" . $test_dir . "_" . basename($entry, '.php'); Zend::loadClass($className); $classNames[] = $className; } } } $this->_tests_to_run = $classNames; }
function ReadAllProvider() { $dirName = dirname(__FILE__) . DIRECTORY_SEPARATOR; $handle = dir($dirName); if ($handle === false) { return; } while (false !== ($entry = $handle->read())) { if (is_dir($entry)) { continue; } if (!preg_match("/byjg\\.provider\\.(.*)\\.php/", $entry)) { continue; } $providerName = substr($entry, strlen('byjg.provider.'), strlen($entry)); $providerName = substr($providerName, 0, strlen($providerName) - strlen('.php')); if (empty($providerName)) { continue; } if ($providerName == 'provider') { continue; } require_once $entry; $this->_providers[$providerName] = $entry; } }
function clearFolderContent($folder_path) { if (!file_exists($folder_path) or !is_dir($folder_path)) { return false; } $folder_path = str_replace("\\", "/", realpath($folder_path)); if (_ml_substr($folder_path, -1, 1) != "/") { $folder_path .= "/"; } $folder = dir($folder_path); while (($entry = $folder->read()) !== false) { if ($entry == '..' or $entry == '.') { continue; } if (is_dir($folder_path . $entry)) { $this->clearFolderContent($folder_path . $entry); @rmdir($folder_path . $entry); } if (is_file($folder_path . $entry)) { @unlink($folder_path . $entry); } } $folder->close(); return true; }
function execute(&$request) { if ($request['user']->isMember() && $request['user']->get('perms') >= ADMIN) { $request['template']->setVar('current_location', $request['template']->getVar('L_FILEBROWSER')); $request['template']->setVar('opener_input', @$_REQUEST['input']); $request['template']->setVar('selected', @$_REQUEST['selected']); $directory = BB_BASE_DIR . DIRECTORY_SEPARATOR . @$_REQUEST['dir']; if (!isset($_REQUEST['dir']) || $_REQUEST['dir'] == '' || !file_exists($directory) || !is_dir($directory)) { $action = new K4InformationAction(new K4LanguageElement('L_DIRECTORYDOESNTEXIST', BB_BASE_DIR . DIRECTORY_SEPARATOR . $dir), 'content', FALSE); return $action->execute($request); } $filetypes = array('html' => array('HTM', 'HTML', 'JS'), 'php' => array('PHP'), 'img' => array('GIF', 'PNG', 'TIFF', 'JPG', 'JPEG', 'BMP', 'ICO')); $filetype = (!isset($_REQUEST['filetype']) || $_REQUEST['filetype'] == '') && !array_key_exists(@$_REQUEST['filetype'], $filetypes) ? FALSE : $_REQUEST['filetype']; $dir = dir($directory); $files = array(); while (false !== ($file = $dir->read())) { if ($file != '.' && $file != '..' && $file != 'Thumbs.db') { if (!is_dir($directory . DIRECTORY_SEPARATOR . $file)) { $temp = array(); /* Get File extension */ $exts = explode(".", $file); $temp['fileext'] = count($exts) < 2 ? '' : strtoupper($exts[count($exts) - 1]); $temp['shortname'] = $file; $temp['filename'] = $_REQUEST['dir'] . '/' . $file; $temp['file'] = $exts[0]; if (in_array($temp['fileext'], $filetypes['html'])) { $temp['filetype'] = 'html'; } else { if (in_array($temp['fileext'], $filetypes['php'])) { $temp['filetype'] = 'php'; } else { if (in_array($temp['fileext'], $filetypes['img'])) { $temp['filetype'] = 'img'; $dimensions = $this->resize_image($temp['filename']); $temp['width'] = $dimensions[0]; $temp['height'] = $dimensions[1]; } else { $temp['filetype'] = ''; } } } if (!$filetype) { $files[] = $temp; } else { if ($temp['filetype'] == $filetype) { $files[] = $temp; } } } } } $files =& new FAArrayIterator($files); $request['template']->setVar('img', 'img'); $request['template']->setList('files_list', $files); $request['template']->setFile('content', 'file_browser.html'); } else { no_perms_error($request); } return TRUE; }
/** used in phpdoc.php and new_phpdoc.php */ function phpDocumentor_ConfigFileList($directory) { $ret = array(); if (@is_dir($directory)) { $ret = array(); $d = @dir($directory); // thanks to Jason E Sweat (jsweat@users.sourceforge.net) for fix while ($d && ($entry = $d->read())) { $getentry = false; if (strcmp($entry, ".") != 0 && strcmp($entry, "..") != 0) { if (substr($entry, 0, 1) != ".") { $getentry = true; } } if ($getentry == true) { if (strpos($entry, '.ini')) { if (is_file($directory . PATH_DELIMITER . $entry)) { $ret[] = str_replace('.ini', '', $entry); } } } } if ($d) { $d->close(); } } else { } return $ret; }
function full_rmdir($dir) { if (!is_writable($dir)) { if (!@chmod($dir, WT_PERM_EXE)) { return false; } } $d = dir($dir); while (false !== ($entry = $d->read())) { if ($entry == '.' || $entry == '..') { continue; } $entry = $dir . '/' . $entry; if (is_dir($entry)) { if (!full_rmdir($entry)) { return false; } continue; } if (!@unlink($entry)) { $d->close(); return false; } } $d->close(); rmdir($dir); return TRUE; }
function rmdirr($dirname, $oc = 0) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname) && time() - fileatime($dirname) > 3600) { return unlink($dirname); } // Loop through the folder if (is_dir($dirname)) { $dir = dir($dirname); while (false !== ($entry = $dir->read())) { // Skip pointers if ($entry === '.' || $entry === '..') { continue; } // Recurse rmdirr($dirname . '/' . $entry, $oc); } $dir->close(); } // Clean up if ($oc == 1) { return rmdir($dirname); } }
public function run() { DB::table('mst_countries')->truncate(); $country_name_full = array(); $country_name_file = app_path() . "/country_name_new.txt"; $myfile_country_name = fopen($country_name_file, "r") or die("Unable to open file!"); $read_country_name_file = fread($myfile_country_name, filesize($country_name_file)); $array_country_names = explode("\n", $read_country_name_file); foreach ($array_country_names as $key_country_names) { if ($key_country_names != null) { $country_name_list = explode(" ", $key_country_names); $country_name_full[$country_name_list[0]] = $country_name_list[1]; } } $country_name_ja = ""; $file_folder = public_path() . "/flags/"; //use the directory class $files = dir($file_folder); //read all files ;from the directory chdir($file_folder); $file_names = glob('*.png'); $i = 1; //$c = 1; foreach ($file_names as $file_name) { $country_name_en = explode('.', $file_name, -1); if (!empty($country_name_full[$country_name_en[0]])) { $country_name_ja = $country_name_full[$country_name_en[0]]; } $country = array("country_name" => $country_name_en[0], "flag_url" => "flags/" . $file_name, "country_name_ja" => $country_name_ja); Country::create($country); $i++; echo $i . "\n"; } closedir($files->handle); }
function generate() { $table_name = "gu"; $ctl = "gu"; $tmplvar = array(); $tmplvar["ctl"] = $ctl; $tmplvar["table_name"] = $table_name; $db = $this->fmodel($table_name); $tmplvar["table"] = $db->detail(); $view = View::getObj(); $files = array(); $dir = dir(ROOT . "data/programetpl/crub/"); while (($file = $dir->read()) !== false) { if (!preg_match("/^\\./", $file) && preg_match("/\\.tpl\$/", $file)) { $str = $view->fetch_html($tmplvar, ROOT . "data/programetpl/crub/{$file}"); echo "{$file}<br><textarea cols=300 rows=20>" . e($str) . "</textarea><br>"; if (f("go")) { mkdir(ROOT . "data/programetpl/log/{$ctl}", 0700); $handle = fopen(ROOT . "data/programetpl/log/{$ctl}/{$file}", 'w'); fwrite($handle, $str); fclose($handle); } } } $dir->close(); echo "<a href=/admin/generate/?go=1>DO</a>"; exit; }
function delDir($dirName, $orig = false) { if (!$orig) { $orig = $dirName; } if (empty($dirName)) { return true; } if (file_exists($dirName)) { $dir = dir($dirName); while ($file = $dir->read()) { if ($file != '.' && $file != '..') { if (is_dir($dirName . '/' . $file)) { Pommo_Helper_Maintenance::delDir($dirName . '/' . $file, $orig); } else { unlink($dirName . '/' . $file) or die('File ' . $dirName . '/' . $file . ' couldn\'t be deleted!'); } } } $dir->close(); if ($dirName != $orig) { @rmdir($dirName) or die('Folder ' . $dirName . ' couldn\'t be deleted!'); } } else { return false; } return true; }
function copy_files($from_folder, $to_folder) { if (!is_dir($from_folder)) { exit("Cannot copy from {$from_folder}, no such file or directory\n"); } if (!is_dir($to_folder)) { exit("Cannot copy to {$to_folder}, no such file or directory\n"); } $d = dir($from_folder); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..') { if (is_dir($entry)) { continue; } // skip folders. $from_file = $from_folder . DIRECTORY_SEPARATOR . $entry; $to_file = $to_folder . DIRECTORY_SEPARATOR . $entry; if (is_file($to_file)) { echo "\texists {$to_file}\n"; continue; } if (!copy($from_file, $to_file)) { echo "cannot copy: {$from_file} to {$to_file}!\n"; continue; } else { echo "\tcreate {$to_file}\n"; } } } }
function build_cache_postimg() { $imgextarray = array('jpg', 'gif', 'png'); $imgdir = array('hrline', 'postbg'); $postimgjs = 'var postimg_type = new Array();'; foreach ($imgdir as $perdir) { $count = 0; $pdir = DISCUZ_ROOT . './static/image/' . $perdir; $postimgdir = dir($pdir); $postimgjs .= 'postimg_type["' . $perdir . '"]=['; while ($entry = $postimgdir->read()) { if (in_array(strtolower(fileext($entry)), $imgextarray) && preg_match("/^[\\w\\-\\.\\[\\]\\(\\)\\<\\> &]+\$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($pdir . '/' . $entry)) { $postimg[$perdir][] = array('url' => $entry); $postimgjs .= ($count ? ',' : '') . '"' . $entry . '"'; $count++; } } $postimgjs .= '];'; $postimgdir->close(); } savecache('postimg', $postimg); $cachedir = 'saekv://data/cache/'; if (@($fp = fopen($cachedir . 'common_postimg.js', 'w'))) { fwrite($fp, $postimgjs); fclose($fp); } else { exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .'); } }
private function recurse_copy($source, $target) { if (is_dir($source)) { @mkdir($target); $d = dir($source); while (FALSE !== ($entry = $d->read())) { if ($entry == '.' || $entry == '..') { continue; } $Entry = $source . '/' . $entry; if (is_dir($Entry)) { $res = $this->recurse_copy($Entry, $target . '/' . $entry); if ($res !== true) { return $res; } continue; } if (!@copy($Entry, $target . '/' . $entry)) { return $Entry; } } $d->close(); } else { if (!@copy($source, $target)) { return $source; } } return true; }
function register($group) { $group = basename($group); $directory = DIR_FS_CATALOG . 'includes/hooks/' . $this->_site . '/' . $group; if (file_exists($directory)) { if ($dir = @dir($directory)) { while ($file = $dir->read()) { if (!is_dir($directory . '/' . $file)) { if (substr($file, strrpos($file, '.')) == '.php') { $code = substr($file, 0, strrpos($file, '.')); $class = 'hook_' . $this->_site . '_' . $group . '_' . $code; include $directory . '/' . $file; $GLOBALS[$class] = new $class(); foreach (get_class_methods($GLOBALS[$class]) as $method) { if (substr($method, 0, 7) == 'listen_') { $this->_hooks[$this->_site][$group][substr($method, 7)][] = $code; } } } } } $dir->close(); } } }
/** * Copy a file, or recursively copy a folder and its contents * * @author Aidan Lister <*****@*****.**> * @version 1.0.1 * @link http://aidanlister.com/2004/04/recursively-copying-directories-in-php/ * @param string $source Source path * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ function copyr($source, $dest) { // Check for symlinks if (is_link($source)) { return symlink(readlink($source), $dest); } // Simple copy for a file if (is_file($source)) { return copy($source, $dest); } // Make destination directory if (!is_dir($dest)) { mkdir($dest); } // Loop through the folder $dir = dir($source); while (false !== ($entry = $dir->read())) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories copyr("{$source}/{$entry}", "{$dest}/{$entry}"); } // Clean up $dir->close(); return true; }
function phorum_check_modules_filenames($is_install = false) { $PHORUM = $GLOBALS["PHORUM"]; if ($is_install) { return array(PHORUM_SANITY_SKIP, NULL, NULL); } $d = dir("./mods"); while (false !== ($entry = $d->read())) { // Some entries which we skip by default. if ($entry == '.' || $entry == '..' || $entry == '.svn' || $entry == 'ATTIC' || $entry == '.htaccess') { continue; } // Read in the module information. $lines = array(); if (file_exists("./mods/{$entry}/info.txt")) { $lines = file("./mods/{$entry}/info.txt"); } if (is_file("./mods/{$entry}") && substr($entry, -4) == ".php") { // one file module, skip it } else { if (!file_exists("./mods/{$entry}/info.txt")) { return array(PHORUM_SANITY_WARN, "Your module "{$entry}" doesn't have an info.txt file in its directory. Either its not a module or the installation of that module is broken.", "You should remove all files or directories which are not modules from the mods-directory and fix broken module installations."); } elseif (!file_exists("./mods/{$entry}/{$entry}.php")) { return array(PHORUM_SANITY_WARN, "Your module "{$entry}" doesn't have an corresponding .php file in its directory. \n Each module needs a .php-file with the same name as the directory to work. Either that directory isn't for a module or the installation is broken and either the filename or the directoryname needs corrected.", "You should remove all files or directories which are not modules from the mods-directory and fix broken module installations."); } } } // All checks are OK. return array(PHORUM_SANITY_OK, NULL, NULL); }
/** * Returns a list of folders recursively under the specified * folder path. */ function filemanager_list_folders($path = '') { $folders = array(); if (!empty($path)) { $rpath = 'files/' . $path; $epath = $path . '/'; } else { $rpath = 'files'; $epath = ''; } $d = dir($rpath); if (!$d) { return array(); } while (false !== ($file = $d->read())) { $files[] = $file; } $d->close(); foreach ($files as $file) { if (strpos($file, '.') === 0 || !@is_dir($rpath . '/' . $file)) { continue; } $folders[] = $epath . $file; $subs = filemanager_list_folders($epath . $file); foreach ($subs as $sub) { $folders[] = $sub; } } return $folders; }
function findFilesHelper($additional, &$files, $term = '', $extensions = array()) { $basefolder = __DIR__ . '/../../files/'; $currentfolder = realpath($basefolder . '/' . $additional); $dir = dir($currentfolder); $ignored = array('.', '..', '.DS_Store', '.gitignore', '.htaccess'); while (false !== ($entry = $dir->read())) { if (in_array($entry, $ignored) || substr($entry, 0, 2) == '._') { continue; } if (is_file($currentfolder . '/' . $entry) && is_readable($currentfolder . '/' . $entry)) { // Check for 'term'.. if (!empty($term) && strpos(strtolower($currentfolder . '/' . $entry), $term) === false) { continue; // skip this one.. } // Check for correct extensions.. if (!empty($extensions) && !in_array(getExtension($entry), $extensions)) { continue; // Skip files without correct extension.. } if (!empty($additional)) { $filename = $additional . '/' . $entry; } else { $filename = $entry; } $files[] = $filename; } if (is_dir($currentfolder . '/' . $entry)) { findFilesHelper($additional . '/' . $entry, $files, $term, $extensions); } } $dir->close(); }
protected function _findControllers() { $cDirPaths = Zend_Controller_Front::getInstance()->getControllerDirectory(); $controllers = array(); $privileges = array(); foreach ($cDirPaths as $cPath) { $d = dir($cPath); while (false !== ($entry = $d->read())) { preg_match_all('/(.*)\\.php$/', $entry, $matches); if (!count($matches[0]) > 0) { continue; } $this->_acl->add(new Zend_Acl_Resource($matches[1][0])); include_once $cPath . "/" . $matches[1][0] . ".php"; $class = new ReflectionClass($matches[1][0]); $methods = $class->getMethods(); foreach ($methods as $method) { if (preg_match('/(.*)Action$/', $method->name, $methodMatches)) { $privileges[$methodMatches[1]] = ""; } } // $matches[1][0] . "<br/>"; } } $this->_acl->addRole(new Zend_Acl_Role('administrator'), null, array_keys($privileges)); }