当前位置: 首页>>代码示例>>PHP>>正文


PHP get_remote_addr函数代码示例

本文整理汇总了PHP中get_remote_addr函数的典型用法代码示例。如果您正苦于以下问题:PHP get_remote_addr函数的具体用法?PHP get_remote_addr怎么用?PHP get_remote_addr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_remote_addr函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_get_remote_addr

 /**
  * @covers ::get_remote_addr
  */
 function test_get_remote_addr()
 {
     $this->assertEmpty(get_remote_addr());
     $_SERVER = ['REMOTE_ADDR' => '10.0.0.2'];
     $this->assertEquals('10.0.0.2', get_remote_addr());
     $_SERVER += ['HTTP_X_FORWARDED_FOR' => '10.0.0.3', 'HTTP_CLIENT_IP' => '10.0.0.4'];
     $this->assertEquals('10.0.0.3', get_remote_addr(), "HTTP_X_FORWARDED_FOR must be prioritized.");
 }
开发者ID:keruald,项目名称:globalfunctions,代码行数:11,代码来源:coreTest.php

示例2: kotoba_session_start

require_once Config::ABS_PATH . '/lib/misc.php';
require_once Config::ABS_PATH . '/lib/db.php';
require_once Config::ABS_PATH . '/lib/errors.php';
require_once Config::ABS_PATH . '/lib/logging.php';
require_once Config::ABS_PATH . '/lib/exceptions.php';
try {
    // Initialization.
    kotoba_session_start();
    if (Config::LANGUAGE != $_SESSION['language']) {
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/messages.php";
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/logging.php";
    }
    locale_setup();
    $smarty = new SmartyKotobaSetup();
    // Check if client banned.
    if (($ban = bans_check(get_remote_addr())) !== FALSE) {
        // Cleanup.
        DataExchange::releaseResources();
        $smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
        $smarty->assign('reason', $ban['reason']);
        $smarty->display('banned.tpl');
        session_destroy();
        exit(1);
    }
    // Check permission and write message to log file.
    if (!is_admin()) {
        // Cleanup.
        DataExchange::releaseResources();
        display_error_page($smarty, new NotAdminError());
        exit(1);
    }
开发者ID:jellycucmber,项目名称:kotoba-ib,代码行数:31,代码来源:edit_user_groups.php

示例3: ini_set

ini_set('session.gc_probability', 1);
// Garbage Collection
ini_set('session.gc_maxlifetime', 3600);
// max session time
ini_set('session.cookie_lifetime', 0);
// cookie last browser session
ini_set('session.auto_start', 0);
// don't auto start sessions
// how long a session can be inactive
define('SESS_MAXLIFE', 3600);
// {nocache|private|publuc|private_no_cache}
session_cache_limiter('none');
// if we should check IPADDR along with SESSID for enhanced security?
define('SESS_IPCHECK', true);
// get the remote IPADDR
define('SESS_REMOTE_ADDR', get_remote_addr());
// database link needs to be initialized
$MY_DBH = null;
// make use of persistent database connections?
define('DB_PCONNECT', false);
// user call-back functions for session events
session_set_save_handler('_sess_mysql_open', '_sess_mysql_close', '_sess_mysql_read', '_sess_mysql_write', '_sess_mysql_destroy', '_sess_mysql_gc');
// Kick it, lets get this party started
session_start();
// load request data class
require_once $base_dir . 'includes/initrequests.php';
require_once $base_dir . 'includes/request.class.php';
// load theme layout class
require_once $base_dir . 'themes/' . THEME . '/block.class.php';
// register globals work around, I don't like this and am working
// to get rid of it...
开发者ID:jgatica,项目名称:Netoffice,代码行数:31,代码来源:library.php


注:本文中的get_remote_addr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。