<?php
/*
* explorer! function library
* Date of preparation: 2008-06-29
* Last update: 2008-07-18 2:08
*
*/
Class system{//System section
function Usr_level ($name) {
$SQL = new MySQL ();
$SQL->query ("Select ' Level ' WHERE ' username ' = ' $name ';");
$SQL->nextrecord ();
$TMP = $SQL->getrecord (' level ');
$SQL->free ();
return $TMP;
}
function Channel_level ($cid) {
$SQL = new MySQL ();
$SQL->query ("Select ' Level ' channels ' WHERE ' id ' = $id;");
$SQL->nextrecord ();
$TMP = $SQL->getrecord (' id ');
$SQL->free ();
return $TMP;
}
function Uid2name ($uid) {
$SQL = new MySQL ();
if ($SQL->query ("Select ' username ' from ' WHERE '" uid ' = $uid; ")) {
$SQL->nextrecord ();
$TMP = $SQL->getrecord (' username ');
$SQL->free ();
return $TMP;
}else{
return 0;
}
}
function Name2uid ($name) {
$SQL = new MySQL ();
if ($SQL->query ("Select ' uid ' from ' WHERE ' username ' = ' $name ';")) {
$SQL->nextrecord ();
$TMP = $SQL->getrecord (' uid ');
$SQL->free ();
return $TMP;
}else{
return 0;
}
}
function SysInfo ($Name) {//Get system Information
$SQL = new MySQL ();
$SQL->query ("select * from ' SysInfo ';");
$SQL->nextrecord ();
$TMP = $SQL->getrecord ($Name);
$SQL->free ();
return $TMP;
}
function Find_member ($name) {//Find the user (required for registration)
$SQL = New MySQL ();
$SQL->query ("select * from ' The Members ' WHERE ' username ' = ' $name ';");
$RS = $SQL->rows ();
$SQL->free ();
if ($RS)
return 1;
Else
return 0;
}
function Str_safe ($STR) {//String security filtering
$str = Str_replace ($str, ";", ";");
$str = Str_replace ($str, "'", "");
$str = Str_replace ($str, "/", "/");
$str = Str_replace ($str, "'", "");
$str = Str_replace ($str, "\", "\");
return $str;
}
function Getmyip ()
{
if ($HTTP _server_vars["Http_x_forwarded_for"])
$ip = $HTTP _server_vars["Http_x_forwarded_for"];
ElseIf ($HTTP _server_vars["HTTP_CLIENT_IP"])
$ip = $HTTP _server_vars["Http_client_ip"];
ElseIf ($HTTP _server_vars["REMOTE_ADDR"])
$ip = $HTTP _server_vars["REMOTE_ADDR"];
ElseIf (getenv ("Http_x_forwarded_for"))
$ip = getenv ("Http_x_forwarded_for");
ElseIf (getenv ("Http_client_ip"))
$ip = getenv ("Http_client_ip");
ElseIf (getenv ("REMOTE_ADDR"))
$ip = getenv ("REMOTE_ADDR");
Else
$ip = "127.0.0.1";
return $IP;
}
function Version () {
return "1.0.9";
}
}
Class mysql{//Database section
var $DBServer = ' localhost ';//server
var $DBName = ';//Database name
var $DBUser = ';//database user
var $DBPass = ';//Database Password
var $OnErrorResume = 1;//Error prompt shutdown
var $LinkID = 0;//Connection handle
var $QueryID = 0;//Query handle
var $ResultS = array ();//Query result set
var $Error = ';//error message
Function Connect ($SRV = "", $USR = "", $Pass = "", $DB = "") {//Connection database
if ($SRV = = "") $Srv = $this->dbserver;
if ($USR = = "") $USR = $this->dbuser;
if ($Pass = = "") $Pass = $this->dbpass;
if ($DB = = "") $DB = $this->dbname;
if ($this->linkid = = 0) {
$this->linkid = @mysql_connect ($SRV, $USR, $Pass) or Die ("database connection failed, contact your administrator to fix this problem." ");
}
@mysql_select_db ($DB, $this->linkid) or Die ("Database selection failed, please contact your administrator to fix this problem." ");
return $this->linkid;
}
function free () {//Release query results
@mysql_free_result ($this->queryid);
$this->queryid = 0;
}
function RowS () {//Total number of records queried
if (! $this->queryid) return 0;
Return @mysql_num_rows ($this->queryid);
}
function NextRecord () {//Next record
if (! $this->queryid) return 0;
$this->results = @mysql_fetch_array ($this->queryid);
}
function Seek ($seek) {
if (! $this->queryid) return 0;
@mysql_data_seek ($this->queryid, $seek);
}
function query ($SQL) {//Execute Query
if ($SQL = = "") return 0;
if ($this->linkid = = 0) $this->connect ();
if ($this->queryid) $this->free ();//Release original query result
$this->queryid = @mysql_query ($SQL, $this->linkid);
$this->error = mysql_error ($this->linkid);
if (! $this->queryid) exit ("$Sql execution failed.");
return $this->queryid;
}
function Getrecord ($Name) {
if (! $this->queryid) return 0;
return $this->results[$Name];
}
}
?>