[ADD-ON] improve forum speed

Mod that adds a birthday field to the users profile, theire age are displayed beside the posts, and on there birthday they will have a greeting popup
Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

Postby Blisk on Sun 17. Oct, 2004 21:56

Should we all update, or that's is for a windows users which you talking before?
Blisk
Poster
Poster
 
Posts: 128
Joined: Wed 20. Aug, 2003 14:14

Postby Niels on Sun 17. Oct, 2004 22:17

all should update, as there was a serious bug in the privious posted code - I might come with a better solution later, but in the mean time, please run with the posted code.
(it doesen't matter witch OS you run on)
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby .Wes. on Mon 18. Oct, 2004 00:46

It might just be me, but after installing the mod the viewtopic.php takes a lot longer to load.. I didn't notice much difference with the index page.

Is there a way to speed that page up?
.Wes.
Poster
Poster
 
Posts: 2
Joined: Sat 31. Jul, 2004 22:13

Postby galixte on Mon 18. Oct, 2004 02:06

Hello,

could you join together all the modifications to be carried out on only one post.

Because I am not understand all...

By thanking you :wink:
User avatar
galixte
Poster
Poster
 
Posts: 16
Joined: Tue 27. Apr, 2004 15:14
Location: France

Postby Niels on Sat 23. Oct, 2004 14:47

.Wes. wrote:It might just be me, but after installing the mod the viewtopic.php takes a lot longer to load.. I didn't notice much difference with the index page.

index, should deffently speed up - and the change will not affect the viewtopic.php (other than the CPU have less to do on index, thereby
serving the viewtopic faster also)
If this isen't the case - make shure your webserver have WRITE access to the cache folder - and verify that the mod actually are making files in this folder - if no files is pressent you have located your problem.
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Sat 23. Oct, 2004 14:59

I have now updated the code witch makes the data cache file - this should solve a isue, where usernames have specail chars.
upgrade is recormented, as the birthday list may fail if you do not.

in index.php
Code: Select all
[FIND]
include ($cache_data_file);
[AFTER, ADD]

$birthday_today_list = stripslashes($birthday_today_list);
$birthday_week_list = stripslashes($birthday_week_list);

[FIND]
$data .='$birthday_today_list = \'' . addslashes($birthday_today_list) . "';\n";
$data .='$birthday_week_list = \''.addslashes($birthday_week_list) . "';\n?>";

[REPLACE WITH]
$data .='$birthday_today_list = \'' . $birthday_today_list . "';\n";
$data .='$birthday_week_list = \''. $birthday_week_list . "';\n?>";
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Gog on Sat 23. Oct, 2004 16:23

Hi Niels
I have been following your instructions, to speed up the Birthday mod. I have made a directory called cache_index giving it read and write permissions.... and have added your modified scripts. See below.


Code: Select all
// Birthday Mod, Show users with birthday
$cache_data_file = $phpbb_root_path."cache_index/birthday_". $board_config['board_timezone'] . ".dat";
if (@is_file($cache_data_file))
{
    $valid = (date('YzH',time()) - date('YzH',@filemtime($cache_data_file))<1) ? true : false;
} else
{
   $valid = false;
}

if ($valid )
{
   include ($cache_data_file);
   $birthday_today_list = stripslashes($birthday_today_list);
   $birthday_week_list = stripslashes($birthday_week_list);
} else
{

$sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username" :"";
if($result = $db->sql_query($sql))
{
   if (!empty($result))
   {
      $time_now = time();
      $this_year = create_date('Y', $time_now, $board_config['board_timezone']);
      $date_today = create_date('Ymd', $time_now, $board_config['board_timezone']);
      $date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
         while ($birthdayrow = $db->sql_fetchrow($result))
      {
usleep(1);
            $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
            if ( $user_birthday2 < $date_today ) $user_birthday2 += 10000;
         if ( $user_birthday2 > $date_today  && $user_birthday2 <= $date_forward )
         {
            // user are having birthday within the next days
            $user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']);
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
                  break;
               case MOD :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
                  break;
               default: $style_color = '';
            }
            $birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
         } else if ( $user_birthday2 == $date_today )
            {
            //user have birthday today
            $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
                  break;
               case MOD :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
                  break;
               default: $style_color = '';
            }

            $birthday_today_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
            }
         
      }
      if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' ';
      if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' ';
   }
   $db->sql_freeresult($result);
}
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']))
{
   // stores the data set in a cache file
   $data = "<?php\n";
$data .='$birthday_today_list = \'' . $birthday_today_list . "';\n";
$data .='$birthday_week_list = \''. $birthday_week_list . "';\n?>";
   $fp = fopen( $cache_data_file, "w" );
   fwrite($fp, $data);
   fclose($fp);
}


Unfortunatly when I run the script I get this error;

Parse error: parse error, unexpected $ in /content/StartupHostPlus/g/h/www.myname.co.uk/web/phpBB2/index.php on line 573

Which relates to the last bit of the index.php script. See below;

Code: Select all
//-- fin mod : categories hierarchy ----------------------------------------------------------------
{
   message_die(GENERAL_MESSAGE, $lang['No_forums']);
}

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>


Am I doing something wrong????
Gog
Poster
Poster
 
Posts: 2
Joined: Fri 22. Oct, 2004 13:34

Postby LkSBR on Sun 24. Oct, 2004 21:06

Niels wrote:this is the new section witch I now use on index....this can be used on all OS
Notice you will need a folder named /cache/index - and the www server need write access to this.

FInd the section of code added already to index.php - and replace by this

Code: Select all
// Birthday Mod, Show users with birthday
$cache_data_file = $phpbb_root_path."cache/index/birthday_".
(...)
($birthday_week_list) . "';\n?>";
      $fp = fopen( $cache_data_file, "w" );
      fwrite($fp, $data);
      fclose($fp);
}


Before.... One error!

Parse error: parse error, unexpected T_ELSE in /home/fltotal/public_html/index.php on line 566


'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
);
}
}
}
}
}
563 - } // for ... categories
564-
565 - }// if ... total_categories
566 - else
567 - {
568- message_die(GENERAL_MESSAGE, $lang['No_forums']);
}
// Generate the page
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>

I find:

Code: Select all
// Birthday Mod, Show users with birthday
$sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username" :"";
if($result = $db->sql_query($sql))
{
   if (!empty($result))
   {
      $time_now = time();
      $this_year = create_date('Y', $time_now, $board_config['board_timezone']);
      $date_today = create_date('Ymd', $time_now, $board_config['board_timezone']);
      $date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
         while ($birthdayrow = $db->sql_fetchrow($result))
      {
usleep(2);
            $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
            if ( $user_birthday2 < $date_today ) $user_birthday2 += 10000;
         if ( $user_birthday2 > $date_today  && $user_birthday2 <= $date_forward )
         {
            // user are having birthday within the next days
            $user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']);
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
                  break;
               case MOD :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
                  break;
               default: $style_color = '';
            }
            $birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
         } else if ( $user_birthday2 == $date_today )
            {
            //user have birthday today
            $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
                  break;
               case MOD :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
                  break;
               default: $style_color = '';
            }

            $birthday_today_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
            }

      }
      if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' ';
      if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' ';
   }
   $db->sql_freeresult($result);
}


And change... He is correct? This topic is very great, and full of alterations it would be good for making something more simplified! In the style of the MOD's of phpBB. :wink:
LkSBR
Poster
Poster
 
Posts: 3
Joined: Tue 27. Jul, 2004 01:09

PreviousNext

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron