/** * Returns a list of payment providers. * * @return array List of <PaymentProvider> objects */ function payment_list_providers() { $res = array(); foreach (system_glob(__DIR__ . '/payment/*.class.php') as $file) { $cn = basename($file, ".class.php"); $cn = new $cn(); if ($cn instanceof PaymentProvider && $cn->IsAvailable()) { $res[] = $cn; } } return $res; }
/** * @internal Used from <minify_pre_render_handler>(). */ function use_minified_file($target_base_name, $kind, $base_uri) { global $CONFIG; $target_base_name .= isSSL() ? ".1" : ".0"; foreach (system_glob($target_base_name . ".*.{$kind}") as $f) { $CONFIG["use_compiled_{$kind}"] = $base_uri . basename($f); return; } unset($CONFIG["use_compiled_{$kind}"]); }
/** * Lists all files of a directory recursively. * * Note that default pattern in *.* thus only listing files with a dot in the name. * If you change that to '*' everything will be returned. * We use *.* a common filter for all files (yes, we know that this is wrong). * @param string $directory Directory name * @param string $pattern Filename pattern * @return array Listing of all files */ function system_glob_rec($directory = '', $pattern = '*.*') { system_ensure_path_ending($directory); $paths = system_glob($directory . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); $files = system_glob($directory . $pattern); foreach ($paths as $path) { $files = array_merge($files, system_glob_rec($path, $pattern)); } return $files; }
/** * Initializes the Scavix ScavixWDF. * * This is one of two essential functions you must know about. * Initializes the complete ScavixWDF, loads all essentials and defined modules and initializes them, * prepares the session and writes out some headers (from config too). * @param string $application_name Application name. This will become your session cookie name! * @param bool $skip_header Optional. If true, will not send headers. * @param bool $logging_category An initial category for logging. Very optional! * @return void */ function system_init($application_name, $skip_header = false, $logging_category = false) { global $CONFIG; $thispath = __DIR__; if (!isset($_SESSION["system_internal_cache"])) { $_SESSION["system_internal_cache"] = array(); } $CONFIG['system']['application_name'] = $application_name; if (!isset($CONFIG['model']['internal']['connection_string'])) { $CONFIG['model']['internal']['connection_string'] = 'sqlite::memory:'; } // load essentials as if they were modules. system_load_module('essentials/logging.php'); system_load_module('essentials/model.php'); system_load_module('essentials/session.php'); system_load_module('essentials/resources.php'); system_load_module('essentials/admin.php'); system_load_module('essentials/localization.php'); system_load_module('essentials/translation.php'); foreach (system_glob($thispath . '/essentials/*.php') as $essential) { // load all other essentials system_load_module($essential); } if ($logging_category) { logging_add_category($logging_category); } logging_set_user(); // works as both (session and logging) are now essentials session_run(); // auto-load all system-modules defined in $CONFIG['system']['modules'] foreach ($CONFIG['system']['modules'] as $mod) { if (file_exists($thispath . "/modules/{$mod}.php")) { system_load_module($thispath . "/modules/{$mod}.php"); } elseif (file_exists("{$mod}.php")) { system_load_module("{$mod}.php"); } } if (isset($_REQUEST['request_id'])) { session_keep_alive('request_id'); } // attach more headers here if required if (!$skip_header) { try { foreach ($CONFIG['system']['header'] as $k => $v) { header("{$k}: {$v}"); } } catch (Exception $ex) { } } // if $_SERVER['SCRIPT_URI'] is not set build from $_SERVER['SCRIPT_NAME'] and $_SERVER['SERVER_NAME'] Mantis #3477 if ((!isset($_SERVER['SCRIPT_URI']) || $_SERVER['SCRIPT_URI'] == '') && isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SERVER_NAME'])) { $_SERVER['SCRIPT_URI'] = $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; } execute_hooks(HOOK_POST_INIT); }
function createLinks() { global $home; $quickref = @file_get_contents(file_exists(__DIR__ . '/quick.ref') ? __DIR__ . '/quick.ref' : "http://php.net/quickref.php"); if ($quickref && preg_match_all('|<li><a href="([^"]+)">([^<]+)</a></li>|', $quickref, $documented)) { file_put_contents(__DIR__ . '/quick.ref', $quickref); list(, $doc_links, $doc_names) = $documented; $documented = array_combine($doc_names, $doc_links); $home['funcs'] = array_merge($documented, $home['funcs']); // add PHP predefined functions $def_funcs = get_defined_functions(); foreach ($def_funcs['internal'] as $f) { if (isset($documented[$f])) { $home['funcs'][$f] = strtolower("http://www.php.net" . $documented[$f]); } } // add PHP predefined classes foreach (array_merge(get_declared_classes(), get_declared_interfaces()) as $c) { if (isset($documented[strtolower($c)])) { $home['classes'][$c] = strtolower("http://www.php.net" . $documented[strtolower($c)]); } } } else { $this->errors[] = "Could not create PHP internal functions/classes links"; } // sorting the found information foreach (array_keys($home) as $key) { natksort($home[$key]); } $linking = function ($match) { global $home, $current_link_file; if ($match[1] != 'array') { if (isset($home['funcs'][$match[1]])) { return "[{$match[1]}]({$home['funcs'][$match[1]]})"; } if (isset($home['classes'][$match[1]])) { return "[{$match[1]}]({$home['classes'][$match[1]]})"; } } $p = explode("::", $match[1]); if (count($p) < 2) { return $match[0]; } if ($p[0] == "NAMESPACE") { // log_debug("NS link found: {$p[1]}",$home['namespaces'][$p[1]]); return "[" . str_replace(":", "\\", $p[1]) . "](namespacetree#wiki-{$home['namespaces'][$p[1]]['hash']})"; } if ($p[0] == "PARENTCLASSES") { $parents = array(); $class = $p[1]; do { $class = DocMain::getParent($class); if ($class) { $parents[] = DocMain::linkCls($class); } } while ($class); if (count($parents) == 0) { return ""; } return "\n\n**Extends**: " . implode(" » ", $parents); } if ($p[0] == "SUBCLASSES") { $subs = array(); DocMain::getSubclasses($p[1], $subs, false); if (count($subs) == 0) { return ""; } return "\n\n**Subclasses**: " . implode(", ", $subs); } if ($p[0] == "OVERRIDE") { if (count($p) != 3) { return ""; } $class = $p[1]; do { $class = DocMain::getParent($class); if (!$class) { break; } if (isset($home['methods'][$class][$p[2]])) { return "[{$class}::{$p[2]}]({$home['methods'][$class][$p[2]]})"; } } while (true); return ""; } if (!isset($home['methods'][$p[0]][$p[1]])) { if (!in_array($match[0], DocMain::$known_token)) { $lnk = DocMain::linkCls($p); if ($lnk) { return $lnk; } log_debug("NO match", $match[0], "in {$current_link_file}", $p); } return $match[0]; } return "[{$match[1]}]({$home['methods'][$p[0]][$p[1]]})"; }; $regex1 = '/<([a-zA-Z0-9_:]+)>/'; $regex2 = '/`([a-zA-Z0-9_:]+)`/'; global $current_link_file; foreach (system_glob(__DIR__ . '/out/*_*') as $md) { $current_link_file = $md; $cont = file_get_contents($md); $cont = preg_replace_callback($regex1, $linking, $cont); $cont = preg_replace_callback($regex2, $linking, $cont); file_put_contents($md, $cont); } }
protected function rotate() { $this->ensureFile(); if (!isset($this->max_filesize) || @filesize($this->filename) < $this->max_filesize) { return; } $ext = pathinfo($this->filename, PATHINFO_EXTENSION); $archived = preg_replace('/.' . $ext . '$/', "_" . date("Y-m-d-H-i-s") . ".{$ext}", $this->filename); if (!@rename($this->filename, $archived)) { return; } $source = $archived; $archived = $archived . ".gz"; if ($fp_out = gzopen($archived, 'wb9')) { if ($fp_in = fopen($source, 'rb')) { while (!feof($fp_in)) { @gzwrite($fp_out, fread($fp_in, 1024 * 512)); } @fclose($fp_in); } else { $error = true; } @gzclose($fp_out); } @unlink($source); if (isset($this->keep_for_days) && $this->keep_for_days > 0) { $max_age = time() - 86400 * $this->keep_for_days; foreach (system_glob(str_replace(".{$ext}", "_*.gz", $this->filename)) as $f) { if (@filemtime($f) < $max_age) { @unlink($f); } } } }