"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "owa_coreAPI.php" between
Open-Web-Analytics-1.6.9.tar.gz and Open-Web-Analytics-1.7.0.tar.gz

About: Open Web Analytics (OWA) is web analytics software to track and analyze how people use your web sites and applications.

owa_coreAPI.php  (Open-Web-Analytics-1.6.9):owa_coreAPI.php  (Open-Web-Analytics-1.7.0)
skipping to change at line 54 skipping to change at line 54
if(!empty($params)): if(!empty($params)):
$api->params = $params; $api->params = $params;
endif; endif;
return $api; return $api;
} }
public static function setupStorageEngine($type) { public static function setupStorageEngine($type) {
if (!class_exists('owa_db')) { if ( ! class_exists( 'owa_db' ) ) {
require_once(OWA_BASE_CLASSES_DIR.'owa_db.php'); require_once(OWA_BASE_CLASSES_DIR.'owa_db.php');
} }
if ($type) { if ( $type ) {
$connection_class = "owa_db_" . $type;
$connection_class = "owa_db_" . $type; if ( ! class_exists( $connection_class ) ) {
if (!class_exists($connection_class)) {
$connection_class_path = OWA_PLUGIN_DIR.'db/' . $connection_clas s . ".php"; $connection_class_path = OWA_PLUGIN_DIR.'db/' . $connection_clas s . ".php";
if (!require_once($connection_class_path)) { if ( file_exists( $connection_class_path ) ) {
owa_coreAPI::error(sprintf('Cannot locate proper db class a
t %s.', $connection_class_path)); if ( ! require_once( $connection_class_path ) ) {
return false;
} owa_coreAPI::error(sprintf('Cannot locate proper db
} class at %s.', $connection_class_path));
return false;
}
} else {
owa_coreAPI::error("$type database connec
tion class file not found.");
}
}
} else {
owa_coreAPI::error("$type is not a supported database.");
} }
return true; return true;
} }
/** /**
* @return owa_db * @return owa_db
*/ */
public static function dbSingleton() { public static function dbSingleton() {
skipping to change at line 97 skipping to change at line 110
return $db; return $db;
} }
public static function dbFactory() { public static function dbFactory() {
$db_type = owa_coreAPI::getSetting('base', 'db_type'); $db_type = owa_coreAPI::getSetting('base', 'db_type');
$ret = owa_coreAPI::setupStorageEngine($db_type); $ret = owa_coreAPI::setupStorageEngine($db_type);
if (!$ret) { if (!$ret) {
owa_coreAPI::error(sprintf('Cannot locate proper db class at %s. Ex iting.', $connection_class_path)); owa_coreAPI::error(sprintf('Failed to intialise db of type %s. Exit ing.', $db_type));
return; return;
} else { } else {
$connection_class = 'owa_db_'.$db_type; $connection_class = 'owa_db_'.$db_type;
$db = new $connection_class( $db = new $connection_class(
owa_coreAPI::getSetting('base','db_host'), owa_coreAPI::getSetting('base','db_host'),
owa_coreAPI::getSetting('base','db_port'), owa_coreAPI::getSetting('base','db_port'),
owa_coreAPI::getSetting('base','db_name'), owa_coreAPI::getSetting('base','db_name'),
owa_coreAPI::getSetting('base','db_user'), owa_coreAPI::getSetting('base','db_user'),
owa_coreAPI::getSetting('base','db_password'), owa_coreAPI::getSetting('base','db_password'),
owa_coreAPI::getSetting('base','db_force_new_connections'), owa_coreAPI::getSetting('base','db_force_new_connections'),
skipping to change at line 764 skipping to change at line 777
if ( isset($module['is_active']) && $module['is_active'] == true) { if ( isset($module['is_active']) && $module['is_active'] == true) {
$active_modules[] = $k; $active_modules[] = $k;
} }
} }
return $active_modules; return $active_modules;
} }
public static function getPresentModules() {
$path = OWA_DIR.'modules';
// Check directory exists or not
if( file_exists($path) && is_dir($path)) {
// Scan the files in this directory
$result = scandir($path);
// Filter out the current (.) and parent (..) directories
$files = array_diff($result, array('.', '..', 'index.php'
));
owa_coreAPI::debug('Modules present are: ');
owa_coreAPI::debug( $files );
return $files;
}
}
public static function getModulesNeedingUpdates() { public static function getModulesNeedingUpdates() {
$service = owa_coreAPI::serviceSingleton(); $service = owa_coreAPI::serviceSingleton();
return $service->getModulesNeedingUpdates(); return $service->getModulesNeedingUpdates();
} }
/** /**
* Invokes controller to perform controller * Invokes controller to perform controller
* *
skipping to change at line 843 skipping to change at line 872
/** /**
* Logs an event to the event queue * Logs an event to the event queue
* *
* take an owa_event object as a message. * take an owa_event object as a message.
* *
* @param string $event_type * @param string $event_type
* @param object $message * @param object $message
* @return boolean * @return boolean
*/ */
public static function logEvent($event_type, $message = '') { public static function logEvent( $event_type, $message = '') {
// debug owa_coreAPI::debug("Logging new event $event_type");
owa_coreAPI::debug("logging event $event_type");
if (owa_coreAPI::getSetting('base', 'error_log_level') > 9) {
owa_coreAPI::debug("PHP Server Global: ".print_r($_SERVER, true));
}
// Check to see if named users should be logged // Check to see if named users should be logged
if (owa_coreAPI::getSetting('base', 'log_named_users') != true) { if (owa_coreAPI::getSetting('base', 'log_named_users') != true) {
$cu = owa_coreAPI::getCurrentUser(); $cu = owa_coreAPI::getCurrentUser();
$cu_user_id = $cu->getUserData('user_id'); $cu_user_id = $cu->getUserData('user_id');
if(!empty($cu_user_id)) { if( ! empty( $cu_user_id ) ) {
return false; return false;
} }
} }
// do not log if the request is robotic // backwads compatability with old style messages
$service = owa_coreAPI::serviceSingleton(); // @todo is this needed anymore?
$bcap = $service->getBrowscap(); $class= 'owa_event';
owa_coreAPI::profile(__CLASS__, __FUNCTION__, __LINE__);
if (!owa_coreAPI::getSetting('base', 'log_robots')) {
if ($bcap->robotCheck()) { if ( ! ( $message instanceof $class ) ) {
owa_coreAPI::debug("ABORTING: request appears to be from a robot
"); $event = owa_coreAPI::supportClassFactory( 'base', 'event' );
owa_coreAPI::setRequestParam('is_robot', true); $event->setProperties( $message );
return; $event->setEventType( $event_type );
}
owa_coreAPI::profile(__CLASS__, __FUNCTION__, __LINE__);
}
// form event if one was not passed
$class= 'owa_event';
if (!($message instanceof $class)) {
$event = owa_coreAPI::supportClassFactory('base', 'event');
$event->setProperties($message);
$event->setEventType($event_type);
} else { } else {
$event = $message; $event = $message;
} }
// STAGE 1 - set environmental properties from SERVER $service = owa_coreAPI::serviceSingleton();
// Tracking Event processing STAGE 1
// sets any necessary environmental properties from SERVER global
$teh = owa_coreAPI::getInstance( 'owa_trackingEventHelpers', OWA_BASE_CL ASS_DIR.'trackingEventHelpers.php'); $teh = owa_coreAPI::getInstance( 'owa_trackingEventHelpers', OWA_BASE_CL ASS_DIR.'trackingEventHelpers.php');
$environmentals = $service->getMap( 'tracking_properties_environmental' ); $environmentals = $service->getMap( 'tracking_properties_environmental' );
$teh->setTrackerProperties( $event, $environmentals ); $teh->setTrackerProperties( $event, $environmentals );
// Filter XSS exploits from event properties
//$event->cleanProperties();
// do not log if the do not log property is set on the event. // do not log if the do not log property is set on the event.
if ($event->get('do_not_log')) { if ($event->get('do_not_log')) {
return false; return false;
} }
// do not log if the request is robotic
owa_coreAPI::debug("Testing to see if event was generated by a robot");
owa_coreAPI::debug("User Agent: ". $message->get('HTTP_USER_AGENT') );
$bcap = $service->getBrowscap( $message->get('HTTP_USER_AGENT') );
if ( ! owa_coreAPI::getSetting('base', 'log_robots') ) {
if ( $bcap->robotCheck() ) {
owa_coreAPI::debug("ABORTING: request appears to be from a robot
");
owa_coreAPI::setRequestParam('is_robot', true);
return;
}
}
// check to see if IP should be excluded // check to see if IP should be excluded
if ( owa_coreAPI::isIpAddressExcluded( $event->get('ip_address') ) ) { if ( owa_coreAPI::isIpAddressExcluded( $event->get('ip_address') ) ) {
owa_coreAPI::debug("Not logging event. IP address found in exclusion list."); owa_coreAPI::debug("Not logging event. IP address found in exclusion list.");
return false; return false;
} }
// queue for later or process event straight away // queue for later or process event straight away
if ( owa_coreAPI::getSetting( 'base', 'queue_events' ) || if ( owa_coreAPI::getSetting( 'base', 'queue_events' ) ||
owa_coreAPI::getSetting( 'base', 'queue_incoming_tracking_events' ) ) { owa_coreAPI::getSetting( 'base', 'queue_incoming_tracking_events' ) ) {
$q = owa_coreAPI::getEventQueue( 'incoming_tracking_events' ); $q = owa_coreAPI::getEventQueue( 'incoming_tracking_events' );
owa_coreAPI::debug('Queuing '.$event->getEventType().' event with pr operties: '.print_r($event->getProperties(), true ) ); owa_coreAPI::debug('Queuing '.$event->getEventType().' event with pr operties: '.print_r($event->getProperties(), true ) );
$q->sendMessage( $event ); $q->sendMessage( $event );
} else { } else {
// lookup which event processor to use to process this event type // lookup which event processor to use to process this event type
$processor_action = owa_coreAPI::getEventProcessor( $event->getEvent Type() ); $processor_action = owa_coreAPI::getEventProcessor( $event->getEvent Type() );
return owa_coreAPI::handleRequest( array( 'event' => $event ), $proc
essor_action ); owa_coreAPI::debug('About to perform action: '.$processor
_action);
owa_coreAPI::debug($event);
return owa_coreAPI::performAction( $processor_action, arr
ay( 'event' => $event ) );
} }
} }
public static function getInstance( $class, $path ) { public static function getInstance( $class, $path ) {
if ( ! class_exists( $class ) ) { if ( ! class_exists( $class ) ) {
require_once( $path ); require_once( $path );
} }
skipping to change at line 1089 skipping to change at line 1128
return; return;
} }
public static function notice($msg) { public static function notice($msg) {
$e = owa_coreAPI::errorSingleton(); $e = owa_coreAPI::errorSingleton();
$e->notice($msg); $e->notice($msg);
return; return;
} }
public static function createCookie($cookie_name, $cookie_value, $expires = 0, $path = '/', $domain = '') { public static function createCookie($cookie_name, $cookie_value, $expires = 0, $path = '/; samesite=Lax', $domain = '') {
if ( $domain ) { if ( $domain ) {
// sanitizes the domain // sanitizes the domain
$domain = owa_lib::sanitizeCookieDomain( $domain ); $domain = owa_lib::sanitizeCookieDomain( $domain );
} else { } else {
$domain = owa_coreAPI::getSetting('base', 'cookie_domain'); $domain = owa_coreAPI::getSetting('base', 'cookie_domain');
} }
if (is_array($cookie_value)) { if (is_array($cookie_value)) {
$cookie_value = owa_lib::implode_assoc('=>', '|||', $cookie_value); $cookie_value = owa_lib::implode_assoc('=>', '|||', $cookie_value);
skipping to change at line 1733 skipping to change at line 1772
public static function getCurrentUrl() { public static function getCurrentUrl() {
$r = owa_coreAPI::requestContainerSingleton(); $r = owa_coreAPI::requestContainerSingleton();
return $r->getCurrentUrl(); return $r->getCurrentUrl();
} }
public static function isIpAddressExcluded( $ip_address ) { public static function isIpAddressExcluded( $ip_address ) {
// do not log if ip address is on the do not log list // do not log if ip address is on the do not log list
$ips = owa_coreAPI::getSetting( 'base', 'excluded_ips' ); $ips = owa_coreAPI::getSetting( 'base', 'excluded_ips' );
owa_coreAPI::debug('excluded ips: '.$ips);
if ( $ips ) { if ( $ips ) {
owa_coreAPI::debug('Excluded ip address list: '.$ips);
$ips = trim( $ips ); $ips = trim( $ips );
if ( strpos( $ips, ',' ) ) { if ( strpos( $ips, ',' ) ) {
$ips = explode( ',', $ips ); $ips = explode( ',', $ips );
} else { } else {
$ips = array( $ips ); $ips = array( $ips );
} }
foreach( $ips as $ip ) { foreach( $ips as $ip ) {
$ip = trim( $ip ); $ip = trim( $ip );
 End of changes. 24 change blocks. 
46 lines changed or deleted 90 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)