Location: PHPKode > projects > Chinese Project Forum > upload/admin/global.php
<?
require("./../config.php");
#°æ±¾°üº¬
include ("./../version.php");
#AdodbÊý¾Ý¿â·¾¶
$adodbdir="./../cpfadodb";
#ADODB°üº¬
require("$adodbdir/adodb.inc.php");
#ADODBÊý¾Ý¿âÁ¬½Ó
$conn=&ADONEWConnection($dbtype);
if ($usepconnect)
$conn->PConnect($dbhost,$dbuser,$dbpassword,$dbdb);
else $conn->Connect($dbhost,$dbuser,$dbpassword,$dbdb);
#ADODB Êý×éģʽ
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
#ADODB Debugģʽ
$conn->debug = false;

#Sessions³õʼ»¯

session_name("sid");
session_start();
if(!$sid) $sid = session_id();

if(!$user_id) $user_id = $HTTP_SESSION_VARS[user_id];
if(!$user_password) $user_password = $HTTP_SESSION_VARS[user_password];

$session = "&sid=".$sid;
$session2 = "?sid=".$sid;


function gettemplate($template) {
	$file = file("templates/".$template.".htm");
	$template = implode("",$file);
	$template = str_replace("\"","\\\"",$template);
	return $template;
}

function dooutput($template) {
	echo $template;
}

function getUserid($usernick) {
	global $prefix,$conn;
	$result = &$conn->Execute("SELECT userid FROM ".$prefix."_user_table WHERE username='$usernick'");
	return $result->fields[userid];
}

function getUser_stat($userid,$password)  {
	global $prefix,$conn;
	$result = &$conn->Execute("SELECT groupid, blocked FROM ".$prefix."_user_table WHERE userid='$userid' AND userpassword='$password' AND activation='1'");
	$result = $result->fields;
	$result = &$conn->Execute("SELECT canuseacp FROM ".$prefix."_groups WHERE id = '$result[groupid]'");
        return $result->fields[0];
}

function editDBdata($data) {
	$data = str_replace("&acute;","'", $data);
	$data = str_replace("&quot;","\"", $data);
	return $data;
}

function editPostdata($data) {
	$data = str_replace("'","&acute;", $data);
	$data = str_replace("\"","&quot;", $data);
	return $data;
}

function check_boardobject($boardid,$objectid,$field) {
	global $conn, $prefix;
	$result = &$conn->Execute("SELECT COUNT(*) FROM ".$prefix."_object2board WHERE boardid = '$boardid' AND objectid = '$objectid' AND $field = 1");
	return $result->fields[0];
}

function checkemail($email) {
	global $conn, $prefix;
	if(!substr_count($email,"@") || substr_count($email,"@")>1) return 1;
	$position1 = strrpos($email,"@");
	if(!$position1) return 1;
	$position2 = strrpos($email,".");
	if(!$position2) return 1;
	if(strlen(substr($email, $position2)) < 3)return 1;
	if(strlen(substr($email, $position1,$position2-$position1-1))<2) return 1;

	$result = &$conn->Execute("SELECT multi_email, banemail FROM ".$prefix."_config");
	if(!$result->fields[0]) {
		$check = &$conn->Execute("SELECT COUNT(userid) FROM ".$prefix."_user_table WHERE useremail = '$email'");
		if($check->fields[0]) return 1;
	}
	$banemail = explode("\n",$result->fields[banemail]);
	for($i = 0; $i < count($banemail); $i++) {
		if(!trim($banemail[$i])) continue;
		if(ereg("\*", $banemail[$i])) {
			$banemail[$i] = str_replace("*",".*", trim($banemail[$i]));
			if(eregi("$banemail[$i]", $email)) return 1;
			break;
		}
		elseif(strtolower($email)==strtolower(trim($banemail[$i]))) {
			return 1;
			break;
		}  
	}
	
}

function checkname($name) {
	global $conn, $prefix;
	$check = &$conn->Execute("SELECT COUNT(userid) FROM ".$prefix."_user_table WHERE username = '$name'");
	return $check->fields[0];
}

function Hackdate($time) {
	global $conn, $prefix;
	$recordset = &$conn->Execute("SELECT timeoffset, shortdateformat, timetype  FROM ".$prefix."_config");
	$config = $recordset->fields;
	$out = str_replace("DD",date("d", $time+(3600*$config[timeoffset])), $config[shortdateformat]);
	$out = str_replace("MM",date("m", $time+(3600*$config[timeoffset])), $out);
	$out = str_replace("YYYY",date("Y", $time+(3600*$config[timeoffset])), $out);
	$out = str_replace("YY",date("y", $time+(3600*$config[timeoffset])), $out);
	$out = str_replace("MN",get_month_name(date("n", $time+(3600*$config[timeoffset]))), $out);
	if($config[timetype]) { #12 Stunden
		$out = str_replace("II","II ".date("A", $time+(3600*$config[timeoffset])), $out);	
		$out = str_replace("HH",date("h", $time+(3600*$config[timeoffset])), $out);
	}
	else $out = str_replace("HH",date("H", $time+(3600*$config[timeoffset])), $out);
	$out = str_replace("II",date("i", $time+(3600*$config[timeoffset])), $out);
	return $out;
}

function get_month_name($month_number) {
	$name_monat[1]    =  "January";  
	$name_monat[2]    =  "February";  
	$name_monat[3]    =  "March";  
	$name_monat[4]    =  "April";  
	$name_monat[5]    =  "May";  
	$name_monat[6]    =  "June";  
	$name_monat[7]    =  "July";  
	$name_monat[8]    =  "August";  
	$name_monat[9]    =  "September";  
	$name_monat[10]  =  "October";  
	$name_monat[11]  =  "November";  
	$name_monat[12]  =  "December";
	
	return $name_monat[$month_number];
}

function bb_order() {
	global $conn, $prefix;
	$board_result = &$conn->Execute("SELECT boardid FROM ".$prefix."_boards");
	while(!$board_result->EOF) {
		$boards = $board_result->fields;
		$countp = &$conn->Execute("SELECT COUNT(postid) FROM ".$prefix."_posts WHERE boardparentid = '$boards[boardid]'");
		$countp = $countp->fields;
		$countt = &$conn->Execute("SELECT COUNT(threadid) FROM ".$prefix."_threads WHERE boardparentid = '$boards[boardid]'");
		$countt = $countt->fields;
		$lastpost = $conn->Execute("SELECT postid, posttime FROM ".$prefix."_posts WHERE boardparentid = '$boards[boardid]' ORDER BY posttime DESC LIMIT 1");
		$lastpost = $lastpost->fields;
		$conn->Execute("UPDATE ".$prefix."_boards SET posts = '$countp[0]', threads = '$countt[0]', lastposttime = '$lastpost[posttime]', lastpostid = '$lastpost[postid]' WHERE boardid = '$boards[boardid]'");	
		$board_result->MoveNext();
	}
}

function ifelse ($expression,$returntrue,$returnfalse) {
	if (!$expression) return $returnfalse;
	else return $returntrue;
}

?>
Return current item: Chinese Project Forum