Location: PHPKode > projects > L-Forum > l-forum/read_thr.php
<?

include "config.php";
include "lib/init.inc";
include "lib/date_trans.inc";

$root = $r;

if(empty($r)){
   error_f($lang['no_mess_id']);
}
else{
   if($db_type=='mysql'){
      $timestamp = "UNIX_TIMESTAMP(time) as time";
      $limit = "$o, ".$forum_array[$f]['mpp'];
   }
   else if($db_type=='postgres'){
      $timestamp = "date_part('epoch', time) as time";
      $limit = $forum_array[$f]['mpp'].", $o";
   }

   $q=new Query("select id, level, author, email, subject, body, subs, root, views, attach, moderation_state, $timestamp from articles where moderation_state != 1 and root=$root order by time");
   if($q->nr()==0)
      error($lang['bad_res']);
   
   function make_list_recursive($mess_id){
      global $array, $out_array, $level, $type, $f, $open_thr, $forum_array;

      @$level[$array[$mess_id]['level']]++;

      $out_array[]=$mess_id;
      if(($array[$mess_id]['level']>0||@$open_thr[$f][$mess_id]==1||$type==1)){
         $subs = unserialize($array[$mess_id]['subs']);
         $parent = false;
         $newsubs = Array();
         $count = count($subs);
         for($i=0; $i<$count; $i++){
            if($forum_array[$f]['moderation']){
               if(isset($array[$subs[$i]]['moderation_state'])){
                  make_list_recursive($subs[$i]);
                  $newsubs[] = $subs[$i];
                  $parent = true;
               }
            }
            else
               make_list_recursive($subs[$i]);
         }
         if($forum_array[$f]['moderation']){
            $array[$mess_id]['is_parent'] = $parent;
            $array[$mess_id]['subs'] = serialize($newsubs);
         }
      }
   }

   if(empty($cookie_read))
      $ca = Array();
   else
      $ca = unserialize($cookie_read);

   while($row=$q->row()){
      $array[$row['id']]=$row;
      $ca[$row['id']]=1;
   }

   setcookie("cookie_read", serialize($ca), time()+99999999);
   
   $out_array = Array();
   $type = 1;

   make_list_recursive($root);

   echo str_replace("__TITLE__", $lang['read_message'], $design['head']);
   include "themes/".$theme."/header.inc";

   $count_out = count($out_array);
   for($x=0; $x<$count_out; $x++){
      $r = $array[$out_array[$x]];
      $newrows = $r['views']+1;
      if($count_view)
         $upqry=new Query("update articles set views=".$newrows." where id=".$r['id']);
      $date_arr = getdate($r['time']);
      $date = $lang[$dow[$date_arr['wday']]."_l"];
      $date .= ", ".$date_arr['mday']." ".$lang[$mth[$date_arr['mon']]."_l"]." ";
      $date .= $date_arr['year']." ";
      $date .= ($date_arr['hours']<10?"0".$date_arr['hours']:$date_arr['hours']).":";
      $date .= ($date_arr['minutes']<10?"0".$date_arr['minutes']:$date_arr['minutes']).":";
      $date .= ($date_arr['seconds']<10?"0".$date_arr['seconds']:$date_arr['seconds']);
?>
<table border=0 width="<?echo $design['readwidth']?>"><tr><td align=left>
<?
if($r['moderation_state']==2||$r['moderation_state']==3)
   echo "<div class=header>".$lang['msg_locked']."</div>";
else{
?>
<a href="new.php?f=<?echo $f?>&r=<?echo $r['id']?>" class=list><?echo $lang['reply']?></a>&nbsp;
<?
}
echo $design['readhead'] ?>

<tr><td bgcolor="<? echo $design['oddcolor'] ?>" class=readhead width=25%>
<? echo $lang['from'] ?>:</td><td  bgcolor="<? echo $design['oddcolor'] ?>">
<? echo $r['author'] ?></td></tr>
<tr><td bgcolor="<? echo $design['evencolor'] ?>" class=readhead>
<? echo $lang['email'] ?>:</td><td bgcolor="<? echo $design['evencolor'] ?>">
<? 
if(!empty($r['email']))
   echo "<a href=\"mailto:".hide_addr($r['email'])."\">".$r['email']."</a>";
else
   echo "&nbsp;";
?></td></tr>
<tr><td bgcolor="<? echo $design['oddcolor'] ?>" class=readhead>
<? echo $lang['date'] ?>:</td><td bgcolor="<? echo $design['oddcolor'] ?>">
<? echo $date ?></td></tr>
<tr><td bgcolor="<? echo $design['evencolor'] ?>" class=readhead>
<? echo $lang['subject'] ?>:</td><td bgcolor="<? echo $design['evencolor'] ?>">
<? echo $r['subject'] ?></td></tr>
<? if(!empty($r['attach'])){ ?>
<tr><td bgcolor="<? echo $design['oddcolor']?>" class=readhead>
<?echo $lang['att']?>:</td>
<td bgcolor="<? echo $design['oddcolor']?>">
<a href="upload/<?echo $r['id']?>" target="_blank"><?echo $r['attach']?></a>
 (<?echo filesize("upload/".$r['id'])." ".$lang['bytes']?>)
</td></tr>
<? } ?>
<tr><td bgcolor="<? echo $design['evencolor'] ?>" colspan=2>
<table border=0 width="100%"><tr><td bgcolor="<? echo $design['oddcolor'] ?>">
<? echo nl2br($r['body']);?>
</td></tr></table></td></tr>
<? echo $design['readfoot'] ?>
</td></tr></table><br>
<? } ?>
<div align=center><a class="list" href="<?
   if(ereg("last.php", $HTTP_REFERER))
      $ref = "last.php";
   else
      $ref = "list.php";
   echo "$ref?f=$f\">".$lang['back']."</a></div>";
   include "themes/".$theme."/footer.inc";
   echo $design['footer'];
}
?>
Return current item: L-Forum