本文整理汇总了PHP中P2Util::getRemoteHost方法的典型用法代码示例。如果您正苦于以下问题:PHP P2Util::getRemoteHost方法的具体用法?PHP P2Util::getRemoteHost怎么用?PHP P2Util::getRemoteHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P2Util
的用法示例。
在下文中一共展示了P2Util::getRemoteHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eh
echo $hr;
}
?>
<p id="client_status">
<?php
eh($autho_user_st);
?>
: <?php
eh($_login->user_u);
?>
<br>
<?php
eh($client_host_st);
?>
: <?php
eh(P2Util::getRemoteHost());
?>
<br>
<?php
eh($client_ip_st);
?>
: <?php
eh($_SERVER['REMOTE_ADDR']);
?>
<br>
<?php
eh($browser_ua_st);
?>
: <?php
ehi($_SERVER['HTTP_USER_AGENT']);
?>
示例2: recAccessLog
/**
* アクセス(ログイン)情報をログに記録する
*
* @access public
* @return boolean
*/
function recAccessLog($logfile, $maxline = 100, $format = 'dataphp')
{
global $_conf, $_login;
// ログファイルの中身を取得する
$lines = array();
if (file_exists($logfile)) {
if ($format == 'dataphp') {
$lines = DataPhp::fileDataPhp($logfile);
} else {
$lines = file($logfile);
}
}
if ($lines) {
// 制限行調整
while (sizeof($lines) > $maxline - 1) {
array_pop($lines);
}
} else {
$lines = array();
}
$lines = array_map('rtrim', $lines);
// 変数設定
$date = date('Y/m/d (D) G:i:s');
$user = isset($_login->user_u) ? $_login->user_u : "";
// 新しいログ行を設定
$newdata = implode('<>', array($date, $_SERVER['REMOTE_ADDR'], P2Util::getRemoteHost(), geti($_SERVER['HTTP_USER_AGENT']), geti($_SERVER['HTTP_REFERER']), '', $user));
//$newdata = htmlspecialchars($newdata, ENT_QUOTES);
// まずタブを全て外して
$newdata = str_replace("\t", "", $newdata);
// <>をタブに変換して
$newdata = str_replace("<>", "\t", $newdata);
// 新しいデータを一番上に追加
@array_unshift($lines, $newdata);
$cont = implode("\n", $lines) . "\n";
FileCtl::make_datafile($logfile, $_conf['p2_perm']);
// 書き込み処理
if ($format == 'dataphp') {
if (!DataPhp::writeDataPhp($logfile, $cont, $_conf['p2_perm'])) {
return false;
}
} else {
if (false === file_put_contents($logfile, $cont, LOCK_EX)) {
trigger_error("file_put_contents(" . $logfile . ")", E_USER_WARNING);
return false;
}
}
return true;
}
示例3: _buildRequestForPost
/**
* @return array array($request, $send_host, $send_port)
*/
function _buildRequestForPost($host, $bbs, $key, $post, $bbs_cgi)
{
global $_conf, $_login;
$method = 'POST';
$bbs_cgi_url = 'http://' . $host . $bbs_cgi;
$purl = parse_url($bbs_cgi_url);
$purl['query'] = isset($purl['query']) ? '?' . $purl['query'] : '';
// プロキシ
if ($_conf['proxy_use']) {
$send_host = $_conf['proxy_host'];
$send_port = $_conf['proxy_port'];
$send_path = $bbs_cgi_url;
} else {
$send_host = $purl['host'];
$send_port = isset($purl['port']) ? $purl['port'] : null;
$send_path = $purl['path'] . $purl['query'];
}
!$send_port and $send_port = 80;
$request = $method . ' ' . $send_path . " HTTP/1.0" . "\r\n";
$request .= 'Host: ' . $purl['host'] . "\r\n";
$remote_host = P2Util::getRemoteHost($_SERVER['REMOTE_ADDR']);
$add_user_info = '';
//$add_user_info = "; p2-client-ip: {$_SERVER['REMOTE_ADDR']}";
//$add_user_info .= "; p2-client-host: {$remote_host}";
$request .= sprintf('User-Agent: Monazilla/1.00 (%s/%s%s)', $_conf['p2uaname'], $_conf['p2version'], $add_user_info) . "\r\n";
$request .= 'Referer: http://' . $purl['host'] . '/' . "\r\n";
// クライアントのIPを送信するp2独自のヘッダ
$request .= "X-P2-Client-IP: " . $_SERVER['REMOTE_ADDR'] . "\r\n";
$request .= "X-P2-Client-Host: " . $remote_host . "\r\n";
// クッキー
$cookies_to_send = '';
$p2cookies = _readCookieFile(_cachePathForCookieByHost($host));
if ($p2cookies) {
foreach ($p2cookies as $cname => $cvalue) {
if ($cname != 'expires') {
$cookies_to_send .= " {$cname}={$cvalue};";
}
}
}
// be.2ch 認証クッキー
// be板では自動Be書き込みを試みる
if (P2Util::isBbsBe2chNet($host, $bbs) || !empty($_REQUEST['submit_beres'])) {
$cookies_to_send .= ' MDMD=' . $_conf['be_2ch_code'] . ';';
// be.2ch.netの認証コード(パスワードではない)
$cookies_to_send .= ' DMDM=' . $_conf['be_2ch_mail'] . ';';
// be.2ch.netの登録メールアドレス
}
!$cookies_to_send and $cookies_to_send = ' ;';
$request .= 'Cookie:' . $cookies_to_send . "\r\n";
//$request .= 'Cookie: PON='.$SPID.'; NAME='.$FROM.'; MAIL='.$mail."\r\n";
$request .= 'Connection: Close' . "\r\n";
// {{{ POSTの時はヘッダを追加して末尾にURLエンコードしたデータを添付
if (strtoupper($method) == 'POST') {
$post_enc = array();
while (list($name, $value) = each($post)) {
if (!isset($value)) {
continue;
}
// したらば or be.2ch.netなら、EUCに変換
if (P2Util::isHostJbbsShitaraba($host) || P2Util::isHostBe2chNet($host)) {
$value = mb_convert_encoding($value, 'eucJP-win', 'SJIS-win');
}
$post_enc[] = $name . "=" . urlencode($value);
}
$postdata = implode('&', $post_enc);
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: " . strlen($postdata) . "\r\n";
$request .= "\r\n";
$request .= $postdata;
} else {
$request .= "\r\n";
}
return array($request, $send_host, $send_port);
}
示例4: postIt
/**
* レスを書き込む or 新規スレッドを立てる
* スレ立ての場合は、$key は空 '' でよい
*
* @return boolean 書き込み成功なら true、失敗なら false
*/
function postIt($host, $bbs, $key, $post)
{
global $_conf, $post_result, $post_error2ch, $popup, $rescount, $ttitle_en, $STYLE;
global $bbs_cgi, $post_cache;
$method = "POST";
$bbs_cgi_url = "http://" . $host . $bbs_cgi;
$purl = parse_url($bbs_cgi_url);
if (isset($purl['query'])) {
$purl['query'] = "?" . $purl['query'];
} else {
$purl['query'] = "";
}
// プロキシ
if ($_conf['proxy_use']) {
$send_host = $_conf['proxy_host'];
$send_port = $_conf['proxy_port'];
$send_path = $bbs_cgi_url;
} else {
$send_host = $purl['host'];
$send_port = $purl['port'];
$send_port = isset($purl['port']) ? $purl['port'] : null;
$send_path = $purl['path'] . $purl['query'];
}
!$send_port and $send_port = 80;
$request = $method . " " . $send_path . " HTTP/1.0" . "\r\n";
$request .= "Host: " . $purl['host'] . "\r\n";
$remote_host = P2Util::getRemoteHost($_SERVER['REMOTE_ADDR']);
$add_user_info = '';
//$add_user_info = "; p2-client-ip: {$_SERVER['REMOTE_ADDR']}";
//$add_user_info .= "; p2-client-host: {$remote_host}";
$request .= "User-Agent: Monazilla/1.00 (" . $_conf['p2name'] . "/" . $_conf['p2version'] . "{$add_user_info})" . "\r\n";
$request .= 'Referer: http://' . $purl['host'] . '/' . "\r\n";
// クライアントのIPを送信するp2独自のヘッダ
$request .= "X-P2-Client-IP: " . $_SERVER['REMOTE_ADDR'] . "\r\n";
$request .= "X-P2-Client-Host: " . $remote_host . "\r\n";
// クッキー
$cookies_to_send = "";
// クッキーの読み込み
$cookie_file = cachePathForCookie($host);
$p2cookies = readCookieFile($cookie_file);
if ($p2cookies) {
foreach ($p2cookies as $cname => $cvalue) {
if ($cname != 'expires') {
$cookies_to_send .= " {$cname}={$cvalue};";
}
}
}
// be.2ch 認証クッキー
// be板では自動Be書き込みを試みる
if (P2Util::isBbsBe2chNet($host, $bbs) || !empty($_REQUEST['submit_beres'])) {
$cookies_to_send .= ' MDMD=' . $_conf['be_2ch_code'] . ';';
// be.2ch.netの認証コード(パスワードではない)
$cookies_to_send .= ' DMDM=' . $_conf['be_2ch_mail'] . ';';
// be.2ch.netの登録メールアドレス
}
!$cookies_to_send and $cookies_to_send = ' ;';
$request .= 'Cookie:' . $cookies_to_send . "\r\n";
//$request .= 'Cookie: PON='.$SPID.'; NAME='.$FROM.'; MAIL='.$mail."\r\n";
$request .= "Connection: Close\r\n";
// {{{ POSTの時はヘッダを追加して末尾にURLエンコードしたデータを添付
if (strtoupper($method) == "POST") {
$post_enc = array();
while (list($name, $value) = each($post)) {
if (!isset($value)) {
continue;
}
// したらば or be.2ch.netなら、EUCに変換
if (P2Util::isHostJbbsShitaraba($host) || P2Util::isHostBe2chNet($host)) {
$value = mb_convert_encoding($value, 'eucJP-win', 'SJIS-win');
}
$post_enc[] = $name . "=" . urlencode($value);
}
$postdata = implode("&", $post_enc);
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: " . strlen($postdata) . "\r\n";
$request .= "\r\n";
$request .= $postdata;
} else {
$request .= "\r\n";
}
// }}}
$maru_kakiko = empty($_POST['maru_kakiko']) ? 0 : 1;
setConfUser('maru_kakiko', $maru_kakiko);
// 書き込みを一時的に保存
$failed_post_file = P2Util::getFailedPostFilePath($host, $bbs, $key);
$cont = serialize($post_cache);
DataPhp::writeDataPhp($failed_post_file, $cont, $_conf['res_write_perm']);
// WEBサーバへ接続
$fp = fsockopen($send_host, $send_port, $errno, $errstr, $_conf['fsockopen_time_limit']);
if (!$fp) {
showPostMsg(false, "サーバ接続エラー: {$errstr} ({$errno})<br>p2 Error: 板サーバへの接続に失敗しました", false);
return false;
}
// HTTPリクエスト送信
//.........这里部分代码省略.........