[ PHPXref.com ] [ Generated: Sun Jul 20 20:01:31 2008 ] [ PHPWind 4.3.2 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/upload/ -> thread.php (source)

   1  <?php
   2  define('SCR','thread');
   3  require_once ('global.php');
   4  require_once (R_P.'require/forum.php');
   5  require_once (R_P.'require/updateforum.php');
   6  
   7  $foruminfo = $db->get_one("SELECT f.*,fe.creditset,fe.forumset,fd.topic,fd.top1,fd.top2,a.aid,a.author,a.startdate,a.subject,a.content FROM pw_forums f LEFT JOIN pw_forumsextra fe ON fe.fid=f.fid LEFT JOIN pw_forumdata fd ON fd.fid=f.fid LEFT JOIN pw_announce a ON a.ffid=f.fid WHERE f.fid='$fid'");
   8  $forumset  = unserialize($foruminfo['forumset']);
   9  $forumset['newtime'] && $db_newtime=$forumset['newtime'];
  10  $forumset['link'] && ObHeader($forumset['link']);
  11  $foruminfo['type']=='category' && ObHeader("index.php?cateid=$fid");
  12  
  13  unset($searchadd,$thread_children,$thread_online,$fastpost);
  14  if(!$foruminfo){
  15      require_once (R_P.'require/url_error.php');
  16  }
  17  wind_forumcheck($foruminfo);
  18  
  19  include_once(D_P.'data/bbscache/forum_cache.php');
  20  $forumname=$forum[$foruminfo['fid']]['name'];
  21  require_once (R_P.'require/header.php');
  22  
  23  $ajaxcheck = $groupid == 3 ? 1 : 0;
  24  if($windid==$manager){
  25      $admincheck=1;
  26      $ajaxcheck=1;
  27  } elseif($foruminfo['forumadmin'] && strpos($foruminfo['forumadmin'],','.$windid.',')!==false){
  28      $admincheck=1;
  29      $ajaxcheck=1;
  30  } elseif($groupid!=5 && ($SYSTEM['tpctype'] || $SYSTEM['check'] || $SYSTEM['typeadmin'] || $SYSTEM['delatc'] || $SYSTEM['moveatc'] || $SYSTEM['copyatc'] || $SYSTEM['topped'])){
  31      $admincheck=1;
  32  } else{
  33      $admincheck=0;
  34  }
  35  !$windid && $admincheck = 0;
  36  if ($windid != $manager && $groupid != 3 && !$foruminfo['allowvisit'] && (!$foruminfo['forumadmin'] || strpos($foruminfo['forumadmin'],','.$windid.',')===false)){
  37      list($db_moneyname,,$db_rvrcname,,$db_creditname,)=explode("\t",$db_credits);
  38      forum_creditcheck();
  39  }
  40  
  41  $adminarray='';
  42  $adminarray=explode("\t",$foruminfo['forumadmin']);
  43  if($adminarray[0]){
  44      $forumadmin=explode(",",$adminarray[0]);
  45      foreach($forumadmin as $key => $value){
  46          if($value){
  47              if(!$db_adminshow){
  48                  if ($key==10) {$admin_T['admin'].='...'; break;}
  49                  $admin_T['admin'].="<a href=profile.php?action=show&username=".rawurlencode($value).">$value</a> ";
  50              } else{
  51                  $admin_T['admin'].="<option value=$value>$value</option>";
  52              }
  53          }
  54      }
  55      $admin_T['admin']='&nbsp;'.$admin_T['admin'];
  56  }
  57  Update_ol();
  58  if($db_threadonline==1){
  59      $trd_hide=$trd_nothide=$trd_guest=0;
  60      $guestarray=readover(D_P.'data/bbscache/guest.php');
  61      $detail=explode("<FiD>$fid\t",$guestarray);
  62      $trd_guest=count($detail)-1;
  63      $onlinearray=openfile(D_P.'data/bbscache/online.php');
  64      $count_ol=count($onlinearray);
  65      for($i=1; $i<$count_ol; $i++){
  66          $detail=explode("\t",$onlinearray[$i]);
  67          if ($detail[3]==$fid){
  68              if(strpos($db_showgroup,",".$detail[5].",")!==false){
  69                  $img=$detail[5];
  70              } else{
  71                  $img='6';
  72              }
  73              if($trd_nothide%8==0)$trd_onlineinfo.="</tr><tr>";
  74              if($detail[9]=='<>') {$trd_hide++; continue;} else $trd_nothide++;
  75              $trd_onlineinfo.="<td width=12%>&nbsp;<img src='$imgpath/$stylepath/group/$img.gif' align='bottom'><a href=profile.php?action=show&uid=$detail[8]>$detail[0]</a></td>";
  76          }
  77      }
  78      unset($guestarray,$detail);
  79      $trd_sumonline2=$trd_nothide+$trd_guest+$trd_hide;
  80      $trd_sumonline1=$trd_nothide+$trd_hide;
  81      $thread_online='thread_online';
  82  }
  83  
  84  $guidename=forumindex($foruminfo['fup']);
  85  $msg_guide=headguide($guidename);
  86  include_once(D_P.'data/bbscache/thread_announce.php');
  87  $ifsort=0;
  88  $NT_A=$NT_C=array();
  89  if($notice_A){
  90      $ifsort=1;
  91      $NT_A=array_shift($notice_A);
  92      $NT_A['rawauthor']=rawurlencode($NT_A['author']);
  93      $NT_A['startdate']=get_date($NT_A['startdate']);
  94  }
  95  if($notice_C[$cateid]){
  96      $ifsort=1;
  97      $NT_C=$notice_C[$cateid];
  98      $NT_C['rawauthor']=rawurlencode($NT_C['author']);
  99      $NT_C['startdate']=get_date($NT_C['startdate']);
 100  }
 101  
 102  if($foruminfo['aid']){
 103      $foruminfo['rawauthor']=rawurlencode($foruminfo['author']);
 104      $foruminfo['startdate']=get_date($foruminfo['startdate']);
 105      $foruminfo['content']=str_replace("\n","<br>",$foruminfo['content']);
 106  }
 107  
 108  if(strpos($_COOKIE['deploy'],"\t".thread."\t")===false){
 109      $thread_img='fold';
 110  }else{
 111      $thread_img='open';
 112      $cate_thread='display:none;';
 113  }
 114  $forumdb=array();
 115  if($foruminfo['childid']){
 116  
 117      $adminarray='';
 118      $query = $db->query("SELECT f.fid,f.logo,f.name, f.descrip,f.forumadmin,f.password,f.allowvisit,f.f_type,fd.tpost,fd.topic,fd.article,fd.subtopic,fd.lastpost FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.fup='$fid' ORDER BY f.vieworder");
 119      while($child = $db->fetch_array($query)) {
 120  
 121          if(empty($child['allowvisit']) || strpos($child['allowvisit'],','.$groupid.',')!==false){
 122  
 123              list($f_a,$child['au'],$f_c,$child['ft'])=explode("\t",$child['lastpost']);
 124              $child['pic'] = $winddb['lastvisit']<$f_c && ($f_c+172800>$timestamp) ? 'new' : 'old';
 125              $child['newtitle']=get_date($f_c);
 126              $child['t']=substrs($f_a,21);
 127          } else{
 128              if($child['f_type']==='hidden'){
 129                  continue;
 130              }
 131              $child['pic']="lock";
 132          }
 133          $child['topics']=$child['topic']+$child['subtopic'];
 134          if($db_indexfmlogo==2){
 135              $child['logo']!='' ? $child['logo']="<img align=left src=$child[logo] border=0>":'';
 136          } elseif($db_indexfmlogo==1){
 137              $forumlogofile="$stylepath/forumlogo/$child[fid].gif";
 138              file_exists("$imgdir/$forumlogofile") && $child['logo']="<img align=left src='$imgpath/$forumlogofile' border=0>";
 139          }
 140          $adminarray=explode("\t",$child['forumadmin']);
 141          if($adminarray[0]){
 142              $forumadmin=explode(",",$adminarray[0]);
 143              foreach($forumadmin as $key=> $value){
 144                  if($value){
 145                      if(!$db_adminshow){
 146                          //if ($key==4) {$child['admin'].='...'; break;}

 147                          $child['admin'].="<a href=profile.php?action=show&username=".rawurlencode($value).">$value</a> ";
 148                      } else{
 149                          $child['admin'].="<option value=$value>$value</option>";
 150                      }
 151                  }
 152              }
 153              $db_adminshow && $child['admin'].='</select>';
 154          }
 155          $forumdb[]=$child;
 156      }
 157      $db->free_result($query);
 158      $forumdb && $thread_children='thread_children';
 159      if($foruminfo['viewsub']==1){
 160          require_once PrintEot('thread_childmain');footer();
 161      }
 162  }
 163  
 164  if ($admincheck){
 165      !$_GET['managemode'] && $managemode=GetCookie('managemode');
 166      if($concle==1){
 167          $concle=2;    $managemode=1;
 168          Cookie("managemode","1",0);
 169      }elseif($concle==2){
 170          $concle=1;    $managemode='';
 171          Cookie("managemode","",0);
 172      }elseif(!$managemode){
 173          $concle=1;
 174      }elseif($managemode){
 175          $concle=2;
 176      }
 177      $trd_adminhide="<form action=mawhole.php method=post><input type=hidden name=fid value=$fid>";
 178  }
 179  
 180  $t_typedb=array();
 181  $t_db=$foruminfo['t_type'];
 182  $t_db && $t_typedb=explode("\t",$t_db);
 183  unset($t_typedb[0]);/* 0 */
 184  if($t_db && is_numeric($type) && isset($t_typedb[$type])){
 185      $searchadd=" AND type='$type' AND ifcheck='1'";
 186      $typeadd="type=$type&";
 187      $rs=$db->get_one("SELECT COUNT(*) AS count FROM pw_threads WHERE fid='$fid' $searchadd");
 188      $count=$rs['count'];
 189  } elseif($search=='digest'){
 190      $searchadd=" AND digest>'0' AND ifcheck='1'";
 191      $rs=$db->get_one("SELECT COUNT(*) AS count FROM pw_threads WHERE fid='$fid' $searchadd");
 192      $count=$rs['count'];
 193  } elseif($search=='check'){
 194      if($admincheck){
 195          $searchadd=" AND ifcheck='0'";
 196      }else{
 197          $searchadd=" AND authorid='$winduid' AND ifcheck='0'";
 198      }
 199      $rs=$db->get_one("SELECT COUNT(*) AS count FROM pw_threads WHERE fid='$fid' $searchadd");
 200      $count=$rs['count'];
 201  } elseif(is_numeric($search)){
 202      $searchadd=" AND lastpost>='".($timestamp - $search*84600)."' AND ifcheck='1'";    
 203      $rs=$db->get_one("SELECT COUNT(*) AS count FROM pw_threads WHERE fid='$fid' $searchadd");
 204      $count=$rs['count'];
 205  }else{
 206      $searchadd=" AND ifcheck='1'";
 207      $count=$foruminfo['topic'];
 208  }
 209  if ($winddb['t_num']){
 210      $db_perpage = $winddb['t_num'];
 211  } elseif ($forumset['threadnum']){
 212      $db_perpage = $forumset['threadnum'];
 213  }
 214  if ($winddb['p_num']){
 215      $db_readperpage = $winddb['p_num'];
 216  } elseif ($forumset['readnum']){
 217      $db_readperpage = $forumset['readnum'];
 218  }
 219  
 220  $tpcdb=array();
 221  
 222  $db_maxpage && $page > $db_maxpage && $page=$db_maxpage;
 223  (!is_numeric($page) || $page < 1) && $page=1;
 224  
 225  if($db_recycle && $fid==$db_recycle){
 226      $sql="fid='$fid'";
 227  } elseif($db_topped && $foruminfo['top1']){
 228      $sql="fid='$fid' AND topped=0";
 229      $topadd='';   ///

 230      $count+=$foruminfo['top1'];
 231  } else{
 232      $sql="fid='$fid'";
 233      $topadd='topped DESC,';
 234  }
 235  $orderway ? $w_add="orderway=$orderway&asc=$asc&" : $w_add='';
 236  if($gp_alloworder){
 237      if($orderway!='lastpost' && $orderway!='postdate' && $orderway!='hits' && $orderway!='replies'){
 238          $orderway='lastpost';
 239      }
 240      $ordersel[$orderway]='selected';
 241      $asc!='DESC' && $asc!='ASC' && $asc = 'DESC';
 242      $ascsel[$asc]='selected';
 243  } else{
 244      $asc = 'DESC';
 245      $orderway='lastpost';
 246  }
 247  
 248  $numofpage=ceil($count/$db_perpage);
 249  $totlepage=$numofpage;
 250  if ($numofpage && $page>$numofpage){
 251      $page=$numofpage;
 252  }
 253  
 254  $start_limit = ($page - 1) * $db_perpage;
 255  
 256  $R=0;
 257  if($db_topped && $foruminfo['top1']){
 258      $rows=$foruminfo['top1']+$foruminfo['top2'];
 259      if($start_limit < $rows){
 260          $L=min($rows-$start_limit,$db_perpage);
 261          $limit="LIMIT $start_limit,$L";
 262          if($L == $db_perpage){
 263              $limit2="";
 264          } else{
 265              $limit2="LIMIT 0,".($db_perpage-$L);
 266          }
 267          $fids=getfids($fid);
 268          $query=$db->query("SELECT * FROM pw_threads WHERE topped=3 OR (topped=2 AND fid IN($fids)) OR (topped=1 AND fid='$fid') ORDER BY topped DESC,lastpost DESC $limit");
 269          while($rt=$db->fetch_array($query)){
 270              $tpcdb[]=$rt;
 271          }
 272      } else{
 273          $limit2="LIMIT ".($start_limit-$rows).",$db_perpage";
 274      }
 275  } else{
 276      $limit2="LIMIT $start_limit,$db_perpage";
 277  }
 278  
 279  $pages=numofpage($count,$page,$numofpage,"thread.php?fid=$fid&search=$search&$w_add$typeadd",$db_maxpage);
 280  $orderway.=' '.$asc;
 281  
 282  $attachtype=array(
 283      '1'=>'img',
 284      '2'=>'txt',
 285      '3'=>'zip'
 286      );
 287  
 288  if($limit2){
 289      $query = $db->query("SELECT * FROM pw_threads WHERE $sql $searchadd ORDER BY $topadd $orderway $limit2");
 290      while($thread = $db->fetch_array($query)) {
 291          $tpcdb[]=$thread;
 292      }
 293  }
 294  
 295  $threaddb=array();
 296  foreach($tpcdb as $key => $thread){
 297      $foruminfo['allowhtm']==1 && $htmurl=$htmdir.'/'.$fid.'/'.date('ym',$thread['postdate']).'/'.$thread['tid'].'.html';
 298      $thread['tpcurl']="read.php?tid=$thread[tid]".($page>1 ? "&fpage=$page" : '');
 299      if($managemode==1){
 300          $thread['tpcurl'].='&toread=1';
 301      } elseif(!$foruminfo['cms'] && $foruminfo['allowhtm']==1 && file_exists(R_P.$htmurl)){
 302          $thread['tpcurl']="$htmurl";
 303      }
 304      $forumset['cutnums'] && $thread['subject'] = substrs($thread['subject'],$forumset['cutnums']);
 305      if ($thread['titlefont']){
 306          $titledetail=explode("~",$thread['titlefont']);
 307          if($titledetail[0])$thread['subject']="<font color=$titledetail[0]>$thread[subject]</font>";
 308          if($titledetail[1])$thread['subject']="<b>$thread[subject]</b>";
 309          if($titledetail[2])$thread['subject']="<i>$thread[subject]</i>";
 310          if($titledetail[3])$thread['subject']="<u>$thread[subject]</u>";
 311      }
 312      if($thread['ifmark']){
 313          $thread['ifmark']=$thread['ifmark']>0 ? " ( +$thread[ifmark] ) " : " ( $thread[ifmark] ) ";
 314      } else{
 315          unset($thread['ifmark']);
 316      }
 317      if($thread['pollid']&&$thread['locked']==0){
 318          $thread['status']="<img src='$imgpath/$stylepath/thread/vote.gif' border=0>";
 319      } elseif($thread['pollid']&&$thread['locked']>0){
 320          $thread['status']="<img src='$imgpath/$stylepath/thread/votelock.gif' border=0>";
 321      } else{
 322          if ($thread['locked']==1){
 323              $thread['status']="<img src='$imgpath/$stylepath/thread/topiclock.gif' border=0>";
 324          } elseif ($thread['locked']==2){
 325              $thread['status']="<img src='$imgpath/$stylepath/thread/topicclose.gif' border=0>";
 326          } elseif ($thread['replies']>=10){
 327              $thread['status']="<img src='$imgpath/$stylepath/thread/topichot.gif' border=0>";
 328          } else{
 329              $thread['status']="<img src='$imgpath/$stylepath/thread/topicnew.gif' border=0>";
 330          }
 331      }
 332      if($thread['topped'] && $thread['toolinfo'] != '' && $thread['toolfield']){
 333          if($timestamp > $thread['toolfield']){
 334              $db->update("UPDATE pw_threads SET toolinfo='',toolfield=0,topped=0 WHERE tid='$thread[tid]'");
 335          }
 336      }
 337      $thread['topped'] && $ifsort=1;
 338  
 339      $thread['ispage']='';
 340      if ($thread['replies']+1>$db_readperpage)
 341      {
 342          if (($thread['replies']+1)%$db_readperpage==0){
 343              $numofpage=($thread['replies']+1)/$db_readperpage;
 344          } else{
 345              $numofpage=floor(($thread['replies']+1)/$db_readperpage)+1;
 346          }
 347          $thread['ispage']=' ';
 348          $thread['ispage'].="[ <img src='$imgpath/$stylepath/file/multipage.gif' border=0><span style='font-size:7pt;font-family:verdana;'>";
 349          for ($j=1; $j<=$numofpage; $j++){
 350              if ($j==6 && $j+1<$numofpage){
 351                  $thread['ispage'].=" .. <a href='read.php?tid=$thread[tid]&page=$numofpage&fpage=$page'>$numofpage</a>";
 352                  break;
 353              }
 354              $thread['ispage'].=" <a href='read.php?tid=$thread[tid]&page=$j&fpage=$page'>$j</a>";
 355          }
 356          $thread['ispage'].='</span> ]';
 357      }
 358      $thread['postdate']=get_date($thread['postdate'],'Y-m-d');
 359      $postdetail=explode(",",$thread['lastpost']);
 360  
 361      if($thread['ifupload']){
 362          $atype=$attachtype[$thread['ifupload']];
 363          $thread['titleadd']=" <img src='$imgpath/$stylepath/file/$atype.gif' align='absbottom' border=0>";
 364      } else{
 365          $thread['titleadd']="";
 366      }
 367