OSDN Git Service

Small update and bugfix
[idb/iDB.git.git] / inc / lowreplies.php
1 <?php
2 /*
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the Revised BSD License.
5
6     This program is distributed in the hope that it will be useful,
7     but WITHOUT ANY WARRANTY; without even the implied warranty of
8     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9     Revised BSD License for more details.
10
11     Copyright 2004-2015 iDB Support - http://idb.berlios.de/
12     Copyright 2004-2015 Game Maker 2k - http://gamemaker2k.org/
13
14     $FileInfo: lowreplies.php - Last Update: 01/26/2017 SVN 810 - Author: cooldude2k $
15 */
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="replies.php"||$File3Name=="/replies.php") {
18         require('index.php');
19         exit(); }
20 $pstring = null; $pagenum = null;
21 if(!is_numeric($_GET['id'])) { $_GET['id'] = null; }
22 if(!is_numeric($_GET['post'])) { $_GET['post'] = null; }
23 if(!is_numeric($_GET['page'])) { $_GET['page'] = 1; }
24 if(!isset($_GET['st'])) { $_GET['st'] = 0; }
25 if(!is_numeric($_GET['st'])) { $_GET['st'] = 0; }
26 if(!isset($_GET['modact'])) { $_GET['modact'] = null; }
27 if($_GET['modact']=="pin"||$_GET['modact']=="unpin"||$_GET['modact']=="open"||
28         $_GET['modact']=="close"||$_GET['modact']=="edit"||$_GET['modact']=="delete")
29                 { $_GET['act'] = $_GET['modact']; }
30 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"id\"=%i".$ForumIgnoreList4." LIMIT 1", array($_GET['id']));
31 $preresult=sql_query($prequery,$SQLStat);
32 $prenum=sql_num_rows($preresult);
33 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);
34 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
35 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
36 if($prenum>=1) {
37 $TopicName=sql_result($preresult,0,"TopicName");
38 $TopicID=sql_result($preresult,0,"id");
39 $TopicForumID=sql_result($preresult,0,"ForumID");
40 $TopicCatID=sql_result($preresult,0,"CategoryID");
41 $TopicClosed=sql_result($preresult,0,"Closed");
42 if($TopicClosed==3&&$PermissionInfo['CanModForum'][$TopicForumID]=="no") { 
43 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);
44 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
45 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
46 if(!isset($_GET['post'])||$_GET['post']!==null) {
47 $NumberReplies=sql_result($preresult,0,"NumReply"); }
48 if(isset($_GET['post'])&&$_GET['post']!==null) {
49 $NumberReplies=1; }
50 $ViewTimes=sql_result($preresult,0,"NumViews");
51 sql_free_result($preresult);
52 $forumcheckx = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2."  LIMIT 1", array($TopicForumID));
53 $fmckresult=sql_query($forumcheckx,$SQLStat);
54 $fmcknum=sql_num_rows($fmckresult);
55 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);
56 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
57 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
58 $ForumID=sql_result($fmckresult,0,"id");
59 $ForumName=sql_result($fmckresult,0,"Name");
60 $ForumType=sql_result($fmckresult,0,"ForumType");
61 $ForumShow=sql_result($fmckresult,0,"ShowForum");
62 $InSubForum=sql_result($fmckresult,0,"InSubForum");
63 if($InSubForum!=0) {
64 $subforumcheckx = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2."  LIMIT 1", array($InSubForum));
65 $subfmckresult=sql_query($subforumcheckx,$SQLStat);
66 $subfmcknum=sql_num_rows($subfmckresult);
67 $SubForumName=sql_result($subfmckresult,0,"Name");
68 $SubForumType=sql_result($subfmckresult,0,"ForumType");
69 $InSubCategory=sql_result($catresult,0,"InSubCategory");
70 $SubForumShow=sql_result($subfmckresult,0,"ShowForum");
71 sql_free_result($subfmckresult); }
72 if($ForumShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
73 $CanHaveTopics=sql_result($fmckresult,0,"CanHaveTopics");
74 $ForumPostCountView=sql_result($fmckresult,0,"PostCountView");
75 $ForumKarmaCountView=sql_result($fmckresult,0,"KarmaCountView");
76 sql_free_result($fmckresult);
77 $catcheck = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2."  LIMIT 1", array($TopicCatID));
78 $catresult=sql_query($catcheck,$SQLStat);
79 $CategoryID=sql_result($catresult,0,"id");
80 $CategoryName=sql_result($catresult,0,"Name");
81 $CategoryShow=sql_result($catresult,0,"ShowCategory");
82 if($CategoryShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
83 $CategoryType=sql_result($catresult,0,"CategoryType");
84 $CategoryPostCountView=sql_result($catresult,0,"PostCountView");
85 $CategoryKarmaCountView=sql_result($catresult,0,"KarmaCountView");
86 sql_free_result($catresult);
87 if($GroupInfo['HasAdminCP']!="yes"||$GroupInfo['HasModCP']!="yes") {
88 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
89 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
90 if($ForumPostCountView!=0&&$MyPostCountChk<$ForumPostCountView) {
91 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
92 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
93 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
94 if($ForumKarmaCountView!=0&&$MyKarmaCount<$ForumKarmaCountView) {
95 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
96 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
97 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
98 if($ForumCheck!="skip") {
99 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=view&id=".$_GET['id']."&page=".$_GET['page'],"&","=",$prexqstr['topic'],$exqstr['topic']);
100 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
101 $_SESSION['ViewingFile'] = $exfile['topic'].$Settings['file_ext']; }
102 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
103 $_SESSION['ViewingFile'] = $exfile['topic']; }
104 $_SESSION['PreViewingTitle'] = "Viewing Topic:";
105 $_SESSION['ViewingTitle'] = $TopicName;
106 $_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:".$InSubCategory.",".$CategoryID."; currentforumid:".$InSubForum.",".$ForumID."; currenttopicid:".$TopicID."; currentmessageid:0; currenteventid:0; currentmemberid:0;"; 
107 ?>
108 <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>
109 <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=view&id=".$_GET['id']."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']); ?>"><?php echo $TopicName; ?></a></div>
110 <div>&nbsp;</div>
111 <?php }
112 if(!isset($CatPermissionInfo['CanViewCategory'][$TopicCatID])) {
113         $CatPermissionInfo['CanViewCategory'][$TopicCatID] = "no"; }
114 if($CatPermissionInfo['CanViewCategory'][$TopicCatID]=="no"||
115         $CatPermissionInfo['CanViewCategory'][$TopicCatID]!="yes") {
116 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
117 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
118 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
119 if(!isset($PermissionInfo['CanViewForum'][$TopicForumID])) {
120         $PermissionInfo['CanViewForum'][$TopicForumID] = "no"; }
121 if($PermissionInfo['CanViewForum'][$TopicForumID]=="no"||
122         $PermissionInfo['CanViewForum'][$TopicForumID]!="yes") {
123 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
124 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
125 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
126 if($_GET['act']!="view") { 
127 $CanMakeReply = "no"; $CanMakeTopic = "no";
128 if($PermissionInfo['CanMakeTopics'][$TopicForumID]=="yes"&&$CanHaveTopics=="yes") { 
129         $CanMakeTopic = "yes"; }
130 if($TopicClosed==0&&$PermissionInfo['CanMakeReplys'][$TopicForumID]=="yes") {
131         $CanMakeReply = "yes"; }
132 if($TopicClosed==1&&$PermissionInfo['CanMakeReplysClose'][$TopicForumID]=="yes"
133         &&$PermissionInfo['CanMakeReplys'][$TopicForumID]=="yes") {
134                 $CanMakeReply = "yes"; } } 
135 if($_GET['act']=="lowview") {
136 if($NumberReplies==null) { 
137         $NumberReplies = 0; }
138 $num=$NumberReplies+1;
139 //Start Reply Page Code
140 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
141 if($_GET['page']==null) { $_GET['page'] = 1; } 
142 if($_GET['page']<=0) { $_GET['page'] = 1; }
143 if($_GET['st']<=0||!isset($_GET['st'])) {
144 $nums = $_GET['page'] * $Settings['max_posts']; }
145 if($_GET['st']>0&&isset($_GET['st'])) {
146 $nums = $_GET['st']; }
147 if($nums>$num) { $nums = $num; }
148 $numz = $nums - $Settings['max_posts'];
149 if($numz<=0) { $numz = 0; }
150 //$i=$numz;
151 if($nums<$num) { $nextpage = $_GET['page'] + 1; }
152 if($nums>=$num) { $nextpage = $_GET['page']; }
153 if($numz>=$Settings['max_posts']) { $backpage = $_GET['page'] - 1; }
154 if($_GET['page']<=1) { $backpage = 1; }
155 $pnum = $num; $l = 1; $Pages = null;
156 while ($pnum>0) {
157 if($pnum>=$Settings['max_posts']) { 
158         $pnum = $pnum - $Settings['max_posts']; 
159         $Pages[$l] = $l; ++$l; }
160 if($pnum<$Settings['max_posts']&&$pnum>0) { 
161         $pnum = $pnum - $pnum; 
162         $Pages[$l] = $l; ++$l; } }
163 $snumber = $_GET['page'] - 1;
164 if($_GET['st']<=0||!isset($_GET['st'])) {
165 $PageLimit = $Settings['max_posts'] * $snumber; }
166 if($_GET['st']>0&&isset($_GET['st'])) {
167 $PageLimit = $_GET['st']; }
168 if($PageLimit<0) { $PageLimit = 0; }
169 //End Reply Page Code
170 $i=0;
171 if(!isset($_GET['post'])||$_GET['post']!==null) {
172 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i ORDER BY \"TimeStamp\" ASC ".$SQLimit, array($_GET['id'],$PageLimit,$Settings['max_posts'])); }
173 if(isset($_GET['post'])&&$_GET['post']!==null) {
174 $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'])); }
175 $result=sql_query($query,$SQLStat);
176 $num=sql_num_rows($result);
177 if($num==0) { redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
178 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
179 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
180 if($num!=0) { 
181 if($ViewTimes==0||$ViewTimes==null) { $NewViewTimes = 1; }
182 if($ViewTimes!=0&&$ViewTimes!=null) { $NewViewTimes = $ViewTimes + 1; }
183 $viewsup = sql_pre_query("UPDATE \"".$Settings['sqltable']."topics\" SET \"NumViews\"='%s' WHERE \"id\"=%i", array($NewViewTimes,$_GET['id']));
184 sql_query($viewsup,$SQLStat); }
185 //List Page Number Code Start
186 $pagenum=count($Pages);
187 if($_GET['page']>$pagenum) {
188         $_GET['page'] = $pagenum; }
189 $pagei=0; $pstring = null;
190 if($pagenum>1) {
191 $pstring = "<div class=\"PageList\"><span class=\"pagelink\">".$pagenum." Pages:</span> "; }
192 if($_GET['page']<4) { $Pagez[0] = null; }
193 if($_GET['page']>=4) { $Pagez[0] = "First"; }
194 if($_GET['page']>=3) {
195 $Pagez[1] = $_GET['page'] - 2; }
196 if($_GET['page']<3) {
197 $Pagez[1] = null; }
198 if($_GET['page']>=2) {
199 $Pagez[2] = $_GET['page'] - 1; }
200 if($_GET['page']<2) {
201 $Pagez[2] = null; }
202 $Pagez[3] = $_GET['page'];
203 if($_GET['page']<$pagenum) {
204 $Pagez[4] = $_GET['page'] + 1; }
205 if($_GET['page']>=$pagenum) {
206 $Pagez[4] = null; }
207 $pagenext = $_GET['page'] + 1;
208 if($pagenext<$pagenum) {
209 $Pagez[5] = $_GET['page'] + 2; }
210 if($pagenext>=$pagenum) {
211 $Pagez[5] = null; }
212 if($_GET['page']<$pagenum) { $Pagez[6] = "Last"; }
213 if($_GET['page']>=$pagenum) { $Pagez[6] = null; }
214 $pagenumi=count($Pagez);
215 if($num==0) {
216 $pagenumi = 0;
217 $pstring = null; }
218 if($pagenum>1) {
219 while ($pagei < $pagenumi) {
220 if($_GET['page']!=1&&$pagei==1) {
221 $Pback = $_GET['page'] - 1;
222 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pback,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">&lt;</a></span> "; }
223 if($Pagez[$pagei]!=null&&
224    $Pagez[$pagei]!="First"&&
225    $Pagez[$pagei]!="Last") {
226 if($pagei!=3) { 
227 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">".$Pagez[$pagei]."</a></span> "; }
228 if($pagei==3) { 
229 $pstring = $pstring."<span class=\"pagecurrent\"><a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">".$Pagez[$pagei]."</a></span> "; } }
230 if($Pagez[$pagei]=="First") {
231 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">&laquo;</a></span> "; }
232 if($Pagez[$pagei]=="Last") {
233 $ptestnext = $pagenext + 1;
234 $paget = $pagei - 1;
235 $Pnext = $_GET['page'] + 1;
236 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pnext,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">&gt;</a></span> ";
237 if($ptestnext<$pagenum) {
238 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$pagenum,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">&raquo;</a></span> "; } }
239         ++$pagei; } $pstring = $pstring."</div>"; }
240 //List Page Number Code end
241 $CanMakeReply = "no"; $CanMakeTopic = "no";
242 if($PermissionInfo['CanMakeTopics'][$TopicForumID]=="yes"&&$CanHaveTopics=="yes") { 
243         $CanMakeTopic = "yes"; }
244 if($TopicClosed==0&&$PermissionInfo['CanMakeReplys'][$TopicForumID]=="yes") {
245         $CanMakeReply = "yes"; }
246 if($TopicClosed==1&&$PermissionInfo['CanMakeReplysClose'][$TopicForumID]=="yes"
247         &&$PermissionInfo['CanMakeReplys'][$TopicForumID]=="yes") {
248                 $CanMakeReply = "yes"; }
249 ?>
250 <div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;">
251 <?php echo $pstring; ?></div>
252 <div>&nbsp;</div>
253 <div style="padding: 10px; border: 1px solid gray;">
254 <?php while ($i < $num) {
255 $MyPostID=sql_result($result,$i,"id");
256 $MyTopicID=sql_result($result,$i,"TopicID");
257 $MyPostIP=sql_result($result,$i,"IP");
258 $MyForumID=sql_result($result,$i,"ForumID");
259 $MyCategoryID=sql_result($result,$i,"CategoryID");
260 $MyUserID=sql_result($result,$i,"UserID");
261 $MyGuestName=sql_result($result,$i,"GuestName");
262 $MyTimeStamp=sql_result($result,$i,"TimeStamp");
263 $MyEditTime=sql_result($result,$i,"LastUpdate");
264 $MyEditUserID=sql_result($result,$i,"EditUser");
265 $MyEditUserName=sql_result($result,$i,"EditUserName");
266 $tmpusrcurtime = new DateTime();
267 $tmpusrcurtime->setTimestamp($MyTimeStamp);
268 $tmpusrcurtime->setTimezone($usertz);
269 $MyTimeStamp=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
270 $MyPost=sql_result($result,$i,"Post");
271 $MyDescription=sql_result($result,$i,"Description");
272 $requery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
273 $reresult=sql_query($requery,$SQLStat);
274 $renum=sql_num_rows($reresult);
275 if($renum<1) { $MyUserID = -1;
276 $requery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
277 $reresult=sql_query($requery,$SQLStat);
278 $renum=sql_num_rows($reresult); }
279 $memrequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."mempermissions\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
280 $memreresult=sql_query($memrequery,$SQLStat);
281 $memrenum=sql_num_rows($memreresult);
282 $rei=0; $ipshow = "two";
283 $User1ID=$MyUserID; $GuestsName = $MyGuestName;
284 $User1Name=sql_result($reresult,$rei,"Name");
285 $User1IP=sql_result($reresult,$rei,"IP");
286 if($User1IP==$MyPostIP) { $ipshow = "one"; }
287 $User1Email=sql_result($reresult,$rei,"Email");
288 $User1Title=sql_result($reresult,$rei,"Title");
289 $PreUserCanExecPHP=sql_result($memreresult,$rei,"CanExecPHP");
290 if($PreUserCanExecPHP!="yes"&&$PreUserCanExecPHP!="no"&&$PreUserCanExecPHP!="group") {
291         $PreUserCanExecPHP = "no"; }
292 $PreUserCanDoHTML=sql_result($memreresult,$rei,"CanDoHTML");
293 if($PreUserCanDoHTML!="yes"&&$PreUserCanDoHTML!="no"&&$PreUserCanDoHTML!="group") {
294         $PreUserCanDoHTML = "no"; }
295 $PreUserCanUseBBTags=sql_result($memreresult,$rei,"CanUseBBTags");
296 if($PreUserCanUseBBTags!="yes"&&$PreUserCanUseBBTags!="no"&&$PreUserCanUseBBTags!="group") {
297         $PreUserCanUseBBTags = "no"; }
298 sql_free_result($memreresult);
299 $User1Joined=sql_result($reresult,$rei,"Joined");
300 $tmpusrcurtime = new DateTime();
301 $tmpusrcurtime->setTimestamp($User1Joined);
302 $tmpusrcurtime->setTimezone($usertz);
303 $User1Joined=$tmpusrcurtime->format($_SESSION['iDBDateFormat']);
304 $User1GroupID=sql_result($reresult,$rei,"GroupID");
305 $gquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($User1GroupID));
306 $gresult=sql_query($gquery,$SQLStat);
307 $User1Group=sql_result($gresult,0,"Name");
308 $User1CanExecPHP = $PreUserCanExecPHP;
309 if($PreUserCanExecPHP=="group") {
310 $User1CanExecPHP=sql_result($gresult,0,"CanExecPHP"); }
311 if($User1CanExecPHP!="yes"&&$User1CanExecPHP!="no") {
312         $User1CanExecPHP = "no"; }
313 $User1CanDoHTML = $PreUserCanDoHTML;
314 if($PreUserCanDoHTML=="group") {
315 $User1CanDoHTML=sql_result($gresult,0,"CanDoHTML"); }
316 if($User1CanDoHTML!="yes"&&$User1CanDoHTML!="no") {
317         $User1CanDoHTML = "no"; }
318 $User1CanUseBBTags = $PreUserCanUseBBTags;
319 if($User1CanUseBBTags=="group") {
320 $User1CanUseBBTags=sql_result($gresult,0,"CanUseBBTags"); }
321 if($User1CanUseBBTags!="yes"&&$User1CanUseBBTags!="no") {
322         $User1CanUseBBTags = "no"; }
323 $GroupNamePrefix=sql_result($gresult,0,"NamePrefix");
324 $GroupNameSuffix=sql_result($gresult,0,"NameSuffix");
325 $User1PermissionID=sql_result($gresult,0,"PermissionID");
326 sql_free_result($gresult);
327 $per1query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."permissions\" WHERE \"PermissionID\"=%i LIMIT 1", array($User1PermissionID));
328 $per1esult=sql_query($per1query,$SQLStat);
329 $per1num=sql_num_rows($per1esult);
330 $User1CanDoHTML1=sql_result($per1esult,0,"CanDoHTML");
331 if($User1CanDoHTML1!="yes"&&$User1CanDoHTML1!="no") {
332         $User1CanDoHTML1 = "no"; }
333 $User1CanUseBBTags1=sql_result($per1esult,0,"CanUseBBTags");
334 if($User1CanUseBBTags1!="yes"&&$User1CanUseBBTags1!="no") {
335         $User1CanUseBBTags1 = "no"; }
336 sql_free_result($per1esult);
337 $User1Signature=sql_result($reresult,$rei,"Signature");
338 $User1Avatar=sql_result($reresult,$rei,"Avatar");
339 $User1AvatarSize=sql_result($reresult,$rei,"AvatarSize");
340 if ($User1Avatar=="http://"||$User1Avatar==null||
341         strtolower($User1Avatar)=="noavatar") {
342 $User1Avatar=$ThemeSet['NoAvatar'];
343 $User1AvatarSize=$ThemeSet['NoAvatarSize']; }
344 $AvatarSize1=explode("x", $User1AvatarSize);
345 $AvatarSize1W=$AvatarSize1[0]; $AvatarSize1H=$AvatarSize1[1];
346 $User1Website=sql_result($reresult,$rei,"Website");
347 $BoardWWWChCk = parse_url($Settings['idburl']);
348 if($User1Website=="http://") { 
349         $User1Website = $Settings['idburl']; }
350 $User1WWWChCk = parse_url($User1Website);
351 $User1Website = urlcheck($User1Website);
352 $opennew = " onclick=\"window.open(this.href);return false;\"";
353 if($BoardWWWChCk['host']==$User1WWWChCk['host']) {
354         $opennew = null; }
355 $User1PostCount=sql_result($reresult,$rei,"PostCount");
356 $User1Karma=sql_result($reresult,$rei,"Karma");
357 $User1IP=sql_result($reresult,$rei,"IP");
358 sql_free_result($reresult);
359 if($User1Name=="Guest") { $User1Name=$GuestsName;
360 if($User1Name==null) { $User1Name="Guest"; } }
361 if(isset($GroupNamePrefix)&&$GroupNamePrefix!=null) {
362         $User1Name = $GroupNamePrefix.$User1Name; }
363 if(isset($GroupNameSuffix)&&$GroupNameSuffix!=null) {
364         $User1Name = $User1Name.$GroupNameSuffix; }
365 $MySubPost = null;
366 if($MyEditTime!=$MyTimeStamp&&$MyEditUserID!=0) {
367 if($MyEditUserID!=$MyUserID) {
368 $euquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyEditUserID));
369 $euresult = sql_query($euquery,$SQLStat);
370 $eunum = sql_num_rows($euresult);
371 if($eunum<1) { $MyEditUserID = -1;
372 $euquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyEditUserID));
373 $euresult = sql_query($euquery,$SQLStat);
374 $eunum = sql_num_rows($euresult); }
375         $EditUserID = $MyEditUserID;
376         $EditUserGroupID = sql_result($euresult,0,"GroupID");
377         $EditUserHidden=sql_result($euresult,0,"HiddenMember");
378         $EditUserName = sql_result($euresult,0,"Name");
379         sql_free_result($euresult);
380         $eugquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($EditUserGroupID));
381         $eugresult=sql_query($eugquery,$SQLStat);
382         $EditUserGroup=sql_result($eugresult,0,"Name");
383         $EditUserNamePrefix=sql_result($eugresult,0,"NamePrefix");
384         $EditUserNameSuffix=sql_result($eugresult,0,"NameSuffix");
385         sql_free_result($eugresult);    }
386         if($MyEditUserID==$MyUserID) {
387         $EditUserID = $User1ID;
388         $EditUserGroupID = $User1GroupID;
389         //$EditUserHidden=$User1Hidden;
390         $EditUserName = $User1Name;
391         $EditUserGroup=$User1Group;
392         $EditUserNamePrefix=null;
393         $EditUserNameSuffix=null; }
394         if($EditUserName=="Guest") { $EditUserName=$MyEditUserName;
395         if($EditUserName==null) { $EditUserName="Guest"; } }
396         if(isset($GroupNamePrefix)&&$GroupNamePrefix!=null) {
397                 $EditUserName = $EditUserNamePrefix.$EditUserName; }
398         if(isset($GroupNameSuffix)&&$GroupNameSuffix!=null) {
399                 $EditUserName = $EditUserName.$EditUserNameSuffix; }
400         $tmpusrcurtime = new DateTime();
401         $tmpusrcurtime->setTimestamp($MyEditTime);
402         $tmpusrcurtime->setTimezone($usertz);
403         $MyEditTime = $tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
404         $MySubPost = "<div class=\"EditReply\"><br />This post has been edited by <b>".$EditUserName."</b> on ".$MyEditTime."</div>"; }
405 if($MyEditTime!=$MyTimeStamp&&$MyEditUserID!=0&&$MyEditUserID!=$MyUserID) {
406 $requery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"id\"=%i LIMIT 1", array($MyUserID));
407 $reresult=sql_query($requery,$SQLStat);
408 $renum=sql_num_rows($reresult);
409 $rei=0; $ipshow = "two";
410 $User1ID=$MyUserID; $GuestsName = $MyGuestName;
411 $User1Name=sql_result($reresult,$rei,"Name");
412 $User1IP=sql_result($reresult,$rei,"IP");
413 if($User1IP==$MyPostIP) { $ipshow = "one"; }
414 $User1Email=sql_result($reresult,$rei,"Email");
415 $User1Title=sql_result($reresult,$rei,"Title");
416 $User1Joined=sql_result($reresult,$rei,"Joined");
417 $tmpusrcurtime = new DateTime();
418 $tmpusrcurtime->setTimestamp($User1Joined);
419 $tmpusrcurtime->setTimezone($usertz);
420 $User1Joined=$tmpusrcurtime->format($_SESSION['iDBDateFormat']);
421 $User1Hidden=sql_result($reresult,$rei,"HiddenMember");
422 $User1GroupID=sql_result($reresult,$rei,"GroupID");
423 $gquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($User1GroupID));
424 $gresult=sql_query($gquery,$SQLStat);
425 $User1Group=sql_result($gresult,0,"Name");
426 $GroupNamePrefix=sql_result($gresult,0,"NamePrefix");
427 $GroupNameSuffix=sql_result($gresult,0,"NameSuffix");
428 sql_free_result($gresult); }
429 if($User1CanUseBBTags1=="yes") { $MyPost = bbcode_parser($MyPost); }
430 if($User1CanExecPHP=="no") {
431 $MyPost = preg_replace("/\[ExecPHP\](.*?)\[\/ExecPHP\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute php code.",$MyPost); }
432 if($User1CanExecPHP=="yes") { $MyPost = php_execute($MyPost); }
433 if($User1CanDoHTML1=="no") {
434 $MyPost = preg_replace("/\[DoHTML\](.*?)\[\/DoHTML\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute html.",$MyPost); }
435 if($User1CanDoHTML1=="yes") { $MyPost = do_html_bbcode($MyPost); }
436 $MyPost = text2icons($MyPost,$Settings['sqltable'],$SQLStat);
437 $MyPost = preg_replace("/\<br\>/", "<br />", nl2br($MyPost));
438 $MyPost = url2link($MyPost);
439 if($MySubPost!=null) { $MyPost = $MyPost."\n".$MySubPost; }
440 if($User1CanUseBBTags=="yes") { $User1Signature = bbcode_parser($User1Signature); }
441 if($User1CanExecPHP=="no") {
442 $User1Signature = preg_replace("/\[ExecPHP\](.*?)\[\/ExecPHP\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute php code.",$User1Signature); }
443 if($User1CanExecPHP=="yes") { $User1Signature = php_execute($User1Signature); }
444 if($User1CanDoHTML1=="no") {
445 $User1Signature = preg_replace("/\[DoHTML\](.*?)\[\/DoHTML\]/is","<span style=\"color: red; font-weight: bold;\">ERROR:</span> cannot execute html.",$User1Signature); }
446 if($User1CanDoHTML=="yes") { $User1Signature = do_html_bbcode($User1Signature); }
447 $User1Signature = text2icons($User1Signature,$Settings['sqltable'],$SQLStat);
448 $User1Signature = preg_replace("/\<br\>/", "<br />", nl2br($User1Signature));
449 $User1Signature = url2link($User1Signature);
450 $CanEditReply = false; $CanDeleteReply = false;
451 if($_SESSION['UserGroup']!=$Settings['GuestGroup']) {
452 if($PermissionInfo['CanEditReplys'][$MyForumID]=="yes"&&
453         $_SESSION['UserID']==$MyUserID) { $CanEditReply = true; }
454 if($PermissionInfo['CanDeleteReplys'][$MyForumID]=="yes"&&
455         $_SESSION['UserID']==$MyUserID) { $CanDeleteReply = true; }
456 if($PermissionInfo['CanModForum'][$MyForumID]=="yes") { 
457         $CanEditReply = true; $CanDeleteReply = true; } }
458 if($_SESSION['UserID']==0) { 
459         $CanEditReply = false; $CanDeleteReply = false; }
460 $ReplyNum = $i + $PageLimit + 1;
461 ?>
462 <div style="border:1px solid #E6E3E4; padding:1px; margin-bottom: 15px;" id="reply<?php echo $ReplyNum; ?>">
463 <div style="border: 1px solid #E6E3E4; padding:1px; margin-bottom: 15px; background-color: #E6E3E4; padding: 6px;" id="post<?php echo $MyPostID; ?>">
464 <div style="font-weight: bold; font-size: 0.8em; width: auto; float: left;"><?php echo $User1Name; ?></div>
465 <div style="width:auto; font-size: 0.8em; color: gray; text-align:right;"><?php echo $MyTimeStamp; ?></div>
466 </div>
467 <div style="padding: 6px; font-size: 0.8em;"><?php echo $MyPost; ?></div></div>
468 <?php ++$i; } sql_free_result($result); 
469 ?></div><div>&nbsp;</div>
470 <div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;">
471 <?php echo $pstring; ?></div>
472 <div>&nbsp;</div><?php } } ?>