OSDN Git Service

Add files via upload
[idb/iDB.git.git] / inc / searches.php
index 43b241c..1226270 100644 (file)
@@ -8,10 +8,10 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     Revised BSD License for more details.
 
-    Copyright 2004-2011 iDB Support - http://idb.berlios.de/
-    Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
+    Copyright 2004-2019 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
+    Copyright 2004-2019 Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2
 
-    $FileInfo: searches.php - Last Update: 12/28/2010 SVN 607 - Author: cooldude2k $
+    $FileInfo: searches.php - Last Update: 4/8/2022 SVN 951 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="searches.php"||$File3Name=="/searches.php") {
@@ -21,11 +21,29 @@ if($Settings['enable_search']=="off"||
        $GroupInfo['CanSearch']=="no") {
 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
 header("Content-Type: text/plain; charset=".$Settings['charset']);
-ob_clean(); echo "Sorry you do not have permission to do a search."; 
+ob_clean(); echo "Sorry you do not have permission to do a search."; $urlstatus = 302;
 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 $pagenum = null;
 if($Settings['enable_search']=="on"||
        $GroupInfo['CanSearch']=="yes") {
+if(isset($_SESSION['OldViewingPage'])) { $_SESSION['AncientViewingPage'] = $_SESSION['OldViewingPage']; } else { $_SESSION['AncientViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
+if(isset($_SESSION['OldViewingFile'])) { $_SESSION['AncientViewingFile'] = $_SESSION['OldViewingFile']; } else { 
+        if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
+           $_SESSION['AncientViewingFile'] = $exfile['index'].$Settings['file_ext']; }
+        if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
+           $_SESSION['AncientViewingFile'] = $exfile['index']; } }
+if(isset($_SESSION['OldPreViewingTitle'])) { $_SESSION['AncientPreViewingTitle'] = $_SESSION['OldPreViewingTitle']; } else { $_SESSION['AncientPreViewingTitle'] = "Viewing"; }
+if(isset($_SESSION['OldViewingTitle'])) { $_SESSION['AncientViewingTitle'] = $_SESSION['OldViewingTitle']; } else { $_SESSION['AncientViewingTitle'] = "Board index"; }
+if(isset($_SESSION['OldExtraData'])) { $_SESSION['AncientExtraData'] = $_SESSION['OldExtraData']; } else { $_SESSION['AncientExtraData'] = "currentact:view; currentcategoryid:0; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;"; }
+if(isset($_SESSION['ViewingPage'])) { $_SESSION['OldViewingPage'] = $_SESSION['ViewingPage']; } else { $_SESSION['OldViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
+if(isset($_SESSION['ViewingFile'])) { $_SESSION['OldViewingFile'] = $_SESSION['ViewingFile']; } else { 
+        if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
+           $_SESSION['OldViewingFile'] = $exfile['index'].$Settings['file_ext']; }
+        if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
+           $_SESSION['OldViewingFile'] = $exfile['index']; } }
+if(isset($_SESSION['PreViewingTitle'])) { $_SESSION['OldPreViewingTitle'] = $_SESSION['PreViewingTitle']; } else { $_SESSION['OldPreViewingTitle'] = "Viewing"; }
+if(isset($_SESSION['ViewingTitle'])) { $_SESSION['OldViewingTitle'] = $_SESSION['ViewingTitle']; } else { $_SESSION['OldViewingTitle'] = "Board index"; }
+if(isset($_SESSION['ExtraData'])) { $_SESSION['OldExtraData'] = $_SESSION['ExtraData']; } else { $_SESSION['OldExtraData'] = "currentact:view; currentcategoryid:0; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;"; }
 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=topics","&","=",$prexqstr['search'],$exqstr['search']);
 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
 $_SESSION['ViewingFile'] = $exfile['search'].$Settings['file_ext']; }
@@ -33,10 +51,11 @@ if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
 $_SESSION['ViewingFile'] = $exfile['search']; }
 $_SESSION['PreViewingTitle'] = "Searching";
 $_SESSION['ViewingTitle'] = "Topics";
+$_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:0; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;";
 if($_GET['act']=="topics") {
        if($_GET['search']==null&&$_GET['type']==null) {
        ?>
-<div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>">Board index</a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Search topics</a></div>
+<div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>"><?php echo $Settings['board_name']; ?></a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Search topics</a></div>
 <div class="DivNavLinks">&nbsp;</div>
 <div class="Table1Border">
 <?php if($ThemeSet['TableStyle']=="div") { ?>
@@ -60,10 +79,10 @@ if($_GET['act']=="topics") {
 <table style="text-align: left;">
 <tr style="text-align: left;">
        <td style="width: 30%;"><label class="TextBoxLabel" for="search">Enter SearchTerm: </label></td>
-       <td style="width: 70%;"><input maxlength="35" class="TextBox" id="search" type="text" name="search" /></td>
+       <td style="width: 70%;"><input maxlength="35" class="TextBox" id="search" type="search" name="search" /></td>
 </tr><tr style="text-align: left;">
        <td style="width: 30%;"><label class="TextBoxLabel" for="msearch">Filter by Member (optional): </label></td>
-       <td style="width: 70%;"><input maxlength="25" class="TextBox" id="msearch" type="text" name="msearch" /></td>
+       <td style="width: 70%;"><input maxlength="25" class="TextBox" id="msearch" type="search" name="msearch" /></td>
 </tr><tr style="text-align: left;">
        <td style="width: 30%;"><label class="TextBoxLabel" title="Wildcard is %" for="type">Search Type: </label></td>
        <td style="width: 70%;"><select id="type" name="type" class="TextBox">
@@ -84,10 +103,10 @@ if($_GET['act']=="topics") {
 <td class="TableColumn4">&nbsp;</td>
 </tr>
 </table></div>
-<?php } if($_GET['search']!=null&&$_GET['type']!=null) {
+<?php } if(($_GET['search']!=null&&$_GET['type']!=null)||$_GET['type']=="getactive") {
 if(pre_strlen($_GET['msearch'])>="25") { 
        $_GET['msearch'] = null; }
-if($_GET['msearch']!=null) {
+if(isset($_GET['msearch'])&&$_GET['msearch']!=null) {
 $_GET['memid'] = null;
 $memsiquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"Name\"='%s' LIMIT 1", array($_GET['msearch']));
 $memsiresult=sql_query($memsiquery,$SQLStat);
@@ -97,6 +116,7 @@ if($memsinum==0) { $memsid = -1; }
 if($memsinum!=0) {
 $memsid=sql_result($memsiresult,$memsi,"id"); 
 sql_free_result($memsiresult); } }
+if(!isset($_GET['memid'])) { $_GET['memid'] = null; }
 if(!is_numeric($_GET['memid'])||$_GET['memid']<1) { 
        $_GET['memid'] = null; }
 if($_GET['memid']!=null&&is_numeric($_GET['memid'])) {
@@ -113,14 +133,14 @@ $nums = $_GET['page'] * $Settings['max_topics'];
 $PageLimit = $nums - $Settings['max_topics'];
 if($PageLimit<0) { $PageLimit = 0; }
 if($_GET['msearch']==null) {
-if($_GET['type']!="wildcard") {
+if($_GET['type']=="normal") {
 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$PageLimit,$Settings['max_topics'])); 
 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s'".$ForumIgnoreList4."", array($_GET['search'])); }
 if($_GET['type']=="wildcard") {
 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$PageLimit,$Settings['max_topics'])); 
 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s'".$ForumIgnoreList4."", array($_GET['search'])); } }
 if($_GET['msearch']!=null) {
-if($_GET['type']!="wildcard") {
+if($_GET['type']=="normal") {
 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s' AND \"UserID\"=%i".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$memsid,$PageLimit,$Settings['max_topics']));
 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s' AND \"UserID\"=%i".$ForumIgnoreList4."", array($_GET['search']));
 if($memsid==-1) {
@@ -132,6 +152,14 @@ $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics
 if($memsid==-1) {
 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s' AND \"GuestName\"='%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$_GET['msearch'],$PageLimit,$Settings['max_topics'])); 
 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s' AND \"GuestName\"='%s'".$ForumIgnoreList4."", array($_GET['search'],$_GET['msearch'])); } } }
+if($_GET['type']=="getactive") {
+$active_month = $usercurtime->format("m");
+$active_day = $usercurtime->format("d");
+$active_year = $usercurtime->format("Y");
+$active_start = mktime(0,0,0,$active_month,$active_day,$active_year);
+$active_end = mktime(23,59,59,$active_month,$active_day,$active_year);
+$query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE (\"TimeStamp\">=%i AND \"TimeStamp\"<=%i) OR (\"LastUpdate\">=%i AND \"LastUpdate\"<=%i)".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($active_start,$active_end,$active_start,$active_end,$PageLimit,$Settings['max_topics']));
+$rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE (\"TimeStamp\">=%i AND \"TimeStamp\"<=%i) OR (\"LastUpdate\">=%i AND \"LastUpdate\"<=%i)".$ForumIgnoreList4."", array($active_start,$active_end,$active_start,$active_end)); }
 $result=sql_query($query,$SQLStat);
 $rnresult=sql_query($rnquery,$SQLStat);
 $NumberTopics = sql_result($rnresult,0);
@@ -152,7 +180,7 @@ if($nums<$num) { $nextpage = $_GET['page'] + 1; }
 if($nums>=$num) { $nextpage = $_GET['page']; }
 if($numz>=$Settings['max_topics']) { $backpage = $_GET['page'] - 1; }
 if($_GET['page']<=1) { $backpage = 1; }
-$pnum = $num; $l = 1; $Pages = null;
+$pnum = $num; $l = 1; $Pages = array();;
 while ($pnum>0) {
 if($pnum>=$Settings['max_topics']) { 
        $pnum = $pnum - $Settings['max_topics']; 
@@ -164,7 +192,7 @@ if($pnum<$Settings['max_topics']&&$pnum>0) {
 $num=sql_num_rows($result);
 if($num<=0) { 
 redirect("location",$rbasedir.url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'],false));
-header("Content-Type: text/plain; charset=".$Settings['charset']);
+header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
 ob_clean(); echo "Sorry could not find any search results."; sql_free_result($result);
 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 $i=0;
@@ -250,7 +278,7 @@ if($ptestnext<$pagenum) {
 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$pagenum,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&raquo;</a></span> "; } } }
        ++$pagei; } $pstring = $pstring."</div>"; }
 ?>
-<div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>">Board index</a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Search topics</a></div>
+<div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>"><?php echo $Settings['board_name']; ?></a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Search topics</a></div>
 <div class="DivNavLinks">&nbsp;</div>
 <?php
 echo $pstring;
@@ -264,10 +292,12 @@ if($pagenum>1) {
 <div class="TableRow1">
 <span style="text-align: left;">
 <?php echo $ThemeSet['TitleIcon'];
-if($_GET['msearch']==null) { ?>
+if($_GET['msearch']==null&&$_GET['search']!=null) { ?>
 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?></a>
-<?php } if($_GET['msearch']!=null) { ?>
+<?php } if($_GET['msearch']!=null&&$_GET['search']!=null) { ?>
 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?> by <?php echo $_GET['msearch']; ?></a>
+<?php } if($_GET['type']=="getactive") { ?>
+<a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Todays Active Topics</a>
 <?php } ?></span></div>
 <?php } ?>
 <table class="Table1">
@@ -275,10 +305,12 @@ if($_GET['msearch']==null) { ?>
 <tr id="SearchStart" class="TableRow1">
 <td class="TableColumn1" colspan="6"><span style="text-align: left;">
 <?php echo $ThemeSet['TitleIcon'];
-if($_GET['msearch']==null) { ?>
+if($_GET['msearch']==null&&$_GET['search']!=null) { ?>
 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?></a>
-<?php } if($_GET['msearch']!=null) { ?>
+<?php } if($_GET['msearch']!=null&&$_GET['search']!=null) { ?>
 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?> by <?php echo $_GET['msearch']; ?></a>
+<?php } if($_GET['type']=="getactive") { ?>
+<a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Todays Active Topics</a>
 <?php } ?></span>
 </td>
 </tr><?php } ?>
@@ -309,7 +341,10 @@ $CategoryID=sql_result($result,$i,"CategoryID");
 $UsersID=sql_result($result,$i,"UserID");
 $GuestsName=sql_result($result,$i,"GuestName");
 $TheTime=sql_result($result,$i,"TimeStamp");
-$TheTime=GMTimeChange("F j Y, g:i a",$TheTime,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
+$tmpusrcurtime = new DateTime();
+$tmpusrcurtime->setTimestamp($TheTime);
+$tmpusrcurtime->setTimezone($usertz);
+$TheTime=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
 $NumReply=sql_result($result,$i,"NumReply");
 $NumberPosts=$NumReply + 1;
 $prepagelist = null;
@@ -401,7 +436,10 @@ $ReplyID1=sql_result($glrresult,0,"id");
 $UsersID1=sql_result($glrresult,0,"UserID");
 $GuestsName1=sql_result($glrresult,0,"GuestName");
 $TimeStamp1=sql_result($glrresult,0,"TimeStamp");
-$TimeStamp1=GMTimeChange("F j Y, g:i a",$TimeStamp1,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
+$tmpusrcurtime = new DateTime();
+$tmpusrcurtime->setTimestamp($TimeStamp1);
+$tmpusrcurtime->setTimezone($usertz);
+$TimeStamp1=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
 $PreUsersName1 = GetUserName($UsersID1,$Settings['sqltable'],$SQLStat);
 if($PreUsersName1['Name']===null) { $UsersID1 = -1;
 $PreUsersName1 = GetUserName($UsersID1,$Settings['sqltable'],$SQLStat); }