📄 search.php
字号:
<?php
/**
* Title: search
* File Name: ./mods/search.php
* Copyright (c) 2004 M-logger
* Author: milkliker
* Modify: milkliker
* Last Change: 15:46 04-8-10
* Version: 0.3.1
**/
//---[Page Start]-------------------------------------------
$m=trim($_GET['m']);
$tpl->set_file('tplModule','search.htm');
$pageTitle=$lang['Search'];
$tpl->set_var('BLOGNAME',$config['LogName']);
//---[Search Function]--------------------------------------
function search($query,$time=''){
global $user,$thisTime;
if(empty($time)) $time=date("Y",$thisTime);
$listName='list/year_'.$time;
if(!$user->exists($listName)) return false;
$year=substr($time,-4);
$dates=$user->get(true,true,null,$listName);
$out=array();
foreach($dates as $value){
if(!empty($value['dates'])){
$_date=explode(',',$value['dates']);
foreach($_date as $date){
$tblName='content/'.$year.'_'.$value['month'].'_'.$date;
$temp=$user->get("$query",true,null,$tblName);//[8]NO CACHE..
if(!empty($temp)) $out=array_merge($out,$temp);
}
}
}
return $out;
}
$num=$user->get('0',false,null,'num',$config['UseCache']);
$tbls=explode(',',$num[0]['year']);
if(empty($tbls)){
header('location:./');
exit;
}
//---[Display Form]-----------------------------------------
if($m==''){
$tpl->set_block_vars('FORM');
$i=array_search(date("Y",$thisTime),$tbls);
unset($tbls[$i]);
if(!empty($tbls)){foreach($tbls as $value){
$tpl->set_block_vars('FORM.YEARS',array('YEAR'=>$value));
}}//if&foreach
$cate=$user->get(true,1,null,'cate',$config['UseCache']);
foreach($cate as $value){
$tpl->set_block_vars('FORM.CATE',$value);
}
//---[Do Search]--------------------------------------------
}else{
$tpl->set_block_vars('RESULT');
$key=str_replace(array(',','<','>'),array('','<','>'),trim($_POST['key']));//more..
if(empty($key)){
header('location:./?a=search');
exit;
}
$result=array();
$tpl->set_var('KEY',$key);
if($m=='search'){//(hello+to you)|(hi+to us)
$querys=array();
$sort=trim($_POST['sort']);
$time=trim($_POST['time']);
$cate=trim($_POST['cate']);
if($cate!='all'){
$scate=" and '{cate}'=='".$cate."'";
}
if(trim($_POST['title'])=='y') $querys[]="(strpos(' '.\$this->tbls[\$table]['values'][\$id]['title'],'$key') and '{type}'=='log'".$scate.")";
if(trim($_POST['author'])=='y') $querys[]="(strpos(' '.\$this->tbls[\$table]['values'][\$id]['author'],'$key') and '{type}'=='log'".$scate.")";
if(trim($_POST['describe'])=='y') $querys[]="(strpos(' '.\$this->tbls[\$table]['values'][\$id]['describe'],'$key') and '{type}'=='log'".$scate.")";
if(trim($_POST['content'])=='y') $querys[]="(strpos(' '.\$this->tbls[\$table]['values'][\$id]['content'],'$key') and '{type}'=='log'".$scate.")";
$query=implode(' or ',$querys);
if(empty($query)) $query="strpos(' '.\$this->tbls[\$table]['values'][\$id]['title'],'$key')";
if($time=='all'){
foreach($tbls as $time){
$temp=search($query,$time);
if(!empty($temp)) $result=array_merge($result,$temp);
}
}else{
if($time=='this') $time=date("Y",$thisTime);
$result=search($query,$time);
}
if(!empty($sort)){
$sort=explode('_',$sort);
$result=$user->_sort($result,$sort[0],$sort[1]);
}
}elseif($m=='fast_search'){
$pageTitle=$lang['FastSearch'];
$query="strpos(' '.\$this->tbls[\$table]['values'][\$id]['title'],'$key') and '{type}'=='log'";
$result=search($query);
}
if(empty($result)){
$tpl->set_var('RESULTNUMBER','0');
}else{
$category=$user->get(true,true,null,'cate',$config['UseCache']);
if(!empty($category)){foreach($category as $value){
$cateName[$value['id']]=$value['name'];
}}//if&foreach
$tpl->set_var('RESULTNUMBER',count($result));
foreach($result as $value){
if($user->user['rank'] <= $value['view'] or $user->user['name']==$value['author']){
$outDate=date("Y-n-j",$value['time']);
if($config['Html']=='y'){
$content=str_replace(array('/n','/r',"\"","'"),array('\n','\r',"\\\"","\\'"),$value['describe']);
}else{
$content=str_replace(array("\"","'"),array("\\\"","\\'"),$value['describe']);
}
$blogData['time']=date($config['DateFormat'],$value['time']);
$blogData['date']=$outDate;
$blogData['title']=$value['title'];
$blogData['author']=$value['author'];
$blogData['content']=$content;
$blogData['comment']=$value['comment'];
$blogData['trackback']=$value['trackback'];
$blogData['id']=$value['id'];
$blogData['catename']=$cateName[$value['cate']];
$blogData['cateid']=$value['cate'];
$blogData['sign']=str_replace(array('<br>','\\"',"\\'"),array("\n",'"',"'"),$value['sign']);
$tpl->set_block_vars('RESULT.BLOG',$blogData);
if($user->user['rank']=='1'){
$tpl->set_block_vars('RESULT.BLOG.MODIFY');
$tpl->set_block_vars('RESULT.BLOG.DELETE');
}elseif($user->user['name']==$value['author']){
$tpl->set_block_vars('RESULT.BLOG.MODIFY');
}
if(!empty($value['content'])) $tpl->set_block_vars('RESULT.BLOG.MORE');
}
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -