function getPerms() { $_PEFI = $GLOBALS['_PEFI']; $perms = array(); $perms[] = array('global', 'global_ALL', 'global_SHOW', 'global_LIST'); $files = array(); foreach ($_PEFI->modules as $modName => $modDir) { $files = array_merge($files, discoverFilesDeep("{$_PEFI->path}/{$modDir}/data", 'perms.conf')); } foreach ($files as $fileName) { $perms[] = getPermsFromFile($fileName); } return $perms; }
function discoverTests($fsObj) { if (is_dir($fsObj)) { foreach (discoverFilesDeep($fsObj, array('php')) as $fPath) { $fName = basename($fPath); if (!is_dir($fPath) && strpos($fName, 'Test_') === 0) { include_once $fPath; } } } elseif (is_file($fsObj)) { include_once $fsObj; } else { throw new Exception("argument {$fsObj} is not a valid dir or a valid file"); } }
$_PEFI = new stdClass(); $_PEFI->pageDir = '_pages'; // Hardcoded because is used in Router class $_PEFI->path = dirname(__FILE__); $_PEFI->libPath = "{$_PEFI->path}/lib"; $_PEFI->dlibPath = "{$_PEFI->path}/_lib"; $_PEFI->url = '/' . str_replace('\\', '/', basename($_PEFI->path)); $_PEFI->libURL = "{$_PEFI->url}/lib"; $_PEFI->dlibURL = "{$_PEFI->url}/_lib"; if (!isset($pefi['modules'])) { $pefi['modules'] = array('setup' => 'setup', 'user' => 'user', 'site' => 'site', 'page' => 'page'); } $_PEFI->modules = $pefi['modules']; include_once "{$_PEFI->libPath}/pefi_cmshelper.php"; include_once "{$_PEFI->libPath}/pefi_fileshelper.php"; foreach (discoverFilesDeep($_PEFI->libPath, '.class.php') as $file) { include_once $file; } if (session_id() == '') { session_start(); } if (!isset($pefi['logger'])) { if (!isset($pefi['loglevel'])) { $pefi['loglevel'] = Logger::WARNING; } $pefi['logger'] = new Logger($pefi['loglevel'], array(new FileLoggerOutput('_log/general.log'))); } $_PEFI->logger = $pefi['logger']; if (!isset($pefi['dbpref'])) { $pefi['dbpref'] = ''; }
function discoverFilesDeep($startdir, $suffixes, $fullMatch = False) { $files = array(); if (is_dir($startdir)) { $all_files = searchFiles($startdir, $suffixes, $fullMatch); foreach ($all_files as $file) { $file = "{$startdir}/{$file}"; if (is_dir($file)) { $files = array_merge($files, discoverFilesDeep($file, $suffixes, $fullMatch)); } else { $files[] = $file; } } } return $files; }