Ejemplo n.º 1
0
 function action()
 {
     $service = owa_coreAPI::serviceSingleton();
     $im = owa_coreAPI::supportClassFactory('base', 'installManager');
     $this->e->notice('Starting OWA Install from command line.');
     //create config file
     $present = $this->c->isConfigFilePresent();
     if ($present) {
         $this->c->applyConfigConstants();
         // install schema
         $status = $im->installSchema();
         // schema was installed successfully
         if ($status === true) {
             //create admin user
             //owa_coreAPI::debug('password: '******'base', 'db_password') ) );
             $im->createAdminUser($this->getParam('email_address'), $this->getParam('real_name'), $this->c->get('base', 'db_password'));
             // create default site
             $im->createDefaultSite($this->getParam('domain'), $this->getParam('domain'), $this->getParam('description'), $this->getParam('site_family'));
             // Persist install complete flag.
             $this->c->persistSetting('base', 'install_complete', true);
             $save_status = $this->c->save();
             if ($save_status === true) {
                 $this->e->notice('Install Completed.');
             } else {
                 $this->e->notice('Could not persist Install Complete Flag to the Database');
             }
             // 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;
         }
     } else {
         $this->e->notice("Could not locate config file. Aborting installation.");
     }
 }
Ejemplo n.º 2
0
 function getBrowscap()
 {
     if (empty($this->browscap)) {
         $this->browscap = owa_coreAPI::supportClassFactory('base', 'browscap', $this->request->getServerParam('HTTP_USER_AGENT'));
     }
     return $this->browscap;
 }
 /**
  * Invokes the action for the reset controller.
  **/
 function action()
 {
     $appSettings = owa_coreAPI::supportClassFactory('ecoinsight', 'appSettings');
     $appSettings->reset();
     $this->e->notice($this->getMsg(2503));
     $this->setStatusCode(2503);
     $this->setRedirectAction('ecoinsight.generalSettings');
 }
Ejemplo n.º 4
0
 function action()
 {
     $sm = owa_coreAPI::supportClassFactory('base', 'siteManager');
     $ret = $sm->createNewSite($this->getParam('domain'), $this->getParam('name'), $this->getParam('description'), $this->getParam('site_family'));
     if ($ret) {
         owa_coreAPI::notice("Site added successfully. site_id: {$ret}");
     }
 }
