OSDN Git Service

Small update
[idb/iDB.git.git] / inc / lowreplies.php
index 1b2fdcc..022c6e3 100644 (file)
@@ -8,10 +8,10 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     Revised BSD License for more details.
 
-    Copyright 2004-2009 iDB Support - http://idb.berlios.de/
-    Copyright 2004-2009 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: replies.php - Last Update: 11/14/2009 SVN 347 - Author: cooldude2k $
+    $FileInfo: lowreplies.php - Last Update: 08/02/2019 SVN 905 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="replies.php"||$File3Name=="/replies.php") {
@@ -21,52 +21,99 @@ $pstring = null; $pagenum = null;
 if(!is_numeric($_GET['id'])) { $_GET['id'] = null; }
 if(!is_numeric($_GET['post'])) { $_GET['post'] = null; }
 if(!is_numeric($_GET['page'])) { $_GET['page'] = 1; }
+if(!isset($_GET['st'])) { $_GET['st'] = 0; }
+if(!is_numeric($_GET['st'])) { $_GET['st'] = 0; }
 if(!isset($_GET['modact'])) { $_GET['modact'] = null; }
 if($_GET['modact']=="pin"||$_GET['modact']=="unpin"||$_GET['modact']=="open"||
        $_GET['modact']=="close"||$_GET['modact']=="edit"||$_GET['modact']=="delete")
                { $_GET['act'] = $_GET['modact']; }
-$prequery = query("SELECT * FROM `".$Settings['sqltable']."topics` WHERE `id`=%i LIMIT 1", array($_GET['id']));
-$preresult=exec_query($prequery);
-$prenum=mysql_num_rows($preresult);
-if($prenum==0) { redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); @mysql_free_result($preresult);
-ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
-gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @session_write_close(); die(); }
+$prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"id\"=%i".$ForumIgnoreList4." LIMIT 1", array($_GET['id']));
+$preresult=sql_query($prequery,$SQLStat);
+$prenum=sql_num_rows($preresult);
+if($prenum==0) { redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); sql_free_result($preresult);
+ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 if($prenum>=1) {
-$TopicName=mysql_result($preresult,0,"TopicName");
-$TopicID=mysql_result($preresult,0,"id");
-$TopicForumID=mysql_result($preresult,0,"ForumID");
-$TopicCatID=mysql_result($preresult,0,"CategoryID");
-$TopicClosed=mysql_result($preresult,0,"Closed");
-$NumberReplies=mysql_result($preresult,0,"NumReply");
-$ViewTimes=mysql_result($preresult,0,"NumViews");
-@mysql_free_result($preresult);
-$forumcheckx = query("SELECT * FROM `".$Settings['sqltable']."forums` WHERE `id`=%i  LIMIT 1", array($TopicForumID));
-$fmckresult=exec_query($forumcheckx);
-$ForumName=mysql_result($fmckresult,0,"Name");
-$ForumType=mysql_result($fmckresult,0,"ForumType");
-$CanHaveTopics=mysql_result($fmckresult,0,"CanHaveTopics");
-$ForumPostCountView=mysql_result($fmckresult,0,"PostCountView");
-$ForumKarmaCountView=mysql_result($fmckresult,0,"KarmaCountView");
-@mysql_free_result($fmckresult);
-$catcheck = query("SELECT * FROM `".$Settings['sqltable']."categories` WHERE `id`=%i  LIMIT 1", array($TopicCatID));
-$catresult=exec_query($catcheck);
-$CategoryName=mysql_result($catresult,0,"Name");
-$CategoryType=mysql_result($catresult,0,"CategoryType");
-$CategoryPostCountView=mysql_result($catresult,0,"PostCountView");
-$CategoryKarmaCountView=mysql_result($catresult,0,"KarmaCountView");
-@mysql_free_result($catresult);
+$TopicName=sql_result($preresult,0,"TopicName");
+$TopicID=sql_result($preresult,0,"id");
+$TopicForumID=sql_result($preresult,0,"ForumID");
+$TopicCatID=sql_result($preresult,0,"CategoryID");
+$TopicClosed=sql_result($preresult,0,"Closed");
+if($TopicClosed==3&&$PermissionInfo['CanModForum'][$TopicForumID]=="no") { 
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); sql_free_result($preresult);
+ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
+if(!isset($_GET['post'])||$_GET['post']!==null) {
+$NumberReplies=sql_result($preresult,0,"NumReply"); }
+if(isset($_GET['post'])&&$_GET['post']!==null) {
+$NumberReplies=1; }
+$ViewTimes=sql_result($preresult,0,"NumViews");
+sql_free_result($preresult);
+$forumcheckx = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2."  LIMIT 1", array($TopicForumID));
+$fmckresult=sql_query($forumcheckx,$SQLStat);
+$fmcknum=sql_num_rows($fmckresult);
+if($fmcknum==0) { redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); sql_free_result($preresult);
+ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
+$ForumID=sql_result($fmckresult,0,"id");
+$ForumName=sql_result($fmckresult,0,"Name");
+$ForumType=sql_result($fmckresult,0,"ForumType");
+$ForumShow=sql_result($fmckresult,0,"ShowForum");
+$InSubForum=sql_result($fmckresult,0,"InSubForum");
+if($InSubForum!=0) {
+$subforumcheckx = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2."  LIMIT 1", array($InSubForum));
+$subfmckresult=sql_query($subforumcheckx,$SQLStat);
+$subfmcknum=sql_num_rows($subfmckresult);
+$SubForumName=sql_result($subfmckresult,0,"Name");
+$SubForumType=sql_result($subfmckresult,0,"ForumType");
+$InSubCategory=sql_result($catresult,0,"InSubCategory");
+$SubForumShow=sql_result($subfmckresult,0,"ShowForum");
+sql_free_result($subfmckresult); }
+if($ForumShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
+$CanHaveTopics=sql_result($fmckresult,0,"CanHaveTopics");
+$ForumPostCountView=sql_result($fmckresult,0,"PostCountView");
+$ForumKarmaCountView=sql_result($fmckresult,0,"KarmaCountView");
+sql_free_result($fmckresult);
+$catcheck = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2."  LIMIT 1", array($TopicCatID));
+$catresult=sql_query($catcheck,$SQLStat);
+$CategoryID=sql_result($catresult,0,"id");
+$CategoryName=sql_result($catresult,0,"Name");
+$CategoryShow=sql_result($catresult,0,"ShowCategory");
+if($CategoryShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
+$CategoryType=sql_result($catresult,0,"CategoryType");
+$CategoryPostCountView=sql_result($catresult,0,"PostCountView");
+$CategoryKarmaCountView=sql_result($catresult,0,"KarmaCountView");
+sql_free_result($catresult);
 if($GroupInfo['HasAdminCP']!="yes"||$GroupInfo['HasModCP']!="yes") {
 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
 if($ForumPostCountView!=0&&$MyPostCountChk<$ForumPostCountView) {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
 if($ForumKarmaCountView!=0&&$MyKarmaCount<$ForumKarmaCountView) {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
 if($ForumCheck!="skip") {
+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=view&id=".$_GET['id']."&page=".$_GET['page'],"&","=",$prexqstr['topic'],$exqstr['topic']);
 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
 $_SESSION['ViewingFile'] = $exfile['topic'].$Settings['file_ext']; }
@@ -74,25 +121,28 @@ if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
 $_SESSION['ViewingFile'] = $exfile['topic']; }
 $_SESSION['PreViewingTitle'] = "Viewing Topic:";
 $_SESSION['ViewingTitle'] = $TopicName;
+if(isset($InSubCategory)) {
+$_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:".$InSubCategory.",".$CategoryID."; currentforumid:".$InSubForum.",".$ForumID."; currenttopicid:".$TopicID."; currentmessageid:0; currenteventid:0; currentmemberid:0;"; } else {
+$_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:0,".$CategoryID."; currentforumid:".$InSubForum.",".$ForumID."; currenttopicid:".$TopicID."; currentmessageid:0; currenteventid:0; currentmemberid:0;"; }
 ?>
 <div style="font-size: 1.0em; font-weight: bold; margin-bottom: 10px; padding-top: 3px; width: auto;">Full Version: <a href="<?php echo url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']); ?>"><?php echo $TopicName; ?></a></div>
-<div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;"><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>">Board index</a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile[$CategoryType],$Settings['file_ext'],"act=lowview&id=".$TopicCatID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php echo $CategoryName; ?></a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$TopicForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $ForumName; ?></a></div>
+<div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;"><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$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[$CategoryType],$Settings['file_ext'],"act=lowview&id=".$TopicCatID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php echo $CategoryName; ?></a><?php echo $ThemeSet['NavLinkDivider']; if($InSubForum!=0 && $subfmcknum>0) { ?><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=view&id=".$InSubForum."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $SubForumName; ?></a><?php echo $ThemeSet['NavLinkDivider']; } ?><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$TopicForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $ForumName; ?></a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']); ?>"><?php echo $TopicName; ?></a></div>
 <div>&nbsp;</div>
 <?php }
 if(!isset($CatPermissionInfo['CanViewCategory'][$TopicCatID])) {
        $CatPermissionInfo['CanViewCategory'][$TopicCatID] = "no"; }
 if($CatPermissionInfo['CanViewCategory'][$TopicCatID]=="no"||
        $CatPermissionInfo['CanViewCategory'][$TopicCatID]!="yes") {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
-ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
-gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @session_write_close(); die(); }
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
+ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 if(!isset($PermissionInfo['CanViewForum'][$TopicForumID])) {
        $PermissionInfo['CanViewForum'][$TopicForumID] = "no"; }
 if($PermissionInfo['CanViewForum'][$TopicForumID]=="no"||
        $PermissionInfo['CanViewForum'][$TopicForumID]!="yes") {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
-ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
-gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @session_write_close(); die(); }
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
+ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 if($_GET['act']!="view") { 
 $CanMakeReply = "no"; $CanMakeTopic = "no";
 if($PermissionInfo['CanMakeTopics'][$TopicForumID]=="yes"&&$CanHaveTopics=="yes") { 
@@ -110,7 +160,10 @@ $num=$NumberReplies+1;
 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
 if($_GET['page']==null) { $_GET['page'] = 1; } 
 if($_GET['page']<=0) { $_GET['page'] = 1; }
-$nums = $_GET['page'] * $Settings['max_posts'];
+if($_GET['st']<=0||!isset($_GET['st'])) {
+$nums = $_GET['page'] * $Settings['max_posts']; }
+if($_GET['st']>0&&isset($_GET['st'])) {
+$nums = $_GET['st']; }
 if($nums>$num) { $nums = $num; }
 $numz = $nums - $Settings['max_posts'];
 if($numz<=0) { $numz = 0; }
@@ -128,28 +181,34 @@ if($pnum<$Settings['max_posts']&&$pnum>0) {
        $pnum = $pnum - $pnum; 
        $Pages[$l] = $l; ++$l; } }
 $snumber = $_GET['page'] - 1;
-$PageLimit = $Settings['max_posts'] * $snumber;
+if($_GET['st']<=0||!isset($_GET['st'])) {
+$PageLimit = $Settings['max_posts'] * $snumber; }
+if($_GET['st']>0&&isset($_GET['st'])) {
+$PageLimit = $_GET['st']; }
 if($PageLimit<0) { $PageLimit = 0; }
 //End Reply Page Code
 $i=0;
-$query = query("SELECT * FROM `".$Settings['sqltable']."posts` WHERE `TopicID`=%i ORDER BY `TimeStamp` ASC LIMIT %i,%i", array($_GET['id'],$PageLimit,$Settings['max_posts']));
-$result=exec_query($query);
-$num=mysql_num_rows($result);
-if($num==0) { redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
-ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
-gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @session_write_close(); die(); }
+if(!isset($_GET['post'])||$_GET['post']!==null) {
+$query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i ORDER BY \"TimeStamp\" ASC ".$SQLimit, array($_GET['id'],$PageLimit,$Settings['max_posts'])); }
+if(isset($_GET['post'])&&$_GET['post']!==null) {
+$query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i AND \"id\"=%i ORDER BY \"TimeStamp\" ASC ".$SQLimit, array($_GET['id'],$_GET['post'],$PageLimit,$Settings['max_posts'])); }
+$result=sql_query($query,$SQLStat);
+$num=sql_num_rows($result);
+if($num==0) { redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
+ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 if($num!=0) { 
 if($ViewTimes==0||$ViewTimes==null) { $NewViewTimes = 1; }
 if($ViewTimes!=0&&$ViewTimes!=null) { $NewViewTimes = $ViewTimes + 1; }
-$viewsup = query("UPDATE `".$Settings['sqltable']."topics` SET `NumViews`='%s' WHERE `id`=%i", array($NewViewTimes,$_GET['id']));
-exec_query($viewsup); }
+$viewsup = sql_pre_query("UPDATE \"".$Settings['sqltable']."topics\" SET \"NumViews\"='%s' WHERE \"id\"=%i", array($NewViewTimes,$_GET['id']));
+sql_query($viewsup,$SQLStat); }
 //List Page Number Code Start
 $pagenum=count($Pages);
 if($_GET['page']>$pagenum) {
        $_GET['page'] = $pagenum; }
 $pagei=0; $pstring = null;
 if($pagenum>1) {
-$pstring = "<div style=\"\" class=\"PageList\"><span class=\"pagelink\">".$pagenum." Pages:</span> "; }
+$pstring = "<div class=\"PageList\"><span class=\"pagelink\">".$pagenum." Pages:</span> "; }
 if($_GET['page']<4) { $Pagez[0] = null; }
 if($_GET['page']>=4) { $Pagez[0] = "First"; }
 if($_GET['page']>=3) {
@@ -213,58 +272,110 @@ if($TopicClosed==1&&$PermissionInfo['CanMakeReplysClose'][$TopicForumID]=="yes"
 <div>&nbsp;</div>
 <div style="padding: 10px; border: 1px solid gray;">
 <?php while ($i < $num) {
-$MyPostID=mysql_result($result,$i,"id");
-$MyTopicID=mysql_result($result,$i,"TopicID");
-$MyPostIP=mysql_result($result,$i,"IP");
-$MyForumID=mysql_result($result,$i,"ForumID");
-$MyCategoryID=mysql_result($result,$i,"CategoryID");
-$MyUserID=mysql_result($result,$i,"UserID");
-$MyGuestName=mysql_result($result,$i,"GuestName");
-$MyTimeStamp=mysql_result($result,$i,"TimeStamp");
-$MyEditTime=mysql_result($result,$i,"LastUpdate");
-$MyEditUserID=mysql_result($result,$i,"EditUser");
-$MyEditUserName=mysql_result($result,$i,"EditUserName");
-$MyTimeStamp=GMTimeChange("M j, Y, g:i a",$MyTimeStamp,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
-$MyPost=mysql_result($result,$i,"Post");
-$MyPost = preg_replace("/\<br\>/", "<br />\n", nl2br($MyPost));
-$MyDescription=mysql_result($result,$i,"Description");
-$requery = query("SELECT * FROM `".$Settings['sqltable']."members` WHERE `id`=%i LIMIT 1", array($MyUserID));
-$reresult=exec_query($requery);
-$renum=mysql_num_rows($reresult);
+$MyPostID=sql_result($result,$i,"id");
+$MyTopicID=sql_result($result,$i,"TopicID");
+$MyPostIP=sql_result($result,$i,"IP");
+$MyForumID=sql_result($result,$i,"ForumID");
+$MyCategoryID=sql_result($result,$i,"CategoryID");
+$MyUserID=sql_result($result,$i,"UserID");
+$MyGuestName=sql_result($result,$i,"GuestName");
+$MyTimeStamp=sql_result($result,$i,"TimeStamp");
+$MyEditTime=sql_result($result,$i,"LastUpdate");
+$MyEditUserID=sql_result($result,$i,"EditUser");
+$MyEditUserName=sql_result($result,$i,"EditUserName");
+$tmpusrcurtime = new DateTime();
+$tmpusrcurtime->setTimestamp($MyTimeStamp);
+$tmpusrcurtime->setTimezone($usertz);
+$MyTimeStamp=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
+$MyPost=sql_result($result,$i,"Post");
+$MyDescription=sql_result($result,$i,"Description");
+$requery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
+$reresult=sql_query($requery,$SQLStat);
+$renum=sql_num_rows($reresult);
 if($renum<1) { $MyUserID = -1;
-$requery = query("SELECT * FROM `".$Settings['sqltable']."members` WHERE `id`=%i LIMIT 1", array($MyUserID));
-$reresult=exec_query($requery);
-$renum=mysql_num_rows($reresult); }
+$requery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
+$reresult=sql_query($requery,$SQLStat);
+$renum=sql_num_rows($reresult); }
+$memrequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."mempermissions\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
+$memreresult=sql_query($memrequery,$SQLStat);
+$memrenum=sql_num_rows($memreresult);
 $rei=0; $ipshow = "two";
 $User1ID=$MyUserID; $GuestsName = $MyGuestName;
-$User1Name=mysql_result($reresult,$rei,"Name");
-$User1IP=mysql_result($reresult,$rei,"IP");
+$User1Name=sql_result($reresult,$rei,"Name");
+$User1IP=sql_result($reresult,$rei,"IP");
 if($User1IP==$MyPostIP) { $ipshow = "one"; }
-$User1Email=mysql_result($reresult,$rei,"Email");
-$User1Title=mysql_result($reresult,$rei,"Title");
-$User1Joined=mysql_result($reresult,$rei,"Joined");
-$User1Joined=GMTimeChange("M j Y",$User1Joined,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
-$User1GroupID=mysql_result($reresult,$rei,"GroupID");
-$gquery = query("SELECT * FROM `".$Settings['sqltable']."groups` WHERE `id`=%i LIMIT 1", array($User1GroupID));
-$gresult=exec_query($gquery);
-$User1Group=mysql_result($gresult,0,"Name");
-$GroupNamePrefix=mysql_result($gresult,0,"NamePrefix");
-$GroupNameSuffix=mysql_result($gresult,0,"NameSuffix");
-@mysql_free_result($gresult);
-$User1Signature=mysql_result($reresult,$rei,"Signature");
-$User1Avatar=mysql_result($reresult,$rei,"Avatar");
-$User1AvatarSize=mysql_result($reresult,$rei,"AvatarSize");
+$User1Email=sql_result($reresult,$rei,"Email");
+$User1Title=sql_result($reresult,$rei,"Title");
+$PreUserCanExecPHP=sql_result($memreresult,$rei,"CanExecPHP");
+if($PreUserCanExecPHP!="yes"&&$PreUserCanExecPHP!="no"&&$PreUserCanExecPHP!="group") {
+       $PreUserCanExecPHP = "no"; }
+$PreUserCanDoHTML=sql_result($memreresult,$rei,"CanDoHTML");
+if($PreUserCanDoHTML!="yes"&&$PreUserCanDoHTML!="no"&&$PreUserCanDoHTML!="group") {
+       $PreUserCanDoHTML = "no"; }
+$PreUserCanUseBBTags=sql_result($memreresult,$rei,"CanUseBBTags");
+if($PreUserCanUseBBTags!="yes"&&$PreUserCanUseBBTags!="no"&&$PreUserCanUseBBTags!="group") {
+       $PreUserCanUseBBTags = "no"; }
+sql_free_result($memreresult);
+$User1Joined=sql_result($reresult,$rei,"Joined");
+$tmpusrcurtime = new DateTime();
+$tmpusrcurtime->setTimestamp($User1Joined);
+$tmpusrcurtime->setTimezone($usertz);
+$User1Joined=$tmpusrcurtime->format($_SESSION['iDBDateFormat']);
+$User1GroupID=sql_result($reresult,$rei,"GroupID");
+$gquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($User1GroupID));
+$gresult=sql_query($gquery,$SQLStat);
+$User1Group=sql_result($gresult,0,"Name");
+$User1CanExecPHP = $PreUserCanExecPHP;
+if($PreUserCanExecPHP=="group") {
+$User1CanExecPHP=sql_result($gresult,0,"CanExecPHP"); }
+if($User1CanExecPHP!="yes"&&$User1CanExecPHP!="no") {
+       $User1CanExecPHP = "no"; }
+$User1CanDoHTML = $PreUserCanDoHTML;
+if($PreUserCanDoHTML=="group") {
+$User1CanDoHTML=sql_result($gresult,0,"CanDoHTML"); }
+if($User1CanDoHTML!="yes"&&$User1CanDoHTML!="no") {
+       $User1CanDoHTML = "no"; }
+$User1CanUseBBTags = $PreUserCanUseBBTags;
+if($User1CanUseBBTags=="group") {
+$User1CanUseBBTags=sql_result($gresult,0,"CanUseBBTags"); }
+if($User1CanUseBBTags!="yes"&&$User1CanUseBBTags!="no") {
+       $User1CanUseBBTags = "no"; }
+$GroupNamePrefix=sql_result($gresult,0,"NamePrefix");
+$GroupNameSuffix=sql_result($gresult,0,"NameSuffix");
+$User1PermissionID=sql_result($gresult,0,"PermissionID");
+sql_free_result($gresult);
+$per1query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."permissions\" WHERE \"PermissionID\"=%i LIMIT 1", array($User1PermissionID));
+$per1esult=sql_query($per1query,$SQLStat);
+$per1num=sql_num_rows($per1esult);
+$User1CanDoHTML1=sql_result($per1esult,0,"CanDoHTML");
+if($User1CanDoHTML1!="yes"&&$User1CanDoHTML1!="no") {
+       $User1CanDoHTML1 = "no"; }
+$User1CanUseBBTags1=sql_result($per1esult,0,"CanUseBBTags");
+if($User1CanUseBBTags1!="yes"&&$User1CanUseBBTags1!="no") {
+       $User1CanUseBBTags1 = "no"; }
+sql_free_result($per1esult);
+$User1Signature=sql_result($reresult,$rei,"Signature");
+$User1Avatar=sql_result($reresult,$rei,"Avatar");
+$User1AvatarSize=sql_result($reresult,$rei,"AvatarSize");
 if ($User1Avatar=="http://"||$User1Avatar==null||
        strtolower($User1Avatar)=="noavatar") {
 $User1Avatar=$ThemeSet['NoAvatar'];
 $User1AvatarSize=$ThemeSet['NoAvatarSize']; }
 $AvatarSize1=explode("x", $User1AvatarSize);
 $AvatarSize1W=$AvatarSize1[0]; $AvatarSize1H=$AvatarSize1[1];
-$User1Website=mysql_result($reresult,$rei,"Website");
-$User1PostCount=mysql_result($reresult,$rei,"PostCount");
-$User1Karma=mysql_result($reresult,$rei,"Karma");
-$User1IP=mysql_result($reresult,$rei,"IP");
-@mysql_free_result($reresult);
+$User1Website=sql_result($reresult,$rei,"Website");
+$BoardWWWChCk = parse_url($Settings['idburl']);
+if($User1Website=="http://") { 
+       $User1Website = $Settings['idburl']; }
+$User1WWWChCk = parse_url($User1Website);
+$User1Website = urlcheck($User1Website);
+$opennew = " onclick=\"window.open(this.href);return false;\"";
+if($BoardWWWChCk['host']==$User1WWWChCk['host']) {
+       $opennew = null; }
+$User1PostCount=sql_result($reresult,$rei,"PostCount");
+$User1Karma=sql_result($reresult,$rei,"Karma");
+$User1IP=sql_result($reresult,$rei,"IP");
+sql_free_result($reresult);
 if($User1Name=="Guest") { $User1Name=$GuestsName;
 if($User1Name==null) { $User1Name="Guest"; } }
 if(isset($GroupNamePrefix)&&$GroupNamePrefix!=null) {
@@ -274,28 +385,28 @@ if(isset($GroupNameSuffix)&&$GroupNameSuffix!=null) {
 $MySubPost = null;
 if($MyEditTime!=$MyTimeStamp&&$MyEditUserID!=0) {
 if($MyEditUserID!=$MyUserID) {
-$euquery = query("SELECT * FROM `".$Settings['sqltable']."members` WHERE `id`=%i LIMIT 1", array($MyEditUserID));
-$euresult = exec_query($euquery);
-$eunum = mysql_num_rows($euresult);
+$euquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyEditUserID));
+$euresult = sql_query($euquery,$SQLStat);
+$eunum = sql_num_rows($euresult);
 if($eunum<1) { $MyEditUserID = -1;
-$euquery = query("SELECT * FROM `".$Settings['sqltable']."members` WHERE `id`=%i LIMIT 1", array($MyEditUserID));
-$euresult = exec_query($euquery);
-$eunum = mysql_num_rows($euresult); }
+$euquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyEditUserID));
+$euresult = sql_query($euquery,$SQLStat);
+$eunum = sql_num_rows($euresult); }
        $EditUserID = $MyEditUserID;
-       $EditUserGroupID = mysql_result($euresult,0,"GroupID");
-       $EditUserHidden=mysql_result($euresult,0,"HiddenMember");
-       $EditUserName = mysql_result($euresult,0,"Name");
-       @mysql_free_result($euresult);
-       $eugquery = query("SELECT * FROM `".$Settings['sqltable']."groups` WHERE `id`=%i LIMIT 1", array($EditUserGroupID));
-       $eugresult=exec_query($eugquery);
-       $EditUserGroup=mysql_result($eugresult,0,"Name");
-       $EditUserNamePrefix=mysql_result($eugresult,0,"NamePrefix");
-       $EditUserNameSuffix=mysql_result($eugresult,0,"NameSuffix");
-       @mysql_free_result($eugresult); }
+       $EditUserGroupID = sql_result($euresult,0,"GroupID");
+       $EditUserHidden=sql_result($euresult,0,"HiddenMember");
+       $EditUserName = sql_result($euresult,0,"Name");
+       sql_free_result($euresult);
+       $eugquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($EditUserGroupID));
+       $eugresult=sql_query($eugquery,$SQLStat);
+       $EditUserGroup=sql_result($eugresult,0,"Name");
+       $EditUserNamePrefix=sql_result($eugresult,0,"NamePrefix");
+       $EditUserNameSuffix=sql_result($eugresult,0,"NameSuffix");
+       sql_free_result($eugresult);    }
        if($MyEditUserID==$MyUserID) {
        $EditUserID = $User1ID;
        $EditUserGroupID = $User1GroupID;
-       $EditUserHidden=$User1Hidden;
+       //$EditUserHidden=$User1Hidden;
        $EditUserName = $User1Name;
        $EditUserGroup=$User1Group;
        $EditUserNamePrefix=null;
@@ -306,33 +417,56 @@ $eunum = mysql_num_rows($euresult); }
                $EditUserName = $EditUserNamePrefix.$EditUserName; }
        if(isset($GroupNameSuffix)&&$GroupNameSuffix!=null) {
                $EditUserName = $EditUserName.$EditUserNameSuffix; }
