X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=361b71180b06a5c4ac1e1adf9bb2fa1fb5e276fd;hp=10b4d02d329c05dc548ad0e5d24520cf9cafd306;hb=706f3b7d03e9bd0f241aa7ee7d2eaa0b2e2869c2;hpb=49248176a5638be80b148ef55d0dc8c334522bf3 diff --git a/inc/functions.php b/inc/functions.php index 10b4d02d32..361b71180b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -44,7 +44,11 @@ if (!defined('__SECURITY')) { // Output HTML code directly or 'render' it. You addionally switch the new-line character off function OUTPUT_HTML ($HTML, $newLine = true) { // Some global variables - global $OUTPUT; + global $OUTPUT, $username; + + // Prepare IP number and User Agent + $REMOTE_ADDR = detectRemoteAddr(); + $HTTP_USER_AGENT = detectUserAgent(); // Do we have HTML-Code here? if (!empty($HTML)) { @@ -58,7 +62,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { outputRawCode($HTML); // That's why you don't need any \n at the end of your HTML code... :-) - if ($newLine) echo "\n"; + if ($newLine) print("\n"); } else { // Render mode for old or lame servers... $OUTPUT .= $HTML; @@ -74,22 +78,22 @@ function OUTPUT_HTML ($HTML, $newLine = true) { // The same as above... ^ outputRawCode($HTML); - if ($newLine) echo "\n"; + if ($newLine) print("\n"); break; default: // Huh, something goes wrong or maybe you have edited config.php ??? - app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}"); + 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? if (headers_sent()) { // Log this error - DEBUG_LOG(__FUNCTION__, __LINE__, "Headers already sent! We need debug backtrace here."); + DEBUG_LOG(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.'); // Trigger an user error - debug_report_bug("Headers are already sent!"); + debug_report_bug('Headers are already sent!'); } // END - if // Output cached HTML code @@ -120,7 +124,11 @@ function OUTPUT_HTML ($HTML, $newLine = true) { // Compile and run finished rendered HTML code while (strpos($OUTPUT, '{!') > 0) { + // Replace _MYSQL_PREFIX + $OUTPUT = str_replace('{!_MYSQL_PREFIX!}', getConfig('_MYSQL_PREFIX'), $OUTPUT); + // Prepare the content and eval() it... + $content = array(); $newContent = ''; $eval = "\$newContent = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";"; eval($eval); @@ -128,7 +136,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { // Was that eval okay? if (empty($newContent)) { // Something went wrong! - app_die(__FUNCTION__, __LINE__, "Evaluation error:
".htmlentities($eval)."
"); + app_die(__FUNCTION__, __LINE__, 'Evaluation error:
' . htmlentities($eval) . '
'); } // END - if $OUTPUT = $newContent; } // END - while @@ -155,7 +163,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { // Output the raw HTML code function outputRawCode ($HTML) { // Output stripped HTML code to avoid broken JavaScript code, etc. - echo stripslashes(stripslashes($HTML)); + print(stripslashes(stripslashes($HTML))); // Flush the output if only constant('_OB_CACHING') is not 'on' if (constant('_OB_CACHING') != 'on') { @@ -211,31 +219,33 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { // @TODO Remove this sanity-check if all is fine if (!is_bool($return)) debug_report_bug('return is not bool (' . gettype($return) . ')'); + // Prepare IP number and User Agent + $REMOTE_ADDR = detectRemoteAddr(); + $HTTP_USER_AGENT = detectUserAgent(); + // Add more variables which you want to use in your template files global $DATA, $username; - // Get whole config array - $_CONFIG = getConfigArray(); - // Make all template names lowercase $template = strtolower($template); // Count the template load incrementConfigEntry('num_templates'); - // Prepare IP number and User Agent - $REMOTE_ADDR = detectRemoteAddr(); - if (!defined('REMOTE_ADDR')) define('REMOTE_ADDR', $REMOTE_ADDR); - $HTTP_USER_AGENT = detectUserAgent(); - // Init some data $ret = ''; if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0; + // Generate date/time string + $date_time = generateDateTime(time(), '1'); + + // Is content an array + if (is_array($content)) $content['date_time'] = $date_time; + // @DEPRECATED Try to rewrite the if() condition 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", + $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(getUserId()), __FUNCTION__, __LINE__); // Is content an array? @@ -247,24 +257,21 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { $content['gender'] = translateGender($content['gender']); } else { // @DEPRECATED - // @TODO Fine all templates which are using these direct variables and rewrite them. + // @TODO Find all templates which are using these direct variables and rewrite them. // @TODO After this step is done, this else-block is history list($gender, $surname, $family, $email) = SQL_FETCHROW($result); // Translate gender $gender = translateGender($gender); - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content))); + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array [%s], template=%s.", gettype($content), $template)); } // Free result SQL_FREERESULT($result); } // END - if - // Generate date/time string - $date_time = generateDateTime(time(), '1'); - // Base directory - $basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage()); + $basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage()); $mode = ''; // Check for admin/guest/member templates @@ -286,13 +293,16 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { } elseif (strpos($template, 'la_') > -1) { // 'Logical-area' template found $mode = 'la/'; + } elseif (strpos($template, 'js_') > -1) { + // JavaScript template found + $mode = 'js/'; } else { // Test for extension $test = substr($template, 0, strpos($template, '_')); if (EXT_IS_ACTIVE($test)) { // Set extra path to extension's name - $mode = $test.'/'; - } + $mode = $test . '/'; + } // END - if } //////////////////////// @@ -333,16 +343,23 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { // Do we have to compile the code? $ret = ''; if ((strpos($tmpl_file, "\$") !== false) || (strpos($tmpl_file, '{--') !== false) || (strpos($tmpl_file, '--}') > 0)) { - // Okay, compile it! - $tmpl_file = "\$ret=\"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";"; - eval($tmpl_file); + // Compile it + $eval = "\$ret = \"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";"; + eval($eval); + // NEW WAY: $ret = str_replace("\$content", "\$GLOBALS[compile][".$template."]", $tmpl_file); + // NEW WAY: $ret = str_replace("\$DATA", "\$GLOBALS[data][".$template."]", $ret); + // NEW WAY: $GLOBALS['compile'][$template] = $content; + // NEW WAY: $GLOBALS['data'][$template] = $DATA; } else { // Simply return loaded code $ret = $tmpl_file; } - // Add surrounding HTML comments to help finding bugs faster - $ret = "\n" . $ret . "\n"; + // Normal HTML output? + if ($GLOBALS['output_mode'] == 0) { + // Add surrounding HTML comments to help finding bugs faster + $ret = "\n" . $ret . "\n"; + } // END - if } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) { // Only admins shall see this warning or when installation mode is active $ret = "
{--TEMPLATE_404--}
@@ -377,22 +394,24 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { // Send mail out to an email address function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') { - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
"); // Compile subject line (for POINTS constant etc.) $eval = "\$subject = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($subject))."\");"; eval($eval); // Set from header - if ((!eregi("@", $toEmail)) && ($toEmail > 0)) { + if ((!eregi('@', $toEmail)) && ($toEmail > 0)) { // Value detected, is the message extension installed? - if (EXT_IS_ACTIVE("msg")) { + // @TODO Extension 'msg' does not exist + if (EXT_IS_ACTIVE('msg')) { ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $HTML); return; } else { // Load email address - $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($toEmail)), __FUNCTION__, __LINE__); - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
\n"; + $result_email = SQL_QUERY_ESC("SELECT `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", + array(bigintval($toEmail)), __FUNCTION__, __LINE__); + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
"); // Does the user exist? if (SQL_NUMROWS($result_email)) { @@ -400,7 +419,7 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') list($toEmail) = SQL_FETCHROW($result_email); } else { // Set webmaster - $toEmail = constant('WEBMASTER'); + $toEmail = getConfig('WEBMASTER'); } // Free result @@ -408,9 +427,9 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') } } elseif ($toEmail == '0') { // Is the webmaster! - $toEmail = constant('WEBMASTER'); + $toEmail = getConfig('WEBMASTER'); } - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):TO={$toEmail}
"); // Check for PHPMailer or debug-mode if (!checkPhpMailerUsage()) { @@ -458,7 +477,7 @@ Message : " . $message." sendRawEmail($toEmail, $subject, $message, $mailHeader); } elseif ($HTML == 'N') { // Problem found! - sendRawEmail(constant('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader); + sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader); } } @@ -479,7 +498,7 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { // get new instance $mail = new PHPMailer(); - $mail->PluginDir = sprintf("%sinc/phpmailer/", constant('PATH')); + $mail->PluginDir = sprintf("%sinc/phpmailer/", getConfig('PATH')); $mail->IsSMTP(); $mail->SMTPAuth = true; @@ -488,11 +507,11 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { $mail->Username = getConfig('SMTP_USER'); $mail->Password = getConfig('SMTP_PASSWORD'); if (empty($from)) { - $mail->From = constant('WEBMASTER'); + $mail->From = getConfig('WEBMASTER'); } else { $mail->From = $from; } - $mail->FromName = constant('MAIN_TITLE'); + $mail->FromName = getConfig('MAIN_TITLE'); $mail->Subject = $subject; if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($message) != $message)) { $mail->Body = $message; @@ -503,9 +522,9 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { $mail->Body = decodeEntities($message); } $mail->AddAddress($toEmail, ''); - $mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE')); - $mail->AddCustomHeader('Errors-To:' . constant('WEBMASTER')); - $mail->AddCustomHeader('X-Loop:' . constant('WEBMASTER')); + $mail->AddReplyTo(getConfig('WEBMASTER'), getConfig('MAIN_TITLE')); + $mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER')); + $mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER')); $mail->Send(); } else { // Use legacy mail() command @@ -699,7 +718,7 @@ function translateUserStatus ($status) { // Generates an URL for the dereferer function DEREFERER ($URL) { // Don't de-refer our own links! - if (substr($URL, 0, strlen(constant('URL'))) != constant('URL')) { + if (substr($URL, 0, strlen(getConfig('URL'))) != getConfig('URL')) { // De-refer this link $URL = 'modules.php?module=loader&url=' . encodeString(compileUriCode($URL)); } // END - if @@ -711,7 +730,7 @@ function DEREFERER ($URL) { // Generates an URL for the frametester function FRAMETESTER ($URL) { // Prepare frametester URL - $frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&url=%s", + $frametesterUrl = sprintf("{?URL?}/modules.php?module=frametester&url=%s", encodeString(compileUriCode($URL)) ); return $frametesterUrl; @@ -730,7 +749,7 @@ function countSelection ($array) { // Generate XHTML code for the CAPTCHA function generateCaptchaCode ($code, $type, $DATA, $uid) { - return 'Code'; + return 'Code'; } // Loads an email template and compiles it @@ -751,7 +770,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { $HTTP_USER_AGENT = detectUserAgent(); // Default admin - $ADMIN = constant('MAIN_TITLE'); + $ADMIN = getConfig('MAIN_TITLE'); // Is the admin logged in? if (IS_ADMIN()) { @@ -763,7 +782,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { } // END - if // Neutral email address is default - $email = constant('WEBMASTER'); + $email = getConfig('WEBMASTER'); // Expiration in a nice output format // NOTE: Use $content[expiration] in your templates instead of $EXPIRATION @@ -782,25 +801,25 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { } // END - if // Load user's data - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content)."
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content)."
"); if (($UID > 0) && (is_array($content))) { // If nickname extension is installed, fetch nickname as well if (EXT_IS_ACTIVE('nickname')) { - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):NICKNAME!
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):NICKNAME!
"); // 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__); + $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__); } else { - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):NO-NICK!
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):NO-NICK!
"); /// 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__); + $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", + array(bigintval($UID)), __FUNCTION__, __LINE__); } // Fetch and merge data - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
"); $content = merge_array($content, SQL_FETCHARRAY($result)); - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
"); // Free result SQL_FREERESULT($result); @@ -816,7 +835,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { $DATA['email'] = $email; // Base directory - $basePath = sprintf("%stemplates/%s/emails/", constant('PATH'), getLanguage()); + $basePath = sprintf("%stemplates/%s/emails/", getConfig('PATH'), getLanguage()); // Check for admin/guest/member templates if (strpos($template, 'admin_') > -1) { @@ -907,7 +926,7 @@ function redirectToUrl ($URL) { // Check if http(s):// is there if ((substr($URL, 0, 7) != 'http://') && (substr($URL, 0, 8) != 'https://')) { // Make all URLs full-qualified - $URL = constant('URL') . '/' . $URL; + $URL = getConfig('URL') . '/' . $URL; } // END - if // Three different debug ways... @@ -919,7 +938,7 @@ function redirectToUrl ($URL) { $rel = ' rel="external"'; // Do we have internal or external URL? - if (substr($URL, 0, strlen(constant('URL'))) == constant('URL')) { + if (substr($URL, 0, strlen(getConfig('URL'))) == getConfig('URL')) { // Own (=internal) URL $rel = ''; } // END - if @@ -987,11 +1006,11 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true) if ($constants === true) { // BEFORE 0.2.1 : Language and data constants // WITH 0.2.1+ : Only language constants - $code = str_replace('{--','".', str_replace('--}','."', $code)); + $code = str_replace('{--', "\".getMessage('", str_replace('--}', "').\"", $code)); // BEFORE 0.2.1 : Not used // WITH 0.2.1+ : Data constants - $code = str_replace('{!','".', str_replace("!}", '."', $code)); + $code = str_replace('{!', "\".constant('", str_replace("!}", "').\"", $code)); } // END - if // Compile QUOT and other non-HTML codes @@ -1004,7 +1023,7 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true) if ($simple) $code = str_replace("'", '{QUOT}', $code); // Find $content[bla][blub] entries - preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); + preg_match_all('/\$(content|GLOBALS|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); // Are some matches found? if ((count($matches) > 0) && (count($matches[0]) > 0)) { @@ -1020,35 +1039,50 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true) $test = substr($found, 0, strlen($match)); // Does this entry exist? - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):found={$found},match={$match},set={$set}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):found={$found},match={$match},set={$set}
"); if ($test == $match) { // Match found! - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):fuzzyFound!
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):fuzzyFound!
"); $fuzzyFound = true; break; } // END - if } // END - foreach // Skip this entry? - if ($fuzzyFound) continue; + if ($fuzzyFound === true) continue; // Take all string elements if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) { // Replace it in the code - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):key={$key},match={$match}
\n"; - $newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match); + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):key={$key},match={$match}
"); + $newMatch = str_replace('[', "['", str_replace(']', "']", $match)); $code = str_replace($match, "\"." . $newMatch.".\"", $code); - $matchesFound[$key."_" . $matches[4][$key]] = 1; + $matchesFound[$key . '_' . $matches[4][$key]] = 1; $matchesFound[$match] = 1; } elseif (!isset($matchesFound[$match])) { // Not yet replaced! - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):match={$match}
\n"; + //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):match={$match}
"); $code = str_replace($match, "\"." . $match.".\"", $code); $matchesFound[$match] = 1; } } // END - foreach } // END - if + // Compile {?some_var?} to getConfig('some_var') + preg_match_all('/\{\?(([a-zA-Z0-9-_]+)*)\?\}/', $code, $matches); + + // Some entries found? + if ((count($matches) > 0) && (count($matches[0]) > 0)) { + // Replace all matches + foreach ($matches[0] as $key => $match) { + // Replace it + //* DEBUG: */ if ($key == 0) { print '
'; debug_print_backtrace(); print '
'; } + //* DEBUG: */ print htmlentities($match).'['.strlen($match).']='.$matches[1][$key].'='.getConfig($matches[1][$key]).' (key='.$key.',len='.strlen($code).')
'; + $code = str_replace($match, getConfig($matches[1][$key]), $code); + //* DEBUG: */ if (($match == '{?URL?}') && (strlen($code) > 10000)) die('
'.htmlentities($code).'
'); + } // END - foreach + } // END - if + // Return compiled code return $code; } @@ -1223,18 +1257,14 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') { // Optional : $DATA // function generateRandomCode ($length, $code, $uid, $DATA = '') { - // Fix missing _MAX constant - // @TODO Rewrite this unnice code - if (!defined('_MAX')) define('_MAX', 15235); - // Build server string - $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(constant('PATH').'inc/databases.php'); + $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(getConfig('PATH').'inc/databases.php'); // Build key string $keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY'); if (isConfigEntrySet('secret_key')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key'); if (isConfigEntrySet('file_hash')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash'); - $keys .= getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime'))); + $keys .= getConfig('ENCRYPT_SEPERATOR') . date("d-m-Y (l-F-T)", getConfig('patch_ctime')); if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt'); // Build string from misc data @@ -1255,13 +1285,13 @@ function generateRandomCode ($length, $code, $uid, $DATA = '') { $saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR') . $server.getConfig('ENCRYPT_SEPERATOR') . $keys.getConfig('ENCRYPT_SEPERATOR') . $data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR') . $a, getConfig('master_salt')); // Create number from hash - $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi(); + $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(getConfig('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi(); } else { // Generate hash with "hash of site key" from modula of number with the prime number and other data $saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR') . $server.getConfig('ENCRYPT_SEPERATOR') . $keys.getConfig('ENCRYPT_SEPERATOR') . $data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR') . $a, substr(sha1(getConfig('SITE_KEY')), 0, 8)); // Create number from hash - $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi(); + $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getConfig('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi(); } // At least 10 numbers shall be secure enought! @@ -1286,9 +1316,9 @@ function bigintval ($num, $castValue = true) { // Has the whole value changed? // @TODO Remove this if() block if all is working fine - if ("" . $ret."" != '' . $num."") { + if ('' . $ret . '' != '' . $num . '') { // Log the values - debug_report_bug("{$ret}<>{$num}"); + //debug_report_bug("{$ret}<>{$num}"); } // END - if // Return result @@ -1302,11 +1332,11 @@ function GENERATE_IMAGE ($img_code, $headerSent=true) { return; } elseif (!$headerSent) { // Return in an HTML code code - return "\"Image\"\n"; + return "\"Image\"\n"; } // Load image - $img = sprintf("%s/theme/%s/images/code_bg.%s", constant('PATH'), getCurrentTheme(), getConfig('img_type')); + $img = sprintf("%s/theme/%s/images/code_bg.%s", getConfig('PATH'), getCurrentTheme(), getConfig('img_type')); if (isFileReadable($img)) { // Switch image type switch (getConfig('img_type')) @@ -1362,25 +1392,25 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = // First of all years... $Y = abs(floor($timestamp / (31536000 + $SWITCH))); - //* DEBUG: */ print("Y={$Y}
\n"); + //* DEBUG: */ print("Y={$Y}
"); // Next months... $M = abs(floor($timestamp / 2628000 - $Y * 12)); - //* DEBUG: */ print("M={$M}
\n"); + //* DEBUG: */ print("M={$M}
"); // Next weeks $W = abs(floor($timestamp / 604800 - $Y * ((365 + $SWITCH / getConfig('one_day')) / 7) - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) / 7))); - //* DEBUG: */ print("W={$W}
\n"); + //* DEBUG: */ print("W={$W}
"); // Next days... $D = abs(floor($timestamp / 86400 - $Y * (365 + $SWITCH / getConfig('one_day')) - ($M / 12 * (365 + $SWITCH / getConfig('one_day'))) - $W * 7)); - //* DEBUG: */ print("D={$D}
\n"); + //* DEBUG: */ print("D={$D}
"); // Next hours... $h = abs(floor($timestamp / 3600 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24) - $W * 7 * 24 - $D * 24)); - //* DEBUG: */ print("h={$h}
\n"); + //* DEBUG: */ print("h={$h}
"); // Next minutes.. $m = abs(floor($timestamp / 60 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 60 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 60) - $W * 7 * 24 * 60 - $D * 24 * 60 - $h * 60)); - //* DEBUG: */ print("m={$m}
\n"); + //* DEBUG: */ print("m={$m}
"); // And at last seconds... $s = abs(floor($timestamp - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600) - $W * 7 * 24 * 3600 - $D * 24 * 3600 - $h * 3600 - $m * 60)); - //* DEBUG: */ print("s={$s}
\n"); + //* DEBUG: */ print("s={$s}
"); // Is seconds zero and time is < 60 seconds? if (($s == 0) && ($timestamp < 60)) { @@ -1412,7 +1442,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = $OUT .= "
{--_YEARS--}\n"; } - if (ereg("M", $display) || (empty($display))) { + if (ereg('M', $display) || (empty($display))) { $OUT .= "
{--_MONTHS--}\n"; } @@ -1452,7 +1482,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = $OUT .= "\n"; } - if (ereg("M", $display) || (empty($display))) { + if (ereg('M', $display) || (empty($display))) { // Generate month selection $OUT .= "