X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Ffunctions.php;h=d157a7ed00344842431105feecb76d2b92f85811;hb=48b997e125d13e5184281449feb9f4c8caf48e56;hp=b9decbaac6d40711fb02e40b93b2ed486c0f5837;hpb=0437f06b273f885db05736449a952c6eb72086ca;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index b9decbaac6..d157a7ed00 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -51,36 +51,36 @@ function OUTPUT_HTML ($HTML, $newLine = true) { // Yes, so we handle it as you have configured switch (getConfig('OUTPUT_MODE')) { - case 'render': - // That's why you don't need any \n at the end of your HTML code... :-) - if (constant('_OB_CACHING') == 'on') { - // Output into PHP's internal buffer - outputRawCode($HTML); - + case 'render': // That's why you don't need any \n at the end of your HTML code... :-) - if ($newLine) echo "\n"; - } else { - // Render mode for old or lame servers... - $OUTPUT .= $HTML; + if (constant('_OB_CACHING') == 'on') { + // Output into PHP's internal buffer + outputRawCode($HTML); - // That's why you don't need any \n at the end of your HTML code... :-) - if ($newLine) $OUTPUT .= "\n"; - } - break; + // That's why you don't need any \n at the end of your HTML code... :-) + if ($newLine) echo "\n"; + } else { + // Render mode for old or lame servers... + $OUTPUT .= $HTML; - case 'direct': - // If we are switching from render to direct output rendered code - if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; } + // That's why you don't need any \n at the end of your HTML code... :-) + if ($newLine) $OUTPUT .= "\n"; + } + break; - // The same as above... ^ - outputRawCode($HTML); - if ($newLine) echo "\n"; - break; + case 'direct': + // If we are switching from render to direct output rendered code + if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; } - default: - // Huh, something goes wrong or maybe you have edited config.php ??? - app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}"); - break; + // The same as above... ^ + outputRawCode($HTML); + if ($newLine) echo "\n"; + break; + + default: + // Huh, something goes wrong or maybe you have edited config.php ??? + app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}"); + break; } } elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) { // Headers already sent? @@ -233,7 +233,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { if ($template == "member_support_form") { // Support request of a member $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(getUserId()), __FUNCTION__, __LINE__); + array(getUserId()), __FUNCTION__, __LINE__); // Is content an array? if (is_array($content)) { @@ -300,10 +300,10 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { if ((!empty($GLOBALS['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($mode == "guest/") || ($mode == "member/") || ($mode == "admin/"))) { // Select what depended header/footer template file for admin/guest/member area $file2 = sprintf("%s%s%s_%s.tpl", - $basePath, - $mode, - $template, - SQL_ESCAPE($GLOBALS['what']) + $basePath, + $mode, + $template, + SQL_ESCAPE($GLOBALS['what']) ); // Probe for it... @@ -548,28 +548,28 @@ function generateDateTime ($time, $mode = '0') { switch (getLanguage()) { - case 'de': // German date / time format - switch ($mode) { - case '0': $ret = date("d.m.Y \u\m H:i \U\h\\r", $time); break; - case '1': $ret = strtolower(date("d.m.Y - H:i", $time)); break; - case '2': $ret = date("d.m.Y|H:i", $time); break; - case '3': $ret = date("d.m.Y", $time); break; - default: - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); - break; - } - break; - - default: // Default is the US date / time format! - switch ($mode) { - case '0': $ret = date("r", $time); break; - case '1': $ret = date("Y-m-d - g:i A", $time); break; - case '2': $ret = date("y-m-d|H:i", $time); break; - case '3': $ret = date("y-m-d", $time); break; - default: - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); - break; - } + case 'de': // German date / time format + switch ($mode) { + case '0': $ret = date("d.m.Y \u\m H:i \U\h\\r", $time); break; + case '1': $ret = strtolower(date("d.m.Y - H:i", $time)); break; + case '2': $ret = date("d.m.Y|H:i", $time); break; + case '3': $ret = date("d.m.Y", $time); break; + default: + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); + break; + } + break; + + default: // Default is the US date / time format! + switch ($mode) { + case '0': $ret = date("r", $time); break; + case '1': $ret = date("Y-m-d - g:i A", $time); break; + case '2': $ret = date("y-m-d|H:i", $time); break; + case '3': $ret = date("y-m-d", $time); break; + default: + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); + break; + } } return $ret; } @@ -635,13 +635,13 @@ function translateComma ($dotted, $cut = true, $max = 0) { // Translate it now switch (getLanguage()) { - case 'de': - $dotted = number_format($dotted, $maxComma, ',', '.'); - break; + case 'de': + $dotted = number_format($dotted, $maxComma, ',', '.'); + break; - default: - $dotted = number_format($dotted, $maxComma, '.', ','); - break; + default: + $dotted = number_format($dotted, $maxComma, '.', ','); + break; } // Return translated value @@ -672,21 +672,21 @@ function translateGender ($gender) { function translateUserStatus ($status) { switch ($status) { - case 'UNCONFIRMED': - case 'CONFIRMED': - case 'LOCKED': - $ret = getMessage(sprintf("ACCOUNT_%s", $status)); - break; - - case '': - case null: - $ret = getMessage('ACCOUNT_DELETED'); - break; - - default: - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); - $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status); - break; + case 'UNCONFIRMED': + case 'CONFIRMED': + case 'LOCKED': + $ret = getMessage(sprintf("ACCOUNT_%s", $status)); + break; + + case '': + case null: + $ret = getMessage('ACCOUNT_DELETED'); + break; + + default: + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); + $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status); + break; } // Return it @@ -709,7 +709,7 @@ function DEREFERER ($URL) { function FRAMETESTER ($URL) { // Prepare frametester URL $frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&url=%s", - encodeString(compileUriCode($URL)) + encodeString(compileUriCode($URL)) ); return $frametesterUrl; } @@ -730,51 +730,6 @@ function generateCaptchaCode ($code, $type, $DATA, $uid) { return ''; } -// "Getter" for language -function getLanguage () { - // Set default return value to default language from config - $ret = getConfig('DEFAULT_LANG'); - - // Init variable - $lang = ''; - - // Is the variable set - if (REQUEST_ISSET_GET('mx_lang')) { - // Accept only first 2 chars - $lang = substr(REQUEST_GET('mx_lang'), 0, 2); - } elseif (isset($GLOBALS['cache_array']['language'])) { - // Use cached - $ret = $GLOBALS['cache_array']['language']; - } elseif (!empty($lang)) { - // Check if main language file does exist - if (isFileReadable(constant('PATH') . 'inc/language/'.$lang.'.php')) { - // Okay found, so let's update cookies - setLanguage($lang); - } // END - if - } elseif (isSessionVariableSet('mx_lang')) { - // Return stored value from cookie - $ret = getSession('mx_lang'); - - // Fixes a warning before the session has the mx_lang constant - if (empty($ret)) $ret = getConfig('DEFAULT_LANG'); - } - - // Cache entry - $GLOBALS['cache_array']['language'] = $ret; - - // Return value - return $ret; -} - -// "Setter" for language -function setLanguage ($lang) { - // Accept only first 2 chars! - $lang = substr(SQL_ESCAPE(strip_tags($lang)), 0, 2); - - // Set cookie - setSession('mx_lang', $lang); -} - // Loads an email template and compiles it function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { global $DATA, $_CONFIG; @@ -828,12 +783,12 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { //* DEBUG: */ print __FUNCTION__."(".__LINE__."):NICKNAME!\n"; // Load nickname $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($UID)), __FUNCTION__, __LINE__); + array(bigintval($UID)), __FUNCTION__, __LINE__); } else { //* DEBUG: */ print __FUNCTION__."(".__LINE__."):NO-NICK!\n"; /// Load normal data $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($UID)), __FUNCTION__, __LINE__); + array(bigintval($UID)), __FUNCTION__, __LINE__); } // Fetch and merge data @@ -950,7 +905,7 @@ function redirectToUrl ($URL) { } // END - if // Three different debug ways... - /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); + //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL); //* DEBUG: */ die($URL); @@ -1160,98 +1115,98 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') { } switch ($type) { - case "day": // Day - for ($idx = 1; $idx < 32; $idx++) { - $OUT .= "\n"; - } // END - for - break; + case "day": // Day + for ($idx = 1; $idx < 32; $idx++) { + $OUT .= "\n"; + } // END - for + break; - case "month": // Month - foreach ($GLOBALS['month_descr'] as $month => $descr) { - $OUT .= "\n"; - } // END - for - break; + case "month": // Month + foreach ($GLOBALS['month_descr'] as $month => $descr) { + $OUT .= "\n"; + } // END - for + break; - case "year": // Year - // Get current year - $year = date('Y', time()); + case "year": // Year + // Get current year + $year = date('Y', time()); - // Use configured min age or fixed? - if (GET_EXT_VERSION('other') >= '0.2.1') { - // Configured - $startYear = $year - getConfig('min_age'); - } else { - // Fixed 16 years - $startYear = $year - 16; - } + // Use configured min age or fixed? + if (GET_EXT_VERSION('other') >= '0.2.1') { + // Configured + $startYear = $year - getConfig('min_age'); + } else { + // Fixed 16 years + $startYear = $year - 16; + } - // Calculate earliest year (100 years old people can still enter Internet???) - $minYear = $year - 100; + // Calculate earliest year (100 years old people can still enter Internet???) + $minYear = $year - 100; + + // Check if the default value is larger than minimum and bigger than actual year + if (($default > $minYear) && ($default >= $year)) { + for ($idx = $year; $idx < ($year + 11); $idx++) { + $OUT .= "\n"; + } // END - for + } elseif ($default == -1) { + // Current year minus 1 + for ($idx = $startYear; $idx <= ($year + 1); $idx++) + { + $OUT .= "".$idx."\n"; + } + } else { + // Get current year and subtract the configured minimum age + $OUT .= "<".$minYear."\n"; + // Calculate earliest year depending on extension version + if (GET_EXT_VERSION('other') >= '0.2.1') { + // Use configured minimum age + $year = date('Y', time()) - getConfig('min_age'); + } else { + // Use fixed 16 years age + $year = date('Y', time()) - 16; + } - // Check if the default value is larger than minimum and bigger than actual year - if (($default > $minYear) && ($default >= $year)) { - for ($idx = $year; $idx < ($year + 11); $idx++) { + // Construct year selection list + for ($idx = $minYear; $idx <= $year; $idx++) { + $OUT .= "\n"; + } // END - for + } + break; + + case "sec": + case "min": + for ($idx = 0; $idx < 60; $idx+=5) { + if (strlen($idx) == 1) $idx = '0'.$idx; $OUT .= "\n"; } // END - for - } elseif ($default == -1) { - // Current year minus 1 - for ($idx = $startYear; $idx <= ($year + 1); $idx++) - { - $OUT .= "".$idx."\n"; - } - } else { - // Get current year and subtract the configured minimum age - $OUT .= "<".$minYear."\n"; - // Calculate earliest year depending on extension version - if (GET_EXT_VERSION('other') >= '0.2.1') { - // Use configured minimum age - $year = date('Y', time()) - getConfig('min_age'); - } else { - // Use fixed 16 years age - $year = date('Y', time()) - 16; - } + break; - // Construct year selection list - for ($idx = $minYear; $idx <= $year; $idx++) { + case "hour": + for ($idx = 0; $idx < 24; $idx++) { + if (strlen($idx) == 1) $idx = '0'.$idx; $OUT .= "\n"; } // END - for - } - break; - - case "sec": - case "min": - for ($idx = 0; $idx < 60; $idx+=5) { - if (strlen($idx) == 1) $idx = '0'.$idx; - $OUT .= "\n"; - } // END - for - break; - - case "hour": - for ($idx = 0; $idx < 24; $idx++) { - if (strlen($idx) == 1) $idx = '0'.$idx; - $OUT .= "\n"; - } // END - for - break; - - case 'yn': - $OUT .= "\n"; for ($idx = 0; $idx <= 11; $idx++) { - $OUT .= " \n"; } @@ -1617,11 +1572,11 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) { // Check which admin shall receive this mail $result = SQL_QUERY_ESC("SELECT DISTINCT admin_id FROM `{!_MYSQL_PREFIX!}_admins_mails` WHERE mail_template='%s' ORDER BY admin_id", - array($template), __FUNCTION__, __LINE__); + array($template), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 0) { // Create new entry (to all admins) SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_admins_mails` (admin_id, mail_template) VALUES (0, '%s')", - array($template), __FUNCTION__, __LINE__); + array($template), __FUNCTION__, __LINE__); } else { // Load admin IDs... // @TODO This can be, somehow, rewritten @@ -1645,19 +1600,19 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) { } else { // Log error for debug DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Extension 'events' missing: tpl=%s,subj=%s,UID=%s", - $template, - $subj, - $UID + $template, + $subj, + $UID )); } } elseif ($aid == '0') { // Select all email adresses $result = SQL_QUERY("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id`", - __FUNCTION__, __LINE__); + __FUNCTION__, __LINE__); } else { // If Admin-ID is not "to-all" select $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` WHERE id IN (%s) ORDER BY `id`", - array($aid), __FUNCTION__, __LINE__); + array($aid), __FUNCTION__, __LINE__); } } @@ -1760,7 +1715,7 @@ function extractHostnameFromUrl (&$script) { $url = constant('SERVER_URL'); // Is this URL valid? - if (substr($script, 0, 7) == "http://") { + if (substr($script, 0, 7) == 'http://') { // Use the hostname from script URL as new hostname $url = substr($script, 7); $extract = explode('/', $url); @@ -1769,12 +1724,12 @@ function extractHostnameFromUrl (&$script) { } // END - if // Extract host name - $host = str_replace("http://", '', $url); + $host = str_replace('http://', '', $url); if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); // Generate relative URL //* DEBUG: */ print("SCRIPT=".$script."\n"); - if (substr(strtolower($script), 0, 7) == "http://") { + if (substr(strtolower($script), 0, 7) == 'http://') { // But only if http:// is in front! $script = substr($script, (strlen($url) + 7)); } elseif (substr(strtolower($script), 0, 8) == "https://") { @@ -1798,17 +1753,17 @@ function sendGetRequest ($script) { $host = extractHostnameFromUrl($script); // Generate GET request header - $request = "GET /" . trim($script) . " HTTP/1.1\r\n"; - $request .= "Host: " . $host . "\r\n"; - $request .= "Referer: " . constant('URL') . "/admin.php\r\n"; + $request = "GET /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL'); + $request .= "Host: " . $host . getConfig('HTTP_EOL'); + $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL'); if (defined('FULL_VERSION')) { - $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . "\r\n"; + $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL'); } else { - $request .= "User-Agent: " . constant('TITLE') . "/?.?.?\r\n"; + $request .= "User-Agent: " . constant('TITLE') . "/?.?.?" . getConfig('HTTP_EOL'); } - $request .= "Content-Type: text/plain\r\n"; - $request .= "Cache-Control: no-cache\r\n"; - $request .= "Connection: Close\r\n\r\n"; + $request .= "Content-Type: text/plain" . getConfig('HTTP_EOL'); + $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL'); + $request .= "Connection: Close" . getConfig('HTTP_EOL') . getConfig('HTTP_EOL'); // Send the raw request $response = sendRawRequest($host, $request); @@ -1836,14 +1791,14 @@ function sendPostRequest ($script, $postData) { $data = http_build_query($postData, '','&'); // Generate POST request header - $request = "POST /" . trim($script) . " HTTP/1.1\r\n"; - $request .= "Host: " . $host . "\r\n"; - $request .= "Referer: " . constant('URL') . "/admin.php\r\n"; - $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . "\r\n"; - $request .= "Content-type: application/x-www-form-urlencoded\r\n"; - $request .= "Content-length: " . strlen($data) . "\r\n"; - $request .= "Cache-Control: no-cache\r\n"; - $request .= "Connection: Close\r\n\r\n"; + $request = "POST /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL'); + $request .= "Host: " . $host . getConfig('HTTP_EOL'); + $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL'); + $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL'); + $request .= "Content-type: application/x-www-form-urlencoded" . getConfig('HTTP_EOL'); + $request .= "Content-length: " . strlen($data) . getConfig('HTTP_EOL'); + $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL'); + $request .= "Connection: Close" . getConfig('HTTP_EOL') . getConfig('HTTP_EOL'); $request .= $data; // Send the raw request @@ -1855,6 +1810,9 @@ function sendPostRequest ($script, $postData) { // Sends a raw request to another host function sendRawRequest ($host, $request) { + // Init errno and errdesc with 'all fine' values + $errno = 0; $errdesc = ''; + // Initialize array $response = array('', '', ''); @@ -1869,9 +1827,11 @@ function sendRawRequest ($host, $request) { // Open connection //* DEBUG: */ die("SCRIPT=".$script."\n"); - if ($useProxy) { - $fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), getConfig('proxy_port'), $errno, $errdesc, 30); + if ($useProxy === true) { + // Connect to host through proxy connection + $fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30); } else { + // Connect to host directly $fp = @fsockopen($host, 80, $errno, $errdesc, 30); } @@ -1882,20 +1842,20 @@ function sendRawRequest ($host, $request) { } // END - if // Do we use proxy? - if ($useProxy) { + if ($useProxy === true) { // Generate CONNECT request header - $proxyTunnel = "CONNECT ".$host.":80 HTTP/1.1\r\n"; - $proxyTunnel .= "Host: ".$host."\r\n"; + $proxyTunnel = "CONNECT " . $host . ":80 HTTP/1.1" . getConfig('HTTP_EOL'); + $proxyTunnel .= "Host: " . $host . getConfig('HTTP_EOL'); // Use login data to proxy? (username at least!) if (getConfig('proxy_username') != '') { // Add it as well - $encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')).getConfig('ENCRYPT_SEPERATOR').COMPILE_CODE(getConfig('proxy_password'))); - $proxyTunnel .= "Proxy-Authorization: Basic ".$encodedAuth."\r\n"; + $encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')) . getConfig('ENCRYPT_SEPERATOR') . COMPILE_CODE(getConfig('proxy_password'))); + $proxyTunnel .= "Proxy-Authorization: Basic " . $encodedAuth . getConfig('HTTP_EOL'); } // END - if // Add last new-line - $proxyTunnel .= "\r\n"; + $proxyTunnel .= getConfig('HTTP_EOL'); //* DEBUG: */ print("proxyTunnel=".$proxyTunnel.""); // Write request @@ -1946,7 +1906,7 @@ function sendRawRequest ($host, $request) { //* DEBUG: */ print("Response:".print_r($response, true).""); // Proxy agent found? - if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy)) { + if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) { // Proxy header detected, so remove two lines array_shift($response); array_shift($response); @@ -2048,7 +2008,7 @@ function generateMemberEmailLink ($email, $table = 'admins') { if ((EXT_IS_ACTIVE('admins')) && ($table == 'admins')) { // Create email link for contacting admin in guest area $EMAIL = adminsCreateEmailLink($email); - } elseif ((EXT_IS_ACTIVE('user')) && (GET_EXT_VERSION('user') >= '0.3.3') && ($table == 'user_data')) { + } elseif ((EXT_IS_ACTIVE('user')) && (GET_EXT_VERSION('user') >= '0.3.3') && ($table == 'user_data')) { // Create email link for contacting a member within admin area (or later in other areas, too?) $EMAIL = USER_generateMemberEmailLink($email); } elseif ((EXT_IS_ACTIVE('sponsor')) && ($table == 'sponsor_data')) { @@ -2263,9 +2223,6 @@ function app_die ($F, $L, $msg) { // Load footer loadIncludeOnce('inc/footer.php'); - - // Exit explicitly - shutdown(); } else { // Script tried to kill itself twice debug_report_bug('Script wanted to kill itself more than once! Raw message=' . $msg . ', file/function=' . $F . ', line=' . $L); @@ -2336,31 +2293,6 @@ function isApacheModuleLoaded ($apacheModule) { return (((function_exists('apache_get_modules')) && (in_array($apacheModule, apache_get_modules()))) || (!function_exists('apache_get_modules'))); } -// "Getter" for language strings -// @TODO Rewrite all language constants to this function. -function getMessage ($messageId) { - // Default is not found! - $return = '!'.$messageId.'!'; - - // Is the language string found? - if (isset($GLOBALS['msg'][strtolower($messageId)])) { - // Language array element found in small_letters - $return = $GLOBALS['msg'][$messageId]; - } elseif (isset($GLOBALS['msg'][strtoupper($messageId)])) { - // @DEPRECATED Language array element found in BIG_LETTERS - $return = $GLOBALS['msg'][$messageId]; - } elseif (defined($messageId)) { - // @DEPRECATED Deprecated constant found - $return = constant($messageId); - } else { - // Missing language constant - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Missing message string %s detected.", $messageId)); - } - - // Return the string - return $return; -} - // Get current theme name function getCurrentTheme() { // The default theme is 'default'... ;-) @@ -2433,7 +2365,7 @@ function getThemeId ($name) { } elseif (GET_EXT_VERSION('cache') != '0.1.8') { // Check if current theme is already imported or not $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_themes` WHERE theme_path='%s' LIMIT 1", - array($name), __FUNCTION__, __LINE__); + array($name), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -2475,7 +2407,7 @@ function searchDirsRecursive ($dir, &$last_changed) { // Get dir as array //* DEBUG: */ print __FUNCTION__."(".__LINE__."):dir=".$dir."\n"; // Does it match what we are looking for? (We skip a lot files already!) - // RegexPattern to exclude ., .., .revision, .svn, debug.log or .cache in the filenames + // RegexPattern to exclude ., .., .revision, .svn, debug.log or .cache in the filenames $excludePattern = '@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache|config\.php)$@'; $ds = getArrayFromDirectory($dir, '', true, false, $excludePattern); //* DEBUG: */ print __FUNCTION__."(".__LINE__."):ds[]=".count($ds)."\n"; @@ -2488,7 +2420,7 @@ function searchDirsRecursive ($dir, &$last_changed) { // Is it a file and readable? //* DEBUG: */ print __FUNCTION__."(".__LINE__."):FQFN={$FQFN}\n"; if (isDirectory($FQFN)) { - // $FQFN is a directory so also crawl into this directory + // $FQFN is a directory so also crawl into this directory $newDir = $d; if (!empty($dir)) $newDir = $dir . '/'. $d; //* DEBUG: */ print __FUNCTION__."(".__LINE__."):DESCENT: ".$newDir."\n"; @@ -2516,8 +2448,8 @@ function getActualVersion ($type = 'Revision') { // Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File) if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') $new = true; if (!isset($GLOBALS['cache_array']['revision'][$type]) - || count($GLOBALS['cache_array']['revision']) < 3 - || !$GLOBALS['cache_instance']->loadCacheFile('revision')) $new = true; + || count($GLOBALS['cache_array']['revision']) < 3 + || !$GLOBALS['cache_instance']->loadCacheFile('revision')) $new = true; // Is the cache file outdated/invalid? if ($new === true){ @@ -2617,9 +2549,9 @@ function getArrayFromActualVersion () { // at least 3 keyword-Tags are needed for propper values if ($res && $res >= 3 - && isset($akt_vers['Revision']) && $akt_vers['Revision'] != '' - && isset($akt_vers['Date']) && $akt_vers['Date'] != '' - && isset($akt_vers['Tag']) && $akt_vers['Tag'] != '') { + && isset($akt_vers['Revision']) && $akt_vers['Revision'] != '' + && isset($akt_vers['Date']) && $akt_vers['Date'] != '' + && isset($akt_vers['Tag']) && $akt_vers['Tag'] != '') { // Prepare content witch need special treadment // Prepare timestamp for date @@ -2676,7 +2608,7 @@ function debug_report_bug ($message = '') { if (!empty($message)) { // Use and log it $debug = sprintf("Note: %s\n", - $message + $message ); // @TODO Add a little more infos here @@ -2684,7 +2616,7 @@ function debug_report_bug ($message = '') { } // END - if // Add output - $debug .= "Please report this bug at bugs.mxchange.org:"; + $debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you cannot attach files!):"; $debug .= debug_get_printable_backtrace(); $debug .= "\nRequest-URI: ".$_SERVER['REQUEST_URI']."\n"; $debug .= "Thank you for finding bugs."; @@ -2723,7 +2655,7 @@ function convertCodeToMessage ($code) { case getCode('EXTENSION_PROBLEM'): if (REQUEST_ISSET_GET('ext')) { - $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET('ext')); + $msg = generateExtensionInactiveMessage(REQUEST_GET('ext')); } else { $msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT'); } @@ -2784,15 +2716,15 @@ function compileUriCode ($code, $simple=true) { // Compile QUOT and other non-HTML codes $code = str_replace('{DOT}', '.', - str_replace('{SLASH}', '/', - str_replace('{QUOT}', "'", - str_replace('{DOLLAR}', '$', - str_replace('{OPEN_ANCHOR}', '(', - str_replace('{CLOSE_ANCHOR}', ')', - str_replace('{OPEN_SQR}', '[', - str_replace('{CLOSE_SQR}', ']', - str_replace('{PER}', '%', - $code + str_replace('{SLASH}', '/', + str_replace('{QUOT}', "'", + str_replace('{DOLLAR}', '$', + str_replace('{OPEN_ANCHOR}', '(', + str_replace('{CLOSE_ANCHOR}', ')', + str_replace('{OPEN_SQR}', '[', + str_replace('{CLOSE_SQR}', ']', + str_replace('{PER}', '%', + $code ))))))))); // Return compiled code @@ -2877,16 +2809,16 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // Is the file there and read-/write-able? if ((isFileReadable($FQFN)) && (is_writeable($FQFN))) { - $search = "CFG: ".$comment; - $tmp = $FQFN.".tmp"; + $search = 'CFG: ' . $comment; + $tmp = $FQFN . '.tmp'; // Open the source file - $fp = fopen($FQFN, 'r') or OUTPUT_HTML("READ: ".$FQFN.""); + $fp = fopen($FQFN, 'r') or OUTPUT_HTML('READ: ' . $FQFN . "\n"); // Is the resource valid? if (is_resource($fp)) { // Open temporary file - $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML("WRITE: ".$tmp.""); + $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML('WRITE: ' . $tmp . "\n"); // Is the resource again valid? if (is_resource($fp_tmp)) { @@ -2899,7 +2831,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { if ($next > -1) { if ($next === $seek) { $next = -1; - $line = $prefix . $DATA . $suffix."\n"; + $line = $prefix . $DATA . $suffix . "\n"; } else { $next++; } @@ -2907,31 +2839,31 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // Write to temp file fputs($fp_tmp, $line); - } + } // END - while // Close temp file fclose($fp_tmp); // Finished writing tmp file $done = true; - } + } // END - if // Close source file fclose($fp); - if (($done) && ($found)) { + if (($done === true) && ($found === true)) { // Copy back tmp file and delete tmp :-) - copy($tmp, $FQFN); - return unlink($tmp); - } elseif (!$found) { - OUTPUT_HTML("CHANGE: 404!"); + copyFileVerified($tmp, $FQFN, 0644); + return removeFile($tmp); + } elseif ($found === false) { + OUTPUT_HTML('CHANGE: 404!'); } else { - OUTPUT_HTML("TMP: UNDONE!"); + OUTPUT_HTML('TMP: UNDONE!'); } } } else { // File not found, not readable or writeable - OUTPUT_HTML("404: ".$FQFN.""); + OUTPUT_HTML('404: ' . $FQFN . ''); } // An error was detected! @@ -3211,15 +3143,15 @@ function addNewBonusMail ($data, $mode = '', $output=true) { if (!empty($RECEIVER)) { // Add bonus mail to queue addBonusMailToQueue( - $data['subject'], - $data['text'], - $RECEIVER, - $data['points'], - $data['seconds'], - $data['url'], - $data['cat'], - $mode, - $data['receiver'] + $data['subject'], + $data['text'], + $RECEIVER, + $data['points'], + $data['seconds'], + $data['url'], + $data['cat'], + $mode, + $data['receiver'] ); // Mail inserted into bonus pool @@ -3363,6 +3295,27 @@ function isExtraTitleSet () { return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title']))); } +// Generates a 'extension foo inactive' message +function generateExtensionInactiveMessage ($ext) { + // Is the extension empty? + if (empty($ext)) { + // This should not happen + trigger_error(__FUNCTION__ . ': Parameter ext is empty. This should not happen.'); + } // END - if + + // Default message + $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), $ext); + + // Is an admin logged in? + if (IS_ADMIN()) { + // Then output admin message + $msg = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_INACTIVE'), $ext); + } // END - if + + // Return prepared message + return $msg; +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // //////////////////////////////////////////////////
".$proxyTunnel."
".print_r($response, true)."
"; + $debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you cannot attach files!):"; $debug .= debug_get_printable_backtrace(); $debug .= "\nRequest-URI: ".$_SERVER['REQUEST_URI']."\n"; $debug .= "Thank you for finding bugs."; @@ -2723,7 +2655,7 @@ function convertCodeToMessage ($code) { case getCode('EXTENSION_PROBLEM'): if (REQUEST_ISSET_GET('ext')) { - $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET('ext')); + $msg = generateExtensionInactiveMessage(REQUEST_GET('ext')); } else { $msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT'); } @@ -2784,15 +2716,15 @@ function compileUriCode ($code, $simple=true) { // Compile QUOT and other non-HTML codes $code = str_replace('{DOT}', '.', - str_replace('{SLASH}', '/', - str_replace('{QUOT}', "'", - str_replace('{DOLLAR}', '$', - str_replace('{OPEN_ANCHOR}', '(', - str_replace('{CLOSE_ANCHOR}', ')', - str_replace('{OPEN_SQR}', '[', - str_replace('{CLOSE_SQR}', ']', - str_replace('{PER}', '%', - $code + str_replace('{SLASH}', '/', + str_replace('{QUOT}', "'", + str_replace('{DOLLAR}', '$', + str_replace('{OPEN_ANCHOR}', '(', + str_replace('{CLOSE_ANCHOR}', ')', + str_replace('{OPEN_SQR}', '[', + str_replace('{CLOSE_SQR}', ']', + str_replace('{PER}', '%', + $code ))))))))); // Return compiled code @@ -2877,16 +2809,16 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // Is the file there and read-/write-able? if ((isFileReadable($FQFN)) && (is_writeable($FQFN))) { - $search = "CFG: ".$comment; - $tmp = $FQFN.".tmp"; + $search = 'CFG: ' . $comment; + $tmp = $FQFN . '.tmp'; // Open the source file - $fp = fopen($FQFN, 'r') or OUTPUT_HTML("READ: ".$FQFN.""); + $fp = fopen($FQFN, 'r') or OUTPUT_HTML('READ: ' . $FQFN . "\n"); // Is the resource valid? if (is_resource($fp)) { // Open temporary file - $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML("WRITE: ".$tmp.""); + $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML('WRITE: ' . $tmp . "\n"); // Is the resource again valid? if (is_resource($fp_tmp)) { @@ -2899,7 +2831,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { if ($next > -1) { if ($next === $seek) { $next = -1; - $line = $prefix . $DATA . $suffix."\n"; + $line = $prefix . $DATA . $suffix . "\n"; } else { $next++; } @@ -2907,31 +2839,31 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // Write to temp file fputs($fp_tmp, $line); - } + } // END - while // Close temp file fclose($fp_tmp); // Finished writing tmp file $done = true; - } + } // END - if // Close source file fclose($fp); - if (($done) && ($found)) { + if (($done === true) && ($found === true)) { // Copy back tmp file and delete tmp :-) - copy($tmp, $FQFN); - return unlink($tmp); - } elseif (!$found) { - OUTPUT_HTML("CHANGE: 404!"); + copyFileVerified($tmp, $FQFN, 0644); + return removeFile($tmp); + } elseif ($found === false) { + OUTPUT_HTML('CHANGE: 404!'); } else { - OUTPUT_HTML("TMP: UNDONE!"); + OUTPUT_HTML('TMP: UNDONE!'); } } } else { // File not found, not readable or writeable - OUTPUT_HTML("404: ".$FQFN.""); + OUTPUT_HTML('404: ' . $FQFN . ''); } // An error was detected! @@ -3211,15 +3143,15 @@ function addNewBonusMail ($data, $mode = '', $output=true) { if (!empty($RECEIVER)) { // Add bonus mail to queue addBonusMailToQueue( - $data['subject'], - $data['text'], - $RECEIVER, - $data['points'], - $data['seconds'], - $data['url'], - $data['cat'], - $mode, - $data['receiver'] + $data['subject'], + $data['text'], + $RECEIVER, + $data['points'], + $data['seconds'], + $data['url'], + $data['cat'], + $mode, + $data['receiver'] ); // Mail inserted into bonus pool @@ -3363,6 +3295,27 @@ function isExtraTitleSet () { return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title']))); } +// Generates a 'extension foo inactive' message +function generateExtensionInactiveMessage ($ext) { + // Is the extension empty? + if (empty($ext)) { + // This should not happen + trigger_error(__FUNCTION__ . ': Parameter ext is empty. This should not happen.'); + } // END - if + + // Default message + $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), $ext); + + // Is an admin logged in? + if (IS_ADMIN()) { + // Then output admin message + $msg = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_INACTIVE'), $ext); + } // END - if + + // Return prepared message + return $msg; +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // //////////////////////////////////////////////////
"; $debug .= debug_get_printable_backtrace(); $debug .= "