Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues
Author Message
khaled_dxb
Regular
Regular



Joined: Jan 15, 2007
Posts: 66

PostPosted: Tue Oct 28, 2008 11:10 am Reply with quote

I have enabled the latest posts on the home page of the site.

I've noticed that the Last Post date/time value does not reflect the current user's timezone information.

it is ALWAYS the last post according to the hosting server's date/time.

Any idea where / how to change this so that it is consistent with what the user has configured as their timezone info?

Thanks.

_________________
Khaled 
View user's profile Send private message
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Tue Oct 28, 2008 11:15 am Reply with quote

In order to be consistent it might be better to leave it at the sever time otherwise you might have other issues such as users posting 'before' the server time due to their local time zone.
Users timezone is only relevant to the Forums module otherwise the server timezone is used throughout the rest of nuke.
 
View user's profile Send private message Send e-mail
khaled_dxb







PostPosted: Tue Oct 28, 2008 11:19 am Reply with quote

well i thought the latest posts block would be part of the forums module?
There are other areas where the server time is visible (albeit only to admins) but the latest posts are what probably all my users look at when they first hit the site, that's the only place i'd like it to be changed, otherwise in other locations it's no issue.
 
Guardian2003







PostPosted: Tue Oct 28, 2008 11:25 am Reply with quote

Oops, yes your right, I was thinking 'news' posts not 'forum' posts (no idea why).
It could be done but it might be expensive in terms of server resources used because you would need to look up every users timezone etc.
Unfortunately it isn't something I have the time to look into right at this moment.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Oct 28, 2008 6:12 pm Reply with quote

Actually, it only needs the current user's timezone and then convert all the server datetimestamps to that user's timezone.

What forum block are you using because I could have sworn this worked just fine.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
khaled_dxb







PostPosted: Wed Oct 29, 2008 4:15 am Reply with quote

Montego, i'm using the one that comes with RN? is there another one?
 
Guardian2003







PostPosted: Wed Oct 29, 2008 4:58 am Reply with quote

The standard RN forum block should display the forums posts in the order they were posted as it sorts the result by 'topic time' which infers that one or more of your users have not set their local time in their forum profile. The time stamp in the forum profile is used to compensate for any discrepancy between their time and the server time I think but I'll try anf investigate if I get some time
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Oct 29, 2008 9:27 pm Reply with quote

khaled_dxb] what block are you using? Are you using the one on the front of this site?
 
View user's profile Send private message
khaled_dxb







PostPosted: Thu Oct 30, 2008 10:03 am Reply with quote

Palbin wrote:
khaled_dxb] what block are you using? Are you using the one on the front of this site?


The block is called Latest Posts - i think the one being used here is the News Block.
 
Palbin







PostPosted: Thu Oct 30, 2008 10:46 am Reply with quote

Can you post the code here. I am not sure what block you are talking about.
 
khaled_dxb







PostPosted: Thu Oct 30, 2008 11:10 am Reply with quote

Ok, so thanks to you i've just realised that the block is a customised block that is specific to the theme i'm using - so probably not a bug at all... sorry - please move to appropriate forum.

The code is below, and i can see that $result3 is where the time is being selected from the database, however i'm not sure how to modify it so that it takes into consideration the user's timezone value.

Code:


<?php
if (eregi("block-fiblack3d-Forum.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
   
global $prefix, $db, $sitename, $admin;

$HideViewReadOnly = 1;
          
$Last_New_Topics  = 10;
$show = "  <tr>
    <td height=\"28\" colspan=\"6\" align=\"center\" class=\"cat\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$Topic_Buffer = "";
$result = $db->sql_query( "SELECT t.topic_id, f.forum_name, f.forum_id, t.topic_last_post_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_moved_id FROM ".$prefix."_bbtopics t, ".$prefix."_bbforums f where t.forum_id=f.forum_id ORDER BY topic_last_post_id DESC" );
while( list( $topic_id, $forum_name, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = $db->sql_fetchrow( $result ) )

{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $result1 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'" );
      list( $auth_view, $auth_read ) = $db->sql_fetchrow( $result1 );
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }

   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }
   
   if( $skip_display == 0 )
   {
     $Count_Topics += 1;

$result2 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'");
list($username, $user_id)=$db->sql_fetchrow($result2);
$avtor=$username;
$sifra=$user_id;

$result3 = $db->sql_query("SELECT poster_id, FROM_UNIXTIME(post_time,'%b %d, %Y at %T') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'");
list($poster_id, $post_time)=$db->sql_fetchrow($result3);

$result4 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'");
list($username, $user_id)=$db->sql_fetchrow($result4);

                         $viewlast .="  <tr>
    <td align=\"center\" height=\"30\" width=\"35\" nowrap class=\"row1\"><img src=\"themes/fiblack3d/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" class=\"row1\">&nbsp;<b>$forum_name</b><br>&nbsp;&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">$topic_title</a></td>
    <td align=\"center\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
    <td align=\"center\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap class=\"row3\"><font size=\"-2\"><i>&nbsp;&nbsp;$post_time&nbsp;</i></font><br>
      <a href=\"profile-.html$user_id\">$username</a>&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\"><img src=\"themes/fiblack3d/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Last Post\"></a></td>
  </tr>";
}
   
   if( $Last_New_Topics == $Count_Topics ) { break 1; }
   
}

    $content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#000000\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"forumline\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap class=\"thcornerl\"><font color=\"#8E8E8E\"><strong>Forum/Topic</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap class=\"thtop\"><font color=\"#8E8E8E\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap class=\"thtop\"><font color=\"#8E8E8E\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap class=\"thtop\"><font color=\"#8E8E8E\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap class=\"thcornerr\"><font color=\"#8E8E8E\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr>";
    $content .= "$viewlast";

 $content .= "$show";

?>
 
Guardian2003







PostPosted: Thu Oct 30, 2008 4:18 pm Reply with quote

Try...
Look for the first line starting with $result
Follow that code until you get to ORDER BY topic_last_post_id and try changing it to ORDER BY topic_time
If that works for you you might want to add
Code:


if(empty($content)) $content = '';
if(empty($vewlast)) $viewlast = '';

Under the first line starting with global to clean up the two errors that are there.
 
Palbin







PostPosted: Thu Oct 30, 2008 7:23 pm Reply with quote

The Block should now display the post time correctly in regard to the users timezone.

Code:
<?php 

if (!defined('BLOCK_FILE')) {
   Header('Location: ../index.php');
   die();
}
   
global $admin, $cookie, $db, $prefix, $user_prefix, $sitename, $ThemeSel, $user, $userinfo;

$content = '';
$viewlast = '';

$HideViewReadOnly = 1;
$Last_New_Topics  = 10;

// Calculate posting time offset for user defined timezones
$serverTimeZone = date("Z")/3600;

if ($serverTimeZone >= 0) $serverTimeZone = "+".$serverTimeZone;

if (is_user($user)) {
   cookiedecode($user);
   $uid = $cookie[0];
   $name = $cookie[1];
   
   $userinfo = getusrinfo($user);
   $userTimeZone = $userinfo['user_timezone'];
   $userDateFormat = $userinfo['user_dateformat'];
}
else {
   $uid = 1;
   $name = "$anonymous";

   $sql  = "SELECT v1.config_value , v2.config_value  FROM ".$prefix."_bbconfig v1, ".$prefix."_bbconfig v2  WHERE v1.config_name='board_timezone' and v2.config_name='default_dateformat' ";
   $result = $db->sql_query($sql);
   list($userTimeZone, $userDateFormat) = $db->sql_fetchrow($result);
}

$userTimeZone = ($userTimeZone - $serverTimeZone)*3600;

if (!is_numeric($userTimeZone)) $userTimeZone = 0;

$show = "  <tr>
    <td height=\"28\" colspan=\"6\" align=\"center\" class=\"cat\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$Topic_Buffer = "";

$result = $db->sql_query( "SELECT t.topic_id, f.forum_name, f.forum_id, t.topic_last_post_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_moved_id FROM ".$prefix."_bbtopics t, ".$prefix."_bbforums f where t.forum_id=f.forum_id ORDER BY topic_last_post_id DESC" );
while( list( $topic_id, $forum_name, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = $db->sql_fetchrow( $result ) ) {
   $skip_display = 0;
   if( $HideViewReadOnly == 1 ) {
      $result1 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'" );
      list( $auth_view, $auth_read ) = $db->sql_fetchrow( $result1 );
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }

   if( $topic_moved_id != 0 ) {
      // Shadow Topic !!
      $skip_display = 1;
   }
   
   if( $skip_display == 0 ) {
      $Count_Topics += 1;

      $result2 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'");
      list($username, $user_id)=$db->sql_fetchrow($result2);
      $avtor=$username;
      $sifra=$user_id;

      $result3 = $db->sql_query("SELECT poster_id, post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'");
      list($poster_id, $post_time)=$db->sql_fetchrow($result3);

      $result4 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'");
      list($username, $user_id)=$db->sql_fetchrow($result4);

      $post_time = date($userDateFormat, ($post_time + $userTimeZone));

      $viewlast .="  <tr>
          <td align=\"center\" height=\"30\" width=\"35\" nowrap=\"nowrap\" class=\"row1\"><img src=\"themes/$ThemeSel/forums/images/folder_new.gif\" border=\"0\" /></td>
          <td width=\"100%\" class=\"row1\">&nbsp;<b>$forum_name</b><br />&nbsp;&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">$topic_title</a></td>
          <td align=\"center\" class=\"row2\">$topic_replies</td>
          <td align=\"center\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
          <td align=\"center\" class=\"row2\">$topic_views</td>
          <td align=\"center\" nowrap=\"nowrap\" class=\"row3\"><font size=\"-2\"><i>&nbsp;&nbsp;$post_time&nbsp;</i></font><br />
            <a href=\"profile-.html$user_id\">$username</a>&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\"><img src=\"themes/$ThemeSel/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Last Post\" /></a></td>
        </tr>";
   }
   
   if( $Last_New_Topics == $Count_Topics ) { break 1; }
}

    $content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#000000\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"forumline\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap=\"nowrap\" class=\"thcornerl\"><font color=\"#8E8E8E\"><strong>Forum/Topic</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap=\"nowrap\" class=\"thtop\"><font color=\"#8E8E8E\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap=\"nowrap\" class=\"thtop\"><font color=\"#8E8E8E\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap=\"nowrap\" class=\"thtop\"><font color=\"#8E8E8E\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap=\"nowrap\" class=\"thcornerr\"><font color=\"#8E8E8E\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr>";

   $content .= "$viewlast";
   $content .= "$show";
?>
 
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6437

PostPosted: Thu Oct 30, 2008 7:42 pm Reply with quote

Palbin, thanks.

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
khaled_dxb







PostPosted: Fri Oct 31, 2008 1:51 am Reply with quote

Thanks Palbin,

Although i'm curious why to changed the links from .php to .html? since now when you click on the actual link, it doesnt go anywhere...

For example, look below for the difference between the previous block and your modified block.

http://corp.com/modules.php?name=Forums&file=viewtopic&p=13876#13876

http://staging/rn2300/forums.html?file=viewtopic&p=11774#11774

I Modified the code to reflect the above and it's working perfectly - thanks ALOT!
 
Palbin







PostPosted: Fri Oct 31, 2008 5:35 am Reply with quote

I have no idea how that happened very strange. I reason it is in my code is because that is the way it was in your code Smile. Must have something to do with Shortlinks.
 
Palbin







PostPosted: Fri Oct 31, 2008 5:39 am Reply with quote

Test Post

<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">

Code:
<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">



**EDIT**
That SUCKS Shortlinks shortens the links in posted code Sad

Anyway to get around that or make it stop happening?
 
Guardian2003







PostPosted: Fri Oct 31, 2008 6:37 am Reply with quote

We normally link to a plain text file when posting substantial amounts of code like but I had not though about the code being re-written before.
 
kguske







PostPosted: Fri Oct 31, 2008 6:43 am Reply with quote

I'm not sure if ShortLinks supports the modified version of NSN News, but I asked montego to take a look at this.
 
montego







PostPosted: Sat Nov 01, 2008 12:21 pm Reply with quote

All I have to offer is what this individual has submitted by way of additional taps:

http://montegoscripts.com/ftopict-203.html
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©