0)
{
$to = (isset($components['scheme']) && startswith($components['scheme'], 'http') ? $components['scheme'] : $schema) . '://';
$to .= isset($components['host']) ? $components['host'] : $host;
$to .= isset($components['port']) ? ':' . $components['port'] : '';
if(isset($components['path']))
{
if(in_array(substr($components['path'],0,1),array('\\','/')))//Path is absolute, just append.
{
$to .= $components['path'];
}
//Path is relative, append current directory first.
else if (isset($_SERVER['PHP_SELF']) && !is_null($_SERVER['PHP_SELF'])) //Apache
{
$to .= (strlen(dirname($_SERVER['PHP_SELF'])) > 1 ? dirname($_SERVER['PHP_SELF']).'/' : '/') . $components['path'];
}
else if (isset($_SERVER['REQUEST_URI']) && !is_null($_SERVER['REQUEST_URI'])) //Lighttpd
{
if (endswith($_SERVER['REQUEST_URI'], '/'))
$to .= (strlen($_SERVER['REQUEST_URI']) > 1 ? $_SERVER['REQUEST_URI'] : '/') . $components['path'];
else
$to .= (strlen(dirname($_SERVER['REQUEST_URI'])) > 1 ? dirname($_SERVER['REQUEST_URI']).'/' : '/') . $components['path'];
}
}
$to .= isset($components['query']) ? '?' . $components['query'] : '';
$to .= isset($components['fragment']) ? '#' . $components['fragment'] : '';
}
else
{
$to = $schema."://".$host."/".$to;
}
session_write_close();
$debug = false;
if( class_exists('CmsApp') )
{
$config = cmsms()->GetConfig();
$debug = $config['debug'];
}
if (headers_sent() && !$debug)
{
// use javascript instead
echo '
';
exit;
}
else
{
if ( $debug )
{
echo "Debug is on. Redirecting disabled... Please click this link to continue.
";
echo "".$to."
";
echo '
The requested URL was not found on this server.
'; exit(); } /** * A method to perform HTML entity conversion on a string * * @see htmlentities * @param string The input string * @param string A flag indicating how quotes should be handled (see htmlentities) (ignored) * @param string The input character set (ignored) * @param boolean A flag indicating wether single quotes should be converted to entities. * @return string the converted string. */ function cms_htmlentities($val, $param=ENT_QUOTES, $charset="UTF-8", $convert_single_quotes = false) { if ($val == "") return ""; $val = str_replace( " ", " ", $val ); $val = str_replace( "&" , "&" , $val ); $val = str_replace( "" , "-->" , $val ); $val = preg_replace( "/'."\n" . '' . "\n"; $scripts['jquery-ui.min.js'] = ''."\n"; $scripts['jquery.ui.nestedSortable.js'] = ''."\n"; $scripts['jquery.json.min.js'] = ''."\n"; // Check if we need exclude some script if(!empty($exclude)) { $exclude_list = explode(",", trim(str_replace(' ','',$exclude))); foreach($exclude_list as $one) { if ($one == 'jquery-1.6.2.min.js') { $one = 'jquery.min.js'; } if ($one == 'jquery-ui-1.8.14.min.js') { $one = 'jquery-ui.min.js'; } if ($one == 'jquery.json-2.2.js') { $one = 'jquery.json.min.js'; } if ($one == 'jquery.ui.nestedSortable-1.3.4.js') { $one = 'jquery.ui.nestedSortable.js'; } unset($scripts[$one]); } } // let them add scripts to the end ie: a jQuery plugin if(!empty($append)) { $append_list = explode(",", trim(str_replace(' ','',$append))); foreach($append_list as $key => $item) { $scripts['user_'+$key]=''."\n";; } } // Output $output = ''; foreach($scripts as $script) { $output .= $script; } return $output; } /** * Rolf: only used in lib/classes/class.CMSModule.php */ if(!function_exists('get_called_class')) { function get_called_class() { try { return cms_function_help::get_called_class(); } catch( Exception $e ) { // ignore } } // this class must exist in this file until CMSMS 1.12 when we dont have to worry abut PHP 5.2 // this file is loaded before the autoloader runs. class cms_function_help { public static function get_called_class($bt = false,$l = 1) { if (!$bt) $bt = debug_backtrace(); if (!isset($bt[$l])) throw new Exception("Cannot find called class -> stack level too deep."); if (!isset($bt[$l]['type'])) { if( $l >= 2 ) { throw new Exception ('type not set'); } else { return self::get_called_class($bt,$l+1); } } else switch ($bt[$l]['type']) { case '::': $lines = file($bt[$l]['file']); $i = 0; $callerLine = ''; do { $i++; $callerLine = $lines[$bt[$l]['line']-$i] . $callerLine; } while (stripos($callerLine,$bt[$l]['function']) === false); preg_match('/([a-zA-Z0-9\_]+)::'.$bt[$l]['function'].'/', $callerLine, $matches); if (!isset($matches[1])) { // must be an edge case. throw new Exception ("Could not find caller class: originating method call is obscured."); } switch ($matches[1]) { case 'self': case 'parent': return self::get_called_class($bt,$l+1); default: return $matches[1]; } // won't get here. case '->': switch ($bt[$l]['function']) { case '__get': // edge case -> get class of calling object if (!is_object($bt[$l]['object'])) throw new Exception ("Edge case fail. __get called on non object."); return get_class($bt[$l]['object']); default: return $bt[$l]['class']; } default: throw new Exception ("Unknown backtrace method type"); } } } } # vim:ts=4 sw=4 noet ?>