Ejemplo n.º 5
0
 function action()
 {
     $this->params['domain'] = $this->params['protocol'] . $this->params['domain'];
     $sm = owa_coreAPI::supportClassFactory('base', 'siteManager');
     $ret = $sm->createNewSite($this->getParam('domain'), $this->getParam('name'), $this->getParam('description'), $this->getParam('site_family'));
     $this->setRedirectAction('base.sites');
     $this->set('status_code', 3202);
 }
 /**
  * Executes the controller behavior.
  **/
 function action()
 {
     $appSettings = owa_coreAPI::supportClassFactory('ecoinsight', 'appSettings');
     $this->data['configuration'] = $appSettings->getSettings();
     // add data to container
     $this->setView('base.options');
     $this->setSubview('ecoinsight.generalSettings');
 }
 function action()
 {
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $this->getParam('siteId'));
     $goal_number = $this->getParam('goalNumber');
     if (!$goal_number) {
         $goal_number = 1;
     }
     $goal = $gm->getGoal($goal_number);
     $funnel = $gm->getGoalFunnel($goal_number);
     if ($funnel) {
         $goal = $gm->getGoal($goal_number);
         // find required steps. build a constraint string.
         $required_step_constraints = '';
         $steps_count = count($funnel);
         for ($i = 1; $i <= $steps_count; $i++) {
             if (array_key_exists('is_required', $funnel[$i]) && $funnel[$i]['is_required'] === true) {
                 $required_step_constraints .= 'pagePath==' . $funnel[$i]['url'] . ',';
             }
         }
         $required_step_constraints = trim($required_step_constraints, ',');
         //print $required_step_constraints;
         // get total visits
         $total_visitors_rs = owa_coreAPI::executeApiCommand(array('period' => $this->get('period'), 'startDate' => $this->get('startDate'), 'endDate' => $this->get('endDate'), 'constraints' => $required_step_constraints, 'metrics' => 'visitors', 'do' => 'getResultSet', 'siteId' => $this->getParam('siteId')));
         //print_r($total_visitors_rs);
         $total_visitors = $total_visitors_rs->getAggregateMetric('visitors');
         //print "Total visits: $total_visitors";
         $this->set('total_visitors', $total_visitors);
         // get visits for each step
         // add goal url to steps array
         $funnel[] = array('url' => $goal['details']['goal_url'], 'name' => $goal['goal_name'], 'step_number' => $steps_count + 1);
         foreach ($funnel as $k => $step) {
             $operator = '==';
             $rs = owa_coreAPI::executeApiCommand(array('period' => $this->get('period'), 'startDate' => $this->get('startDate'), 'endDate' => $this->get('endDate'), 'metrics' => 'visitors', 'constraints' => 'pagePath' . $operator . $step['url'], 'do' => 'getResultSet', 'siteId' => $this->getParam('siteId')));
             $visitors = $rs->getAggregateMetric('visitors') ? $rs->getAggregateMetric('visitors') : 0;
             $funnel[$k]['visitors'] = $visitors;
             // backfill check in case there are more visitors to this step than were at prior step.
             if ($funnel[$k]['visitors'] <= $funnel[$k - 1]['visitors']) {
                 if ($funnel[$k - 1]['visitors'] > 0) {
                     $funnel[$k]['visitor_percentage'] = round($funnel[$k]['visitors'] / $funnel[$k - 1]['visitors'], 4) * 100 . '%';
                 } else {
                     $funnel[$k]['visitor_percentage'] = '0.00%';
                 }
             } else {
                 $funnel[$k]['visitor_percentage'] = '100%';
             }
         }
         //print_r($funnel);
         $goal_step = end($funnel);
         $goal_conversion_rate = round($goal_step['visitors'] / $total_visitors, 2) * 100 . '%';
         $this->set('goal_conversion_rate', $goal_conversion_rate);
         $this->set('funnel', $funnel);
     }
     // set view stuff
     $this->setSubview('base.reportGoalFunnel');
     $this->setTitle('Funnel Visualization:', 'Goal ' . $goal_number);
     $this->set('goal_number', $goal_number);
 }
 /**
  * Pre Action
  * Current user is fully authenticated and loaded by this point
  *
  */
 function pre()
 {
     $sites = $this->getSitesAllowedForCurrentUser();
     $this->set('sites', $sites);
     $this->set('currentSiteId', $this->getParam('siteId'));
     // pass full set of params to view
     $this->data['params'] = $this->params;
     // setup the time period object in $this->period
     $this->setPeriod();
     // check to see if the period is a default period. TODO move this ot view where needed.
     $this->set('is_default_period', $this->period->isDefaultPeriod());
     $this->setView('base.report');
     $this->setViewMethod('delegate');
     $this->dom_id = str_replace('.', '-', $this->getParam('do'));
     $this->data['dom_id'] = $this->dom_id;
     $this->data['do'] = $this->getParam('do');
     $nav = owa_coreAPI::getGroupNavigation('Reports');
     // setup tabs
     $siteId = $this->get('siteId');
     if ($siteId) {
         $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
         $tabs = array();
         $site_usage = array('tab_label' => 'Site Usage', 'metrics' => 'visits,pagesPerVisit,visitDuration,bounceRate,uniqueVisitors', 'sort' => 'visits-', 'trendchartmetric' => 'visits');
         $tabs['site_usage'] = $site_usage;
         // ecommerce tab
         if (owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) {
             $ecommerce = array('tab_label' => 'e-commerce', 'metrics' => 'visits,transactions,transactionRevenue,revenuePerVisit,revenuePerTransaction,ecommerceConversionRate', 'sort' => 'transactionRevenue-', 'trendchartmetric' => 'transactions');
             $tabs['ecommerce'] = $ecommerce;
         }
         $goal_groups = $gm->getActiveGoalGroups();
         if ($goal_groups) {
             foreach ($goal_groups as $group) {
                 $goal_metrics = 'visits';
                 $active_goals = $gm->getActiveGoalsByGroup($group);
                 if ($active_goals) {
                     foreach ($active_goals as $goal) {
                         $goal_metrics .= sprintf(',goal%sCompletions', $goal);
                     }
                 }
                 $goal_metrics .= ',goalValueAll';
                 $goal_group = array('tab_label' => $gm->getGoalGroupLabel($group), 'metrics' => $goal_metrics, 'sort' => 'goalValueAll-', 'trendchartmetric' => 'visits');
                 $name = 'goal_group_' . $group;
                 $tabs[$name] = $goal_group;
             }
         }
         $this->set('tabs', $tabs);
         $this->set('tabs_json', json_encode($tabs));
         if (!owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) {
             unset($nav['Ecommerce']);
         }
     }
     //$this->body->set('sub_nav', owa_coreAPI::getNavigation($this->get('nav_tab'), 'sub_nav'));
     $this->set('top_level_report_nav', $nav);
 }
