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


PHP HTTPRequest::getIPAddress方法代码示例

本文整理汇总了PHP中HTTPRequest::getIPAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTPRequest::getIPAddress方法的具体用法?PHP HTTPRequest::getIPAddress怎么用?PHP HTTPRequest::getIPAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTPRequest的用法示例。


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

示例1: logUser

 /**
  * $params['isScript']
  * $params['groupId']
  * $params['time']
  */
 function logUser($params)
 {
     if (!$params['isScript']) {
         $uid = 0;
         $uid = user_getid();
         $request = HTTPRequest::instance();
         $cookie_manager = new CookieManager();
         $userLogManager = new UserLogManager();
         $userLogManager->logAccess($params['time'], $params['groupId'], $uid, $cookie_manager->getCookie('session_hash'), $request->getFromServer('HTTP_USER_AGENT'), $request->getFromServer('REQUEST_METHOD'), $request->getFromServer('REQUEST_URI'), HTTPRequest::getIPAddress(), $request->getFromServer('HTTP_REFERER'));
     }
 }
开发者ID:rinodung,项目名称:tuleap,代码行数:16,代码来源:userlogPlugin.class.php

示例2: __construct

 public function __construct(PFUser $user, Git_HTTP_Command $command)
 {
     parent::__construct();
     $gitolite_user_info = posix_getpwnam('gitolite');
     $this->gitolite_home = $gitolite_user_info['dir'];
     $this->env['SHELL'] = '/bin/sh';
     $this->env['REMOTE_USER'] = $user->getUnixName();
     $this->env['GIT_HTTP_BACKEND'] = $command->getCommand();
     $this->env['HOME'] = $this->gitolite_home;
     $this->env['REMOTE_ADDR'] = HTTPRequest::getIPAddress();
     $this->appendToEnv('REQUEST_URI');
     $this->appendToEnv('REMOTE_PORT');
     $this->appendToEnv('SERVER_ADDR');
     $this->appendToEnv('SERVER_PORT');
 }
开发者ID:rinodung,项目名称:tuleap,代码行数:15,代码来源:CommandGitolite.class.php

示例3: viewvc_utils_passcommand

/**
 * call the viewvc.cgi and echo the parsed output
 */
