Seite 1 von 2

Heute/Gestern MOD kompatibel zu 2.0.13

Verfasst: 10.03.2005 09:45
von adac
Hallo,

ich bin leider über die Suche (und der Ergebnisse) nicht ganz fündig geworden. Anscheinend gibt es wohl nur noch Probleme bzgl. des MODs. Leider nützen mir auch Beiträge von vor 2-3 Jahren auf Grund der unterschiedlichen Versionen nicht wirklich etwas.

Anscheinend gibt es auch verschiedene MODs zum Thema Heute/Gestern.

In meinem Forum laufen zur Zeit Last Visit Mod, Birthday Mod und einige andere die aber nichts mit dem Thema "Datum" zu tun haben.

Es wäre schön wenn mir jemand einen Link nennen könnte zu einem Heute/Gestern MOD der einwandfrei läuft, also ohne Zeitprobleme oder Einflussnahme auf andere MODs.

Danke für Eure Hilfe

Verfasst: 10.03.2005 12:49
von Mario Siebert
Diesen Today at/Yesterday at Mod habe ich erst gestern mehrfach in 2.0.13er eingebaut in denen auch der Last Visit/Birthday Mod verbaut war, er läuft ohne Probleme:
## EasyMod 0.0.7 compliant
##############################################################
## MOD Title: Today At/Yesterday At
## MOD Author: netclectic < adrian@netclectic.com > (Adrian Cockburn) http://www.netclectic.com
## MOD Description: Will show Today At if the post was posted today
## Will show Yesterday At if the post was posted yesterday
##
## MOD Version: 1.3.0
##
## Installation Level: easy
## Installation Time: 10 Minutes
## Files To Edit: (6) page_header.php, index.php, search.php, viewforum.php, viewtopic.php, lang_main.php
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##############################################################
## Author Notes:
##
## Original Author: blulegend
## Update by netclectic to work on 2.0.4
##
##############################################################
## MOD History:
##
## 2003-06-10 - v1.3.0
## - updated for 2.0.4
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------
#
includes/page_header.php

#
#-----[ FIND ]------------------------------------------
#
//
// Parse and show the overall header.
//

#
#-----[ BEFORE, ADD ]-----------------------------------
#
//
// MOD - TODAY AT - BEGIN
// PARSE DATEFORMAT TO GET TIME FORMAT
//
$time_reg = '([gh][[:punct:][:space:]]{1,2}[[:punct:][:space:]]{0,2}[a]?[[:punct:][:space:]]{0,2}[S]?)';
eregi($time_reg, $board_config['default_dateformat'], $regs);
$board_config['default_timeformat'] = $regs[1];
unset($time_reg);
unset($regs);

//
// GET THE TIME TODAY AND YESTERDAY
//
$today_ary = explode('|', create_date('m|d|Y', time(),$board_config['board_timezone']));
$board_config['time_today'] = gmmktime(0 - $board_config['board_timezone'] - $board_config['dstime'],0,0,$today_ary[0],$today_ary[1],$today_ary[2]);
$board_config['time_yesterday'] = $board_config['time_today'] - 86400;
unset($today_ary);
// MOD - TODAY AT - END

#
#-----[ OPEN ]------------------------------
#
index.php

#
#-----[ FIND ]-----------------------------------
#
$last_post = $last_post_time . '<br />';

#
#-----[ REPLACE WITH ]-----------------------------------
#

// OLD
// $last_post = $last_post_time . '<br />';
//
// MOD - TODAY AT - BEGIN
//
if ( $board_config['time_today'] < $forum_data[$j]['post_time'])
{
$last_post = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])) . '<br />';
}
else if ( $board_config['time_yesterday'] < $forum_data[$j]['post_time'])
{
$last_post = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])) . '<br />';
}
else
{
$last_post = $last_post_time . '<br />';
}
// MOD - TODAY AT - END

#
#-----[ OPEN ]------------------------------
#
search.php

#
#-----[ FIND ]-----------------------------------
#
$post_date = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']);

#
#-----[ AFTER, ADD ]-----------------------------------
#

//
// MOD - TODAY AT - BEGIN
//
if ( $board_config['time_today'] < $searchset[$i]['post_time'])
{
$post_date = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone']));
}
else if ( $board_config['time_yesterday'] < $searchset[$i]['post_time'])
{
$post_date = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone']));
}
// MOD - TODAY AT - END

#
#-----[ FIND ]-----------------------------------
#
$last_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']);

#
#-----[ AFTER, ADD ]-----------------------------------
#

//
// MOD - TODAY AT - BEGIN
//
if ( $board_config['time_today'] < $searchset[$i]['post_time'])
{
$last_post_time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone']));
}
else if ( $board_config['time_yesterday'] < $searchset[$i]['post_time'])
{
$last_post_time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $searchset[$i]['post_time'], $board_config['board_timezone']));
}
// MOD - TODAY AT - END

#
#-----[ OPEN ]------------------------------
#
viewforum.php

#
#-----[ FIND ]-----------------------------------
#
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);

#
#-----[ AFTER, ADD ]-----------------------------------
#

//
// MOD - TODAY AT - BEGIN
//
if ( $board_config['time_today'] < $topic_rowset[$i]['post_time'])
{
$last_post_time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']));
}
else if ( $board_config['time_yesterday'] < $topic_rowset[$i]['post_time'])
{
$last_post_time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']));
}
// MOD - TODAY AT - END

#
#-----[ OPEN ]------------------------------
#
viewtopic.php

#
#-----[ FIND ]-----------------------------------
#
$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);

#
#-----[ AFTER, ADD ]-----------------------------------
#

