From a954ccdf4aba81ec0e75a1836aa4bc14cb245aba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 22 Feb 2009 16:31:44 +0000 Subject: [PATCH] Two tickets resolved (57/89) - debug backtrace rewritten which adds links in bugtracker (resolves #57) - Code like "if (getConfig('foo_entry') == null)" rewritten to use isConfigEntrySet() (resolves #89) - More constants and language strings rewritten --- beg.php | 21 ++- birthday_confirm.php | 2 +- inc/databases.php | 2 +- inc/db/lib-mysql3.php | 14 +- inc/extensions/ext-birthday.php | 2 +- inc/filters.php | 7 + inc/functions.php | 244 +++++++++++++++++++---------- inc/language/de.php | 5 +- inc/libs/online_functions.php | 14 +- inc/libs/surfbar_functions.php | 4 +- inc/libs/user_functions.php | 6 +- inc/modules/admin.php | 40 ++--- inc/modules/guest/what-login.php | 30 ++-- inc/modules/index.php | 24 +-- inc/modules/member/what-logout.php | 9 +- inc/modules/member/what-order.php | 89 +++++------ inc/modules/sponsor.php | 4 +- inc/mysql-connect.php | 12 +- inc/mysql-manager.php | 11 +- inc/session.php | 6 +- inc/stylesheet.php | 2 +- index.php | 4 +- mailid.php | 26 ++- show_bonus.php | 2 +- surfbar.php | 2 +- 25 files changed, 311 insertions(+), 271 deletions(-) diff --git a/beg.php b/beg.php index 123ff8054f..ccf6edf252 100644 --- a/beg.php +++ b/beg.php @@ -51,7 +51,7 @@ require("inc/config.php"); // Is the "beg" extension active? if (!EXT_IS_ACTIVE("beg")) { // Redirect to index - LOAD_URL("modules.php?module=index&msg=".CODE_EXTENSION_PROBLEM."&ext=beg"); + LOAD_URL("modules.php?module=index&msg=".constant('CODE_EXTENSION_PROBLEM')."&ext=beg"); } // END - if // Is the script installed? @@ -74,7 +74,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { array($_GET['uid']), __FILE__, __LINE__); } else { // Nickname entered but nickname is not active - $msg = CODE_EXTENSION_PROBLEM; + $msg = constant('CODE_EXTENSION_PROBLEM'); $uid = -1; } } else { @@ -96,9 +96,6 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Secure userid $uid = bigintval($uid); - // Calculate beg points - mt_srand((double)microtime() * 10000000000 / time()); - // Multiply configured values with 100000 and divide with 100000 so we can also handle small values // If we need more number behind the decimal dot then we just need to increase all these three // numbers matching to the numbers behind the decimal dot. Simple! ;-) @@ -150,7 +147,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { } // Pay points? - if ($pay) { + if ($pay === true) { // Add points to user or begging rallye account if (BEG_ADD_POINTS($uid, $points)) { // Set "done" message @@ -169,9 +166,9 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { } elseif (getConfig('beg_pay_mode') != "NONE") { // Other pay-mode active! // Prepare content for template $content = array( - 'clicks' => __BEG_CLICKS, - 'points' => __BEG_POINTS, - 'uid' => __BEG_UID + 'clicks' => constant('__BEG_CLICKS'), + 'points' => constant('__BEG_POINTS'), + 'uid' => constant('__BEG_UID') ); // Load message template depending on pay-mode @@ -215,17 +212,17 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { array($_GET['uid']), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Locked account - $msg = CODE_ACCOUNT_LOCKED; + $msg = constant('CODE_ACCOUNT_LOCKED'); } else { // Invalid nickname! (404) - $msg = CODE_USER_404; + $msg = constant('CODE_USER_404'); } // Free memory SQL_FREERESULT($result); } elseif ($uid == getConfig('beg_uid')) { // Webmaster's ID cannot beg for points! - $msg = CODE_BEG_SAME_AS_OWN; + $msg = constant('CODE_BEG_SAME_AS_OWN'); } // Reload to index module diff --git a/birthday_confirm.php b/birthday_confirm.php index f6f17c746d..ca7d8243be 100644 --- a/birthday_confirm.php +++ b/birthday_confirm.php @@ -47,7 +47,7 @@ require("inc/config.php"); // Is the "birthday" extension active? if (!EXT_IS_ACTIVE("birthday")) { // Redirect to index - LOAD_URL("modules.php?module=index&msg=".CODE_EXTENSION_PROBLEM."&ext=birthday"); + LOAD_URL("modules.php?module=index&msg=".constant('CODE_EXTENSION_PROBLEM')."&ext=birthday"); } // END - if // Is the script installed? diff --git a/inc/databases.php b/inc/databases.php index df92e0ae1f..81b40f415b 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -105,7 +105,7 @@ define('CURR_SVN_VERSION' , getActualVersion(2)); define('_PRIME', 591623); // Calculate "entropy" with the prime number (for code generation) -define('_ADD', (_PRIME * _PRIME / (pi() * getConfig('code_length') + 1))); +define('_ADD', (constant('_PRIME') * constant('_PRIME') / (pi() * getConfig('code_length') + 1))); // Random number for e.g. the "cache-buster" used in OpenX script define('CACHE_BUSTER', mt_rand(1000000, 9999999)); diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 58bdc436b2..61d9be17fa 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -90,7 +90,7 @@ Query string:
} // END - if // Count DB hits - if (getConfig('db_hits_run') == null) { + if (!isConfigEntrySet('db_hits_run')) { // Count in dummy variable setConfigEntry('db_hits_run', 1); } else { @@ -103,7 +103,7 @@ Query string:
} // SQL num rows -function SQL_NUMROWS($result) { +function SQL_NUMROWS ($result) { // Is the result a valid resource? if (is_resource($result)) { // Get the count of rows from database @@ -266,9 +266,13 @@ function SQL_QUERY_ESC ($qstring, $data, $file, $line, $run=true, $strip=true) { // Was the eval() command fine? if ($query == "failed") { // Something went wrong? - print "eval=".htmlentities($eval)."
";
-		debug_print_backtrace();
-		die("
"); + printf("eval=%s\n
%s
", + htmlentities($eval), + debug_get_printable_backtrace() + ); + + // Abort further code executions + exit; } // END - if if ($run) { diff --git a/inc/extensions/ext-birthday.php b/inc/extensions/ext-birthday.php index 07cdfd488f..4a0e9d2612 100644 --- a/inc/extensions/ext-birthday.php +++ b/inc/extensions/ext-birthday.php @@ -122,7 +122,7 @@ PRIMARY KEY(id) case "0.2.8": // SQL queries for v0.2.8 // Update notes (these will be set as task text!) - $UPDATE_NOTES = "Vergessenes _OB_CACHING gesetzt."; + $UPDATE_NOTES = "Vergessenes _OB_CACHING gesetzt."; break; case "0.2.9": // SQL queries for v0.2.9 diff --git a/inc/filters.php b/inc/filters.php index 846668aa08..8715aed08f 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -104,6 +104,7 @@ ORDER BY `filter_id` ASC", __FILE__, __LINE__); // Init filters REGISTER_FILTER('init', 'UPDATE_LOGIN_DATA'); + REGISTER_FILTER('init', 'INIT_RANDOMIZER'); // Login failures handler REGISTER_FILTER('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES'); @@ -508,5 +509,11 @@ function FILTER_CHECK_ADMIN_ACL () { return $ret; } +// Filter for initializing randomizer +function FILTER_INIT_RANDOMIZER () { + // Simply init the randomizer with seed and _ADD value + mt_srand(make_seed() + constant('_ADD')); +} + // ?> diff --git a/inc/functions.php b/inc/functions.php index 492bd3e90c..2ee2e1e264 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -60,7 +60,7 @@ function IS_INC_WRITEABLE($inc) { } // Output HTML code directly or "render" it. You addionally switch the new-line character off -function OUTPUT_HTML ($HTML, $NEW_LINE = true) { +function OUTPUT_HTML ($HTML, $newLine = true) { // Some global variables global $OUTPUT, $footer, $CSS; @@ -71,28 +71,28 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { { case "render": // That's why you don't need any \n at the end of your HTML code... :-) - if (_OB_CACHING == "on") { + if (constant('_OB_CACHING') == "on") { // Output into PHP's internal buffer OUTPUT_RAW($HTML); // That's why you don't need any \n at the end of your HTML code... :-) - if ($NEW_LINE) echo "\n"; + if ($newLine) echo "\n"; } else { // Render mode for old or lame servers... $OUTPUT .= $HTML; // That's why you don't need any \n at the end of your HTML code... :-) - if ($NEW_LINE) $OUTPUT .= "\n"; + if ($newLine) $OUTPUT .= "\n"; } break; case "direct": // If we are switching from render to direct output rendered code - if ((!empty($OUTPUT)) && (_OB_CACHING != "on")) { OUTPUT_RAW($OUTPUT); $OUTPUT = ""; } + if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != "on")) { OUTPUT_RAW($OUTPUT); $OUTPUT = ""; } // The same as above... ^ OUTPUT_RAW($HTML); - if ($NEW_LINE) echo "\n"; + if ($newLine) echo "\n"; break; default: @@ -101,14 +101,14 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { mxchange_die("{!FATAL_ERROR!}: {!LANG_NO_RENDER_DIRECT!}"); break; } - } elseif ((_OB_CACHING == "on") && ($footer == 1)) { + } elseif ((constant('_OB_CACHING') == "on") && ($footer == 1)) { // Headers already sent? if (headers_sent()) { // Log this error DEBUG_LOG(__FUNCTION__, __LINE__, "Headers already sent! We need debug backtrace here."); // Trigger an user error - trigger_error("Headers are already sent!"); + debug_report_bug("Headers are already sent!"); } // END - if // Output cached HTML code @@ -174,8 +174,8 @@ function OUTPUT_RAW ($HTML) { // Output stripped HTML code to avoid broken JavaScript code, etc. echo stripslashes(stripslashes($HTML)); - // Flush the output if only _OB_CACHING is not "on" - if (_OB_CACHING != "on") { + // Flush the output if only constant('_OB_CACHING') is not "on" + if (constant('_OB_CACHING') != "on") { // Flush it flush(); } // END - if @@ -524,9 +524,6 @@ function GEN_PASS ($LEN = 0) { // Initialize array with all allowed chars $ABC = explode(",", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/"); - // Initialize randomizer - mt_srand((double) microtime() * 1000000); - // Start creating password $PASS = ""; for ($i = 0; $i < $LEN; $i++) { @@ -584,7 +581,7 @@ function MAKE_DATETIME ($time, $mode="0") // Translates the american decimal dot into a german comma function TRANSLATE_COMMA ($dotted, $cut=true, $max=0) { // Default is 3 you can change this in admin area "Misc -> Misc Options" - if (getConfig('max_comma') == null) setConfigEntry('max_comma', "3"); + if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', "3"); // Use from config is default $maxComma = getConfig('max_comma'); @@ -913,11 +910,7 @@ function LOAD_URL($URL, $addUrlData=true) { } // Get output buffer - /* - print "
";
-	debug_print_backtrace();
-	die("
"); - */ + //* DEBUG: */ debug_report_bug(); $OUTPUT = ob_get_contents(); // Clear it only if there is content @@ -937,11 +930,7 @@ function LOAD_URL($URL, $addUrlData=true) { OUTPUT_HTML("".$URL.""); } elseif (!headers_sent()) { // Load URL when headers are not sent - /* - print("
");
-		debug_print_backtrace();
-		die("
URL={$URL}"); - */ + //* DEBUG: */ debug_report_bug("URL={$URL}"); header ("Location: ".str_replace("&", "&", $URL)); } else { // Output error message @@ -1256,17 +1245,17 @@ function GEN_RANDOM_CODE($length, $code, $uid, $DATA="") { if (isset($GLOBALS['refid'])) $data .= ":".$GLOBALS['refid']; // Calculate number for generating the code - $a = $code + _ADD - 1; + $a = $code + constant('_ADD') - 1; if (getConfig('master_hash') != null) { // Generate hash with master salt from modula of number with the prime number and other data - $saltedHash = generateHash(($a % _PRIME).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, getConfig('master_salt')); + $saltedHash = generateHash(($a % constant('_PRIME')).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, getConfig('master_salt')); // Create number from hash $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(_MAX - $a + sqrt(_ADD)) / pi(); } else { // Generate hash with "hash of site key" from modula of number with the prime number and other data - $saltedHash = generateHash(($a % _PRIME).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, substr(sha1(SITE_KEY), 0, 8)); + $saltedHash = generateHash(($a % constant('_PRIME')).":".$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a, substr(sha1(SITE_KEY), 0, 8)); // Create number from hash $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(_MAX - $a + sqrt(_ADD)) / pi(); @@ -1292,12 +1281,10 @@ function bigintval($num, $castValue = true) { if ($castValue) $ret = (double)$ret; // Has the whole value changed? + // @TODO Remove this if() block if all is working fine if ("".$ret."" != "".$num."") { // Log the values - print("
");
-		debug_print_backtrace();
-		die("
"); - DEBUG_LOG(__FUNCTION__, __LINE__, " num={$num},ret={$ret}"); + debug_report_bug(); } // END - if // Return result @@ -2024,11 +2011,9 @@ function generateHash ($plainText, $salt = "") { } // END - if // Do we miss an arry element here? - if (getConfig('file_hash') == null) { + if (!isConfigEntrySet('file_hash')) { // Stop here - print("Missing file_hash in ".__FUNCTION__.". Backtrace:
");
-		debug_print_backtrace();
-		die("
"); + debug_report_bug("Missing file_hash in ".__FUNCTION__."."); } // END - if // When the salt is empty build a new one, else use the first x configured characters as the salt @@ -2037,16 +2022,16 @@ function generateHash ($plainText, $salt = "") { $server = $_SERVER['PHP_SELF'].":".GET_USER_AGENT().":".getenv('SERVER_SOFTWARE').":".GET_REMOTE_ADDR().":".":".filemtime(PATH."inc/databases.php"); // Build key string - $keys = SITE_KEY.":".DATE_KEY.":".getConfig('secret_key').":".getConfig('file_hash').":".date("d-m-Y (l-F-T)", bigintval(getConfig('patch_ctime'))).":".getConfig('master_salt'); + $keys = constant('SITE_KEY').":".constant('DATE_KEY').":".getConfig('secret_key').":".getConfig('file_hash').":".date("d-m-Y (l-F-T)", bigintval(getConfig('patch_ctime'))).":".getConfig('master_salt'); // Additional data $data = $plainText.":".uniqid(mt_rand(), true).":".time(); // Calculate number for generating the code - $a = time() + _ADD - 1; + $a = time() + constant('_ADD') - 1; // Generate SHA1 sum from modula of number and the prime number - $sha1 = sha1(($a % _PRIME).$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a); + $sha1 = sha1(($a % constant('_PRIME')).$server.":".$keys.":".$data.":".date("d-m-Y (l-F-T)", time()).":".$a); //* DEBUG: */ echo "SHA1=".$sha1." (".strlen($sha1).")
"; $sha1 = scrambleString($sha1); //* DEBUG: */ echo "Scrambled=".$sha1." (".strlen($sha1).")
"; @@ -2120,9 +2105,8 @@ function descrambleString($str) { return $orig; } // -function genScrambleString($len) { - // Prepare randomizer and array for the numbers - mt_srand((double) microtime() * 1000000); +function genScrambleString ($len) { + // Prepare array for the numbers $scrambleNumbers = array(); // First we need to setup randomized numbers from 0 to 31 @@ -2143,6 +2127,7 @@ function genScrambleString($len) { $scrambleString = implode(":", $scrambleNumbers); return $scrambleString; } + // Append data like session ID or referal ID to the given URL which would // normally be stored in cookies function ADD_URL_DATA ($URL) { @@ -2151,7 +2136,7 @@ function ADD_URL_DATA ($URL) { // Determine URL binder $BIND = "?"; - if (strpos($URL, "?") !== false) $BIND = "&"; + if (strpos($URL, "?") !== false) $BIND = "&"; if ((!defined('__COOKIES')) || ((!__COOKIES))) { // Cookies are not accepted @@ -2162,25 +2147,14 @@ function ADD_URL_DATA ($URL) { // Not found! So let's set default here $ADD .= $BIND."refid=".getConfig('def_refid'); } - - // Is there already added data? Then change the binder - if (!empty($ADD)) $BIND = "&"; - - // Add session ID - if ((!empty($_GET['PHPSESSID'])) && (strpos($URL, "PHPSESSID=") == 0)) { - // Add session from URL - $ADD .= $BIND."PHPSESSID=".SQL_ESCAPE(strip_tags($_GET['PHPSESSID'])); - } else { - // Add current session - $ADD .= $BIND."PHPSESSID=".session_id(); - } } // END - if // Add all together and return it - return $URL.$ADD; + return $URL . $ADD; } + // Generate an PGP-like encrypted hash of given hash for e.g. cookies -function generatePassString($passHash) { +function generatePassString ($passHash) { // Return vanilla password hash $ret = $passHash; @@ -2193,9 +2167,9 @@ function generatePassString($passHash) { $part2 = hexdec(substr(getConfig('secret_key'), $start, 4)); $mod = dechex($idx); if ($part1 > $part2) { - $mod = dechex(sqrt(($part1 - $part2) * _PRIME / pi())); + $mod = dechex(sqrt(($part1 - $part2) * constant('_PRIME') / pi())); } elseif ($part2 > $part1) { - $mod = dechex(sqrt(($part2 - $part1) * _PRIME / pi())); + $mod = dechex(sqrt(($part2 - $part1) * constant('_PRIME') / pi())); } $mod = substr(round($mod), 0, 4); $mod = str_repeat('0', 4-strlen($mod)).$mod; @@ -2241,7 +2215,7 @@ function mxchange_die ($msg) { LOAD_TEMPLATE("admin_settings_saved", false, $msg); // Load footer - LOAD_INC("inc/footer.php"); + LOAD_INC_ONCE("inc/footer.php"); // Exit explicitly exit; @@ -2404,9 +2378,7 @@ function merge_array ($array1, $array2) { } // Both are not arrays - print(__FUNCTION__.":
");
-	debug_print_backtrace();
-	die("
"); + debug_report_bug(__FUNCTION__.":"); } // Debug message logger @@ -2666,19 +2638,19 @@ function CACHE_PURGE_ADMIN_MENU ($id=0, $action="", $what="", $str="") { // No cache instance! DEBUG_LOG(__FUNCTION__, __LINE__, " No cache instance found."); return false; - } elseif ((getConfig('cache_admin_menu') == null) || (getConfig('cache_admin_menu') == "N")) { + } elseif ((!isConfigEntrySet('cache_admin_menu')) || (getConfig('cache_admin_menu') == "N")) { // Caching disabled (currently experiemental!) return false; } // Experiemental feature! - trigger_error("Experimental feature: You have to delete the admin_*.cache files by yourself at this point."); + debug_report_bug("Experimental feature: You have to delete the admin_*.cache files by yourself at this point."); } // Translates the "pool type" into human-readable function TRANSLATE_POOL_TYPE ($type) { - // Default type is unknown - $translated = sprintf(POOL_TYPE_UNKNOWN, $type); + // Default type is unknown + $translated = sprintf(getMessage('POOL_TYPE_UNKNOWN'), $type); // Generate constant $constName = sprintf("POOL_TYPE_%s", $type); @@ -2784,6 +2756,7 @@ function ADD_NEW_BONUS_MAIL ($data, $mode="", $output=true) { DEBUG_LOG(__FUNCTION__, __LINE__, " cat={$data['cat']},receiver={$data['receiver']},data=".base64_encode(serialize($data))." More selected, than available!"); } } + // Determines referal id and sets it function DETERMINE_REFID () { global $CLICK, $_SERVER; @@ -2826,7 +2799,7 @@ function DETERMINE_REFID () { } // Destroys the admin session -function DESTROY_ADMIN_SESSION ($destroy = true) { +function destroyAdminSession ($destroy = true) { // Kill maybe existing session variables including array elements set_session('admin_login', ""); set_session('admin_md5' , ""); @@ -2835,7 +2808,7 @@ function DESTROY_ADMIN_SESSION ($destroy = true) { // Destroy session and return status if ($destroy) { - return @session_destroy(); + return session_destroy(); } // END - if // All fine if we shall not really destroy the session @@ -2856,7 +2829,7 @@ function getConfig ($entry) { $value = null; // Is the entry there? - if (isset($_CONFIG[$entry])) { + if (isConfigEntrySet($entry)) { // Then use it $value = $_CONFIG[$entry]; } // END - if @@ -2876,8 +2849,26 @@ function setConfigEntry ($entry, $value) { $_CONFIG[$entry] = $value; } -// @TODO Rewrite all language constants to this function. +// Checks wether the given config entry is set +function isConfigEntrySet ($entry) { + global $_CONFIG; + return (isset($_CONFIG[$entry])); +} + +// Increment or init with given value or 1 as default the given config entry +function incrementConfigEntry ($configEntry, $value=1) { + global $_CONFIG; + + // Increment it if set or init it with 1 + if (getConfig($configEntry) > 0) { + $_CONFIG[$configEntry] += $value; + } else { + $_CONFIG[$configEntry] = $value; + } +} + // "Getter" for language strings +// @TODO Rewrite all language constants to this function. function getMessage ($messageId) { // Default is not found! $return = "!".$messageId."!"; @@ -2889,7 +2880,7 @@ function getMessage ($messageId) { } elseif (isset($GLOBALS['msg'][strtoupper($messageId)])) { // @DEPRECATED Language array element found in BIG_LETTERS $return = $GLOBALS['msg'][$messageId]; - } elseif (defined(strtoupper($messageId))) { + } elseif (defined($messageId)) { // @DEPRECATED Deprecated constant found $return = constant($messageId); } else { @@ -2993,18 +2984,6 @@ function THEME_GET_ID ($name) { return $id; } -// Increment or init with given value or 1 as default the given config entry -function incrementConfigEntry ($configEntry, $value=1) { - global $_CONFIG; - - // Increment it if set or init it with 1 - if (getConfig($configEntry) > 0) { - $_CONFIG[$configEntry] += $value; - } else { - $_CONFIG[$configEntry] = $value; - } -} - // Read a given file function READ_FILE ($FQFN, $sqlPrepare = false) { // Load the file @@ -3047,7 +3026,7 @@ function WRITE_FILE ($FQFN, $content) { // Generates an error code from given account status function GEN_ERROR_CODE_FROM_ACCOUNT_STATUS ($status) { // Default error code if unknown account status - $ERROR = CODE_UNKNOWN_STATUS; + $ERROR = constant('CODE_UNKNOWN_STATUS'); // Generate constant name $constantName = sprintf("CODE_ID_%s", $status); @@ -3070,7 +3049,7 @@ function clearOutputBuffer () { // Trigger an error on failure if (!ob_end_clean()) { // Failed! - trigger_error(__FUNCTION__.": Failed to clean output buffer."); + debug_report_bug(__FUNCTION__.": Failed to clean output buffer."); } // END - if } @@ -3100,8 +3079,9 @@ function getActualVersion ($type = 0) { } } - if ($new) { - // no Revision-File or has no valid Data so read the Revision from the Server. + // Has it been updated? + if ($new === true) { + // No Revision-File or has no valid Data so read the Revision from the Server. $version = GET_URL("check-updates3.php"); // Prepare content @@ -3158,6 +3138,96 @@ function LOAD_INC_ONCE ($INC) { } // END - if } +// Back-ported from the new ship-simu engine. :-) +function debug_get_printable_backtrace () { + // Init variable + $backtrace = "
    \n"; + + // Get and prepare backtrace for output + $backtraceArray = debug_backtrace(); + foreach ($backtraceArray as $key => $trace) { + if (!isset($trace['file'])) $trace['file'] = __FILE__; + if (!isset($trace['line'])) $trace['line'] = __LINE__; + if (!isset($trace['args'])) $trace['args'] = array(); + $backtrace .= "
  1. ".basename($trace['file']).":".$trace['line'].", ".$trace['function']."(".count($trace['args']).")
  2. \n"; + } // END - foreach + + // Close it + $backtrace .= "
\n"; + + // Return the backtrace + return $backtrace; +} + +// Output a debug backtrace to the user +function debug_report_bug ($message = "") { + // Init message + $debug = ""; + // Is the optional message set? + if (!empty($message)) { + // Use and log it + $debug = sprintf("Note: %s
\n", + $message + ); + + // @TODO Add a little more infos here + DEBUG_LOG(__FUNCTION__, __LINE__, $message); + } // END - if + + // Add output + $debug .= ("Please report this error at bugs.mxchange.org:
");
+	$debug .= (debug_get_printable_backtrace());
+	$debug .= ("
Thank you for your help finding bugs."); + + // And abort here + die($debug); +} + +// Generates a ***weak*** seed (taken from de.php.net/mt_srand) +function make_seed () { + list($usec, $sec) = explode(" ", microtime()); + return ((float)$sec + (float)$usec); +} + +// Converts a message code to a human-readable message +function convertCodeToMessage ($code) { + $msg = ""; + switch ($code) { + case constant('CODE_LOGOUT_DONE') : $msg = getMessage('LOGOUT_DONE'); break; + case constant('CODE_LOGOUT_FAILED') : $msg = "{!LOGOUT_FAILED!}"; break; + case constant('CODE_DATA_INVALID') : $msg = getMessage('MAIL_DATA_INVALID'); break; + case constant('CODE_POSSIBLE_INVALID') : $msg = getMessage('MAIL_POSSIBLE_INVALID'); break; + case constant('CODE_ACCOUNT_LOCKED') : $msg = getMessage('MEMBER_ACCOUNT_LOCKED_UNC'); break; + case constant('CODE_USER_404') : $msg = getMessage('USER_NOT_FOUND'); break; + case constant('CODE_STATS_404') : $msg = getMessage('MAIL_STATS_404'); break; + case constant('CODE_ALREADY_CONFIRMED'): $msg = getMessage('MAIL_ALREADY_CONFIRMED'); break; + + case constant('CODE_ERROR_MAILID'): + if (EXT_IS_ACTIVE($ext, true)) { + $msg = getMessage('ERROR_CONFIRMING_MAIL'); + } else { + $msg = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), "mailid"); + } + break; + + case constant('CODE_EXTENSION_PROBLEM'): + if (isset($_GET['ext'])) { + $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), SQL_ESCAPE($_GET['ext'])); + } else { + $msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT'); + } + break; + + case constant('CODE_COOKIES_DISABLED') : $msg = getMessage('LOGIN_NO_COOKIES'); break; + case constant('CODE_BEG_SAME_AS_OWN') : $msg = getMessage('BEG_SAME_UID_AS_OWN'); break; + case constant('CODE_LOGIN_FAILED') : $msg = getMessage('LOGIN_FAILED_GENERAL'); break; + default : $msg = UNKNOWN_MAILID_CODE_1.$code.UNKNOWN_MAILID_CODE_2; break; + } // END - switch + + // Return the message + return $msg; +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // ////////////////////////////////////////////////// diff --git a/inc/language/de.php b/inc/language/de.php index c71ee82fe3..371a5c21b5 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -984,7 +984,6 @@ define('CLICK_NOW', "Klick!"); define('MAILID_LINK', "Best.-Link"); define('UNKNOWN_MAILID_CODE_1', "Unbekannter Fehler-Code "); define('UNKNOWN_MAILID_CODE_2', " erkannt!"); -define('EXTENSION_PROBLEM_EXT_INACTIVE', "Erweiterung %s deaktiviert! Fehler: Kann nicht fortfahren!"); define('CHANGE_GUEST_MENU', "Verdecken, anzeigen, deaktivieren, aktivieren des Gastmenüs"); define('IS_LOCKED', "Ist gesperrt"); define('ADMIN_REMOVE_STATS_ENTRY', "Hier klicken, um Mitgliederstatistik zu entfernen!"); @@ -1074,7 +1073,6 @@ define('DEFAULT_MT_WORD', "Mailtausch"); define('DEFAULT_MT_WORD2', "Mailtausches"); define('DEFAULT_MT_WORD3', "Mailtauscher"); define('DEFAULT_POINTS', "Punkte"); -define('EXTENSION_PROBLEM_NOT_INSTALLED', "Erweiterung %s nicht installiert."); define('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE', "{!POINTS!}-Übersicht derzeit nicht verfügbar."); define('ADMIN_NOTHING_SELECTED_CHANGE', "Sie haben nichts zum Ändern des Status ausgewählt."); define('TEMPLATE_CONTENT', "Template-Content:"); @@ -1113,6 +1111,9 @@ define('ADMIN_POINTS_REPAYED', "Es wurden dem Mitglied %s%s {!POINTS!} in den Jackpot gelegt."); define('ADMIN_NO_POINTS_REPAYED', "Die Mailbuchung hatte keine {!POINTS!} zum zurückbuchen!"); define('ADMIN_POINTS_SHREDDED', "Es wurden %s {!POINTS!} geschrettert."); +define('EXTENSION_PROBLEM_EXT_INACTIVE', "Erweiterung %s deaktiviert! Fehler: Kann nicht fortfahren!"); +define('EXTENSION_PROBLEM_NOT_INSTALLED', "Erweiterung %s nicht installiert."); +define('EXTENSION_PROBLEM_UNSET_EXT', "Skriptfehler: Parameter ext nicht gesetzt!"); define('EXTENSION_WARNING_EXT_INACTIVE', "Die Erweiterung %s ist nicht aktiv. Dies kann zu Störungen führen.
\nBitte aktivieren Sie diese unter Verschiedenes->Erweiterungen."); define('EXTENSION_WARNING_USER_LIMIT', "Die Erweiterung user ist nicht aktiv. Die Anzahl User pro Seite wurde auf 100 gesetzt. Bitte aktivieren Sie diese unter Verschiedenes->Erweiterungen."); define('ADMIN_PROXY_SETTINGS_INVALID', "Ihre Proxy-Einstellungen scheinen ungültig zu sein!"); diff --git a/inc/libs/online_functions.php b/inc/libs/online_functions.php index 4e43875e37..96400dc2b1 100644 --- a/inc/libs/online_functions.php +++ b/inc/libs/online_functions.php @@ -39,17 +39,13 @@ if (!defined('__SECURITY')) { // Filter for updates/extends on the online list function FILTER_UPDATE_ONLINE_LIST () { - global $PHPSESSID; - // Do not update online list when extension is deactivated if (!EXT_IS_ACTIVE("online", true)) return; // Empty session? - if (empty($PHPSESSID)) { + if (session_id() == "") { // This is invalid here! - print "Invalid session. Backtrace:
";
-		debug_print_backtrace();
-		die("
"); + debug_report_bug("Invalid session."); } // END - if // Initialize variables @@ -74,7 +70,7 @@ function FILTER_UPDATE_ONLINE_LIST () { // Now search for the user $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_online` WHERE sid='%s' LIMIT 1", - array($PHPSESSID), __FILE__, __LINE__); + array(session_id()), __FILE__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -99,7 +95,7 @@ WHERE sid='%s' LIMIT 1", $MEM, $ADMIN, GET_REMOTE_ADDR(), - $PHPSESSID + session_id() ), __FILE__, __LINE__ ); } else { @@ -113,7 +109,7 @@ WHERE sid='%s' LIMIT 1", $rid, $MEM, $ADMIN, - $PHPSESSID, + session_id(), GET_REMOTE_ADDR() ), __FILE__, __LINE__ ); diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 2dffd31ac9..fd99af7bf8 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -1621,8 +1621,8 @@ function SURFBAR_GET_DATA ($element) { } else { // END - if print("
");
 		print_r($SURFBAR_CACHE);
-		debug_print_backtrace();
-		die("
"); + print(""); + debug_report_bug(); } // Return result diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index e5ecb1b7a8..bab177e564 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -378,14 +378,14 @@ function USER_DO_LOGIN ($uid, $passwd) { $ERROR = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); } else { // ID not found! - $ERROR = CODE_WRONG_ID; + $ERROR = constant('CODE_WRONG_ID'); } // Construct URL $URL = "modules.php?module=index&what=login&login=".$ERROR; } else { // ID not found! - $URL = "modules.php?module=index&what=login&login=".CODE_WRONG_ID; + $URL = "modules.php?module=index&what=login&login=".constant('CODE_WRONG_ID'); } // Return URL @@ -417,7 +417,7 @@ function USER_DO_NEW_PASSWORD ($email, $uid) { } else { // Userid not set! DEBUG_LOG(__FUNCTION__, __LINE__, "Userid is not set! BUG!"); - $ERROR = CODE_WRONG_ID; + $ERROR = constant('CODE_WRONG_ID'); } // Any entry found? diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 30d4372fbc..05336033fc 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -61,7 +61,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { $hashedPass = md5($_POST['pass']); // Kill maybe existing session variables - DESTROY_ADMIN_SESSION(false); + destroyAdminSession(false); // Do registration $ret = REGISTER_ADMIN($_POST['login'], $hashedPass); @@ -69,23 +69,23 @@ if (!isBooleanConstantAndTrue('admin_registered')) { { case "done": admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0); - if (!_FATAL) { + if (!constant('_FATAL')) { // Registering is done LOAD_URL("modules.php?module=admin&action=login®ister=done"); } else { - $ret = ADMIN_CANNOT_COMPLETE; + $ret = getMessage('ADMIN_CANNOT_COMPLETE'); } break; case "failed": - $ret = ADMIN_REGISTER_FAILED; + $ret = getMessage('ADMIN_REGISTER_FAILED'); break; case "already": default: if ($ret == "already") { // Admin does already exists! - $ret = ADMIN_LOGIN_ALREADY_REG; + $ret = getMessage('ADMIN_LOGIN_ALREADY_REG'); } else { // Any other kind will be logged and interpreted as 'done' DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown return code %s from CHECK_ADMIN_LOGIN()", $ret)); @@ -117,16 +117,16 @@ if (!isBooleanConstantAndTrue('admin_registered')) { // Yet-another "Notice" fix if ((!empty($_POST['ok'])) && ($_POST['ok'] == "***")) { // No login entered? - if (empty($_POST['login'])) $MSG1 = ADMIN_NO_LOGIN; + if (empty($_POST['login'])) $MSG1 = getMessage('ADMIN_NO_LOGIN'); // An error comes back from registration? if (!empty($ret)) $MSG1 = $ret; // No password entered? - if (empty($_POST['pass'])) $MSG2 = ADMIN_NO_PASS; + if (empty($_POST['pass'])) $MSG2 = getMessage('ADMIN_NO_PASS'); // Or password too short? - if (strlen($_POST['pass']) < 4) $MSG2 = ADMIN_SHORT_PASS; + if (strlen($_POST['pass']) < 4) $MSG2 = getMessage('ADMIN_SHORT_PASS'); // Output error messages define('__MSG_LOGIN', LOAD_TEMPLATE("admin_login_msg", true, $MSG1)); @@ -159,7 +159,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { $valid = ADMIN_VALIDATE_RESET_LINK_HASH_LOGIN($_POST['hash'], $_POST['login']); // Valid? - if ($valid) { + if ($valid === true) { // Prepare content first $content = array( 'hash' => SQL_ESCAPE($_POST['hash']), @@ -230,13 +230,13 @@ if (!isBooleanConstantAndTrue('admin_registered')) { case "404": // Administrator login not found $_POST['ok'] = $ret; $ret = getMessage('ADMIN_NOT_FOUND'); - DESTROY_ADMIN_SESSION(); + destroyAdminSession(); break; case "pass": // Wrong password $_POST['ok'] = $ret; $ret = "{!WRONG_PASS!} [{!ADMIN_RESET_PASS!}]\n"; - DESTROY_ADMIN_SESSION(); + destroyAdminSession(); break; default: // Others will be logged @@ -258,16 +258,16 @@ if (!isBooleanConstantAndTrue('admin_registered')) { $MSG1 = ""; $MSG2 = ""; // No login entered? - if (empty($_POST['login'])) $MSG1 = ADMIN_NO_LOGIN; + if (empty($_POST['login'])) $MSG1 = getMessage('ADMIN_NO_LOGIN'); // An error comes back from login? if ((!empty($ret)) && ($_POST['ok'] == "404")) $MSG1 = $ret; // No password entered? - if (empty($_POST['pass'])) $MSG2 = ADMIN_NO_PASS; + if (empty($_POST['pass'])) $MSG2 = getMessage('ADMIN_NO_PASS'); // Or password too short? - if (strlen($_POST['pass']) < 4) $MSG2 = ADMIN_SHORT_PASS; + if (strlen($_POST['pass']) < 4) $MSG2 = getMessage('ADMIN_SHORT_PASS'); // An error comes back from login? if ((!empty($ret)) && ($_POST['ok'] == "pass")) $MSG2 = $ret; @@ -309,7 +309,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { } // END - if } elseif (isset($_GET['logout'])) { // Only try to remove cookies - if (DESTROY_ADMIN_SESSION()) { + if (destroyAdminSession()) { // Load logout template if (isset($_GET['register'])) { // Secure input @@ -329,10 +329,10 @@ if (!isBooleanConstantAndTrue('admin_registered')) { } } else { // Something went wrong here... - LOAD_TEMPLATE("admin_settings_saved", false, "
".ADMIN_LOGOUT_FAILED."
"); + LOAD_TEMPLATE("admin_settings_saved", false, "
{!ADMIN_LOGOUT_FAILED!}
"); // Add fatal message - addFatalMessage(CANNOT_UNREG_SESS); + addFatalMessage(getMessage('CANNOT_UNREG_SESS')); } } else { // Maybe an Admin want's to login? @@ -344,7 +344,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { define('__ACL_ALLOW', RUN_FILTER('check_admin_acl')); // When type of admin menu is not set fallback to old menu system - if (getConfig('admin_menu') == null) setConfigEntry('admin_menu', "OLD"); + if (!isConfigEntrySet('admin_menu')) setConfigEntry('admin_menu', "OLD"); // Check for version and switch between old menu system and new "intelligent menu system" if ((ADMIN_CHECK_MENU_MODE() == "NEW") && (FILE_READABLE(PATH."inc/modules/admin/lasys-inc.php"))) { @@ -368,13 +368,13 @@ if (!isBooleanConstantAndTrue('admin_registered')) { case "404": // Administrator login not found $_POST['ok'] = $ret; - DESTROY_ADMIN_SESSION(); + destroyAdminSession(); addFatalMessage(getMessage('ADMIN_NOT_FOUND')); break; case "pass": // Wrong password $_POST['ok'] = $ret; - DESTROY_ADMIN_SESSION(); + destroyAdminSession(); addFatalMessage(getMessage('WRONG_PASS')); break; diff --git a/inc/modules/guest/what-login.php b/inc/modules/guest/what-login.php index 9b7ffe5dfc..0b6002d9ce 100644 --- a/inc/modules/guest/what-login.php +++ b/inc/modules/guest/what-login.php @@ -85,7 +85,7 @@ if (IS_MEMBER()) { $URL = "modules.php?module=login"; } elseif ((isset($_POST['ok'])) && ("".$uid."" != "".$_POST['id']."")) { // Invalid input (no nickname extension installed but nickname entered) - $ERROR = CODE_EXTENSION_PROBLEM; + $ERROR = constant('CODE_EXTENSION_PROBLEM'); } elseif (isset($_POST['ok'])) { // Try the login (see inc/libs/user_functions.php) $URL = USER_DO_LOGIN($_POST['id'], $_POST['password']); @@ -109,37 +109,37 @@ if (!empty($ERROR)) { "; switch ($ERROR) { - case CODE_WRONG_PASS: - $MSG .= LOGIN_WRONG_PASS; + case constant('CODE_WRONG_PASS'): + $MSG .= getMessage('LOGIN_WRONG_PASS'); break; - case CODE_WRONG_ID: - $MSG .= LOGIN_WRONG_ID; + case constant('CODE_WRONG_ID'): + $MSG .= getMessage('LOGIN_WRONG_ID'); break; - case CODE_ID_LOCKED: - $MSG .= LOGIN_ID_LOCKED; + case constant('CODE_ID_LOCKED'): + $MSG .= getMessage('LOGIN_ID_LOCKED'); break; - case CODE_ID_UNCONFIRMED: - $MSG .= LOGIN_ID_UNCONFIRMED; + case constant('CODE_ID_UNCONFIRMED'): + $MSG .= getMessage('LOGIN_ID_UNCONFIRMED'); break; - case CODE_NO_COOKIES: - $MSG .= LOGIN_NO_COOKIES; + case constant('CODE_NO_COOKIES'): + $MSG .= getMessage('LOGIN_NO_COOKIES'); break; - case CODE_EXTENSION_PROBLEM: + case constant('CODE_EXTENSION_PROBLEM'): if (IS_ADMIN()) { - $MSG .= sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "nickname"); + $MSG .= sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), "nickname"); } else { - $MSG .= LOGIN_WRONG_ID; + $MSG .= getMessage('LOGIN_WRONG_ID'); } break; default: DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR)); - $MSG .= LOGIN_WRONG_ID; + $MSG .= getMessage('LOGIN_WRONG_ID'); break; } $MSG .= " diff --git a/inc/modules/index.php b/inc/modules/index.php index 686da74754..27111a3f10 100644 --- a/inc/modules/index.php +++ b/inc/modules/index.php @@ -55,29 +55,7 @@ if (!empty($_GET['msg'])) { if (!empty($_GET['ext'])) $ext = SQL_ESCAPE($_GET['ext']); // Which message shall we output? - switch ($_GET['msg']) { - case CODE_LOGOUT_DONE : $msg = LOGOUT_DONE; break; - case CODE_LOGOUT_FAILED : $msg = "".LOGOUT_FAILED.""; break; - case CODE_DATA_INVALID : $msg = MAIL_DATA_INVALID; break; - case CODE_POSSIBLE_INVALID : $msg = MAIL_POSSIBLE_INVALID; break; - case CODE_ACCOUNT_LOCKED : $msg = MEMBER_ACCOUNT_LOCKED_UNC; break; - case CODE_USER_404 : $msg = USER_NOT_FOUND; break; - case CODE_STATS_404 : $msg = MAIL_STATS_404; break; - case CODE_ALREADY_CONFIRMED: $msg = MAIL_ALREADY_CONFIRMED; break; - - case CODE_ERROR_MAILID: - if (EXT_IS_ACTIVE($ext, true)) { $msg = ERROR_CONFIRMING_MAIL; } else { $msg = sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "mailid"); } - break; - - case CODE_EXTENSION_PROBLEM: - $msg = sprintf(EXTENSION_PROBLEM_EXT_INACTIVE, $ext); - break; - - case CODE_COOKIES_DISABLED : $msg = LOGIN_NO_COOKIES; break; - case CODE_BEG_SAME_AS_OWN : $msg = BEG_SAME_UID_AS_OWN; break; - case CODE_LOGIN_FAILED : $msg = LOGIN_FAILED_GENERAL; break; - default : $msg = UNKNOWN_MAILID_CODE_1.$_GET['msg'].UNKNOWN_MAILID_CODE_2; break; - } // END - switch + $msg = convertCodeToMessage($_GET['msg']); // Load message template LOAD_TEMPLATE("message", false, $msg); diff --git a/inc/modules/member/what-logout.php b/inc/modules/member/what-logout.php index 3eaf9e7583..39829c6c76 100644 --- a/inc/modules/member/what-logout.php +++ b/inc/modules/member/what-logout.php @@ -40,20 +40,17 @@ if (!defined('__SECURITY')) { } // Base URL for redirection (both cases) -$URL = "modules.php?module=index"; +$URL = "modules.php?module=index&msg="; if (destroy_user_session()) { // Remove theme cookie as well set_session("mxchange_theme", ""); // Logout completed - $URL .= "&msg=".CODE_LOGOUT_DONE; - - // Destroy session here - @session_destroy(); + $URL .= constant('CODE_LOGOUT_DONE'); } else { // Cannot logout! :-( - $URL .= "&msg=".CODE_LOGOUT_FAILED; + $URL .= constant('CODE_LOGOUT_FAILED'); } // Load the URL diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 3f39d1517e..f55e82999d 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -113,7 +113,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", // Test submitted text against some filters (length, URLs in text etc.) if ((strpos(strtolower($_POST['text']), "https://") > -1) || (strpos(strtolower($_POST['text']), "http://") > -1) || (strpos(strtolower($_POST['text']), "www") > -1)) { // URL found! - $URL = "modules.php?module=login&what=order&msg=".CODE_URL_FOUND; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_URL_FOUND'); } // END - if // Remove new-line and carriage-return characters @@ -122,7 +122,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", // Text length within allowed length? if (strlen($TEST) > getConfig('max_tlength')) { // Text is too long! - $URL = "modules.php?module=login&what=order&msg=".CODE_OVERLENGTH; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_OVERLENGTH'); } // END - if } // END - if @@ -132,7 +132,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", $_POST['subject'] = str_replace("\\", "[nl]", substr($_POST['subject'], 0, 200)); if ((strpos(strtolower($_POST['subject']), "http://") > -1) || (strpos(strtolower($_POST['subject']), "www") > -1)) { // URL in subject found - $URL = "modules.php?module=login&what=order&msg=".CODE_SUBJ_URL; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_SUBJ_URL'); } // END - if } // END - if @@ -147,7 +147,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", list($blist) = SQL_FETCHROW($result); // Create redirect-URL - $URL = "modules.php?module=login&what=order&msg=".CODE_BLIST_URL."&blist=".$blist; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_BLIST_URL')."&blist=".$blist; } // END - if // Free result @@ -157,13 +157,13 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", // Enougth receivers entered? if (($_POST['receiver'] < getConfig('order_min')) && (!IS_ADMIN())) { // Less than allowed receivers entered! - $URL = "modules.php?module=login&what=order&msg=".CODE_MORE_RECEIVERS3; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_RECEIVERS3'); } // END - if // Validate URL if (!VALIDATE_URL($_POST['url'])) { // URL is invalid! - $URL = "modules.php?module=login&what=order&msg=".CODE_INVALID_URL; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_INVALID_URL'); } // END - if // Probe for HTML extension @@ -174,7 +174,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", $_POST['text'] = HTML_CHECK_TAGS($_POST['text']); // Maybe invalid tags found? - if (empty($_POST['text'])) $URL = "modules.php?module=login&what=order&msg=".CODE_INVALID_TAGS."&id=".$id; + if (empty($_POST['text'])) $URL = "modules.php?module=login&what=order&msg=".constant('CODE_INVALID_TAGS')."&id=".$id; } else { // Remove any HTML code $_POST['text'] = str_replace("<", "{OPEN_HTML}", str_replace(">", "{CLOSE_HTML}", $_POST['text'])); @@ -182,7 +182,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1", } } elseif (!IS_ADMIN()) { // He has already sent a mail within a specific time - $URL = "modules.php?module=login&what=order&msg=".CODE_URL_TLOCK."&id=".$id; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_URL_TLOCK')."&id=".$id; } // Still no error? @@ -374,19 +374,19 @@ array( $URL = "modules.php?module=frametester&order=".$id.""; } elseif ($MAX_SEND == 0) { // Not enougth receivers found which can receive mails - $URL = "modules.php?module=login&what=order&msg=".CODE_MORE_RECEIVERS2; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_RECEIVERS2'); } else { // No enougth points left! - $URL = "modules.php?module=login&what=order&msg=".CODE_MORE_POINTS; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_POINTS'); } } else { // Ordered more mails than he can send in this category - $URL = "modules.php?module=login&what=order&msg=".CODE_NO_RECS_LEFT; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_NO_RECS_LEFT'); } } } elseif ($_POST['receiver'] == "0") { // Not enougth receivers selected - $URL = "modules.php?module=login&what=order&msg=".CODE_MORE_RECEIVERS1; + $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_RECEIVERS1'); } elseif (($ALLOWED == 0) && (getConfig('order_max_full') == "ORDER")) { // No more mail orders allowed LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MEMBER_ORDER_ALLOWED_EXHAUSTED')); @@ -417,7 +417,7 @@ array( // Select users in current category $result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s AND userid != '%s' ORDER BY userid", - array(bigintval($id), $GLOBALS['userid']), __FILE__, __LINE__); + array(bigintval($id), $GLOBALS['userid']), __FILE__, __LINE__); $uid_cnt = 0; while (list($ucat) = SQL_FETCHROW($result_uids)) { @@ -476,7 +476,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); $MSG = ""; switch ($_GET['msg']) { - case CODE_URL_TLOCK: + case constant('CODE_URL_TLOCK'): $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s LIMIT 1", array(bigintval($_GET['id'])), __FILE__, __LINE__); @@ -497,53 +497,54 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); $SEC = getConfig('url_tlock') - $STD * 60 * 60 - $MIN * 60; // Finally contruct the message - $MSG = MEMBER_URL_TIME_LOCK."
".CONFIG_URL_TLOCK." ".$STD." ". - _HOURS.", ".$MIN." "._MINUTES." "._AND." ".$SEC." "._SECONDS."
". - MEMBER_LAST_TLOCK.": ".$LORDER; + // @TODO Rewrite this old lost code to a template + $MSG = "{!MEMBER_URL_TIME_LOCK!}
{!CONFIG_URL_TLOCK!} ".$STD." + {!_HOURS!}, ".$MIN." {!_MINUTES!} {!_AND!} ".$SEC." {!_SECONDS!}
+ {!MEMBER_LAST_TLOCK!}: ".$LORDER; break; - case CODE_OVERLENGTH: - $MSG = MEMBER_TEXT_OVERLENGTH; + case constant('CODE_OVERLENGTH'): + $MSG = getMessage('MEMBER_TEXT_OVERLENGTH'); break; - case CODE_URL_FOUND: - $MSG = MEMBER_TEXT_CONTAINS_URL; + case constant('CODE_URL_FOUND'): + $MSG = getMessage('MEMBER_TEXT_CONTAINS_URL'); break; - case CODE_SUBJ_URL: - $MSG = MEMBER_SUBJ_CONTAINS_URL; + case constant('CODE_SUBJ_URL'): + $MSG = getMessage('MEMBER_SUBJ_CONTAINS_URL'); break; - case CODE_BLIST_URL: - $MSG = MEMBER_URL_BLACK_LISTED."
\n".MEMBER_BLIST_TIME.": ".MAKE_DATETIME($_GET['blist'], "0"); + case constant('CODE_BLIST_URL'): + $MSG = "{!MEMBER_URL_BLACK_LISTED!}
\n{!MEMBER_BLIST_TIME!}: ".MAKE_DATETIME($_GET['blist'], "0"); break; - case CODE_NO_RECS_LEFT: - $MSG = MEMBER_SELECTED_MORE_RECS; + case constant('CODE_NO_RECS_LEFT'): + $MSG = getMessage('MEMBER_SELECTED_MORE_RECS'); break; - case CODE_INVALID_TAGS: - $MSG = MEMBER_HTML_INVALID_TAGS; + case constant('CODE_INVALID_TAGS'): + $MSG = getMessage('MEMBER_HTML_INVALID_TAGS'); break; - case CODE_MORE_POINTS: - $MSG = MEMBER_MORE_POINTS_NEEDED; + case constant('CODE_MORE_POINTS'): + $MSG = getMessage('MEMBER_MORE_POINTS_NEEDED'); break; - case CODE_MORE_RECEIVERS1: - $MSG = MEMBER_ENTER_MORE_RECEIVERS; + case constant('CODE_MORE_RECEIVERS1'): + $MSG = getMessage('MEMBER_ENTER_MORE_RECEIVERS'); break; - case CODE_MORE_RECEIVERS2: - $MSG = MEMBER_NO_MORE_RECEIVERS_FOUND; + case constant('CODE_MORE_RECEIVERS2'): + $MSG = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND'); break; - case CODE_MORE_RECEIVERS3: - $MSG = MEMBER_ENTER_MORE_MIN_RECEIVERS_1.getConfig('order_min').MEMBER_ENTER_MORE_MIN_RECEIVERS_2; + case constant('CODE_MORE_RECEIVERS3'): + $MSG = "{!MEMBER_ENTER_MORE_MIN_RECEIVERS_1!}".getConfig('order_min')."{!MEMBER_ENTER_MORE_MIN_RECEIVERS_2!}"; break; - case CODE_INVALID_URL: - $MSG = MEMBER_ENTER_INVALID_URL; + case constant('CODE_INVALID_URL'): + $MSG = getMessage('MEMBER_ENTER_INVALID_URL'); break; case "": // When no error code is included in the URL we do not need to output an error message as well... @@ -551,7 +552,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); default: DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown error code %s detected.", $_GET['msg'])); - $MSG = UNKNOWN_CODE_1.$_GET['msg'].UNKNOWN_CODE_2; + $MSG = "{!UNKNOWN_CODE_1!}".$_GET['msg']."{!UNKNOWN_CODE_2!}"; break; } @@ -575,7 +576,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); switch (getConfig('order_max_full')) { case "MAX": // He is allowed to send as much as possible - define('ORDER_MAX_VALUE', ORDER_ALLOED_MAX); + define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOED_MAX')); break; case "ORDER": // He is allowed to send as much as he setup the receiving value @@ -584,7 +585,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); default: // Unknown/invalid DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown order_mas_full config detected.", getConfig('order_max_full'))); - define('ORDER_MAX_VALUE', ORDER_ALLOED_UNKNOWN); + define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOED_UNKNOWN')); break; } @@ -622,7 +623,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); foreach ($CATS['id'] as $key => $value) { $CAT .= " \n"; } // END - foreach // Mail type @@ -633,7 +634,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); // Output option line $type .= " \n"; } // END - if } // END - foreach diff --git a/inc/modules/sponsor.php b/inc/modules/sponsor.php index 4abb280e85..48ad6970cd 100644 --- a/inc/modules/sponsor.php +++ b/inc/modules/sponsor.php @@ -35,11 +35,11 @@ if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php"; require($INC); } elseif ((!EXT_IS_ACTIVE("sponsor")) - addFatalMessage(EXTENSION_PROBLEM_EXT_INACTIVE); + addFatalMessage(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE')); return; } elseif (!IS_SPONSOR()) { // No sponsor! - addFatalMessage(SPONSOR_ONLY_AREA_ENTERED); + addFatalMessage(getMessage('SPONSOR_ONLY_AREA_ENTERED')); return; } elseif (empty($GLOBALS['what'])) { // Empty what value detected! diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 697481ec2e..a84a8336c4 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -71,14 +71,10 @@ function __errorHandler ($errno, $errstr, $errfile, $errline) { // Output message to user and die if (EXT_IS_ACTIVE("debug")) { // Debug extension found! So Output a small message - mxchange_die("Error message written to debug.log. Please try to call the main page to continue."); + mxchange_die("Error message written to debug.log. Please try to call the main page to continue."); } else { - // No debug extension found - // @TODO Find a way to rewrite debug_print_backtrace() so we can maybe - // @TODO (?) rewrite this to mxchange_die() - print("Please report this error at bugs.mxchange.org:
");
-		debug_print_backtrace();
-		die("
Thank you for your help finding bugs."); + // No debug extension found, so regular output + debug_report_bug(); } } @@ -97,7 +93,7 @@ function __SHUTDOWN_HOOK () { SQL_CLOSE($link, __FILE__, __LINE__); } else { // No database link - addFatalMessage(NO_DB_LINK); + addFatalMessage(getMessage('NO_DB_LINK')); } } diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 6413d76687..9484506fc9 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -681,14 +681,11 @@ function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false) // Run SQL command $result = SQL_QUERY($SQL, __FILE__, __LINE__); if ($UPDATE) { - if (SQL_AFFECTEDROWS() == 1) $ret = true; - //* DEBUG: */ debug_print_backtrace(); + // Check updated/affected rows + $ret = (SQL_AFFECTEDROWS() == 1); } else { - if (SQL_NUMROWS($result) == 1) { - //* DEBUG: */ echo __LINE__."+".$SQL."+
\n"; - //* DEBUG: */ echo __LINE__."*".$id."/".$wht."/".$wht2."*
\n"; - $ret = true; - } + // Check found rows + $ret = (SQL_NUMROWS($result) == 1); } // Free memory diff --git a/inc/session.php b/inc/session.php index 37f988dd22..9e0876c97f 100644 --- a/inc/session.php +++ b/inc/session.php @@ -48,13 +48,11 @@ if (($VIEW == 1) && ($_SERVER['PHP_SELF'])) return; // Set session save path if set if (getConfig('session_save_path') != "") { // Please make sure this valid! - @session_save_path(getConfig('session_save_path')); + session_save_path(getConfig('session_save_path')); } // END - if // Start the session -@session_start(); -global $PHPSESSID; -$PHPSESSID = @session_id(); +session_start(); // Load language system LOAD_INC_ONCE("inc/language.php"); diff --git a/inc/stylesheet.php b/inc/stylesheet.php index 5c56b56320..a84660c803 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -46,7 +46,7 @@ $STYLES = array( if ((basename($_SERVER['PHP_SELF']) == "install.php") || (!isBooleanConstantAndTrue('mxchange_installed')) || (isset($_GET['installing']))) $STYLES[] = "install.css"; // When no CSS output-mode is set, set it to file-output -if (getConfig('css_php') == null) setConfigEntry('css_php', "FILE"); +if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', "FILE"); // Output CSS files or content or link to css.php ? if (($CSS == "1") || (getConfig('css_php') == "DIRECT")) { diff --git a/index.php b/index.php index aed7b1e9c5..c19e9a2f77 100644 --- a/index.php +++ b/index.php @@ -51,8 +51,8 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { LOAD_INC("inc/header.php"); // Fix missing array elements here - if (getConfig('index_delay') == null) setConfigEntry('index_delay' , 0); - if (getConfig('index_cookie') == null) setConfigEntry('index_cookie', 0); + if (!isConfigEntrySet('index_delay')) setConfigEntry('index_delay' , 0); + if (!isConfigEntrySet('index_cookie')) setConfigEntry('index_cookie', 0); // Check for cookies if ((isSessionVariableSet('visited')) || (getConfig('index_delay') == 0) || (getConfig('index_cookie') == 0)) { diff --git a/mailid.php b/mailid.php index 5a33578dea..e600274171 100644 --- a/mailid.php +++ b/mailid.php @@ -48,7 +48,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Is the extension active if (!EXT_IS_ACTIVE("mailid", true)) { // Is not activated/installed yet! - LOAD_URL("modules.php?module=index&msg=".CODE_EXTENSION_PROBLEM."&ext=mailid"); + LOAD_URL("modules.php?module=index&msg=".constant('CODE_EXTENSION_PROBLEM')."&ext=mailid"); } // END - if // Init @@ -96,7 +96,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Is the bonus extension active? if (!EXT_IS_ACTIVE("bonus")) { // Abort here - LOAD_URL("modules.php?module=index&msg=".CODE_EXTENSION_PROBLEM."&ext=mailid"); + LOAD_URL("modules.php?module=index&msg=".constant('CODE_EXTENSION_PROBLEM')."&ext=mailid"); } // END - if // Bonus-Mails @@ -128,8 +128,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { case "NORMAL": $result = SQL_QUERY_ESC("SELECT payment_id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s LIMIT 1", array(bigintval($pool)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + if (SQL_NUMROWS($result) == 1) { list($pay) = SQL_FETCHROW($result); $time = GET_PAY_POINTS($pay, "time"); $payment = GET_PAY_POINTS($pay, "payment"); @@ -143,8 +142,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { case "BONUS": $result = SQL_QUERY_ESC("SELECT points, time FROM `{!_MYSQL_PREFIX!}_bonus` WHERE id=%s LIMIT 1", array($url_bid), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + if (SQL_NUMROWS($result) == 1) { list($points, $time) = SQL_FETCHROW($result); $payment = "0.00000"; $VALID = true; @@ -173,29 +171,29 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Load template LOAD_TEMPLATE("mailid_frames"); } else { - $msg = CODE_DATA_INVALID; + $msg = constant('CODE_DATA_INVALID'); } } else { - $msg = CODE_POSSIBLE_INVALID; + $msg = constant('CODE_POSSIBLE_INVALID'); } } else { - $msg = CODE_ACCOUNT_LOCKED; + $msg = constant('CODE_ACCOUNT_LOCKED'); } } else { SQL_FREERESULT($result); - $msg = CODE_USER_404; + $msg = constant('CODE_USER_404'); } } else { SQL_FREERESULT($result); - $msg = CODE_STATS_404; + $msg = constant('CODE_STATS_404'); } } else { SQL_FREERESULT($result); - $msg = CODE_ALREADY_CONFIRMED; + $msg = constant('CODE_ALREADY_CONFIRMED'); } } else { // Nothing entered - $msg = CODE_ERROR_MAILID; + $msg = constant('CODE_ERROR_MAILID'); } // Error code is set? @@ -211,7 +209,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { default: DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s detected in mailid_error_redirect.", getConfig('mailid_error_redirect'))); - LOAD_URL("modules.php?module=index&msg=".CODE_UNKNOWN_STATUS."&ext=mailid"); + LOAD_URL("modules.php?module=index&msg=".constant('CODE_UNKNOWN_STATUS')."&ext=mailid"); break; } } else { diff --git a/show_bonus.php b/show_bonus.php index 2987ae3f11..12629fb9d9 100644 --- a/show_bonus.php +++ b/show_bonus.php @@ -49,7 +49,7 @@ require("inc/config.php"); // Is the "bonus" extension active? if (!EXT_IS_ACTIVE("bonus")) { // Redirect to index - LOAD_URL("modules.php?module=index&msg=".CODE_EXTENSION_PROBLEM."&ext=bonus"); + LOAD_URL("modules.php?module=index&msg=".constant('CODE_EXTENSION_PROBLEM')."&ext=bonus"); } // END - if // List only rankings when script is installed diff --git a/surfbar.php b/surfbar.php index 6b458b247a..5adb2f674e 100644 --- a/surfbar.php +++ b/surfbar.php @@ -54,7 +54,7 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Only logged in users may use this surfbar! if (!EXT_IS_ACTIVE("surfbar")) { // Surfbar deactivated - LOAD_URL("modules.php?module=login&msg=".CODE_EXTENSION_PROBLEM."&ext=surfbar"); + LOAD_URL("modules.php?module=login&msg=".constant('CODE_EXTENSION_PROBLEM')."&ext=surfbar"); } elseif (!IS_MEMBER()) { // Redirect LOAD_URL("modules.php?module=index"); -- 2.39.5