OSDN Git Service

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