Exemplo n.º 1
0
 function __construct()
 {
     $columns = array();
     $columns['id'] = new owa_dbColumn('id', OWA_DTD_BIGINT);
     $columns['id']->setPrimaryKey();
     $columns['visitor_id'] = new owa_dbColumn('visitor_id', OWA_DTD_BIGINT);
     $columns['visitor_id']->setForeignKey('base.visitor');
     $columns['session_id'] = new owa_dbColumn('session_id', OWA_DTD_BIGINT);
     $columns['session_id']->setForeignKey('base.session');
     $columns['session_id']->setIndex();
     $columns['site_id'] = new owa_dbColumn('site_id', OWA_DTD_VARCHAR255);
     $columns['site_id']->setForeignKey('base.site', 'site_id');
     $columns['site_id']->setIndex();
     $columns['referer_id'] = new owa_dbColumn('referer_id', OWA_DTD_BIGINT);
     $columns['referer_id']->setForeignKey('base.referer');
     $columns['ua_id'] = new owa_dbColumn('ua_id', OWA_DTD_BIGINT);
     $columns['ua_id']->setForeignKey('base.ua');
     $columns['host_id'] = new owa_dbColumn('host_id', OWA_DTD_BIGINT);
     $columns['host_id']->setForeignKey('base.host');
     $columns['os_id'] = new owa_dbColumn('os_id', OWA_DTD_BIGINT);
     $columns['os_id']->setForeignKey('base.os');
     $columns['location_id'] = new owa_dbColumn('location_id', OWA_DTD_BIGINT);
     $columns['location_id']->setForeignKey('base.location_dim');
     $columns['referring_search_term_id'] = new owa_dbColumn('referring_search_term_id', OWA_DTD_BIGINT);
     $columns['referring_search_term_id']->setForeignKey('base.search_term_dim');
     $columns['timestamp'] = new owa_dbColumn('timestamp', OWA_DTD_INT);
     $columns['yyyymmdd'] = new owa_dbColumn('yyyymmdd', OWA_DTD_INT);
     $columns['yyyymmdd']->setIndex();
     $columns['year'] = new owa_dbColumn('year', OWA_DTD_INT);
     $columns['month'] = new owa_dbColumn('month', OWA_DTD_INT);
     $columns['day'] = new owa_dbColumn('day', OWA_DTD_TINYINT2);
     $columns['dayofweek'] = new owa_dbColumn('dayofweek', OWA_DTD_VARCHAR10);
     $columns['dayofyear'] = new owa_dbColumn('dayofyear', OWA_DTD_INT);
     $columns['weekofyear'] = new owa_dbColumn('weekofyear', OWA_DTD_INT);
     $columns['last_req'] = new owa_dbColumn('last_req', OWA_DTD_BIGINT);
     $columns['ip_address'] = new owa_dbColumn('ip_address', OWA_DTD_VARCHAR255);
     $columns['is_new_visitor'] = new owa_dbColumn('is_new_visitor', OWA_DTD_BOOLEAN);
     $columns['is_repeat_visitor'] = new owa_dbColumn('is_repeat_visitor', OWA_DTD_BOOLEAN);
     $columns['language'] = new owa_dbColumn('language', OWA_DTD_VARCHAR255);
     $columns['days_since_prior_session'] = new owa_dbColumn('days_since_prior_session', OWA_DTD_INT);
     $columns['days_since_first_session'] = new owa_dbColumn('days_since_first_session', OWA_DTD_INT);
     $columns['num_prior_sessions'] = new owa_dbColumn('num_prior_sessions', OWA_DTD_INT);
     $columns['medium'] = new owa_dbColumn('medium', OWA_DTD_VARCHAR255);
     $columns['source_id'] = new owa_dbColumn('source_id', OWA_DTD_BIGINT);
     $columns['source_id']->setForeignKey('base.source_dim');
     $columns['ad_id'] = new owa_dbColumn('ad_id', OWA_DTD_BIGINT);
     $columns['ad_id']->setForeignKey('base.ad_dim');
     $columns['campaign_id'] = new owa_dbColumn('campaign_id', OWA_DTD_BIGINT);
     $columns['campaign_id']->setForeignKey('base.campaign_dim');
     $columns['user_name'] = new owa_dbColumn('user_name', OWA_DTD_VARCHAR255);
     // custom variable columns
     $cv_max = owa_coreAPI::getSetting('base', 'maxCustomVars');
     for ($i = 1; $i <= $cv_max; $i++) {
         $cvar_name_col = 'cv' . $i . '_name';
         $columns[$cvar_name_col] = new owa_dbColumn($cvar_name_col, OWA_DTD_VARCHAR255);
         $cvar_value_col = 'cv' . $i . '_value';
         $columns[$cvar_value_col] = new owa_dbColumn($cvar_value_col, OWA_DTD_VARCHAR255);
     }
     return $columns;
 }
