/** * Returns the path to the library * @return string */ public static function path() { if (static::$path === null) { static::$path = __DIR__ . DIRECTORY_SEPARATOR; } return static::$path; }
/** * Set the root path to use in the path methods. * * @param int|string $path Either one of the PATH class constants or an actual path to a directory that exists, and is readable * * @return void */ public static function usePath($path) { # Use the document root normally set via apache if ($path === self::PATH_DOCUMENT_ROOT) { if (empty($_SERVER["DOCUMENT_ROOT"]) || !is_dir($_SERVER["DOCUMENT_ROOT"])) { throw new \InvalidArgumentException("DOCUMENT_ROOT not defined"); } static::$path = $_SERVER["DOCUMENT_ROOT"]; return; } # Get the full path of the running script and use it's directory if ($path === self::PATH_PHP_SELF) { if (empty($_SERVER["PHP_SELF"]) || !($path = realpath($_SERVER["PHP_SELF"]))) { throw new \InvalidArgumentException("PHP_SELF not defined"); } static::$path = pathinfo($path, PATHINFO_DIRNAME); return; } # Calculate the parent of the vendor directory and use that if ($path === self::PATH_VENDOR_PARENT) { static::$path = realpath(__DIR__ . "/../../../.."); return; } if (is_dir($path)) { static::$path = $path; } else { throw new \InvalidArgumentException("Invalid path specified"); } }
public static function path($path = '') { if (empty($path)) { return static::$path; } static::$path = $path; }
public static function path($path = null) { if (!empty($path)) { static::$path = $path; } return static::$path; }
/** * Verify that the specified directory paths exist and * attempts to create them if not. * @throws \Exception */ private static function _verify_directory_paths() { // Clean strings. static::$path = trim(static::$path); static::$cache_path = trim(static::$cache_path); // Verify that the path is not empty. if (static::$path == '') { throw new \Exception('No view path specified...'); } // Verify that the cache path is not empty. if (static::$cache_path == '') { throw new \Exception('No cache path specified...'); } if (!is_dir(static::$base_path . static::$path)) { // Attempt to create directory. mkdir(static::$base_path . static::$path); if (!is_dir(static::$base_path . static::$path)) { throw new \Exception('"' . static::$base_path . static::$path . '" does not exist."'); } } if (!is_dir(static::$base_path . static::$cache_path)) { // Attempt to create directory. mkdir(static::$base_path . static::$cache_path); if (!is_dir(static::$base_path . static::$cache_path)) { throw new \Exception('"' . static::$base_path . static::$cache_path . '" does not exist."'); } } }
public static function route($routepath = null, $root = null) { // Calculate root (parameter -> global const -> guessed) static::$root = $root ?: ROOT ?: dirname($_SERVER['DOCUMENT_ROOT']); if (substr(static::$root, -1) != DIRECTORY_SEPARATOR) { static::$root .= DIRECTORY_SEPARATOR; } // Get path to route static::$path = $routepath ?: $_REQUEST['routepath']; static::$path = str_replace(chr(0), '', static::$path); // Protect against poison null byte attacks // Split the url on '/' static::$parts = array_filter(explode('/', static::$path)); if (!static::$parts[0]) { static::$parts[0] = static::$default; } // If first part is empty, replace with default // Keep popping file path tokens from static::$parts until we find a routable target, or run out of parts while (count(static::$parts)) { // Build filename foreach (static::$route_prefix as $pre) { $path = static::$root . $pre . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, static::$parts); // If file exists, then include controller and return. if (file_exists($path . static::$extension)) { return static::$filename = $path . static::$extension; } } // Pop the next token off the path, and prepend it to the list of unrouteable parts array_unshift(static::$unrouted_parts, array_pop(static::$parts)); } // Could not find a page to route to - throw exception throw new HTTP\NotFound(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { static::$path = realpath(__DIR__ . '/Tmpl/plates'); if (!static::$path) { throw new \RuntimeException('Path not exists'); } $this->instance = new PlatesRenderer(static::$path); }
public function __construct(Request $request) { static::$path = $request->path(); foreach (static::$paths as $k => $v) { if (strpos(static::$path, $k) !== false) { return $this->table = $v; } } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { static::$path = realpath(__DIR__ . '/Tmpl/blade'); if (!static::$path) { throw new \RuntimeException('Path not exists'); } Folder::create(__DIR__ . '/cache'); $this->instance = new BladeRenderer(static::$path, array('cache_path' => __DIR__ . '/cache')); }
/** * Method for generating Main configuration file * * @param array $filesList * @param int $poller_id * @param string $path * @param string $filename * @param int $testing */ public static function generate(&$filesList, $poller_id, $path, $filename, $testing = 0) { static::$path = rtrim($path, '/'); /* Get Content */ $content = static::getContent($poller_id, $filesList, $testing); /* Write Check-Command configuration file */ WriteConfigFile::writeParamsFile($content, $path . $poller_id . "/" . $filename, $filesList, $user = "******"); unset($content); }
/** * WPLogger constructor. * インスタンスの初期化 */ private function __construct() { static::$path = get_template_directory() . '/logs/debug.log'; static::$logger = new Logger('wptheme'); $output = "[%datetime%] %level_name%: %message% %context% %extra%\n"; $formatter = new LineFormatter($output); $stream = new StreamHandler(static::$path, Logger::DEBUG); $stream->setFormatter($formatter); static::$logger->pushHandler($stream); }
public static function path($filename = '') { if (static::$path === null) { $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http'; $server = $_SERVER['SERVER_NAME']; $directory = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'); static::$path = sprintf("%s://%s%s/", $protocol, $server, $directory); } return static::$path . $filename; }
public function __construct($identifier, $config) { $this->config = isset($config['file']) ? $config['file'] : array(); // check for an expiration override $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) ? $this->config['expiration'] : $this->expiration); // determine the file cache path static::$path = !empty($this->config['path']) ? $this->config['path'] : APPPATH . 'cache' . DS; if (!is_dir(static::$path) || !is_writable(static::$path)) { throw new \Cache_Exception('Cache directory does not exist or is not writable.'); } parent::__construct($identifier, $config); }
public static function init() { static::$path = J_APPPATH . "storage" . DS . "cache" . DS; if (Request::isLocal()) { if (!File::exists(static::$path)) { trigger_error("Directory <b>" . static::$path . "</b> doesn't exists."); } else { if (!is_writable(static::$path)) { trigger_error("Directory <b>" . static::$path . "</b> is not writable."); } } } }
/** * static init * * @return void */ public static function _init() { if (!($path = CCConfig::create("Packtacular::packtacular")->path)) { throw new CCException("CCPacktacular - please set your packtacular path!"); } // is there a cache dir? if (!is_dir(PUBLICPATH . $path)) { if (!mkdir(PUBLICPATH . $path, 0755, true)) { throw new CCException("CCPacktacular - could not create Packtacular folder at: {$path}"); } } static::$path = '/' . $path; }
public static function configure() { if (is_null(static::$site)) { static::$site = kirby::panelsetup(); } // load all available routes static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php'); static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php'); // setup the blueprint root blueprint::$root = c::get('root.site') . DS . 'blueprints'; // start the router static::$router = new Router(); static::$router->register(static::$routes); // content language switcher variable if (static::$site->multilang()) { if ($language = server::get('http_language') or $language = s::get('lang')) { static::$site->visit('/', $language); } app::$language = static::$site->language()->code(); s::set('lang', app::$language); } // load the interface language file if (static::$site->user()) { $languageCode = static::$site->user()->language(); } else { $languageCode = c::get('panel.language', 'en'); } // validate the language code if (!in_array($languageCode, static::languages()->keys())) { $languageCode = 'en'; } // store the interface language app::$interfaceLanguage = $languageCode; $language = (require root('panel.app.languages') . DS . $languageCode . '.php'); // set all language variables l::$data = $language['data']; // register router filters static::$router->filter('auth', function () { if (!app::$site->user()) { go('panel/login'); } }); // check for a completed installation static::$router->filter('isInstalled', function () { if (app::$site->users()->count() == 0) { go('panel/install'); } }); // only use the fragments of the path without params static::$path = implode('/', (array) url::fragments(detect::path())); }
/** * 初始化 */ static function init() { if (static::$path) { return; } $path = BASE . '/runtime/logs'; if (!is_writable($path)) { $root = substr($path, 0, strrpos($path, '/')); exec("chmod 777 {$root}"); } if (!is_dir($path)) { mkdir($path, 0777, true); } static::$path = realpath($path); }
/** * * @param \CentreonConfiguration\Events\GenerateEngine */ public static function execute(GenerateEngineEvent $event) { static::$event = $event; $config = Di::getDefault()->get('config'); static::$path = $config->get('global', 'centreon_generate_tmp_dir'); static::$path = rtrim(static::$path, '/') . '/engine/generate/'; static::$fileList = array(); $output = array(); exec("rm -rf " . static::$path . $event->getPollerId() . "/* 2>&1", $output, $statusDelete); if ($statusDelete) { $event->setOutput(_('Error while deleting Engine temporary configuration files') . "\n" . implode("\n", $output)); } $event->setOutput(sprintf(_('Generating temporary configuration files for poller %s:'), $event->getPollerId())); static::generateObjectsFiles(); static::generateMainFiles(); }
public function __construct($identifier, $first = 60, $second = 43200) { $this->identifier = static::$path . $identifier; static::$path = rtrim(static::$path, "/") . "/"; if (static::$path == '/') { static::$path = ''; } $this->fileName = static::$path . CacheUtility::sanitize($identifier) . ".cache.json"; $this->first = $first; $this->second = $second; $this->functions['onNoCache'] = function () { throw new \Exception("no onNoCache Callback defined"); }; $this->functions['onErrorAndNoCache'] = function (\Exception $e) { throw $e; }; }
public static function init() { $config = array('db' => array()); require_once APP . 'config.php'; static::$data = new stdClass(); static::$data->title = $config['default']['title']; static::$template = $config['default']['template']; // Database config options define('DB_HOST', $config['db']['host']); define('DB_NAME', $config['db']['name']); define('DB_USER', $config['db']['user']); define('DB_PASS', base64_decode($config['db']['pass'])); // Path to remove from uri static::$path = $config['path']; static::$profiler = $config['profiler']['log']; static::$profiler_query = $config['profiler']['query']; static::$status = $config['status']; }
/** * * @param \CentreonConfiguration\Events\GenerateEngine $event */ public static function execute(GenerateEngineEvent $event) { static::$event = $event; $config = Di::getDefault()->get('config'); static::$path = $config->get('global', 'centreon_generate_tmp_dir'); static::$path = rtrim(static::$path, '/') . '/broker/generate/'; static::$fileList = array(); $config = Di::getDefault()->get('config'); $path = $config->get('global', 'centreon_generate_tmp_dir'); $path = rtrim($path, '/') . '/broker/generate/'; $output = array(); exec("rm -rf " . $path . $event->getPollerId() . "/* 2>&1", $output, $statusDelete); if ($statusDelete) { $event->setOutput(_('Error while deleting Broker temporary configuration files') . "\n" . implode("\n", $output)); } $configBroker = new ConfigGenerateRepository(); $configBroker->generate($event->getPollerId()); ConfigCorrelationRepository::generate($event->getPollerId()); static::generateObjectsFiles(); }
public function __construct($path = null, array $options = []) { if (!$path) { if (!($path = static::$path)) { # Check which version we should use based on the current machine architecture $bin = "wkhtmltopdf-"; if (posix_uname()["machine"][0] == "i") { $bin .= "i386"; } else { $bin .= "amd64"; } # Start in the directory that we are in $path = __DIR__; # Move up to the composer vendor directory $path .= "/../../.."; # Add the wkhtmltopdf binary path $path .= "/h4cc/" . $bin . "/bin/" . $bin; static::$path = $path; } } parent::__construct($path, $options); }
public static function setPath() { static::$path = OSCOM::BASE_DIR . 'Work/Cache/'; }
/** * Used in the 'behind the scenes' logic during a frontend request, this checks whether * there is a controller associated with a particular template * * @param string $template Path to the template, relative to the root of the views directory * @return boolean */ public static function hasController($template) { static::$path = strpos($template, '.') === false ? $template : substr($template, 0, -strlen(strrchr($template, '.'))); // determine the viewmodel namespace and classname if (empty(static::$module)) { static::$module = \Request::active() ? ucfirst(\Request::active()->module) : ''; } // Strip the first part of the path off for module templates if (!empty(static::$module) && strpos(static::$path, static::$module) === 0) { static::$path = str_replace(static::$module . '/', '', static::$path); } $controller_class = ucfirst(static::$module) . '\\Controller_' . \Inflector::words_to_upper(ucfirst(str_replace(array('/', DS), '_', static::$path))); return class_exists($controller_class); }
/** * Add a path to theme. * * @param string $path */ public function addPath($path) { static::$path = rtrim($path, '/') . '/'; }
/** * Set the file path to a new location * * @param string Location to set the datastore path to * @return null */ public function setPath($to) { static::$path = $to; }
/** * Propagate path. * * @since 160308 PHP CLI server. * * @return string $path Path to propagate. */ protected static function propagatePath($path) { static::$path = $path; # Update & propagate. static::$full_path = static::$path . static::$path_info; static::$file = static::$root . static::$path; static::$file = preg_replace('/\\/+$/u', '', static::$file); static::$ext = static::ext(static::$file); }
/** * Setup the Path variable * * @param string|null $base base path * @return void */ protected static function _setPath($base = null) { if (empty($base)) { static::$path = '/'; return; } if (strpos($base, 'index.php') !== false) { $base = str_replace('index.php', '', $base); } if (strpos($base, '?') !== false) { $base = str_replace('?', '', $base); } static::$path = $base; }
public static function __init() { static::$path = Libraries::get(true, 'resources') . '/tmp/tests/test_karmas.ini'; }
/** * 设置配置所在的文件夹 * @example Config::path($path) * @param string $path * @return void */ static function path($path) { if (!isset(static::$path)) { static::$path = $path; } }