Ejemplo n.º 9
0
 function __construct($params)
 {
     if (array_key_exists('event', $params) && !empty($params['event'])) {
         $this->event = $params['event'];
     } else {
         owa_coreAPI::debug("No event object was passed to controller.");
         $this->event = owa_coreAPI::supportClassFactory('base', 'event');
     }
     $this->eq = owa_coreAPI::getEventDispatch();
     return parent::__construct($params);
 }
Ejemplo n.º 10
0
 function action()
 {
     $siteId = $this->get('siteId');
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
     $goals = $gm->getAllGoals();
     $goal_groups = $gm->getAllGoalGroupLabels();
     $this->set('goals', $goals);
     $this->set('goal_groups', $goal_groups);
     $this->setView('base.options');
     $this->setSubView('base.optionsGoals');
     $this->set('siteId', $siteId);
 }
 function action()
 {
     $number = $this->getParam('goal_number');
     $siteId = $this->get('siteId');
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
     $goal = $gm->getGoal($number);
     $goal_groups = $gm->getAllGoalGroupLabels();
     $this->set('goal_groups', $goal_groups);
     $this->set('goal', $goal);
     $this->set('goal_number', $number);
     $this->set('siteId', $this->getParam('siteId'));
     $this->setView('base.options');
     $this->setSubView('base.optionsGoalEntry');
 }
 /**
  * Sends the email request notification.
  **/
 function sendNotificationRequest($event, $advertiser, $targetUrl)
 {
     $appSettings = owa_coreAPI::supportClassFactory('ecoinsight', 'appSettings');
     $url = $appSettings->getNotificationUrl();
     if ($url == '') {
         return false;
     }
     if (substr_compare($url, '/', -strlen('/'), strlen('/')) == 0) {
         $url = substr($url, 0, strlen($url) - 1);
     }
     owa_coreAPI::debug('Preparing to notify endpoint - ' . $url);
     // Open the connection
     $httpSession = curl_init();
     $data = $this->serializeRequest($event->get('guid'), $advertiser, $targetUrl, $event->get('user_name'), $event->get('user_email'));
     // Configure curl
     curl_setopt($httpSession, CURLOPT_URL, $url);
     curl_setopt($httpSession, CURLOPT_POST, 1);
     curl_setopt($httpSession, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($httpSession, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($httpSession, CURLOPT_POSTFIELDS, $data);
     curl_setopt($httpSession, CURLOPT_FAILONERROR, true);
     curl_setopt($httpSession, CURLOPT_HTTPHEADER, array("Content-Type: text/xml", "Content-length: " . strlen($data)));
     curl_setopt($httpSession, CURLOPT_SSL_VERIFYPEER, false);
     if (defined('ECO_HTTP_PROXY')) {
         curl_setopt($httpSession, CURLOPT_PROXY, ECO_HTTP_PROXY);
     }
     // Post the data
     $content = curl_exec($httpSession);
     $result = false;
     // If the response is 202 (Accepted), the notification has reached
     // the target server. If not, an error occured.
     // TODO: Log failures to a table for later retry or analysis.
     if (curl_getinfo($httpSession, CURLINFO_HTTP_CODE) != 202) {
         $msg = sprintf('Error occurred while sending notification: %s', curl_error($httpSession));
         owa_coreAPI::error($msg);
         owa_coreAPI::error(curl_getinfo($httpSession));
     } else {
         $result = true;
     }
     // Cleanup the connection.
     curl_close($httpSession);
     return $result;
 }
Ejemplo n.º 13
0
 function action()
 {
     $this->setSubview('base.reportGoals');
     $this->setTitle('Goals');
     $this->set('metrics', 'visits,goalCompletionsAll,goalConversionRateAll,goalAbandonRateAll,goalValueAll');
     $this->set('trendTitle', 'There were <*= this.d.resultSet.aggregates.goalCompletionsAll.formatted_value *> goals completed.');
     $this->set('trendChartMetric', 'goalCompletionsAll');
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $this->getParam('siteId'));
     $goals = $gm->getActiveGoals();
     if ($goals) {
         $goal_metrics = '';
         $goal_count = count($goals);
         $i = 1;
         foreach ($goals as $goal) {
             $goal_metrics .= 'goal' . $goal['goal_number'] . 'Completions';
             if ($i < $goal_count) {
                 $goal_metrics .= ',';
             }
             $i++;
         }
     }
     $this->set('goal_metrics', $goal_metrics);
 }
 function eventFactory()
 {
     return owa_coreAPI::supportClassFactory('base', 'event');
 }
 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;
     }
 }
