]> git.mxchange.org Git - mailer.git/commitdiff
More EL code, security for $_POST elements rewritten (simplified):
authorRoland Häder <roland@mxchange.org>
Tue, 28 Jun 2011 09:00:38 +0000 (09:00 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 28 Jun 2011 09:00:38 +0000 (09:00 +0000)
- More usage of EL code
- Removed double secureString() call
- Non-array elements in $_POST are now also secured in
  inc/libs/security_functions.php
- Renamed more array elements for better naming consistancy
- TODOs.txt updated

23 files changed:
DOCS/TODOs.txt
inc/libs/security_functions.php
inc/libs/sponsor_functions.php
inc/libs/theme_functions.php
inc/modules/admin.php
inc/modules/admin/what-config_points.php
inc/modules/admin/what-del_sponsor.php
inc/modules/admin/what-edit_sponsor.php
inc/modules/admin/what-lock_sponsor.php
inc/modules/admin/what-user_contct.php
inc/modules/guest/what-sponsor_reg.php
inc/modules/member/what-beg2.php
inc/modules/member/what-holiday.php
inc/modules/member/what-transfer.php
inc/monthly/monthly_beg.php
inc/request-functions.php
inc/session-functions.php
inc/stylesheet.php
templates/de/emails/admin/admin_transfer_points.tpl
templates/de/emails/member/member_beg.tpl
templates/de/emails/member/member_transfer_recipient.tpl
templates/de/emails/member/member_transfer_sender.tpl
templates/de/html/member/member_list_beg_row.tpl

index bb04566458374327e6b9ebb496d3ee6f0dff35e0..8102d8aca66ce39ec4c73814a1e35a2430e7ba79 100644 (file)
 ./inc/modules/admin/what-config_admins.php:108:        // @TODO Rewrite this to a filter
 ./inc/modules/admin/what-config_admins.php:136:        // @TODO Rewrite this to filter 'run_sqls'
 ./inc/modules/admin/what-config_mods.php:55:                   // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function
-./inc/modules/admin/what-config_points.php:111:                        // @TODO Rewrite this to a filter
+./inc/modules/admin/what-config_points.php:110:                        // @TODO Rewrite this to a filter
 ./inc/modules/admin/what-config_rallye_prices.php:195:                 // @TODO Rewrite these two constants
 ./inc/modules/admin/what-config_register.php:75:       // @TODO Move this HTML code into a template
 ./inc/modules/admin/what-del_email.php:61:             // @TODO Unused: cat_id, payment_id
 ./inc/modules/guest/what-sponsor_reg.php:287:                  // @TODO Maybe a default referal id?
 ./inc/modules/guest/what-stats.php:100:                // @TODO This can be somehow rewritten
 ./inc/modules/guest/what-stats.php:74:// @TODO This can be rewritten in a dynamic include
-./inc/modules/member/what-beg2.php:87:         // @TODO points->beg_points
 ./inc/modules/member/what-beg.php:54:// @TODO Can't this be moved into EL?
 ./inc/modules/member/what-beg.php:63:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getBegUseridTimeout()));
 ./inc/modules/member/what-bonus.php:55:        // @TODO Rewrite this to a filter
 ./inc/modules/member/what-refback.php:124:                     // @TODO UNUSED: $refRow['status']      = translateUserStatus($refRow['status']);
 ./inc/modules/member/what-reflinks.php:52:// @TODO Move this into a filter
 ./inc/modules/member/what-transfer.php:134:                            // @TODO Rewrite this to a filter
-./inc/modules/member/what-transfer.php:224:                            // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
+./inc/modules/member/what-transfer.php:223:                            // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
 ./inc/modules/member/what-transfer.php:96:                     // @TODO Rewrite this to a filter
 ./inc/modules/member/what-unconfirmed.php:142: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
 ./inc/modules/member/what-unconfirmed.php:207:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
index 2b41ab968c41922a2c72966aba5193602ea8d7f6..df3d5686b041a2c92d12329778be45f75d188291 100644 (file)
@@ -212,6 +212,18 @@ if (is_array($_GET)) {
        } // END - foreach
 } // END - if
 
