[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.246,1.247

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Mon Aug 18 10:34:34 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory geeklog_prod:/tmp/cvs-serv14217

Modified Files:
	lib-common.php 
Log Message:
An attempt to speed up COM_emailUserTopics().


Index: lib-common.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.246
retrieving revision 1.247
diff -C2 -d -r1.246 -r1.247
*** lib-common.php	18 Aug 2003 08:36:57 -0000	1.246
--- lib-common.php	18 Aug 2003 14:34:31 -0000	1.247
***************
*** 3642,3645 ****
--- 3642,3665 ----
      global $_TABLES, $LANG08, $LANG24, $_CONF, $LANG_CHARSET;
  
+     // prepare email header - it's always the same for all users
+     $charset = $LANG_CHARSET;
+     if( empty( $charset ))
+     {
+         $charset = $_CONF['default_charset'];
+         if( empty( $charset ))
+         {
+             $charset = "iso-8859-1";
+         }
+     }
+ 
+     $mailfrom = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\n"
+               . "Return-Path: <{$_CONF['site_mail']}>\r\n"
+               . "X-Mailer: GeekLog " . VERSION . "\r\n"
+               . "Content-Type: text/plain; charset={$charset}";
+ 
+     $subject = strip_tags( $_CONF['site_name'] . $LANG08[30] . strftime( '%Y-%m-%d', time() ));
+ 
+     $authors = array();
+ 
      // Get users who want stories emailed to them
      $usersql = "SELECT username,email,etids,{$_TABLES['users']}.uid AS uuid "
***************
*** 3657,3662 ****
          $U = DB_fetchArray( $users );
  
-         $cur_day = strftime( "%D", time() );
- 
          $storysql = "SELECT sid,uid,date AS day,title,introtext,bodytext "
              . "FROM {$_TABLES['stories']} "
--- 3677,3680 ----
***************
*** 3665,3682 ****
          if( !empty( $U['etids'] ))
          {
-             $storysql .= " AND (";
              $ETIDS = explode( ' ', $U['etids'] );
! 
!             for( $i = 0; $i < sizeof( $ETIDS ); $i++ )
!             {
!                 if( $i == (sizeof( $ETIDS ) - 1 ))
!                 {
!                     $storysql .= "tid = '$ETIDS[$i]')";
!                 }
!                 else
!                 {
!                     $storysql .= "tid = '$ETIDS[$i]' OR ";
!                 }
!             }
          }
          else // get all topics this user has access to
--- 3683,3688 ----
          if( !empty( $U['etids'] ))
          {
              $ETIDS = explode( ' ', $U['etids'] );
!             $storysql .= " AND (tid='" . implode( "' OR tid='", $ETIDS ) . "')";
          }
          else // get all topics this user has access to
***************
*** 3716,3720 ****
          $mailtext = $LANG08[29] . strftime( $_CONF['shortdate'], time() ) . "\n";
  
!         for( $y=0; $y < $nsrows; $y++ )
          {
              // Loop through stories building the requested email message
--- 3722,3726 ----
          $mailtext = $LANG08[29] . strftime( $_CONF['shortdate'], time() ) . "\n";
  
!         for( $y = 0; $y < $nsrows; $y++ )
          {
              // Loop through stories building the requested email message
***************
*** 3726,3730 ****
              if( $_CONF['contributedbyline'] == 1 )
              {
!                 $storyauthor = DB_getItem( $_TABLES['users'], 'username', "uid = '{$S['uid']}'" );
                  $mailtext .= "$LANG24[7]: " . $storyauthor . "\n";
              }
--- 3732,3740 ----
              if( $_CONF['contributedbyline'] == 1 )
              {
!                 if( empty( $authors[$S['uid']] ))
!                 {
!                     $storyauthor = DB_getItem( $_TABLES['users'], 'username', "uid = '{$S['uid']}'" );
!                     $authors[$S['uid']] = $storyauthor;
!                 }
                  $mailtext .= "$LANG24[7]: " . $storyauthor . "\n";
              }
***************
*** 3757,3783 ****
          $mailto = "{$U['username']} <{$toemail}>";
  
-         $charset = $LANG_CHARSET;
-         if( empty( $charset ))
-         {
-             $charset = $_CONF['default_charset'];
-             if( empty( $charset ))
-             {
-                 $charset = "iso-8859-1";
-             }
-         }
- 
-         $mailfrom = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\n"
-                   . "Return-Path: <{$_CONF['site_mail']}>\r\n"
-                   . "Content-Type: text/plain; charset={$charset}\r\n"
-                   . "X-Mailer: GeekLog " . VERSION;
- 
-         $subject = strip_tags( stripslashes( $_CONF['site_name'] . $LANG08[30] . strftime( '%Y-%m-%d', time() )));
- 
          @mail( $toemail, $subject, $mailtext, $mailfrom );
      }
  
!     $tmpdate = date( "Y-m-d H:i:s", time() );
! 
!     DB_query( "UPDATE {$_TABLES['vars']} SET value = '$tmpdate' WHERE name = 'lastemailedstories'" );
  }
  
--- 3767,3774 ----
          $mailto = "{$U['username']} <{$toemail}>";
  
          @mail( $toemail, $subject, $mailtext, $mailfrom );
      }
  
!     DB_query( "UPDATE {$_TABLES['vars']} SET value = NOW() WHERE name = 'lastemailedstories'" );
  }
  





More information about the geeklog-cvs mailing list