本文整理汇总了PHP中CASHSystem::getRemoteIP方法的典型用法代码示例。如果您正苦于以下问题:PHP CASHSystem::getRemoteIP方法的具体用法?PHP CASHSystem::getRemoteIP怎么用?PHP CASHSystem::getRemoteIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CASHSystem
的用法示例。
在下文中一共展示了CASHSystem::getRemoteIP方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recordAnalytics
/**
* Records the basic access data to the elements analytics table
*
* @return boolean
*/
protected function recordAnalytics($id, $access_method, $access_action = 'getmarkup', $access_data = '')
{
$ip_and_proxy = CASHSystem::getRemoteIP();
$already_recorded = false;
// first check and see if we've recorded this session and circumstance yet
// only do this for empty lock_method_table queries so we don't repeat
// unnecessary rows and overwhelm the table
if ($access_action == 'getmarkup') {
$already_recorded = $this->db->getData('elements_analytics', 'id', array("element_id" => array("condition" => "=", "value" => $id), "access_method" => array("condition" => "=", "value" => $access_method), "access_location" => array("condition" => "=", "value" => CASHSystem::getCurrentURL()), "cash_session_id" => array("condition" => "=", "value" => $this->getCASHSessionID()), "client_ip" => array("condition" => "=", "value" => $ip_and_proxy['ip']), "client_proxy" => array("condition" => "=", "value" => $ip_and_proxy['proxy'])));
}
if (!$already_recorded) {
$result = $this->db->setData('elements_analytics', array('element_id' => $id, 'access_method' => $access_method, 'access_location' => CASHSystem::getCurrentURL(), 'access_action' => $access_action, 'access_data' => $access_data, 'access_time' => time(), 'client_ip' => $ip_and_proxy['ip'], 'client_proxy' => $ip_and_proxy['proxy'], 'cash_session_id' => $this->getCASHSessionID()));
return $result;
} else {
return true;
}
}
示例2: startSession
/**
* Sets the initial CASH session_id and cookie on the user's machine
*
* @return boolean
*/
public function startSession($reset_session_id = false, $force_session_id = false)
{
// if 'session_id' is already set in script store then we've already started
// the session in this script, do not hammer the database needlessly
$newsession = false;
$expiration = false;
if (!$this->sessionGet('start_time', 'script') || $reset_session_id || $force_session_id) {
if ($force_session_id) {
$this->sessionSet('session_id', $force_session_id, 'script');
}
// first make sure we have a valid session
$current_session = $this->getAllSessionData();
if ($current_session['persistent'] && isset($current_session['expiration_date'])) {
// found session data, check expiration
if ($current_session['expiration_date'] < time()) {
$this->sessionClearAll();
$current_session['persistent'] = false;
$reset_session_id = false;
$force_session_id = false;
}
}
$expiration = time() + $this->cash_session_timeout;
$current_ip = CASHSystem::getRemoteIP();
$session_id = $this->getSessionID();
if ($force_session_id) {
// if we're forcing an id, we're almost certainly in our JS session stuff
$session_id = $force_session_id;
// we SHOULD rotate ids here, but that's hard to keep in sync on the JS side
// revisit this later:
//$reset_session_id = true;
}
if ($session_id) {
// if there is an existing cookie that's not expired, use it as the
$previous_session = array('session_id' => array('condition' => '=', 'value' => $session_id));
} else {
// create a new session
$newsession = true;
$session_id = md5($current_ip['ip'] . rand(10000, 99999)) . time();
// IP + random, hashed, plus timestamo
$previous_session = false;
}
$session_data = array('session_id' => $session_id, 'expiration_date' => $expiration, 'client_ip' => $current_ip['ip'], 'client_proxy' => $current_ip['proxy']);
if ($reset_session_id) {
// forced session reset
$session_id = md5($current_ip['ip'] . rand(10000, 99999)) . time();
$session_data['session_id'] = $session_id;
}
if (!$current_session['persistent']) {
// no existing session, set up empty data
$session_data['data'] = json_encode(array('created' => time()));
}
// set the session info
$this->sessionSet('session_id', $session_id, 'script');
$this->sessionSet('start_time', time(), 'script');
// set the database session data
if (!$this->db) {
$this->connectDB();
}
$this->db->setData('sessions', $session_data, $previous_session);
// set the client-side cookie
if (!headers_sent()) {
// no headers yet, we can just send the cookie through
setcookie('cashmusic_session', $session_id, $expiration, '/');
}
} else {
$session_id = $this->sessionGet('session_id', 'script');
}
// garbage collection daemon. 2% chance of running.
if (rand(1, 100) <= 2) {
$gc = new CASHDaemon();
}
return array('newsession' => $newsession, 'expiration' => $expiration, 'id' => $session_id);
}
示例3: recordLoginAnalytics
/**
* Records the basic login data to the people analytics table
*
* @return boolean
*/
protected function recordLoginAnalytics($user_id, $element_id = null, $login_method = 'internal')
{
$result = false;
// check settings first as they're already loaded in the environment
$record_type = CASHSystem::getSystemSettings('analytics');
if ($record_type == 'off') {
return true;
}
// first the big record if needed
if ($record_type == 'full' || !$record_type) {
$ip_and_proxy = CASHSystem::getRemoteIP();
$result = $this->db->setData('people_analytics', array('user_id' => $user_id, 'element_id' => $element_id, 'access_time' => time(), 'client_ip' => $ip_and_proxy['ip'], 'client_proxy' => $ip_and_proxy['proxy'], 'login_method' => $login_method));
}
// basic logging happens for full or basic
if ($record_type == 'full' || $record_type == 'basic') {
$condition = array("user_id" => array("condition" => "=", "value" => $user_id));
$current_result = $this->db->getData('people_analytics_basic', '*', $condition);
if (is_array($current_result)) {
$last_login = $current_result[0]['modification_date'];
$new_total = $current_result[0]['total'] + 1;
} else {
$last_login = time();
$new_total = 1;
$condition = false;
}
// store the "last_login" time (as long as it's internal (web login) and > 2 min have passed)
if ($login_method == 'internal' && $last_login < time() - 120) {
new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'storeuserdata', 'user_id' => $user_id, 'key' => 'last_login', 'value' => $last_login));
$result = $this->db->setData('people_analytics_basic', array('user_id' => $user_id, 'total' => $new_total), $condition);
}
}
return $result;
}
示例4: recordAnalytics
/**
* Records the basic access data to the assets analytics table
*
* @return boolean
*/
protected function recordAnalytics($id, $element_id = 0)
{
// check settings first as they're already loaded in the environment
$record_type = CASHSystem::getSystemSettings('analytics');
if ($record_type == 'off') {
return true;
}
// only count one asset per session
$recorded_assets = $this->sessionGet('recorded_assets');
if (is_array($recorded_assets)) {
if (in_array($id, $recorded_assets)) {
// already recorded for this session. just return true.
return true;
} else {
// didn't find a record of this asset. record it and move forward
$recorded_assets[] = $id;
$this->sessionSet('recorded_assets', $recorded_assets);
}
} else {
$this->sessionSet('recorded_assets', array($id));
}
// first the big record if needed
if ($record_type == 'full' || !$record_type) {
$ip_and_proxy = CASHSystem::getRemoteIP();
$result = $this->db->setData('assets_analytics', array('asset_id' => $id, 'element_id' => $element_id, 'access_time' => time(), 'client_ip' => $ip_and_proxy['ip'], 'client_proxy' => $ip_and_proxy['proxy'], 'cash_session_id' => $this->getSessionID()));
}
// basic logging happens for full or basic
if ($record_type == 'full' || $record_type == 'basic') {
$condition = array("asset_id" => array("condition" => "=", "value" => $id));
$current_result = $this->db->getData('assets_analytics_basic', '*', $condition);
if (is_array($current_result)) {
$new_total = $current_result[0]['total'] + 1;
} else {
$new_total = 1;
$condition = false;
}
$result = $this->db->setData('assets_analytics_basic', array('asset_id' => $id, 'total' => $new_total), $condition);
}
return $result;
}
示例5: recordLoginAnalytics
/**
* Records the basic login data to the people analytics table
*
* @return boolean
*/
protected function recordLoginAnalytics($user_id, $element_id = null, $login_method = 'internal')
{
$ip_and_proxy = CASHSystem::getRemoteIP();
$result = $this->db->setData('people_analytics', array('user_id' => $user_id, 'element_id' => $element_id, 'access_time' => time(), 'client_ip' => $ip_and_proxy['ip'], 'client_proxy' => $ip_and_proxy['proxy'], 'login_method' => $login_method));
return $result;
}
示例6: recordAnalytics
/**
* Records the basic access data to the assets analytics table
*
* @return boolean
*/
protected function recordAnalytics($id, $element_id = 0)
{
$ip_and_proxy = CASHSystem::getRemoteIP();
$result = $this->db->setData('assets_analytics', array('asset_id' => $id, 'element_id' => $element_id, 'access_time' => time(), 'client_ip' => $ip_and_proxy['ip'], 'client_proxy' => $ip_and_proxy['proxy'], 'cash_session_id' => $this->getCASHSessionID()));
return $result;
}
示例7: recordAnalytics
/**
* Records the basic access data to the elements analytics table
*
* @return boolean
*/
protected function recordAnalytics($id, $access_method, $access_action = 'getmarkup', $location = false, $access_data = '')
{
// check settings first as they're already loaded in the environment
$record_type = CASHSystem::getSystemSettings('analytics');
if ($record_type == 'off') {
return true;
}
if (!$location) {
$location = CASHSystem::getCurrentURL();
}
// only count one asset + situation per session
$recorded_elements = $this->sessionGet('recorded_elements');
if (is_array($recorded_elements)) {
if (in_array($id . $access_method . $location, $recorded_elements)) {
// already recorded for this session. just return true.
return true;
} else {
// didn't find a record of this asset. record it and move forward
$recorded_elements[] = $id . $access_method . $location;
$this->sessionSet('recorded_elements', $recorded_elements);
}
} else {
$this->sessionSet('recorded_elements', array($id . $access_method . $location));
}
// first the big record if needed
if ($record_type == 'full' || !$record_type) {
$ip_and_proxy = CASHSystem::getRemoteIP();
$result = $this->db->setData('elements_analytics', array('element_id' => $id, 'access_method' => $access_method, 'access_location' => $location, 'access_action' => $access_action, 'access_data' => json_encode($access_data), 'access_time' => time(), 'client_ip' => $ip_and_proxy['ip'], 'client_proxy' => $ip_and_proxy['proxy'], 'cash_session_id' => $this->getSessionID()));
}
// basic logging happens for full or basic
if ($record_type == 'full' || $record_type == 'basic') {
$condition = array("element_id" => array("condition" => "=", "value" => $id));
$current_result = $this->db->getData('elements_analytics_basic', '*', $condition);
$short_geo = false;
if (is_array($access_data)) {
if (isset($access_data['geo'])) {
$short_geo = $access_data['geo']['city'] . ', ' . $access_data['geo']['region'] . ' / ' . $access_data['geo']['countrycode'];
}
}
if (is_array($current_result)) {
$new_total = $current_result[0]['total'] + 1;
$data = json_decode($current_result[0]['data'], true);
if (isset($data['locations'][$location])) {
$data['locations'][$location] = $data['locations'][$location] + 1;
} else {
$data['locations'][$location] = 1;
}
if (isset($data['methods'][$access_method])) {
$data['methods'][$access_method] = $data['methods'][$access_method] + 1;
} else {
$data['methods'][$access_method] = 1;
}
if (isset($data['geo'][$short_geo])) {
$data['geo'][$short_geo] = $data['geo'][$short_geo] + 1;
} else {
$data['geo'][$short_geo] = 1;
}
} else {
$new_total = 1;
$data = array('locations' => array($location => 1), 'methods' => array($access_method => 1), 'geo' => array($short_geo => 1));
$condition = false;
}
$result = $this->db->setData('elements_analytics_basic', array('element_id' => $id, 'data' => json_encode($data), 'total' => $new_total), $condition);
}
return $result;
}