本文整理汇总了PHP中apache_note函数的典型用法代码示例。如果您正苦于以下问题:PHP apache_note函数的具体用法?PHP apache_note怎么用?PHP apache_note使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apache_note函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGeoIpByMaxMind
private function getGeoIpByMaxMind()
{
$ip = isset($this->request->server['HTTP_X_FORWARDED_FOR']) && $this->request->server['HTTP_X_FORWARDED_FOR'] ? $this->request->server['HTTP_X_FORWARDED_FOR'] : 0;
$ip = $ip ? $ip : $this->request->server['REMOTE_ADDR'];
$part = explode(".", $ip);
$ip_int = 0;
if (count($part) == 4) {
$ip_int = $part[3] + 256 * ($part[2] + 256 * ($part[1] + 256 * $part[0]));
}
$geo = $this->cache->get('maxmind.' . $ip_int);
if (!isset($geo)) {
if (function_exists('apache_note') && ($code = apache_note('GEOIP_COUNTRY_CODE'))) {
if ($country_id = $this->getCountryIdbyISO($code)) {
$geo = array('country_id' => $country_id, 'zone_id' => '', 'city' => '', 'postcode' => '');
}
} else {
if (function_exists('geoip_record_by_name') && ($code = geoip_record_by_name($ip))) {
if ($country_id = $this->getCountryIdbyISO($code['country_code'])) {
$geo = array('country_id' => $country_id, 'zone_id' => '', 'city' => '', 'postcode' => '');
}
}
}
}
$this->cache->set('maxmind.' . $ip_int, isset($geo) ? $geo : false);
return $geo;
}
示例2: execute
public function execute($filterChain)
{
if ($this->isFirstCall()) {
$user = $this->getContext()->getUser();
if ($user->isAuthenticated()) {
//Check if the user still exists
$q = Doctrine_Query::create()->useResultCache(true)->setResultCacheLifeSpan(60 * 5)->from('Users')->andWhere('id = ?', $user->getId());
$usr = $q->fetchOne();
if (!$usr) {
$user->clearCredentials();
$user->setAuthenticated(false);
return $this->getContext()->getController()->redirect('homepage');
}
$user->setAttribute('db_user_type', $usr->getDbUserType());
}
if ($user->isAuthenticated() && sfConfig::get('dw_tracking_enabled', null)) {
$conn = Doctrine_Manager::connection();
$conn->exec("select fct_set_user( ? );", array($user->getId()));
}
if ($user->isAuthenticated() && function_exists('apache_note')) {
apache_note('username', $user->getId());
apache_note('sessionID', session_id());
}
}
$filterChain->execute();
}
示例3: PMA_logUser
/**
* Logs user information to webserver logs.
*
* @param string $user user name
* @param string $status status message
*
* @return void
*/
function PMA_logUser($user, $status = 'ok')
{
if (function_exists('apache_note')) {
apache_note('userID', $user);
apache_note('userStatus', $status);
}
}
示例4: log_script_timing
/**
* Logs execution time of script
* if $CONF['log_script_timing'] isn't set, nothing happens
* if $CONF['log_script_timing'] == 'file' timings are logged in the logs folder
* if $CONF['log_script_timing'] == 'apache' timings are logged via apache
*/
function log_script_timing()
{
global $STARTTIME, $USER, $CONF;
list($usec, $sec) = explode(' ', microtime());
$endtime = (double) $usec + (double) $sec;
$timetaken = sprintf('%0.4F', $endtime - $STARTTIME);
if ($CONF['log_script_timing'] == 'file') {
//%03.4f doesn't seem to work so we must add our own padding
//this makes the output file easily sortable
if ($timetaken < 100) {
$timetaken = '0' . $timetaken;
}
if ($timetaken < 10) {
$timetaken = '0' . $timetaken;
}
$logfile = $CONF['log_script_folder'] . '/' . date('Ymd-H') . '.log';
$h = @fopen($logfile, 'a');
if ($h) {
$time = date("i:s");
$logline = "{$timetaken},{$time},{$_SERVER['SCRIPT_URL']},{$_SERVER['REQUEST_METHOD']},\"{$_SERVER['QUERY_STRING']}\",{$_SERVER['REMOTE_ADDR']},{$USER->user_id},\"{$_SERVER['HTTP_REFERER']}\"\n";
fwrite($h, $logline);
fclose($h);
}
} elseif ($CONF['log_script_timing'] == 'apache') {
@apache_note('php_timing', $timetaken);
}
}
示例5: logUser
/**
* Logs user information to webserver logs.
*
* @param string $user user name
* @param string $status status message
*
* @return void
*/
public static function logUser($user, $status = 'ok')
{
if (function_exists('apache_note')) {
apache_note('userID', $user);
apache_note('userStatus', $status);
}
if (function_exists('syslog') && $status != 'ok') {
@openlog('phpMyAdmin', LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
@syslog(LOG_WARNING, 'user denied: ' . $user . ' (' . $status . ') from ' . PMA_getIp());
}
}
示例6: _canGetUid
/**
* UIDが取得できる状態かどうか
* 取得のためのパラメータが設定されていなかったら、パラメータを付けてリダイレクトする
*
* @return null
*/
private function _canGetUid()
{
$context = $this->getContext();
$req = $context->getRequest();
if ($req->isMethod('get') && sfJpMobile::isDocomo() && $req->getParameter('guid') == null) {
$uri = getenv('REQUEST_URI');
$uri .= strpos($uri, '?') === false ? '?' : '&';
$context->getController()->getAction($context->getModuleName(), $context->getActionName())->redirect("{$uri}guid=ON");
}
apache_note('uid', sfJpMobile::getDevice()->getUid());
}
示例7: PMA_logUser
/**
* Logs user information to webserver logs.
*
* @param string $user user name
* @param string $status status message
*
* @return void
*/
function PMA_logUser($user, $status = 'ok')
{
if (function_exists('apache_note')) {
apache_note('userID', $user);
apache_note('userStatus', $status);
}
if (function_exists('syslog') && $status != 'ok') {
@openlog('phpMyAdmin', LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
@syslog(LOG_WARNING, 'user denied: ' . $user . ' (' . $status . ') from ' . $_SERVER['REMOTE_ADDR']);
}
}
示例8: outputAccessLog
public static function outputAccessLog(sfEvent $event, $content = '')
{
if (!function_exists('apache_note')) {
return $content;
}
$response = sfContext::getInstance()->getResponse();
$apps = sfContext::getInstance()->getConfiguration()->getApplication();
if (('pc_frontend' === $apps || 'mobile_frontend' === $apps) && 200 === $response->getStatusCode()) {
$memberId = (int) sfContext::getInstance()->getUser()->getMemberId();
$domain = sfContext::getInstance()->getRequest()->getHost();
apache_note('originallog', sprintf('PV %s %s %s %d', $apps, $domain, memory_get_peak_usage(), $memberId));
} else {
apache_note('originallog', sprintf('OT %s %s %s %d', $apps, '-', memory_get_peak_usage(), 0));
}
return $content;
}
示例9: getCountry
public static function getCountry($allow_countory, $deny_countory)
{
// Block countory via Geolocation
$country_code = false;
if (isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
// CloudFlareを使用している場合、そちらのGeolocationを読み込む
// https://www.cloudflare.com/wiki/IP_Geolocation
$country_code = $_SERVER['HTTP_CF_IPCOUNTRY'];
} else {
if (isset($_SERVER['GEOIP_COUNTRY_CODE'])) {
// サーバーが$_SERVER['GEOIP_COUNTRY_CODE']を出力している場合
// Apache : http://dev.maxmind.com/geoip/mod_geoip2
// nginx : http://wiki.nginx.org/HttpGeoipModule
// cherokee : http://www.cherokee-project.com/doc/config_virtual_servers_rule_types.html
$country_code = $_SERVER['GEOIP_COUNTRY_CODE'];
} else {
if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_COUNTRY_EDITION) && function_exists('geoip_region_by_name')) {
// それでもダメな場合は、phpのgeoip_region_by_name()からGeolocationを取得
// http://php.net/manual/en/function.geoip-region-by-name.php
$geoip = geoip_region_by_name(REMOTE_ADDR);
$country_code = $geoip['country_code'];
if (DEBUG) {
$info[] = !empty($geoip['country_code']) ? 'GeoIP is usable. Your country code from IP is inferred <var>' . $geoip['country_code'] . '</var>.' : 'GeoIP is NOT usable. Maybe database is not installed. Please check <a href="http://www.maxmind.com/app/installation?city=1" rel="external">GeoIP Database Installation Instructions</a>';
}
} else {
if (function_exists('apache_note')) {
// Apacheの場合
$country_code = apache_note('GEOIP_COUNTRY_CODE');
}
}
}
}
if (DEBUG) {
// 使用可能かをチェック
$info[] = isset($country_code) && !empty($country_code) ? 'Your country code from IP is inferred <var>' . $country_code . '</var>.' : 'Seems Geolocation is not available. <var>' . $deny_countory . '</var> value and <var>' . $allow_countory . '</var> value is ignoled.';
}
return $country_code;
}
示例10: authenticateSubscriptionRequest
/**
* Authenticate Subscription Requests
*
* @return void
*/
private function authenticateSubscriptionRequest()
{
$realm = '[' . Config::get('sitename') . '] Group Calendar: ' . $this->group->get('description');
if (empty($_SERVER['PHP_AUTH_USER'])) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . $realm . '"');
echo Lang::txt('You are not authorized to view this calendar.');
exit;
}
//get the username and password
$httpBasicUsername = $_SERVER['PHP_AUTH_USER'];
$httpBasicPassword = $_SERVER['PHP_AUTH_PW'];
//make sure we have a username and password
if (!isset($httpBasicUsername) || !isset($httpBasicPassword) || $httpBasicUsername == '' || $httpBasicPassword == '') {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . $realm . '"');
die(Lang::txt('You must enter a valid username and password.'));
}
//get the user based on username
$sql = "SELECT u.id, u.username, up.passhash\n\t\t FROM #__users AS u, #__users_password AS up\n\t\t WHERE u.id=up.user_id\n\t\t AND u.username=" . $this->database->quote($httpBasicUsername);
$this->database->setQuery($sql);
$user = $this->database->loadObject();
//make sure we found a user
if (!is_object($user) || $user->id == '' || $user->id == 0) {
App::get('log')->logger('auth')->info($httpBasicUsername . ' ' . $_SERVER['REMOTE_ADDR'] . ' invalid group calendar subscription auth for ' . $this->group->get('cn'));
apache_note('auth', 'invalid');
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . $realm . '"');
die(Lang::txt('You must enter a valid username and password.'));
}
//make sure password matches stored password
if (!\Hubzero\User\Password::comparePasswords($user->passhash, $httpBasicPassword)) {
App::get('log')->logger('auth')->info($httpBasicUsername . ' ' . $_SERVER['REMOTE_ADDR'] . ' invalid group calendar subscription auth for ' . $this->group->get('cn'));
apache_note('auth', 'invalid');
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . $realm . '"');
die(Lang::txt('You must enter a valid username and password.'));
}
return $user;
}
示例11: get_uid
$UID = get_uid(false);
$ip = getRemoteIP();
// Ticket #0028763
if (is_release() && $UID > 0 && !isset($error404_page) && strpos($ip, '10.') !== 0 && isset($_SESSION['permissions']) && !empty($_SESSION['permissions'])) {
//Админ не под VPN
header("Location: /404.php");
exit;
}
//Если это не авторизация то чистим метку
$_action = __paramInit('striptrim', 'action', 'action');
if ($_action !== 'login' && !defined('IS_AUTH_SECOND') && !defined('IS_OPAUTH') && !defined('IS_PHP_JS')) {
unset($_SESSION['2fa_provider']);
}
// Добавление в Apache лог идентификатора пользователя
if (function_exists('apache_note')) {
apache_note('custom_field', $UID);
}
if (isset($_GET['blogon'])) {
$_SESSION['blog_ON'] = 1;
}
if (isset($_GET['blogoff'])) {
unset($_SESSION['blog_ON']);
}
// Закрываем блоги (перенос всего в сообщества) #0023347
// @TODO Вынести потом все эти настройки в конфиг
if ($_SESSION['blog_ON'] != 1) {
// Для теста на бете
define("BLOGS_CLOSED", true);
} else {
define("BLOGS_CLOSED", false);
}
示例12: apache_note
<?php
apache_note('statsd.stat', 'set.via.note');
示例13: rm
/**
* remove variable from memory
*
* @param string $name name of the variable
*
* @return bool true on success
* @access public
*/
function rm($name)
{
apache_note($name, null);
return true;
}
示例14: init
protected function init()
{
if (isset($this->_params['clientTag'])) {
$this->clientTag = $this->_params['clientTag'];
}
$ks = $this->getKs();
if ($ks === false) {
if (self::$_debugMode) {
$this->debugLog("getKs failed, disabling cache");
}
return false;
}
// if the request triggering the cache warmup was an https request, fool the code to treat the current request as https as well
$warmCacheHeader = self::getRequestHeaderValue(self::WARM_CACHE_HEADER);
if ($warmCacheHeader == "https") {
$_SERVER['HTTPS'] = "on";
}
$this->addKsData($ks);
$this->addInternalCacheParams();
// print the partner id using apache note
if ($this->_ksPartnerId) {
$this->_partnerId = $this->_ksPartnerId;
} else {
if (isset($this->_params["partnerId"])) {
$this->_partnerId = $this->_params["partnerId"];
}
}
if (!is_numeric($this->_partnerId)) {
$this->_partnerId = null;
}
if ($this->_partnerId && function_exists('apache_note')) {
apache_note("Kaltura_PartnerId", $this->_partnerId);
}
if (!kConf::get('enable_cache') || $this->isCacheDisabled()) {
if (self::$_debugMode) {
$this->debugLog("cache disabled due to request parameters / configuration");
}
return false;
}
return true;
}
示例15: checkEnv
/**
* 環境変数のチェック
*/
public static function checkEnv($env)
{
global $deny_countory, $allow_countory;
// 国別設定
$country_code = '';
if (isset($env['HTTP_CF_IPCOUNTRY'])) {
// CloudFlareを使用している場合、そちらのGeolocationを読み込む
// https://www.cloudflare.com/wiki/IP_Geolocation
$country_code = $env['HTTP_CF_IPCOUNTRY'];
} else {
if (isset($env['GEOIP_COUNTRY_CODE'])) {
// サーバーが$_SERVER['GEOIP_COUNTRY_CODE']を出力している場合
// Apache : http://dev.maxmind.com/geoip/mod_geoip2
// nginx : http://wiki.nginx.org/HttpGeoipModule
// cherokee : http://www.cherokee-project.com/doc/config_virtual_servers_rule_types.html
$country_code = $env['GEOIP_COUNTRY_CODE'];
} else {
if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_COUNTRY_EDITION) && function_exists('geoip_region_by_name')) {
// それでもダメな場合は、phpのgeoip_region_by_name()からGeolocationを取得
// http://php.net/manual/en/function.geoip-region-by-name.php
$geoip = geoip_region_by_name(REMOTE_ADDR);
$country_code = $geoip['country_code'];
$info[] = !empty($geoip['country_code']) ? 'GeoIP is usable. Your country code from IP is inferred <var>' . $geoip['country_code'] . '</var>.' : 'GeoIP is NOT usable. Maybe database is not installed. Please check <a href="http://www.maxmind.com/app/installation?city=1" rel="external">GeoIP Database Installation Instructions</a>';
} else {
if (function_exists('apache_note')) {
// Apacheの場合
$country_code = apache_note('GEOIP_COUNTRY_CODE');
}
}
}
}
// 使用可能かをチェック
if (!isset($country_code) || empty($country_code)) {
$info[] = 'Seems Geolocation is not available. <var>$deny_countory</var> value and <var>$allow_countory</var> value is ignoled.';
} else {
$info[] = 'Your country code from IP is inferred <var>' . $country_code . '</var>.';
if (isset($deny_countory) && !empty($deny_countory)) {
if (in_array($country_code, $deny_countory)) {
die('Sorry, access from your country(' . $geoip['country_code'] . ') is prohibited.');
exit;
}
}
if (isset($allow_countory) && !empty($allow_countory)) {
if (!in_array($country_code, $allow_countory)) {
die('Sorry, access from your country(' . $geoip['country_code'] . ') is prohibited.');
exit;
}
}
}
// INI_FILE: $agents: UserAgentの識別
$user_agent = $matches = array();
$user_agent['agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
// unset(${$ua}, $_SERVER[$ua], $HTTP_SERVER_VARS[$ua], $ua); // safety
if (empty($user_agent['agent'])) {
die;
}
// UAが取得できない場合は処理を中断
foreach (self::loadConfig('profile.ini.php') as $agent) {
if (preg_match($agent['pattern'], $user_agent['agent'], $matches)) {
$user_agent = array('profile' => isset($agent['profile']) ? $agent['profile'] : null, 'name' => isset($matches[1]) ? $matches[1] : null, 'vers' => isset($matches[2]) ? $matches[2] : null);
break;
}
}
$ua_file = self::add_homedir($user_agent['profile'] . '.ini.php');
if ($ua_file) {
require $ua_file;
}
define('UA_NAME', isset($user_agent['name']) ? $user_agent['name'] : null);
define('UA_VERS', isset($user_agent['vers']) ? $user_agent['vers'] : null);
define('UA_CSS', isset($user_agent['css']) ? $user_agent['css'] : null);
// HTTP_X_REQUESTED_WITHヘッダーで、ajaxによるリクエストかを判別
define('IS_AJAX', isset($env['HTTP_X_REQUESTED_WITH']) && strtolower($env['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || isset($vars['ajax']));
}