<?php
if(!defined('DRK'))die('Hacking attempt...');
function SignupChars($text)
{
$chars="aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789.-_";
for($i=0;$i<strlen($text);$i++){
$ch=substr($text,$i,1);
if(substr_count($chars,$ch)==0)return false;
}
return $chars;
}
function EmailChars($text)
{
$chars="abcdefghijklmnopqrstuvwxyz0123456789.-_@";
for($i=0;$i<strlen($text);$i++){
$ch=substr($text,$i,1);
if(substr_count($chars,$ch)==0)return false;
if(!strpos($text,"@"))return false;
}
return true;
}
function IllegalChars($text)
{
/*if(preg_match('/[^a-z0-9\ \-\_\/\*\(\)\[\]\!\?\.\,\#\:\&\%\@\=\+\~\<\>\;]/i',$text))return true;*/
$chars="aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789 -_\*()[]!?.,#:&%$@=+~<>;/";
for($i=0;$i<strlen($text);$i++){
$ch=substr($text,$i,1);
if(substr_count($chars,$ch)==0)return true;
}
return false;
}
function get_var($var)
{
$myvar=$_REQUEST["$var"];
if(is_array($myvar))$var=$myvar[0];
else $var=htmlspecialchars(trim($_REQUEST["$var"]),ENT_QUOTES);
return $var;
}
function error($errmsg)
{
global $global_what;
global $global_with;
global $sitename;
$what=Array("errmsg","sitename");
$with=Array($errmsg,$sitename);
Template($what,$with,"error");
exit;
}
function TimeMsg($secs)
{
$msg="";
$mins=floor(($secs)/60);
$hours=floor(($mins)/60);
$days=floor(($hours)/24);
if($secs>59)$secs=$secs-($mins*60);
if($mins>59)$mins=$mins-($hours*60);
if($hours>23)$hours=$hours-($days*24);
if($days>0)$msg.=$days." day";
if($days>1)$msg.="s";
if(($days>0||$weeks>0)&&$hours>0)$msg.=", ";
if($hours>0)$msg.=$hours." hour";
if($hours>1)$msg.="s";
if($days==0||$hours==0){
if(($hours>0||$days>0)&&$mins>0)$msg.=", ";
if($mins>0)$msg.=$mins." minute";
if($mins>1)$msg.="s";
}
if($mins<1)$msg="less then a minute";
return $msg;
}
function bb_code($text)
{
global $action,$mod,$session;
$text=preg_replace('/[^0-9a-z\ \-\_\/\*\(\)\[\]\!\?\.\,\#\:\&\%\$\@\=\+\~\<\>\;]+/i','',$text);
$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);
$query=query("*",smileys);
while($row=mysql_fetch_array($query)){
$text=str_replace($row['code'],"<img src=\"$row[path]\" alt=\"$row[code]\"/>",$text);
}
return $text;
}
function Location($path)
{
global $act,$ses,$username,$password,$global_what,$global_with,$sitename;
if($act!="login")$ses_path="&ses=$ses";
else $ses_path="";
$location="http://$_SERVER[SERVER_NAME]/?$path$ses_path";
$what=Array("sitename","sesid","location");
$with=Array($sitename,"&ses=$sesid",$location);
Template($what,$with,"location");
exit;
}
?>