本文整理汇总了PHP中getIP函数的典型用法代码示例。如果您正苦于以下问题:PHP getIP函数的具体用法?PHP getIP怎么用?PHP getIP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getIP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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';
}
开发者ID:BersnardC,项目名称:DROPINN,代码行数:27,代码来源:geoplugin.class.php
示例2: isAllowedIP
function isAllowedIP()
{
if (in_array(getIP(), _get("allowIP"))) {
return true;
}
return false;
}
开发者ID:jgianpiere,项目名称:ZanPHP,代码行数:7,代码来源:security.php
示例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('用户或密码不正确!');
}
开发者ID:hxghxg527,项目名称:FamilyDecoration,代码行数:30,代码来源:userDB.php
示例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}'");
}
}
}
开发者ID:no2key,项目名称:MuuCMS,代码行数:27,代码来源:users.php
示例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");
}
}
开发者ID:andyongithub,项目名称:joyplus-cms,代码行数:25,代码来源:index.php
示例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;
}
开发者ID:chaobj001,项目名称:tt,代码行数:34,代码来源:AuthUser.class.php
示例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);
}
}
开发者ID:qing3gan,项目名称:socialcobs,代码行数:27,代码来源:ip_to_country.php
示例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();
}
开发者ID:bo-blog,项目名称:bw,代码行数:9,代码来源:comment.inc.php
示例9: isBlockedIp
public function isBlockedIp($zoneID)
{
$ip = getIP();
$cacheKey = "BlockIP_{$zoneID}_{$ip}";
if (RedisHelper::hExist($cacheKey, 1)) {
return true;
}
return false;
}
开发者ID:huycao,项目名称:yodelivery,代码行数:9,代码来源:Tracking.php
示例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;
}
开发者ID:cyberorca,项目名称:dfp-api,代码行数:11,代码来源:user_model.php
示例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);
}
开发者ID:sdgdsffdsfff,项目名称:PMtools,代码行数:11,代码来源:system_log_model.php
示例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";
}
}
开发者ID:EvanGlazer,项目名称:Web-Platform-Queue-System,代码行数:12,代码来源:QueueCheck.php
示例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!');
}
}
开发者ID:yunsite,项目名称:yuan-pad,代码行数:52,代码来源:SiteController.php
示例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;
}
开发者ID:prometheus-ev,项目名称:promdilps,代码行数:18,代码来源:remote.inc.php
示例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();
}
}
开发者ID:captaim,项目名称:cleverPHP,代码行数:22,代码来源:Log.class.php
示例16: post
/**
* 表单提交
*/
public function post()
{
//$this->load->helper('curl');
$_SESSION['token'] = session_id();
$ret = 0;
$msg = '';
$this->db->trans_start();
try {
$name = isset($_REQUEST['name']) ? trim(strip_tags($_REQUEST['name'])) : null;
$tel = isset($_REQUEST['tel']) ? trim(strip_tags($_REQUEST['tel'])) : null;
$address = isset($_REQUEST['address']) ? trim(strip_tags($_REQUEST['address'])) : null;
$type = isset($_REQUEST['type']) ? trim(strip_tags($_REQUEST['type'])) : null;
if (empty($name)) {
$ret = 1001;
$msg = 'name 不能为空~';
} elseif (empty($tel)) {
$ret = 1002;
$msg = 'tel 不能为空~';
} elseif (empty($address)) {
$ret = 1003;
$msg = 'address 不能为空~';
} elseif (empty($type)) {
$ret = 1004;
$msg = 'type 不能为空~';
} else {
$data = array('name' => $name, 'tel' => $tel, 'address' => $address, 'type' => $type, 'create_ip' => getIP(), 'create_time' => date('Y-m-d H:i:s'));
$this->db->insert('love2015_user', $data);
}
/*
$this->db->where('phone', $phone);
$count = $this->db->count_all_results('t_user');
if($count < 0){
$ret = 1001;
$msg = '该手机号码已经被申领';
}
else{
}
*/
} catch (Exception $e) {
$ret = 2000;
$msg = $e->getMessage();
}
$this->db->trans_complete();
$result = array('ret' => $ret, 'msg' => $msg);
$this->output->set_content_type('application/json')->set_output(json_encode($result));
}
开发者ID:alexa0503,项目名称:nivea_2015love,代码行数:50,代码来源:index.php
示例17: add_writing
function add_writing($id, &$writing, $user_id)
{
try {
$ip = getIP();
if (!isset($user_id)) {
$user_id = "NULL";
}
date_default_timezone_set('PRC');
$sql = "INSERT INTO\r\n `tomoe_writing`\t(\r\n `char_id`,\r\n `writing`,\r\n `user_id`,\r\n `ip`,\r\n `add_date`)\r\n VALUES(\r\n '" . $id . "',\r\n \t'" . json_encode($writing) . "',\r\n \t" . $user_id . ",\r\n '" . $ip . "',\r\n \t'" . date("Y-m-d H:i:s") . "');";
$result = $this->db->insert($sql);
if ($result == 0) {
throw new Exception("无法添加数据");
}
} catch (Exception $e) {
throw $e;
}
}
开发者ID:tianxang,项目名称:php-handwriting,代码行数:17,代码来源:dictionary.php
示例18: guardarAccion
function guardarAccion($email, $accion)
{
if (isset($_SESSION["codSesion"])) {
$cod = $_SESSION["codSesion"];
usuarioEstaOnline();
} else {
$cod = NULL;
$email = NULL;
}
date_default_timezone_set("Europe/Madrid");
$date = date('Y-m-d H:i:s');
$ip = getIP();
$sql = "INSERT INTO Acciones (cod_conexion,email,accion,time,ip) VALUES ('{$cod}','{$email}','{$accion}','{$date}','{$ip}')";
$link = Conectar();
$link->query($sql);
$link->close();
}
开发者ID:mgarcia223,项目名称:AlbumFotos,代码行数:17,代码来源:funciones.php
示例19: verifyLogin
function verifyLogin()
{
global $configArray;
if (isset($_GET['logout'])) {
unset($_SESSION['userId']);
unset($_SESSION['username']);
unset($_SESSION['userPassword']);
unset($_SESSION['userEmail']);
unset($_SESSION['userType']);
}
if (isset($_POST['login'])) {
$email = $_POST['email'];
$pass = $_POST['pass'];
$loginSql = "SELECT *\n\t\t\t\tFROM conturi_admin c \n\t\t\t\tWHERE c.email = '" . $email . "' AND c.parola = '" . $pass . "' AND c.activ = '1' LIMIT 1";
$_USER = getQueryInArray($loginSql, $configArray['dbcnx']);
//print_r('<!-- qwerty '.$loginSql.' -->');
$isUser = false;
if (!count($_USER)) {
$isUser = false;
} else {
$isUser = true;
}
if ($isUser) {
$insertIntoLog = "INSERT INTO log SET ip = '" . mySqlEscape(getIP()) . "', " . " data = '" . mySqlEscape(date("Y-m-d H:i:s")) . "', " . " query = '" . mySqlEscape($loginSql) . "', " . " id_conturi = '" . mySqlEscape($_USER[0]['id']) . "', " . " obs ='AUTENTIFICARE ADMINISTRATOR' ";
@mysql_query($insertIntoLog);
$_SESSION['userId'] = intval($_USER[0]['id']);
//cont_admin ID
//$_SESSION['userId'] = intval($_USER[0]['user_id']); //conturi ID
$_SESSION['username'] = ucwords(strtolower($_USER[0]['nume'])) . ' ' . ucwords(strtolower($_USER[0]['prenume']));
$_SESSION['userEmail'] = $_USER[0]['email'];
$_SESSION['userType'] = $_USER[0]['cont_tip'];
$_SESSION['userPassword'] = $pass;
}
//endif isUser
if (isset($_POST['backurl'])) {
redirect($_POST['backurl']);
}
}
//endif $_POST['login']
if (!isset($_SESSION['userId']) && (!stristr($_SERVER['SCRIPT_NAME'], 'index.php') && !stristr($_SERVER['SCRIPT_NAME'], 'forgot_pass.php'))) {
redirect('index.php?msg=1&url=' . $_SERVER['REQUEST_URI']);
}
}
开发者ID:createitro,项目名称:hartafreeex,代码行数:43,代码来源:functions.inc.php
示例20: login
public static function login($login, $pw)
{
global $mysql;
$query = "SELECT password FROM peq_admin WHERE login=\"{$login}\"";
$result = $mysql->query_assoc($query);
if ($result == '') {
$_SESSION['error'] = 1;
logSQL("Invalid login attempt. Bad username from IP: '" . getIP() . "'. Username: '{$login}' Password: '{$pw}'.");
return;
}
extract($result);
if ($password == md5($pw)) {
$_SESSION['login'] = $login;
$_SESSION['password'] = md5($pw);
} else {
$_SESSION['error'] = 1;
logSQL("Invalid login attempt. Bad password from IP: '" . getIP() . "'. Username: '{$login}' Password: '{$pw}'.");
}
}
开发者ID:Akkadius,项目名称:EQEmuEOC,代码行数:19,代码来源:session.php
注:本文中的getIP函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论