[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.407,1.408

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Wed Dec 29 03:43:39 EST 2004


Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv23392/public_html

Modified Files:
	lib-common.php 
Log Message:
Fixed caching of $_GROUPS and made a minor optimzation, saving one SQL request when displaying the comment bar for anonymous users.


Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.407
retrieving revision 1.408
diff -C2 -d -r1.407 -r1.408
*** lib-common.php	22 Dec 2004 16:10:28 -0000	1.407
--- lib-common.php	29 Dec 2004 08:43:37 -0000	1.408
***************
*** 2650,2654 ****
      }
  
!     if( $_USER['uid'] > 1)
      {
          $username = $_USER['username'];
--- 2650,2654 ----
      }
  
!     if( $_USER['uid'] > 1 )
      {
          $username = $_USER['username'];
***************
*** 2658,2663 ****
      else
      {
!         $username = DB_getItem( $_TABLES['users'], 'username', "uid = '1'" );
!         $fullname = DB_getItem( $_TABLES['users'], 'fullname', "uid = '1'" );
      }
      if( empty( $fullname ))
--- 2658,2665 ----
      else
      {
!         $result = DB_query( "SELECT username,fullname FROM {$_TABLES['users']} WHERE uid = 1" );
!         $N = DB_fetchArray( $result );
!         $username = $N['username'];
!         $fullname = $N['fullname'];
      }
      if( empty( $fullname ))
***************
*** 3786,3790 ****
      if( $A['type'] == 'phpblock' && !$_USER['noboxes'] )
      {
!         if( !($A['name'] == 'whosonline_block' AND DB_getItem( $_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0 ))
          {
              $function = $A['phpblockfn'];
--- 3788,3792 ----
      if( $A['type'] == 'phpblock' && !$_USER['noboxes'] )
      {
!         if( !( $A['name'] == 'whosonline_block' AND DB_getItem( $_TABLES['blocks'], 'is_enabled', "name='whosonline_block'" ) == 0 ))
          {
              $function = $A['phpblockfn'];
***************
*** 5582,5593 ****
          $table .= '.';
      }
!     if(( $u_id <= 0 ) || ( $u_id == $_USER['uid'] ))
      {
!         $uid = $_USER['uid'];    
!         $GROUPS = $_GROUPS;
      }
      else
      {
          $uid = $u_id;
          $GROUPS = SEC_getUserGroups( $uid );
      }
--- 5584,5612 ----
          $table .= '.';
      }
!     if( $u_id <= 0)
      {
!         if( empty( $_USER['uid'] ))
!         {
!             $uid = 1;
!         }
!         else
!         {
!             $uid = $_USER['uid'];
!         }
      }
      else
      {
          $uid = $u_id;
+     }
+     if(( empty( $_USER['uid'] ) && ( $uid == 1 )) || ( $uid == $_USER['uid'] ))
+     {
+         if( empty( $_GROUPS ))
+         {
+             $_GROUPS = SEC_getUserGroups( $uid );
+         }
+         $GROUPS = $_GROUPS;
+     }
+     else
+     {
          $GROUPS = SEC_getUserGroups( $uid );
      }
***************
*** 6046,6074 ****
  }
  
! /** Convert a text based date YYYY-MM-DD to a unix timestamp integer value 
  *
! * @param    string $date     Date in the format YYYY-MM-DD
! * @param    string $time     Option time in the format HH:MM::SS
! * @return   int          UNIX Timestamp
  */
! function COM_convertDate2Timestamp($date,$time='') {
!         // Breakup the string using either a space, fwd slash, bkwd slash or colon as a delimiter
!         $atok = strtok($date," /-\\:");
!         while ($atok !== FALSE) {
!             $atoks[] = $atok;
!             $atok = strtok(" /-\\:");  // get the next token
!         }
!         if ($time == '') {
!             $timestamp = mktime(0,0,0,$atoks[1],$atoks[2],$atoks[0]);
!         } else {
!             $btok = strtok($time," /-\\:");
!             while ($btok !== FALSE) {
!                 $btoks[] = $btok;
!                 $btok = strtok(" /-\\:");
!             }
!             $timestamp = mktime($btoks[0],$btoks[1],$btoks[2],$atoks[1],$atoks[2],$atoks[0]);
          }
!         return $timestamp;
  }
  // Now include all plugin functions
  foreach( $_PLUGINS as $pi_name )
--- 6065,6104 ----
  }
  
! /**
! * Convert a text based date YYYY-MM-DD to a unix timestamp integer value 
  *
! * @param    string  $date   Date in the format YYYY-MM-DD
! * @param    string  $time   Option time in the format HH:MM::SS
! * @return   int             UNIX Timestamp
  */
! function COM_convertDate2Timestamp( $date, $time = '' )
! {
!     // Breakup the string using either a space, fwd slash, bkwd slash or
!     // colon as a delimiter
!     $atok = strtok( $date, ' /-\\:' );
!     while( $atok !== FALSE )
!     {
!         $atoks[] = $atok;
!         $atok = strtok( ' /-\\:' );  // get the next token
!     }
!     if( $time == '' )
!     {
!         $timestamp = mktime( 0, 0, 0, $atoks[1], $atoks[2], $atoks[0] );
!     }
!     else
!     {
!         $btok = strtok( $time, ' /-\\:' );
!         while( $btok !== FALSE )
!         {
!             $btoks[] = $btok;
!             $btok = strtok( ' /-\\:' );
          }
!         $timestamp = mktime( $btoks[0], $btoks[1], $btoks[2],
!                              $atoks[1], $atoks[2], $atoks[0] );
!     }
! 
!     return $timestamp;
  }
+ 
  // Now include all plugin functions
  foreach( $_PLUGINS as $pi_name )




More information about the geeklog-cvs mailing list