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:
|
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)) {
$row['smilietitle']=getlangvar($row['smilietitle'], $lang);
$row['smiliepath'] = replaceImagefolder($row['smiliepath']);
$row['smiliecode'] = addcslashes($row['smiliecode'], "'\\");
eval ("\$smilieArray[\"".$i."\"] = \"".$tpl->get("bbcode_smiliebit")."\";");
$i++;
}
$tableRows = ceil($maxSmilies/$tableColumns);
$count = 0;
$smiliebits = "";
for ($i=0; $i<$tableRows; $i++) {
$smiliebits .= "\t<tr>\n";
for ($j=0; $j<$tableColumns; $j++) {
$smiliebits .= $smilieArray[$count];
$count++;
}
$smiliebits .= "\t</tr>\n";
}
eval ("\$lang->items['LANG_POSTINGS_SMILIE_COUNT'] = \"".$lang->get4eval("LANG_POSTINGS_SMILIE_COUNT")."\";");
eval ("\$bbcode_smilies = \"".$tpl->get("bbcode_smilies")."\";");
return $bbcode_smilies;
}
/** if number is odd get element one otherwise element two **/
function getone($number, $one, $two) {
if($number & 1) return $one;
else return $two;
}
/** generate the boardlist for boardjump **/
function makeboardjump($current) {
global $wbbuserdata, $boardcache, $permissioncache, $useuseraccess, $tpl, $session, $boardnavcache, $style, $lang;
if(!isset($boardcache) || !isset($permissioncache)) {
global $db, $n, $wbbuserdata, $boardordermode;
switch($boardordermode) {
case 1: $boardorder="title ASC"; break;
case 2: $boardorder="title DESC"; break;
case 3: $boardorder="lastposttime DESC"; break;
default: $boardorder="boardorder ASC"; break;
}
$result = $db->unbuffered_query("SELECT boardid, parentid, boardorder, title, invisible FROM bb".$n."_boards ORDER by parentid ASC, $boardorder");
while ($row = $db->fetch_array($result)) {
$boardcache[$row['parentid']][$row['boardorder']][$row['boardid']] = $row;
$boardnavcache[$row['boardid']]=$row;
}
$permissioncache=getPermissions();
}
if(is_array($boardcache) && count($boardcache)) {
reset($boardcache);
$boardoptions=makeboardselect(0,1,$current);
}
eval ("\$boardjump = \"".$tpl->get("boardjump")."\";");
return $boardjump;
}
/** generate a general boardlist **/
function makeboardselect($boardid,$depth=1,$current=0,$catmarking="%s") {
global $boardcache, $permissioncache, $accesscache, $wbbuserdata, $lang;
if(!isset($boardcache[$boardid])) return;
$boardbit="";
while (list($key1,$val1) = each($boardcache[$boardid])) {
while(list($key2,$boards) = each($val1)) {
if(!isset($permissioncache[$boards['boardid']]['can_view_board']) || $permissioncache[$boards['boardid']]['can_view_board']==-1) $permissioncache[$boards['boardid']]['can_view_board']=$wbbuserdata['can_view_board'];
if($boards['invisible']==2 || ($boards['invisible']==1 && !$permissioncache[$boards['boardid']]['can_view_board'])) continue;
if($depth>1) $prefix=str_repeat("--",$depth-1)." ";
else $prefix="";
$boards['title']=getlangvar($boards['title'], $lang);
if(isset($boards['isboard']) && !$boards['isboard'] && $catmarking!="%s") $boards['title']=sprintf($catmarking, $boards['title']);
$boardbit .= makeoption($boards['boardid'],$prefix.$boards['title'],$current,1);
$boardbit .= makeboardselect($boards['boardid'],$depth+1,$current);
}
}
unset($boardcache[$boardid]);
return $boardbit;
}
/** format rank images **/
function formatRI($images) {
if(!$images) return;
$imgArray = explode(";",$images);
$RI="";
$imgArray_count=count($imgArray);
for($i=0;$i<$imgArray_count;$i++)
$RI.=makeimgtag($imgArray[$i]);
return $RI;
}
/** parse URLs in post **/
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;
}
/** generate pagelinks **/
function makepagelink($link,$page,$pages,$number) {
global $tpl, $lang;
eval ("\$pagelink = \"".$tpl->get("pagelink")."\";");
if($page-$number>1) eval ("\$pagelink .= \"".$tpl->get("pagelink_first")."\";");
if($page>1) {
$temppage=$page-1;
eval ("\$pagelink .= \"".$tpl->get("pagelink_left")."\";");
}
$count = (($page+$number>=$pages) ? ($pages) : ($page+$number));
for($i=$page-$number;$i<=$count;$i++) {
if($i<1) $i=1;
if($i==$page) eval ("\$pagelink .= \"".$tpl->get("pagelink_current")."\";");
else eval ("\$pagelink .= \"".$tpl->get("pagelink_nocurrent")."\";");
}
if($page<$pages) {
$temppage=$page+1;
eval ("\$pagelink .= \"".$tpl->get("pagelink_right")."\";");
}
if($page+$number<$pages) eval ("\$pagelink .= \"".$tpl->get("pagelink_last")."\";");
return $pagelink;
}
/** generate a option tag **/
function makeoption($value,$text,$selected_value="",$selected=1,$style="") {
$option_selected="";
if($selected==1) {
if(is_array($selected_value)) {
if(in_array($value,$selected_value)) $option_selected=" selected=\"selected\"";
}
elseif($selected_value==$value) $option_selected=" selected=\"selected\"";
}
return "<option value=\"$value\"".(($style!="") ? (" style=\"color:$style\"") : ("")).$option_selected.">$text</option>";
}
/** get name of a month **/
function getmonth($number) {
global $months, $lang;
if(!isset($months)) $months = explode("|", $lang->get("LANG_GLOBAL_MONTHS"));
return $months[$number-1];
}
/** get name of a day **/
function getday($number) {
global $days, $lang;
if(!isset($days)) $days = explode("|", $lang->get("LANG_GLOBAL_DAYS"));
return $days[$number];
}
/** show access error page and die **/
function access_error($isacp=0)
{
if($isacp==0)
{
global $db,$n,$wbbuserdata, $header, $footer, $headinclude, $session, $sid, $master_board_name, $REQUEST_URI, $tpl, $style, $lang, $usercbar_username, $allowloginencryption;
$update_session=false;
if(!$wbbuserdata['userid'] && $allowloginencryption==1)
{
// force authentificationcode
$authentificationcode=makeAuthentificationcode(0);
if($authentificationcode!=$session['authentificationcode'])
{
$update_session=true;
$session['authentificationcode']=$authentificationcode;
$db->unbuffered_query("UPDATE bb".$n."_sessions SET authentificationcode = '".addslashes($session['authentificationcode'])."', request_uri='', boardid=0, threadid=0 WHERE sessionhash = '$sid'",1);
}
}
if(!$update_session) $db->unbuffered_query("UPDATE bb".$n."_sessions SET request_uri='', boardid=0, threadid=0 WHERE sessionhash = '$sid'",1);
$REQUEST_URI = htmlconverter($REQUEST_URI);
eval ("\$lang->items['LANG_GLOBAL_ACCESS_ERROR_DESC'] = \"".$lang->get4eval("LANG_GLOBAL_ACCESS_ERROR_DESC")."\";");
eval("\$tpl->output(\"".$tpl->get("access_error")."\");");
exit();
}
else
{
global $tpl, $lang, $master_board_name;
eval("\$tpl->output(\"".$tpl->get("access_error",1)."\",1);");
exit;
}
}
/** verify an username **/
function verify_username($username) {
global $db, $n, $minusernamelength, $maxusernamelength, $ban_name;
if(strlen($username)<$minusernamelength || strlen($username)>$maxusernamelength) return false;
$ban_name=explode("\n",preg_replace("/\s*\n\s*/","\n",strtolower(wbb_trim($ban_name))));
$ban_name_count=count($ban_name);
for($i = 0; $i < $ban_name_count; $i++) {
$ban_name[$i]=wbb_trim($ban_name[$i]);
if(!$ban_name[$i]) continue;
if(strstr($ban_name[$i], "*")) {
$ban_name[$i] = str_replace("*",".*",$ban_name[$i]);
if(preg_match("/$ban_name[$i]/i",$username)) return false;
}
elseif(strtolower($username)==$ban_name[$i]) return false;
}
$result = $db->query_first("SELECT COUNT(*) FROM bb".$n."_users WHERE username = '".addslashes($username)."'");
if($result[0]!=0) return false;
else return true;
}
/** verify a email **/
function verify_email($email) {
global $db, $n, $multipleemailuse, $ban_email;
$email=strtolower($email);
if(!preg_match("/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si",$email)) return false;
$ban_email=explode("\n",preg_replace("/\s*\n\s*/","\n",strtolower(wbb_trim($ban_email))));
$ban_email_count=count($ban_email);
for($i = 0; $i < $ban_email_count; $i++) {
$ban_email[$i]=wbb_trim($ban_email[$i]);
if(!$ban_email[$i]) continue;
if(strstr($ban_email[$i], "*")) {
$ban_email[$i] = str_replace("*",".*",$ban_email[$i]);
if(preg_match("/$ban_email[$i]/i",$email)) return false;
}
elseif($email==$ban_email[$i]) return false;
}
if($multipleemailuse==1) return true;
else {
$result = $db->query_first("SELECT COUNT(*) FROM bb".$n."_users WHERE email = '".$email."'");
if($result[0]!=0) return false;
else return true;
}
}
/** verify an ip address **/
function verify_ip($ip) {
global $ban_ip;
if($ban_ip) {
$ban_ip=explode("\n",preg_replace("/\s*\n\s*/","\n",strtolower(wbb_trim($ban_ip))));
$ban_ip_count=count($ban_ip);
for($i = 0; $i < $ban_ip_count; $i++) {
$ban_ip[$i]=wbb_trim($ban_ip[$i]);
if(!$ban_ip[$i]) continue;
if(strstr($ban_ip[$i], "*")) {
$ban_ip[$i] = str_replace("*",".*",$ban_ip[$i]);
if(preg_match("/$ban_ip[$i]/i",$ip)) access_error();
}
elseif($ip==$ban_ip[$i]) access_error();
}
}
}
/** verify an usertitle **/
function verify_usertitle($usertitle) {
global $db, $n, $wbbuserdata, $ban_usertitle;
if($wbbuserdata['can_avoid_ban_usertitle']==1) return true;
else
{
if(!is_array($ban_usertitle)) $ban_usertitle=explode("\n",preg_replace("/\s*\n\s*/","\n",strtolower(wbb_trim($ban_usertitle))));
$ban_usertitle_count=count($ban_usertitle);
for($i = 0; $i < $ban_usertitle_count; $i++) {
$ban_usertitle[$i]=wbb_trim($ban_usertitle[$i]);
if(!$ban_usertitle[$i]) continue;
if(strstr($ban_usertitle[$i], "*")) {
$ban_usertitle[$i] = str_replace("*",".*",$ban_usertitle[$i]);
if(preg_match("/$ban_usertitle[$i]/i",$usertitle)) return false;
}
elseif(strtolower($usertitle)==$ban_usertitle[$i]) return false;
}
return true;
}
}
/** verify posttime for flood control **/
function flood_control($userid,$ipaddress,$avoid_fc) {
if($avoid_fc==1) return false;
global $db, $n, $fctime;
if($userid) $result=$db->query_first("SELECT postid FROM bb".$n."_posts WHERE userid='$userid' AND posttime>='".(time()-$fctime)."'",1);
else $result=$db->query_first("SELECT postid FROM bb".$n."_posts WHERE ipaddress='$ipaddress' AND posttime>='".(time()-$fctime)."'",1);
if($result['postid']) return true;
else return false;
}
/** generate a new password **/
function password_generate($numbers=2,$length=8) {
$time = intval(substr(microtime(), 2, 8));
mt_srand($time);
$numberchain="1234567890";
for($i=0;$i<$numbers;$i++) {
$random=mt_rand(0,strlen($numberchain)-1);
$number[intval($numberchain[$random])]=mt_rand(1,9);
$numberchain=str_replace($random,"",$numberchain); |