Exemplo n.º 1
0
 function action()
 {
     $cu = owa_coreAPI::getCurrentUser();
     $this->set('go', $this->getParam('go'));
     $this->set('user_id', $cu->getUserData('user_id'));
     $this->setView('base.loginForm');
 }
 function action()
 {
     $service =& owa_coreAPI::serviceSingleton();
     $this->e->notice('starting Embedded install');
     //create config file
     $this->c->createConfigFile($this->params);
     $this->c->applyConfigConstants();
     // install schema
     $base = $service->getModule('base');
     $status = $base->install();
     // schema was installed successfully
     if ($status === true) {
         //create admin user
         $cu = owa_coreAPI::getCurrentUser();
         $this->createAdminUser($cu->getUserData('email_address'), $cu->getUserData('real_name'));
         // create default site
         $this->createDefaultSite($this->getParam('domain'), $this->getParam('name'), $this->getParam('description'), $this->getParam('site_family'), $this->getParam('site_id'));
         // Persist install complete flag.
         $this->c->persistSetting('base', 'install_complete', true);
         $save_status = $this->c->save();
         if ($save_status === true) {
             $this->e->notice('Install Complete Flag added to configuration');
         } else {
             $this->e->notice('Could not persist Install Complete Flag to the Database');
         }
         $this->setView('base.installFinishEmbedded');
         // schema was not installed successfully
     } else {
         $this->e->notice('Aborting embedded install due to errors installing schema. Try dropping all OWA tables and try again.');
         return false;
     }
 }
Exemplo n.º 3
0
 function up()
 {
     // create admin user for embedded installs.
     // embedded installs did not create admin users until this release (v1.2.1)
     $cu = owa_coreAPI::getCurrentUser();
     $this->createAdminUser($cu->getUserData('email_address'));
     $ds = owa_coreAPI::entityFactory('base.domstream');
     $ret = $ds->createTable();
     if ($ret == true) {
         $this->e->notice('Domstream entity table created');
         return true;
     } else {
         $this->e->notice('Domstream entity table creation failed');
         return false;
     }
 }
 static function setEmailAddress($email_address, $event)
 {
     if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
         $cu = owa_coreAPI::getCurrentUser();
         return $cu->user->get('email_address');
     }
 }
 public static function createNonce($action)
 {
     $time = owa_coreAPI::getNonceTimeInterval();
     $cu = owa_coreAPI::getCurrentUser();
     $user_id = $cu->getUserData('user_id');
     $full_nonce = $time . $action . $user_id . 'owa_nonce';
     $nonce = substr(owa_coreAPI::saltedHash($full_nonce, 'nonce'), -12, 10);
     return $nonce;
 }
 function getCurrentUser()
 {
     return owa_coreAPI::getCurrentUser();
 }
