From: Roland Häder Date: Mon, 5 Aug 2013 20:18:58 +0000 (+0000) Subject: Some cleanups/improvements X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a00ad7dd8c36a5322e28f38d8d641efb90c00c92;p=mailer.git Some cleanups/improvements --- diff --git a/inc/functions.php b/inc/functions.php index 983af617ef..f7c2247656 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -104,8 +104,9 @@ function generatePassword ($length = '0', $exclude = array()) { } // END - while /* - * When the size is below 40 we can also add additional security by - * scrambling it. Otherwise the hash may corrupted.. + * When the length of the password is below 40 characters additional + * security can be added by scrambling it. Otherwise the hash may + * corrupted. */ if (strlen($password) <= 40) { // Also scramble the password @@ -181,10 +182,15 @@ function translateYesNo ($yn) { // Default $GLOBALS[__FUNCTION__][$yn] = '??? (' . $yn . ')'; switch ($yn) { - case 'Y': $GLOBALS[__FUNCTION__][$yn] = '{--YES--}'; break; - case 'N': $GLOBALS[__FUNCTION__][$yn] = '{--NO--}'; break; - default: - // Log unknown value + case 'Y': // Yes + $GLOBALS[__FUNCTION__][$yn] = '{--YES--}'; + break; + + case 'N': // No + $GLOBALS[__FUNCTION__][$yn] = '{--NO--}'; + break; + + default: // Log unknown value logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown value %s. Expected: Y/N', $yn)); break; } // END - switch @@ -201,10 +207,15 @@ function translateActivationStatus ($status) { // Default $GLOBALS[__FUNCTION__][$status] = '??? (' . $status . ')'; switch ($status) { - case 'Y': $GLOBALS[__FUNCTION__][$status] = '{--ACTIVATED--}'; break; - case 'N': $GLOBALS[__FUNCTION__][$status] = '{--DEACTIVATED--}'; break; - default: - // Log unknown value + case 'Y': // Activated + $GLOBALS[__FUNCTION__][$status] = '{--ACTIVATED--}'; + break; + + case 'N': // Deactivated + $GLOBALS[__FUNCTION__][$status] = '{--DEACTIVATED--}'; + break; + + default: // Log unknown value logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown value %s. Expected: Y/N', $status)); break; } // END - switch @@ -377,7 +388,7 @@ function generateDereferrerUrl ($url) { // Generates an URL for the frametester function generateFrametesterUrl ($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)) ); @@ -618,13 +629,16 @@ function bigintval ($num, $castValue = TRUE, $abortOnMismatch = TRUE) { // Creates a Uni* timestamp from given selection data and prefix function createEpocheTimeFromSelections ($prefix, $postData) { + // Assert on typical array element (maybe all?) + assert(isset($postData[$prefix . '_ye'])); + // Initial return value $ret = '0'; // Is there a leap year? $SWITCH = '0'; - $TEST = getYear() / 4; - $M1 = getMonth(); + $TEST = getYear() / 4; + $M1 = getMonth(); // If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day) // 01 2 2 1 1 1 123 4 43 3 32 233 4 43 3 3210 @@ -708,7 +722,7 @@ function isEmailValid ($email) { // Return check result //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'email=' . $email . ',isValid=' . intval($GLOBALS[__FUNCTION__][$email]) . ' - EXIT!'); - return $GLOBALS[__FUNCTION__][$email];; + return $GLOBALS[__FUNCTION__][$email]; } // Function taken from user comments on www.php.net / function isInStringIgnoreCase() @@ -831,10 +845,8 @@ function scrambleString ($str) { $scrambleNums = explode(':', genScrambleString(strlen($str))); } - // Compare both lengths and abort if different - if (strlen($str) != count($scrambleNums)) { - return $str; - } // END - if + // Assert on both lengths + assert(strlen($str) == count($scrambleNums)); // Scramble string here //* DEBUG: */ debugOutput('***Original=' . $str.'***
'); @@ -900,6 +912,8 @@ function genScrambleString ($len) { // So let's create the string for storing it in database $scrambleString = implode(':', $scrambleNumbers); + + // Return it return $scrambleString; } @@ -928,6 +942,7 @@ function encodeHashForCookie ($passHash) { // Default is hexadecimal of index if both are same $mod = dechex($idx); + // Is part1 larger or part2 than its counter part? if ($part1 > $part2) { // part1 is larger diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php index c9657b6ad8..fc188c5f11 100644 --- a/inc/modules/admin/what-admins_mails.php +++ b/inc/modules/admin/what-admins_mails.php @@ -85,7 +85,7 @@ if (isFormSent('edit')) { // Prepare content $content['id'] = $id; $content['mail_template'] = $template; - $content['admins'] = generateOptions('admins', 'id', 'login', '', 'email');; + $content['admins'] = generateOptions('admins', 'id', 'login', '', 'email'); if (isValidId($adminId2)) { // Add form for an additional admin diff --git a/inc/modules/admin/what-surfbar_stats.php b/inc/modules/admin/what-surfbar_stats.php index a60aee9bd4..a53e511c3d 100644 --- a/inc/modules/admin/what-surfbar_stats.php +++ b/inc/modules/admin/what-surfbar_stats.php @@ -71,7 +71,7 @@ ORDER BY // Load row template $OUT .= loadTemplate('admin_surfbar_url_stats_row', TRUE, $content); - $count++;; + $count++; } // END - while // Prepare content