-       $MyEditTime = GMTimeChange("M j, Y, g:i a",$MyEditTime,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
+       $tmpusrcurtime = new DateTime();
+       $tmpusrcurtime->setTimestamp($MyEditTime);
+       $tmpusrcurtime->setTimezone($usertz);
+       $MyEditTime = $tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
        $MySubPost = "<div class=\"EditReply\"><br />This post has been edited by <b>".$EditUserName."</b> on ".$MyEditTime."</div>"; }
 if($MyEditTime!=$MyTimeStamp&&$MyEditUserID!=0&&$MyEditUserID!=$MyUserID) {
-$requery = query("SELECT * FROM `".$Settings['sqltable']."members` WHERE `id`=%i LIMIT 1", array($MyUserID));
-$reresult=exec_query($requery);
-$renum=mysql_num_rows($reresult);
+$requery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
+$reresult=sql_query($requery,$SQLStat);
+$renum=sql_num_rows($reresult);
 $rei=0; $ipshow = "two";
 $User1ID=$MyUserID; $GuestsName = $MyGuestName;
-$User1Name=mysql_result($reresult,$rei,"Name");
-$User1IP=mysql_result($reresult,$rei,"IP");
+$User1Name=sql_result($reresult,$rei,"Name");
+$User1IP=sql_result($reresult,$rei,"IP");
 if($User1IP==$MyPostIP) { $ipshow = "one"; }
-$User1Email=mysql_result($reresult,$rei,"Email");
-$User1Title=mysql_result($reresult,$rei,"Title");
-$User1Joined=mysql_result($reresult,$rei,"Joined");
-$User1Joined=GMTimeChange("M j Y",$User1Joined,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
-$User1Hidden=mysql_result($reresult,$rei,"HiddenMember");
-$User1GroupID=mysql_result($reresult,$rei,"GroupID");
-$gquery = query("SELECT * FROM `".$Settings['sqltable']."groups` WHERE `id`=%i LIMIT 1", array($User1GroupID));
-$gresult=exec_query($gquery);
-$User1Group=mysql_result($gresult,0,"Name");
-$GroupNamePrefix=mysql_result($gresult,0,"NamePrefix");
-$GroupNameSuffix=mysql_result($gresult,0,"NameSuffix");
-@mysql_free_result($gresult); }
-$MyPost = text2icons($MyPost,$Settings['sqltable']);
+$User1Email=sql_result($reresult,$rei,"Email");
+$User1Title=sql_result($reresult,$rei,"Title");
+$User1Joined=sql_result($reresult,$rei,"Joined");
+$tmpusrcurtime = new DateTime();
+$tmpusrcurtime->setTimestamp($User1Joined);
+$tmpusrcurtime->setTimezone($usertz);
+$User1Joined=$tmpusrcurtime->format($_SESSION['iDBDateFormat']);
+$User1Hidden=sql_result($reresult,$rei,"HiddenMember");
+$User1GroupID=sql_result($reresult,$rei,"GroupID");
+$gquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($User1GroupID));
+$gresult=sql_query($gquery,$SQLStat);
+$User1Group=sql_result($gresult,0,"Name");
+$GroupNamePrefix=sql_result($gresult,0,"NamePrefix");
+$GroupNameSuffix=sql_result($gresult,0,"NameSuffix");
+sql_free_result($gresult); }
+if($User1CanUseBBTags1=="yes") { $MyPost = bbcode_parser($MyPost); }
+if($User1CanExecPHP=="no") {
+$MyPost = preg_replace("/\[ExecPHP\](.*?)\[\/ExecPHP\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute php code.",$MyPost); }
+if($User1CanExecPHP=="yes") { $MyPost = php_execute($MyPost); }
+if($User1CanDoHTML1=="no") {
+$MyPost = preg_replace("/\[DoHTML\](.*?)\[\/DoHTML\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute html.",$MyPost); }
+if($User1CanDoHTML1=="yes") { $MyPost = do_html_bbcode($MyPost); }
+$MyPost = text2icons($MyPost,$Settings['sqltable'],$SQLStat);
+$MyPost = preg_replace("/\<br\>/", "<br />", nl2br($MyPost));
+$MyPost = url2link($MyPost);
 if($MySubPost!=null) { $MyPost = $MyPost."\n".$MySubPost; }