Exemplo n.º 7
0
 /**
  * Must be called before all other event property setting functions
  */
 function pre()
 {
     // ENVIRONMENTAL PARAMS
     // check for no value
     // clean
     // apply default if necessary
     // filter
     // these should really be pulled from the service layer
     $this->event->set('timestamp', owa_coreAPI::getRequestTimestamp());
     $this->event->set('microtime', microtime());
     //set user agent
     if (!$this->event->get('HTTP_USER_AGENT')) {
         $this->event->set('HTTP_USER_AGENT', owa_coreAPI::getServerParam('HTTP_USER_AGENT'));
     }
     // filter user agent
     $this->event->set('HTTP_USER_AGENT', $this->eq->filter('user_agent', $this->event->get('HTTP_USER_AGENT')));
     // set http_host
     if (!$this->event->get('HTTP_HOST')) {
         $this->event->set('HTTP_HOST', owa_coreAPI::getServerParam('HTTP_HOST'));
     }
     //filter http_host
     $this->event->set('HTTP_HOST', $this->eq->filter('HTTP_HOST', $this->event->get('HTTP_HOST')));
     // set language
     if (!$this->event->get('language')) {
         $this->event->set('language', substr(owa_coreAPI::getServerParam('HTTP_ACCEPT_LANGUAGE'), 0, 5));
     }
     // filter language
     $this->event->set('language', $this->eq->filter('language', $this->event->get('language')));
     // Set Ip Address
     if (!$this->event->get('ip_address')) {
         $this->event->set('ip_address', owa_coreAPI::getServerParam('REMOTE_ADDR'));
     }
     $this->event->set('ip_address', $this->eq->filter('ip_address', $this->event->get('ip_address')));
     // Set host related properties
     if (!$this->event->get('REMOTE_HOST')) {
         $this->event->set('REMOTE_HOST', owa_coreAPI::getServerParam('REMOTE_HOST'));
     }
     //$teh = owa_trackingEventHelpers::getInstance();
     //$teh->setEnvironmentals( $this->event );
     /// REQUIRED PARAMS
     // check for value
     // clean based on type
     // filter
     // apply default value if necessary
     // set page type
     // moved
     if (!$this->event->get('page_type')) {
         $this->event->set('page_type', '(not set)');
     }
     //filter page type
     //moved
     $this->event->set('page_type', $this->eq->filter('page_type', $this->event->get('page_type')));
     // filter page_url
     //moved
     $this->event->set('page_url', $this->eq->filter('page_url', $this->event->get('page_url'), $this->event->get('site_id')));
     // Page title
     // moved
     if ($this->event->get('page_title')) {
         $page_title = owa_lib::utf8Encode(trim($this->event->get('page_title')));
     } else {
         $page_title = '(not set)';
     }
     $this->event->set('page_title', $this->eq->filter('page_title', $page_title));
     // needs key translation
     // translated,
     $this->event->set('days_since_first_session', $this->event->get('dsfs'));
     $this->event->set('days_since_prior_session', $this->event->get('dsps'));
     $this->event->set('num_prior_sessions', $this->event->get('nps'));
     // OPTIONAL PARAMS
     // filter http referer
     /* moved */
     if ($this->event->get('HTTP_REFERER')) {
         $this->event->set('HTTP_REFERER', $this->eq->filter('HTTP_REFERER', $this->event->get('HTTP_REFERER')));
     }
     // Filter the target url of clicks
     /* moved */
     if ($this->event->get('target_url')) {
         $this->event->set('target_url', $this->eq->filter('target_url', $this->event->get('target_url'), $this->event->get('site_id')));
     }
     /* moved */
     if ($this->event->get('source')) {
         $this->event->set('source', $this->eq->filter('source', trim(strtolower($this->event->get('source')))));
     }
     /* moved */
     if ($this->event->get('medium')) {
         $this->event->set('medium', $this->eq->filter('medium', trim(strtolower($this->event->get('medium')))));
     }
     // set session referer (the site that originally referer the visit)
     /* moved */
     if ($this->event->get('session_referer')) {
         $this->event->set('session_referer', $this->eq->filter('session_referer', $this->event->get('session_referer')));
     }
     $this->setCustomVariables();
     // DEPENDANT SETS
     // evaluate
     // produce value
     // filter
     // add default if required
     // Set all time related properties
     // depends on 'timestamp'
     /* moved */
     $this->setTimeProperties($this->event);
     /* moved */
     // set repeat visitor type flag visitor is not new.
     if (!$this->event->get('is_new_visitor')) {
         $this->event->set('is_repeat_visitor', true);
     } else {
         // properly cast this to a bool.
         $this->event->set('is_new_visitor', true);
     }
     /* moved */
     if (!$this->event->get('page_uri')) {
         $page_uri = $this->derivePageUri($this->event->get('page_url'));
     }
     $this->event->set('page_uri', $this->eq->filter('page_uri', $page_uri));
     // host properties
     /* mooved */
     $this->event->set('full_host', $this->eq->filter('full_host', $this->event->get('REMOTE_HOST'), $this->event->get('ip_address')));
     // required
     if (!$this->event->get('full_host')) {
         $this->event->set('full_host', '(not set)');
     }
     /* moved */
     $this->event->set('host', $this->eq->filter('host', $this->event->get('full_host'), $this->event->get('ip_address')));
     //required
     if (!$this->event->get('host')) {
         $this->event->set('host', '(not set)');
     }
     // Browser related properties
     // required
     $service = owa_coreAPI::serviceSingleton();
     $bcap = $service->getBrowscap();
     // Assume browser untill told otherwise
     /* moved */
     $this->event->set('is_browser', true);
     /* moved */
     $this->event->set('browser_type', $this->eq->filter('browser_type', $bcap->getUaFamily()));
     /* moved */
     if ($bcap->getUaVersion()) {
         $this->event->set('browser', $this->eq->filter('browser', $bcap->getUaVersion()));
     } else {
         $this->event->set('browser', $this->eq->filter('browser', '(unknown)'));
     }
     //Check for what kind of page request this is
     /* moved */
     if ($bcap->isRobot()) {
         $this->event->set('is_robot', true);
         $this->event->set('is_browser', false);
     }
     /* moved */
     $this->event->set('os', $this->eq->filter('operating_system', $bcap->getOsFamily(), $this->event->get('HTTP_USER_AGENT')));
     /*moved */
     if ($this->event->get('is_new_session')) {
         //mark entry page flag on current request
         $this->event->set('is_entry_page', true);
     }
     /* moved */
     $this->setGeolocation();
     // set prior page properties
     /* moved */
     if ($this->event->get('HTTP_REFERER')) {
         $referer_parse = owa_lib::parse_url($this->event->get('HTTP_REFERER'));
         if ($referer_parse['host'] === $page_parse['host']) {
             $this->event->set('prior_page', $this->eq->filter('prior_page', $this->event->get('HTTP_REFERER'), $this->event->get('site_id')));
         }
     }
     // set  search terms
     /* moved */
     $search_terms = $this->event->get('search_terms');
     if ($search_terms && $search_terms != '(not set)') {
         $this->event->set('search_terms', $this->eq->filter('search_terms', trim(strtolower($this->event->get('search_terms')))));
     }
     // ID GENERATION
     //set user agent id
     /* moved */
     $this->event->set('ua_id', owa_lib::setStringGuid($this->event->get('HTTP_USER_AGENT')));
     // set document/page id
     /* moved */
     if ($this->event->get('page_url')) {
         $this->event->set('document_id', owa_lib::setStringGuid($this->event->get('page_url')));
     }
     // Generate host_id
     /* moved */
     $this->event->set('host_id', owa_lib::setStringGuid($this->event->get('host')));
     // generate os_id
     /* moved */
     $this->event->set('os_id', owa_lib::setStringGuid($this->event->get('os')));
     /* moved */
     if ($this->event->get('campaign')) {
         $this->event->set('campaign_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('campaign')))));
     }
     /* moved */
     if ($this->event->get('ad')) {
         $this->event->set('ad_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('ad')))));
     }
     /* moved */
     if ($this->event->get('source')) {
         $this->event->set('source_id', owa_lib::setStringGuid($this->event->get('source')));
     }
     // set session referer (the site that originally referer the visit)
     /* moved */
     if ($this->event->get('session_referer')) {
         // generate referer_id for downstream handlers
         $this->event->set('referer_id', owa_lib::setStringGuid($this->event->get('session_referer')));
     }
     /* moved */
     if ($this->event->get('search_terms')) {
         $this->event->set('referring_search_term_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('search_terms')))));
     }
     // SHOULD BE A FILTER
     // record and filter personally identifiable info (PII)
     if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
         // set user name if one does not already exist on event
         /* moved */
         if (!$this->event->get('user_name') && owa_coreAPI::getSetting('base', 'log_owa_user_names')) {
             $cu = owa_coreAPI::getCurrentUser();
             $this->event->set('user_name', $cu->user->get('user_id'));
         }
         $this->event->set('user_name', $this->eq->filter('user_name', $this->event->get('user_name')));
         // set email_address if one does not already exist on event
         /* moved */
         if (!$this->event->get('email_address')) {
             $cu = owa_coreAPI::getCurrentUser();
             $this->event->set('email_address', $cu->user->get('email_address'));
         }
         $this->event->set('user_email', $this->eq->filter('user_email', $this->event->get('email_address')));
     }
     // anonymize Ip address
     if (owa_coreAPI::getSetting('base', 'anonymize_ips')) {
         $this->event->set('ip_address', $this->anonymizeIpAddress($this->event->get('ip_address')));
         $this->event->set('full_host', '(not set)');
     }
 }
 function setCurrentUser($role, $login_name = '')
 {
     $cu =& owa_coreAPI::getCurrentUser();
     $cu->setRole($role);
     $cu->setAuthStatus(true);
 }
Exemplo n.º 9
0
/**
 * OWA authentication filter method
 *
 * This filter function authenticates the user and populates the
 * the current user in OWA with the proper role, and allowed sites list.
 *
 * This method kicks in after all over OWA's built in auth methods have failed
 * in the owa_auth class.
 * 
 * @param 	$auth_status	boolean
 * @return	$auth_status	boolean
 */
function owa_wpAuthUser($auth_status)
{
    $current_user = wp_get_current_user();
    if ($current_user instanceof WP_User) {
        // logged in, authenticated
        $cu = owa_coreAPI::getCurrentUser();
        $cu->setAuthStatus(true);
        if (isset($current_user->user_login)) {
            $cu->setUserData('user_id', $current_user->user_login);
            owa_coreAPI::debug("Wordpress User_id: " . $current_user->user_login);
        }
        if (isset($current_user->user_email)) {
            $cu->setUserData('email_address', $current_user->user_email);
        }
        if (isset($current_user->first_name)) {
            $cu->setUserData('real_name', $current_user->first_name . ' ' . $current_user->last_name);
            $cu->setRole(owa_translate_role($current_user->roles));
        }
        owa_coreAPI::debug("Wordpress User Role: " . print_r($current_user->roles, true));
        owa_coreAPI::debug("Wordpress Translated OWA User Role: " . $cu->getRole());
        // fetch the list of allowed blogs from WP
        $domains = array();
        $allowedBlogs = get_blogs_of_user($current_user->ID);
        foreach ($allowedBlogs as $blog) {
            $domains[] = $blog->siteurl;
        }
        // check to see if we are installing before trying to load sites
        // other wise you run into a race condition as config file
        // might not be created.
        if (!defined('OWA_INSTALLING')) {
            // load assigned sites list by domain
            $cu->loadAssignedSitesByDomain($domains);
        }
        $cu->setInitialized();
        return true;
    } else {
        // not logged in to WP and therefor not authenticated
        return false;
    }
}
Exemplo n.º 10
0
/**
 * Populates OWA's current user object with info about the current mediawiki user.
 * This info is needed by OWA authentication system as well as to add dimensions
 * requests that are logged.
 */
function owa_mwAuthUser($auth_status)
{
    global $wgUser, $wgOwaSiteId;
    if ($wgUser->isLoggedIn()) {
        $cu = owa_coreAPI::getCurrentUser();
        $cu->setAuthStatus(true);
        $cu->setUserData('user_id', $wgUser->getName());
        $cu->setUserData('email_address', $wgUser->getEmail());
        $cu->setUserData('real_name', $wgUser->getRealName());
        $cu->setRole(owa_translate_role($wgUser->getGroups()));
        // set list of allowed sites. In this case it's only this wiki.
        $domains = array($wgOwaSiteId);
        // load assigned sites list by domain
        $cu->loadAssignedSitesByDomain($domains);
        $cu->setInitialized();
        return true;
    } else {
        // not logged in
        return false;
    }
}
 /**
  * Checks to see if the user credentials match a real user object in the DB
  *
  * @return boolean
  */
 function isUser()
 {
     // get current user
     $cu =& owa_coreAPI::getCurrentUser();
     // fetches user object from DB
     $this->getUser();
     if ($this->credentials['user_id'] === $this->u->get('user_id')) {
         if ($this->credentials['password'] === $this->u->get('password')) {
             $this->_is_user = true;
             // set as new current user in service layer
             $cu->loadNewUserByObject($this->u);
             $cu->setAuthStatus(true);
             return true;
         } else {
             $this->_is_user = false;
             return false;
         }
     } else {
         $this->_is_user = false;
         return false;
     }
 }
/**
 * Singleton Method
 *
 * Returns an instance of OWA
 *
 * @return $owa object
 */
function &owa_getInstance()
{
    static $owa;
    if (empty($owa)) {
        require_once OWA_BASE_CLASSES_DIR . 'owa_wp.php';
        // create owa instance w/ config
        $owa = new owa_wp();
        $owa->setSiteId(md5(get_settings('siteurl')));
        $owa->setSetting('base', 'report_wrapper', 'wrapper_wordpress.tpl');
        $owa->setSetting('base', 'link_template', '%s&%s');
        $owa->setSetting('base', 'main_url', '../wp-admin/index.php?page=owa');
        $owa->setSetting('base', 'main_absolute_url', get_bloginfo('url') . '/wp-admin/index.php?page=owa');
        $owa->setSetting('base', 'action_url', get_bloginfo('url') . '/index.php?owa_specialAction');
        $owa->setSetting('base', 'api_url', get_bloginfo('url') . '/index.php?owa_apiAction');
        $owa->setSetting('base', 'is_embedded', true);
        // needed as old installs might have this turned on by default...
        $owa->setSetting('base', 'delay_first_hit', false);
        // Access WP current user object to check permissions
        $current_user = owa_getCurrentWpUser();
        //print_r($current_user);
        // Set OWA's current user info and mark as authenticated so that
        // downstream controllers don't have to authenticate
        $cu =& owa_coreAPI::getCurrentUser();
        if (isset($current_user->user_login)) {
            $cu->setUserData('user_id', $current_user->user_login);
            owa_coreAPI::debug("Wordpress User_id: " . $current_user->user_login);
        }
        if (isset($current_user->user_email)) {
            $cu->setUserData('email_address', $current_user->user_email);
        }
        if (isset($current_user->first_name)) {
            $cu->setUserData('real_name', $current_user->first_name . ' ' . $current_user->last_name);
            $cu->setRole(owa_translate_role($current_user->roles));
        }
        owa_coreAPI::debug("Wordpress User Role: " . print_r($current_user->roles, true));
        owa_coreAPI::debug("Wordpress Translated OWA User Role: " . $cu->getRole());
        $cu->setAuthStatus(true);
    }
    return $owa;
}
 /**
  * Returns array of owa_site entities where the current user has access to, taken the current controller cap into account 
  * @return array
  */
 protected function getSitesAllowedForCurrentUser()
 {
     owa_coreAPI::debug('get Sites Allowed for user');
     $currentUser = owa_coreAPI::getCurrentUser();
     if ($currentUser->isAnonymousUser() || $currentUser->isAdmin()) {
         $result = array();
         $relations = owa_coreAPI::getSitesList();
         foreach ($relations as $siteRow) {
             $site = owa_coreAPI::entityFactory('base.site');
             owa_coreAPI::debug('getSitesAllowedforuser');
             $site->load($siteRow['id']);
             $result[$siteRow['site_id']] = $site;
         }
         return $result;
     } else {
         return $currentUser->getAssignedSites();
     }
 }
/**
 * OWA Singelton
 *
 * Needed to avoid OWA loading for every mediawiki request
 */
function owa_singleton()
{
    static $owa;
    if (empty($owa)) {
        global $wgUser, $wgServer, $wgScriptPath, $wgScript, $wgMainCacheType, $wgMemCachedServers, $wgOwaSiteId, $wgOwaMemCachedServers;
        /* OWA CONFIGURATION OVERRIDES */
        $owa_config = array();
        // check for memcache. these need to be passed into OWA to avoid race condition.
        if ($wgMainCacheType === CACHE_MEMCACHED) {
            $owa_config['cacheType'] = 'memcached';
            $owa_config['memcachedServers'] = $wgMemCachedServers;
        }
        $owa = new owa_mw($owa_config);
        $owa->setSetting('base', 'report_wrapper', 'wrapper_mediawiki.tpl');
        $owa->setSetting('base', 'main_url', $wgScriptPath . '/index.php?title=Special:Owa');
        $owa->setSetting('base', 'main_absolute_url', $wgServer . $owa->getSetting('base', 'main_url'));
        $owa->setSetting('base', 'action_url', $wgServer . $wgScriptPath . '/index.php?action=owa&owa_specialAction');
        $owa->setSetting('base', 'api_url', $wgServer . $wgScriptPath . '/index.php?action=owa&owa_apiAction');
        $owa->setSetting('base', 'link_template', '%s&%s');
        $owa->setSetting('base', 'is_embedded', true);
        $owa->setSetting('base', 'query_string_filters', 'returnto');
        $owa->setSetting('base', 'delay_first_hit', false);
        if (!$wgOwaSiteId) {
            $wgOwaSiteId = md5($wgServer . $wgScriptPath);
        }
        $owa->setSiteId($wgOwaSiteId);
        /**
         * Populates OWA's current user object with info about the current mediawiki user.
         * This info is needed by OWA authentication system as well as to add dimensions
         * requests that are logged.
         */
        $cu =& owa_coreAPI::getCurrentUser();
        $cu->setUserData('user_id', $wgUser->getName());
        $cu->setUserData('email_address', $wgUser->getEmail());
        $cu->setUserData('real_name', $wgUser->getRealName());
        $cu->setRole(owa_translate_role($wgUser->getGroups()));
        $cu->setAuthStatus(true);
    }
    return $owa;
}
 /**
  * Must be called before all other event property setting functions
  */
 function pre()
 {
     // Set all time related properties
     $this->event->setTime();
     // set repeat visitor type flag visitor is not new.
     if (!$this->event->get('is_new_visitor')) {
         $this->event->set('is_repeat_visitor', true);
     } else {
         // properly cast this to a bool.
         $this->event->set('is_new_visitor', true);
     }
     //set user agent
     if (!$this->event->get('HTTP_USER_AGENT')) {
         $this->event->set('HTTP_USER_AGENT', owa_coreAPI::getServerParam('HTTP_USER_AGENT'));
     }
     $this->event->set('HTTP_USER_AGENT', $this->eq->filter('user_agent', $this->event->get('HTTP_USER_AGENT')));
     //set user agent id
     $this->event->set('ua_id', owa_lib::setStringGuid($this->event->get('HTTP_USER_AGENT')));
     // filter http referer
     if ($this->event->get('HTTP_REFERER')) {
         $this->event->set('HTTP_REFERER', $this->eq->filter('HTTP_REFERER', $this->event->get('HTTP_REFERER')));
     }
     // set http_host
     if (!$this->event->get('HTTP_HOST')) {
         $this->event->set('HTTP_HOST', owa_coreAPI::getServerParam('HTTP_HOST'));
     }
     //filter http_host
     $this->event->set('HTTP_HOST', $this->eq->filter('HTTP_HOST', $this->event->get('HTTP_HOST')));
     // set language
     if (!$this->event->get('language')) {
         $this->event->set('language', substr(owa_coreAPI::getServerParam('HTTP_ACCEPT_LANGUAGE'), 0, 5));
     }
     // filter language
     $this->event->set('language', $this->eq->filter('language', $this->event->get('language')));
     // set page type to unknown if not already set by caller
     if (!$this->event->get('page_type')) {
         $this->event->set('page_type', '(not set)');
     }
     //filter page_type
     $this->event->set('page_type', $this->eq->filter('page_type', $this->event->get('page_type')));
     // Set the page url or else construct it from environmental vars
     if (!$this->event->get('page_url')) {
         $this->event->set('page_url', owa_lib::get_current_url());
     }
     // filter page_url
     $this->event->set('page_url', $this->eq->filter('page_url', $this->event->get('page_url'), $this->event->get('site_id')));
     // set document/page id
     $this->event->set('document_id', owa_lib::setStringGuid($this->event->get('page_url')));
     // needed?
     $this->event->set('inbound_page_url', $this->event->get('page_url'));
     // Page title
     if ($this->event->get('page_title')) {
         $page_title = owa_lib::utf8Encode(trim($this->event->get('page_title')));
     } else {
         $page_title = '(not set)';
     }
     $this->event->set('page_title', $this->eq->filter('page_title', $page_title));
     $page_parse = parse_url($this->event->get('page_url'));
     if (!array_key_exists('path', $page_parse) || empty($page_parse['path'])) {
         $page_parse['path'] = '/';
     }
     if (!$this->event->get('page_uri')) {
         if (array_key_exists('query', $page_parse) || !empty($page_parse['query'])) {
             $this->event->set('page_uri', $this->eq->filter('page_uri', sprintf('%s?%s', $page_parse['path'], $page_parse['query'])));
         } else {
             $this->event->set('page_uri', $this->eq->filter('page_uri', $page_parse['path']));
         }
     }
     // set session referer (the site that originally referer the visit)
     if ($this->event->get('session_referer')) {
         //filter session_referer
         $this->event->set('session_referer', $this->eq->filter('session_referer', $this->event->get('session_referer')));
         // generate referer_id for downstream handlers
         $this->event->set('referer_id', owa_lib::setStringGuid($this->event->get('session_referer')));
     }
     // set prior page properties
     if ($this->event->get('HTTP_REFERER')) {
         $referer_parse = owa_lib::parse_url($this->event->get('HTTP_REFERER'));
         if ($referer_parse['host'] === $page_parse['host']) {
             $this->event->set('prior_page', $this->eq->filter('prior_page', $this->event->get('HTTP_REFERER'), $this->event->get('site_id')));
         }
     }
     // set  search terms and id
     $search_terms = $this->event->get('search_terms');
     if ($search_terms && $search_terms != '(not set)') {
         $this->event->set('search_terms', $this->eq->filter('search_terms', trim(strtolower($this->event->get('search_terms')))));
         $this->event->set('referring_search_term_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('search_terms')))));
     }
     // Filter the target url of clicks
     if ($this->event->get('target_url')) {
         $this->event->set('target_url', $this->eq->filter('target_url', $this->event->get('target_url'), $this->event->get('site_id')));
     }
     // Set Ip Address
     if (!$this->event->get('ip_address')) {
         $this->event->set('ip_address', owa_coreAPI::getServerParam('REMOTE_ADDR'));
     }
     $this->event->set('ip_address', $this->eq->filter('ip_address', $this->event->get('ip_address')));
     // check to see if IP should be excluded
     if ($this->isIpAddressExcluded($this->event->get('ip_address'))) {
         $this->event->set('do_not_log', true);
         return;
     }
     // Set host related properties
     if (!$this->event->get('REMOTE_HOST')) {
         $this->event->set('REMOTE_HOST', owa_coreAPI::getServerParam('REMOTE_HOST'));
     }
     // host properties
     $this->event->set('full_host', $this->eq->filter('full_host', $this->event->get('REMOTE_HOST'), $this->event->get('ip_address')));
     if (!$this->event->get('full_host')) {
         $this->event->set('full_host', '(not set)');
     }
     $this->event->set('host', $this->eq->filter('host', $this->event->get('full_host'), $this->event->get('ip_address')));
     if (!$this->event->get('host')) {
         $this->event->set('host', '(not set)');
     }
     // Generate host_id
     $this->event->set('host_id', owa_lib::setStringGuid($this->event->get('host')));
     // Browser related properties
     $service = owa_coreAPI::serviceSingleton();
     $bcap = $service->getBrowscap();
     // Assume browser untill told otherwise
     $this->event->set('is_browser', true);
     $this->event->set('browser_type', $this->eq->filter('browser_type', $bcap->get('Browser')));
     if ($bcap->get('Version')) {
         $this->event->set('browser', $this->eq->filter('browser', $bcap->get('Browser') . ' ' . $bcap->get('Version')));
     } else {
         $this->event->set('browser', $this->eq->filter('browser', $bcap->get('Browser')));
     }
     // Set Operating System
     $this->event->set('os', $this->eq->filter('operating_system', $bcap->get('Platform'), $this->event->get('HTTP_USER_AGENT')));
     $this->event->set('os_id', owa_lib::setStringGuid($this->event->get('os')));
     //Check for what kind of page request this is
     if ($bcap->get('Crawler')) {
         $this->event->set('is_robot', true);
         $this->event->set('is_browser', false);
     }
     // feed request properties
     $et = $this->event->getEventType();
     if ($et === 'base.feed_request') {
         // Feed subscription tracking code
         if (!$this->event->get('feed_subscription_id')) {
             $this->event->set('feed_subscription_id', $this->getParam(owa_coreAPI::getSetting('base', 'feed_subscription_param')));
         }
         // needed??
         $this->event->set('feed_reader_guid', $this->event->setEnvGUID());
         // set feedreader flag to true, browser flag to false
         $this->event->set('is_feedreader', true);
         $this->event->set('is_browser', false);
     }
     // record and filter personally identifiable info (PII)
     if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
         // set user name if one does not already exist on event
         if (!$this->event->get('user_name') && owa_coreAPI::getSetting('base', 'log_owa_user_names')) {
             $cu = owa_coreAPI::getCurrentUser();
             $this->event->set('user_name', $cu->user->get('user_id'));
         }
         $this->event->set('user_name', $this->eq->filter('user_name', $this->event->get('user_name')));
         // set email_address if one does not already exist on event
         if (!$this->event->get('email_address')) {
             $cu = owa_coreAPI::getCurrentUser();
             $this->event->set('email_address', $cu->user->get('email_address'));
         }
         $this->event->set('user_email', $this->eq->filter('user_email', $this->event->get('email_address')));
     }
     $this->event->set('days_since_first_session', $this->event->get('dsfs'));
     $this->event->set('days_since_prior_session', $this->event->get('dsps'));
     $this->event->set('num_prior_sessions', $this->event->get('nps'));
     if ($this->event->get('is_new_session')) {
         //mark entry page flag on current request
         $this->event->set('is_entry_page', true);
     }
     if ($this->event->get('medium')) {
         $this->event->set('medium', $this->eq->filter('medium', trim(strtolower($this->event->get('medium')))));
     }
     if ($this->event->get('source')) {
         $this->event->set('source', $this->eq->filter('source', trim(strtolower($this->event->get('source')))));
         $this->event->set('source_id', owa_lib::setStringGuid($this->event->get('source')));
     }
     if ($this->event->get('campaign')) {
         $this->event->set('campaign_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('campaign')))));
     }
     if ($this->event->get('ad')) {
         $this->event->set('ad_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('ad')))));
     }
     $this->setCustomVariables();
     $this->setGeolocation();
     // anonymize Ip address
     if (owa_coreAPI::getSetting('base', 'anonymize_ips')) {
         $this->event->set('ip_address', $this->anonymizeIpAddress($this->event->get('ip_address')));
         $this->event->set('full_host', '(not set)');
     }
 }