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

title

Body

[close]

/upload/ -> search.php (source)

   1  <?php
   2  $wind_in = 'sc';
   3  require_once ('global.php');
   4  @set_time_limit(0);
   5  $gp_allowsearch == 0 && Showmsg('search_group_right');
   6  
   7  list($db_opensch,$db_schstart,$db_schend) = explode("\t",$db_opensch);
   8  if($db_opensch==1 && $groupid != 3 && $groupid != 4){
   9      if($db_schstart < $db_schend && ($t['hours'] < $db_schstart || $t['hours'] >= $db_schend)){
  10          Showmsg('search_opensch');
  11      }elseif($db_schstart > $db_schend && ($t['hours'] < $db_schstart && $t['hours'] >= $db_schend)){
  12          Showmsg('search_opensch');
  13      }
  14  }
  15  
  16  include_once(D_P.'data/bbscache/forum_cache.php');
  17  include_once(D_P.'data/bbscache/forumcache.php');
  18  
  19  $forumadd = '';
  20  $fidout = '-999';
  21  $query    = $db->query("SELECT fid,name,allowvisit,password,f_type FROM pw_forums WHERE type<>'category'");
  22  while($forums = $db->fetch_array($query)){
  23      if ($forums['f_type'] == 'hidden' && strpos($forums['allowvisit'],','.$groupid.',') !== false){
  24          $forumadd.="<option value='$forums[fid]'> &nbsp;|- $forums[name]</option>";
  25      } elseif ($forums['password'] || ($forums['allowvisit'] && strpos($forums['allowvisit'],','.$groupid.',') === false)){
  26          $forumcache = preg_replace("/\<option value='$forums[fid]'\>(.+?)\<\/option\>\\n/is",'',$forumcache);
  27          $fidout .= ','.$forums['fid'];
  28      }
  29  }
  30  $db->free_result($query);
  31  
  32  unset($forums);
  33  $keyword = Char_cv($keyword);
  34  
  35  require_once (R_P.'require/header.php');
  36  
  37  if ($newatc == 1 || is_numeric($authorid) || $digest == 1){
  38      $step = 2;
  39  }
  40  if(!$step){
  41      list($f,$db_searchinfo)=explode("\t",readover(D_P.'data/bbscache/info.txt'));
  42      $disable = $gp_allowsearch == 1 ? 'disabled' : '';
  43      require_once PrintEot('search');
  44      footer();
  45  }else{
  46      $_POST && empty($keyword) && empty($pwuser) && $sch_time == 'all' && Showmsg('no_condition');
  47  
  48      $seekfid = $s_type == 'all' ? 'all':($s_type == 'forum' ? $f_fid : $c_fid);
  49      $admincheck = 0;
  50      if (is_numeric($seekfid)){
  51          $rt = $db->get_one("SELECT forumadmin FROM pw_forums WHERE fid='$seekfid'");
  52          if ($windid == $manager){
  53              $admincheck = 1;
  54          } elseif ($rt['forumadmin'] && strpos($rt['forumadmin'],','.$windid.',') !== false){
  55              $admincheck = 1;
  56          } elseif ($groupid != 5 && ($SYSTEM['tpctype'] || $SYSTEM['delatc'] || $SYSTEM['moveatc'] || $SYSTEM['copyatc'])){
  57              $admincheck = 1;
  58          }
  59      }
  60  
  61      $keyword  && strlen($keyword) <= 2  && Showmsg('search_word_limit');
  62      $authorid && !is_numeric($authorid) && Showmsg('user_not_exists');
  63      !is_numeric($sch_area) && $sch_area = 0;
  64      $method   = $method == 'AND' ? 'AND' : 'OR';
  65      $schline  = trim($keyword).'|'.trim($method).'|'.trim($sch_area).'|'.trim($seekfid).'|'.trim($pwuser).'|'.trim($authorid).'|'.trim($sch_time).'|'.trim($digest);
  66      $orderway = ($orderway == 'replies' || $orderway == 'hits') ? $orderway : 'lastpost';
  67      $asc      = $asc == 'ASC'? 'ASC' :'DESC';
  68      $orderby  = "ORDER BY $orderway $asc";
  69      $schedid  = '';
  70  
  71      if (isset($_GET['sid']) && $_GET['sid']){
  72          @extract($db->get_one("SELECT schtime,total,schedid FROM pw_schcache WHERE sid='$sid'"));
  73      } else {
  74          if (!$authorid){
  75              @extract($db->get_one("SELECT sid,schline AS schlinee, schtime,total,schedid FROM pw_schcache WHERE schline='$schline' LIMIT 1"));
  76          }
  77          if($newatc && $timestamp - $schtime > 1800){
  78              $db->update("DELETE FROM pw_schcache WHERE sid='$sid'");
  79              $schedid = '';
  80          }
  81          if (empty($schedid)){
  82              $cachetime = 3600;
  83              $db->update("DELETE FROM pw_schcache WHERE schtime<$timestamp-$cachetime");
  84              if ($_POST && $gp_searchtime != 0){
  85                  if ($timestamp - GetCookie('lasttime') < $gp_searchtime){
  86                      Showmsg('search_limit');
  87                  }
  88                  Cookie('lasttime',$timestamp,0);
  89              }
  90              if (is_numeric($seekfid)){
  91                  if ($forum[$seekfid]['type'] == 'category'){
  92                      Showmsg('search_cate');
  93                  }
  94                  if (strpos(','.$fidout.',',','.$seekfid.',')  === false){
  95                      $sqlwhere = "t.fid='$seekfid' AND ifcheck=1 ";
  96                  } else{
  97                      Showmsg('search_forum_right');
  98                  }
  99              } else{
 100                  $sqlwhere = "t.fid NOT IN ($fidout) AND ifcheck=1 ";
 101              }
 102  
 103              if ($sch_area == '1' && $gp_allowsearch == 2){
 104                  $sqltable = "pw_threads t LEFT JOIN pw_tmsgs tm ON tm.tid=t.tid";
 105              } elseif ($sch_area == '2' && $gp_allowsearch == 2){
 106                  $sqltable = "pw_posts t";
 107                  $orderby  = "ORDER BY tid $asc";
 108              } else{
 109                  $sqltable = "pw_threads t";
 110              }
 111  
 112              unset($uids);
 113              if ($keyword){
 114                  $keyword      = str_replace("%",'\%',$keyword);
 115                  $keyword      = str_replace("_",'\_',$keyword);
 116                  $keyword      = trim($keyword);
 117                  $keywordarray = explode("|",$keyword);
 118                  unset($keywhere);
 119                  foreach($keywordarray as $value){
 120                      if ($value){
 121                          $value     = addslashes($value);
 122                          $keywhere .= $method;
 123                          if ($sch_area == '0'){
 124                              $keywhere .= " t.subject LIKE '%$value%'";
 125                          } elseif ($sch_area == '1' && $gp_allowsearch == 2){
 126                              $keywhere .= " (t.subject LIKE '%$value%' OR tm.content LIKE '%$value%') ";
 127                          } elseif ($sch_area == '2' && $gp_allowsearch == 2){
 128                              $keywhere .= " (t.subject LIKE '%$value%' OR t.content LIKE '%$value%') ";
 129                          }
 130                      }
 131                  }
 132                  if ($keywhere){
 133                      $keywhere = substr_replace($keywhere,"",0,3);
 134                      $keywhere && $sqlwhere .= "AND ($keywhere)";
 135                  } else{
 136                      Showmsg('illegal_keyword');
 137                  }
 138              }elseif ($pwuser){
 139                  if (!str_replace('*','',$pwuser)){
 140                      Showmsg('illegal_author');
 141                  }
 142                  $pwuser = str_replace("%",'\%',$pwuser);
 143                  $pwuser = str_replace("_",'\_',$pwuser);
 144                  $pwuser = addslashes(trim($pwuser));
 145                  $pwuser = str_replace('*','_',$pwuser);
 146                  $query=$db->query("SELECT uid FROM pw_members WHERE username LIKE '$pwuser'");
 147                  while($member=$db->fetch_array($query)){
 148                      $uids .= $member['uid'].',';
 149                  }
 150                  $uids ? $uids=substr($uids,0,-1) : $sqlwhere.=' AND 0 ';
 151              } elseif (is_numeric($authorid)){
 152                  $uids = $authorid;
 153              }
 154              $uids   && $sqlwhere .= "AND t.authorid IN($uids)";
 155              $digest && $sch_area != '2' && $sqlwhere .= "AND t.digest>'0'";
 156  
 157              if (is_numeric($sch_time) && strlen($sch_time)<10){
 158                  $sch_time  = $timestamp-$sch_time;
 159                  $sqlwhere .= "AND t.postdate>'$sch_time'";
 160              }
 161              if ($newatc){
 162                  $limit = 'LIMIT 50';
 163              } else{
 164                  !$db_maxresult && $db_maxresult=500;
 165                  $limit = "LIMIT $db_maxresult";
 166              }
 167              $query   = $db->query("SELECT DISTINCT t.tid FROM $sqltable WHERE $sqlwhere $orderby $limit");
 168              $total   = $db->num_rows($query);
 169              $schedid = $extra = '';
 170              while($sch = $db->fetch_array($query)){
 171                  if ($sch['tid']){
 172                      $schedid .= $extra.$sch['tid'];
 173                      $extra    = ',';
 174                  }
 175              }
 176              $db->free_result($query);
 177              if ($schedid && !$authorid){
 178                  $db->update("INSERT INTO pw_schcache(schline,schtime,total,schedid) VALUES('$schline','$timestamp','$total','$schedid')");
 179                  $sid = $db->insert_id();
 180              }
 181          }
 182      }
 183      if ($schedid){
 184          if (!is_numeric($page) || $page<1){
 185              $page = 1;
 186          }
 187          $start = ($page-1)*$db_perpage;
 188          $limit = "LIMIT $start,$db_perpage";
 189          require  R_P.'require/forum.php';
 190          $numofpage = ceil($total/$db_perpage);
 191          if (substr($schedid,-1) == ','){
 192              $schedid = substr($schedid,0,-1);
 193          }
 194          $rawkeyword = rawurlencode($keyword);
 195          $pages = numofpage($total,$page,$numofpage,"search.php?step=$step&sid=$sid&keyword=$rawkeyword&method=$method&pwuser=".rawurlencode($pwuser)."&authorid=$authorid&orderway=$orderway&s_type=$s_type&f_fid=$f_fid&c_fid=$c_fid&sch_time=$sch_time&sch_area=$sch_area&digest=$digest&");
 196  
 197          $schdb = array();
 198          $query = $db->query("SELECT * FROM pw_threads WHERE tid IN ($schedid) AND fid NOT IN ($fidout) $orderby $limit");
 199          while($sch = $db->fetch_array($query)){
 200              //$sch['subject'] = substrs($sch['subject'],35);

 201              if ($sch['titlefont']){
 202                  $titledetail=explode("~",$sch['titlefont']);
 203                  if ($titledetail[0])$sch['subject'] = "<font color=$titledetail[0]>$sch[subject]</font>";
 204                  if ($titledetail[1])$sch['subject'] = "<b>$sch[subject]</b>";
 205                  if ($titledetail[2])$sch['subject'] = "<i>$sch[subject]</i>";
 206                  if ($titledetail[3])$sch['subject'] = "<u>$sch[subject]</u>";
 207              }
 208              $keywords = explode("|",$keyword);
 209              foreach($keywords as $value){
 210                  $sch['subject'] = str_replace($value,"<font color='red'><u>$value</u></font>",$sch['subject']);
 211              }
 212              if ($sch['pollid']&&$sch['locked'] == 0){
 213                  $sch['status'] = "<img src='$imgpath/$stylepath/thread/vote.gif' border=0>";
 214              } elseif ($sch['pollid']&&$sch['locked']>0){
 215                  $sch['status'] = "<img src='$imgpath/$stylepath/thread/votelock.gif' border=0>";
 216              } else{
 217                  if ($sch['locked'] == 1){
 218                      $sch['status'] =  "<img src='$imgpath/$stylepath/thread/topiclock.gif' border=0>";
 219                  } elseif ($sch['locked'] == 2){
 220                      $sch['status'] = "<img src='$imgpath/$stylepath/thread/topicclose.gif' border=0>";
 221                  } elseif ($sch['replies']>=10){
 222                      $sch['status'] = "<img src='$imgpath/$stylepath/thread/topichot.gif' border=0>";
 223                  } else{
 224                      $sch['status'] = "<img src='$imgpath/$stylepath/thread/topicnew.gif' border=0>";
 225                  }
 226              }
 227              $sch['forumname'] = $forum[$sch['fid']]['name'];
 228              $sch['postdate'] = get_date($sch['postdate'],"Y-m-d");
 229              $sch['lastpost'] = get_date($sch['lastpost']);
 230              $sch['lastposterraw'] = rawurlencode($sch['lastposter']);
 231  
 232              $schdb[] = $sch;
 233          }
 234          $db->free_result($query);
 235          require_once PrintEOT('search');footer();
 236      }else{
 237          Showmsg('search_none');
 238      }
 239  }
 240  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]