Seite 4 von 6

Verfasst: 27.04.2005 15:20
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

Verfasst: 27.04.2005 15:21
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

Verfasst: 27.04.2005 15:43
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.

Verfasst: 27.04.2005 16:26
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.

Verfasst: 27.04.2005 16:56
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);
      }
   }
} 

Verfasst: 27.04.2005 17:05
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

Verfasst: 27.04.2005 18:07
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

Verfasst: 27.04.2005 18:25
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...

Verfasst: 27.04.2005 19:08
von John Doe
Sehr schön, das funktioniert nun sowohl off-, als auch online bei
mir.
:grin:

Verfasst: 27.04.2005 19:11
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