exec(array('khxc.main_path_force' => $main_path_force, 'khxc.app' => $app, 'khxc.namespace' => $namespace, 'khxc.robot' => $robot, 'khxc.interface' => $interface, 'khxc.output' => $output, 'khxc.errhandle' => $errhandle, 'khxc.perms_level_files' => $perms_level_files, 'khxc.perms_level_dirs' => $perms_level_dirs, 'khxc.perms_level_config' => $perms_level_config)); // +-- // | Exit() is called from within the KHXC during it's shutdown // | function, however it's good practice to call it here as well // | to handle garbage collection. // +-- exit(); // +------------------------------------------------------------------+ // | Class Definition [KHXC]| // +------------------------------------------------------------------+ class KHXCmain { // +-- // | This class is used to verify the PHP environment we're running // | in, load and execute the KHXC class and provide error handling // | outside of the scope of the main KHXC class. // +-- // +------------------------------------------------------------------+ // | Class Variables [KHXC]| // +------------------------------------------------------------------+ var $class = 'KHXCmain'; var $version = '6.6.0'; var $cerror; // +------------------------------------------------------------------+ // | Constructor Function [KHXC]| // +------------------------------------------------------------------+ function KHXCmain () { // +-- // | This is the constructor function. This function starts up the // | class. Any pre-load variable assignments go here. // +-- // +-- // | Return object. // +-- return $this; } // End of function. // +------------------------------------------------------------------+ // | Function: exec [KHXC]| // +------------------------------------------------------------------+ function exec ($input = array()) { // +-- // | This routine is run to run the internals of the class. Main class // | logic is contained in this function. // +-- // +-- // | Globalize our input array. // +-- if (!(empty($input))) { foreach ($input as $key => $value) {$this->globals($key,$value);} } // End of if statement. // +-- // | Set error handling up to output errors to the browser. We handle // | all errors except for E_NOTICE errors. // +-- ini_set('display_errors','1'); error_reporting(E_ALL ^ E_NOTICE); set_error_handler(array(&$this,'error_display')); // +-- // | Determine the directory from where we're running this program. // +-- $path = $this->globals('khxc.main_path_force'); if ((!(empty($path))) && (@file_exists($path))) { $path = $this->globals('khxc.main_path_force'); } elseif (@file_exists(dirname(__FILE__))) { $path = dirname(__FILE__); } elseif (@file_exists(getcwd())) { $path = getcwd(); } elseif (@file_exists(dirname($_SERVER['PATH_TRANSLATED']))) { $path = dirname($_SERVER['PATH_TRANSLATED']); } elseif (@file_exists(dirname($_SERVER['SCRIPT_FILENAME']))) { $path = dirname($_SERVER['SCRIPT_FILENAME']); } else { $errstr = "
This script could not determine the directory from which it is being executed. You need to edit the scripts 'index.php', 'admin.php' and 'installer.php' and enter a value for the \$main_path_force variable at the top of those scripts. Follow the instructions in each of those scripts for more information.
If you have already edited the \$main_path_force variable and are seeing this message again, the value you used for that variable appears to be incorrect. Please try again.
"; trigger_error($errstr,E_USER_ERROR); } // End of if statement. // +-- // | Format our working directory we've just determined and globalize it. // +-- $path = $this->paths_convert($path); $this->globals('khxc.main_path_force',$path); // +-- // | Include our config.php in the public directory. Globalize the // | config array. // +-- if (@file_exists($this->globals('khxc.main_path_force') . '/config.php')) { include($this->globals('khxc.main_path_force') . '/config.php'); foreach ($config as $key => $value) {$this->globals($key,$value);} unset($config); } // End of if statement. // +-- // | If the $config array key 'khxc.path_private' was not defined, // | we had a problem and need to error out. // +-- $pathpriv = $this->globals('khxc.path_private'); if (empty($pathpriv)) { $errstr = "It appears you have not run the Kyrptronic Hybrid X Core (KHXC) installer script. You need to run the installer script before accessing this script.
Click here to run the installer script.
"; trigger_error($errstr,E_USER_ERROR); } // End of if statement. // +-- // | Our private config file will be included automatically // | by the KHXC when it loads up. // | // | Now that we have our public config file included, // | we can include our main KHXC file. // +-- $privpath = $this->globals('khxc.path_private'); if (@file_exists($privpath . '/core/KHXC/KHXC.php')) { include_once($privpath . '/core/KHXC/KHXC.php'); // +-- // | If there is a problem finding the file, we error out. // +-- } else { $errstr = "This script could not locate the file 'KHXC.php' in the directory:
{$privpath}/core/KHXC
This could be the result of an incomplete installation. The configuration files created by the installer appear to be complete, however the installation of the codebase is incomplete. This is a fatal error that cannot be resolved automatically. Reinstall the software to continue.
Click here to run the installer script.
"; trigger_error($errstr,E_USER_ERROR); } // End of if statement. // +-- // | If we were able to include our main KHXC file, we can run the KHXC. // | Above we set 'output' to '1' and 'errtype' to '0' so the KHXC will // | produce output and trigger errors internally. There is no need to // | check for errors at this level. We run three methods on the KHXC // | object: // | // | new (constructor): To create the object and run startup tasks. // | exec: To run the application phase. // | shutdown: To run shutdown tasks and produce output. // +-- global $xglobal_cache; $khxc =& new KHXC($xglobal_cache); $khxc->exec(); $khxc->shutdown(); // +-- // | Return true. // +-- return 1; } // End of function. // +------------------------------------------------------------------+ // | Function: globals | // +------------------------------------------------------------------+ function globals ($name = '',$value = null,$default = null) { // +-- // | This function maintains a global array of global variables for // | use within the program. Global variables can be set, changed and // | obtained from this function. // +-- global $xglobal_cache; // +-- // | If the request contained a default identifier (passed as a true // | value), we set a default value if the global doesn't exist. // +-- if ((!(empty($name))) && (isset($value)) && (isset($default)) && (!(isset($xglobal_cache[$name])))) { $xglobal_cache[$name] = $value; return $value; } // End of if statement. // +-- // | Set requests have both a name and value passed // | to this function. // +-- if ((!(empty($name))) && (isset($value)) && (!(isset($default)))) { $xglobal_cache[$name] = $value; return $value; } // End of if statement. // +-- // | Get requests have only a global variable name // | passed to this function. // +-- if ((!(empty($name))) && (isset($xglobal_cache[$name]))) { return $xglobal_cache[$name]; } // End of if statement. // +-- // | All other requests result in a null return value. // +-- return null; } // End of function. // +------------------------------------------------------------------+ // | Function: paths_convert | // +------------------------------------------------------------------+ function paths_convert ($string) { // +-- // | This function converts filesystem paths to unix-style and strips // | any trailing slashes. // +-- while (preg_match('/\\\\/',$string)) {$string = preg_replace('/\\\\/','/',$string);} while (preg_match('/\/\//',$string)) {$string = preg_replace('/\/\//','/',$string);} $string = preg_replace('/\/$/','',$string); return $string; } // End of function. // +------------------------------------------------------------------+ // | Function: paths_strip | // +------------------------------------------------------------------+ function paths_strip ($string) { // +-- // | This function strips full server paths from a given string for // | security purposes. // +-- $pathpub = $this->globals('khxc.path_public'); $pathpriv = $this->globals('khxc.path_private'); $pathforce = $this->globals('khxc.main_path_force'); $string = str_replace('\\','/',$string); if (!(empty($pathforce))) { $find = preg_quote($pathforce . '/','/'); $string = preg_replace('/' . $find . '/','/',$string); } // End of if statement. if (!(empty($pathpub))) { $find = preg_quote($pathpub . '/','/'); $string = preg_replace('/' . $find . '/','/',$string); } // End of if statement. if (!(empty($pathpriv))) { $find = preg_quote($pathpriv . '/','/'); $string = preg_replace('/' . $find . '/','/',$string); } // End of if statement. return $string; } // End of function. // +------------------------------------------------------------------+ // | Function: error_display | // +------------------------------------------------------------------+ function error_display ($errno = '',$errstr = '',$errfile = '',$errline = '') { // +-- // | This function is called via PHP when an error is encountered. // | Scripts pass errors through this function via PHP's trigger_error // | function using: // | // | trigger_error('some_error_message',E_USER_ERROR); // | // | PHP also passes errors through this function without script // | intervention. // +-- // +-- // | If we've hit this function with a suppressed error or an E_STRICT // | or E_NOTICE error, we return. // +-- if ((error_reporting() == 0) || ($errno == E_NOTICE) || ($errno == E_STRICT)) { return 1; } // End of if statement. // +-- // | Modify our $errfile if it is non-blank. We want to remove // | full paths from error messages to increase security. // +-- if ($errfile) {$errfile = $this->paths_strip($errfile);} // +-- // | Modify our $errstr if it is non-blank. We want to add// | tags if they're not there. // +-- if (($errstr) && (!(preg_match('/
/',$errstr)))) { $errstr = '
' . $errstr . '
'; } // End of if statement. // +-- // | Define our date (four digit year). // +-- $date_year = @date('Y'); // +-- // | Print output header. // +-- print $this->error_div_header(); // +-- // | Print output content. // +-- if ($errstr) {print $this->error_div_content($errstr);} // +-- // | Print output info. // +-- if ($errno && $errline && $errfile) {print $this->error_div_info($errno,$errline,$errfile);} // +-- // | Print output footer. // +-- print $this->error_div_footer($date_year); // +-- // | This was a fatal error so we exit. // +-- exit(); } // End of function. // +------------------------------------------------------------------+ // | Function: error_div_header | // +------------------------------------------------------------------+ function error_div_header () { // +-- // | This function prints the error header. // +-- $xhtml = <<
Script Execution Error
{$errstr} ENDOFTEXT; return $xhtml; } // End of function. // +------------------------------------------------------------------+ // | Function: error_div_info | // +------------------------------------------------------------------+ function error_div_info ($errno = '',$errline = '',$errfile = '') { // +-- // | This function prints the error info. // +-- $xhtml = <<File: {$errfile} Line: {$errline} Error Number: {$errno}
ENDOFTEXT; return $xhtml; } // End of function. // +------------------------------------------------------------------+ // | Function: error_div_footer | // +------------------------------------------------------------------+ function error_div_footer ($date_year = '') { // +-- // | This function prints the error footer. // +-- $xhtml = <<© 1999-{$date_year} Kryptronic, Inc. All rights reserved worldwide. Kryptronic, the Kryptronic logo and all Kryptronic software names and logos are trademarks of Kryptronic, Inc. All Kryptronic software is copyrighted and the intellectual property of Kryptronic, Inc. All Kryptronic software is developed and distributed under license by Kryptronic, Inc. Application Information: http://www.kryptronic.com/
ENDOFTEXT; return $xhtml; } // End of function. // +------------------------------------------------------------------+ // | End of Class [KHXC]| // +------------------------------------------------------------------+ } // End of class. // +------------------------------------------------------------------+ // | End Of File [KHXC]| // +------------------------------------------------------------------+ ?>