本文整理汇总了PHP中Sys::clientIp方法的典型用法代码示例。如果您正苦于以下问题:PHP Sys::clientIp方法的具体用法?PHP Sys::clientIp怎么用?PHP Sys::clientIp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sys
的用法示例。
在下文中一共展示了Sys::clientIp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
function write($log_file_data, $string)
{
$log_dir = $log_file_data[0];
$log_name = $log_file_data[1];
$file_name = $log_dir . $log_name;
if (!is_dir($log_dir))
Fs :: mkdir($log_dir, 0775, true);
$oldumask = umask(0);
$file_existed = file_exists($file_name);
$log_file = fopen($file_name, 'a');
if ($log_file)
{
$time = gmstrftime("%b %d %Y %H:%M:%S", time());
$notice = '[ ' . $time . " ]\n";
$toolkit =& Limb :: toolkit();
$user =& $toolkit->getUser();
if(($user_id = $user->getId()) != DEFAULT_USER_ID)
$notice .= '[ ' . $user_id . ' ] [ ' . $user->getLogin() . ' ] [ ' . $user->get('email', '') . ' ] ';
$notice .= '[' . Sys::clientIp() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
fwrite($log_file, $notice);
fclose($log_file );
if (!$file_existed)
chmod($file_name, 0664);
umask($oldumask);
$result = true;
}
else
{
umask($oldumask);
return throw_error(new IOException("Cannot open log file '$file_name' for writing\n" .
"The web server must be allowed to modify the file.\n" .
"File logging for '$file_name' is disabled."));
}
return $result;
}
示例2: getClientIp
public function getClientIp()
{
return Ip::encodeIp(Sys::clientIp());
}
示例3: parseHtmlConsole
function parseHtmlConsole()
{
if (!Debug :: isDebugEnabled())
return '';
$inst =& Debug :: instance();
$report = $inst->_parseReportInternal(true);
$ip = Sys :: clientIp();
$js_window = "
<script language='javascript'>
<!-- hide this script from old browsers
function show_debug(file_name, title)
{
var debug_path = '" . DEBUG_HTTP_CONSOLE_DIR . "';
rn = Math.random();
debug_window = window.open(debug_path + file_name + '?rn=' + rn, title, 'top=370,left=550,height=300,width=400,scrollbars,resizable');
}
show_debug('{$ip}-debug.html', 'debug');
//-->
</script>";
$header = '<html><head><script>var NEED_TO_FOCUS = false</script><title>debug</title></head><body onload="if(NEED_TO_FOCUS)window.focus();else window.blur()">';
$footer = '</body></html>';
$fp = fopen(VAR_DIR . $ip . '-debug.html', 'w+');
fwrite($fp, $header);
fwrite($fp, $report);
fwrite($fp, $footer);
fclose($fp);
return $js_window;
}
示例4: registerAnswer
public function registerAnswer($answer_id)
{
if (!$answer_id) {
return false;
}
if (!($poll_data = $this->getActivePoll())) {
return false;
}
$poll_id = $poll_data['id'];
if (!$poll_id) {
return false;
}
if (!$this->canVote()) {
return false;
}
if (!$this->_addVoteToAnswer($poll_data['answers'][$answer_id]['record_id'])) {
return false;
}
$poll_session =& Limb::toolkit()->getSession()->getReference('poll_session');
$poll_session[$poll_id] = $poll_id;
switch ($poll_data['restriction']) {
case 1:
return true;
break;
case 2:
$cookie = $_COOKIE;
if (isset($cookie['poll_ids'])) {
$poll_ids = $cookie['poll_ids'];
$poll_ids += ',' . $poll_id;
} else {
$poll_ids = $poll_id;
}
$one_week = 7 * 24 * 60 * 60;
setcookie('poll_ids', $poll_ids, time() + $one_week, '/');
break;
case 3:
$this->_registerNewIp($poll_id, Sys::clientIp());
break;
}
return true;
}