/**
  * 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;
     }
 }
 /**
  * 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;
     }
 }
Exemplo n.º 3
0
 function setFromMap($map)
 {
     // normalize map
     $m = array('period' => false, 'startDate' => false, 'endDate' => false, 'startTime' => false, 'endTime' => false);
     $map = owa_lib::array_intersect_key($map, $m);
     // set default period if necessary
     if (empty($map['period']) && empty($map['startDate'])) {
         $this->is_default_period = true;
         $period = $this->getDefaultReportingPeriod();
     } elseif (empty($map['period']) && !empty($map['startDate']) && !empty($map['endDate'])) {
         $period = 'date_range';
     } else {
         $period = $map['period'];
     }
     //validate period value
     $valid = $this->isValid($period);
     if ($valid) {
         $this->period = $period;
     } else {
         $this->period = $this->getDefaultReportingPeriod();
         owa_coreAPI::debug("{$period} is not a valid period. Defaulting to default.");
     }
     $this->_setDates($map);
     $this->_setLabel($period);
     $this->_setDifferences();
 }
 /**
  * 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 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;
     }
 }
Exemplo n.º 6
0
 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.");
     }
 }
 /**
  * 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 createAdminUser($email_address, $real_name = '', $password = '')
 {
     //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)) {
             if (!$password) {
                 $password = $u->generateRandomPassword();
             }
             $ret = $u->createNewUser('admin', 'admin', $password, $email_address, $real_name);
             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 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 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()
 {
     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 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;
     }
 }
Exemplo n.º 14
0
 /**
  * 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;
     }
 }
Exemplo n.º 15
0
 function settingsSetFilter($value)
 {
     owa_coreAPI::debug('hello rom setFilter');
     $value = serialize($value);
     owa_coreAPI::debug($value);
     return $value;
 }
 /**
  * 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;
     }
 }
Exemplo n.º 17
0
 function sendMail()
 {
     if (!$this->mailer->Send()) {
         return $this->e->debug(sprintf("Mailer Failure. Was not able to send with subject of '%s'. Error Msgs: '%s'", $this->mailer->Subject, $this->mailer->ErrorInfo));
     } else {
         return owa_coreAPI::debug(sprintf("Mail sent with the subject of '%s'.", $this->mailer->Subject));
     }
 }
 function action()
 {
     if ($this->getParam('queues')) {
         $queues = $this->getParam('queues');
     } else {
         $queues = 'incoming_tracking_events,processing';
     }
     owa_coreAPI::notice("About to process event queues: {$queues}");
     // 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) {
             $q = owa_coreAPI::getEventQueue($queue_name);
             if ($q->connect()) {
                 $d = owa_coreAPI::getEventDispatch();
                 $more = true;
                 while ($more) {
                     owa_coreAPI::debug('calling receive message');
                     // get an item from the queue
                     $event = $q->receiveMessage();
                     owa_coreAPI::debug('Event returned: ' . print_r($event, true));
                     if ($event) {
                         // process event if needed
                         // lookup which event processor to use to process this event type
                         $processor_action = owa_coreAPI::getEventProcessor($event->getEventType());
                         if ($processor_action) {
                             // processor handles it's own event dispatching, so just return
                             return owa_coreAPI::handleRequest(array('event' => $event), $processor_action);
                         } else {
                             // dispatch event
                             $ret = $d->notify($event);
                         }
                         if ($ret = OWA_EHS_EVENT_HANDLED) {
                             // delete event from queue
                             // second param is for backwards compat. remove soon
                             $q->deleteMessage($event->getQueueGuid());
                         }
                     } else {
                         // if no event, stop the loop
                         $more = false;
                         owa_coreAPI::notice("No more events to process.");
                     }
                 }
                 $q->disconnect();
             }
         }
     } else {
         owa_coreAPI::notice("There are no event queues registered.");
     }
 }
Exemplo n.º 19
0
 function addToEventQueue()
 {
     if (!$this->event->get('do_not_log')) {
         //filter event
         $this->event = $this->eq->filter('post_processed_tracking_event', $this->event);
         owa_coreAPI::debug('Dispatching ' . $this->event->getEventType() . ' event with properties: ' . print_r($this->event->getProperties(), true));
         $this->eq->notify($this->event);
     } else {
         owa_coreAPI::debug("Not dispatching event due to 'do not log' flag being set.");
     }
 }
 function post()
 {
     if (owa_coreAPI::getSetting('base', 'delay_first_hit')) {
         // If not, then make sure that there is an inbound visitor_id
         if (!$this->event->get('visitor_id')) {
             // Log request properties to a cookie for processing by a second request and return
             owa_coreAPI::debug('Logging this request to first hit cookie.');
             return $this->log_first_hit();
         }
     }
     owa_coreAPI::debug('Logging ' . $this->event->getEventType() . ' to event queue...');
     return $this->addToEventQueue();
 }
Exemplo n.º 21
0
 function receiveMessage()
 {
     owa_coreAPI::debug('getting message');
     $msg = $this->getNextItem();
     if ($msg) {
         $event = $this->decodeMessage($msg->get('event'));
         $event->wasReceived();
         // backwards compat. remove soon.
         $event->setOldQueueId($msg->get('id'));
         // incrment the count of times the event has been receieved from the queue.
         // increment timesstamps of when last receieved
         $event->wasReceived();
         return $event;
     }
 }
 function isCapable($cap)
 {
     //owa_coreAPI::debug(print_r($this->user->getProperties(), true));
     owa_coreAPI::debug("cap " . $cap);
     // just in case there is no cap passed
     if (!empty($cap)) {
         //adding @ here as is_array throws warning that an empty array is not the right data type!
         if (in_array($cap, $this->capabilities)) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 function action()
 {
     $fh_state_name = owa_coreAPI::getSetting('base', 'first_hit_param');
     //print_r($fh_state_name);
     $fh = owa_coreAPI::getStateParam($fh_state_name);
     owa_coreAPI::debug('cookiename: ' . $fh_state_name);
     //owa_coreAPI::debug(print_r($_COOKIE, true));
     if (!empty($fh)) {
         $this->event->replaceProperties($fh);
         $this->event->setEventType('base.first_page_request');
         //owa_coreAPI::debug(print_r($this->event, true));
         // Delete first_hit Cookie
         owa_coreAPI::clearState($fh_state_name);
     }
     $this->setView('base.pixel');
     $this->setViewMethod('image');
 }
 /**
  * Notify handler method
  *
  * @param 	object	$event
  * @access 	public
  * @return	boolean
  */
 function notify($event)
 {
     $pk = $event->get('session_id');
     // just in case events slip thorugh that have no session_id
     // look for the original session id param
     if (!$pk) {
         $pk = $event->get('original_session_id');
         if ($pk) {
             $event->set('session_id', $pk);
         }
     }
     if ($event->get('session_id')) {
         $s = owa_coreAPI::entityFactory('base.session');
         $s->getByPk('id', $pk);
         $id = $s->get('id');
         if ($id) {
             // summarze the transaction
             $summary = owa_coreAPI::summarize(array('entity' => 'base.commerce_transaction_fact', 'columns' => array('id' => 'count', 'total_revenue' => 'sum', 'tax_revenue' => 'sum', 'shipping_revenue' => 'sum'), 'constraints' => array('session_id' => $id)));
             $s->set('commerce_trans_count', $summary['id_count']);
             $s->set('commerce_trans_revenue', $summary['total_revenue_sum']);
             $s->set('commerce_tax_revenue', $summary['tax_revenue_sum']);
             $s->set('commerce_shipping_revenue', $summary['shipping_revenue_sum']);
             // check for items and summarize if needed.
             $items = $event->get('ct_line_items');
             if (!empty($items)) {
                 $summary = owa_coreAPI::summarize(array('entity' => 'base.commerce_line_item_fact', 'columns' => array('sku' => 'count_distinct', 'item_revenue' => 'sum', 'quantity' => 'sum'), 'constraints' => array('session_id' => $id)));
                 $s->set('commerce_items_count', $summary['sku_dcount']);
                 $s->set('commerce_items_revenue', $summary['item_revenue_sum']);
                 $s->set('commerce_items_quantity', $summary['quantity_sum']);
             }
             $ret = $s->update();
             if ($ret) {
                 return OWA_EHS_EVENT_HANDLED;
             } else {
                 return OWA_EHS_EVENT_FAILED;
             }
         } else {
             owa_coreAPI::debug('Not Updating session commerce transaction properties. Session does not exist yet.');
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not Updating session commerce transaction properties. Session_id not present.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     // Make entity
     $f = owa_coreAPI::entityFactory('base.feed_request');
     $f->load($event->get('guid'));
     if (!$f->wasPersisted()) {
         // rekey Feed subscription id tracking code
         // @todo check the wordpress plugin to see if this is even needed
         if (!$event->get('feed_subscription_id')) {
             $event->set('feed_subscription_id', $event->get(owa_coreAPI::getSetting('base', 'feed_subscription_param')));
         }
         // needed??
         $event->set('feed_reader_guid', $event->setEnvGUID());
         // set feedreader flag to true, browser flag to false
         $event->set('is_feedreader', true);
         $event->set('is_browser', false);
         // set params on entity
         $f->setProperties($event->getProperties());
         // Set Primary Key
         $f->set('id', $event->get('guid'));
         // Make ua id
         $f->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT')));
         // Make OS id
         $f->set('os_id', owa_lib::setStringGuid($event->get('os')));
         // Make document id
         $f->set('document_id', owa_lib::setStringGuid($event->get('page_url')));
         // Generate Host id
         $f->set('host_id', owa_lib::setStringGuid($event->get('host')));
         $f->set('subscription_id', $event->get('feed_subscription_id'));
         // Persist to database
         $ret = $f->create();
         if ($ret) {
             $eq = owa_coreAPI::getEventDispatch();
             $nevent = $eq->makeEvent($event->getEventType() . '_logged');
             $nevent->setProperties($event->getProperties());
             $eq->notify($nevent);
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not persisting. Feed request already exists.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     $os = owa_coreAPI::entityFactory('base.os');
     $os->getByColumn('id', owa_lib::setStringGuid($event->get('os')));
     if (!$os->get('id')) {
         $os->set('name', $event->get('os'));
         $os->set('id', owa_lib::setStringGuid($event->get('os')));
         $ret = $os->create();
         if ($ret) {
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('Not persistig. Operating system already exists.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
 /**
  * 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;
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     $ua = owa_coreAPI::entityFactory('base.ua');
     $ua->getByColumn('id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT')));
     if (!$ua->get('id')) {
         $ua->setProperties($event->getProperties());
         $ua->set('ua', $event->get('HTTP_USER_AGENT'));
         $ua->set('id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT')));
         $ret = $ua->create();
         if ($ret) {
             return OWA_EHS_EVENT_HANDLED;
         } else {
             return OWA_EHS_EVENT_FAILED;
         }
     } else {
         owa_coreAPI::debug('not logging, user agent already exists.');
         return OWA_EHS_EVENT_HANDLED;
     }
 }
Exemplo n.º 29
0
 /**
  * Creates an instance of the ecoInsight metrics module
  **/
 function __construct()
 {
     $this->name = 'ecoinsight';
     $this->display_name = 'ecoInsight Metrics';
     $this->group = 'ecoinsight';
     $this->author = 'ecoInsight, Inc.';
     $this->version = '1.0';
     $this->description = 'Captures and process the ecoInsight service-oriented analytics and advertising-related.';
     $this->config_required = false;
     $this->required_schema_version = 1;
     owa_coreAPI::debug("Loading ecoInsight Module");
     // Time Dimensions (Needed for trend)
     $this->registerDimension('date', 'ecoinsight.eco_core', 'yyyymmdd', 'Date', 'time', 'The full date.', '', true, 'yyyymmdd');
     // Site Id (needed for Trend)
     $this->registerDimension('siteId', 'ecoinsight.eco_core', 'site_id', 'Site ID', 'site', 'The ID of the the web site.', '', true);
     // Session identifier
     $this->registerDimension('sessionId', 'ecoinsight.eco_core', 'session_id', 'Session ID', 'visit-special', 'The ID of the session/visit.', '', true);
     return parent::__construct();
 }
 /**
  * Notify Event Handler
  *
  * @param 	unknown_type $event
  * @access 	public
  */
 function notify($event)
 {
     if ($event->get('visitor_id')) {
         $v = owa_coreAPI::entityFactory('base.visitor');
         $v->load($event->get('visitor_id'));
         if ($v->wasPersisted()) {
             $v->set('num_prior_sessions', $this->summarizePriorSessions($v->get('id')));
             owa_coreAPI::debug("Updating... Visitor already exists.");
             $ret = $v->save();
             if ($ret) {
                 return OWA_EHS_EVENT_HANDLED;
             } else {
                 return OWA_EHS_EVENT_FAILED;
             }
         }
     } else {
         owa_coreAPI::debug("Not updating... no visitor ID present.");
         return OWA_EHS_EVENT_HANDLED;
     }
 }