📄 core.php
字号:
////////////////////////Get user id from session id
function getuid_sid($sid)
{
$uid = mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_ses WHERE id='".$sid."'"));
$uid = $uid[0];
return $uid;
}
/////////////////////Get total number of pms
function getpmcount($uid,$view="all")
{
if($view=="all"){
$nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."'"));
}else if($view =="snt")
{
$nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE byuid='".$uid."'"));
}else if($view =="str")
{
$nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND starred='1'"));
}else if($view =="urd")
{
$nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND unread='1'"));
}
return $nopm[0];
}
function deleteClub($clid)
{
$fid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_forums WHERE clubid='".$clid."'"));
$fid = $fid[0];
$topics = mysql_query("SELECT id FROM ibwf_topics WHERE fid=".$fid."");
while($topic = mysql_fetch_array($topics))
{
mysql_query("DELETE FROM ibwf_posts WHERE tid='".$topic[0]."'");
}
mysql_query("DELETE FROM ibwf_topics WHERE fid='".$fid."'");
mysql_query("DELETE FROM ibwf_forums WHERE id='".$fid."'");
mysql_query("DELETE FROM ibwf_rooms WHERE clubid='".$clid."'");
mysql_query("DELETE FROM ibwf_clubmembers WHERE clid='".$clid."'");
mysql_query("DELETE FROM ibwf_announcements WHERE clid='".$clid."'");
mysql_query("DELETE FROM ibwf_clubs WHERE id=".$clid."");
return true;
}
function deleteMClubs($uid)
{
$uclubs = mysql_query("SELECT id FROM ibwf_clubs WHERE owner='".$uid."'");
while($uclub=mysql_fetch_array($uclubs))
{
deleteClub($uclub[0]);
}
}
//////////////////////Function add user to online list :P
function addonline($uid,$place,$plclink)
{
/////delete inactive users
$tm = time();
$timeout = $tm - 420; //time out = 5 minutes
$deloff = mysql_query("DELETE FROM ibwf_online WHERE actvtime <'".$timeout."'");
///now try to add user to online list
$res = mysql_query("UPDATE ibwf_users SET lastact='".time()."' WHERE id='".$uid."'");
$res = mysql_query("INSERT INTO ibwf_online SET userid='".$uid."', actvtime='".$tm."', place='".$place."', placedet='".$plclink."'");
if(!$res)
{
//most probably userid already in the online list
//so just update the place and time
$res = mysql_query("UPDATE ibwf_online SET actvtime='".$tm."', place='".$place."', placedet='".$plclink."' WHERE userid='".$uid."'");
}
$maxmem=mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE id='2'"));
$result = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_online"));
if($result[0]>=$maxmem[0])
{
$tnow = date("D d M Y - H:i");
mysql_query("UPDATE ibwf_settings set name='".$tnow."', value='".$result[0]."' WHERE id='2'");
}
$maxtoday = mysql_fetch_array(mysql_query("SELECT ppl FROM ibwf_mpot WHERE ddt='".date("d m y")."'"));
if($maxtoday[0]==0||$maxtoday=="")
{
mysql_query("INSERT INTO ibwf_mpot SET ddt='".date("d m y")."', ppl='1', dtm='".date("H:i:s")."'");
$maxtoday[0]=1;
}
if($result[0]>=$maxtoday[0])
{
mysql_query("UPDATE ibwf_mpot SET ppl='".$result[0]."', dtm='".date("H:i:s")."' WHERE ddt='".date("d m y")."'");
}
}
/////////////////////Get members online
function getnumonline()
{
$nouo = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_online "));
return $nouo[0];
}
//////////////////////////////////////is ignored
function isignored($tid, $uid)
{
$ign = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_ignore WHERE target='".$tid."' AND name='".$uid."'"));
if($ign[0]>0)
{
return true;
}
return false;
}
///////////////////////////////////////////GET IP
function getip()
{
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$ip=getenv('HTTP_X_FORWARDED_FOR');
}
else
{
$ip=getenv('REMOTE_ADDR');
}
return $ip;
}
//////////////////////////////////////////ignore result
function ignoreres($uid, $tid)
{
//0 user can't ignore the target
//1 yes can ignore
//2 already ignored
if($uid==$tid)
{
return 0;
}
if(ismod($tid))
{
//you cant ignore staff members
return 0;
}
if(arebuds($tid, $uid))
{
//why the hell would anyone ignore his bud? o.O
return 0;
}
if(isignored($tid, $uid))
{
return 2; // the target is already ignored by the user
}
return 1;
}
///////////////////////////////////////////Function getage
function getage($strdate)
{
$dob = explode("-",$strdate);
if(count($dob)!=3)
{
return 0;
}
$y = $dob[0];
$m = $dob[1];
$d = $dob[2];
if(strlen($y)!=4)
{
return 0;
}
if(strlen($m)!=2)
{
return 0;
}
if(strlen($d)!=2)
{
return 0;
}
$y += 0;
$m += 0;
$d += 0;
if($y==0) return 0;
$rage = date("Y") - $y;
if(date("m")<$m)
{
$rage-=1;
}else{
if((date("m")==$m)&&(date("d")<$d))
{
$rage-=1;
}
}
return $rage;
}
/////////////////////////////////////////getavatar
function getavatar($uid)
{
$av = mysql_fetch_array(mysql_query("SELECT avatar FROM ibwf_users WHERE id='".$uid."'"));
return $av[0];
}
/////////////////////////////////////////Can see details?
function cansee($uid, $tid)
{
if($uid==$tid)
{
return true;
}
if(ismod($uid))
{
return true;
}
return false;
}
//////////////////////////gettimemsg
function gettimemsg($sec)
{
$ds = floor($sec/60/60/24);
if($ds > 0)
{
return "$ds days";
}
$hs = floor($sec/60/60);
if($hs > 0)
{
return "$hs hours";
}
$ms = floor($sec/60);
if($ms > 0)
{
return "$ms minutes";
}
return "$sec Seconds";
}
/////////////////////////////////////////get status
function getstatus($uid)
{
$info= mysql_fetch_array(mysql_query("SELECT perm, plusses FROM ibwf_users WHERE id='".$uid."'"));
if(isbanned($uid))
{
return "Banned!";
}
if($info[0]=='2')
{
return "Administrator!";
}else if($info[0]=='1')
{
return "Moderator!";
}else{
if($info[1]<10)
{
return "Newbie";
}else if($info[1]<25)
{
return "Member";
}else if($info[1]<50)
{
return "Advanced Member";
}else if($info[1]<75)
{
return "Super Member";
}else if($info[1]<250)
{
return "Valued Member";
}else if($info[1]<500)
{
return "wappyCULT VIP";
}else if($info[1]<750)
{
return "Extreme Member";
}else if($info[1]<1000)
{
return "Forum Guru";
}else if($info[1]<1500)
{
return "Hardcore Poster";
}else if($info[1]<2000)
{
return "Forum Master";
}else if($info[1]<2500)
{
return "The Demon Poster";
}else if($info[1]<3000)
{
return "Forum Freak";
}else if($info[1]<4000)
{
return "I Post Too Much Lol";
}else if($info[1]<5000)
{
return "24/7 Poster";
}else if($info[1]<10000)
{
return "Geek";
}else
{
return "Ultimate Member!!";
}
}
}
/////////////////////Get Page Jumber
function getjumper($action, $sid,$pgurl)
{
$rets = "Jump to page<input name=\"pg\" format=\"*N\" size=\"3\"/>";
$rets .= "<anchor>[GO]";
$rets .= "<go href=\"$pgurl.php\" method=\"get\">";
$rets .= "<postfield name=\"action\" value=\"$action\"/>";
$rets .= "<postfield name=\"sid\" value=\"$sid\"/>";
$rets .= "<postfield name=\"page\" value=\"$(pg)\"/>";
$rets .= "</go></anchor>";
return $rets;
}
/////////////////////Get unread number of pms
function getunreadpm($uid)
{
$nopm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND unread='1'"));
return $nopm[0];
}
//////////////////////GET USER NICK FROM USERID
function getnick_uid($uid)
{
$unick = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_users WHERE id='".$uid."'"));
return $unick[0];
}
///////////////////////////////////////////////Get the smilies
function getsmilies($text)
{
$sql = "SELECT * FROM ibwf_smilies";
$smilies = mysql_query($sql);
while($smilie=mysql_fetch_array($smilies))
{
$scode = $smilie[1];
$spath = $smilie[2];
$text = str_replace($scode,"<img src=\"$spath\" alt=\"$scode\"/>",$text);
}
return $text;
}
////////////////////////////////////////////check nicks
function checknick($aim)
{
$chk =0;
$aim = strtolower($aim);
$nicks = mysql_query("SELECT id, name, nicklvl FROM ibwf_nicks");
while($nick=mysql_fetch_array($nicks))
{
if($aim==$nick[1])
{
$chk = $nick[2];
}else if(substr($aim,0,strlen($nick[1]))==$nick[1])
{
$chk = $nick[2];
}else{
$found = strpos($aim, $nick[1]);
if($found!=0)
{
$chk = $nick[2];
}
}
}
return $chk;
}
function autopm($msg, $who)
{
mysql_query("INSERT INTO ibwf_private SET text='".$msg."', byuid='1', touid='".$who."', unread='1', timesent='".time()."'");
}
////////////////////////////////////////////////////Register
function register($name,$pass,$usex,$bday,$uloc, $ubr)
{
$execms = mysql_query("SELECT * FROM ibwf_users WHERE name='".$name."';");
if (mysql_num_rows($execms)>0){
return 1;
}else{
$pass = md5($pass);
$reg = mysql_query("INSERT INTO ibwf_users SET name='".$name."', pass='".$pass."', birthday='".$bday."', sex='".$usex."', location='".$uloc."', regdate='".time()."', ipadd='".getip()."', browserm='".$ubr."'");
if ($reg)
{
$uid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_users WHERE name='".$name."'"));
$msg = "Hello /reader :-)greetings from all wappyCULT staff, we are happy to have you here, welcome to our big happy family! to get the most of our site please read /faq, then read the forums! Also please do not pm administrators for site help, just post in the forums. ENJOY! -hacker- ";
$msg = mysql_escape_string($msg);
autopm($msg, $uid[0]);
return 0;
}else{
return 2;
}
}
}
/////////////////////// GET ibwf_users user id from nickname
function getuid_nick($nick)
{
$uid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_users WHERE name='".$nick."'"));
return $uid[0];
}
/////////////////////////////////////////Is admin?
function isadmin($uid)
{
$admn = mysql_fetch_array(mysql_query("SELECT perm FROM ibwf_users WHERE id='".$uid."'"));
if($admn[0]=='2')
{
return true;
}else{
return false;
}
}
///////////////////////////////////parse bbcode
function getbbcode($text, $sid="")
{
$text=preg_replace("/\[b\](.*?)\[\/b\]/i","<b>\\1</b>", $text);
$text=preg_replace("/\[i\](.*?)\[\/i\]/i","<i>\\1</i>", $text);
$text=preg_replace("/\[u\](.*?)\[\/u\]/i","<u>\\1</u>", $text);
$text=preg_replace("/\[big\](.*?)\[\/big\]/i","<big>\\1</big>", $text);
$text=preg_replace("/\[small\](.*?)\[\/small\]/i","<small>\\1</small>", $text);
$text = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href=\"$1\">$2</a>",$text);
$text = preg_replace("/\[topic\=(.*?)\](.*?)\[\/topic\]/is","<a href=\"index.php?action=viewtpc&tid=$1&sid=$sid\">$2</a>",$text);
$text = preg_replace("/\[club\=(.*?)\](.*?)\[\/club\]/is","<a href=\"index.php?action=gocl&clid=$1&sid=$sid\">$2</a>",$text);
$text = preg_replace("/\[blog\=(.*?)\](.*?)\[\/blog\]/is","<a href=\"index.php?action=viewblog&bid=$1&sid=$sid\">$2</a>",$text);
//$text = ereg_replace("http://[A-Za-z0-9./=?-_]+","<a href=\"\\0\">\\0</a>", $text);
if(substr_count($text,"[br/]")<=3){
$text = str_replace("[br/]","<br/>",$text);
}
$text = str_replace("2wap","2crapforwap",$text);
$text = str_replace("2WAP","2crapforwap",$text);
$text = str_replace("2wAp","2crapforwap",$text);
$text = str_replace("2w4p","2crapforwap",$text);
$text = str_replace("2waP","2crapforwap",$text);
$text = str_replace("2Wap","2crapforwap",$text);
$text = str_replace("hiphop4u","britneyspears",$text);
$text = str_replace("HIPHOP4U","britneyspears",$text);
$text = str_replace("HiPhOp4U","britneyspears",$text);
$text = str_replace("hIpHoP4u","britneyspears",$text);
$text = str_replace("Hiphop4U","britneyspears",$text);
$text = str_replace("Hiphop4u","britneyspears",$text);
$text = str_replace("HipHop4u","britneyspears",$text);
$text = str_replace("hh4u","britneyspears",$text);
$text = str_replace("HH4U","britneyspears",$text);
$text = str_replace("Hh4u","britneyspears",$text);
$text = str_replace("hH4U","britneyspears",$text);
$text = str_replace("HH4u","britneyspears",$text);
$text = str_replace("hh4U","britneyspears",$text);
return $text;
}
//////////////////////////////////////////////////MISC FUNCTIONS
function spacesin($word)
{
$pos = strpos($word," ");
if($pos === false)
{
return false;
}else
{
return true;
}
}
/////////////////////////////////Number of registered members
function regmemcount()
{
$rmc = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users"));
return $rmc[0];
}
///////
///////////////////////////function counter
function addvisitor()
{
$cc = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='Counter'"));
$cc = $cc[0]+1;
$res = mysql_query("UPDATE ibwf_settings SET value='".$cc."' WHERE name='Counter'");
}
function scharin($word)
{
$chars = "abcdefghijklmnopqrstuvwxyz0123456789-_";
for($i=0;$i<strlen($word);$i++)
{
$ch = substr($word,$i,1);
$nol = substr_count($chars,$ch);
if($nol==0)
{
return true;
}
}
return false;
}
function isdigitf($word)
{
$chars = "abcdefghijklmnopqrstuvwxyz";
$ch = substr($word,0,1);
$sres = ereg("[0-9]",$ch);
$ch = substr($word,0,1);
$nol = substr_count($chars,$ch);
if($nol==0)
{
return true;
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -