'Afrikaans', 'ar' => 'العربية', # Arabic 'bg' => 'Български', # Bulgarian 'ca' => 'Català', 'cs' => 'Česky', # Czech 'da' => 'Dansk', 'de' => 'Deutsch', 'el' => 'Ελληνικά', # Greek 'en' => 'English', 'es' => 'Español', 'et' => 'eesti', # Estonian 'fi' => 'Suomi', # Finnish 'fo' => 'Føroyskt', # Faroese 'fr' => 'Français', 'gl' => 'Galego', # Galician 'hr' => 'hrvatski', # Croatian 'hu' => 'Magyar', # Hungarian 'it' => 'Italiano', 'ja' => '日本語', # Japanese 'lt' => 'Lietuvių', # Lithuanian 'nl' => 'Nederlands', # Dutch 'no' => 'Norsk', # Norwegian 'pl' => 'Polski', # Polish 'pt' => 'Português', 'pt-br' => 'Português do Brasil', 'ro' => 'Română', # Romanian 'ru' => 'Русский', # Russian 'sk' => 'Slovenčina', # Slovak 'sl' => 'Slovenščina', # Slovenian 'sv' => 'Svenska', # Swedish 'tr' => 'Türkçe', # Turkish 'uk' => 'Українська', # Ukrainian 'zh' => '中文', # (Zhōng Wén) - Chinese ); $gpversion = gpversion; // @deprecated 3.5b2 $addonDataFolder = $addonCodeFolder = false;//deprecated $addonPathData = $addonPathCode = false; $wbErrorBuffer = $gp_not_writable = $wbMessageBuffer = array(); /* from wordpress * wp-settings.php * see also classes.php */ // Fix for IIS, which doesn't set REQUEST_URI if ( empty( $_SERVER['REQUEST_URI'] ) ) { // IIS Mod-Rewrite if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; } // IIS Isapi_Rewrite else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; }else{ // Use ORIG_PATH_INFO if there is no PATH_INFO if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) ){ $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; } // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) if ( isset($_SERVER['PATH_INFO']) ) { if( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ){ $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; }else{ $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; } } // Append the query string if it exists and isn't null if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } } // Set default timezone in PHP 5. if ( function_exists( 'date_default_timezone_set' ) ) date_default_timezone_set( 'UTC' ); /** * Error Handling * Display the error and a debug_backtrace if gpdebug is not false * If gpdebug is an email address, send the error message to the address * @return false Always returns false so the standard PHP error handler is also used * */ function showError($errno, $errmsg, $filename, $linenum, $vars){ global $wbErrorBuffer, $addon_current_id, $page, $addon_current_version, $config, $addonFolderName; static $reported = array(); $report_error = true; $errortype = array ( E_ERROR => 'Fatal Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict Notice', E_RECOVERABLE_ERROR => 'Recoverable Error', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated', ); // for functions prepended with @ symbol to suppress errors $error_reporting = error_reporting(); if( $error_reporting === 0 ){ $report_error = false; //make sure the error is logged //error_log('PHP '.$errortype[$errno].': '.$errmsg.' in '.$filename.' on line '.$linenum); if( gpdebug === false ){ return false; } return false; } // since we supported php 4.3+, there may be a lot of strict errors if( $errno === E_STRICT ){ return; } //get the backtrace and function where the error was thrown $backtrace = debug_backtrace(); //remove showError() from backtrace if( strtolower($backtrace[0]['function']) == 'showerror' ){ $backtrace = array_slice($backtrace,1,5); }else{ $backtrace = array_slice($backtrace,0,5); } //record one error per function and only record the error once per request if( isset($backtrace[0]['function']) ){ $uniq = $filename.$backtrace[0]['function']; }else{ $uniq = $filename.$linenum; } if( isset($reported[$uniq]) ){ return false; } $reported[$uniq] = true; //disable showError after 20 errors if( count($reported) >= 1 ){ restore_error_handler(); } if( gpdebug === false ){ if( !$report_error ){ return false; } //if it's an addon error, only report if the addon was installed remotely if( isset($addonFolderName) && $addonFolderName ){ if( !isset($config['addons'][$addonFolderName]['remote_install']) ){ return false; } //if it's a core error, it should be in the include folder }elseif( strpos($filename,'/include/') === false ){ return false; } //record the error $i = count($wbErrorBuffer); $args['en'.$i] = $errno; $args['el'.$i] = $linenum; $args['em'.$i] = substr($errmsg,0,255); $args['ef'.$i] = $filename; //filename length checked later if( isset($addon_current_id) ){ $args['ea'.$i] = $addon_current_id; } if( isset($addon_current_version) && $addon_current_version ){ $args['ev'.$i] = $addon_current_version; } if( is_object($page) && !empty($page->title) ){ $args['ep'.$i] = $page->title; } $wbErrorBuffer[$uniq] = $args; return false; } $mess = ''; $mess .= '
'; if( gpdebug === true ){ msg($mess); }elseif( class_exists('\\gp\tool\\Emailer') && $report_error ){ $mailer = new \gp\tool\Emailer(); $subject = \gp\tool::ServerName(true).' Debug'; $mailer->SendEmail(gpdebug, $subject, $mess); } return false; } /** * Define a constant if it hasn't already been set * @param string $var The name of the constant * @param mixed $default The value to set the constant if it hasn't been set * @since 2.4RC2 */ function gp_defined($var,$default){ defined($var) or define($var,$default); } /** * Fix GPCR if magic_quotes_gpc is on * magic_quotes_gpc is deprecated, but still on by default in many versions of php * */ if( function_exists( 'get_magic_quotes_gpc' ) && version_compare(phpversion(),'5.4','<=') && @get_magic_quotes_gpc() ){ fix_magic_quotes( $_GET ); fix_magic_quotes( $_POST ); fix_magic_quotes( $_COOKIE ); fix_magic_quotes( $_REQUEST ); } //If Register Globals if( \gp\tool::IniGet('register_globals') ){ foreach($_REQUEST as $key => $value){ $key = strtolower($key); if( ($key == 'globals') || $key == '_post'){ die('Hack attempted.'); } } } function fix_magic_quotes( &$arr ) { $new = array(); foreach( $arr as $key => $val ) { $key = stripslashes($key); if( is_array( $val ) ){ fix_magic_quotes( $val ); }else{ $val = stripslashes( $val ); } $new[$key] = $val; } $arr = $new; } /** * Store a user message in the buffer * */ function message(){ $args = func_get_args(); //for php previous to 5.3 call_user_func_array('msg',$args); } /** * @since 4.0 * */ function msg(){ global $wbMessageBuffer; $args = func_get_args(); if( empty($args[0]) ){ return; } if( isset($args[1]) ){ $wbMessageBuffer[] = ''.htmlspecialchars($output,ENT_COMPAT,'UTF-8',false).''; } return $output; } /** * @deprecated 2.6 */ function showArray($mixed){ trigger_error('Deprecated function showArray(). Use pre() instead'); } /** * Modified from Wordpress function win_is_writable() * Working for users without requiring trailing slashes as noted in Wordpress * * Workaround for Windows bug in is_writable() function * will work in despite of Windows ACLs bug * NOTE: use a trailing slash for folders!!! * see http://bugs.php.net/bug.php?id=27609 * see http://bugs.php.net/bug.php?id=30931 * * @param string $path * @return bool */ function gp_is_writable( $path ){ if( is_writable($path) ){ return true; } // check tmp file for read/write capabilities if( is_dir($path) ){ $path = rtrim($path,'/').'/' . uniqid( mt_rand() ) . '.tmp'; } $should_delete_tmp_file = !file_exists( $path ); $f = @fopen( $path, 'a' ); if ( $f === false ) return false; fclose( $f ); if ( $should_delete_tmp_file ) unlink( $path ); return true; }