1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
|
<?php
function get_vars_old() {
global $HTTP_COOKIE_VARS, $HTTP_POST_FILES, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_SERVER_VARS, $_REQUEST, $_COOKIE, $_POST, $_GET, $_SERVER, $_FILES;
if(is_array($HTTP_COOKIE_VARS)) {
while(list($key,$val)=each($HTTP_COOKIE_VARS)) {
$_REQUEST[$key]=$val;
$_COOKIE[$key]=$val;
}
}
if(is_array($HTTP_POST_VARS)) {
while(list($key,$val)=each($HTTP_POST_VARS)) {
$_REQUEST[$key]=$val;
$_POST[$key]=$val;
}
}
if(is_array($HTTP_GET_VARS)) {
while(list($key,$val)=each($HTTP_GET_VARS)) {
$_REQUEST[$key]=$val;
$_GET[$key]=$val;
}
}
if(is_array($HTTP_POST_FILES)) while(list($key,$val)=each($HTTP_POST_FILES)) $_FILES[$key]=$val;
if(is_array($HTTP_SERVER_VARS)) while(list($key,$val)=each($HTTP_SERVER_VARS)) $_SERVER[$key]=$val;
}
function convert_url($url,$hash,$nosessionhash=0) {
if($nosessionhash==0) $url=preg_replace("/sid=[0-9a-z]*/","sid=$hash",$url);
else $url=preg_replace("/sid=[0-9a-z]*/","sid=",$url);
return $url;
}
function rehtmlspecialchars($text) {
$text = str_replace("<","<",$text);
$text = str_replace(">",">",$text);
$text = str_replace(""",""",$text);
$text = str_replace("&","&",$text);
return $text;
}
function stripslashes_array(&$array) {
reset($array);
while(list($key,$val)=each($array)) {
if(is_string($val)) $array[$key]=stripslashes($val);
elseif(is_array($val)) $array[$key]=stripslashes_array($val);
}
return $array;
}
function trim_array(&$array) {
reset($array);
while(list($key,$val)=each($array)) {
if(is_array($val)) $array[$key]=trim_array($val);
elseif(is_string($val)) $array[$key]=trim($val);
}
return $array;
}
function htmlspecialchars_array(&$array) {
reset($array);
while(list($key,$val)=each($array)) {
if(is_array($val)) $array[$key]=htmlspecialchars_array($val);
elseif(is_string($val)) $array[$key]=htmlspecialchars($val);
}
return $array;
}
function ifelse($expression,$returntrue,$returnfalse="") {
if($expression) return $returntrue;
else return $returnfalse;
}
function bbcookie($name, $value, $time) {
global $cookiepath, $cookiedomain;
if($cookiedomain) setcookie($name, $value, $time, $cookiepath, $cookiedomain);
elseif($cookiepath) setcookie($name, $value, $time, $cookiepath);
else setcookie($name, $value, $time);
}
function mailer($email,$subject,$text,$sender="",$other="") {
global $frommail, $master_board_name;
if($sender) return @mail($email,$subject,$text,"From: $sender".$other);
else return @mail($email,$subject,$text,"From: $frommail".$other);
}
function makehreftag($url, $name, $target="") {
return "<a href="".$url.""".ifelse($target," target="".$target.""").">".$name."</a>";
}
function makeimgtag($path,$alt="") {
return "<img src="$path" ".ifelse($alt,"alt="".$alt."" ","")."border=0>";
}
function formatdate($timeformat,$timestamp,$replacetoday=0) {
global $wbbuserdata, $tpl, $default_timezoneoffset;
$summertime = date("I")*3600;
$timestamp+=3600*intval($default_timezoneoffset)+$summertime;
if($replacetoday==1) {
if(gmdate("Ymd",$timestamp)==gmdate("Ymd",time()+3600*intval($default_timezoneoffset)+$summertime)) {
eval ("\$today = "".$tpl->get("today")."";");
return $today;
}
else $replacetoday=0;
}
if($replacetoday==0) return gmdate($timeformat, $timestamp);
}
function getSubboards($boardid) {
global $boardcache, $session, $tpl, $permissioncache;
if (!isset($boardcache[$boardid])) return;
while(list($key1,$val1)=each($boardcache[$boardid])) {
while(list($key2,$boards)=each($val1)) {
if($boards['invisible']==2 || ($boards['invisible']==1 && !$permissioncache[$boards['boardid']]['boardpermission'])) continue;
eval ("\$subboardbit .= "".$tpl->get("index_subboardbit")."";");
$subboardbit.=getSubboards($boards['boardid']);
}
}
return $subboardbit;
}
function makeboardbit($boardid,$depth=1) {
global $db, $n, $tpl, $boardvisit, $threadvisit, $boardcache, $visitcache, $permissioncache, $modcache, $wbbuserdata, $session, $hidecats, $index_depth, $show_subboards, $showlastposttitle, $dateformat, $timeformat, $filename, $temp_boardid;
if(!isset($boardcache[$boardid])) return;
reset($boardcache[$boardid]);
$boardbit="";
while(list($key1,$val1)=each($boardcache[$boardid])) {
while(list($key2,$boards)=each($val1)) {
if($boards['invisible']==2 || ($boards['invisible']==1 && !$permissioncache[$boards['boardid']]['boardpermission'])) continue;
if($boards['description']) eval ("\$boards['description'] = "".$tpl->get("index_boarddescription")."";");
$subboardbit="";
$subboards="";
if($depth==$index_depth && $show_subboards==1) {
$subboardbit=getSubboards($boards['boardid']);
if($subboardbit) {
$subboardbit=substr($subboardbit, 0, -2);
eval ("\$subboards = "".$tpl->get("index_subboard")."";");
}
}
if($wbbuserdata['lastvisit'] > $boards['lastposttime'] || $boardvisit[$boards['boardid']] > $boards['lastposttime']) $onoff="off";
else {
$onoff="off";
$tempids = explode(",","$boards[boardid],$boards[childlist]");
for($j=0;$j<count($tempids);$j++) {
if($tempids[$j]==0) continue;
if(is_array($visitcache[$tempids[$j]]) && count($visitcache[$tempids[$j]])) {
reset($visitcache[$tempids[$j]]);
while(list($threadid,$lastposttime)=each($visitcache[$tempids[$j]])) {
if($threadvisit[$threadid]<$lastposttime && $boardvisit[$tempids[$j]]<$lastposttime) {
$onoff="on";
break 2;
} // end if
} // end while
} // end if
} // end for
} // end else
if($boards['isboard']) {
if($boards['closed']==1) $onoff.="closed";
elseif((!$permissioncache[$boards['boardid']]['startpermission'] && !$permissioncache[$boards['boardid']]['replypermission']) || (!$wbbuserdata['canstarttopic'] && !$wbbuserdata['canreplytopic'])) $onoff.="closed";
if($boards['threadcount']) {
$lastpostdate=formatdate($dateformat,$boards['lastposttime'],1);
$lastposttime=formatdate($timeformat,$boards['lastposttime']);
if($boards['lastposterid']) eval ("\$lastposter = "".$tpl->get("index_lastposter")."";");
else eval ("\$lastposter = "".$tpl->get("index_lastposter_guest")."";");
if($showlastposttitle==1) {
if(!$permissioncache[$boards['boardid']]['boardpermission'] || $boards['password']!="") eval ("\$lastposttitle = "".$tpl->get("index_lastpost_title_hide")."";");
else {
if(strlen($boards['topic'])>30) $topic=cutTopic($boards['topic']);
else $topic=$boards['topic'];
eval ("\$lastposttitle = "".$tpl->get("index_lastpost_title_show")."";");
}
if(isset($boards['iconid'])) $ViewPosticon=makeimgtag($boards['iconpath'],$boards['icontitle']);
else $ViewPosticon=makeimgtag("{imagefolder}/icons/icon14.gif");
if(isset($boards['threadprefix']) && $boards['threadprefix']!="") {
$threads['prefix']=$boards['threadprefix'];
eval ("\$prefix = "".$tpl->get("board_thread_prefix")."";");
}
else $prefix="";
eval ("\$lastpost = "".$tpl->get("index_lastpost_title")."";");
}
else eval ("\$lastpost = "".$tpl->get("index_lastpost")."";");
}
else eval ("\$lastpost = "".$tpl->get("index_nolastpost")."";");
$moderators="";
$moderatorbit="";
if(isset($modcache[$boards['boardid']])) {
while (list($mkey,$moderator)=each($modcache[$boards['boardid']])) {
if($moderatorbit) eval ("\$moderatorbit .= ", ".$tpl->get("index_moderatorbit")."";");
else eval ("\$moderatorbit = "".$tpl->get("index_moderatorbit")."";");
}
}
else $moderatorbit=" ";
eval ("\$moderators = "".$tpl->get("index_moderators")."";");
eval ("\$boardbit .= "".$tpl->get("index_boardbit$depth")."";");
}
else {
eval ("\$boardbit .= "".$tpl->get("index_catbit$depth")."";");
}
if ((isset($hidecats[$boards['boardid']]) && $hidecats[$boards['boardid']]==0) || ($depth<$index_depth && (!isset($hidecats[$boards['boardid']]) || $hidecats[$boards['boardid']]!=1))) $boardbit.=makeboardbit($boards['boardid'],$depth+1);
}
}
unset($boardcache[$boardid]);
return $boardbit;
}
function getNavbar($parentlist,$template="navbar_board") {
global $db, $n, $session, $url2board, $lines, $tpl, $boardnavcache;
if($parentlist=="0") return;
else {
$navbar="";
if(!isset($boardnavcache) || !is_array($boardnavcache) || !count($boardnavcache)) {
$result = $db->query("SELECT boardid, title FROM bb".$n."_boards WHERE boardid IN ($parentlist)");
while($row=$db->fetch_array($result)) $boardnavcache[$row['boardid']]=$row;
}
$parentids=explode(",", $parentlist);
for($i=1;$i<count($parentids);$i++) {
if($template=="print_navbar") $lines.=str_repeat("-",$i);
$board=$boardnavcache[$parentids[$i]];
eval ("\$navbar .= "".$tpl->get($template)."";");
}
return $navbar;
}
}
function getcodebuttons() {
global $bbcodemode, $tpl;
if($bbcodemode==1) $modechecked[1]="checked";
else $modechecked[0]="checked";
eval ("\$bbcode_sizebits = "".$tpl->get("bbcode_sizebits")."";");
eval ("\$bbcode_fontbits = "".$tpl->get("bbcode_fontbits")."";");
eval ("\$bbcode_colorbits = "".$tpl->get("bbcode_colorbits")."";");
eval ("\$bbcode_buttons = "".$tpl->get("bbcode_buttons")."";");
return $bbcode_buttons;
}
function getclickysmilies($tableColumns=3,$maxSmilies=-1) {
global $db, $n, $tpl, $showsmiliesrandom;
if($showsmiliesrandom==1) $result = $db->query("SELECT smiliepath, smilietitle, smiliecode FROM bb".$n."_smilies ORDER BY RAND()");
else $result = $db->query("SELECT smiliepath, smilietitle, smiliecode FROM bb".$n."_smilies ORDER BY smilieorder ASC");
$totalSmilies = $db->num_rows($result);
if (($maxSmilies == -1) || ($maxSmilies >= $totalSmilies)) $maxSmilies = $totalSmilies;
elseif ($maxSmilies < $totalSmilies) eval ("\$bbcode_smilies_getmore = "".$tpl->get("bbcode_smilies_getmore")."";");
$i=0;
while($row = $db->fetch_array($result)) {
eval ("\$smilieArray["".$i.""] = "".$tpl->get("bbcode_smiliebit")."";");
$i++;
}
$tableRows = ceil($maxSmilies/$tableColumns);
$count = 0;
for ($i=0; $i<$tableRows; $i++) {
$smiliebits .= "\t<tr bgcolor="{tablecolorb}" id="tableb">\n";
for ($j=0; $j<$tableColumns; $j++) {
$smiliebits .= $smilieArray[$count];
$count++;
}
$smiliebits .= "\t</tr>\n";
}
eval ("\$bbcode_smilies = "".$tpl->get("bbcode_smilies")."";");
return $bbcode_smilies;
}
function getone($number, $one, $two) {
if($number % 2) return $one;
else return $two;
}
function makeboardjump($current) {
global $wbbuserdata, $boardcache, $permissioncache, $tpl, $session, $boardnavcache;
if(!isset($boardcache) || !isset($permissioncache)) {
global $db, $n, $wbbuserdata;
$result = $db->query("SELECT boardid, parentid, boardorder, title, invisible FROM bb".$n."_boards ORDER by parentid ASC, boardorder ASC");
while ($row = $db->fetch_array($result)) {
$boardcache[$row['parentid']][$row['boardorder']][$row['boardid']] = $row;
$boardnavcache[$row['boardid']]=$row;
}
$result = $db->query("SELECT * FROM bb".$n."_permissions WHERE groupid = '$wbbuserdata[groupid]'");
while ($row = $db->fetch_array($result)) $permissioncache[$row['boardid']] = $row;
}
if(is_array($boardcache) && count($boardcache)) {
reset($boardcache);
$boardoptions=makeboardselect(0,1,$current);
}
eval ("\$boardjump = "".$tpl->get("boardjump")."";");
return $boardjump;
}
function makeboardselect($boardid,$depth=1,$current=0) {
global $boardcache, $permissioncache;
if(!isset($boardcache[$boardid])) return;
$boardbit="";
while (list($key1,$val1) = each($boardcache[$boardid])) {
while(list($key2,$boards) = each($val1)) {
if($boards['invisible']==1 && $permissioncache[$boards['boardid']]['boardpermission'] == 0) continue;
if($depth>1) $prefix=str_repeat("--",$depth-1)." ";
else $prefix="";
$boardbit .= makeoption($boards['boardid'],$prefix.$boards['title'],$current,1);
$boardbit .= makeboardselect($boards['boardid'],$depth+1,$current);
}
}
unset($boardcache[$boardid]);
return $boardbit;
}
function formatRI($images) {
if(!$images) return;
$imgArray = explode(";",$images);
for($i=0;$i<count($imgArray);$i++)
$RI.="<img src="$imgArray[$i]">";
return $RI;
}
function parseURL($message) {
$urlsearch[]="/([^]@_a-z0-9-="'\/])((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`"'\|\[\]\{\}<>]*)/si";
$urlsearch[]="/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`"'\|\[\]\{\}<>]*)/si";
$urlreplace[]="\\1[URL]\\2\\4[/URL]";
$urlreplace[]="[URL]\\1\\3[/URL]";
$emailsearch[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
$emailsearch[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
$emailreplace[]="\\1[EMAIL]\\2[/EMAIL]";
$emailreplace[]="[EMAIL]\\0[/EMAIL]";
$message = preg_replace($urlsearch, $urlreplace, $message);
if (strpos($message, "@")) $message = preg_replace($emailsearch, $emailreplace, $message);
return $message;
}
|