//
// MOD - TODAY AT - BEGIN
//
if ( $board_config['time_today'] < $postrow[$i]['post_time'])
{
$post_date = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $postrow[$i]['post_time'], $board_config['board_timezone']));
}
else if ( $board_config['time_yesterday'] < $postrow[$i]['post_time'])
{
$post_date = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $postrow[$i]['post_time'], $board_config['board_timezone']));
}
// MOD - TODAY AT - END

#
#-----[ OPEN ]------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]-----------------------------------
#
//
// That's all, Folks!

#
#-----[ BEFORE, ADD ]-----------------------------------
#

// MOD - TODAY AT - BEGIN
$lang['Today_at'] = "Today at %s"; // %s is the time
$lang['Yesterday_at'] = "Yesterday at %s"; // %s is the time
// MOD - TODAY AT - END

#
#-----[ SAVE/CLOSE ALL FILES ]-----------------------------------
# EoM




Grüße Mario

Verfasst: 10.03.2005 14:13
von ATARI
hi mario, der mod ist echt klasse.
nur mit dem editieren der index.php hab ich leichte schwierigkeiten, da ich den last post on index mod von e-sven schon drinnen hab.

hier meine index.php: - klick -


könntest du mir sagen wie ich den code hier reinbringe?


thanks in advance, atari

Verfasst: 10.03.2005 14:52
von adac
Hallo Mario,

erst einmal Danke. Ich werde es nachher mal testen.

Verfasst: 10.03.2005 19:08
von ATARI
push

Verfasst: 21.03.2005 05:08
von TK
Hallo ATARI,

ohne Gewähr auf Richtigkeit (denn ich habe diesen last post on index-mod NICHT, und konnte meinen code daher nicht ausprobieren), aber nach meinem "Logikverständnis" ;) müsstest du in deinem speziellen fall in deiner index.php bei dir folgende Änderungen anwenden:

Code: Alles auswählen

# 
#-----[ OPEN ]------------------------------ 
# 
index.php

# 
#-----[ FIND ]----------------------------------- 
#
$last_post .= $last_post_time . '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '"></a><br>' . $lang['by'] . '&nbsp;';

# 
#-----[ REPLACE WITH ]----------------------------------- 
#
// MOD - TODAY AT - BEGIN 
// 
if ( $board_config['time_today'] < $forum_data[$j]['post_time']) 
{ 
$last_post .= sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])); 
} 
else if ( $board_config['time_yesterday'] < $forum_data[$j]['post_time']) 
{ 
$last_post .= sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $forum_data[$j]['post_time'], $board_config['board_timezone'])); 
} 
else 
{ 
$last_post .= $last_post_time; 
} 

$last_post .= '&nbsp;<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '"></a><br>' . $lang['by'] . '&nbsp;';
// MOD - TODAY AT - END
Wie gesagt, ich hab's nicht ausprobiert, daher solltest du unbedingt von deiner jetzigen index.php ein Backup machen und notfalls wieder zurück einspielen, falls ich versagt haben sollte :D

Kannst ja berichten, ob's geklappt hat...

Verfasst: 02.04.2005 14:54
von TK
Oh Mann... ich hatte mich schon so gefreut, einen Heute/Gestern-MOD gefunden zu haben, der nicht global hardcodet, sondern nur an den gewünschten Stellen die Ausgabe ändert, und auch die Zeitzonen korrekt berücksichtigt... Aber ich hatte mich zu früh gefreut... Pünktlich zur Zeitumstellung gab's Probleme: Beiträge, die zwischen 0-1 Uhr geschrieben wurden, wurden fälschlicherweise dem vorherigen Tag zugeordnet (also z.B. "Gestern, 00:30", obwohl "Heute, 00:30" korrekt gewesen wäre)

Ich hab mir den Code nochmal genauer angeschaut und bemerkte, dass die Sommerzeit prinzipiell berücksichtigt wird, aber anscheinend nur mit einem anderen MOD zusammen, der die Sommerzeit erkennt und $board_config['dstime'] auf TRUE setzt. $board_config['dstime'] wird nämlich in diesem Gestern/Heute-MOD abgefragt und berücksichtigt, ist aber in normalen Standard-Installationen von phpBB nicht definiert (auch nicht in der deutschen phpbb.de-Version mit integriertem Sommerzeit-Fix von phpbb.de), so dass die Sommerzeit nicht korrekt erkannt wird.

Einfache Abhilfe dieses Problems erfolgt, indem innerhalb der includes/page_header.php statt

Code: Alles auswählen

$board_config['time_today'] = gmmktime(0 - $board_config['board_timezone'] - $board_config['dstime'],0,0,$today_ary[0],$today_ary[1],$today_ary[2]);
eine eventuell derzeitig aktive Sommerzeit direkt via date('I') (großes I) abgefragt wird:

Code: Alles auswählen

$board_config['time_today'] = gmmktime(0 - $board_config['board_timezone'] - date('I'),0,0,$today_ary[0],$today_ary[1],$today_ary[2]);
Anmerkung: Der Server liefert bei der date-Funktion bei "I" den Wert 1 zurück, wenn Sommerzeit aktiv ist, ansonsten nur 0.

(Alternativ kann man statt der Änderung der obigen Zeile natürlich auch einfach $board_config['dstime'] definieren:

Code: Alles auswählen

$board_config['dstime'] = date("I");
- das muss dann natürlich vor der obigen Zeile geschehen)

Verfasst: 02.04.2005 15:09
von ATARI
danke TK, hat tatsächlich geklappt!

Verfasst: 02.04.2005 19:34
von TK
ATARI hat geschrieben:danke TK, hat tatsächlich geklappt!
Bezieht sich das jetzt auf das Sommerzeit-Problem oder dem anderen vorherigen Problem von dir, worauf ich hier im Thread geantwortet hatte? ;)

Verfasst: 03.04.2005 12:32
von ATARI
auf meine spezielle frage bezog sich das.