From: quix0r Date: Sun, 25 Nov 2012 12:39:58 +0000 (+0000) Subject: Some improvements: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=03ef277b4c79d18b534b5e790cce9c8fb8018add;p=mailer.git Some improvements: - Used empty() instead of checking strlen() is zero or larger zero - Used str_pad() instead of other code --- diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 140b809cc9..26e1520bf7 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -365,8 +365,7 @@ INDEX `userid` (`userid`)", case '0.5.6': // SQL queries for v0.5.6 // Get current month - $curr = getMonth(); - if (strlen($curr) == 1) $curr = '0' . $curr; + $curr = str_pad(getMonth(), 2, '0', STR_PAD_LEFT); if ($curr == '00') $curr = '12'; // Generate timemark... diff --git a/inc/functions.php b/inc/functions.php index ab8907f080..4ff81b5d8d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -648,7 +648,7 @@ function createFancyTime ($stamp) { } // END - foreach // Is something there? - if (strlen($ret) > 0) { + if (!empty($ret)) { // Remove leading commata and space $ret = substr($ret, 2); } else { @@ -799,7 +799,9 @@ function scrambleString ($str) { } // Compare both lengths and abort if different - if (strlen($str) != count($scrambleNums)) return $str; + if (strlen($str) != count($scrambleNums)) { + return $str; + } // END - if // Scramble string here //* DEBUG: */ debugOutput('***Original=' . $str.'***
'); @@ -904,7 +906,7 @@ function encodeHashForCookie ($passHash) { $mod = substr($mod, 0, 2); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')'); - $mod = str_repeat('0', (2 - strlen($mod))) . $mod; + $mod = str_pad($mod, 2, '0', STR_PAD_LEFT); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*'); $start += 2; $newHash .= $mod; diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php index ad47803a44..1eb7c9ca10 100644 --- a/inc/modules/admin/what-list_beg.php +++ b/inc/modules/admin/what-list_beg.php @@ -47,8 +47,7 @@ if (isBegRallyeEnabled()) { // Shall I withdraw now? if (isPostRequestElementSet('withdraw')) { // Okay, let's prepare... - $curr = getMonth() - 1; - if (strlen($curr) == 1) $curr = '0' . $curr; + $curr = str_pad((getMonth() - 1), 2, '0', STR_PAD_LEFT); updateConfiguration('last_month', $curr); displayMessage('{--ADMIN_BEG_WITHDRAW_PREPARED--}'); } // END - if diff --git a/inc/modules/admin/what-list_bonus.php b/inc/modules/admin/what-list_bonus.php index 70c57a3a5e..78e687de93 100644 --- a/inc/modules/admin/what-list_bonus.php +++ b/inc/modules/admin/what-list_bonus.php @@ -47,8 +47,7 @@ if (isBonusRallyeActive()) { // Shall I withdraw now? if (isPostRequestElementSet('withdraw')) { // Okay, let's prepare... - $curr = getMonth() - 1; - if (strlen($curr) == 1) $curr = '0' . $curr; + $curr = str_pad((getMonth() - 1), 2, '0', STR_PAD_LEFT); updateConfiguration('last_month', $curr); displayMessage('{--ADMIN_BONUS_WITHDRAW_PREPARED--}'); } // END - if diff --git a/inc/modules/member/what-mydata.php b/inc/modules/member/what-mydata.php index 92371167db..168fcacc7f 100644 --- a/inc/modules/member/what-mydata.php +++ b/inc/modules/member/what-mydata.php @@ -79,8 +79,8 @@ switch ($mode) { $content['change'] = loadTemplate('member_mydata_button', TRUE); } - if (strlen($content['birth_day']) == 1) $content['birth_day'] = '0' . $content['birth_day']; - if (strlen($content['birth_month']) == 1) $content['birth_month'] = '0' . $content['birth_month']; + $content['birth_day'] = str_pad($content['birth_day'] , 2, '0', STR_PAD_LEFT); + $content['birth_month'] = str_pad($content['birth_month'], 2, '0', STR_PAD_LEFT); switch (getLanguage()) { case 'de': $content['dob'] = $content['birth_day'] . '.' . $content['birth_month'] . '.' . $content['birth_year']; break; diff --git a/inc/xml-functions.php b/inc/xml-functions.php index ff62e48d5d..e180a49fe9 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -232,7 +232,7 @@ function xmlCharacterHandler ($resource, $characters) { $characters = trim($characters); // Are there some to handle? - if (strlen($characters) == 0) { + if (empty($characters)) { // Nothing to handle return; } // END - if diff --git a/mailid_top.php b/mailid_top.php index 214a125218..87db810c76 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -371,7 +371,6 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr $content['userid'] = $userId; $content['type'] = $type; $content['data'] = $urlId; - $content['rand'] = getRandomTan(); $content['banner'] = loadTemplate('mailid_banner', TRUE); // Load template diff --git a/templates/de/html/mailid/mailid_timer.tpl b/templates/de/html/mailid/mailid_timer.tpl index 51417150e2..7a8558a175 100644 --- a/templates/de/html/mailid/mailid_timer.tpl +++ b/templates/de/html/mailid/mailid_timer.tpl @@ -15,7 +15,7 @@ function startCounter() { document.confirm.counter.value = timer; if (timer == 0) { clearInterval(Counter); - document.location.href = '{%url,js=mailid_top.php?userid=$content[userid]&$content[type]=$content[data]&do=confirm&code=$content[rand]%}'; + document.location.href = '{%url,js=mailid_top.php?userid=$content[userid]&$content[type]=$content[data]&do=confirm&code={%pipe,getRandomTan%}%}'; } } //-->