Ejemplo n.º 16
0
 function getDomClicks($pageUrl, $siteId, $startDate, $endDate, $document_id = '', $period = '', $resultsPerPage = 100, $page = 1, $format = 'jsonp')
 {
     // Fetch document object
     $d = owa_coreAPI::entityFactory('base.document');
     if (!$document_id) {
         $eq = owa_coreAPI::getEventDispatch();
         $document_id = $d->generateId($eq->filter('page_url', urldecode($pageUrl), $siteId));
     }
     $d->getByColumn('id', $document_id);
     $rs = owa_coreAPI::supportClassFactory('base', 'paginatedResultSet');
     $db = owa_coreAPI::dbSingleton();
     $db->selectFrom('owa_click');
     $db->selectColumn("click_x as x,\r\n\t\t\t\t\t\t\tclick_y as y,\r\n\t\t\t\t\t\t\tpage_width,\r\n\t\t\t\t\t\t\tpage_height,\r\n\t\t\t\t\t\t\tdom_element_x,\r\n\t\t\t\t\t\t\tdom_element_y,\r\n\t\t\t\t\t\t\tposition");
     $db->orderBy('click_y', 'ASC');
     $db->where('document_id', $document_id);
     $db->where('site_id', $siteId);
     if ($period) {
         $p = owa_coreAPI::supportClassFactory('base', 'timePeriod');
         $p->set($period);
         $startDate = $p->startDate->get('yyyymmdd');
         $endDate = $p->endDate->get('yyyymmdd');
     }
     if ($startDate && $endDate) {
         $db->where('yyyymmdd', array('start' => $startDate, 'end' => $endDate), 'BETWEEN');
     }
     // pass limit to rs object if one exists
     $rs->setLimit($resultsPerPage);
     // pass page to rs object if one exists
     $rs->setPage($page);
     $results = $rs->generate($db);
     //$rs->resultsRows = $results;
     if ($format) {
         owa_lib::setContentTypeHeader($format);
         return $rs->formatResults($format);
     } else {
         return $rs;
     }
 }
 /**
  * pre action
  *
  */
 function pre()
 {
     // site lists
     $sites = owa_coreAPI::getSitesList();
     $this->set('sites', $sites);
     // set default siteId if none exists on request
     $site_id = $this->getParam('siteId');
     if (!$site_id) {
         $site_id = $this->getParam('site_id');
     }
     if (!$site_id) {
         $site_id = $sites[0]['site_id'];
     }
     $this->setParam('siteId', $site_id);
     // pass full set of params to view
     $this->data['params'] = $this->params;
     // set default period if necessary
     if (!$this->getParam('period') && !$this->getParam('startDate')) {
         $this->set('is_default_period', true);
         $period = 'last_seven_days';
         $this->params['period'] = $period;
     } elseif (!$this->getParam('period') && $this->getParam('startDate')) {
         $period = 'date_range';
         $this->params['period'] = $period;
     } else {
         $period = $this->getParam('period');
     }
     $this->setPeriod($period);
     $this->setView('base.report');
     $this->setViewMethod('delegate');
     $this->dom_id = str_replace('.', '-', $this->getParam('do'));
     $this->data['dom_id'] = $this->dom_id;
     $this->data['do'] = $this->getParam('do');
     // setup tabs
     $siteId = $this->get('siteId');
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
     $tabs = array();
     $site_usage = array('tab_label' => 'Site Usage', 'metrics' => 'visits,pagesPerVisit,visitDuration,bounceRate,uniqueVisitors', 'sort' => 'visits-');
     $tabs['site_usage'] = $site_usage;
     // ecommerce tab
     if (owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) {
         $ecommerce = array('tab_label' => 'e-commerce', 'metrics' => 'visits,transactions,transactionRevenue,revenuePerVisit,revenuePerTransaction,ecommerceConversionRate', 'sort' => 'transactionRevenue-');
         $tabs['ecommerce'] = $ecommerce;
     }
     $goal_groups = $gm->getActiveGoalGroups();
     if ($goal_groups) {
         foreach ($goal_groups as $group) {
             $goal_metrics = 'visits';
             $active_goals = $gm->getActiveGoalsByGroup($group);
             if ($active_goals) {
                 foreach ($active_goals as $goal) {
                     $goal_metrics .= sprintf(',goal%sCompletions', $goal);
                 }
             }
             $goal_metrics .= ',goalValueAll';
             $goal_group = array('tab_label' => $gm->getGoalGroupLabel($group), 'metrics' => $goal_metrics, 'sort' => 'goalValueAll-');
             $name = 'goal_group_' . $group;
             $tabs[$name] = $goal_group;
         }
     }
     $this->set('tabs', $tabs);
     $this->set('tabs_json', json_encode($tabs));
     //$this->body->set('sub_nav', owa_coreAPI::getNavigation($this->get('nav_tab'), 'sub_nav'));
     $nav = owa_coreAPI::getGroupNavigation('Reports');
     if (!owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) {
         unset($nav['Ecommerce']);
     }
     $this->set('top_level_report_nav', $nav);
 }
 function makeEvent($type = '')
 {
     $event = owa_coreAPI::supportClassFactory('base', 'event');
     if ($type) {
         $event->setEventType($type);
     }
     return $event;
 }
