[geeklog-cvs] geeklog: Let's use count() instead of sizeof() everywhere from n...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Sep 6 10:18:02 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/cd653ce9aafb
changeset: 7292:cd653ce9aafb
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Sep 06 15:46:20 2009 +0200
description:
Let's use count() instead of sizeof() everywhere from now on

diffstat:

 public_html/admin/group.php               |   8 ++++----
 public_html/admin/plugins/polls/index.php |   6 +++---
 public_html/admin/syndication.php         |   2 +-
 public_html/admin/user.php                |   2 +-
 public_html/directory.php                 |   4 ++--
 public_html/lib-common.php                |  20 ++++++++++----------
 public_html/users.php                     |   4 ++--
 public_html/usersettings.php              |  10 +++++-----
 system/classes/downloader.class.php       |   4 ++--
 system/classes/upload.class.php           |   2 +-
 system/lib-plugins.php                    |   4 ++--
 system/lib-security.php                   |   6 +++---
 system/lib-story.php                      |   2 +-
 system/lib-user.php                       |   2 +-
 14 files changed, 38 insertions(+), 38 deletions(-)

diffs (truncated from 381 to 300 lines):

diff -r 62bd06e50034 -r cd653ce9aafb public_html/admin/group.php
--- a/public_html/admin/group.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/admin/group.php	Sun Sep 06 15:46:20 2009 +0200
@@ -307,7 +307,7 @@
             }
         }
     }
-    while (sizeof ($tocheck) > 0);
+    while (count($tocheck) > 0);
 
     // get features for all groups in $checked
     $glist = join (',', $checked);
@@ -370,7 +370,7 @@
         $indirectfeatures = explode (',', $indirectfeatures);
 
         // Build an array of indirect features
