Xkeeper0/jul

Setting custom date formats

Closed this issue · 6 comments

A date format is already set in layout (and overwritten somewhere too), but apparently changing it messes some things up:
$dateformat='m-d-y h:i:s A';
$dateshort='m-d-y';
Ideally it should be user-configurable, which would require a new column in the database.

Do me a favor and do a grep for $dateformat and $dateshort so I can pick out all the places it shouldn't be used.

[sanky@rikorisu jul]$ grep "\$dateformat" * -n -r
activeusers.php:101:                    $tccell1>".date($dateformat, $user['regdate'] + $tzoff) ."</td>
admin-threads2.php:88:                          $tccell1>". ($data['lastpostdate'] ? date($dateformat, $data['lastpostdate'] + $tzoff) : "-") ."</td>
admin-threads2.php:89:                          $tccell1>". ($data['realdate'] ? date($dateformat, $data['realdate'] + $tzoff) : "-") ."</td>
biggestposters.php:55:                  $tccell1>".date($dateformat, $user['regdate'] + $tzoff) ."</td>
del.php:179:    if($user['lastactivity'] != $user['regdate']) $lastactivity     = date($dateformat, $user['lastactivity'] - $tzoff);
editprofile.php:144:     $tccell1><b>Timezone offset:$descbr How many hours you're offset from the time on the board (".date($dateformat,ctime()).").</td>
edituser.php:118:       $lft Registration time:</b>$smallfont<br>(seconds since ".date($dateformat,$tzoff).")</td>$tccell2l>$inpt=regtime SIZE=10 MAXLENGTH=15 VALUE=$user[regdate]><tr>
forum.php:77:           <td colspan=6 class='tbl tdbg1 font'><a href=announcement.php>$annc[title]</a> -- Posted by <a href=profile.php?id=$annc[user]><font $namecolor>$annc[name]</font></a> on ".date($dateformat,$annc[date]+$tzoff)."<tr>
forum.php:85:       $tccell1l colspan=7><a href=announcement.php?f=$id>$annc[title]</a> -- Posted by <a href=profile.php?id=$annc[user]><font $namecolor>$annc[name]</font></a> on ".date($dateformat,$annc[date]+$tzoff)."<tr>
forum.php:229:          $tccell2><div class='lastpost'>".date($dateformat,$thread[lastpostdate]+$tzoff)."<br>by <a href='profile.php?id=$thread[lastposter]'><font $namecolor2>$thread[name2]</font></a></div></td>";
index.php:142:          $lastmsg="Last message from <a href='profile.php?id=$pmsg[id]' $namecolor>$pmsg[name]</a> on ".date($dateformat,$pmsg[date]+$tzoff);
index.php:181:                          $forumlastpost="<nobr>". date($dateformat,$forum[lastpostdate]+$tzoff);
ipsearch.php:96:            $tccell1>".@date($dateformat,$user[regdate])."</td>
ipsearch.php:97:            $tccell1>".date($dateformat,$user[lastposttime])."</td>
ipsearch.php:98:            $tccell1>".date($dateformat,$user[lastactivity])."</td>
ipsearch.php:121:           $tccell1><nobr>".date($dateformat,$post[date])."</nobr></td>
ipsearch.php:145:           $tccell1><nobr>".date($dateformat,$pmsg[date])."</nobr></td>
lib/threadpost.php:3:           global $loguser,$quote,$edit,$ip,$smallfont,$tzoff,$sep,$dateformat,$dateshort,$postl,$tlayout,${"tablebg$bg"};
lib/threadpost.php:13:          $set['date']  = date($dateformat,$post[date]+$tzoff);
lib/function.php:366:   global $tagval,$v,$tzoff,$dateformat, $hacks;
lib/function.php:392:           elseif($in=='&date&')           $out=date($dateformat,ctime()+$tzoff);
lib/layout.php:30:      $dateformat='m-d-y h:i:s A';
lib/layout.php:80:              $dateformat = "m/d/y h:i";
lib/layout.php:204:                     $boardtitle     .= "<br><a href='shitbugs.php'><span class=font style=\"color: #f00\"><b>". $xminilog['count'] ."</b> suspicious request(s) logged, last at <b>". date($dateformat, $xminilog['time'] + $tzoff) ."</b> by <b>". $xminilogip['ip'] ." (". $xminilogip['banflags'] .")</b></span></a>";
lib/layout.php:209:                     $boardtitle     .= "<br><span class='font' style=\"color: #ff0\"><b>". $xminilog['count'] ."</b> pending user(s), last <b>'". $xminilogip['username'] ."'</b> at <b>". date($dateformat, $xminilog['time'] + $tzoff) ."</b> by <b>". $xminilogip['ip'] ."</b></span>";
lib/layout.php:284:                     $lastmsg   =  "Last message from <a href=profile.php?id=$pmsg[id]><font $namecolor>$pmsg[name]</font></a> on ".date($dateformat,$pmsg[date]+$tzoff);
lib/layout.php:338:               <td width='120px' class='tbl tdbg2 center fonts'><nobr>".  date($dateformat,ctime()+$tzoff) ."<br><img src=images/_.gif width=120 height=1><tr>" 
lib/layout.php:339:             : "<br>$views views, ". date($dateformat,ctime()+$tzoff) ."
lib/layout.php:377:                     $r=fputs($fpnt, "User $loguserid IP changed from $ulastip to $userip, on ".date($dateformat,ctime())."
memberlist.php:155:       $tccell2>".date($dateformat,$user[2]+$tzoff)."</td>
online.php:65:    $user[lastposttime]=date($dateformat,$user[lastposttime]+$tzoff);
postsbyuser.php:31:       $tccell1s>".date($dateformat,$post[3]+$tzoff)."</td>
private.php:65:         $tccell2>".date($dateformat,$pmsg[date]+$tzoff)
profile.php:45:  if($user[posts]) $lastpostdate=date($dateformat,$user[lastposttime]+$tzoff);
profile.php:89: $tzdate=date($dateformat,ctime()+$tzoffset*3600);
profile.php:109:          else $projdate=" -- Projected date for $topposts posts: ".date($dateformat,$projdate+$tzoff);
profile.php:149:        $tccell1l width=150><b>Registered on</td>               $tccell2l>".@date($dateformat,$user[regdate]+$tzoff)." (".floor((ctime()-$user[regdate])/86400)." days ago)<tr>
profile.php:151:        $tccell1l width=150><b>Last activity</td>               $tccell2l>".date($dateformat,$user[lastactivity]+$tzoff)."$lastip<tr>
stats.php:49:   $tccell2ls>$misc[maxpostsday], on ".date($dateformat,$misc[maxpostsdaydate])."<tr>
stats.php:51:   $tccell2ls>$misc[maxpostshour], on ".date($dateformat,$misc[maxpostshourdate])."<tr>
stats.php:53:   $tccell2ls>$misc[maxusers], on ".date($dateformat,$misc[maxusersdate])."$misc[maxuserstext]
tlayouts/postwide.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$dateshort,$dateformat,$tlayout,$textcolor,$numdir,$numfil;
tlayouts/postwide.php:38:    $postdate=date($dateformat,$post[date]+$tzoff);
tlayouts/rpg.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$dateformat,$tccell1l,$tccell2l,$tableborder,$tablebg2,$tableheadtext,$numdir;
tlayouts/rpg.php:7:    $postdate=date($dateformat,$post[date]+$tzoff);
tlayouts/extended.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$opts,$dateshort,$dateformat,$tlayout,$textcolor,$numdir,$numfil;
tlayouts/extended.php:44:    $postdate=date($dateformat,$post[date]+$tzoff);
tlayouts/regular.php:6:    global $tzoff, $smallfont, $ip, $quote, $edit, $dateshort, $dateformat, $tlayout, $textcolor, $numdir, $numfil, $tblstart, $hacks, $x_hacks, $loguser;
tlayouts/regular.php:46:    $postdate=date($dateformat,$post[date]+$tzoff);
tlayouts/vertical.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$dateshort,$dateformat,$tlayout,$textcolor,$numdir,$numfil;
tlayouts/vertical.php:38:    $postdate=date($dateformat,$post[date]+$tzoff);
tlayouts/hydra.php:5:           global $tzoff, $smallfont, $ip, $quote, $edit, $dateshort, $dateformat, $tlayout, $textcolor, $numdir, $numfil, $tblstart, $hacks, $x_hacks, $loguser;
tlayouts/hydra.php:18:          $postdate  =  date($dateformat,$post[date]+$tzoff);
[sanky@rikorisu jul]$ grep "\$dateshort" * -n -r
del.php:177:    if($user['lastposttime']) $lastpost             = date($dateshort, $user['lastposttime'] - $tzoff);
del.php:181:    if($user['regdate']) $regdate                   = date($dateshort, $user['regdate'] - $tzoff);
lib/threadpost.php:3:           global $loguser,$quote,$edit,$ip,$smallfont,$tzoff,$sep,$dateformat,$dateshort,$postl,$tlayout,${"tablebg$bg"};
lib/layout.php:31:      $dateshort='m-d-y';
lib/layout.php:81:              $dateshort  = "m/d/y";
tlayouts/postwide.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$dateshort,$dateformat,$tlayout,$textcolor,$numdir,$numfil;
tlayouts/postwide.php:37:    $since='Since: '.@date($dateshort,$post[regdate]+$tzoff);
tlayouts/extended.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$opts,$dateshort,$dateformat,$tlayout,$textcolor,$numdir,$numfil;
tlayouts/extended.php:43:    $since='Since: '.@date($dateshort,$post[regdate]+$tzoff);
tlayouts/regular.php:6:    global $tzoff, $smallfont, $ip, $quote, $edit, $dateshort, $dateformat, $tlayout, $textcolor, $numdir, $numfil, $tblstart, $hacks, $x_hacks, $loguser;
tlayouts/regular.php:45:    $since='Since: '.@date($dateshort,$post[regdate]+$tzoff);
tlayouts/regular.php:385:               $joindate               = 'Joined </font>'. date($dateshort,$post[regdate]+$tzoff) ."<font color=$fcol2>";
tlayouts/regular.php:418:               $joindate               = 'Joined </font>'. date($dateshort,$post[regdate]+$tzoff) ."<font color=$fcol2>";
tlayouts/regular.php:540:               $joindate               = 'Joined '. date($dateshort,$post[regdate]+$tzoff);
tlayouts/vertical.php:5:    global $tzoff,$smallfont,$ip,$quote,$edit,$dateshort,$dateformat,$tlayout,$textcolor,$numdir,$numfil;
tlayouts/hydra.php:5:           global $tzoff, $smallfont, $ip, $quote, $edit, $dateshort, $dateformat, $tlayout, $textcolor, $numdir, $numfil, $tblstart, $hacks, $x_hacks, $loguser;
tlayouts/hydra.php:16:          $since='Since: '.@date($dateshort,$post[regdate]+$tzoff);

does this thing work

EDIT: subfolders

Huh, maybe I already fixed it? Look for the insert into dailystats and see if it's using a hard-coded value for the entry. I may have fixed that as one of the first things I did.

[sanky@rikorisu jul]$ grep "dailystats" * -n --context 0 -r
install.sql:82:-- Table structure for table `dailystats`
install.sql:85:CREATE TABLE IF NOT EXISTS `dailystats` (
lib/layout.php:268:     mysql_query("INSERT INTO dailystats (date) VALUES ('".date('m-d-y',ctime())."')");
lib/layout.php:269:     mysql_query("UPDATE dailystats SET users=$count[u],threads=$count[t],posts=$count[p],views=$views WHERE date='".date('m-d-y',ctime())."'");
stats.php:82:   .tblinfo('dailystats')
stats.php:103:  $stats=mysql_query("SELECT * FROM dailystats");

Also I forgot to check subfolders previously, amending...

Done in my dateformat branch: Sanqui/jul@8b21339
Changes: Sanqui/jul@master...dateformat
Requires a database change in update.sql.

bleaugh