OSDN Git Service

Small bug fix and update. :P
[idb/iDB.git.git] / inc / groupsetup.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: groupsetup.php - Last Update: 11/19/2011 SVN 771 - Author: cooldude2k $
15 */
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="groupsetup.php"||$File3Name=="/groupsetup.php") {
18         require('index.php');
19         exit(); }
20 //Set members temp location
21 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']);
22 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
23 $_SESSION['ViewingFile'] = $exfile['index'].$Settings['file_ext']; }
24 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
25 $_SESSION['ViewingFile'] = $exfile['index']; }
26 $_SESSION['PreViewingTitle'] = "Viewing";
27 $_SESSION['ViewingTitle'] = "Board index";
28 /*$ggidquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"Name\"='%s' LIMIT 1", array($Settings['GuestGroup']));
29 $ggidresult=sql_query($ggidquery,$SQLStat);
30 $Settings['GuestGroupID']=sql_result($ggidresult,0,"id");*/
31 // Check to make sure MemberInfo is right
32 $MyPostCountChk = null; $MyKarmaCount = null;
33 if(!isset($_SESSION['UserID'])) { $_SESSION['UserID'] = 0; }
34 if($_SESSION['UserID']!=0&&$_SESSION['UserID']!=null) { $BanError = null;
35 $kgbquerychkusr = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"Name\"='%s' AND \"UserPassword\"='%s' AND \"id\"=%i LIMIT 1", array($_SESSION['MemberName'],$_SESSION['UserPass'],$_SESSION['UserID'])); 
36 $resultchkusr=sql_query($kgbquerychkusr,$SQLStat);
37 $numchkusr=sql_num_rows($resultchkusr);
38 if($numchkusr==1) {
39 $ChkUsrID=sql_result($resultchkusr,0,"id");
40 $ChkUsrName=sql_result($resultchkusr,0,"Name");
41 $ChkUsrGroup=sql_result($resultchkusr,0,"GroupID");
42 $ChkUsrGroupID=$ChkUsrGroup;
43 $ChkUsrPass=sql_result($resultchkusr,0,"UserPassword");
44 $ChkUsrTimeZone=sql_result($resultchkusr,0,"TimeZone");
45 $ChkUsrDateFormat=sql_result($resultchkusr,0,"DateFormat");
46 $ChkUsrTimeFormat=sql_result($resultchkusr,0,"TimeFormat");
47 $ChkUsrTheme=sql_result($resultchkusr,0,"UseTheme");
48 $ChkUsrLastPostTime=sql_result($resultchkusr,0,"LastPostTime");
49 $MyPostCountChk=sql_result($resultchkusr,0,"PostCount");
50 $MyKarmaCount=sql_result($resultchkusr,0,"Karma");
51 $MyKarmaUpdate=sql_result($resultchkusr,0,"KarmaUpdate");
52 $MyRepliesPerPage=sql_result($resultchkusr,0,"RepliesPerPage");
53 $Settings['max_posts'] = $MyRepliesPerPage;
54 $MyTopicsPerPage=sql_result($resultchkusr,0,"TopicsPerPage");
55 $Settings['max_topics'] = $MyTopicsPerPage;
56 $MyMessagesPerPage=sql_result($resultchkusr,0,"MessagesPerPage");
57 $Settings['max_memlist'] = $MyMessagesPerPage;
58 $Settings['max_pmlist'] = $MyMessagesPerPage;
59 $ChkUsrDST=sql_result($resultchkusr,0,"DST");
60 $svrquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($ChkUsrGroup));
61 $svrgresultkgb=sql_query($svrquery,$SQLStat);
62 $ChkUsrGroup=sql_result($svrgresultkgb,0,"Name"); 
63 $ChkUsrBanTime=sql_result($resultchkusr,0,"BanTime");
64 $ChkUsrGMTime = GMTimeStamp();
65 if($ChkUsrBanTime!=0&&$ChkUsrBanTime!=null) {
66 if($ChkUsrBanTime>=$ChkUsrGMTime) { $BanError = "yes"; }
67 if($ChkUsrBanTime<0) { $BanError = "yes"; } }
68 if($BanError!="yes") {
69 $_SESSION['Theme']=$ChkUsrTheme;
70 $_SESSION['MemberName']=$ChkUsrName;
71 $_SESSION['UserID']=$ChkUsrID;
72 $_SESSION['UserIP']=$_SERVER['REMOTE_ADDR'];
73 $_SESSION['UserTimeZone']=$ChkUsrTimeZone;
74 $_SESSION['iDBDateFormat']=$ChkUsrDateFormat;
75 $_SESSION['iDBTimeFormat']=$ChkUsrTimeFormat;
76 $_SESSION['UserGroup']=$ChkUsrGroup;
77 $_SESSION['UserGroupID']=$ChkUsrGroupID;
78 $_SESSION['UserDST']=$ChkUsrDST;
79 $_SESSION['UserPass']=$ChkUsrPass;
80 $_SESSION['LastPostTime'] = $ChkUsrLastPostTime; } }
81 if($numchkusr<=0||$numchkusr>1||$BanError=="yes") { session_unset();
82 if($cookieDomain==null) {
83 setcookie("MemberName", null, GMTimeStamp() - 3600, $cbasedir);
84 setcookie("UserID", null, GMTimeStamp() - 3600, $cbasedir);
85 setcookie("SessPass", null, GMTimeStamp() - 3600, $cbasedir);
86 setcookie(session_name(), "", GMTimeStamp() - 3600, $cbasedir); }
87 if($cookieDomain!=null) {
88 if($cookieSecure===true) {
89 setcookie("MemberName", null, GMTimeStamp() - 3600, $cbasedir, $cookieDomain, 1);
90 setcookie("UserID", null, GMTimeStamp() - 3600, $cbasedir, $cookieDomain, 1);
91 setcookie("SessPass", null, GMTimeStamp() - 3600, $cbasedir, $cookieDomain, 1);
92 setcookie(session_name(), "", GMTimeStamp() - 3600, $cbasedir, $cookieDomain, 1); }
93 if($cookieSecure===false) {
94 setcookie("MemberName", null, GMTimeStamp() - 3600, $cbasedir, $cookieDomain);
95 setcookie("UserID", null, GMTimeStamp() - 3600, $cbasedir, $cookieDomain);
96 setcookie("SessPass", null, GMTimeStamp() - 3600, $cbasedir, $cookieDomain);
97 setcookie(session_name(), "", GMTimeStamp() - 3600, $cbasedir, $cookieDomain); } }
98 unset($_COOKIE[session_name()]);
99 $_SESSION = array(); session_unset(); session_destroy();
100 redirect("location",$rbasedir.url_maker($exfile['member'],$Settings['file_ext'],"act=login",$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'],false)); sql_free_result($resultchkusr); sql_free_result($svrgresultkgb);
101 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
102 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
103 sql_free_result($resultchkusr); sql_free_result($svrgresultkgb); }
104 if($_SESSION['UserID']==0||$_SESSION['UserID']==null) {
105 $_SESSION['UserIP']=$_SERVER['REMOTE_ADDR'];
106 $_SESSION['MemberName'] = null;
107 $_SESSION['UserGroup'] = $Settings['GuestGroup']; 
108 $gidquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"Name\"='%s' LIMIT 1", array($Settings['GuestGroup']));
109 $gidresult=sql_query($gidquery,$SQLStat);
110 $_SESSION['UserGroupID']=sql_result($gidresult,0,"id"); 
111 sql_free_result($gidresult); }
112 if($_SESSION['MemberName']==null) { $_SESSION['UserID'] = "0";
113 $_SESSION['UserIP']=$_SERVER['REMOTE_ADDR'];
114 $_SESSION['UserGroup'] = $Settings['GuestGroup']; 
115 $gidquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"Name\"='%s' LIMIT 1", array($Settings['GuestGroup']));
116 $gidresult=sql_query($gidquery,$SQLStat);
117 $_SESSION['UserGroupID']=sql_result($gidresult,0,"id"); 
118 sql_free_result($gidresult); }
119 // Member Group Setup
120 if(!isset($_SESSION['UserGroup'])) { $_SESSION['UserGroup'] = null; }
121 if($_SESSION['UserGroup']==null) { 
122 $_SESSION['UserGroup']=$Settings['GuestGroup']; } $GruError = null;
123 $gruquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"Name\"='%s' LIMIT 1", array($_SESSION['UserGroup']));
124 $gruresult=sql_query($gruquery,$SQLStat);
125 $grunum=sql_num_rows($gruresult);
126 if($grunum<=0) { $GruError = true; sql_free_result($gruresult);
127 header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 503;
128 ob_clean(); echo "Sorry could not find group data in database.\nContact the board admin about error."; 
129 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
130 if($_SESSION['UserID']!=0) {
131 $memprequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."mempermissions\" WHERE \"id\"=%i LIMIT 1", array($_SESSION['UserID'])); }
132 if($_SESSION['UserID']==0) {
133 $memprequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."mempermissions\" WHERE \"id\"=%i LIMIT 1", array(-1)); }
134 $mempreresult=sql_query($memprequery,$SQLStat);
135 $memprenum=sql_num_rows($mempreresult);
136 if($grunum>=1) {
137 $GroupInfo['ID']=sql_result($gruresult,0,"id");
138 if(!is_numeric($GroupInfo['ID'])) { $GruError = true; }
139 $GroupInfo['Name']=sql_result($gruresult,0,"Name");
140 $GroupInfo['PermissionID']=sql_result($mempreresult,0,"PermissionID");
141 if(!is_numeric($GroupInfo['PermissionID'])||$GroupInfo['PermissionID']=="0") {
142 $GroupInfo['PermissionID']=sql_result($gruresult,0,"PermissionID");
143 if(!is_numeric($GroupInfo['PermissionID'])) { $GruError = true; } }
144 $GroupInfo['NamePrefix']=sql_result($gruresult,0,"NamePrefix");
145 $GroupInfo['NameSuffix']=sql_result($gruresult,0,"NameSuffix");
146 $GroupInfo['CanViewBoard']=sql_result($mempreresult,0,"CanViewBoard");
147 if($GroupInfo['CanViewBoard']!="yes"&&$GroupInfo['CanViewBoard']!="no"&&$GroupInfo['CanViewBoard']!="group") {
148                 $GruError = true; }
149 if($GroupInfo['CanViewBoard']=="group") {
150 $GroupInfo['CanViewBoard']=sql_result($gruresult,0,"CanViewBoard");
151 if($GroupInfo['CanViewBoard']!="yes"&&$GroupInfo['CanViewBoard']!="no") {
152                 $GruError = true; } }
153 $GroupInfo['CanViewOffLine']=sql_result($mempreresult,0,"CanViewOffLine");
154 if($GroupInfo['CanViewOffLine']!="yes"&&$GroupInfo['CanViewOffLine']!="no"&&$GroupInfo['CanViewOffLine']!="group") {
155                 $GruError = true; }
156 if($GroupInfo['CanViewOffLine']=="group") {
157 $GroupInfo['CanViewOffLine']=sql_result($gruresult,0,"CanViewOffLine");
158 if($GroupInfo['CanViewOffLine']!="yes"&&$GroupInfo['CanViewOffLine']!="no") {
159                 $GruError = true; } }
160 $GroupInfo['FloodControl']=sql_result($mempreresult,0,"FloodControl");
161 if(!is_numeric($GroupInfo['FloodControl'])) { $GroupInfo['FloodControl'] = 30; }
162 if($GroupInfo['FloodControl']==-1) {
163 $GroupInfo['FloodControl']=sql_result($gruresult,0,"FloodControl");
164 if(!is_numeric($GroupInfo['FloodControl'])) { $GroupInfo['FloodControl'] = 30; } }
165 $GroupInfo['SearchFlood']=sql_result($mempreresult,0,"SearchFlood");
166 if(!is_numeric($GroupInfo['SearchFlood'])) { $GroupInfo['SearchFlood'] = 30; }
167 if($GroupInfo['SearchFlood']==-1) {
168 $GroupInfo['SearchFlood']=sql_result($gruresult,0,"SearchFlood");
169 if(!is_numeric($GroupInfo['SearchFlood'])) { $GroupInfo['SearchFlood'] = 30; } }
170 $GroupInfo['CanEditProfile']=sql_result($mempreresult,0,"CanEditProfile");
171 if($GroupInfo['CanEditProfile']!="yes"&&$GroupInfo['CanEditProfile']!="no"&&$GroupInfo['CanEditProfile']!="group") {
172                 $GruError = true; }
173 if($GroupInfo['CanEditProfile']=="group") {
174 $GroupInfo['CanEditProfile']=sql_result($gruresult,0,"CanEditProfile");
175 if($GroupInfo['CanEditProfile']!="yes"&&$GroupInfo['CanEditProfile']!="no") {
176                 $GruError = true; } }
177 $GroupInfo['CanAddEvents']=sql_result($mempreresult,0,"CanAddEvents");
178 if($GroupInfo['CanAddEvents']!="yes"&&$GroupInfo['CanAddEvents']!="no"&&$GroupInfo['CanAddEvents']!="group") {
179                 $GruError = true; }
180 if($GroupInfo['CanAddEvents']=="group") {
181 $GroupInfo['CanAddEvents']=sql_result($gruresult,0,"CanAddEvents");
182 if($GroupInfo['CanAddEvents']!="yes"&&$GroupInfo['CanAddEvents']!="no") {
183                 $GruError = true; } }
184 $GroupInfo['CanPM']=sql_result($mempreresult,0,"CanPM");
185 if($GroupInfo['CanPM']!="yes"&&$GroupInfo['CanPM']!="no"&&$GroupInfo['CanPM']!="group") {
186                 $GruError = true; }
187 if($GroupInfo['CanPM']=="group") {
188 $GroupInfo['CanPM']=sql_result($gruresult,0,"CanPM");
189 if($GroupInfo['CanPM']!="yes"&&$GroupInfo['CanPM']!="no") {
190                 $GruError = true; } }
191 $GroupInfo['CanSearch']=sql_result($mempreresult,0,"CanSearch");
192 if($GroupInfo['CanSearch']!="yes"&&$GroupInfo['CanSearch']!="no"&&$GroupInfo['CanSearch']!="group") {
193                 $GruError = true; }
194 if($GroupInfo['CanSearch']=="group") {
195 $GroupInfo['CanSearch']=sql_result($gruresult,0,"CanSearch");
196 if($GroupInfo['CanSearch']!="yes"&&$GroupInfo['CanSearch']!="no") {
197                 $GruError = true; } }
198 $GroupInfo['CanExecPHP']=sql_result($mempreresult,0,"CanExecPHP");
199 if($GroupInfo['CanExecPHP']!="yes"&&$GroupInfo['CanExecPHP']!="no"&&$GroupInfo['CanExecPHP']!="group") {
200         $GroupInfo['CanExecPHP'] = "no"; }
201 if($GroupInfo['CanExecPHP']=="group") {
202 $GroupInfo['CanExecPHP']=sql_result($gruresult,0,"CanExecPHP");
203 if($GroupInfo['CanExecPHP']!="yes"&&$GroupInfo['CanExecPHP']!="no") {
204         $GroupInfo['CanExecPHP'] = "no"; } }
205 $GroupInfo['CanDoHTML']=sql_result($mempreresult,0,"CanDoHTML");
206 if($GroupInfo['CanDoHTML']!="yes"&&$GroupInfo['CanDoHTML']!="no"&&$GroupInfo['CanDoHTML']!="group") {
207         $GroupInfo['CanDoHTML'] = "no"; }
208 if($GroupInfo['CanDoHTML']=="group") {
209 $GroupInfo['CanDoHTML']=sql_result($gruresult,0,"CanDoHTML");
210 if($GroupInfo['CanDoHTML']!="yes"&&$GroupInfo['CanDoHTML']!="no") {
211         $GroupInfo['CanDoHTML'] = "no"; } }
212 $GroupInfo['CanUseBBags']=sql_result($mempreresult,0,"CanUseBBags");
213 if($GroupInfo['CanUseBBags']!="yes"&&$GroupInfo['CanUseBBags']!="no"&&$GroupInfo['CanUseBBags']!="group") {
214         $GroupInfo['CanUseBBags'] = "no"; }
215 if($GroupInfo['CanUseBBags']=="group") {
216 $GroupInfo['CanUseBBags']=sql_result($gruresult,0,"CanUseBBags");
217 if($GroupInfo['CanUseBBags']!="yes"&&$GroupInfo['CanUseBBags']!="no") {
218         $GroupInfo['CanUseBBags'] = "no"; } }
219 $GroupInfo['PromoteTo']=sql_result($gruresult,0,"PromoteTo");
220 $GroupInfo['PromotePosts']=sql_result($gruresult,0,"PromotePosts");
221 if(!is_numeric($GroupInfo['PromotePosts'])) { 
222         $GroupInfo['PromotePosts'] = 0; $GroupInfo['PromoteTo'] = 0; }
223 $GroupInfo['PromoteKarma']=sql_result($gruresult,0,"PromoteKarma");
224 if(!is_numeric($GroupInfo['PromoteKarma'])) { 
225         $GroupInfo['PromoteKarma'] = 0; $GroupInfo['PromoteTo'] = 0; }
226 if(!isset($Settings['KarmaBoostDays'])) {
227         $Settings['KarmaBoostDays'] = null; }
228 $Settings['OldKarmaBoostDays'] = $Settings['KarmaBoostDays'];
229 if(!isset($Settings['KBoostPercent'])) {
230         $Settings['KBoostPercent'] = "6|10"; }
231 //Update karma and group upgrade on post count or karma count.
232 if($_SESSION['UserID']!=0) { $BoostTotal = null;
233 $KarmaExp = explode("&",$Settings['KarmaBoostDays']);
234 $KarmaNow = GMTimeGet("md",$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
235 $kupdate = false;
236 if(in_array($KarmaNow,$KarmaExp)) {
237 $KarmaNum = count($KarmaExp); 
238 $Karmai = 0;
239 while ($Karmai < $KarmaNum) {
240 if($KarmaExp[$Karmai]==$KarmaNow) { 
241 $Settings['KarmaBoostDays'] = $KarmaExp[$Karmai]; 
242 $kupdate = true; break 1; }
243 ++$Karmai; } }
244 if($kupdate===false) {
245 $Settings['KarmaBoostDays'] = $KarmaExp[0]; }
246 $NewKarmaUpdate = GMTimeGet("Ymd",$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
247 $ThisYearUpdate = GMTimeGet("Y",$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
248 if($MyKarmaUpdate<$NewKarmaUpdate&&$MyPostCountChk>0) { 
249         $KarmaBoostDay = $Settings['KarmaBoostDays'];
250         $KBoostPercent = explode("|",$Settings['KBoostPercent']);
251         if(count($KBoostPercent)<1) { 
252         $KBoostPercent[0] = rand(1,4); }
253         if(!is_numeric($KBoostPercent[0])) {
254         $KBoostPercent[0] = 6; }
255         if(count($KBoostPercent)==1) { 
256         $KBoostPercent[1] = $KBoostPercent[0] + rand(3,6); }
257         if(!is_numeric($KBoostPercent[1])) {
258         $KBoostPercent[0] = 10; }
259         $KBoostPercent = rand($KBoostPercent[0],$KBoostPercent[1]);
260         if($ThisYearUpdate.$KarmaBoostDay==$NewKarmaUpdate&&
261         is_numeric($KarmaBoostDay)) {
262         $KBoostPercent = $KBoostPercent / 100;
263         $BoostTotal = $MyKarmaCount * $KBoostPercent;
264         $BoostTotal = round($BoostTotal,0); }
265         if($BoostTotal!=null) {
266         $MyKarmaCount = $MyKarmaCount + $BoostTotal; }
267         if($BoostTotal==null) {
268         $MyKarmaCount = $MyKarmaCount + 1; }
269         $querykarmaup = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"Karma\"=%i,\"KarmaUpdate\"=%i WHERE \"id\"=%i", array($MyKarmaCount,$NewKarmaUpdate,$_SESSION['UserID']));
270         sql_query($querykarmaup,$SQLStat); }
271         $Settings['KarmaBoostDays'] = $Settings['OldKarmaBoostDays'];
272 if($GroupInfo['PromoteTo']!=0&&$MyPostCountChk>=$GroupInfo['PromotePosts']) {
273         $sql_group_check = sql_query(sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($GroupInfo['PromoteTo'])),$SQLStat);
274         $group_check = sql_num_rows($sql_group_check);
275         sql_free_result($sql_group_check);
276         if($group_check > 0) {
277         $queryupgrade = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"GroupID\"=%i WHERE \"id\"=%i", array($GroupInfo['PromoteTo'],$_SESSION['UserID']));
278         sql_query($queryupgrade,$SQLStat); } }
279 if($GroupInfo['PromotePosts']==0&&$GroupInfo['PromoteTo']!=0&&$MyKarmaCount>=$GroupInfo['PromoteKarma']) {
280         $sql_group_check = sql_query(sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."groups\" WHERE \"id\"=%i LIMIT 1", array($GroupInfo['PromoteTo'])),$SQLStat);
281         $group_check = sql_num_rows($sql_group_check);
282         sql_free_result($sql_group_check);
283         if($group_check > 0) {
284         $queryupgrade = sql_pre_query("UPDATE \"".$Settings['sqltable']."members\" SET \"GroupID\"=%i WHERE \"id\"=%i", array($GroupInfo['PromoteTo'],$_SESSION['UserID']));
285         sql_query($queryupgrade,$SQLStat); } } }
286 $GroupInfo['HasModCP']=sql_result($mempreresult,0,"HasModCP");
287 if($GroupInfo['HasModCP']!="yes"&&$GroupInfo['HasModCP']!="no"&&$GroupInfo['HasModCP']!="group") {
288         $GroupInfo['HasModCP'] = "no"; }
289 if($GroupInfo['HasModCP']=="group") {
290 $GroupInfo['HasModCP']=sql_result($gruresult,0,"HasModCP");
291 if($GroupInfo['HasModCP']!="yes"&&$GroupInfo['HasModCP']!="no") {
292         $GroupInfo['HasModCP'] = "no"; } }
293 $GroupInfo['HasAdminCP']=sql_result($mempreresult,0,"HasAdminCP");
294 if($GroupInfo['HasAdminCP']!="yes"&&$GroupInfo['HasAdminCP']!="no"&&$GroupInfo['HasAdminCP']!="group") {
295         $GroupInfo['HasAdminCP'] = "no"; }
296 if($GroupInfo['HasAdminCP']=="group") {
297 $GroupInfo['HasAdminCP']=sql_result($gruresult,0,"HasAdminCP");
298 if($GroupInfo['HasAdminCP']!="yes"&&$GroupInfo['HasAdminCP']!="no") {
299         $GroupInfo['HasAdminCP'] = "no"; } }
300 $GroupInfo['CanViewIPAddress']=sql_result($mempreresult,0,"CanViewIPAddress");
301 if($GroupInfo['CanViewIPAddress']!="yes"&&$GroupInfo['CanViewIPAddress']!="no"&&$GroupInfo['CanViewIPAddress']!="group") {
302         $GroupInfo['CanViewIPAddress'] = "no"; }
303 if($GroupInfo['CanViewIPAddress']=="group") {
304 $GroupInfo['CanViewIPAddress']=sql_result($gruresult,0,"CanViewIPAddress");
305 if($GroupInfo['CanViewIPAddress']!="yes"&&$GroupInfo['CanViewIPAddress']!="no") {
306         $GroupInfo['CanViewIPAddress'] = "no"; } }
307 $GroupInfo['CanViewUserAgent']=sql_result($mempreresult,0,"CanViewUserAgent");
308 if($GroupInfo['CanViewUserAgent']!="yes"&&$GroupInfo['CanViewUserAgent']!="no"&&$GroupInfo['CanViewUserAgent']!="group") {
309         $GroupInfo['CanViewUserAgent'] = "no"; }
310 if($GroupInfo['CanViewUserAgent']=="group") {
311 $GroupInfo['CanViewUserAgent']=sql_result($gruresult,0,"CanViewUserAgent");
312 if($GroupInfo['CanViewUserAgent']!="yes"&&$GroupInfo['CanViewUserAgent']!="no") {
313         $GroupInfo['CanViewUserAgent'] = "no"; } }
314 $GroupInfo['ViewDBInfo']=sql_result($mempreresult,0,"ViewDBInfo");
315 if($GroupInfo['ViewDBInfo']!="yes"&&$GroupInfo['ViewDBInfo']!="no"&&$GroupInfo['ViewDBInfo']!="group") {
316         $GroupInfo['ViewDBInfo'] = "no"; }
317 if($GroupInfo['ViewDBInfo']=="group") {
318 $GroupInfo['ViewDBInfo']=sql_result($gruresult,0,"ViewDBInfo"); 
319 if($GroupInfo['ViewDBInfo']!="yes"&&$GroupInfo['ViewDBInfo']!="no") {
320         $GroupInfo['ViewDBInfo'] = "no"; } }
321 if($GruError==true) {
322 header("Content-Type: text/plain; charset=".$Settings['charset']); 
323 sql_free_result($gruresult); sql_free_result($mempreresult); $urlstatus = 503;
324 ob_clean(); echo "Sorry could not load all group data in database.\nContact the board admin about error."; 
325 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
326 sql_free_result($gruresult);
327 if($GroupInfo['CanViewBoard']=="no") { 
328 header("Content-Type: text/plain; charset=".$Settings['charset']); 
329 ob_clean(); echo "Sorry you can not view the board."; $urlstatus = 503;
330 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
331 // Member Group Permissions Setup
332 $perquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."permissions\" WHERE \"PermissionID\"=%i ORDER BY \"ForumID\" ASC", array($GroupInfo['PermissionID']));
333 $peresult=sql_query($perquery,$SQLStat);
334 $pernum=sql_num_rows($peresult);
335 $peri=0; $PerError = null;
336 if($pernum<0) { $PerError = true; sql_free_result($peresult);
337 header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 503;
338 ob_clean(); echo "Sorry could not find permission data in database.\nContact the board admin about error."; 
339 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
340 $ForumIgnoreList1 = null; $ForumIgnoreList2 = null;
341 $ForumIgnoreList3 = null; $ForumIgnoreList4 = null;
342 $ForumIgnoreList5 = null; $ForumIgnoreList6 = null;
343 $ModForumIgnoreList1 = null; $ModForumIgnoreList2 = null;
344 $ModForumIgnoreList3 = null; $ModForumIgnoreList4 = null;
345 if($pernum>=1) { while ($peri < $pernum) {
346 $PerForumID=sql_result($peresult,$peri,"ForumID");
347 if(!is_numeric($PerForumID)) { $PerError = true; }
348 $PermissionInfo['ID'][$PerForumID]=sql_result($peresult,$peri,"id");
349 if(!is_numeric($PermissionInfo['ID'][$PerForumID])) { $PerError = true; }
350 $PermissionInfo['PermissionID'][$PerForumID]=sql_result($peresult,$peri,"PermissionID");
351 if(!is_numeric($PermissionInfo['PermissionID'][$PerForumID])) { $PerError = true; }
352 $PermissionInfo['Name'][$PerForumID]=sql_result($peresult,$peri,"Name");
353 $PermissionInfo['ForumID'][$PerForumID]=sql_result($peresult,$peri,"ForumID");
354 if(!is_numeric($PermissionInfo['ForumID'][$PerForumID])) { $PerError = true; }
355 $PermissionInfo['CanViewForum'][$PerForumID]=sql_result($peresult,$peri,"CanViewForum");
356 if($PermissionInfo['CanViewForum'][$PerForumID]!="yes"&&$PermissionInfo['CanViewForum'][$PerForumID]!="no") {
357                 $PerError = true; }
358 if($PermissionInfo['CanViewForum'][$PerForumID]=="no") {
359 if(strlen($ForumIgnoreList1)>1) { $ForumIgnoreList1 .= " AND \"id\"<>".$PerForumID; }
360 if(strlen($ForumIgnoreList1)<1) { $ForumIgnoreList1 = " \"id\"<>".$PerForumID; }
361 if(strlen($ForumIgnoreList2)>1) { $ForumIgnoreList2 .= " AND \"id\"<>".$PerForumID; }
362 if(strlen($ForumIgnoreList2)<1) { $ForumIgnoreList2 = " AND \"id\"<>".$PerForumID; }
363 if(strlen($ForumIgnoreList3)>1) { $ForumIgnoreList3 .= " AND \"ForumID\"<>".$PerForumID; }
364 if(strlen($ForumIgnoreList3)<1) { $ForumIgnoreList3 = " WHERE \"ForumID\"<>".$PerForumID; }
365 if(strlen($ForumIgnoreList4)>1) { $ForumIgnoreList4 .= " AND \"ForumID\"<>".$PerForumID; }
366 if(strlen($ForumIgnoreList4)<1) { $ForumIgnoreList4 = " AND \"ForumID\"<>".$PerForumID; }
367 if(strlen($ForumIgnoreList5)>1) { $ForumIgnoreList5 .= " AND \"OldForumID\"<>".$PerForumID; }
368 if(strlen($ForumIgnoreList5)<1) { $ForumIgnoreList5 = " WHERE \"OldForumID\"<>".$PerForumID; }
369 if(strlen($ForumIgnoreList6)>1) { $ForumIgnoreList6 .= " AND \"OldForumID\"<>".$PerForumID; }
370 if(strlen($ForumIgnoreList6)<1) { $ForumIgnoreList6 = " AND \"OldForumID\"<>".$PerForumID; } }
371 $PermissionInfo['CanMakePolls'][$PerForumID]=sql_result($peresult,$peri,"CanMakePolls");
372 if($PermissionInfo['CanMakePolls'][$PerForumID]!="yes"&&$PermissionInfo['CanMakePolls'][$PerForumID]!="no") {
373                 $PerError = true; }
374 $PermissionInfo['CanMakeTopics'][$PerForumID]=sql_result($peresult,$peri,"CanMakeTopics");
375 if($PermissionInfo['CanMakeTopics'][$PerForumID]!="yes"&&$PermissionInfo['CanMakeTopics'][$PerForumID]!="no") {
376                 $PerError = true; }
377 $PermissionInfo['CanMakeReplys'][$PerForumID]=sql_result($peresult,$peri,"CanMakeReplys");
378 if($PermissionInfo['CanMakeReplys'][$PerForumID]!="yes"&&$PermissionInfo['CanMakeReplys'][$PerForumID]!="no") {
379                 $PerError = true; }
380 $PermissionInfo['CanMakeReplysClose'][$PerForumID]=sql_result($peresult,$peri,"CanMakeReplysCT");
381 if($PermissionInfo['CanMakeReplysClose'][$PerForumID]!="yes"&&$PermissionInfo['CanMakeReplysClose'][$PerForumID]!="no") {
382                 $PerError = true; }
383 $PermissionInfo['CanEditTopics'][$PerForumID]=sql_result($peresult,$peri,"CanEditTopics");
384 if($PermissionInfo['CanEditTopics'][$PerForumID]!="yes"&&$PermissionInfo['CanEditTopics'][$PerForumID]!="no") {
385         $PermissionInfo['CanEditTopics'][$PerForumID] = "no"; }
386 $PermissionInfo['CanEditTopicsClose'][$PerForumID]=sql_result($peresult,$peri,"CanEditTopicsCT");
387 if($PermissionInfo['CanEditTopicsClose'][$PerForumID]!="yes"&&$PermissionInfo['CanEditTopicsClose'][$PerForumID]!="no") {
388         $PermissionInfo['CanEditTopicsClose'][$PerForumID] = "no"; }
389 $PermissionInfo['CanEditReplys'][$PerForumID]=sql_result($peresult,$peri,"CanEditReplys");
390 if($PermissionInfo['CanEditReplys'][$PerForumID]!="yes"&&$PermissionInfo['CanEditReplys'][$PerForumID]!="no") {
391         $PermissionInfo['CanEditReplys'][$PerForumID] = "no"; }
392 $PermissionInfo['CanEditReplysClose'][$PerForumID]=sql_result($peresult,$peri,"CanEditReplysCT");
393 if($PermissionInfo['CanEditReplysClose'][$PerForumID]!="yes"&&$PermissionInfo['CanEditReplysClose'][$PerForumID]!="no") {
394         $PermissionInfo['CanEditReplysClose'][$PerForumID] = "no"; }
395 $PermissionInfo['CanDeleteTopics'][$PerForumID]=sql_result($peresult,$peri,"CanDeleteTopics");
396 if($PermissionInfo['CanDeleteTopics'][$PerForumID]!="yes"&&$PermissionInfo['CanDeleteTopics'][$PerForumID]!="no") {
397         $PermissionInfo['CanDeleteTopics'][$PerForumID] = "no"; }
398 $PermissionInfo['CanDeleteTopicsClose'][$PerForumID]=sql_result($peresult,$peri,"CanDeleteTopicsCT");
399 if($PermissionInfo['CanDeleteTopicsClose'][$PerForumID]!="yes"&&$PermissionInfo['CanDeleteTopicsClose'][$PerForumID]!="no") {
400         $PermissionInfo['CanDeleteTopicsClose'][$PerForumID] = "no"; }
401 $PermissionInfo['CanDeleteReplys'][$PerForumID]=sql_result($peresult,$peri,"CanDeleteReplys");
402 if($PermissionInfo['CanDeleteReplys'][$PerForumID]!="yes"&&$PermissionInfo['CanDeleteReplys'][$PerForumID]!="no") {
403         $PermissionInfo['CanDeleteReplys'][$PerForumID] = "no"; }
404 $PermissionInfo['CanDeleteReplysClose'][$PerForumID]=sql_result($peresult,$peri,"CanDeleteReplysCT");
405 if($PermissionInfo['CanDeleteReplysClose'][$PerForumID]!="yes"&&$PermissionInfo['CanDeleteReplysClose'][$PerForumID]!="no") {
406         $PermissionInfo['CanDeleteReplysClose'][$PerForumID] = "no"; }
407 $PermissionInfo['CanCloseTopics'][$PerForumID]=sql_result($peresult,$peri,"CanCloseTopics");
408 if($PermissionInfo['CanCloseTopics'][$PerForumID]!="yes"&&$PermissionInfo['CanCloseTopics'][$PerForumID]!="no") {
409         $PermissionInfo['CanCloseTopics'][$PerForumID] = "no"; }
410 $PermissionInfo['CanPinTopics'][$PerForumID]=sql_result($peresult,$peri,"CanPinTopics");
411 if($PermissionInfo['CanPinTopics'][$PerForumID]!="yes"&&$PermissionInfo['CanPinTopics'][$PerForumID]!="no") {
412         $PermissionInfo['CanPinTopics'][$PerForumID] = "no"; }
413 $PermissionInfo['CanDoHTML'][$PerForumID]=sql_result($peresult,$peri,"CanDoHTML");
414 if($PermissionInfo['CanDoHTML'][$PerForumID]!="yes"&&$PermissionInfo['CanDoHTML'][$PerForumID]!="no") {
415         $PermissionInfo['CanDoHTML'][$PerForumID] = "no"; }
416 $PermissionInfo['CanUseBBags'][$PerForumID]=sql_result($peresult,$peri,"CanUseBBags");
417 if($PermissionInfo['CanUseBBags'][$PerForumID]!="yes"&&$PermissionInfo['CanUseBBags'][$PerForumID]!="no") {
418         $PermissionInfo['CanUseBBags'][$PerForumID] = "no"; }
419 $PermissionInfo['CanModForum'][$PerForumID]=sql_result($peresult,$peri,"CanModForum");
420 if($PermissionInfo['CanModForum'][$PerForumID]!="yes"&&$PermissionInfo['CanModForum'][$PerForumID]!="no") {
421         $PermissionInfo['CanModForum'][$PerForumID] = "no"; }
422 if($PermissionInfo['CanModForum'][$PerForumID]=="no") {
423 if(strlen($ModForumIgnoreList1)>1) { $ModForumIgnoreList1 .= " AND \"id\"<>".$PerForumID; }
424 if(strlen($ModForumIgnoreList1)<1) { $ModForumIgnoreList1 = " \"id\"<>".$PerForumID; }
425 if(strlen($ModForumIgnoreList2)>1) { $ModForumIgnoreList2 .= " AND \"id\"<>".$PerForumID; }
426 if(strlen($ModForumIgnoreList2)<1) { $ModForumIgnoreList2 = " AND \"id\"<>".$PerForumID; }
427 if(strlen($ModForumIgnoreList3)>1) { $ModForumIgnoreList3 .= " AND \"ForumID\"<>".$PerForumID; }
428 if(strlen($ModForumIgnoreList3)<1) { $ModForumIgnoreList3 = " WHERE \"ForumID\"<>".$PerForumID; }
429 if(strlen($ModForumIgnoreList4)>1) { $ModForumIgnoreList4 .= " AND \"ForumID\"<>".$PerForumID; }
430 if(strlen($ModForumIgnoreList4)<1) { $ModForumIgnoreList4 = " AND \"ForumID\"<>".$PerForumID; } }
431 if($PerError===true) { $peri = $pernum; }
432 ++$peri; } if($PerError===true) {
433 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult); $urlstatus = 503;
434 ob_clean(); echo "Sorry could not load all permission data in database.\nContact the board admin about error."; 
435 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
436 sql_free_result($peresult);
437 $per2query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."catpermissions\" WHERE \"PermissionID\"=%i ORDER BY \"CategoryID\" ASC", array($GroupInfo['PermissionID']));
438 $per2esult=sql_query($per2query,$SQLStat);
439 $per2num=sql_num_rows($per2esult);
440 $per2i=0; $Per2Error = null;
441 if($per2num<=0) { $Per2Error = true; sql_free_result($per2esult);
442 header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 503;
443 ob_clean(); echo "Sorry could not find permission data in database.\nContact the board admin about error."; 
444 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
445 $CatIgnoreList1 = null; $CatIgnoreList2 = null;
446 $CatIgnoreList3 = null; $CatIgnoreList4 = null;
447 $CatIgnoreList5 = null; $CatIgnoreList6 = null;
448 if($per2num>=1) { while ($per2i < $per2num) {
449 $PerCatID=sql_result($per2esult,$per2i,"CategoryID");
450 if(!is_numeric($PerCatID)) { $Per2Error = true; }
451 $CatPermissionInfo['ID'][$PerCatID]=sql_result($per2esult,$per2i,"id");
452 if(!is_numeric($CatPermissionInfo['ID'][$PerCatID])) { $Per2Error = true; }
453 $CatPermissionInfo['PermissionID'][$PerCatID]=sql_result($per2esult,$per2i,"PermissionID");
454 if(!is_numeric($CatPermissionInfo['PermissionID'][$PerCatID])) { $Per2Error = true; }
455 $CatPermissionInfo['Name'][$PerCatID]=sql_result($per2esult,$per2i,"Name");
456 $CatPermissionInfo['CategoryID'][$PerCatID]=sql_result($per2esult,$per2i,"CategoryID");
457 if(!is_numeric($CatPermissionInfo['CategoryID'][$PerCatID])) { $Per2Error = true; }
458 $CatPermissionInfo['CanViewCategory'][$PerCatID]=sql_result($per2esult,$per2i,"CanViewCategory");
459 if($CatPermissionInfo['CanViewCategory'][$PerCatID]!="yes"&&$CatPermissionInfo['CanViewCategory'][$PerCatID]!="no") { $Per2Error = true; }
460 if($CatPermissionInfo['CanViewCategory'][$PerCatID]=="no") {
461 if(strlen($CatIgnoreList1)>1) { $CatIgnoreList1 .= " AND \"id\"<>".$PerCatID; }
462 if(strlen($CatIgnoreList1)<1) { $CatIgnoreList1 = " \"id\"<>".$PerCatID; }
463 if(strlen($CatIgnoreList2)>1) { $CatIgnoreList2 .= " AND \"id\"<>".$PerCatID; }
464 if(strlen($CatIgnoreList2)<1) { $CatIgnoreList2 = " AND \"id\"<>".$PerCatID; }
465 if(strlen($CatIgnoreList3)>1) { $CatIgnoreList3 .= " AND \"CategoryID\"<>".$PerCatID; }
466 if(strlen($CatIgnoreList3)<1) { $CatIgnoreList3 = " WHERE \"CategoryID\"<>".$PerCatID; }
467 if(strlen($CatIgnoreList4)>1) { $CatIgnoreList4 .= " AND \"CategoryID\"<>".$PerCatID; }
468 if(strlen($CatIgnoreList4)<1) { $CatIgnoreList4 = " AND \"CategoryID\"<>".$PerCatID; }
469 if(strlen($CatIgnoreList5)>1) { $CatIgnoreList5 .= " AND \"OldCategoryID\"<>".$PerCatID; }
470 if(strlen($CatIgnoreList5)<1) { $CatIgnoreList5 = " WHERE \"OldCategoryID\"<>".$PerCatID; }
471 if(strlen($CatIgnoreList6)>1) { $CatIgnoreList6 .= " AND \"OldCategoryID\"<>".$PerCatID; }
472 if(strlen($CatIgnoreList6)<1) { $CatIgnoreList6 = " AND \"OldCategoryID\"<>".$PerCatID; } }
473 if($Per2Error===true) { $per2i = $per2num; }
474 ++$per2i; } if($Per2Error===true) {
475 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($per2esult); $urlstatus = 503;
476 ob_clean(); echo "Sorry could not load all permission data in database.\nContact the board admin about error."; 
477 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
478 sql_free_result($per2esult);
479 ?>