protected static function getPartsForMatches($matches) { $urlSuffix = html_entity_decode($matches[3]); $file = self::$currentInstance->urlSuffixToFile($urlSuffix); if (strpos($matches[0], '/' . FileLoader::fileDir() . '/') !== FALSE) { $file = ''; // do not rewrite fileloader urls $replacement = $matches[0]; } else { if ($file) { $replacement = $matches[1] . $file . $matches[4]; } else { Kurogo::log(LOG_NOTICE, "Unable to determine file name for '{$matches[0]}'", 'api'); $replacement = $matches[0]; } } return array($urlSuffix, $file, $replacement); }
array( 'pattern' => ';^.*favicon.ico$;', 'func' => '_outputFile', 'params' => array(THEME_DIR.'/common/images/favicon.ico'), ), array( 'pattern' => ';^.*ga.php$;', 'func' => '_phpFile', 'params' => array(LIB_DIR.'/ga.php'), ), array( 'pattern' => ';^.*(modules|common)(/.*images)/(.*)$;', 'func' => '_outputTypeFile', ), array( 'pattern' => ';^.*'.FileLoader::fileDir().'/(.+)$;', 'func' => '_outputFileLoaderFile', ), array( 'pattern' => ';^.*(media)(/.*)$;', 'func' => '_outputSiteFile', ) ); // try the url patterns. Run the path through each pattern testing for a match foreach ($url_patterns as $pattern_data) { if (preg_match($pattern_data['pattern'], $path, $matches)) { $params = isset($pattern_data['params']) ? $pattern_data['params'] : array($matches); call_user_func_array($pattern_data['func'], $params); } }
function CacheHeaders($file) { $mtime = gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT'; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $mtime) { header('HTTP/1.1 304 Not Modified'); exit; } } header("Last-Modified: {$mtime}"); return; } // // Handle page request // $url_patterns = array(array('pattern' => ';^.*favicon.ico$;', 'func' => '_outputFile', 'params' => array(THEME_DIR . '/common/images/favicon.ico')), array('pattern' => ';^.*ga.php$;', 'func' => '_phpFile', 'params' => array(LIB_DIR . '/ga.php')), array('pattern' => ';^.*(modules|common)(/.*images)/(.*)$;', 'func' => '_outputTypeFile'), array('pattern' => ';^.*' . FileLoader::fileDir() . '/(.+)$;', 'func' => '_outputFileLoaderFile'), array('pattern' => ';^.*(media)(/.*)$;', 'func' => '_outputSiteFile')); // try the url patterns. Run the path through each pattern testing for a match foreach ($url_patterns as $pattern_data) { if (preg_match($pattern_data['pattern'], $path, $matches)) { $params = isset($pattern_data['params']) ? $pattern_data['params'] : array($matches); call_user_func_array($pattern_data['func'], $params); } } // No pattern matches. Attempt to load a module $args = array_merge($_GET, $_POST); unset($args['_path']); // undo magic_quotes_gpc if set. It really shouldn't be. Stop using it. if (get_magic_quotes_gpc()) { function deepStripSlashes($v) { return is_array($v) ? array_map('deepStripSlashes', $v) : stripslashes($v);