Birthday Caching Addon (RC3)

In diesem Forum können Mod-Autoren ihre Mods vorstellen, die sich noch im Entwicklungsstatus befinden. Der Einbau in Foren im produktiven Betrieb wird nicht empfohlen.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Benutzeravatar
easygo
Mitglied
Beiträge: 2170
Registriert: 03.09.2004 13:45
Kontaktdaten:

Beitrag von easygo »

AmigaLink hat geschrieben:<1 übrigens für den Fall das daß Cachefile älter als 1 Tag ist. Mit ==0 hätteste in dem Fall ein Problem. ;)
Aehm... welches Problem dann?

Beispiel:

valid = 2.005.186 - 2.005.181 = 5

Macht dann: valid != 0

valid = false

Oder hab ich da jetzt nen Denkfehler?

:D easy
Zuletzt geändert von easygo am 27.04.2005 15:22, insgesamt 1-mal geändert.
Benutzeravatar
AmigaLink
Mitglied
Beiträge: 1417
Registriert: 09.06.2003 21:56
Wohnort: NRW
Kontaktdaten:

Beitrag von AmigaLink »

Hast recht. :oops:
Aber sicher ist sicher. ;)

// EDIT
Bei mir läufts auf jeden Fall einwandfrei. :)
Hab Lokal auch mal mit veränderung der Systemzeit getestet. :D
Benutzeravatar
easygo
Mitglied
Beiträge: 2170
Registriert: 03.09.2004 13:45
Kontaktdaten:

Beitrag von easygo »

Super! Dann sind wir ja fast durch mit der Beta. :grin:

Lassen wirs sicherheitshalber noch 2-3 Tage so stehen und dann...

auf zur nächster Board-Bremse oder so.

Thx @ AmigaLink
easygo hat geschrieben: $sql = "SELECT user_regdate
FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS . " AND user_active = 1
ORDER BY user_id DESC
LIMIT 0,1";
$result = $db->sql_query($sql);
while ($row = mysql_fetch_array($result))
{
$newest_regdate = $row['user_regdate'];
}
$db->sql_freeresult($result);
Btw: das Rote würd ich schon noch übernehmen...
weil sonst gibts da hin und wieder Probleme. Außerdem steckt
ja noch ein sql_query drin im Caching Addon.
Benutzeravatar
AmigaLink
Mitglied
Beiträge: 1417
Registriert: 09.06.2003 21:56
Wohnort: NRW
Kontaktdaten:

Beitrag von AmigaLink »

Kein Problem! :)
auf zur nächster Board-Bremse oder so.
Bei Optimierungen bin ich immer dabei! :)

Deine Roten zusätze werd ich noch übernehmen.
Benutzeravatar
BraveEagle
Mitglied
Beiträge: 1884
Registriert: 16.01.2003 18:05
Wohnort: born 2 be a Paelzer
Kontaktdaten:

Beitrag von BraveEagle »

So auf diesen Thread bezogen: Wenn ich das mache kommt folgender Fehler:

Code: Alles auswählen

Warning: Unterminated comment starting line 370 in /www/htdocs/bcforuma/index.php on line 370

Parse error: parse error, unexpected $ in /www/htdocs/bcforuma/index.php on line 370
Ich habe bisher folgendes gemacht:


das hier:

Code: Alles auswählen

// 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))
      {
            $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);
}
mit dem hier ersetzt:

Code: Alles auswählen

// 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)  && empty($SID))
{
    $valid = (date('YzH',time(),0) - date('YzH',@filemtime($cache_data_file),0)<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))
         {
               $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);
      if (empty($SID))
      {
         // stores the data set in a cache file
         $data = "<?php\n";
         $data .='$birthday_today_list = \'' . addslashes($birthday_today_list) . ".';\n";
         $data .='$birthday_week_list = \''.addslashes($birthday_week_list) . ".';\n?>";
         $fp = fopen( $cache_data_file, "w" );
         fwrite($fp, $data);
         fclose($fp);
      }
   }
} 
Benutzeravatar
easygo
Mitglied
Beiträge: 2170
Registriert: 03.09.2004 13:45
Kontaktdaten:

Beitrag von easygo »

Hi BraveEagle, du verstößt grad gegen die Knigge !? rofl

Ersetz den Code bitte mal damit -->

http://www.net4seven.de/fpost2328.html#2328

Wichtig! Falls nicht vorhanden, Verzeichnis cache/ mit Unterverzeichnis
cache/bday erstellen und für beide CHMOD 777 setzen.

Feedback wär ganz nett. :D easy
Zuletzt geändert von easygo am 10.09.2005 23:09, insgesamt 2-mal geändert.
Benutzeravatar
BraveEagle
Mitglied
Beiträge: 1884
Registriert: 16.01.2003 18:05
Wohnort: born 2 be a Paelzer
Kontaktdaten:

Beitrag von BraveEagle »

Also der Code erzeugt mal keine Fehlermeldung so. ( http://testarea.biologie-chemie-forum.de ). Kann ich auch irgendwie nachvollziehen, ob der nun funzt?

BE
Benutzeravatar
easygo
Mitglied
Beiträge: 2170
Registriert: 03.09.2004 13:45
Kontaktdaten:

Beitrag von easygo »

Klar, zum Teil erkennst du das sofort (normalerweise)

Den Rest müssen die nächsten Tage / Neuregistrierungen zeigen.

Code zum Checken der letzten Update Zeit? Bitte...

Code: Alles auswählen

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//Session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

//Header
$page_title = 'Update Time Control';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

//Here we go
$cache_bday_file = $phpbb_root_path."cache/bday/bday_" . $board_config['board_timezone'] . ".php";

if (file_exists($cache_bday_file)) {
echo "<center>";
echo "Show last Update time of: $cache_bday_file";
echo "<br /><br />";
echo "UNIX Time: " . filemtime($cache_bday_file);
echo "<br />";
echo "Time Format: " .date("d.m.Y, H:i:s", filemtime($cache_bday_file));
echo "<br /></center>";
}
//Footer
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Speichern als _test.php, ins Forum-Verzeichnis kopieren,
und dann einfach in deinem Brwoser aufrufen...
John Doe
Mitglied
Beiträge: 684
Registriert: 30.03.2005 01:06

Beitrag von John Doe »

Sehr schön, das funktioniert nun sowohl off-, als auch online bei
mir.
:grin:
Benutzeravatar
BraveEagle
Mitglied
Beiträge: 1884
Registriert: 16.01.2003 18:05
Wohnort: born 2 be a Paelzer
Kontaktdaten:

Beitrag von BraveEagle »

also nach dem Testcode funzt der COde bei mir nicht:
Show last Update time of: ./cache/bday/bday_1.00.php

UNIX Time: 1114622090
Time Format: 27.04.2005, 19:14:50
Show last Update time of: ./cache/bday/bday_1.00.php

UNIX Time: 1114622090
Time Format: 27.04.2005, 19:15:15
Antworten

Zurück zu „phpBB 2.0: Mods in Entwicklung“