Ejemplo n.º 19
0
 function _setDates($map = array())
 {
     $time_now = owa_lib::time_now();
     $nowDate = owa_coreAPI::supportClassFactory('base', 'date');
     $nowDate->set(time(), 'timestamp');
     $start = '';
     $end = '';
     switch ($this->period) {
         case "today":
             $start = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']);
             $end = $start + 3600 * 24 - 1;
             break;
         case "last_24_hours":
             $end = $time_now['timestamp'];
             $start = $end - 3600 * 24;
             break;
         case "last_hour":
             $end = $time_now['timestamp'];
             $start = $end - 3600;
             break;
         case "last_half_hour":
             $end = $time_now['timestamp'];
             $start = $end - 1800;
             break;
         case "last_seven_days":
             //$end = mktime(0, 0, 0, $time_now['month'], $time_now['day']+1, $time_now['year']);
             $end = mktime(23, 59, 59, $time_now['month'], $time_now['day'], $time_now['year']);
             $start = $end - 3600 * 24 * 7;
             break;
         case "this_week":
             $end = mktime(23, 59, 59, $time_now['month'], $time_now['day'], $time_now['year']) + (6 - $nowDate->get('day_of_week')) * 3600 * 24;
             $start = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']) - $nowDate->get('day_of_week') * 3600 * 24;
             break;
         case "this_month":
             $start = mktime(0, 0, 0, $time_now['month'], 1, $time_now['year']);
             $end = mktime(23, 59, 59, $time_now['month'], $nowDate->get('num_days_in_month'), $time_now['year']);
             break;
         case "this_year":
             $start = mktime(0, 0, 0, 1, 1, $time_now['year']);
             $end = mktime(23, 59, 59, 12, 31, $time_now['year']);
             break;
         case "yesterday":
             $end = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']);
             $start = $end - 3600 * 24;
             $end = $end - 1;
             break;
         case "last_week":
             $day = $time_now['day'] - $time_now['dayofweek'] - 7;
             $start = mktime(0, 0, 0, $time_now['month'], $day, $time_now['year']);
             $end = $start + 3600 * 24 * 7;
             break;
         case "last_month":
             $month = $time_now['month'] - 1;
             $start = mktime(0, 0, 0, $month, 1, $time_now['year']);
             $last = owa_coreAPI::supportClassFactory('base', 'date');
             $last->set($start, 'timestamp');
             $end = mktime(23, 59, 59, $last->get('month'), $last->get('num_days_in_month'), $last->get('year'));
             break;
         case "last_year":
             $year = $time_now['year'] - 1;
             $start = mktime(0, 0, 0, 1, 1, $year);
             $end = mktime(23, 59, 59, 12, 31, $year);
             break;
         case "same_day_last_week":
             $start = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']) - 3600 * 24 * 7;
             $end = $start + 3600 * 24 - 1;
             break;
             ///
         ///
         case "same_month_last_year":
             $year = $time_now['year'] - 1;
             $month = $time_now['month'];
             $start = mktime(0, 0, 0, $month, 1, $year);
             $last = owa_coreAPI::supportClassFactory('base', 'date');
             $last->set($start, 'timestamp');
             $end = mktime(23, 59, 59, $month, $last->get('num_days_in_month'), $year);
             break;
         case "all_time":
             $end = time();
             $start = mktime(0, 0, 0, 1, 1, 1969);
             break;
         case "last_thirty_days":
             $end = mktime(23, 59, 59, $time_now['month'], $time_now['day'], $time_now['year']);
             $start = $end + 1 - 30 * 3600 * 24;
             break;
         case "date_range":
             list($year, $month, $day) = sscanf($map['startDate'], "%4d%2d%2d");
             $start = mktime(0, 0, 0, $month, $day, $year);
             list($year, $month, $day) = sscanf($map['endDate'], "%4d%2d%2d");
             $end = mktime(23, 59, 59, $month, $day, $year);
             break;
         case "time_range":
             $start = $map['startTime'];
             $end = $map['endTime'];
             break;
         case "day":
             list($year, $month, $day) = sscanf($map['startDate'], "%4d%2d%2d");
             $start = mktime(0, 0, 0, $month, $day, $year);
             $end = mktime(23, 59, 59, $month, $day, $year);
             break;
     }
     $this->startDate->set($start, 'timestamp');
     $this->endDate->set($end, 'timestamp');
 }
 function errorAction()
 {
     $goal = $this->getParam('goal');
     $this->setView('base.options');
     $this->setSubview('base.optionsGoalEntry');
     $this->set('error_code', 3311);
     $this->set('goal', $goal);
     $this->set('goal_number', $goal['goal_number']);
     $siteId = $this->get('siteId');
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
     $this->set('goal_groups', $gm->getAllGoalGroupLabels());
 }
