function action()
 {
     $site = owa_coreAPI::entityFactory('base.site');
     $site->delete($site->generateId($this->getParam('siteId')));
     $this->setRedirectAction('base.sites');
     $this->set('status_code', 3204);
 }
 function action()
 {
     $d = owa_coreAPI::entityFactory('base.document');
     if ($this->getParam('pageUrl')) {
         $pageUrl = $this->getParam('pageUrl');
         $d->getByColumn('url', $pageUrl);
         $this->set('constraints', 'pageUrl==' . urlencode($pageUrl));
         $title_slug = $pageUrl;
     }
     if ($this->getParam('pagePath')) {
         $pagePath = $this->getParam('pagePath');
         $d->getByColumn('uri', $pagePath);
         $this->set('constraints', 'pagePath==' . urlencode($pagePath));
         $title_slug = $pagePath;
     }
     if ($this->getParam('document_id')) {
         $did = $this->getParam('document_id');
         $d->load($did);
         $pagePath = $d->get('uri');
         $this->set('constraints', 'pagePath==' . urlencode($pagePath));
         $title_slug = $pagePath;
     }
     $this->setTitle('Dom Clicks: ', $title_slug);
     $this->set('document', $d);
     $this->setSubview('base.reportDomClicks');
     $this->set('metrics', 'domClicks');
     $this->set('sort', 'domClicks');
     $this->set('resultsPerPage', 30);
     $this->set('trendChartMetric', 'domClicks');
     $this->set('trendTitle', 'There were <*= this.d.resultSet.aggregates.domClicks.formatted_value *> dom clicks for this web page.');
 }
 function addToQueue($event)
 {
     if ($event) {
         $properties['owa_event'] = base64_encode(serialize($event));
         //$properties = array_map('urlencode', $properties);
         $properties = owa_lib::implode_assoc('=', '&', $properties);
         //print_r($properties);
         //return;
     } else {
         return;
     }
     $parts = parse_url($this->endpoint);
     $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30);
     if (!$fp) {
         return false;
     } else {
         $out = "POST " . $parts['path'] . " HTTP/1.1\r\n";
         $out .= "Host: " . $parts['host'] . "\r\n";
         $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
         $out .= "Content-Length: " . strlen($properties) . "\r\n";
         $out .= "Connection: Close\r\n\r\n";
         $out .= $properties;
         owa_coreAPI::debug("out: {$out}");
         fwrite($fp, $out);
         fclose($fp);
         return true;
     }
 }
 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;
     }
 }
 /**
  * Notify Handler
  *
  * @access 	public
  * @param 	object $event
  */
 function notify($event)
 {
     $c = owa_coreAPI::entityFactory('base.click');
     $c->load($event->get('guid'));
     if (!$c->wasPersisted()) {
         $c->set('id', $event->get('guid'));
         $c->setProperties($event->getProperties());
         $c->set('visitor_id', $event->get('visitor_id'));
         $c->set('session_id', $event->get('session_id'));
         $c->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT')));
         // Make document id
         $c->set('document_id', owa_lib::setStringGuid($event->get('page_url')));
         // Make Target page id
         $c->set('target_id', owa_lib::setStringGuid($c->get('target_url')));
         // Make position id used for group bys
         $c->set('position', $c->get('click_x') . $c->get('click_y'));
         $ret = $c->create();
         if ($ret) {
             // Tell others that "dom.click" has been logged
             $eq = owa_coreAPI::getEventDispatch();
             $nevent = $eq->makeEvent($event->getEventType() . '_logged');
             $nevent->setProperties($event->getProperties());
             $eq->asyncNotify($nevent);
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 function createAdminUser($email_address)
 {
     //create user entity
     $u = owa_coreAPI::entityFactory('base.user');
     // check to see if an admin user already exists
     $u->getByColumn('role', 'admin');
     $id_check = $u->get('id');
     // if not then proceed
     if (empty($id_check)) {
         //Check to see if user name already exists
         $u->getByColumn('user_id', 'admin');
         $id = $u->get('id');
         // Set user object Params
         if (empty($id)) {
             $password = $u->generateRandomPassword();
             $u->set('user_id', 'admin');
             $u->set('role', 'admin');
             $u->set('real_name', '');
             $u->set('email_address', $email_address);
             $u->set('password', owa_lib::encryptPassword($password));
             $u->set('creation_date', time());
             $u->set('last_update_date', time());
             $ret = $u->create();
             owa_coreAPI::debug("Admin user created successfully.");
             return $password;
         } else {
             owa_coreAPI::debug($this->getMsg(3306));
         }
     } else {
         owa_coreAPI::debug("Admin user already exists.");
     }
 }
 function action()
 {
     $s = owa_coreAPI::serviceSingleton();
     // lookup method class
     $do = $s->getApiMethodClass($this->getParam('do'));
     if ($do) {
         // check credentials
         /* PERFORM AUTHENTICATION */
         if (array_key_exists('required_capability', $do)) {
             /* CHECK USER FOR CAPABILITIES */
             if (!owa_coreAPI::isCurrentUserCapable($do['required_capability'])) {
                 // doesn't look like the currentuser has the necessary priviledges
                 owa_coreAPI::debug('User does not have capability required by this controller.');
                 // auth user
                 $auth =& owa_auth::get_instance();
                 $status = $auth->authenticateUser();
                 // if auth was not successful then return login view.
                 if ($status['auth_status'] != true) {
                     return 'This method requires authentication.';
                 } else {
                     //check for needed capability again now that they are authenticated
                     if (!owa_coreAPI::isCurrentUserCapable($do['required_capability'])) {
                         return 'Your user does not have privileges to access this method.';
                     }
                 }
             }
         }
         //perform
         $map = owa_coreAPI::getRequest()->getAllOwaParams();
         echo owa_coreAPI::executeApiCommand($map);
     }
 }
 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;
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     if ($event->get('ad')) {
         $d = owa_coreAPI::entityFactory('base.ad_dim');
         $new_id = $d->generateId(trim(strtolower($event->get('ad'))));
         $d->getByPk('id', $new_id);
         $id = $d->get('id');
         if (!$id) {
             $d->set('id', $new_id);
             $d->set('name', trim(strtolower($event->get('ad'))));
             $d->set('type', trim(strtolower($event->get('ad_type'))));
             $ret = $d->create();
             if ($ret) {
                 return OWA_EHS_EVENT_HANDLED;
             } else {
                 return OWA_EHS_EVENT_FAILED;
             }
         } else {
             owa_coreAPI::debug('Not Persisting. Ad already exists.');
             return OWA_EHS_EVENT_HANDLED;
         }
     } else {
         owa_coreAPI::debug('Noting to handle. No Ad properties found on event.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 /**
  * Notify method
  *
  * @param 	object $event
  * @access 	public
  */
 function notify($event)
 {
     $ds = owa_coreAPI::entityFactory('base.domstream');
     $ds->load($event->get('guid'));
     if (!$ds->wasPersisted()) {
         $ds->setProperties($event->getProperties());
         $ds->set('id', $event->get('guid'));
         $ds->set('domstream_guid', $event->get('domstream_guid'));
         $ds->set('document_id', $ds->generateId($event->get('page_url')));
         $ds->set('page_url', $event->get('page_url'));
         $ds->set('events', $event->get('stream_events'));
         $ds->set('duration', $event->get('duration'));
         $ret = $ds->create();
         if ($ret) {
             // Tell others that "dom.stream" has been logged
             $eq = owa_coreAPI::getEventDispatch();
             $nevent = $eq->makeEvent($event->getEventType() . '_logged');
             $nevent->setProperties($event->getProperties());
             $eq->asyncNotify($nevent);
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('No persisting. Domsteam  already exists.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 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;
 }
 function action()
 {
     $status = $this->installSchema();
     if ($status == true) {
         $this->set('status_code', 3305);
         $password = $this->createAdminUser($this->getParam('email_address'), '', $this->getParam('password'));
         $site_id = $this->createDefaultSite($this->getParam('protocol') . $this->getParam('domain'));
         // Set 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 add Install Complete Flag to configuration.');
         }
         // fire install complete event.
         $ed = owa_coreAPI::getEventDispatch();
         $event = $ed->eventFactory();
         $event->set('u', 'admin');
         $event->set('p', $password);
         $event->set('site_id', $site_id);
         $event->setEventType('install_complete');
         $ed->notify($event);
         // set view
         $this->set('u', 'admin');
         $this->set('p', $password);
         $this->set('site_id', $site_id);
         $this->setView('base.install');
         $this->setSubview('base.installFinish');
         //$this->set('status_code', 3304);
     } else {
         $this->set('error_msg', $this->getMsg(3302));
         $this->errorAction();
     }
 }
 function action()
 {
     if ($this->getParam('queues')) {
         $queues = $this->getParam('queues');
     } else {
         $queues = 'incoming_tracking_events,processing';
     }
     if ($this->getParam('interval')) {
         $interval = $this->getParam('interval');
     } else {
         $interval = 3600 * 24;
     }
     // pull list of event queues to process from command line
     $queues = $this->getParam('queues');
     if ($queues) {
         // parse command line
         $queues = explode(',', $this->getParam('queues'));
     } else {
         // get whatever queues are registered by modules
         $s = owa_coreAPI::serviceSingleton();
         $queues = array_keys($s->getMap('event_queues'));
     }
     if ($queues) {
         foreach ($queues as $queue_name) {
             owa_coreAPI::notice("About to prune archive of event queue: {$queue_name}");
             $q = owa_coreAPI::getEventQueue($queue_name);
             if ($q->connect()) {
                 $q->pruneArchive($interval);
             }
         }
     }
 }
 /**
  * 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()) {
         $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() . '_persisted');
             $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 up($force = false)
 {
     //$handle = fopen(OWA_DIR . 'owa-config.php', 'r+');
     $c = file_get_contents(OWA_DIR . 'owa-config.php');
     $ret = copy(OWA_DIR . 'owa-config.php', OWA_DIR . 'owa-config.php.backup.' . time());
     if ($ret === false) {
         $this->e->notice('A backup of your owa-config.php could not be created. Check permissions to ensure your main OWA directory is writable.');
         return false;
     }
     if ($c) {
         $n0 = "\n/**\n * AUTHENTICATION KEYS AND SALTS\n * \n * Change these to different unique phrases.\n */" . PHP_EOL . PHP_EOL;
         $n1 = "define('OWA_NONCE_KEY', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL;
         $n2 = "define('OWA_NONCE_SALT', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL;
         $n3 = "define('OWA_AUTH_KEY', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL;
         $n4 = "define('OWA_AUTH_SALT', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL . PHP_EOL;
         $ne = "?>";
         $value = $n0 . $n1 . $n2 . $n3 . $n4 . $ne;
         //fseek($handle, -1, SEEK_END);
         //$ret = fwrite($handle, $value);
         //fclose($handle);
         $c = str_replace('?>', $value, $c);
         $ret = file_put_contents(OWA_DIR . 'owa-config.php', $c);
         if ($ret === false) {
             $this->e->notice('owa-config.php could not be written to. Check permissions to ensure this file is writable.');
             return false;
         }
         $this->e->notice('Auth keys added to owa-config.php.');
         return true;
     } else {
         $this->e->notice('owa-config.php could not be read. check permissions to ensure this file is readable.');
         return false;
     }
 }
 function action()
 {
     $this->e->notice('About to delete handled events from database event queue.');
     $d = owa_coreAPI::getEventDispatch();
     $q = $d->getAsyncEventQueue('database');
     $this->e->notice('Events removed: ' . $q->flushHandledEvents());
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     // create entity
     $d = owa_coreAPI::entityFactory('base.document');
     // get document id from event
     $id = $event->get('document_id');
     // if no document_id present attempt to make one from the page_url property
     if (!$id) {
         $page_url = $event->get('page_url');
         if ($page_url) {
             $id = $d->generateId($page_url);
         } else {
             owa_coreAPI::debug('Not persisting Document, no page_url or document_id event property found.');
             return OWA_EHS_EVENT_HANDLED;
         }
     }
     $d->load($id);
     if (!$d->wasPersisted()) {
         $d->setProperties($event->getProperties());
         $d->set('url', $event->get('page_url'));
         $d->set('uri', $event->get('page_uri'));
         $d->set('id', $id);
         $ret = $d->create();
         if ($ret) {
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not logging Document, already exists');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 function settingsSetFilter($value)
 {
     owa_coreAPI::debug('hello rom setFilter');
     $value = serialize($value);
     owa_coreAPI::debug($value);
     return $value;
 }
 function action()
 {
     // Load the core API
     $api =& owa_coreAPI::singleton($this->params);
     if ($this->params['site_id']) {
         //get site labels
         $s = owa_coreAPI::entityFactory('base.site');
         $s->getByColumn('site_id', $this->getParam('site_id'));
         $this->set('site_name', $s->get('name'));
         $this->set('site_description', $s->get('description'));
     } else {
         $this->set('site_name', 'All Sites');
         $this->set('site_description', 'All Sites Tracked by OWA');
     }
     //setup Metrics
     $m = owa_coreApi::metricFactory('base.latestVisits');
     $m->setConstraint('site_id', $this->getParam('site_id'));
     $m->setPeriod($this->getPeriod());
     $m->setOrder(OWA_SQL_DESCENDING);
     $m->setLimit(15);
     $results = $m->generate();
     $this->set('latest_visits', $results);
     $this->setView('base.kmlVisitsGeolocation');
     return;
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     $terms = trim(strtolower($event->get('search_terms')));
     if ($terms) {
         $st = owa_coreAPI::entityFactory('base.search_term_dim');
         $st_id = owa_lib::setStringGuid($terms);
         $st->getByPk('id', $st_id);
         $id = $st->get('id');
         if (!$id) {
             $st->set('id', $st_id);
             $st->set('terms', $terms);
             $ret = str_replace("", "", $terms, $count);
             $st->set('term_count', $count);
             $ret = $st->create();
             if ($ret) {
                 return OWA_EHS_EVENT_HANDLED;
             } else {
                 return OWA_EHS_EVENT_FAILED;
             }
         } else {
             owa_coreAPI::debug('Not Logging. Search term already exists.');
             return OWA_EHS_EVENT_HANDLED;
         }
     } else {
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 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.");
     }
 }
 function action()
 {
     $document_id = '';
     // get period
     $p = $this->getPeriod();
     // check for limits
     if ($this->getParam('document_id') || $this->getParam('pageUrl') || $this->getParam('pagePath')) {
         $doc = owa_coreAPI::entityFactory('base.document');
         if ($this->getParam('pageUrl')) {
             $doc->getByColumn('url', $this->getParam('pageUrl'));
         } elseif ($this->getParam('pagePath')) {
             $doc->getByColumn('uri', $this->getParam('pagePath'));
         } else {
             $doc->load($this->getParam('document_id'));
         }
         $document_id = $doc->get('id');
         $this->setTitle('Domstream Recordings: ', $doc->get('url'));
         $this->set('document', $doc->_getProperties());
         $this->set('item_properties', $doc);
     } else {
         // latest domstream report
         $this->setTitle('Latest Domstreams');
     }
     $ds = owa_coreAPI::executeApiCommand(array('do' => 'getDomstreams', 'startDate' => $p->getStartDate()->getYyyymmdd(), 'endDate' => $p->getEndDate()->getYyyymmdd(), 'document_id' => $document_id, 'siteId' => $this->getParam('siteId'), 'page' => $this->getParam('page'), 'resultsPerPage' => 50, 'format' => $this->getParam('format')));
     $this->set('domstreams', $ds);
     //print_r($ds);
     // set view stuff
     $this->setSubview('base.reportDomstreams');
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     $v = owa_coreAPI::entityFactory('base.visitor');
     $v->load($event->get('visitor_id'));
     if (!$v->wasPersisted()) {
         $v->setProperties($event->getProperties());
         // Set Primary Key
         $v->set('id', $event->get('visitor_id'));
         $v->set('first_session_id', $event->get('session_id'));
         $v->set('first_session_year', $event->get('year'));
         $v->set('first_session_month', $event->get('month'));
         $v->set('first_session_day', $event->get('day'));
         $v->set('first_session_dayofyear', $event->get('dayofyear'));
         $v->set('first_session_timestamp', $event->get('timestamp'));
         $ret = $v->create();
         if ($ret) {
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug("Not persisting. Visitor already exists.");
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 function action()
 {
     // fetch list of modules that require updates
     $s =& owa_coreAPI::serviceSingleton();
     $modules = $s->getModulesNeedingUpdates();
     //print_r($modules);
     //return;
     // foreach do update in order
     $error = false;
     foreach ($modules as $k => $v) {
         $ret = $s->modules[$v]->update();
         if ($ret != true) {
             $error = true;
             // if there is an error check to see if it's because the cli update mode is required
             $cli_update_required = $s->modules[$v]->isCliUpdateModeRequired();
             break;
         }
     }
     if ($error === true) {
         if ($cli_update_required) {
             $this->set('error_msg', $this->getMsg(3311));
         } else {
             $this->set('error_msg', $this->getMsg(3307));
         }
         $this->setView('base.error');
         $this->setViewMethod('delegate');
     } else {
         // add data to container
         $this->set('status_code', 3308);
         $this->set('do', 'base.optionsGeneral');
         $this->setViewMethod('redirect');
     }
 }
 function sendMessage($event)
 {
     if ($event) {
         $properties = array();
         $properties['owa_event'] = $event->export();
     } else {
         return;
     }
     $parts = parse_url($this->endpoint);
     $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30);
     if (!$fp) {
         return false;
     } else {
         $content = http_build_query($properties);
         $out = "POST " . $parts['path'] . " HTTP/1.1\r\n";
         $out .= "Host: " . $parts['host'] . "\r\n";
         $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
         $out .= "Content-Length: " . strlen($content) . "\r\n";
         $out .= "Connection: Close\r\n\r\n";
         $out .= $content;
         fwrite($fp, $out);
         fclose($fp);
         owa_coreAPI::debug("out: {$out}");
         return true;
     }
 }
 /**
  * Notify Handler
  *
  * @access 	public
  * @param 	object $event
  */
 function notify($event)
 {
     $c = owa_coreAPI::entityFactory('base.click');
     $c->load($event->get('guid'));
     if (!$c->wasPersisted()) {
         $c->set('id', $event->get('guid'));
         $c->setProperties($event->getProperties());
         $c->set('visitor_id', $event->get('visitor_id'));
         $c->set('session_id', $event->get('session_id'));
         $c->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT')));
         // Make document id
         $c->set('document_id', owa_lib::setStringGuid($event->get('page_url')));
         // Make Target page id
         $c->set('target_id', owa_lib::setStringGuid($c->get('target_url')));
         // Make position id used for group bys
         $c->set('position', $c->get('click_x') . $c->get('click_y'));
         $ret = $c->create();
         if ($ret) {
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 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();
     }
 }
 function action()
 {
     $cu = owa_coreAPI::getCurrentUser();
     $this->set('go', $this->getParam('go'));
     $this->set('user_id', $cu->getUserData('user_id'));
     $this->setView('base.loginForm');
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     if ($event->get('source')) {
         $s = owa_coreAPI::entityFactory('base.source_dim');
         $new_id = $s->generateId(trim(strtolower($event->get('source'))));
         $s->getByPk('id', $new_id);
         $id = $s->get('id');
         if (!$id) {
             $s->set('id', $new_id);
             $s->set('source_domain', $event->get('source'));
             $ret = $s->create();
             if ($ret) {
                 return OWA_EHS_EVENT_HANDLED;
             } else {
                 return OWA_EHS_EVENT_FAILED;
             }
         } else {
             owa_coreAPI::debug('Not Persisting. Source already exists.');
             return OWA_EHS_EVENT_HANDLED;
         }
     } else {
         owa_coreAPI::debug('Noting to handle. No source properties found on event.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 /**
  * Notify Handler
  *
  * @access 	public
  * @param 	object $event
  */
 function notify($event)
 {
     $r = owa_coreAPI::entityFactory('base.request');
     $r->load($event->get('guid'));
     if (!$r->wasPersisted()) {
         $r->setProperties($event->getProperties());
         // Set Primary Key
         $r->set('id', $event->get('guid'));
         // Make prior document id
         $r->set('prior_document_id', owa_lib::setStringGuid($event->get('prior_page')));
         // Generate Host id
         $r->set('num_prior_sessions', $event->get('num_prior_sessions'));
         $result = $r->create();
         if ($result == true) {
             $eq = owa_coreAPI::getEventDispatch();
             $nevent = $eq->makeEvent($event->getEventType() . '_logged');
             $nevent->setProperties($event->getProperties());
             $eq->asyncNotify($nevent);
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not persisting. Request already exists.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }