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 '
'; global $sql_queries; if (FALSE == empty($sql_queries)) { echo "
".$sql_queries."
\n"; } foreach (cmsms()->get_errors() as $error) { echo $error; } echo '
'; exit(); } else { header("Location: $to"); exit(); } } } /** * Given a page ID or an alias, redirect to it * Retrieves the URL of the specified page, and performs a redirect * * @param mixed An integer page id or a string page alias. * @return void */ function redirect_to_alias($alias) { $manager = cmsms()->GetHierarchyManager(); $node = $manager->sureGetNodeByAlias($alias); if( !$node ) { // put mention into the admin log audit('','Core','Attempt to redirect to invalid alias: '.$alias); return; } $content = $node->GetContent(); if (!is_object($content)) { audit('','Core','Attempt to redirect to invalid alias: '.$alias); return; } if ($content->GetURL() != '') { redirect($content->GetURL()); } } /** * Calculate the difference in seconds between two microtime() values * * @since 0.3 * @param string Microtime value A * @param string Microtime value B * @return integer The difference. */ function microtime_diff($a, $b) { list($a_dec, $a_sec) = explode(" ", $a); list($b_dec, $b_sec) = explode(" ", $b); return $b_sec - $a_sec + $b_dec - $a_dec; } /** * Joins a path together using proper directory separators * Taken from: http://www.php.net/manual/en/ref.dir.php * * This method accepts a variable number of string arguments. * * @since 0.14 * @return string */ function cms_join_path() { $args = func_get_args(); return implode(DIRECTORY_SEPARATOR,$args); } /** * Return the global cmsms() object * * @since 1.7 * @return object */ function &cmsms() { return CmsApp::get_instance(); } /** * Shows a very close approximation of an Apache generated 404 error. * * Shows a very close approximation of an Apache generated 404 error. * It also sends the actual header along as well, so that generic * browser error pages (like what IE does) will be displayed. * * @since 0.3 * @deprecated * @internal * Rolf: function used in /index.php */ function ErrorHandler404() { @ob_end_clean(); header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); echo ' 404 Not Found

Not Found

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 ?>