本文整理汇总了PHP中getIP函数的典型用法代码示例。如果您正苦于以下问题:PHP getIP函数的具体用法?PHP getIP怎么用?PHP getIP使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getIP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: locate
function locate($ip = null)
{
global $_SERVER;
if (is_null($ip)) {
$ip = getIP();
}
$host = str_replace('{IP}', $ip, $this->host);
$host = str_replace('{CURRENCY}', $this->currency, $host);
$data = array();
$response = $this->fetch($host);
$data = unserialize($response);
//set the geoPlugin vars
$this->ip = $ip;
$this->city = array_key_exists('geoplugin_city', $data) ? $data['geoplugin_city'] : 'N/A';
$this->region = array_key_exists('geoplugin_region', $data) ? $data['geoplugin_region'] : 'N/A';
$this->regionCode = array_key_exists('geoplugin_regionCode', $data) ? $data['geoplugin_regionCode'] : 'N/A';
$this->areaCode = array_key_exists('geoplugin_areaCode', $data) ? $data['geoplugin_areaCode'] : 'N/A';
$this->dmaCode = array_key_exists('geoplugin_dmaCode', $data) ? $data['geoplugin_dmaCode'] : 'N/A';
$this->countryCode = array_key_exists('geoplugin_countryCode', $data) ? $data['geoplugin_countryCode'] : 'N/A';
$this->countryName = array_key_exists('geoplugin_countryName', $data) ? $data['geoplugin_countryName'] : 'N/A';
$this->continentCode = array_key_exists('geoplugin_continentCode', $data) ? $data['geoplugin_continentCode'] : 'N/A';
$this->latitude = array_key_exists('geoplugin_latitude', $data) ? $data['geoplugin_latitude'] : 'N/A';
$this->longitude = array_key_exists('geoplugin_longitude', $data) ? $data['geoplugin_longitude'] : 'N/A';
$this->currencyCode = array_key_exists('geoplugin_currencyCode', $data) ? $data['geoplugin_currencyCode'] : 'N/A';
$this->currencySymbol = array_key_exists('geoplugin_currencySymbol', $data) ? $data['geoplugin_currencySymbol'] : 'N/A';
$this->currencyConverter = array_key_exists('geoplugin_currencyConverter', $data) ? $data['geoplugin_currencyConverter'] : 'N/A';
}
示例2: isAllowedIP
function isAllowedIP()
{
if (in_array(getIP(), _get("allowIP"))) {
return true;
}
return false;
}
示例3: login
/**
* [login description]
* @return [type] [description]
*/
function login()
{
$name = $_REQUEST["name"];
$password = $_REQUEST["password"];
global $mysql, $prefix;
$password = md5($prefix . $password);
$user = $mysql->DBGetOneRow("`user`", "*", "`name` = '{$name}' and `isDeleted` = 'false' ");
if ($user["name"] == $name && $user["password"] == $password) {
$sessionId = session_id();
$userName = $user["name"];
$_SESSION["name"] = $userName;
$_SESSION["realname"] = $user["realname"];
$_SESSION["password"] = $user["password"];
$_SESSION["level"] = $user["level"];
$_SESSION["phone"] = $user["phone"];
$_SESSION["mail"] = $user["mail"];
$ip = getIP();
$userAgent = $_SERVER['HTTP_USER_AGENT'];
//update
$mysql->DBUpdate('online_user', array('lastUpdateTime' => 'now()', 'offlineTime' => 'now()'), "`userName` = '?' and `offlineTime` is null ", array($userName));
$obj = array('userName' => $name, 'onlineTime' => 'now()', 'sessionId' => $sessionId, 'lastUpdateTime' => 'now()', 'ip' => $ip, 'userAgent' => $userAgent);
$mysql->DBInsertAsArray("`online_user`", $obj);
return array('status' => 'successful', 'errMsg' => '', 'token' => $sessionId);
}
throw new Exception('用户或密码不正确!');
}
示例4: getOnlineUsers
function getOnlineUsers()
{
global $Load;
$Db = $Load->core("Db");
$date = time();
$time = 10;
$time = $date - $time * 60;
$IP = getIP();
$user = SESSION("ZanUser");
$Db->deleteBySQL("Start_Date < {$time}", "users_online_anonymous");
$Db->deleteBySQL("Start_Date < {$time}", "users_online");
if ($user) {
$users = $Db->findBy("User", $user, "users_online");
if (!$users) {
$Db->insert("users_online", array("User" => $user, "Start_Date" => $date));
} else {
$Db->updateBySQL("users_online", "Start_Date = '{$date}' WHERE User = '{$user}'");
}
} else {
$users = $Db->findBy("IP", $IP, "users_online_anonymous");
if (!$users) {
$Db->insert("users_online_anonymous", array("IP" => $IP, "Start_Date" => $date));
} else {
$Db->updateBySQL("users_online", "Start_Date = '{$date}' WHERE IP = '{$IP}'");
}
}
}
示例5: checkLogin
function checkLogin()
{
global $db;
$m_name = be("post", "m_name");
$m_name = chkSql($m_name, true);
$m_password = be("post", "m_password");
$m_password = chkSql($m_password, true);
$m_password = md5($m_password);
$m_check = be("post", "m_check");
if (isN($m_name) || isN($m_password) || isN($m_check)) {
alertUrl("请输入您的用户名或密码!", "?action=login");
}
$row = $db->getRow("SELECT * FROM {pre}manager WHERE m_name='" . $m_name . "' AND m_password = '" . $m_password . "' AND m_status=1");
if ($row && $m_check == app_safecode) {
sCookie("adminid", $row["m_id"]);
sCookie("adminname", $row["m_name"]);
sCookie("adminlevels", $row["m_levels"]);
$randnum = md5(rand(1, 99999999));
sCookie("admincheck", md5($randnum . $row["m_name"] . $row["m_id"]));
$db->Update("{pre}manager", array("m_logintime", "m_loginip", "m_random"), array(date("Y-m-d H:i:s"), getIP(), $randnum), " m_id=" . $row["m_id"]);
echo "<script>top.location.href='index.php';</script>";
} else {
alertUrl("您输入的用户名和密码不正确或者您不是系统管理员!", "?action=login");
}
}
示例6: load
public static function load()
{
global $app;
//IP判断=====================================
$onlineip = getIP();
$ipCity = new IpLocation(INCLUDE_DIR . 'ipdata/QQWry.Dat');
$uCity = $ipCity->getlocation($onlineip);
try {
if (strcmp(trim($uCity['country']), '北京市') != 0) {
throw new Exception('对不起您的IP不符合要求');
}
} catch (Exception $e) {
$app->error($e->getMessage(), SITE_URL);
}
//===========================================
if (isset($_SESSION[self::SESSION_KEY]) && isset($_SESSION[self::SESSION_KEY]['username'])) {
if (isset($_SESSION[self::SESSION_KEY]['record'])) {
$user = $_SESSION[self::SESSION_KEY]['record'];
} else {
$user = new User('username', $_SESSION[self::SESSION_KEY]['username']);
}
} else {
if (isset($_COOKIE[self::COOKIE_KEY])) {
$user = self::checkCookie($_COOKIE[self::COOKIE_KEY]);
} else {
return false;
}
}
if (!$user) {
return self::logout();
}
self::setInfos($user);
return true;
}
示例7: logUserAction
function logUserAction()
{
$command = "--";
if (isset($_POST['command'])) {
$command = strtolower($_POST['command']);
}
if ($command == 'user_login' || $command == 'user_logout' || $command == 'new_comment' || $command == 'rate_comment' || $command == 'register_new_user' || $command == 'update_page_rating' || $command == 'add_tag' || $command == 'rate_tag' || $command == 'delete_tag' || $command == 'get_pages_with_tag' || $command == 'follow_contact' || $command == 'unfollow_contact' || $command == 'add_link' || $command == 'rate_link') {
$IP = getIP();
$user_id = -1;
if (isset($_SESSION['user_id'])) {
$user_id = $_SESSION['user_id'];
} else {
if (isset($_POST['user_name'])) {
$user_name = $_POST['user_name'];
$query = "SELECT id FROM User WHERE name = '" . $user_name . "'";
$result = mysql_query($query);
if (mysql_num_rows($result) != 0) {
$result_row = mysql_fetch_assoc($result);
$user_id = $result_row['id'];
}
}
}
$country = IPtoCountry($IP);
$query = "INSERT INTO ActivityLog (user_id, command, ip, country_code2) VALUE ('{$user_id}', '{$command}', '{$IP}', '{$country}')";
$result = mysql_query($query);
}
}
示例8: __construct
public function __construct()
{
global $canonical;
$this->pageNum = $canonical->currentPage;
$this->comList = array();
$this->aID = $this->listBlocked = false;
$this->totalCom = 0;
$this->myIP = getIP();
}
示例9: isBlockedIp
public function isBlockedIp($zoneID)
{
$ip = getIP();
$cacheKey = "BlockIP_{$zoneID}_{$ip}";
if (RedisHelper::hExist($cacheKey, 1)) {
return true;
}
return false;
}
示例10: get_user
function get_user($where)
{
$sql = $this->table($this->table)->where($where)->limit(1)->create_query();
$row = $this->query($sql)->fetchrow();
if (count($row) > 0) {
$id = $row[0]['user_id'];
$dt = array('user_lastlogin' => date("Y-m-d H:i:d"), 'user_lastloginip' => getIP());
$update = $this->update($this->table, $dt, 'user_id = ' . $id);
}
return $row;
}
示例11: tools
public function tools($param)
{
$tid = $param['tid'];
$ttype = $param['ttype'];
$title = $param['title'];
$contents = $param['contents'];
$old_data = $param['old_data'];
$nickname = $_SESSION[$this->config->item('rbac_auth_key')]["INFO"]["nickname"];
$sql = "INSERT INTO system_tools_log (tid,ttype,title,contents,auser,aip,old_data)\n\t\t\t\tVALUES('{$tid}','{$ttype}','{$title}','{$contents}','{$nickname}','" . getIP() . "','{$old_data}')\n\t\t\t\t";
$this->db->query($sql);
}
示例12: ExceedGuests
function ExceedGuests()
{
// ENTER MYSQL AND INSERT IP AND RANDOM ID IN TABLE
// THEN SEND TO QUEUE LIST
$IP = getIP();
$insert = "INSERT INTO QueueList({$IP}), VALUES (?)";
if ($connection->query($insert) === TRUE) {
// successful
} else {
echo "Error";
}
}
示例13: actionInstall
public function actionInstall()
{
$languages = get_all_langs();
$language = isset($_GET['l']) && in_array($_GET['l'], $languages) ? $_GET['l'] : 'en';
$installed = FALSE;
$tips = array();
if (!file_exists(CONFIGFILE)) {
// Check the configuration file permissions
$tips[] = t('CONFIG_FILE_NOTEXISTS', array('{config_file}' => CONFIGFILE), $language);
} elseif (!is_writable(CONFIGFILE)) {
$tips[] = t('CONFIG_FILE_NOTWRITABLE', array('{config_file}' => CONFIGFILE), $language);
}
if (!is_writable(APPROOT . '/data/')) {
$tips[] = t('DATADIR_NOT_WRITABLE', array(), $language);
}
if (isset($_POST['dbtype'])) {
if (!empty($_POST['adminname']) && !empty($_POST['adminpass']) && !empty($_POST['dbtype']) && !empty($_POST['dbusername']) && !empty($_POST['dbname']) && !empty($_POST['dbhost']) && strlen(trim($_POST['adminname'])) > 2) {
$adminname = maple_quotes($_POST['adminname']);
$adminpass = maple_quotes($_POST['adminpass']);
$dbname = maple_quotes($_POST['dbname']);
$tbprefix = $_POST['tbprefix'];
$url = $_POST['dbtype'] . '://' . $_POST['dbusername'] . ':' . $_POST['dbpwd'] . '@' . $_POST['dbhost'] . '/' . $_POST['dbname'];
#$db=YDB::factory($url);
$formError = '';
try {
$db = YDB::factory($url);
} catch (Exception $e) {
$formError = $e->getMessage();
}
} else {
$formError = t('FILL_NOT_COMPLETE', array(), $language);
}
if (!$formError) {
$url_string = "<?php\n\$db_url = '{$url}';\n\$db_prefix = '{$tbprefix}';\n?>";
file_put_contents(CONFIGFILE, $url_string);
$sql_file = APPROOT . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . $_POST['dbtype'] . '.sql';
$sql_array = file($sql_file);
$translate = array('{time}' => time(), '{ip}' => getIP(), '{admin}' => $adminname, '{adminpass}' => $adminpass, '{lang}' => $language, '<' => $tbprefix, '>' => '');
foreach ($sql_array as $sql) {
$_sql = html_entity_decode(strtr(trim($sql), $translate), ENT_COMPAT, 'UTF-8');
$db->query($_sql);
}
$installed = TRUE;
$_SESSION['admin'] = $_POST['adminname'];
}
}
if (file_exists(dirname(dirname(__FILE__)) . '/install.php')) {
include dirname(dirname(__FILE__)) . '/install.php';
} else {
die('Access denied!');
}
}
示例14: interdilpsRequestorAllowed
/**
* Checks whether the requesting ip is a known dilps system and is allowed access to this system
*
* @return boolean
*/
function interdilpsRequestorAllowed()
{
global $config;
require_once "{$config['includepath']}db.inc.php";
global $db, $db_prefix;
$ip = getIP();
$allowed = false;
$sql = "select access from {$db_prefix}interdilps_hosts where ip = " . $db->qstr($ip) . " and access > 0";
if ($access = $db->GetOne($sql)) {
$allowed = true;
}
return $allowed;
}
示例15: FileLog
/**
* 文件日志
* Enter description here ...
* @param unknown_type $content
* @param unknown_type $file
* @param unknown_type $rank
*/
public static function FileLog($content, $file = NULL, $rank = 0)
{
$filename = date("Y-m-d");
$file ? $file = AppDir . "/Runtime/Log/" . $file . ".log" : ($file = AppDir . "/Runtime/Log/" . $filename . ".log");
try {
if ($f = fopen($file, "a+")) {
$content = "服务器时间:[" . date("Y-m-d H:i:s") . "] 等级:" . $rank . " 日志内容如下:\r\n" . $content . " \r\n网址来源:http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . " 来源IP:" . getIP() . "\r\n----------------------------------------------------------------------------------\r\n";
return fwrite($f, $content);
} else {
return false;
}
} catch (Exception $es) {
throw $es->getMessage();
}
}