function viewvc_utils_passcommand()
{
    $parse = viewvc_utils_display_header();
    $request_uri = getStringFromServer('REQUEST_URI');
    //this is very important ...
    if (getStringFromServer('PATH_INFO') == "") {
        $path = "/";
        //echo "no path<br>\n";
    } else {
        $path = getStringFromServer('PATH_INFO');
        // hack: path must always end with /
        if (strrpos($path, "/") != strlen($path) - 1) {
            $path .= "/";
        }
        //echo "path=$path<br>\n";
    }
    // "view=auto" is not well supported in wrapped mode. See SR 341 on Partners.
    $query_string = str_replace("view=auto", "view=markup", viewvc_utils_escape_string_from_server('QUERY_STRING'));
    $command = 'HTTP_COOKIE=' . viewvc_utils_escape_string_from_server('HTTP_COOKIE') . ' ' . 'HTTP_USER_AGENT=' . viewvc_utils_escape_string_from_server('HTTP_USER_AGENT') . ' ' . 'REMOTE_ADDR=' . escapeshellarg(HTTPRequest::getIPAddress()) . ' ' . 'QUERY_STRING=' . $query_string . ' ' . 'SERVER_SOFTWARE=' . viewvc_utils_escape_string_from_server('SERVER_SOFTWARE') . ' ' . 'SCRIPT_NAME=' . viewvc_utils_escape_string_from_server('SCRIPT_NAME') . ' ' . 'HTTP_ACCEPT_ENCODING=' . viewvc_utils_escape_string_from_server('HTTP_ACCEPT_ENCODING') . ' ' . 'HTTP_ACCEPT_LANGUAGE=' . viewvc_utils_escape_string_from_server('HTTP_ACCEPT_LANGUAGE') . ' ' . 'PATH_INFO=' . viewvc_utils_wrap_utf8_file_name($path) . ' ' . 'PATH=' . viewvc_utils_escape_string_from_server('PATH') . ' ' . 'HTTP_HOST=' . viewvc_utils_escape_string_from_server('HTTP_HOST') . ' ' . 'DOCUMENT_ROOT=' . viewvc_utils_escape_string_from_server('DOCUMENT_ROOT') . ' ' . 'CODENDI_LOCAL_INC=' . viewvc_utils_escape_string_from_server('CODENDI_LOCAL_INC') . ' ' . '/var/www/cgi-bin/viewvc.cgi 2>&1';
    $content = viewvc_utils_wrap_utf8_exec($command);
    list($headers, $body) = http_split_header_body($content);
    // Set content type header from the value set by ViewVC
    // No other headers are generated by ViewVC because generate_etags
    // is set to 0 in the ViewVC config file
    $found = false;
    $line = strtok($content, "\n\t\r\v");
    $pathInfo = pathinfo($path);
    while ($line && !$found) {
        if (preg_match('/^Content-Type:(.*)$/', $line, $matches)) {
            //Until Apache will support the office 2007 mime types by default
            //We should keep test on extension for IE to set the right Mime Type.
            $officeEtensions = array('docm' => 'application/vnd.ms-word.document.macroEnabled.12', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template');
            if (array_key_exists('extension', $pathInfo) && array_key_exists($pathInfo['extension'], $officeEtensions)) {
                $viewvc_content_type = $officeEtensions[$pathInfo['extension']];
            } else {
                $viewvc_content_type = $matches[1];
            }
            $found = true;
        }
        $line = strtok("\n\t\r\v");
    }
    $content = substr($content, strpos($content, $line));
    // Now look for 'Location:' header line (e.g. generated by 'view=redirect_pathrev'
    // parameter, used when browsing a directory at a certain revision number)
    $found = false;
    $line = strtok($content, "\n\t\r\v");
    $viewvc_location = false;
    while ($line && !$found && strlen($line) > 1) {
        if (preg_match('/^Location:(.*)$/', $line, $matches)) {
            $viewvc_location = $matches[1];
            $found = true;
        }
        $line = strtok("\n\t\r\v");
    }
    if ($found) {
        $content = substr($content, strpos($content, $line));
    }
    if ($parse) {
        //parse the html doc that we get from viewvc.
        //remove the http header part as well as the html header and
        //html body tags
        $begin_body = strpos($content, "<body");
        if ($begin_body === false) {
            $begin_body = strpos($content, "<BODY");
            $begin_doc = strpos($content, ">", $begin_body) + 1;
        } else {
            $begin_doc = strpos($content, ">", $begin_body) + 1;
        }
        $length = strpos($content, "</body>\n</html>") - $begin_doc;
        // Now insert references, and display
        echo util_make_reference_links(substr($content, $begin_doc, $length), $GLOBALS['group_id']);
    } else {
        if ($viewvc_location) {
            header('Location: ' . $viewvc_location);
            exit(1);
        }
        header('Content-Type:' . $viewvc_content_type . '; charset=utf-8');
        echo $body;
    }
}
开发者ID:rinodung,项目名称:tuleap,代码行数:83,代码来源:viewvc_utils.php

示例4: createSession

 /**
  * @return string the new session_hash
  */
 function createSession($user_id, $time)
 {
     // generate a token from a PRNG
     // continue until unique token is generated (SHOULD only be once)
     $number_generator = new RandomNumberGenerator();
     do {
         $token = $number_generator->getNumber();
         $sql = "SELECT 1\n                    FROM session\n                    WHERE session_hash = " . $this->da->quoteSmart($token);
         $dar = $this->retrieve($sql);
     } while ($dar && $dar->rowCount() == 1);
     $sql = sprintf("INSERT INTO session (session_hash, ip_addr, time,user_id) VALUES (%s, %s, %d, %d)", $this->da->quoteSmart($token), $this->da->quoteSmart(HTTPRequest::getIPAddress()), $time, $user_id);
     if ($this->update($sql)) {
         $this->storeLoginSuccess($user_id, $time);
     } else {
         $token = false;
     }
     return $token;
 }
开发者ID:rinodung,项目名称:tuleap,代码行数:21,代码来源:UserDao.class.php


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