+// Secure also $_POST data (only simple, no replace)
+if (is_array($_POST)) {
+       // Secure only simple data
+       foreach ($_POST as $seckey => $secvalue) {
+               // Is it an array?
+               if (!is_array($secvalue)) {
+                       // Strip all other out
+                       $_POST[$seckey] = secureString($_POST[$seckey]);
+               } // END - if
+       } // END - foreach
+} // END - if
+
 // Detect PHP caching
 detectPhpCaching();
 
index 6135e9108d9d2fdc4b0d6960d8b81442e72057de..814a19b26036677d99e2e4e31ffd380fceb035dd 100644 (file)
@@ -574,11 +574,11 @@ function doProcessSponsorFormRequest ($messageArray = array()) {
                                // Prepare data for the email template
                                $content['id']        = $id;
                                $content['hash']      = $hash;
-                               $content['email']     = secureString(postRequestParameter('email'));
-                               $content['surname']   = secureString(postRequestParameter('surname'));
-                               $content['family']    = secureString(postRequestParameter('family'));
+                               $content['email']     = postRequestParameter('email');
+                               $content['surname']   = postRequestParameter('surname');
+                               $content['family']    = postRequestParameter('family');
                                $content['timestamp'] = generateDateTime(time(), 0);
-                               $content['password']  = secureString(postRequestParameter('pass1'));
+                               $content['password']  = postRequestParameter('pass1');
 
                                // Generate email and send it to the new sponsor
                                $message = loadEmailTemplate('sponsor_confirm', $content, $id);
index 976d45acc50f6eb6367212a7231f1f40dfd39550..58d1fec2c24e0f9c9180e0dcf84dd6abeced686a 100644 (file)
@@ -248,9 +248,9 @@ function getActualTheme () {
                if ((isGetRequestParameterSet('theme')) && (isIncludeReadable($theme))) {
                        // Set cookie from URL data
                        setTheme(getRequestParameter('theme'));
-               } elseif (isIncludeReadable(sprintf("theme/%s/theme.php", secureString(postRequestParameter('theme'))))) {
+               } elseif (isIncludeReadable(sprintf("theme/%s/theme.php", postRequestParameter('theme')))) {
                        // Set cookie from posted data
-                       setTheme(secureString(postRequestParameter('theme')));
+                       setTheme(postRequestParameter('theme'));
                }
 
                // Set return value
index 572888450ffb638c05c6e4ca6cd53ec2a0d5ff1f..f0c295eb5fd91bf084153fc9bfddfc7ee84bdca9 100644 (file)
@@ -194,8 +194,8 @@ if (!isAdminRegistered()) {
                if ($valid === true) {
                        // Prepare content first
                        $content = array(
-                               'hash'  => secureString(postRequestParameter('hash')),
-                               'login' => secureString(postRequestParameter('login'))
+                               'hash'  => postRequestParameter('hash'),
+                               'login' => postRequestParameter('login')
                        );
 
                        // Validation okay so display form for final password change
index 3ef48975ae67b96791e23fad8a030e22c7739790..a9cab39d96eed67c222f14cb7690cfb0b42b9e23 100644 (file)
@@ -77,10 +77,9 @@ if (isFormSent()) {
                        break;
 
                case 'ref':
-                       switch (getRequestParameter('do'))
-                       {
+                       switch (getRequestParameter('do')) {
                                case 'add':
-                                       addSql("INSERT INTO `{?_MYSQL_PREFIX?}_refdepths` (`level`, `percents`) VALUES ('".postRequestParameter('level')."','".postRequestParameter('percents')."')");
+                                       addSql("INSERT INTO `{?_MYSQL_PREFIX?}_refdepths` (`level`, `percents`) VALUES ('".bigintval(postRequestParameter('level'))."','".bigintval(postRequestParameter('percents'))."')");
                                        break;
 
                                case 'edit': // Change entries
@@ -94,7 +93,7 @@ if (isFormSent()) {
                                                // Update entry
                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refdepths` SET `level`=%s, `percents`=%s WHERE `id`=%s LIMIT 1",
                                                        array(bigintval($value), convertCommaToDot(postRequestParameter('percents', $id)), $id), __FILE__, __LINE__);
-                                       }
+                                       } // END - foreach
                                        $message = '{--ADMIN_REFERAL_DEPTHS_SAVED--}';
                                        break;
 
@@ -102,10 +101,10 @@ if (isFormSent()) {
                                        foreach (postRequestParameter('id') as $id => $value) {
                                                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
                                                array(bigintval($id)), __FILE__, __LINE__);
-                                       }
+                                       } // END - foreach
                                        $message = '{--ADMIN_REFERAL_DEPTHS_DELETED--}';
                                        break;
-                       }
+                       } // END - switch
 
                        // Update cache file
                        // @TODO Rewrite this to a filter
index 25521563b1530e1800c639e8251eb49886a9013c..14035c960a5154ca84441900bb87129fceacba0a 100644 (file)
@@ -54,7 +54,7 @@ if (isGetRequestParameterSet('id')) {
                        $content = SQL_FETCHARRAY($result);
 
                        // Prepare data for the template
-                       $content['reason']  = secureString(postRequestParameter('reason'));
+                       $content['reason']  = postRequestParameter('reason');
 
                        // Prepare message and send it away
                        $message = loadEmailTemplate('del_sponsor', $content, bigintval(getRequestParameter('id')));
index 27b3978a2112c8bc9a38ed928e0b70cc22ce8db5..d22020fcbeda8c6e96723c39f620e520df7704f6 100644 (file)
@@ -83,7 +83,7 @@ LIMIT 1",
 
                                                // Remember points /reason for the template
                                                $content['points'] = $points;
-                                               $content['reason'] = secureString(postRequestParameter('reason'));
+                                               $content['reason'] = postRequestParameter('reason');
 
                                                // Send email
                                                $message = loadEmailTemplate('sponsor_add_points', $content);
@@ -106,7 +106,7 @@ LIMIT 1",
 
                                                // Remember points /reason for the template
                                                $content['points'] = $points;
-                                               $content['reason'] = secureString(postRequestParameter('reason'));
+                                               $content['reason'] = postRequestParameter('reason');
 
                                                // Send email
                                                $message = loadEmailTemplate('sponsor_sub_points', $content);
index 00b2e2560a6390870392c168ae4a8976660432cc..ed5d9ea4b51cb8c2272d8e1a111b86fed40e5fd8 100644 (file)
@@ -55,7 +55,7 @@ if (isGetRequestParameterSet('id')) {
                if (($content['status'] == 'CONFIRMED') || ($content['status'] == 'LOCKED')) {
                        // Transfer data to constants
                        $content['id']     = bigintval(getRequestParameter('id'));
-                       $content['reason'] = secureString(postRequestParameter('reason'));
+                       $content['reason'] = postRequestParameter('reason');
 
                        if (isFormSent()) {
                                // Create messages
index ac51462b020053567244723260ebf75c64ecd229..36c68abe8c0f01e7d669f83025ac137366e975e0 100644 (file)
@@ -56,7 +56,7 @@ if ((isGetRequestParameterSet('userid')) && (bigintval(getRequestParameter('user
                // Shall we send the email?
                if (isFormSent()) {
                        // Insert text
-                       $content['text'] = trim(secureString(postRequestParameter('text')));
+                       $content['text'] = postRequestParameter('text');
 
                        // Load email template
                        $message = loadEmailTemplate('member_contct', $content, getRequestParameter('userid'));
index 3d0a93547e41f7f4493b25ceeb04d53dedf1c7ef..9dd8629eb339a35435bfdea5f4c7b51173254b96 100644 (file)
@@ -260,7 +260,7 @@ ORDER BY
                if (count($formErrors) > 0) {
                        // Some found... :-(
                        foreach (array('company','position','tax_ident','surname','family','street_nr1','street_nr2','country','zip','city','phone','fax','cell','email','url') as $entry) {
-                               $content[$entry]    = secureString(postRequestParameter($entry));
+                               $content[$entry]    = postRequestParameter($entry);
                        } // END - foreach
 
                        // Init receive selection
index 25b5bdce5577eb930160866f9f3bf756ceca9bb0..30ff574716be4f119a1e904f4b8fc1ba4fdeac20 100644 (file)
@@ -84,13 +84,8 @@ if (!SQL_HASZERONUMS($result)) {
        $count = 1;
        while ($content = SQL_FETCHARRAY($result)) {
                // Prepare data for the template
-               // @TODO points->beg_points
-               $content = array(
-                       'cnt'         => $count,
-                       'userid'      => $content['userid'],
-                       'points'      => $content['beg_points'],
-                       'last_online' => generateDateTime($content['last_online'], 2),
-               );
+               $content['cnt']         = $count;
+               $content['last_online'] = generateDateTime($content['last_online'], 2);
 
                // Load row template
                $OUT .= loadTemplate('member_list_beg_row', true, $content);
@@ -99,7 +94,7 @@ if (!SQL_HASZERONUMS($result)) {
                $count++;
        } // END - while
 } else {
-       // No one is interested in our "active rallye" ! :-(
+       // No one is interested in our "begging rallye" ! :-(
        $OUT = loadTemplate('member_beg_404', true);
 }
 
index 10c76eea900da06e9b223b983bca4cafac7010b6..46baf1cd6406586921385c357f5bc8d99173ba7f 100644 (file)
@@ -139,7 +139,7 @@ LIMIT 1",
                $content['end_day']     = bigintval(postRequestParameter('end_day'));
                $content['end_month']   = $GLOBALS['month_descr'][postRequestParameter('end_month')];
                $content['end_year']    = bigintval(postRequestParameter('end_year'));
-               $content['comments']    = secureString(postRequestParameter('comments'));
+               $content['comments']    = postRequestParameter('comments');
 
                // Send mail to member
                $message = loadEmailTemplate('member_holiday_request', $content, getMemberId());
index e9e78c92b8ebdc13bada46f49120d7ea1c1f4fe1..cf6fec76cfa512bc46b1a8b9491cee4e4121fde4 100644 (file)
@@ -142,9 +142,8 @@ switch ($mode) {
                                        } // END - if
                                } // END - if
 
-                               // Remember transfer reason and fancy date/time in constants
-                               $content['reason']  = secureString(postRequestParameter('reason'));
-                               $content['expires'] = '{%config,createFancyTime=transfer_age%}';
+                               // Remember transfer reason
+                               $content['reason']  = postRequestParameter('reason');
 
                                // Generate tranafer id
                                $content['trans_id'] = bigintval(generateRandomCode('10', mt_rand(0, 99999), getMemberId(), postRequestParameter('reason')));
index 232bee7b0e91083fa2ee255dfd17b4c0f439a94b..c1effc065c918e777e5a0581d5dee514865a223c 100644 (file)
@@ -71,7 +71,7 @@ if ((getBegRanks() > 0) && (!isCssOutputMode())) {
 
        // SQL string to check for accounts
        $result_main = SQL_QUERY("SELECT
-       `userid`, `email`, `gender`, `surname`, `family`, `beg_points` AS `points`
+       `userid`, `email`, `gender`, `surname`, `family`, `beg_points`
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
@@ -86,7 +86,7 @@ LIMIT {?beg_ranks?}", __FILE__, __LINE__);
                // Load our winners...
                while ($content = SQL_FETCHARRAY($result_main)) {
                        // Add points to user's account directly
-                       addPointsDirectly('monthly_beg', $content['userid'], $content['points']);
+                       addPointsDirectly('monthly_beg', $content['userid'], $content['beg_points']);
 
                        // Load email template and email it away
                        $message = loadEmailTemplate('member_beg', $content, bigintval($content['userid']));
index ee70e614020d7d2810a1819d4b6c9d230934aad5..799d4e38dd120a16452d7442adbb2984618b50cb 100644 (file)
@@ -52,15 +52,15 @@ function getRequestParameter ($element) {
        $value = null;
 
        // Is the element cached or there?
-       if (isset($GLOBALS['cache_request']['request_get'][$element])) {
+       if (isset($GLOBALS['cache_request']['get'][$element])) {
                // Then use the cache
-               $value = $GLOBALS['cache_request']['request_get'][$element];
+               $value = $GLOBALS['cache_request']['get'][$element];
        } elseif (isGetRequestParameterSet($element)) {
                // Then get it directly
                $value = SQL_ESCAPE($GLOBALS['raw_request']['get'][$element]);
 
                // Store it in cache
-               $GLOBALS['cache_request']['request_get'][$element] = $value;
+               $GLOBALS['cache_request']['get'][$element] = $value;
        } // END - if
 
        // Return value
@@ -113,7 +113,7 @@ function setGetRequestParameter ($element, $value) {
        $GLOBALS['raw_request']['get'][$element] = $value;
 
        // Update cache
-       $GLOBALS['cache_request']['request_get'][$element] = $value;
+       $GLOBALS['cache_request']['get'][$element] = $value;
 }
 
 // Wrapper for elements in $_POST
@@ -122,9 +122,9 @@ function postRequestParameter ($element, $subElement=null) {
        $value = null;
 
        // Is the element in cache?
-       if (isset($GLOBALS['cache_request']['request_post'][$element][$subElement])) {
+       if (isset($GLOBALS['cache_request']['post'][$element][$subElement])) {
                // Then use it
-               $value = $GLOBALS['cache_request']['request_post'][$element][$subElement];
+               $value = $GLOBALS['cache_request']['post'][$element][$subElement];
        } elseif (isPostRequestParameterSet($element)) {
                // Then use it
                $value = $GLOBALS['raw_request']['post'][$element];
@@ -139,7 +139,7 @@ function postRequestParameter ($element, $subElement=null) {
                }
 
                // Set it in cache
-               $GLOBALS['cache_request']['request_post'][$element][$subElement] = $value;
+               $GLOBALS['cache_request']['post'][$element][$subElement] = $value;
        } // END - if
 
        // Return value
@@ -218,7 +218,7 @@ function setPostRequestParameter ($element, $value) {
        }
 
        // Update cache
-       $GLOBALS['cache_request']['request_post'][$element][null] = $value;
+       $GLOBALS['cache_request']['post'][$element][null] = $value;
 }
 
 // Checks wether a form was sent. If so, the $_POST['ok'] element must be set
index 7bfb18c901742d31e4ddaf75580f42f3581bfdb3..f71f3e0796ce397b09ea685421ea66499b052321 100644 (file)
@@ -46,7 +46,8 @@ function setSession ($var, $value) {
        if (isCssOutputMode()) return true;
 
        // Trim value and session variable
-       $var = trim(secureString($var)); $value = trim($value);
+       $var   = trim(secureString($var));
+       $value = trim($value);
 
        // Is the session variable set?
        if (('' . $value . '' == '') && (isSessionVariableSet($var))) {
index 7cd2a38cf4d105ed69964e001fe0781b1813b130..81ee2dca3e8e9eff0c552a2f86a390a2de2663b9 100644 (file)
@@ -109,8 +109,11 @@ if ((isCssOutputMode()) || (getConfig('css_php') == 'DIRECT')) {
        if ((isInstallationPhase())) {
                // Default theme first
                $newTheme = 'default';
-               if (isGetRequestParameterSet('theme'))  $newTheme = getRequestParameter('theme');
-               if (isPostRequestParameterSet('theme')) $newTheme = secureString(postRequestParameter('theme'));
+               if (isPostRequestParameterSet('theme')) {
+                       $newTheme = postRequestParameter('theme');
+               } elseif (isGetRequestParameterSet('theme')) {
+                       $newTheme = getRequestParameter('theme');
+               }
                $OUT .= '?theme=' . $newTheme . '&amp;installing=1';
        } else {
                // Add SVN revision to bypass caching problems
index 0529f02805ee9a859aaa54fee933f308aca0ddce..eba85cf5af615330cb2fda340e1a63750fcbe620 100644 (file)
@@ -24,7 +24,7 @@ Verwendungszweck: $content[reason]
 Transaktionsnummer: $content[trans_id]
 ------------------------------
 
-Diese beiden Mitglieder k&ouml;nnen sich die &Uuml;berweisung noch $content[expires] in ihrem Mitgliedsbereich ansehen. Danach wird der Eintrag bei installierter autopurge-Erweiterung automatisch entfernt.
+Diese beiden Mitglieder k&ouml;nnen sich die &Uuml;berweisung noch {%config,createFancyTime=transfer_age%} in ihrem Mitgliedsbereich ansehen. Danach wird der Eintrag bei installierter autopurge-Erweiterung automatisch entfernt.
 
 Mit freundlichen Gr&uuml;&szlig;en,
   Ihr {?MAIN_TITLE?} Script
index a66b7c95ee1d48d667eba1bcc7b6357fab45a6aa..5c8442d5b0dfc4a9ecc4ef3375270d96ccd56a4e 100644 (file)
@@ -1,6 +1,6 @@
 Hallo {%user,gender,translateGender=$userid%} {%user,surname=$userid%} {%user,family=$userid%},
 
-Bei der monatlichen Bettel-Rallye haben Sie soeben Ihre {%pipe,translateComma=$content[points]%} {?POINTS?} gewonnen!
+Bei der monatlichen Bettel-Rallye haben Sie soeben Ihre {%pipe,translateComma=$content[beg_points]%} {?POINTS?} gewonnen!
 
 Herzlichen Gl&uuml;ckwunsch!
 
index e2cddb8bd6049a326553c419a74c106fee771c86..eaf2f9ad13dad4636c6a07d3be318290d4741563 100644 (file)
@@ -15,7 +15,7 @@ Verwendungszweck: $content[reason]
 Transaktionsnummer: $content[trans_id]
 ------------------------------
 
-Sie k&ouml;nnen diese Transaktion $content[expires] noch im Mitgliedsbereich unter "{?POINTS?}-Transfer" nachvollziehen.
+Sie k&ouml;nnen diese Transaktion {%config,createFancyTime=transfer_age%} noch im Mitgliedsbereich unter "{?POINTS?}-Transfer" nachvollziehen.
 
 Mit freundlichen Gr&uuml;&szlig;en,
   Ihr {?MAIN_TITLE?} Team
index a0a8b0ff0947a28916e3f1857357c863e9a6ddad..b12569c5e39556cc1ce555508440351a95432c8f 100644 (file)
@@ -15,7 +15,7 @@ Verwendungszweck: $content[reason]
 Transaktionsnummer: $content[trans_id]
 ------------------------------
 
-Sie k&ouml;nnen diese Transaktion $content[expires] noch im Mitgliedsbereich unter "{?POINTS?}-Transfer" nachvollziehen.
+Sie k&ouml;nnen diese Transaktion {%config,createFancyTime=transfer_age%} noch im Mitgliedsbereich unter "{?POINTS?}-Transfer" nachvollziehen.
 
 Mit freundlichen Gr&uuml;&szlig;en,
   Ihr {?MAIN_TITLE?} Team
index 6812612af1ed8e17034c43c190f5e59273f75b39..6075586f5a4229e244f770f5f59e8c587c69df43 100644 (file)
@@ -1,6 +1,6 @@
 <tr>
        <td align="center" class="{%template,ColorSwitch%} bottom">$content[cnt]</td>
        <td align="center" class="{%template,ColorSwitch%} bottom">$content[userid]</td>
-       <td align="center" class="{%template,ColorSwitch%} bottom">{%pipe,translateComma=$content[points]%}</td>
+       <td align="center" class="{%template,ColorSwitch%} bottom">{%pipe,translateComma=$content[beg_points]%}</td>
        <td align="center" class="{%template,ColorSwitch%} bottom">$content[last_online]</td>
 </tr>