Exemplo n.º 2
0
 function render($data)
 {
     // load body template
     $this->t->set_template('wrapper_blank.tpl');
     // check to see if we should log clicks.
     if (!owa_coreAPI::getSetting('base', 'log_dom_clicks')) {
         $this->body->set('do_not_log_clicks', true);
     }
     // check to see if we should log clicks.
     if (!owa_coreAPI::getSetting('base', 'log_dom_stream')) {
         $this->body->set('do_not_log_domstream', true);
     }
     //set siteId variable name to support old style owa_params js object
     $this->body->set("site_id", "owa_params['site_id']");
     // set name of javascript object containing params that need to be logged
     // depricated, but needed to support old style tags
     $this->body->set("owa_params", true);
     // load body template
     $this->body->set_template('js_logger.tpl');
     // assemble JS libs
     $this->setJs('json2', 'base/js/includes/json2.js');
     $this->setJs('lazyload', 'base/js/includes/lazyload-2.0.min.js');
     $this->setJs('owa', 'base/js/owa.js');
     $this->setJs('owa.tracker', 'base/js/owa.tracker.js');
     //$this->setJs('url_encode', 'base/js/includes/url_encode.js');
     $this->concatinateJs();
     return;
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @return owa_mailer
  */
 function __construct()
 {
     parent::__construct();
     $this->mailer = new PHPMailer();
     if (owa_coreAPI::getSetting('base', 'mailer-from')) {
         $this->mailer->From = owa_coreAPI::getSetting('base', 'mailer-from');
     }
     if (owa_coreAPI::getSetting('base', 'mailer-fromName')) {
         $this->mailer->FromName = owa_coreAPI::getSetting('base', 'mailer-fromName');
     }
     if (owa_coreAPI::getSetting('base', 'mailer-use-smtp')) {
         $this->mailer->IsSMTP();
         // telling the class to use SMTP
         if (owa_coreAPI::getSetting('base', 'mailer-host')) {
             $this->mailer->Host = owa_coreAPI::getSetting('base', 'mailer-host');
         }
         if (owa_coreAPI::getSetting('base', 'mailer-port')) {
             $this->mailer->Port = owa_coreAPI::getSetting('base', 'mailer-port');
         }
         if (owa_coreAPI::getSetting('base', 'mailer-smtpAuth')) {
             $this->mailer->SMTPAuth = owa_coreAPI::getSetting('base', 'mailer-smtpAuth');
         }
         if (owa_coreAPI::getSetting('base', 'mailer-username') && owa_coreAPI::getSetting('base', 'mailer-password')) {
             $this->mailer->Username = owa_coreAPI::getSetting('base', 'mailer-username');
             $this->mailer->Password = owa_coreAPI::getSetting('base', 'mailer-password');
         }
     }
 }
 function action()
 {
     if ($this->getParam('source')) {
         $input_queue_type = $this->getParam('source');
     } else {
         $input_queue_type = owa_coreAPI::getSetting('base', 'event_queue_type');
     }
     $processing_queue_type = $this->getParam('destination');
     if (!$processing_queue_type) {
         $processing_queue_type = owa_coreAPI::getSetting('base', 'event_secondary_queue_type');
     }
     // switch event queue setting in case a new events should be sent to a different type of queue.
     // this is handy for when processing from a file queue to a database queue
     if ($processing_queue_type) {
         owa_coreAPI::setSetting('base', 'event_queue_type', $processing_queue_type);
         owa_coreAPI::debug("Setting event queue type to {$processing_queue_type} for processing.");
     }
     $d = owa_coreAPI::getEventDispatch();
     owa_coreAPI::debug("Loading {$input_queue_type} event queue.");
     $q = $d->getAsyncEventQueue($input_queue_type);
     $ret = $q->processQueue();
     // go ahead and process the secondary event queue
     if ($ret && $processing_queue_type) {
         $destq = $d->getAsyncEventQueue($processing_queue_type);
         $destq->processQueue();
     }
 }
 /**
  * Constructor
  * 
  * Takes cache directory as param
  *
  * @param $cache_dir string
  */
 function __construct($site_id)
 {
     $this->site_id = $site_id;
     $this->numGoals = owa_coreAPI::getSetting('base', 'numGoals');
     $this->numGoalGroups = owa_coreAPI::getSetting('base', 'numGoalGroups');
     $this->loadGoals($site_id);
     $this->loadGoalGroupLabels($site_id);
 }
 function pre()
 {
     if (owa_coreAPI::getSetting('base', 'install_complete')) {
         owa_coreAPI::debug('Install complete redirecting to base.installDetected');
         return $this->redirectBrowser('base.installDetected', false);
     }
     return;
 }
 function __construct($map = array())
 {
     if (array_key_exists('endpoint', $map)) {
         $this->endpoint = $map['endpoint'];
     } else {
         $this->endpoint = owa_coreAPI::getSetting('base', 'remote_event_queue_endpoint');
     }
     return parent::__construct($map);
 }
 function getCapabilities($role)
 {
     $caps = owa_coreAPI::getSetting('base', 'capabilities');
     if (array_key_exists($role, $caps)) {
         return $caps[$role];
     } else {
         return array();
     }
 }
 function __construct($options = '')
 {
     // set the endpoint. move this to constructor
     if (array_key_exists('endpoint', $options)) {
         $this->endpoint = $options['endpoint'];
     } else {
         $this->endpoint = owa_coreAPI::getSetting('base', 'remote_event_queue_endpoint');
     }
 }
 /**
  * Constructor
  *
  * @param array $params
  * @return owa_controller
  */
 function __construct($params)
 {
     if (owa_coreAPI::getSetting('base', 'cli_mode')) {
         return parent::__construct($params);
     } else {
         owa_coreAPI::notice("Controller not called from CLI");
         exit;
     }
 }
 /**
  * Creates a database connection for retrieving the requested data.
  **/
 function _getDatabaseConnection()
 {
     $db_type = owa_coreAPI::getSetting('base', 'db_type');
     $ret = owa_coreAPI::setupStorageEngine($db_type);
     if ($this->connection == null) {
         $connection_class = 'owa_db_' . $db_type;
         $this->connection = new $connection_class($this->settings->getDatabaseHost(), $this->settings->getDatabaseName(), $this->settings->getDatabaseUser(), $this->settings->getDatabasePassword());
     }
     return $this->connection;
 }
 function action()
 {
     $event = $this->getParam('event');
     $site = $this->getParam('site');
     $this->set('site', $site->_getProperties());
     $this->set('email_address', owa_coreAPI::getSetting('base', 'notice_email'));
     $this->set('session', $event->getProperties());
     $this->set('subject', sprintf('OWA: New Visit to %s', $site->get('domain')));
     //$this->set( 'plainTextView', 'base.notifyNewSessionPlainText');
     $this->setView('base.notifyNewSession');
 }
 function post()
 {
     if (owa_coreAPI::getSetting('base', 'delay_first_hit')) {
         // If not, then make sure that there is an inbound visitor_id
         if (!$this->event->get('visitor_id')) {
             // Log request properties to a cookie for processing by a second request and return
             owa_coreAPI::debug('Logging this request to first hit cookie.');
             return $this->log_first_hit();
         }
     }
     owa_coreAPI::debug('Logging ' . $this->event->getEventType() . ' to event queue...');
     return $this->addToEventQueue();
 }
Exemplo n.º 14
0
 function validate()
 {
     $error = $this->getErrorMsg();
     if (empty($error)) {
         $this->setErrorMessage('The user name contains illegal characters.');
     }
     $u = $this->getValues();
     $illegals = owa_coreAPI::getSetting('base', 'user_id_illegal_chars');
     foreach ($illegals as $k => $char) {
         if (strpos($u, $char)) {
             $this->hasError();
             break;
         }
     }
 }
Exemplo n.º 15
0
 function getGeolocationFromIp($ip_address, $refresh = false)
 {
     if (empty($this->properties) || $refresh === true) {
         $geo = array('ip_address' => $ip_address, 'city' => '', 'country' => '', 'state' => '', 'country_code' => '', 'latitude' => '', 'longitude' => '');
         if (owa_coreAPI::getSetting('base', 'geolocation_lookup')) {
             $eq = owa_coreAPI::getEventDispatch();
             $geo = $eq->filter('geolocation', $geo);
         }
         foreach ($geo as $k => $v) {
             if (!$v) {
                 $geo[$k] = '(not set)';
             }
         }
         $this->properties = $geo;
     }
 }
Exemplo n.º 16
0
 function __construct()
 {
     $this->name = 'remoteQueue';
     $this->display_name = 'Remote Queue';
     $this->group = 'logging';
     $this->author = 'Peter Adams';
     $this->version = '1.0';
     $this->description = 'Posts incoming tracking events to a remote instance of OWA';
     $this->config_required = false;
     $this->required_schema_version = 1;
     // register named queues
     $endpoint = owa_coreAPI::getSetting('remoteQueue', 'endpoint');
     if ($endpoint) {
         $this->registerEventQueue('incoming_tracking_events', array('queue_type' => 'http', 'endpoint' => $endpoint));
     }
     return parent::__construct();
 }
 /**
  * Constructor
  * 
  * Takes cache directory as param
  *
  * @param $cache_dir string
  */
 function __construct()
 {
     $servers = owa_coreAPI::getSetting('base', 'memcachedServers');
     if (!$servers) {
         owa_coreAPI::notice('No memcached servers found in configuration settings.');
         return;
     }
     $persistant = owa_coreAPI::getSetting('base', 'memcachedPersisantConnections');
     $error_mode = owa_coreAPI::getSetting('base', 'error_handler');
     if ($error_mode === 'development') {
         $debug = true;
     } else {
         $debug = false;
     }
     $this->mc = new owa_memcachedClient(array('servers' => $servers, 'debug' => $debug, 'compress_threshold' => 10240, 'persistant' => $persistant));
     return parent::__construct();
 }
 function action()
 {
     $fh_state_name = owa_coreAPI::getSetting('base', 'first_hit_param');
     //print_r($fh_state_name);
     $fh = owa_coreAPI::getStateParam($fh_state_name);
     owa_coreAPI::debug('cookiename: ' . $fh_state_name);
     //owa_coreAPI::debug(print_r($_COOKIE, true));
     if (!empty($fh)) {
         $this->event->replaceProperties($fh);
         $this->event->setEventType('base.first_page_request');
         //owa_coreAPI::debug(print_r($this->event, true));
         // Delete first_hit Cookie
         owa_coreAPI::clearState($fh_state_name);
     }
     $this->setView('base.pixel');
     $this->setViewMethod('image');
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     // Make entity
     $f = owa_coreAPI::entityFactory('base.feed_request');
     $f->load($event->get('guid'));
     if (!$f->wasPersisted()) {
         // rekey Feed subscription id tracking code
         // @todo check the wordpress plugin to see if this is even needed
         if (!$event->get('feed_subscription_id')) {
             $event->set('feed_subscription_id', $event->get(owa_coreAPI::getSetting('base', 'feed_subscription_param')));
         }
         // needed??
         $event->set('feed_reader_guid', $event->setEnvGUID());
         // set feedreader flag to true, browser flag to false
         $event->set('is_feedreader', true);
         $event->set('is_browser', false);
         // set params on entity
         $f->setProperties($event->getProperties());
         // Set Primary Key
         $f->set('id', $event->get('guid'));
         // Make ua id
         $f->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT')));
         // Make OS id
         $f->set('os_id', owa_lib::setStringGuid($event->get('os')));
         // Make document id
         $f->set('document_id', owa_lib::setStringGuid($event->get('page_url')));
         // Generate Host id
         $f->set('host_id', owa_lib::setStringGuid($event->get('host')));
         $f->set('subscription_id', $event->get('feed_subscription_id'));
         // Persist to database
         $ret = $f->create();
         if ($ret) {
             $eq = owa_coreAPI::getEventDispatch();
             $nevent = $eq->makeEvent($event->getEventType() . '_logged');
             $nevent->setProperties($event->getProperties());
             $eq->notify($nevent);
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not persisting. Feed request already exists.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 function action()
 {
     $this->setSubview('base.reportDimension');
     $this->setTitle('Campaigns');
     $metrics = 'visits,pageViews,bounces';
     if (owa_coreAPI::getSetting('base', 'enableEcommerceReporting')) {
         $metrics .= ',transactions,transactionRevenue';
     }
     $this->set('metrics', $metrics);
     $this->set('dimensions', 'campaign');
     $this->set('sort', 'visits-');
     $this->set('resultsPerPage', 30);
     $this->set('dimensionLink', array('linkColumn' => 'campaign', 'template' => array('do' => 'base.reportCampaignDetail', 'campaign' => '%s'), 'valueColumns' => 'campaign'));
     $this->set('constraints', 'campaign!=null');
     $this->set('trendChartMetric', 'visits');
     $this->set('trendTitle', 'There were <*= this.d.resultSet.aggregates.visits.formatted_value *> visits from campaigns.');
     $this->set('gridTitle', 'Top Campaigns');
 }
 function lookup($user_agent)
 {
     if (owa_coreAPI::getSetting('base', 'cache_objects') === true) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         $cache_obj = $this->cache->get('browscap', $this->ua);
     }
     if (!empty($cache_obj)) {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         return $cache_obj;
     } else {
         owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
         // Load browscap file into memory
         $user_browscap_file = OWA_DATA_DIR . 'browscap/php_browscap.ini';
         // check to see if a user downloaded version of the file exists
         if (file_exists($user_browscap_file)) {
             $this->browscap_db = $this->load($user_browscap_file);
         } else {
             $this->browscap_db = $this->load($this->config['browscap.ini']);
         }
         $cap = null;
         foreach ($this->browscap_db as $key => $value) {
             if ($key != '*' && !array_key_exists('Parent', $value)) {
                 continue;
             }
             $keyEreg = '^' . str_replace(array('\\', '.', '?', '*', '^', '$', '[', ']', '|', '(', ')', '+', '{', '}', '%'), array('\\\\', '\\.', '.', '.*', '\\^', '\\$', '\\[', '\\]', '\\|', '\\(', '\\)', '\\+', '\\{', '\\}', '\\%'), $key) . '$';
             if (preg_match('%' . $keyEreg . '%i', $user_agent)) {
                 $cap = array('browser_name_regex' => strtolower($keyEreg), 'browser_name_pattern' => $key) + $value;
                 $maxDeep = 8;
                 while (array_key_exists('Parent', $value) && --$maxDeep > 0) {
                     $cap += $value = $this->browscap_db[$value['Parent']];
                 }
                 break;
             }
         }
         if (!empty($cap)) {
             if ($this->config['cache_objects'] == true) {
                 if ($cap['Browser'] != 'Default Browser') {
                     $this->cache->set('browscap', $this->ua, (object) $cap, $this->cacheExpiration);
                 }
             }
         }
         return (object) $cap;
     }
 }
Exemplo n.º 22
0
 function __construct()
 {
     $this->entities['base.action_fact']['addColumn'] = array('last_req', 'ip_address', 'num_prior_sessions', 'is_new_visitor', 'is_repeat_visitor', 'location_id', 'language', 'referer_id', 'referring_search_term_id', 'days_since_prior_session', 'days_since_first_session', 'medium', 'source_id', 'ad_id', 'campaign_id', 'day', 'month', 'year', 'dayofweek', 'dayofyear', 'weekofyear', 'user_name');
     $this->entities['base.domstream']['addColumn'] = array('last_req', 'ip_address', 'num_prior_sessions', 'is_new_visitor', 'is_repeat_visitor', 'location_id', 'language', 'referer_id', 'referring_search_term_id', 'days_since_prior_session', 'days_since_first_session', 'medium', 'source_id', 'ad_id', 'campaign_id', 'ua_id', 'host_id', 'os_id', 'day', 'month', 'year', 'dayofweek', 'dayofyear', 'weekofyear', 'user_name');
     $this->entities['base.click']['addColumn'] = array('referring_search_term_id', 'days_since_prior_session', 'days_since_first_session', 'medium', 'source_id', 'os_id', 'last_req', 'num_prior_sessions', 'is_new_visitor', 'is_repeat_visitor', 'location_id', 'language', 'referer_id', 'user_name', 'dayofweek');
     $this->entities['base.request']['addColumn'] = array('referring_search_term_id', 'days_since_prior_session', 'days_since_first_session', 'medium', 'source_id', 'ad_id', 'campaign_id');
     $this->entities['base.commerce_transaction_fact']['addColumn'] = array('days_since_prior_session', 'last_req', 'language', 'ip_address', 'is_new_visitor', 'is_repeat_visitor', 'day', 'month', 'year', 'dayofweek', 'dayofyear', 'weekofyear', 'user_name');
     $this->entities['base.commerce_line_item_fact']['addColumn'] = array('days_since_prior_session', 'days_since_first_session', 'num_prior_sessions', 'last_req', 'language', 'ip_address', 'is_new_visitor', 'is_repeat_visitor', 'referer_id', 'day', 'month', 'year', 'dayofweek', 'dayofyear', 'weekofyear', 'user_name');
     // custom variable columns
     $cv_max = owa_coreAPI::getSetting('base', 'maxCustomVars');
     $fact_table_entities = array('base.action_fact', 'base.request', 'base.session', 'base.domstream', 'base.click', 'base.commerce_transaction_fact', 'base.commerce_line_item_fact');
     for ($i = 1; $i <= $cv_max; $i++) {
         foreach ($fact_table_entities as $fact_table_entity) {
             $this->entities[$fact_table_entity]['addColumn'][] = 'cv' . $i . '_name';
             $this->entities[$fact_table_entity]['addColumn'][] = 'cv' . $i . '_value';
         }
     }
     return parent::__construct();
 }
Exemplo n.º 23
0
 function __construct()
 {
     $this->name = 'maxmind_geoip';
     $this->display_name = 'Maxmind GeoIP';
     $this->group = 'geoip';
     $this->author = 'Peter Adams';
     $this->version = '1.0';
     $this->description = 'Performs Maxmind Geo-IP lookups.';
     $this->config_required = false;
     $this->required_schema_version = 1;
     $mode = owa_coreAPI::getSetting('maxmind_geoip', 'lookup_method');
     switch ($mode) {
         case "geoip_city_isp_org_web_service":
             $method = 'getLocationFromWebService';
             break;
         case "city_lite_db":
             $method = 'getLocation';
             break;
         default:
             $method = 'getLocation';
     }
     $this->registerFilter('geolocation', 'maxmind', $method, 0, 'classes');
     return parent::__construct();
 }
Exemplo n.º 24
0
 /**
  * Fetches the location from the hostip.info web service
  *
  * @param string $ip
  */
 function get_location($location_map)
 {
     $city = '';
     $state = '';
     $country = '';
     $country_code = '';
     $latitude = '';
     $longitude = '';
     // check to see if ip is in map
     if (array_key_exists('ip_address', $location_map) && !empty($location_map['ip_address']) && empty($location_map['country'])) {
         // check to see if ip is valid and not a private address
         if (filter_var($location_map['ip_address'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)) {
             // create crawler
             $crawler = new owa_http();
             $crawler->read_timeout = owa_coreAPI::getSetting('base', 'ws_timeout');
             // hit web service
             $crawler->fetch(sprintf($this->ws_url, $location_map['ip_address']));
             owa_coreAPI::debug(sprintf("HostIp web service response code: %s", $crawler->crawler->response_code));
             $location = $crawler->crawler->results;
             // replace delimiter
             $location = str_replace("\n", "|", $location);
             // convert string to array
             $loc_array = explode("|", $location);
             $result = array();
             // convert array to multi dimensional array
             foreach ($loc_array as $k => $v) {
                 if (!empty($v)) {
                     list($name, $value) = explode(":", $v, 2);
                     $result[$name] = $value;
                 }
             }
             // parse the city line of response
             if (isset($result['City']) && !empty($result['City'])) {
                 // lowercase
                 $result['City'] = strtolower($result['City']);
                 // explode into array
                 $city_array = explode(',', $result['City']);
                 // city name is always first
                 $city = $city_array[0];
                 // if there is a second element then it's a state
                 if (isset($city_array[1])) {
                     $state = $city_array[1];
                 }
             }
             // parse country line of response
             if (isset($result['Country']) && !empty($result['Country'])) {
                 //lowercase
                 $result['Country'] = strtolower($result['Country']);
                 // set country
                 $country_parts = explode('(', trim($result['Country']));
                 $country = $country_parts[0];
                 // if there is a second element then it's a country code.
                 if (isset($country_parts[1])) {
                     $country_code = substr($country_code, 0, -1);
                 }
                 // debug
                 owa_coreAPI::debug('Parse of Hostip country string: ' . $result['Country'] . ' c: ' . $country . ' cc: ' . $country_code);
             }
             // set latitude
             if (isset($result['Latitude']) && !empty($result['Latitude'])) {
                 $latitude = $result['Latitude'];
             }
             // set longitude
             if (isset($result['Longitude']) && !empty($result['Longitude'])) {
                 $longitude = $result['Longitude'];
             }
         }
         // fail safe checks for empty, unknown or private adddress labels
         // check to make sure values are not "private address" contain "unknown" or "xx"
         if (empty($city) || strpos($city, 'private') || strpos($city, 'unknown')) {
             $city = '(not set)';
         }
         // check state
         if (empty($state) || strpos($state, 'private') || strpos($state, 'unknown')) {
             $state = '(not set)';
         }
         // check country
         if (empty($country) || strpos($country, 'unknown') || strpos($country, 'private')) {
             $country = '(not set)';
         }
         // check country code
         if (empty($country_code) || strpos($country_code, 'xx') || strpos($country_code, 'unknown') || strpos($country_code, 'private')) {
             $country_code = '(not set)';
         }
         $location_map['city'] = strtolower(trim($city));
         $location_map['state'] = strtolower(trim($state));
         $location_map['country'] = strtolower(trim($country));
         $location_map['country_code'] = strtoupper(trim($country_code));
         $location_map['latitude'] = trim($latitude);
         $location_map['longitude'] = trim($longitude);
         // log headers if status is not a 200
         if (isset($crawler->response_code) && !strpos($crawler->response_code, '200')) {
             owa_coreAPI::debug(sprintf("HostIp web service response headers: %s", print_r($crawler->crawler->headers, true)));
         }
     }
     return $location_map;
 }
Exemplo n.º 25
0
 /**
  * Checks to see if the Capability requires
  * user to pass site access control check
  *
  * @param	$capability	string	the name of the capability (e.g. 'view_reports')
  * @return	boolean
  */
 function isSiteAccessRequiredForCapability($capability)
 {
     $capabilitiesThatRequireSiteAccess = owa_coreAPI::getSetting('base', 'capabilitiesThatRequireSiteAccess');
     if (is_array($capabilitiesThatRequireSiteAccess) && in_array($capability, $capabilitiesThatRequireSiteAccess)) {
         return true;
     }
 }
 function SetupHTTP()
 {
     if (!isset($this->http)) {
         $this->http = new http_class();
         $this->http->follow_redirect = 1;
         $this->http->debug = 0;
         $this->http->debug_response_body = 0;
         $this->http->html_debug = 1;
         $this->http->user_agent = owa_coreAPI::getSetting('base', 'owa_user_agent');
         $this->http->timeout = 3;
         $this->http->data_timeout = 3;
     }
 }
 static function setEmailAddress($email_address, $event)
 {
     if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
         $cu = owa_coreAPI::getCurrentUser();
         return $cu->user->get('email_address');
     }
 }
Exemplo n.º 28
0
 public static function isIpAddressExcluded($ip_address)
 {
     // do not log if ip address is on the do not log list
     $ips = owa_coreAPI::getSetting('base', 'excluded_ips');
     owa_coreAPI::debug('excluded ips: ' . $ips);
     if ($ips) {
         $ips = trim($ips);
         if (strpos($ips, ',')) {
             $ips = explode(',', $ips);
         } else {
             $ips = array($ips);
         }
         foreach ($ips as $ip) {
             $ip = trim($ip);
             if ($ip_address === $ip) {
                 owa_coreAPI::debug("Request is from excluded ip address: {$ip}.");
                 return true;
             }
         }
     }
 }
 function logSessionUpdate($event)
 {
     if ($event->get('session_id')) {
         // Make entity
         $s = owa_coreAPI::entityFactory('base.session');
         // Fetch from session from database
         $s->getByPk('id', $event->get('session_id'));
         $id = $s->get('id');
         // fail safe for when there is no existing session in DB
         if (empty($id)) {
             owa_coreAPI::debug("Aborting session update as no existing session was found");
             return OWA_EHS_EVENT_FAILED;
         }
         // idempotent check needed in case updates are processed out of order.
         // dont update the database if the event timestamp is older that the last_req
         // timestamp that is already set on the session object.
         $last_req_time = $s->get('last_req');
         $event_req_time = $event->get('timestamp');
         $ret = false;
         if ($event_req_time > $last_req_time) {
             // increment number of page views
             $s->set('num_pageviews', $this->summarizePageviews($id));
             // set bounce flag to false as there must have been 2 page views
             $s->set('is_bounce', 'false');
             // update timestamp of latest request that triggered the session update
             $s->set('last_req', $event->get('timestamp'));
             // update last page id
             $s->set('last_page_id', $event->get('document_id'));
             // set medium
             if ($event->get('medium')) {
                 $s->set('medium', $event->get('medium'));
             }
             // set source
             if ($event->get('source_id')) {
                 $s->set('source_id', $event->get('source_id'));
             }
             // set search terms
             if ($event->get('referring_search_term_id')) {
                 $s->set('referring_search_term_id', $event->get('referring_search_term_id'));
             }
             // set campaign
             if ($event->get('campaign_id')) {
                 $s->set('campaign_id', $event->get('campaign_id'));
             }
             // set ad
             if ($event->get('ad_id')) {
                 $s->set('ad_id', $event->get('ad_id'));
             }
             // set campaign touches
             if ($event->get('attribs')) {
                 $s->set('latest_attributions', $event->get('attribs'));
             }
             // update user name if changed.
             if ($event->get('user_name')) {
                 if (owa_coreAPI::getSetting('base', 'update_session_user_name')) {
                     // check for different user_name
                     $user_name = $event->get('user_name');
                     $old_user_name = $s->get('user_name');
                     if ($user_name != $old_user_name) {
                         $s->set('user_name', $user_name);
                     }
                 }
             }
             // Persist to database
             $ret = $s->update();
         }
         // setup event message
         $session = $s->_getProperties();
         $properties = array_merge($event->getProperties(), $session);
         $properties['request_id'] = $event->get('guid');
         $ne = owa_coreAPI::supportClassFactory('base', 'event');
         $ne->setProperties($properties);
         $ne->setEventType('base.session_update');
         // Log session update event to event queue
         $eq = owa_coreAPI::getEventDispatch();
         $ret = $eq->notify($ne);
         if ($ret) {
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not persisting new session. No session_id present.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
Exemplo n.º 30
0
 function attributeCampaign($tracking_event)
 {
     $mode = owa_coreAPI::getSetting('base', 'campaign_attribution_mode');
     // direct mode means that that we attribute the latest campaign touch
     // if the request originaled from the touching the campaign.
     if ($mode === 'direct') {
         if ($tracking_event->get('from_campaign')) {
             $campaigns = array_reverse($tracking_event->get('campaign_touches'));
             //$tracking_event->set( 'attributed_campaign', $campaigns[0] );
             return $campaigns[0];
         }
         // orginal mode means that we always attribute the request to the
         // first touch regardless of the medium/source that generated the request
     } elseif ($mode === 'original') {
         $campaigns = $tracking_event->get('campaign_touches');
         //$tracking_event->set( 'attributed_campaign', $campaigns[0] );
         return $campaigns[0];
     }
 }