-$User1Signature = preg_replace("/\<br\>/", "<br />\n", nl2br($User1Signature));
-$User1Signature = text2icons($User1Signature,$Settings['sqltable']);
+if($User1CanUseBBTags=="yes") { $User1Signature = bbcode_parser($User1Signature); }
+if($User1CanExecPHP=="no") {
+$User1Signature = preg_replace("/\[ExecPHP\](.*?)\[\/ExecPHP\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute php code.",$User1Signature); }
+if($User1CanExecPHP=="yes") { $User1Signature = php_execute($User1Signature); }
+if($User1CanDoHTML1=="no") {
+$User1Signature = preg_replace("/\[DoHTML\](.*?)\[\/DoHTML\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute html.",$User1Signature); }
+if($User1CanDoHTML=="yes") { $User1Signature = do_html_bbcode($User1Signature); }
+$User1Signature = text2icons($User1Signature,$Settings['sqltable'],$SQLStat);
+$User1Signature = preg_replace("/\<br\>/", "<br />", nl2br($User1Signature));
+$User1Signature = url2link($User1Signature);
 $CanEditReply = false; $CanDeleteReply = false;
 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
 if($PermissionInfo['CanEditReplys'][$MyForumID]=="yes"&&
@@ -345,11 +479,14 @@ if($_SESSION['UserID']==0) {
        $CanEditReply = false; $CanDeleteReply = false; }
 $ReplyNum = $i + $PageLimit + 1;
 ?>
-<div style="border:1px solid #E6E3E4; padding:1px; margin-bottom: 15px;">
-<div style="border: 1px solid #E6E3E4; padding:1px; margin-bottom: 15px; background-color: #E6E3E4; padding: 6px;">
+<div style="border:1px solid #E6E3E4; padding:1px; margin-bottom: 15px;" id="reply<?php echo $ReplyNum; ?>">
+<div style="border: 1px solid #E6E3E4; padding:1px; margin-bottom: 15px; background-color: #E6E3E4; padding: 6px;" id="post<?php echo $MyPostID; ?>">
 <div style="font-weight: bold; font-size: 0.8em; width: auto; float: left;"><?php echo $User1Name; ?></div>
 <div style="width:auto; font-size: 0.8em; color: gray; text-align:right;"><?php echo $MyTimeStamp; ?></div>
 </div>
 <div style="padding: 6px; font-size: 0.8em;"><?php echo $MyPost; ?></div></div>
-<?php ++$i; } @mysql_free_result($result); 
-?></div><div>&nbsp;</div><?php } } ?>
+<?php ++$i; } sql_free_result($result); 
+?></div><div>&nbsp;</div>
+<div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;">
+<?php echo $pstring; ?></div>
+<div>&nbsp;</div><?php } } ?>