澳门新葡萄京官网注册php REMOTE

上面来拜见在重重程序语言中会使用到的class吧,现在会举个大致的实例来促成php
class,类申明,class使用方法哦。

<?php
/*
 * Explorer! 函数库
 * 编写日期:2009-06-29
 * 最终更新:2010-07-18 2:08
 *
 */
class System{//系统部分
 function usr_level($name){
  $SQL = new MySQL();
  $SQL->Query(“SELECT `level` FROM `members` WHERE `username` =
‘$name’;”);
  $SQL->NextRecord();
  $TMP = $SQL->GetRecord(‘level’);
  $SQL->Free();
  return $TMP;
 }
 function channel_level($cid){
  $SQL = new MySQL();
  $SQL->Query(“SELECT `level` FROM `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 `members` 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 `members` WHERE `username`
= ‘$name’;”)){
   $SQL->NextRecord();
   $TMP = $SQL->GetRecord(‘uid’);
   $SQL->Free();
   return $TMP;
  }else{
   return 0;
  }
 }
 function sysinfo($Name卡塔尔(قطر‎{//获取系统音讯
  $SQL = new MySQL();
  $SQL->Query(“SELECT * FROM `sysinfo`;”);
  $SQL->NextRecord();
  $TMP = $SQL->GetRecord($Name);
  $SQL->Free();
  return $TMP;
 }
 function find_member($nameState of Qatar{//查找该顾客(注册时索要)
  $SQL = New MySQL();
  $SQL->Query(“SELECT * FROM `members` WHERE `username` =
‘$name’;”);
  $RS = $SQL->RowS();
  $SQL->Free();
  if($RS)
   return 1;
  else
   return 0;
 }
 function str_safe($str卡塔尔(قطر‎{//字符串安全过滤
  $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{//数据库部分
 var $DBServer = ‘localhost’;//服务器
 var $DBName = ”;//数据库名称
 var $DBUser = ”;//数据库顾客
 var $DBPass = ”;//数据库密码
 var $OnErrorResume = 1;//错误提醒关闭
 var $LinkID = 0;//连接句柄
 var $QueryID = 0;//查询句柄
 var $ResultS = array(卡塔尔国;//查询结果集
 var $Error = ”;//错误新闻
 function Connect($Srv = “”,$Usr = “”,$Pass = “”,$DB =
“”卡塔尔(قطر‎{//连接数据库
  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(“数据库连接失利,请联系管理员修复此难点。”卡塔尔(قطر‎;
  }
  @mysql_select_db($DB,$this->LinkID卡塔尔国 or
die(“数据库选用失利,请联系管理员修复此主题材料。”卡塔尔;
  return $this->LinkID;
 }
 function Free(卡塔尔{//释放查询结果
  @mysql_free_result($this->QueryID);
  $this->QueryID = 0;
 }
 function RowS(卡塔尔{//查询到的笔录总量
  if(!$this->QueryID) return 0;
  return @mysql_num_rows($this->QueryID);
 }
 function NextRecord(卡塔尔国{//下一条记下
  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卡塔尔国{//推行查询
  if($Sql == “”) return 0;
  if($this->LinkID == 0) $this->Connect();
  if($this->QueryID卡塔尔(قطر‎ $this->Free(卡塔尔(قطر‎;//释放原本查询结果
  $this->QueryID = @mysql_query($Sql,$this->LinkID);
  $this->Error = mysql_error($this->LinkID);
  if(!$this->QueryID卡塔尔 exit(“$Sql施行败北.”卡塔尔国; 
  return $this->QueryID; 
 }
 function GetRecord($Name){
  if(!$this->QueryID) return 0;
  return $this->ResultS[$Name];
 }
}
?>

echo get_real_ip();
?>

?php/** Explorer! 函数库* 编写日期:贰零零捌-06-29* 最终更新:2008-07-18
2:08**/class System{//系统部分function usr_level($name){$SQL = new
MySQL();$SQL-Query(SELECT `level` FROM `members` WHERE `username`
= ‘$name’;);$SQL-NextRecord();$TMP =
$SQL-GetRecord(‘level’);$SQL-Free();return $TMP;}function
channel_level($cid){$SQL = new MySQL();$SQL-Query(SELECT `level` FROM
`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
`members` 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 `members` WHERE `username` =
‘$name’;卡塔尔国卡塔尔(قطر‎{$SQL-NextRecord(卡塔尔国;$TMP =
$SQL-GetRecord(‘uid’卡塔尔(قطر‎;$SQL-Free(卡塔尔(قطر‎;return $TMP;}else{return 0;}}function
sysinfo($Name卡塔尔国{//获取系统音讯$SQL = new MySQL(State of Qatar;$SQL-Query(SELECT *
FROM `sysinfo`;);$SQL-NextRecord();$TMP =
$SQL-GetRecord($Name);$SQL-Free();return $TMP;}function
find_member($nameState of Qatar{//查找该顾客$SQL = New MySQL(卡塔尔;$SQL-Query(SELECT *
FROM `members` WHERE `username` = ‘$name’;);$RS =
$SQL-RowS();$SQL-Free();if($RS)return 1;elsereturn 0;}function
str_safe($str卡塔尔{//字符串安全过滤$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_ADD中华V卡塔尔(قطر‎;else$ip = 127.0.0.1;return $ip;}function
Version(卡塔尔国{return 1.0.9;}}class MySQL{//数据库部分var $DBServer =
‘localhost’;//服务器var $DBName = ”;//数据库名称var $DBUser =
”;//数据库顾客var $DBPass = ”;//数据库密码var $OnErrorResume =
1;//错误提醒关闭var $LinkID = 0;//连接句柄var $QueryID = 0;//查询句柄var
$ResultS = array(State of Qatar;//查询结果集var $Error = ”;//错误新闻function
Connect($Srv = ,$Usr = ,$Pass = ,$DB = State of Qatar{//连接数据库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(数据库连接失利,请联系管理员修复此主题材料。卡塔尔;}@mysql_select_db($DB,$this-LinkIDState of Qataror die(数据库接受失利,请联系管理员修复此难题。卡塔尔(قطر‎;return
$this-LinkID;}function
Free(State of Qatar{//释放查询结果@mysql_free_result($this-QueryID卡塔尔;$this-QueryID =
0;}function RowS(卡塔尔国{//查询到的笔录总的数量if(!$this-QueryID) return 0;return
@mysql_num_rows($this-QueryID卡塔尔;}function
NextRecord(卡塔尔国{//下一条记录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,$seekState of Qatar;}function
Query($Sql卡塔尔国{//推行查询if($Sql == 卡塔尔 return 0;if($this-LinkID == 0卡塔尔$this-Connect(卡塔尔(قطر‎;if($this-QueryID卡塔尔国$this-Free(卡塔尔(قطر‎;//释放原本查询结果$this-QueryID =
@mysql_query($Sql,$this-LinkID);$this-Error =
mysql_error($this-LinkID);if(!$this-QueryIDState of Qatar exit($Sql执行退步.卡塔尔国;return
$this-QueryID;}function GetRecord($Name卡塔尔(قطر‎{if(!$this-QueryID) return
0;return $this-ResultS[$Name];}}?

echo $user_IP;
?>

<?php
function get_real_ip(){
$ip=false;
if(!empty($_SERVER[“HTTP_CLIENT_IP”])){
$ip = $_SERVER[“HTTP_CLIENT_IP”];
}
if (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
$ips = explode (“, “, $_SERVER[‘HTTP_X_FORWARDED_FOR’]);
if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
for ($i = 0; $i < count($ips); $i++) {
if (!eregi (“^(10|172.16|192.168).”, $ips[$i])) {
$ip = $ips[$i];
break;
}
}
}
return ($ip ? $ip : $_SERVER[‘REMOTE_ADDR’]);
}

<?php
if(getenv(‘HTTP_CLIENT_IP’)) {
$onlineip = getenv(‘HTTP_CLIENT_IP’);
} elseif(getenv(‘HTTP_X_FORWARDED_FOR’)) {
$onlineip = getenv(‘HTTP_X_FORWARDED_FOR’);
} elseif(getenv(‘REMOTE_ADDR’)) {
$onlineip = getenv(‘REMOTE_ADDR’);
} else {
$onlineip = $HTTP_SERVER_VARS[‘REMOTE_ADDR’];
}
echo $onlineip;
?>

<?php
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 = “Unknown”;
}
echo “你的IP:”.$ip ;
?>

<?php
$iipp=$_SERVER[“REMOTE_ADDR”];
echo $iipp;
?>[/code][code]<?php
$user_IP = ($_SERVER[“HTTP_VIA”]) ? $_SERVER[“HTTP_X_FORWARDED_FOR”] : $_SERVER[“REMOTE_ADDR”];
$user_IP = ($user_IP) ? $user_IP : $_SERVER[“REMOTE_ADDR”];

发表评论

电子邮件地址不会被公开。 必填项已用*标注