function render($data)
 {
     //page title
     $this->t->set('page_title', 'Configuration File Generator');
     // load body template
     $this->body->set('config', $this->get('config'));
     $this->body->set_template('install_config_entry.php');
     // prepopulate the public url based on the current url.
     $public_url = owa_lib::get_current_url();
     $pos = strpos($public_url, 'install.php');
     $public_url = substr($public_url, 0, $pos);
     $this->body->set('public_url', $public_url);
 }
 function notAuthenticatedAction()
 {
     $this->setRedirectAction('base.loginForm');
     $this->set('go', urlencode(owa_lib::get_current_url()));
 }
 /**
  * Constructor
  * 
  */
 function __construct()
 {
     $this->timestamp = time();
     $this->guid = owa_lib::generateRandomUid();
     // php's server variables
     $this->server = $_SERVER;
     // files
     if (!empty($_FILES)) {
         $this->files = $_FILES;
     }
     // setup cookies
     $this->cookies = array();
     // look for access to the raw HTTP cookie string. This is needed becuause OWA can set settings cookies
     // with the same name under different subdomains. Multiple cookies with the same name are not
     // available under $_COOKIE. Therefor OWA's cookie conainter must be an array of arrays.
     if (isset($_SERVER['HTTP_COOKIE']) && strpos($_SERVER['HTTP_COOKIE'], ';')) {
         $raw_cookie_array = explode(';', $_SERVER['HTTP_COOKIE']);
         foreach ($raw_cookie_array as $raw_cookie) {
             $nvp = explode('=', trim($raw_cookie));
             $this->cookies[$nvp[0]][] = urldecode($nvp[1]);
         }
     } else {
         // just use the normal cookie global
         if ($_COOKIE && is_array($_COOKIE)) {
             foreach ($_COOKIE as $n => $v) {
                 // hack against other frameworks sanitizing cookie data and blowing away our '>' delimiter
                 // this should be removed once all cookies are using json format.
                 if (strpos($v, '>')) {
                     $v = str_replace(">", ">", $v);
                 }
                 $cookies[$n][] = $v;
             }
         }
     }
     // populate owa_cookie container with just the cookies that have the owa namespace.
     $this->owa_cookies = owa_lib::stripParams($this->cookies, owa_coreAPI::getSetting('base', 'ns'));
     // session
     if (!empty($_SESSION)) {
         $this->session = $_SESSION;
     }
     /* STATE CONTAINER */
     // state
     $this->state = owa_coreAPI::supportClassFactory('base', 'state');
     // merges session
     if (!empty($this->session)) {
         $this->state->addStores(owa_lib::stripParams($this->session, owa_coreAPI::getSetting('base', 'ns')));
     }
     // merges cookies
     foreach ($this->owa_cookies as $k => $owa_cookie) {
         $this->state->setInitialState($k, $owa_cookie);
     }
     // create request params from GET or POST or CLI args
     $params = array();
     // use GET vars as the base for the request
     if (isset($_GET) && !empty($_GET)) {
         // get params from _GET
         $params = $_GET;
         $this->request_type = 'get';
     }
     // merge in POST vars. GET and POST can occure on the same request.
     if (isset($_POST) && !empty($_POST)) {
         // get params from _GET
         $params = array_merge($params, $_POST);
         $this->request_type = 'post';
     }
     // look for command line arguments in the 'argv' index.
     if (!$this->request_type && isset($_SERVER['argv'])) {
         $this->cli_args = $_SERVER['argv'];
         // parse arguments into key value pairs
         for ($i = 1; $i < count($this->cli_args); $i++) {
             $it = explode("=", $this->cli_args[$i]);
             if (isset($it[1])) {
                 $params[$it[0]] = $it[1];
             } else {
                 $params[$it[0]] = '';
             }
         }
         $this->request_type = 'cli';
     }
     if ($this->request_type === 'get' || $this->request_type === 'post') {
         $this->current_url = owa_lib::get_current_url();
     }
     // Clean Input arrays
     $this->request = owa_lib::inputFilter($params);
     // get namespace
     $ns = owa_coreAPI::getSetting('base', 'ns');
     // strip action and do params of nasty include exploits.
     if (array_key_exists($ns . 'action', $this->request)) {
         $this->request[$ns . 'action'] = owa_lib::fileInclusionFilter($this->request[$ns . 'action']);
     }
     if (array_key_exists($ns . 'do', $this->request)) {
         $this->request[$ns . 'do'] = owa_lib::fileInclusionFilter($this->request[$ns . 'do']);
     }
     // strip owa namespace
     $this->owa_params = owa_lib::stripParams($this->request, $ns);
     // translate certain request variables that are reserved in javascript
     $this->owa_params = owa_lib::rekeyArray($this->owa_params, array_flip(owa_coreAPI::getSetting('base', 'reserved_words')));
     // set https flag
     if (isset($_SERVER['HTTPS'])) {
         $this->is_https = true;
     }
 }
 /**
  * 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)');
     }
 }
Example #5
0
ignore_user_abort(true);
// turn off gzip compression
if (function_exists('apache_setenv')) {
    apache_setenv('no-gzip', 1);
}
ini_set('zlib.output_compression', 0);
// turn on output buffering if necessary
if (ob_get_level() == 0) {
    ob_start();
}
// removing any content encoding like gzip etc.
header('Content-encoding: none', true);
//check to se if request is a POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // redirect to blank.php
    owa_lib::redirectBrowser(str_replace('log.php', 'blank.php', owa_lib::get_current_url()));
    // necessary or else buffer is not actually flushed
    echo ' ';
} else {
    // return 1x1 pixel gif
    header("Content-type: image/gif");
    // needed to avoid cache time on browser side
    header("Content-Length: 42");
    header("Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate");
    header("Expires: Wed, 11 Jan 2000 12:59:00 GMT");
    header("Last-Modified: Wed, 11 Jan 2006 12:59:00 GMT");
    header("Pragma: no-cache");
    echo sprintf('%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%', 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
}
// flush all output buffers. No reason to make the user wait for OWA.
ob_flush();