Ejemplo n.º 21
0
 /**
  * Logs tracking event from url params taken from request scope.
  * Takes event type from url.
  *
  * @return unknown
  */
 function logEventFromUrl($manage_state = false)
 {
     // keeps php executing even if the client closes the connection
     ignore_user_abort(true);
     $service =& owa_coreAPI::serviceSingleton();
     $service->request->decodeRequestParams();
     $event = owa_coreAPI::supportClassFactory('base', 'event');
     $event->setEventType(owa_coreAPI::getRequestParam('event_type'));
     $event->setProperties($service->request->getAllOwaParams());
     // check for third party cookie mode.
     $mode = owa_coreAPI::getRequestParam('thirdParty');
     if ($mode) {
         return $this->trackEvent($event);
     } else {
         return owa_coreAPI::logEvent($event->getEventType(), $event);
     }
 }
 /**
  * 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, '&gt;')) {
                     $v = str_replace("&gt;", ">", $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;
     }
 }
Ejemplo n.º 23
0
 public static function getGoalManager($siteId)
 {
     static $gm;
     if (!$gm) {
         $gm = array();
     }
     if (!isset($gm[$siteId])) {
         $gm[$siteId] = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
     }
     return $gm[$siteId];
 }
 function createValidator()
 {
     $this->v = owa_coreAPI::supportClassFactory('base', 'validator');
     return;
 }
 function checkForConversion($event)
 {
     $goal_info = array('conversion' => '', 'value' => '', 'start' => '');
     $siteId = $event->get('siteId');
     if (!$siteId) {
         $siteId = $event->get('site_id');
     }
     $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
     $goals = $gm->getActiveGoals();
     owa_coreAPI::debug('active goals: ' . print_r($goals, true));
     if (empty($goals)) {
         return;
     }
     $is_match = false;
     foreach ($goals as $num => $goal) {
         if (!empty($goal)) {
             if (array_key_exists('goal_status', $goal) && $goal['goal_status'] === 'active') {
                 switch ($goal['goal_type']) {
                     case 'url_destination':
                         $match = $this->checkUrlDestinationGoal($event, $goal);
                         $start = $this->checkGoalStart($event, $goal);
                         break;
                     case 'pages_per_visit':
                         $match = $this->checkPagesPerVisitGoal($event, $goal);
                         break;
                     case 'visit_duration':
                         $match = $this->checkPagesPerVisitGoal($event, $goal);
                         break;
                 }
                 if ($match) {
                     $goal_info['conversion'] = $match;
                 }
                 if ($start) {
                     $goal_info['start'] = $start;
                 }
                 //check for dynamic value from commerce transaction
                 if ($event->get('ct_total')) {
                     $goal_value = $event->get('ct_total');
                 } else {
                     // else just use the static value if one is set.
                     if (array_key_exists('goal_value', $goal)) {
                         $goal_value = $goal['goal_value'];
                     }
                 }
                 $goal_info['value'] = $goal_value;
             } else {
                 owa_coreAPI::debug("Goal {$num} not active.");
             }
         }
     }
     owa_coreAPI::debug('conversion info: ' . print_r($goal_info, true));
     return $goal_info;
 }
Ejemplo n.º 26
0
function owa_createTrackedSiteForNewBlog($blog_id, $user_id, $domain, $path, $site_id, $meta)
{
    $owa = owa_getInstance();
    $sm = owa_coreAPI::supportClassFactory('base', 'siteManager');
    $sm->createNewSite($domain, $domain, '', '');
}
 /**
  * Creates an instance of owa_adserver.
  **/
 function __construct()
 {
     $this->settings = owa_coreAPI::supportClassFactory('ecoinsight', 'appSettings');
 }
 /**
  * Generates a result set for the metric
  *
  */
 function getResults()
 {
     // get paginated result set object
     $rs = owa_coreAPI::supportClassFactory('base', 'paginatedResultSet');
     $bm = $this->chooseBaseEntity();
     if ($bm) {
         $bname = $bm->getName();
         owa_coreAPI::debug("Using {$bname} as base entity for making result set.");
         // set constraints
         $this->applyJoins();
         owa_coreAPI::debug('about to apply constraints');
         $this->applyConstraints();
         owa_coreAPI::debug('about to apply selects');
         $this->applySelects();
         // set from table
         if ($this->segment) {
             $this->db->selectFrom($this->generateSegmentQuery($bm), $bm->getTableAlias());
         } else {
             $this->db->selectFrom($bm->getTableName(), $bm->getTableAlias());
         }
         // generate aggregate results
         $results = $this->db->getOneRow();
         // merge into result set
         if ($results) {
             $rs->aggregates = array_merge($this->applyMetaDataToSingleResultRow($results), $rs->aggregates);
         }
         // setup dimensional query
         if (!empty($this->dimensions)) {
             $this->applyJoins();
             // apply dimensional SQL
             $this->applyDimensions();
             $this->applySelects();
             // set from table
             if ($this->segment) {
                 $this->db->selectFrom($this->generateSegmentQuery($bm), $bm->getTableAlias());
             } else {
                 $this->db->selectFrom($bm->getTableName(), $bm->getTableAlias());
             }
             // pass limit to db object if one exists
             if (!empty($this->limit)) {
                 $rs->setLimit($this->limit);
             }
             // pass limit to db object if one exists
             if (!empty($this->page)) {
                 $rs->setPage($this->page);
             }
             $this->applyConstraints();
             if (array_key_exists('orderby', $this->params)) {
                 $sorts = $this->params['orderby'];
                 // apply sort by
                 if ($sorts) {
                     $this->applySorts();
                     foreach ($sorts as $sort) {
                         //$this->db->orderBy($sort[0], $sort[1]);
                         $rs->sortColumn = $sort[0];
                         if (isset($sort[1])) {
                             $rs->sortOrder = strtolower($sort[1]);
                         } else {
                             $rs->sortOrder = 'asc';
                         }
                     }
                 }
             }
             // add labels
             $rs->setLabels($this->getLabels());
             // generate dimensonal results
             $results = $rs->generate($this->db);
             $rs->resultsRows = $this->applyMetaDataToResults($results);
         }
         // add labels
         $rs->setLabels($this->getLabels());
         // add period info
         $rs->setPeriodInfo($this->params['period']->getAllInfo());
         $rs = $this->computeCalculatedMetrics($rs);
         // add urls
         $urls = $this->makeResultSetUrls();
         $rs->self = $urls['self'];
         if ($rs->more) {
             $rs->next = $urls['next'];
         }
         if ($this->page >= 2) {
             $rs->previous = $urls['previous'];
         }
         $rs->createResultSetHash();
     }
     $rs->errors = $this->errors;
     $rs->setRelatedDimensions($this->getAllRelatedDimensions($bm));
     $rs->setRelatedMetrics($this->getAllRelatedMetrics($bm));
     return $rs;
 }