'Afrikaans', # Afrikaans 'ar' => 'العربية', # Arabic 'bg' => 'Български', # Bulgarian 'ca' => 'Català', # Catalan 'cs' => 'Česky', # Czech 'da' => 'Dansk', # Danish 'de' => 'Deutsch', # German 'el' => 'Ελληνικά', # Greek 'en' => 'English', # English 'es' => 'Español', # Spanish 'et' => 'eesti', # Estonian 'fi' => 'Suomi', # Finnish 'fo' => 'Føroyskt', # Faroese 'fr' => 'Français', # French 'gl' => 'Galego', # Galician 'hr' => 'hrvatski', # Croatian 'hu' => 'Magyar', # Hungarian 'is' => 'Íslenska', # Icelandic 'it' => 'Italiano', # Italian 'ja' => '日本語', # Japanese 'lt' => 'Lietuvių', # Lithuanian 'nl' => 'Nederlands', # Dutch 'no' => 'Norsk', # Norwegian 'pl' => 'Polski', # Polish 'pt' => 'Português', # Portuguese 'pt-br' => 'Português do Brasil', # Brazilian Portuguese '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 = []; require_once('deprecated.php'); /* 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']; }else if( isset($_SERVER['HTTP_X_REWRITE_URL']) ){ // IIS Isapi_Rewrite $_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, $backtrace=null){ global $wbErrorBuffer, $addon_current_id, $page, $addon_current_version, $config, $addonFolderName; static $reported = []; $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 ){ return false; } // since we supported older versions of php, there may be a lot of strict errors if( $errno === E_STRICT ){ return; } //get the backtrace and function where the error was thrown if( !$backtrace ){ $backtrace = debug_backtrace(); } //remove showError() from backtrace if( strtolower($backtrace[0]['function']) == 'showerror' ){ $backtrace = array_slice($backtrace, 1); } $backtrace = array_slice($backtrace, 0 ,7); //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) >= 20 ){ restore_error_handler(); } if( gpdebug === 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 = []; $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 .= '
'; $mess .= '' . $errortype[$errno] . ' (' . $errno . ') ' . $errmsg; $mess .= '
    in: ' . $filename; $mess .= '
    on line: ' . $linenum; $mess .= '
    time: ' . date('Y-m-d H:i:s') . ' (' . time() . ')'; $server_params = ['REQUEST_URI', 'REQUEST_METHOD', 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR']; foreach( $server_params as $param ){ if( array_key_exists($param, $_SERVER) ){ $mess .= '
    ' . $param . ': ' . $_SERVER[$param]; } } //attempting to include all data can result in a blank screen foreach($backtrace as $i => $trace){ foreach($trace as $tk => $tv){ if( is_array($tv) ){ $backtrace[$i][$tk] = '[' . count($tv) . ']'; }elseif( is_object($tv) ){ $backtrace[$i][$tk] = 'object ' . get_class($tv); } } } $mess .= '
'; $mess .= '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){ if( defined($var) ){ return; } $env = getenv($var, true); if( $env === false ){ $env = getenv($var); } if( $env !== false ){ define($var, $env); }else{ 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 = []; 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; } /** * @deprecated 5.2 * Wrapper for msg() * */ function message(){ // trigger_error('Deprecated function message(). Use msg() instead'); call_user_func_array('msg', func_get_args()); } /** * Store a user message in the buffer * @since 4.0 * */ function msg(){ global $wbMessageBuffer; $args = func_get_args(); if( empty($args[0]) ){ return; } if( isset($args[1]) ){ $wbMessageBuffer[] = '
  • ' . call_user_func_array('sprintf', $args) . '
  • '; }elseif( is_array($args[0]) || is_object($args[0]) ){ $wbMessageBuffer[] = '
  • ' . pre($args[0]) . '
  • '; }else{ $wbMessageBuffer[] = '
  • ' . $args[0] . '
  • '; } } /** * add message only if admin user is logged in * @since 5.2 * */ function debug(){ if( \gp\tool::LoggedIn() ){ call_user_func_array('msg', func_get_args()); } } /** * Output the message buffer * */ function GetMessages($wrap=true){ global $wbMessageBuffer, $gp_not_writable, $langmessage; if( \gp\tool::loggedIn() && count($gp_not_writable) > 0 ){ $files = '
    • ' . implode('
    • ', $gp_not_writable) . '
    '; $message = sprintf($langmessage['not_writable'], \gp\tool::GetUrl('Admin/Status')) . $files; msg($message); $gp_not_writable = []; } $result = $wrap_end = ''; if( $wrap ){ $result = "\n" . ''; $wrap_end = '' . "\n"; } if( !empty($wbMessageBuffer) ){ if( gpdebug === false ){ $wbMessageBuffer = array_unique($wbMessageBuffer); } $result .= '
    '; $result .= '
    '; $result .= ''; $result .= ''; if( \gp\tool::LoggedIn() ){ // add copy to clipboard icon, only for admins $result .= 'getMessage(), $e->GetFile(), $e->GetLine(), [], $e->getTrace() ); // php < 7.0 doesn't have \Throwable }catch(Exception $e){ \showError( E_ERROR, 'IncludeScript() Fatal Error: ' . $e->getMessage(), $e->GetFile(), $e->GetLine(), [], $e->getTrace() ); } \gp\tool\Output::PopCatchable(); return $return; } /** * Similar to print_r and var_dump, but it is output buffer handling function safe * msg( pre(array(array(true))) ); * msg( pre(new tempo()) ); */ function pre($mixed){ static $level = 0; $output = ''; $type = gettype($mixed); switch($type){ case 'object': $type = get_class($mixed) . ' object'; $output = $type . '(...)' . "\n"; //recursive object references creates an infinite loop break; case 'array': $output = $type . '(' . "\n"; foreach($mixed as $key => $value){ $level++; $output .= str_repeat(' ',$level) . '[' . $key . '] => ' . pre($value) . "\n"; $level--; } $output .= str_repeat(' ', $level) . ')'; break; case 'boolean': if( $mixed ){ $mixed = 'true'; }else{ $mixed = 'false'; } default: $output = '(' . $type . ')' . htmlspecialchars($mixed, ENT_COMPAT, 'UTF-8', false) . ''; break; } if( $level == 0 ){ return '
    ' . 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; }