function suivre_lien($url, $lien) { if (preg_match(',^(mailto|javascript):,iS', $lien)) return $lien; if (preg_match(',^([a-z0-9]+://.*?)(/.*)?$,iS', $lien, $r)) return $r[1].resolve_path($r[2]); # L'url site spip est un lien absolu aussi if ($lien == $GLOBALS['meta']['adresse_site']){ return $lien; } # lien relatif, il faut verifier l'url de base # commencer par virer la chaine de get de l'url de base if (preg_match(',^(.*?://[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$,S', $url, $regs)) { $debut = $regs[1]; $dir = !strlen($regs[2]) ? '/' : $regs[2]; $mot = $regs[3]; $get = isset($regs[4])?$regs[4]:""; $hash = isset($regs[5])?$regs[5]:""; } #var_dump(array('url'=>$url,'debut'=>$debut,'dir'=>$dir,'mot'=>$mot,'get'=>$get,'hash'=>$hash)); switch (substr($lien,0,1)) { case '/': return $debut . resolve_path($lien); case '#': return $debut . resolve_path($dir.$mot.$get.$lien); case '': return $debut . resolve_path($dir.$mot.$get.$hash); default: return $debut . resolve_path($dir.$lien); } }
function suivre_lien($url, $lien) { if (preg_match(',^(mailto|javascript|data):,iS', $lien)) { return $lien; } if (preg_match(';^((?:[a-z]{3,7}:)?//.*?)(/.*)?$;iS', $lien, $r)) { return $r[1] . resolve_path($r[2]); } # L'url site spip est un lien absolu aussi if ($lien == $GLOBALS['meta']['adresse_site']) { return $lien; } # lien relatif, il faut verifier l'url de base # commencer par virer la chaine de get de l'url de base if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) { $debut = $regs[1]; $dir = !strlen($regs[2]) ? '/' : $regs[2]; $mot = $regs[3]; $get = isset($regs[4]) ? $regs[4] : ""; $hash = isset($regs[5]) ? $regs[5] : ""; } switch (substr($lien, 0, 1)) { case '/': return $debut . resolve_path($lien); case '#': return $debut . resolve_path($dir . $mot . $get . $lien); case '': return $debut . resolve_path($dir . $mot . $get . $hash); default: return $debut . resolve_path($dir . $lien); } }
public static function addPluginsDir($dir) { $t = debug_backtrace(); $path = str_replace("\\", "/", $t[0]['file']); $path = resolve_path($path . "/../" . $dir); self::$PLUGINS_DIR[] = $path; return $path; }
/** * Loads a file in `/dsa/php/` path * * @param string $file Relative file path/name * * @return boolean True if success, false otherwise */ function load_file($file) { $path = resolve_path($file); if ($path) { require $path; return true; } return false; }
function remote_filemtime($url, $recurse = 0) { // We hate infinite loops! if (++$recurse > 5) { return 0; } // Caching the remote mtime is a Really Good Idea. static $remote_files = array(); if (isset($remote_files[$url])) { return $remote_files[$url]; } $uri = parse_url($url); $uri['proto'] = isset($uri['proto']) && $uri['proto'] == 'https' ? 'ssl://' : ''; $uri['port'] = isset($uri['port']) ? $uri['port'] : 80; $uri['path'] = isset($uri['path']) ? $uri['path'] : '/'; $uri['query'] = isset($uri['query']) ? '?' . $uri['query'] : ''; $path = $uri['path'] . $uri['query']; $auth = isset($uri['user']) || isset($uri['pass']) ? 'Authentication: Basic ' . base64_encode(@$uri['user'] . ':' . @$uri['pass']) . "\r\n" : ''; $handle = @fsockopen($uri['proto'] . $uri['host'], $uri['port']); if (!$handle) { $remote_files[$url] = 0; return 0; } fputs($handle, "HEAD {$path} HTTP/1.1\r\nHost: {$uri['host']}\r\n{$auth}Connection: close\r\n\r\n"); $headers = array(); while (!feof($handle)) { $line = trim(fgets($handle, 1024)); if (empty($line)) { break; } $headers[] = $line; } fclose($handle); $result = 0; array_shift($headers); foreach ($headers as $header) { list($key, $value) = explode(':', $header, 2); $value = trim($value); switch (strtolower(trim($key))) { case 'location': // Redirect $result = remote_filemtime(resolve_path($url, $value), $recurse); break; case 'last-modified': // Got it! $result = strtotime($value); break; } if ($result) { break; } } $remote_files[$url] = $result; return $result; }
function resolve_url($url, $base = null) { if (!$base) { $base_parts = parse_url($_SERVER['REQUEST_URI']); $base_parts['host'] = $_SERVER['HTTP_HOST']; $base_parts['scheme'] = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http'; } else { $base_parts = parse_url($base); } $url_parts = parse_url($url); if (isset($url_parts['scheme'])) { return $url; } if (isset($base_parts['scheme'])) { $url_parts['scheme'] = $base_parts['scheme']; } if (!isset($url_parts['host'])) { if (isset($base_parts['host'])) { $url_parts['host'] = $base_parts['host']; } $url_parts['path'] = resolve_path($url_parts['path'], $base_parts['path']); } return build_url($url_parts); }
/** *Output PDF to some destination * *@access public *@note reproduces the fpdf's behavior *@param string name the filename *@string dest the destination * by default it's a file ('F') * if 'D' , download * and 'I' , Send to standard output * **/ function Output($name = '', $dest = '') { //----------------------------------- $pdf_file = ''; if ($this->support == "pdftk") { //As PDFTK can only merge FDF files not data directly, require_once "lib/url.php"; //we will need a url support because relative urls for pdf inside fdf files are not supported by PDFTK... require_once "export/fdf/fdf.php"; //...conjointly with my patched/bridged forge_fdf that provides fdf file generation support from array data. require_once "export/pdf/pdftk.php"; //Of course don't forget to bridge to PDFTK! $tmp_file = false; $pdf_file = resolve_path(fix_path(dirname(__FILE__) . '/' . $this->pdf_source)); //string: full pathname to the input pdf , a form file if ($this->fdf_source) { //FDF file provided $fdf_file = resolve_path(fix_path(dirname(__FILE__) . '/' . $this->fdf_source)); } else { $pdf_url = getUrlfromDir($pdf_file); //Normaly http scheme not local file if ($this->fdf_parse_needed) { //fdf source was provided $pdf_data = $this->parseFDFContent(); } else { //fields data was provided as an array, we have to generate the fdf file $pdf_data = $this->fields; } $fdf_file = fix_path(FPDM_CACHE) . "fields" . rnunid() . ".fdf"; $tmp_file = true; $ret = output_fdf($pdf_url, $pdf_data, $fdf_file); if (!$ret["success"]) { $this->Error("Output failed as something goes wrong (Pdf was {$pdf_url}) <br> during internal FDF generation of file {$fdf_file}, <br>Reason is given by {$ret['return']}"); } } //Serializes security options (not deeply tested) $security = ''; if (!is_null($this->security["password"]["owner"])) { $security .= ' owner_pw "' . substr($this->security["password"]["owner"], 0, FPDM_PASSWORD_MAX_LEN) . '"'; } if (!is_null($this->security["password"]["user"])) { $security .= ' user_pw "' . substr($this->security["password"]["user"], 0, FPDM_PASSWORD_MAX_LEN) . '"'; } if ($this->security["encrypt"] != 0) { $security .= ' encrypt_' . $this->security["encrypt"] . 'bit'; } if (count($this->security["allow"]) > 0) { $permissions = $this->security["allow"]; $security .= ' allow '; foreach ($permissions as $permission) { $security .= ' ' . $permission; } } //Serialize output modes $output_modes = ''; if ($this->flatten_mode) { $output_modes .= ' flatten'; } if ($this->compress_mode) { $output_modes .= ' compress'; } if ($this->uncompress_mode) { $output_modes .= ' uncompress'; } $ret = pdftk($pdf_file, $fdf_file, array("security" => $security, "output_modes" => $output_modes)); if ($tmp_file) { @unlink($fdf_file); } //Clear cache if ($ret["success"]) { $pdf_file = $ret["return"]; } else { $this->Error($ret["return"]); } } $this->buffer = $this->get_buffer($pdf_file); $dest = strtoupper($dest); if ($dest == '') { if ($name == '') { $name = 'doc.pdf'; $dest = 'I'; } else { $dest = 'F'; } } //Abort to avoid to polluate output if ($this->verbose && ($dest == 'I' || $dest == 'D')) { $this->Close($dest); } switch ($dest) { case 'I': //Send to standard output if (ob_get_length()) { $this->Error('Some data has already been output, can\'t send PDF file'); } if (php_sapi_name() != 'cli') { //We send to a browser header('Content-Type: application/pdf'); if (headers_sent()) { $this->Error('Some data has already been output, can\'t send PDF file'); } header('Content-Length: ' . strlen($this->buffer)); header('Content-Disposition: inline; filename="' . $name . '"'); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); ini_set('zlib.output_compression', '0'); } echo $this->buffer; break; case 'D': //Download file if (ob_get_length()) { $this->Error('Some data has already been output, can\'t send PDF file'); } header('Content-Type: application/x-download'); if (headers_sent()) { $this->Error('Some data has already been output, can\'t send PDF file'); } header('Content-Length: ' . strlen($this->buffer)); header('Content-Disposition: attachment; filename="' . $name . '"'); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); //header("Pragma: "); // HTTP/1.0 header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public,no-cache'); ini_set('zlib.output_compression', '0'); echo $this->buffer; break; case 'F': //Save to local file if ($this->verbose) { $this->dumpContent("Write file {$name}", "Output"); } $f = fopen($name, 'wb'); if (!$f) { $this->Error('Unable to create output file: ' . $name . ' (currently opened under Acrobat Reader?)'); } fwrite($f, $this->buffer, strlen($this->buffer)); fclose($f); break; case 'S': //Return as a string return $this->buffer; default: $this->Error('Incorrect output destination: ' . $dest); } return ''; }
function _find_controller_file($class, $directory, &$found_class, &$found_path) { global $CFG; $suffix_pattern = '/' . preg_quote($CFG->config['controller_suffix'], '/') . '$/'; $search_dir = realpath(resolve_path(APPPATH . 'controllers/' . $directory)); if ($search_dir !== false) { $search_dir = rtrim(str_replace('\\', '/', $search_dir), '/') . '/'; $found_class = ucfirst($class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } $found_class = preg_replace($suffix_pattern, '', $found_class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } $found_class = lcfirst($class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } $found_class = preg_replace($suffix_pattern, '', $found_class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } } $search_dir = realpath(resolve_path(COMMONPATH . 'controllers/' . $directory)); if ($search_dir !== false) { $search_dir = rtrim(str_replace('\\', '/', $search_dir), '/') . '/'; $found_class = ucfirst($class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } $found_class = preg_replace($suffix_pattern, '', $found_class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } $found_class = lcfirst($class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } $found_class = preg_replace($suffix_pattern, '', $found_class); if (file_exists($search_dir . $found_class . '.php')) { $found_path = $search_dir . $found_class . '.php'; return true; } } $found_class = $class; $found_path = ''; return false; }
/** * Décoder une URL en utilisant les fonctions inverses * * Gère les URLs transformées par le htaccess. * * @note * `$renommer = 'urls_propres_dist';` * renvoie `array($contexte, $type, $url_redirect, $nfond)` * * `$nfond` n'est retourné que si l'URL est définie apres le `?` * et risque d'être effacée par un form en get. * Elle est utilisée par form_hidden exclusivement. * * Compat ascendante si le retour est NULL en gérant une sauvegarde/restauration * des globales modifiées par les anciennes fonctions * * @param string $url * URL à décoder * @param string $fond * Fond initial par défaut * @param array $contexte * Contexte initial à prendre en compte * @param bool $assembler * `true` si l'URL correspond à l'URL principale de la page qu'on est en train d'assembler * dans ce cas la fonction redirigera automatiquement si besoin * et utilisera les eventuelles globales `$_SERVER['REDIRECT_url_propre']` et `$_ENV['url_propre']` * provenant du htaccess * @return array * Liste `$fond, $contexte, $url_redirect`. * * Si l'url n'est pas valide, $fond restera à la valeur initiale passée. * Il suffit d'appeler la fonction sans $fond et de vérifier qu'à son retour celui-ci * est non vide pour vérifier une URL * */ function urls_decoder_url($url, $fond = '', $contexte = array(), $assembler = false) { static $current_base = null; // les anciennes fonctions modifient directement les globales // on les sauve avant l'appel, et on les retablit apres ! $save = array(isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, $GLOBALS['profondeur_url']); if (is_null($current_base)) { include_spip('inc/filtres_mini'); // le decodage des urls se fait toujours par rapport au site public $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); } if (strncmp($url, $current_base, strlen($current_base)) == 0) { $url = substr($url, strlen($current_base)); } // si on est en train d'assembler la page principale, // recuperer l'url depuis les globales url propres si fournies // sinon extraire la bonne portion d'url if ($assembler) { if (isset($_SERVER['REDIRECT_url_propre'])) { $url = $_SERVER['REDIRECT_url_propre']; } elseif (isset($_ENV['url_propre'])) { $url = $_ENV['url_propre']; } else { $qs = explode("?", $url); // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee $url = ltrim($qs[0], '/'); $url = explode('/', $url); while (count($url) > $GLOBALS['profondeur_url'] + 1) { array_shift($url); } $qs[0] = implode('/', $url); $url = implode("?", $qs); } } unset($_SERVER['REDIRECT_url_propre']); unset($_ENV['url_propre']); include_spip('inc/filtres_mini'); if (strpos($url, "://") === false) { $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/{$url}"), '/'), '/'); } else { $GLOBALS['profondeur_url'] = max(0, substr_count($url, "/") - substr_count($current_base, "/")); } $url_redirect = ""; $renommer = generer_url_entite('', '', '', '', true); if (!$renommer and !function_exists('recuperer_parametres_url')) { $renommer = charger_fonction('page', 'urls'); } // fallback pour decoder l'url if ($renommer) { $a = $renommer($url, $fond, $contexte); if (is_array($a)) { list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); if ($url_redirect == $url) { $url_redirect = ""; } // securite pour eviter une redirection infinie if ($assembler and strlen($url_redirect)) { spip_log("Redirige {$url} vers {$url_redirect}"); include_spip('inc/headers'); redirige_par_entete($url_redirect, '', 301); } if (isset($nfond)) { $fond = $nfond; } else { if ($fond == '' or $fond == 'type_urls') { $fond = $type; } } if (isset($ncontexte)) { $contexte = $ncontexte; } if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { $contexte['type'] = $type; } if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { $contexte['type-page'] = $type; } } } elseif (function_exists('recuperer_parametres_url')) { $GLOBALS['fond'] = $fond; $GLOBALS['contexte'] = $contexte; recuperer_parametres_url($fond, nettoyer_uri()); // fond est en principe modifiee directement $contexte = $GLOBALS['contexte']; } // retablir les globales list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; // vider les globales url propres qui ne doivent plus etre utilisees en cas // d'inversion url => objet // maintenir pour compat ? #if ($assembler) { # unset($_SERVER['REDIRECT_url_propre']); # unset($_ENV['url_propre']); #} return array($fond, $contexte, $url_redirect); }
public static function load($file, $file2 = null, $glob_config = array()) { $GLOBALS['CONFIG'] = self::read($glob_config, $file, $file2); // print_r($GLOBALS ['CONFIG']['GLOBAL']); define_globals($GLOBALS['CONFIG']['GLOBAL']); define('Q', isset($_REQUEST['q']) ? $_REQUEST['q'] : NULL); $path_info = pathinfo($_SERVER['PHP_SELF']); $CONTEXT_PATH = Q == NULL ? strstr($_SERVER['PHP_SELF'], $path_info['basename'], TRUE) : strstr($_SERVER['REQUEST_URI'], Q, true); /** * TODO:- Fix it wth better solution */ if ($CONTEXT_PATH == null) { $CONTEXT_PATH = str_replace($path_info['basename'], "", $_SERVER['PHP_SELF']); } define('CONTEXT_PATH', $CONTEXT_PATH); define('APP_CONTEXT', resolve_path($CONTEXT_PATH . get_include_path())); Console::set(TRUE); }
<?php defined('BASEPATH') or exit('No direct script access allowed.'); $config['disabled'] = true; $config['denyZipDownload'] = true; $config['denyUpdateCheck'] = true; $config['denyExtensionRename'] = true; $config['theme'] = 'oxygen'; $config['uploadURL'] = resolve_path(DEFAULT_BASE_URI . 'editor/'); $config['uploadDir'] = resolve_path(DEFAULTFCPATH . 'editor/'); $config['dirPerms'] = DIR_READ_MODE; $config['filePerms'] = FILE_READ_MODE; $config['access'] = array('files' => array('upload' => true, 'delete' => true, 'copy' => true, 'move' => true, 'rename' => true), 'dirs' => array('create' => true, 'delete' => true, 'rename' => true)); $config['deniedExts'] = 'exe com msi bat php phps phtml php3 php4 cgi pl'; // Native CKEditor types $config['types']['files'] = ''; $config['types']['flash'] = 'swf'; $config['types']['images'] = '*img'; // Native TinyMCE types $config['types']['file'] = ''; $config['types']['media'] = 'swf flv avi mpg mpeg qt mov wmv asf rm'; $config['types']['image'] = '*img'; $config['filenameChangeChars'] = array(); $config['dirnameChangeChars'] = array(); $config['mime_magic'] = ''; $config['maxImageWidth'] = 0; $config['maxImageHeight'] = 0; $config['thumbWidth'] = 100; $config['thumbHeight'] = 100; $config['thumbsDir'] = '.thumbs'; $config['jpegQuality'] = 90;
/** Load a module controller **/ public static function load($module) { is_array($module) ? list($module, $params) = each($module) : ($params = NULL); // // Removed by Deepak Patil <*****@*****.**>, 03-APR-2014. // Uniqueness is not distinguished this way. // /* get the requested controller class name */ //$alias = strtolower(basename($module)); /* create or return an existing controller from the registry */ //if ( ! isset(self::$registry[$alias])) { // /* find the controller */ // Modified by Deepak Patil <*****@*****.**>, 21-JAN-2014. //list($class) = CI::$APP->router->locate(explode('/', $module)); list($class) = CI::$APP->router->locate(explode('/', $module), false); // /* controller cannot be located */ if (empty($class)) { return; } /* set the module directory */ // Modified by Deepak Patil <*****@*****.**>, 16-DEC-2013. //$path = APPPATH.'controllers/'.CI::$APP->router->directory; $path = resolve_path(APPPATH . 'controllers/' . CI::$APP->router->directory) . '/'; $path_common = resolve_path(COMMONPATH . 'controllers/' . CI::$APP->router->directory) . '/'; // /* load the controller class */ // Modified by Deepak Patil <*****@*****.**>, 16-DEC-2013. //$class = $class.CI::$APP->config->item('controller_suffix'); if (self::test_load_file(ucfirst($class) . CI::$APP->config->item('controller_suffix'), $path)) { $class = ucfirst($class) . CI::$APP->config->item('controller_suffix'); } elseif (self::test_load_file($class . CI::$APP->config->item('controller_suffix'), $path)) { $class = $class . CI::$APP->config->item('controller_suffix'); } elseif (self::test_load_file(ucfirst($class), $path)) { $class = ucfirst($class); } elseif (self::test_load_file(ucfirst($class) . CI::$APP->config->item('controller_suffix'), $path_common)) { $class = ucfirst($class) . CI::$APP->config->item('controller_suffix'); $path = $path_common; } elseif (self::test_load_file($class . CI::$APP->config->item('controller_suffix'), $path_common)) { $class = $class . CI::$APP->config->item('controller_suffix'); $path = $path_common; } elseif (self::test_load_file(ucfirst($class), $path_common)) { $class = ucfirst($class); $path = $path_common; } elseif (self::test_load_file($class, $path_common)) { $path = $path_common; } // // Modifications by Deepak Patil <*****@*****.**>, 03-APR-2014. // The previous check for loaded controller was not precise. $location = realpath($path . $class . '.php'); $key = strtolower($location); // Check whether the controller has been loaded, based on its system path. if (!isset(self::$registry[$key])) { self::load_file($class, $path); /* create and register the new controller */ $controller = ucfirst($class); self::$registry[$key] = new $controller($params); self::$registry[$key]->path = $location; } // Added by Deepak Patil <*****@*****.**>, 03-APR-2014. // A dirty workaround that is needed for Starter 4. self::$registry[$key]->load->set_module(CI::$APP->router->fetch_module()); // return self::$registry[$key]; }
# Check datatype config values # foreach (array_keys($default_config) as $key) { if (isset($config[$key]) && !(is_string($default_config[$key]) ? is_string($config[$key]) : (is_array($default_config[$key]) ? is_array($config[$key]) : is_int($default_config[$key] ? is_int($config[$key]) : false))) || !isset($config[$key])) { $config[$key] = $default_config[$key]; } } $config_destination = resolve_path($config['destination'], true); if ($config_destination === false) { die(sprintf("{destination=%s} directive is not a valid directory", $config['destination'])); } $config['destination'] = $config_destination; # Filter directive {directories} # foreach (array_keys($config['directories']) as $key) { $dir = resolve_path($config['directories'][$key]); if ($dir && is_dir($dir)) { $config['directories'][$key] = $dir; continue; } unset($config['directories'][$key]); continue; } while (true) { $files = array(); # Extract all files of the specified extensions # $extensions = implode('|', $config['extensions']); foreach ($config['directories'] as $dir) { $files = array_merge($files, list_files($dir, sprintf('/\\.(%s)$/i', $extensions))); }
<?php #error_reporting(E_ALL); include "plog-globals.php"; include_once "plog-load_config.php"; include_once "plog-functions.php"; global $config; // process path here - is set if mod_rewrite is in use if (!empty($_REQUEST["path"])) { // the followling line calculates the path in the album and excludes any subdirectories if // Plogger is installed in one $path = join("/", array_diff(explode("/", $_SERVER["REQUEST_URI"]), explode("/", $_SERVER["PHP_SELF"]))); $resolved_path = resolve_path($path); if (is_array($resolved_path)) { $_GET["level"] = $resolved_path["level"]; $_GET["id"] = $resolved_path["id"]; if (isset($resolved_path['mode'])) { $_GET['mode'] = $resolved_path['mode']; } // get page number from url, if present $parts = parse_url($_SERVER["REQUEST_URI"]); if (isset($parts["query"])) { parse_str($parts["query"], $query_parts); if (!empty($query_parts["plog_page"])) { $_GET["plog_page"] = $query_parts["plog_page"]; } } $path = $parts["path"]; } } // Set sorting session variables if they are passed
<?php if (function_exists('date_default_timezone_set')) { date_default_timezone_set('America/New_York'); } $GLOBALS["appDir"] = resolve_path("app"); $GLOBALS["viewables"] = array(); $GLOBALS["configDir"] = resolve_path("config"); $GLOBALS["vendorDir"] = realpath($_SERVER["DOCUMENT_ROOT"] . "/../app/vendor"); $GLOBALS["baseDir"] = realpath($_SERVER["DOCUMENT_ROOT"] . "/.."); $GLOBALS["testsDir"] = realpath($_SERVER["DOCUMENT_ROOT"] . "/../app/tests"); setg("pageName", basename($_SERVER['PHP_SELF'])); function resolve_path($name) { if ($name == ".") { $publicRoot = $_SERVER["DOCUMENT_ROOT"] . "/.."; $appRoot = $_SERVER["DOCUMENT_ROOT"]; } else { if ($_SERVER["DOCUMENT_ROOT"] != "") { $publicRoot = $_SERVER["DOCUMENT_ROOT"] . "/../{$name}"; $appRoot = $_SERVER["DOCUMENT_ROOT"] . "/{$name}"; } else { return "../{$name}"; } } return file_exists($publicRoot) ? realpath($publicRoot) : realpath($appRoot); } function __autoload($class_name) { if (file_exists($GLOBALS["appDir"] . "/models/{$class_name}.php")) { require_once $GLOBALS["appDir"] . "/models/{$class_name}.php";
function resolve_url($relative_url) { //----------------------------- $url = parse_url($relative_url); $url["path"] = resolve_path($url["path"]); //fix this $absolute_url = build_url($url); return $absolute_url; }
public static function getModuleProperties($dir, $filemodules = array("_" => array(), "bundles" => array())) { if (!is_dir($dir)) { return $filemodules; } $d = dir($dir); // Browser::warn("Scanning Resource Folder",$dir); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..') { if (is_dir($dir . '/' . $entry)) { $filemodules = self::getModuleProperties($dir . '/' . $entry, $filemodules); } else { if (strcmp($entry, "module.properties") == 0) { try { $mod_file = $dir . '/' . $entry; $mode_time = filemtime($mod_file); if (!RX_MODE_DEBUG && isset($filemodules["_"][$mod_file]) && $mode_time == $filemodules["_"][$mod_file]) { // Browser::log("from-cache....",$mod_file); } else { // if(RX_MODE_DEBUG) Browser::log("fresh ....",$dir); $filemodules["_"][$mod_file] = $mode_time; $r = parse_ini_file($dir . '/' . $entry, TRUE); // Browser::console($dir.'/'.$entry); foreach ($r as $mod => $files) { $filemodules['bundles'][$mod] = array("files" => array()); foreach ($files as $key => $file) { if ($key == '@') { $filemodules['bundles'][$mod][$key] = explode(',', $file); } else { if ($key != '@' && !is_remote_file($file)) { // Browser::log("****",resolve_path($dir."/".$file),"***"); $file_path = resolve_path(replace_first(PROJECT_ROOT_DIR, "", $dir . '/' . $file)); $filemodules['bundles'][$mod]["files"][] = $file_path; // echo $file_path."scanning</br>"; // $filemodules['bundles'][$mod]["files"][] = self::resolve_path("/resou/".$dir.'/'.$file); } else { $filemodules['bundles'][$mod]["files"][] = $file; } } } } } } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } } } } $d->close(); return $filemodules; }
$path = preg_replace_callback('/%(.*?)%/', function ($matches) { $env = getenv($matches[1]); if (empty($env) && stripos($env, '(x86)') !== false) { $env = getenv(str_ireplace('(x86)', '', $matches[1])); } return $env; }, $path); return realpath($path); } function escapexmltext($text) { return str_replace('&', '&', $text); } $nppconf = parse_ini_file('compiler/notepad++/npp.ini', true); $pawn_xml_dir = resolve_path(dirname($nppconf['paths']['pawn_xml'])); $user_define_lang_dir = resolve_path(dirname($nppconf['paths']['user_define_lang'])); function resolved_symbol_name($variable, $file = null, $remove_module_prefix = false) { if (empty($file) || !preg_match('/^this./', $variable)) { return $variable; } if (preg_match('/(\\\\|\\/)([^\\\\\\/]+)(\\\\|\\/)(callbacks(\\\\|\\/))?[^\\\\\\/]+\\.inc$/i', $file, $matches)) { $variable = preg_replace('/^this./', "{$matches[2]}.", $variable); } else { echo "WARNING: Unable to determine module for \"{$file}\".\n"; } return $variable; } if ($pawn_xml_dir !== false && $user_define_lang_dir !== false) { $start = microtime(true); $scanner = new PAWNScanner\Scanner();