本文整理汇总了PHP中getUserIP函数的典型用法代码示例。如果您正苦于以下问题:PHP getUserIP函数的具体用法?PHP getUserIP怎么用?PHP getUserIP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getUserIP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class instantiator
*
* @return captcha
*/
function __construct()
{
global $plugin_is_filter;
if (OFFSET_PATH == 2) {
setOptionDefault('zenphoto_captcha_length', 5);
setOptionDefault('zenphoto_captcha_font_size', 18);
setOptionDefault('zenphoto_captcha_key', sha1($_SERVER['HTTP_HOST'] . 'a9606420399a77387af2a4b541414ee5' . getUserIP()));
setOptionDefault('zenphoto_captcha_string', 'abcdefghijkmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWXYZ');
}
}
示例2: handler
/**
*
* Logs User searches
* @param array $search_statistics the search criteria
* @param string $type 'album', 'image', etc.
* @param bool $success did the search return a result
* @param bool $dynamic was it from a dynamic album
* @param int $iteration count of the filters since the search engine instantiation
*/
static function handler($search_statistics, $type, $success, $dynamic, $iteration)
{
if (!$dynamic) {
// log unique user searches
$store = array('type' => $type, 'success' => $success, 'iteration' => $iteration, 'data' => $search_statistics);
$sql = 'INSERT INTO ' . prefix('plugin_storage') . ' (`type`, `aux`,`data`) VALUES ("search_statistics", ' . db_quote(getUserIP()) . ',' . db_quote(serialize($store)) . ')';
query($sql);
}
return $search_statistics;
}
示例3: example_comment_form_defaults
/**
* Adds default values to comment form data
*
* NOTE: the indices available are:
* 'name'
* 'website'
* 'anon'
* 'street'
* 'city'
* 'state'
* 'country'
* 'postal'
* 'private'
*
* @param array $defaults
*/
function example_comment_form_defaults($defaults)
{
// set the web field to the browser IP if it is not otherwise set.
if (empty($defaults['data']['website'])) {
$defaults['data']['website'] = 'http://' . getUserIP();
}
// disable the anonymous and private checkboxes (could also reset the options, but this is an example after all!)
$defaults['data']['anon'] = 0;
$defaults['disabled']['anon'] = ' disabled="disabled"';
$defaults['data']['private'] = 0;
$defaults['disabled']['private'] = ' disabled="disabled"';
return $defaults;
}
示例4: login
/**
* Login
* @return bool
*/
public function login()
{
if ($this->_identity === null) {
$this->_identity = new UserIdentity($this->username, $this->password);
$this->_identity->authenticate();
}
if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
$duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
// 30 days
if (($user = $this->user) !== null) {
$user->saveAttributes(array('login_time' => $user->login_time + 1, 'login_ip' => getUserIP(), 'login_attempts' => NULL));
}
Yii::app()->user->login($this->_identity, $duration);
return true;
}
}
示例5: checkIPBlock
/**
* Check the user IP if we need to ban him
*/
protected function checkIPBlock()
{
// array's of banned IP addresses
$bannedIPS = getParam('ban_ips');
$userIP = getUserIP();
$blockedAddresses = explode("\n", $bannedIPS);
$redirectTo = getParam('ban_ips_redirect_url');
// Check every ip address
if ($bannedIPS && is_array($blockedAddresses) && count($blockedAddresses)) {
if (in_array($userIP, $blockedAddresses)) {
// this is for exact matches of IP address in array
header("Location: " . $redirectTo);
exit;
} else {
// this is for wild card matches
foreach ($blockedAddresses as $ip) {
if (preg_match('~' . $ip . '~', $userIP)) {
header("Location: " . $redirectTo);
exit;
}
}
}
}
}
示例6: security_logger_log_setup
/**
* Logs setup actions
* @param bool $success
* @param string $action
* @param string $file
*/
function security_logger_log_setup($success, $action, $txt)
{
list($user, $name) = security_logger_populate_user();
security_logger_loginLogger($success, $user, $name, getUserIP(), $action, 'zp_admin_auth', $txt);
return $success;
}
示例7: handleOption
function handleOption($option, $currentValue)
{
switch ($option) {
case 'hitcounter_set_defaults':
?>
<script language="javascript" type="text/javascript">
// <!-- <![CDATA[
function hitcounter_defaults() {
$('#hitcounter_ignoreIPList').val('');
$('#hitcounter_ip_button').removeAttr('disabled');
$('#hitcounter_ignoreIPList_enable').removeAttr('checked');
$('#hitcounter_ignoreSearchCrawlers_enable').removeAttr('checked');
$('#hitcounter_searchCrawlerList').val('<?php
echo $this->defaultbots;
?>
');
}
// ]]> -->
</script>
<label><input id="hitcounter_reset_button" type="button" value="<?php
echo gettext('Defaults');
?>
" onclick="hitcounter_defaults();" /></label>
<?php
break;
case 'hitcounter_ignoreIPList':
?>
<input type="hidden" name="<?php
echo CUSTOM_OPTION_PREFIX;
?>
'text-hitcounter_ignoreIPList" value="0" />
<input type="text" size="30" id="hitcounter_ignoreIPList" name="hitcounter_ignoreIPList" value="<?php
echo html_encode($currentValue);
?>
" />
<script language="javascript" type="text/javascript">
// <!-- <![CDATA[
function hitcounter_insertIP() {
if ($('#hitcounter_ignoreIPList').val() == '') {
$('#hitcounter_ignoreIPList').val('<?php
echo getUserIP();
?>
');
} else {
$('#hitcounter_ignoreIPList').val($('#hitcounter_ignoreIPList').val()+',<?php
echo getUserIP();
?>
');
}
$('#hitcounter_ip_button').attr('disabled','disabled');
}
jQuery(window).load(function(){
var current = $('#hitcounter_ignoreIPList').val();
if (current.indexOf('<?php
echo getUserIP();
?>
') < 0) {
$('#hitcounter_ip_button').removeAttr('disabled');
}
});
// ]]> -->
</script>
<label><input id="hitcounter_ip_button" type="button" value="<?php
echo gettext('Insert my IP');
?>
" onclick="hitcounter_insertIP();" disabled="disabled" /></label>
<?php
break;
}
}
示例8: mysql_real_escape_string
$_SESSION['userid'] = $lologin4['ids'];
$_SESSION['username'] = $lologin4['username'];
$_SESSION['status'] = $lologin4['status'];
$_SESSION['team'] = $lologin4['team'];
$_SESSION['readSticky'] = $lologin4['readSticky'];
$_SESSION['acceptedRules'] = $lologin4['acceptedRules'];
$_SESSION['hasLicense'] = $lologin4['hasLicense'];
$_SESSION['transferGesperrt'] = FALSE;
$_SESSION['last_forumneu_anzahl'] = 0;
// LOGIN-LOG ANFANG
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$loginLog_userAgent = mysql_real_escape_string(trim(strip_tags($_SERVER['HTTP_USER_AGENT'])));
} else {
$loginLog_userAgent = '';
}
$loginLog_ip = getUserIP();
if (isset($_COOKIE['uniqueHash'])) {
$loginLog_uniqueHash = mysql_real_escape_string(trim(strip_tags($_COOKIE['uniqueHash'])));
} else {
$loginLog_uniqueHash = $loginLog_ip;
setcookie('uniqueHash', $loginLog_ip, getTimestamp('+30 days'), '/', str_replace('www.', '.', CONFIG_SITE_DOMAIN), FALSE, TRUE);
}
if (!in_array($lologin4['ids'], unserialize(CONFIG_PROTECTED_USERS))) {
$loginLog1 = "INSERT INTO " . $prefix . "loginLog (user, zeit, ip, userAgent, uniqueHash) VALUES ('" . $lologin4['ids'] . "', " . time() . ", '" . $loginLog_ip . "', '" . $loginLog_userAgent . "', '" . $loginLog_uniqueHash . "')";
$loginLog2 = mysql_query($loginLog1);
}
// LOGIN-LOG ENDE
// MAXIMALGEBOT ANFANG
$tageHier = (time() - $lologin4['regdate']) / 86400;
if ($tageHier < 0.08) {
$_SESSION['pMaxGebot'] = 0;
示例9: mysql_query
$sql2 = mysql_query($sql1);
} else {
$sql1 = "UPDATE " . $prefix . "users SET last_login = 1, last_urlaub_kurz = 0, last_urlaub_lang = 0, last_uagent = '', infotext = '', username = CONCAT('GELOESCHT', id) WHERE ids = '" . $cookie_id . "'";
$sql2 = mysql_query($sql1);
}
$sql11 = "DELETE FROM " . $prefix . "pn WHERE von = '" . $cookie_id . "' OR an = '" . $cookie_id . "'";
$sql12 = mysql_query($sql11);
$sql11 = "DELETE FROM " . $prefix . "freunde WHERE f1 = '" . $cookie_id . "' OR f2 = '" . $cookie_id . "'";
$sql12 = mysql_query($sql11);
$sql11 = "DELETE FROM " . $prefix . "freunde_anfragen WHERE von = '" . $cookie_id . "' OR an = '" . $cookie_id . "'";
$sql12 = mysql_query($sql11);
$howLong1 = "SELECT regdate FROM " . $prefix . "users WHERE ids = '" . $cookie_id . "'";
$howLong2 = mysql_query($howLong1);
if (mysql_num_rows($howLong2) == 1) {
$howLong3 = mysql_fetch_assoc($howLong2);
$wielange1 = "INSERT INTO " . $prefix . "abmeldungen (zeit, username, liga, dabei, ip) VALUES (" . time() . ", '" . $cookie_username . "', '" . $cookie_liga . "', " . intval(time() - $howLong3['regdate']) . ", '" . getUserIP() . "')";
$wielange2 = mysql_query($wielange1);
}
header('Location: /logout.php');
exit;
}
$get_urlaub1 = "SELECT urlaub, email FROM " . $prefix . "users WHERE ids = '" . $cookie_id . "'";
$get_urlaub2 = mysql_query($get_urlaub1);
$get_urlaub3 = mysql_fetch_assoc($get_urlaub2);
$noch_urlaub = $get_urlaub3['urlaub'];
$mailAdresse = $get_urlaub3['email'];
$get_urlaub4 = "SELECT ende FROM " . $prefix . "urlaub WHERE user = '" . $cookie_id . "'";
$get_urlaub5 = mysql_query($get_urlaub4);
if (mysql_num_rows($get_urlaub5) > 0) {
$get_urlaub6 = mysql_fetch_assoc($get_urlaub5);
if ($get_urlaub6['ende'] > time()) {
示例10: zp_cookieEncode
/**
*
* Encodes a cookie value tying it to the user IP
* @param $value
*/
function zp_cookieEncode($value)
{
if (IP_TIED_COOKIES) {
return rc4(getUserIP() . HASH_SEED, $value);
} else {
return $value;
}
}
示例11: str_replace
<?php
@session_set_cookie_params(3600 * 24 * 14, '/', str_replace('www.', '.', CONFIG_SITE_DOMAIN), false, true);
@session_start();
if (isset($_SESSION['loggedin']) and $_SESSION['loggedin'] == 1) {
$loggedin = $_SESSION['loggedin'];
$cookie_id = $_SESSION['userid'];
$cookie_username = $_SESSION['username'];
$cookie_liga = $_SESSION['liga'];
$cookie_team = $_SESSION['team'];
$cookie_teamname = $_SESSION['teamname'];
$cookie_scout = $_SESSION['scout'];
if (mt_rand(1, 3) == 2) {
// nur bei jedem dritten Seitenaufruf
$last_login1 = "UPDATE " . $prefix . "users SET verwarnt = 0, last_login = " . time();
$last_login1 .= ", last_ip = '" . getUserIP() . "'";
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$last_login1 .= ", last_uagent = '" . mysql_real_escape_string(trim(strip_tags($_SERVER['HTTP_USER_AGENT']))) . "'";
}
if (isset($_COOKIE['uniqueHash'])) {
$last_login1 .= ", last_uniqueHash = '" . mysql_real_escape_string(trim(strip_tags($_COOKIE['uniqueHash']))) . "'";
}
$last_login1 .= " WHERE ids = '" . $cookie_id . "'";
$last_login2 = mysql_query($last_login1);
}
} else {
$loggedin = 0;
$cookie_id = '';
$cookie_username = '';
$cookie_liga = '';
$cookie_team = '';
示例12: reportError
function reportError($error = "")
{
global $mail;
global $appname;
// generating message
$message = "An error happened in " . $appname . ":";
$message .= "\n\nTime..... " . date("d.m.Y-H:i", time());
$message .= "\nIP....... http://www.utrace.de/?query=" . getUserIP();
$message .= "\nHeader... " . $_SERVER['HTTP_USER_AGENT'];
$message .= "\nError.... " . $error;
// sending error report by mail to given mail address
$sended = mail($mail, "Error Report " . $appname, $message, "From: " . $appname . " <" . $mail . ">");
// check if mail was being send
if (!$sended) {
return false;
}
return true;
}
示例13: beforeValidate
/**
* Makes sure usernames are lowercase
* (emails by standard can have uppercase letters)
* @return parent::beforeValidate
*/
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->create_time = new CDbExpression('NOW()');
$this->activation_key = $this->generate_activation_key();
}
$this->update_time = new CDbExpression('NOW()');
$this->login_ip = getUserIP();
if (!empty($this->username)) {
$this->username = strtolower($this->username);
}
return parent::beforeValidate();
}
示例14: guestLoginLogger
/**
* Logs an attempt for a guest user to log onto the site
* Returns the "success" parameter.
*
* @param bool $success
* @param string $user
* @param string $pass
* @param string $athority what kind of login
* @return bool
*/
function guestLoginLogger($success, $user, $pass, $athority)
{
loginLogger($success, $user, $pass, '', getUserIP(), 'frontend', $athority);
return $success;
}
示例15: load_script
/**
*
* Counts the hitcounter for the page/object
* @param string $script
* @param bool $valid will be false if the object is not found (e.g. there will be a 404 error);
* @return string
*/
static function load_script($script, $valid)
{
if ($script && $valid) {
if (getOption('hitcounter_ignoreIPList_enable')) {
$ignoreIPAddressList = explode(',', str_replace(' ', '', getOption('hitcounter_ignoreIPList')));
$skip = in_array(getUserIP(), $ignoreIPAddressList);
} else {
$skip = false;
}
if (getOption('hitcounter_ignoreSearchCrawlers_enable') && !$skip && array_key_exists('HTTP_USER_AGENT', $_SERVER) && ($agent = $_SERVER['HTTP_USER_AGENT'])) {
$botList = explode(',', getOption('hitcounter_searchCrawlerList'));
foreach ($botList as $bot) {
if (stripos($agent, trim($bot))) {
$skip = true;
break;
}
}
}
if (!$skip) {
global $_zp_gallery_page, $_zp_current_album, $_zp_current_image, $_zp_current_article, $_zp_current_page, $_zp_current_category;
if (checkAccess()) {
// count only if permitted to access
switch ($_zp_gallery_page) {
case 'album.php':
if (!$_zp_current_album->isMyItem(ALBUM_RIGHTS) && getCurrentPage() == 1) {
$_zp_current_album->countHit();
}
break;
case 'image.php':
if (!$_zp_current_album->isMyItem(ALBUM_RIGHTS)) {
//update hit counter
$_zp_current_image->countHit();
}
break;
case 'pages.php':
if (class_exists('CMS') && !zp_loggedin(ZENPAGE_PAGES_RIGHTS)) {
$_zp_current_page->countHit();
}
break;
case 'news.php':
if (class_exists('CMS') && !zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
if (is_NewsArticle()) {
$_zp_current_article->countHit();
} else {
if (is_NewsCategory()) {
$_zp_current_category->countHit();
}
}
}
break;
default:
if (!zp_loggedin()) {
$page = stripSuffix($_zp_gallery_page);
setOption('Page-Hitcounter-' . $page, getOption('Page-Hitcounter-' . $page) + 1);
}
break;
}
}
}
}
return $script;
}