-        for ($i = 0; $i < sizeof($indirectfeatures); $i++) {
+        for ($i = 0; $i < count($indirectfeatures); $i++) {
             $grpftarray[current($indirectfeatures)] = 'indirect';
             next($indirectfeatures);
         }
@@ -387,7 +387,7 @@
         $grpftarray = array_merge ($grpftarray, $grpftarray1);
         if ($VERBOSE) {
             // this is for debugging purposes
-            for ($i = 1; $i < sizeof($grpftarray); $i++) {
+            for ($i = 1; $i < count($grpftarray); $i++) {
                 COM_errorLog("element $i is feature " . key($grpftarray) . " and is " . current($grpftarray),1);
                 next($grpftarray);
             }
@@ -621,7 +621,7 @@
 
     $checked = array ();
 
-    while (sizeof ($to_check) > 0) {
+    while (count($to_check) > 0) {
         $thisgroup = array_pop ($to_check);
         if ($thisgroup > 0) {
             $result = DB_query ("SELECT ug_grp_id FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = $thisgroup");
diff -r 62bd06e50034 -r cd653ce9aafb public_html/admin/plugins/polls/index.php
--- a/public_html/admin/plugins/polls/index.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/admin/plugins/polls/index.php	Sun Sep 06 15:46:20 2009 +0200
@@ -173,7 +173,7 @@
     }
 
     // check if any question was entered
-    if (empty($topic) or (sizeof($Q) == 0) or (strlen($Q[0]) == 0) or
+    if (empty($topic) or (count($Q) == 0) or (strlen($Q[0]) == 0) or
             (strlen($A[0][0]) == 0)) {
         $retval .= COM_siteHeader ('menu', $LANG25[5]);
         $retval .= COM_startBlock ($LANG21[32], '',
@@ -250,7 +250,7 @@
     $k = 0; // set up a counter to make sure we do assign a straight line of question id's
     $v = 0; // re-count votes sine they might have been changed
     // first dimension of array are the questions
-    $num_questions = sizeof($Q);
+    $num_questions = count($Q);
     for ($i = 0; $i < $num_questions; $i++) {
         $Q[$i] = COM_stripslashes($Q[$i]);
         if (strlen($Q[$i]) > 0) { // only insert questions that exist
@@ -259,7 +259,7 @@
                                                "'$k', '$pid', '$Q[$i]'");
             // within the questions, we have another dimensions with answers,
             // votes and remarks
-            $num_answers = sizeof($A[$i]);
+            $num_answers = count($A[$i]);
             for ($j = 0; $j < $num_answers; $j++) {
                 $A[$i][$j] = COM_stripslashes($A[$i][$j]);
                 if (strlen($A[$i][$j]) > 0) { // only insert answers etc that exist
diff -r 62bd06e50034 -r cd653ce9aafb public_html/admin/syndication.php
--- a/public_html/admin/syndication.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/admin/syndication.php	Sun Sep 06 15:46:20 2009 +0200
@@ -421,7 +421,7 @@
     $retval = '';
 
     $plugins = PLG_supportingFeeds ();
-    if (sizeof ($plugins) == 0) {
+    if (count($plugins) == 0) {
         // none of the installed plugins are supporting feeds
         // - go directly to the feed editor
         $retval = COM_siteHeader ('menu', $LANG33[11])
diff -r 62bd06e50034 -r cd653ce9aafb public_html/admin/user.php
--- a/public_html/admin/user.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/admin/user.php	Sun Sep 06 15:46:20 2009 +0200
@@ -453,7 +453,7 @@
     $userChanged = false;
 
     if ($_USER_VERBOSE) COM_errorLog("**** entering saveusers****",1);
-    if ($_USER_VERBOSE) COM_errorLog("group size at beginning = " . sizeof($groups),1);
+    if ($_USER_VERBOSE) COM_errorLog("group size at beginning = " . count($groups),1);
 
     if ($passwd != $passwd_conf) { // passwords don't match
         return edituser($uid, 67);
diff -r 62bd06e50034 -r cd653ce9aafb public_html/directory.php
--- a/public_html/directory.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/directory.php	Sun Sep 06 15:46:20 2009 +0200
@@ -284,7 +284,7 @@
             $A = DB_fetchArray ($result);
 
             if ($mday != $A['mday']) {
-                if (sizeof ($entries) > 0) {
+                if (count($entries) > 0) {
                     $retval .= COM_makeList ($entries);
                     $entries = array ();
                 }
@@ -301,7 +301,7 @@
             $entries[] = COM_createLink(stripslashes ($A['title']), $url);
         }
 
-        if (sizeof ($entries) > 0) {
+        if (count($entries) > 0) {
             $retval .= COM_makeList ($entries);
         }
 
diff -r 62bd06e50034 -r cd653ce9aafb public_html/lib-common.php
--- a/public_html/lib-common.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/lib-common.php	Sun Sep 06 15:46:20 2009 +0200
@@ -587,7 +587,7 @@
     $allowedCounter = 0;
     $counter = 0;
 
-    $num_plugins = sizeof( $plugin_menu );
+    $num_plugins = count( $plugin_menu );
     if( ( $num_plugins == 0 ) && in_array( 'plugins', $_CONF['menu_elements'] ))
     {
         $key = array_search( 'plugins', $_CONF['menu_elements'] );
@@ -601,14 +601,14 @@
         {
             $custom_entries = CUSTOM_menuEntries();
         }
-        if( sizeof( $custom_entries ) == 0 )
+        if( count( $custom_entries ) == 0 )
         {
             $key = array_search( 'custom', $_CONF['menu_elements'] );
             unset( $_CONF['menu_elements'][$key] );
         }
     }
 
-    $num_elements = sizeof( $_CONF['menu_elements'] );
+    $num_elements = count( $_CONF['menu_elements'] );
 
     foreach( $_CONF['menu_elements'] as $item )
     {
@@ -1825,7 +1825,7 @@
         {
             $retval .= '<li><input type="checkbox" name="' . $fieldname . '[]" value="' . $A[0] . '"';
 
-            $sizeS = sizeof( $S );
+            $sizeS = count( $S );
             for( $x = 0; $x < $sizeS; $x++ )
             {
                 if( $A[0] == $S[$x] )
@@ -2529,7 +2529,7 @@
                     $T = DB_fetchArray( $tresult );
                     $tids[] = $T['tid'];
                 }
-                if( sizeof( $tids ) > 0 )
+                if( count( $tids ) > 0 )
                 {
                     $topicsql = " (tid IN ('" . implode( "','", $tids ) . "'))";
                 }
@@ -3044,7 +3044,7 @@
     $str = preg_replace( '/<!--.+?-->/', '', $str );
 
     $filter = new kses4;
-    if( isset( $_CONF['allowed_protocols'] ) && is_array( $_CONF['allowed_protocols'] ) && ( sizeof( $_CONF['allowed_protocols'] ) > 0 ))
+    if( isset( $_CONF['allowed_protocols'] ) && is_array( $_CONF['allowed_protocols'] ) && ( count( $_CONF['allowed_protocols'] ) > 0 ))
     {
         $filter->SetProtocols( $_CONF['allowed_protocols'] );
     }
@@ -3554,7 +3554,7 @@
     // sort the resulting array by block order
     $column = 'blockorder';
     $sortedBlocks = $blocks;
-    $num_sortedBlocks = sizeof( $sortedBlocks );
+    $num_sortedBlocks = count( $sortedBlocks );
     for( $i = 0; $i < $num_sortedBlocks - 1; $i++ )
     {
         for( $j = 0; $j < $num_sortedBlocks - 1 - $i; $j++ )
@@ -4114,7 +4114,7 @@
             $TIDS = array_intersect( $TIDS, $ETIDS );
         }
 
-        if( sizeof( $TIDS ) > 0)
+        if( count( $TIDS ) > 0)
         {
             $commonsql .= " AND (tid IN ('" . implode( "','", $TIDS ) . "'))";
         }
@@ -4413,7 +4413,7 @@
     if( $_CONF['hidenewplugins'] == 0 )
     {
         list( $headlines, $smallheadlines, $content ) = PLG_getWhatsNew();
-        $plugins = sizeof( $headlines );
+        $plugins = count( $headlines );
         if( $plugins > 0 )
         {
             for( $i = 0; $i < $plugins; $i++ )
@@ -5582,7 +5582,7 @@
         $tids[] = $T['tid'];
     }
 
-    if( sizeof( $tids ) > 0 )
+    if( count( $tids ) > 0 )
     {
         $topicsql .= "({$table}tid IN ('" . implode( "','", $tids ) . "'))";
     }
diff -r 62bd06e50034 -r cd653ce9aafb public_html/users.php
--- a/public_html/users.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/users.php	Sun Sep 06 15:46:20 2009 +0200
@@ -208,7 +208,7 @@
     $topics = "'" . implode ("','", $tids) . "'";
 
     // list of last 10 stories by this user
-    if (sizeof ($tids) > 0) {
+    if (count($tids) > 0) {
         $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = $user) AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ($topics))" . COM_getPermSQL ('AND');
         $sql .= " ORDER BY unixdate DESC LIMIT 10";
         $result = DB_query ($sql);
@@ -242,7 +242,7 @@
 
     // list of last 10 comments by this user
     $sidArray = array();
-    if (sizeof ($tids) > 0) {
+    if (count($tids) > 0) {
         // first, get a list of all stories the current visitor has access to
         $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ($topics))" . COM_getPermSQL ('AND');
         $result = DB_query($sql);
diff -r 62bd06e50034 -r cd653ce9aafb public_html/usersettings.php
--- a/public_html/usersettings.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/public_html/usersettings.php	Sun Sep 06 15:46:20 2009 +0200
@@ -1208,7 +1208,7 @@
     $topics = "'" . implode ("','", $tids) . "'";
 
     // list of last 10 stories by this user
-    if (sizeof ($tids) > 0) {
+    if (count($tids) > 0) {
         $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = $user) AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ($topics))" . COM_getPermSQL ('AND');
         $sql .= " ORDER BY unixdate DESC LIMIT 10";
         $result = DB_query ($sql);
@@ -1243,7 +1243,7 @@
 
     // list of last 10 comments by this user
     $sidArray = array();
-    if (sizeof ($tids) > 0) {
+    if (count($tids) > 0) {
         // first, get a list of all stories the current visitor has access to
         $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ($topics))" . COM_getPermSQL ('AND');
         $result = DB_query($sql);
@@ -1384,13 +1384,13 @@
     $AETIDS = USER_getAllowedTopics();          // array of strings (fetched, needed to "clean" $TIDS and $ETIDS)
 
     $tids = '';
-    if (sizeof ($TIDS) > 0) {
+    if (count($TIDS) > 0) {
         // the array_intersect mitigates the need to scrub the TIDS input
         $tids = addslashes (implode (' ', array_intersect ($AETIDS, $TIDS)));
     }
 
     $aids = '';
-    if (sizeof ($AIDS) > 0) {
+    if (count($AIDS) > 0) {
         // Scrub the AIDS array to prevent SQL injection and bad values
         foreach ($AIDS as $key => $val) {
             $AIDS[$key] = COM_applyFilter($val, true);
@@ -1420,7 +1420,7 @@
     }
 
     $etids = '';
-    if (($_CONF['emailstories'] == 1) && (sizeof($ETIDS) > 0)) {
+    if (($_CONF['emailstories'] == 1) && (count($ETIDS) > 0)) {
         // the array_intersect mitigates the need to scrub the ETIDS input
         $etids = addslashes (implode (' ', array_intersect ($AETIDS, $ETIDS)));
     }
diff -r 62bd06e50034 -r cd653ce9aafb system/classes/downloader.class.php
--- a/system/classes/downloader.class.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/system/classes/downloader.class.php	Sun Sep 06 15:46:20 2009 +0200
@@ -188,7 +188,7 @@
     */
     function _setAvailableExtensions($extensions = array())
     {
-        if (sizeof($extensions) == 0) {
+        if (count($extensions) == 0) {
             $this->_availableMimeTypes = 
                 array(
                     'tgz'  => 'application/x-gzip-compressed',
@@ -520,7 +520,7 @@
         $fextension = substr($fileName, $pos);
 
         // If application has not set the allowedExtensions then initialize to the default
-        if(sizeof($this->_allowedExtensions) == 0) {
+        if(count($this->_allowedExtensions) == 0) {
             $this->_allowedExtensions = array_flip($this->_availableExtensions);
         }
 
diff -r 62bd06e50034 -r cd653ce9aafb system/classes/upload.class.php
--- a/system/classes/upload.class.php	Sun Sep 06 15:37:18 2009 +0200
+++ b/system/classes/upload.class.php	Sun Sep 06 15:46:20 2009 +0200
@@ -261,7 +261,7 @@
     */
     function _setAvailableMimeTypes($mimeTypes = array())



More information about the geeklog-cvs mailing list