<?
if( defined( "_LIB_" ) ) return;
define ("_LIB_", 1);
function redirect($url){
header("Location: $url");
}
function wrap($body, $padsize = 76){
$arr=explode(" ", $body);
$count = count($arr);
for($x=0; $x<$count; $x++)
$arr[$x] = (strlen($arr[$x])<=$padsize ? $arr[$x] : substr($arr[$x],0,$padsize)."\n".substr($arr[$x],$padsize, $padsize));
return implode($arr, " ");
}
function br(){
echo "<BR>";
}
function error_f($text){
global $theme, $design, $lang, $pre, $relpath;
$head = ereg_replace("__TITLE__", $lang['title'], $design['head']);
echo $head;
include $pre."themes/".$theme."/header.inc";
error($text);
}
function error($text){
global $theme, $design, $pre, $relpath;
if(is_array($text)){
$count = count($text);
for($x=0; $x<$count; $x++)
echo "<div class=\"error\">$text[$x]</div><br>";
}
else
echo "<div class=\"error\">$text</div>";
$t="d";
include $pre."themes/".$theme."/footer.inc";
echo $design['footer'];
exit();
}
function validate_email($email){
return ereg(".+@.+(\..+)+", $email);
}
function extmailcheck($email) {
$wholeexp = "/^(.+?)@((.+?)\.[a-z]{2,5})$/";
$userexp = "/^[a-z0-9\~\!\#\$\%\&\(\)\-\_\+\=\[\]\;\:\'\"\,\.\/]+$/i";
if (preg_match($wholeexp, $email, $regs)) {
$username = $regs[1];
$host = $regs[2];
if (checkdnsrr($host, MX)) {
if (preg_match($userexp, $username)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
function auth_mod($f){
global $forum_array, $admin_name, $admin_pass;
global $PHP_AUTH_USER, $PHP_AUTH_PW;
if(!isset($PHP_AUTH_USER))
login(3);
else{
if($PHP_AUTH_PW!=$forum_array[$f]['mod_pass'] &&
($PHP_AUTH_USER != $admin_name && $PHP_AUTH_PW != $admin_pass)){
login(3);
}
}
}
function auth($type=1){
global $admin_name, $admin_pass, $PHP_AUTH_USER, $PHP_AUTH_PW;
if(!isset($PHP_AUTH_USER))
login($type);
else{
if($PHP_AUTH_USER!=$admin_name || $PHP_AUTH_PW!=$admin_pass){
login($type);
}
}
}
function login($type=1){
global $lang;
switch($type){
case 1:
$out = $lang['admin_tools'];
break;
case 2:
$out = $lang['res_name'];
break;
case 3:
$out = "Moderation";
}
header("WWW-Authenticate: Basic realm=\"$out\"");
header("HTTP/1.0 401 Unauthorized");
error_f($lang['auth_failed']);
}
function dots($text, $len){
if($len<0) $len=0;
if(strlen($text)>$len)
return substr($text, 0, $len)."...";
else
return $text;
}
function hide_addr($text){
$out_text="";
$len = strlen($text);
for($x=0; $x<$len; $x++){
$out_text .= "%".dechex(ord($text[$x]));
}
return $out_text;
}
?>