diff --git a/asyncEventProcessor.php b/asyncEventProcessor.php index 5878f796d..60de1a11f 100644 --- a/asyncEventProcessor.php +++ b/asyncEventProcessor.php @@ -16,15 +16,12 @@ // $Id$ // -require_once 'owa_settings_class.php'; require_once 'owa_lib.php'; require_once 'owa_env.php'; require_once 'eventQueue.php'; -require_once (OWA_PEARLOG_DIR . '/Log.php'); -require_once 'owa_session_class.php'; -require_once 'owa_request_class.php'; +//require_once (OWA_PEARLOG_DIR . '/Log.php'); require_once 'owa_caller.php'; -require_once('owa_db.php'); + /** * Asynchronous Event Processsor @@ -86,7 +83,7 @@ function asyncEventProcessor($config = null) { // Turns off async setting so that the proper event queue is created $this->config['async_db'] = false; $this->eq = &eventQueue::get_instance(); - $this->db = &owa_db::get_instance(); + $this->db = &owa_coreAPI::dbSingleton(); // Create Error Logger - NEEDED? $conf = array('mode' => 640, 'timeFormat' => '%X %x'); diff --git a/eventQueue.php b/eventQueue.php index 41217bc48..b43332b7d 100644 --- a/eventQueue.php +++ b/eventQueue.php @@ -1,107 +1,108 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ -class eventQueue { - - /** - * Configuration - * - * @var array - */ - var $config; - - /** - * Constructor - * - * @return eventQueue - */ - function eventQueue() { - - return; - } - - /** - * Event Queue factory - * @static - * @return object - * @access public - */ - function &get_instance() { - - static $eq; - - $this->config = &owa_settings::get_settings(); - - if (!isset($eq)): - // Create an async event queue - if ($this->config['async_db'] == true): - $conf = array('mode' => 0600, 'timeFormat' => '%X %x'); - $eq = &Log::singleton('async_queue', $this->config['async_log_dir'].$this->config['async_log_file'], 'async_event_queue', $conf); - $eq->_lineFormat = '%1$s|*|%2$s|*|[%3$s]|*|%4$s|*|%5$s'; - // not sure why this is needed but it is. - $eq->_filename = $this->config['async_log_dir'].$this->config['async_log_file']; - - // This observer will watch the queue and exec a new php process that will process the events - require_once(OWA_PLUGINS_DIR.'/event_handlers/async/observer_async_helper.php'); - $async_helper = &owa_observer::factory('async_helper', PEAR_LOG_INFO); - $eq->attach($async_helper); - - else: - //Create a normal event queue using 'queue' which is an extension to PEAR LOG. - $eq = Log::singleton('queue', '', 'event_queue'); - - /* if ($dir = @opendir(OWA_PLUGINS_DIR.'/event_handlers')): - while (($file = @readdir($dir)) !== false) { - if (strstr($file, '.php') && - substr($file, -1, 1) != "~" && - substr($file, 0, 1) != "#"): - require_once(OWA_PLUGINS_DIR.'/event_handlers/'.$file); - $class = substr($file, 9, -4); - $plugin_name = &owa_observer::factory($class, PEAR_LOG_INFO); - $eq->attach($plugin_name); - endif; - - } - - @closedir($dir); - endif; */ - endif; - endif; - - return $eq; - } - -} - -?> + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ +class eventQueue { + + /** + * Configuration + * + * @var array + */ + var $config; + + /** + * Constructor + * + * @return eventQueue + */ + function eventQueue() { + + return; + } + + /** + * Event Queue factory + * @static + * @return object + * @access public + */ + function &get_instance() { + + static $eq; + + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); + + if (!isset($eq)): + // Create an async event queue + if ($this->config['async_db'] == true): + $conf = array('mode' => 0600, 'timeFormat' => '%X %x'); + $eq = &Log::singleton('async_queue', $this->config['async_log_dir'].$this->config['async_log_file'], 'async_event_queue', $conf); + $eq->_lineFormat = '%1$s|*|%2$s|*|[%3$s]|*|%4$s|*|%5$s'; + // not sure why this is needed but it is. + $eq->_filename = $this->config['async_log_dir'].$this->config['async_log_file']; + + // This observer will watch the queue and exec a new php process that will process the events + require_once(OWA_PLUGINS_DIR.'/event_handlers/async/observer_async_helper.php'); + $async_helper = &owa_observer::factory('async_helper', PEAR_LOG_INFO); + $eq->attach($async_helper); + + else: + //Create a normal event queue using 'queue' which is an extension to PEAR LOG. + $eq = Log::singleton('queue', '', 'event_queue'); + + /* if ($dir = @opendir(OWA_PLUGINS_DIR.'/event_handlers')): + while (($file = @readdir($dir)) !== false) { + if (strstr($file, '.php') && + substr($file, -1, 1) != "~" && + substr($file, 0, 1) != "#"): + require_once(OWA_PLUGINS_DIR.'/event_handlers/'.$file); + $class = substr($file, 9, -4); + $plugin_name = &owa_observer::factory($class, PEAR_LOG_INFO); + $eq->attach($plugin_name); + endif; + + } + + @closedir($dir); + endif; */ + endif; + endif; + + return $eq; + } + +} + +?> diff --git a/ini_db.php b/ini_db.php index 5e678b1b5..a1618f933 100644 --- a/ini_db.php +++ b/ini_db.php @@ -1,210 +1,211 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category wa - * @package wa - * @version $Revision$ - * @since wa 1.0.0 - */ -class ini_db { - - /** - * Data file - * - * @var unknown_type - */ - var $ini_file; - - /** - * Result Format - * - * @var string - */ - var $return_format; - - /** - * Cache flag - * - * @var boolean - */ - var $cache = true; - - /** - * Configuration - * - * @var array - */ - var $config; - - /** - * Database Access Object - * - * @var object - */ - var $db; - - /** - * Constructor - * - * @param string $ini_file - * @param string_type $sections - * @param string $return_format - * @access public - * @return ini_db - */ - function ini_db($ini_file, $sections = null, $return_format = 'object') { - - $this->config = &owa_settings::get_settings(); - $this->ini_file = $ini_file; - $this->return_format = $return_format; - - if (!empty($sections)): - $this->db = $this->readINIfile($this->ini_file, ';'); - else: - $this->db = file($this->ini_file); - endif; - return; - } - - /** - * Returns a section from an ini file based on regex match rule - * contained as keys in an ini file. - * - * @param string - * @access public - */ - function fetch($haystack) { - - $record = null; - - foreach ($this->db as $key=>$value) { - if (($key!='#*#')&&(!array_key_exists('parent',$value))) continue; - - $keyEreg = '#'.$key.'#'; - - if (preg_match($keyEreg, $haystack)) { - $record=array('regex'=>strtolower($keyEreg),'pattern'=>$key)+$value; - - $maxDeep=8; - while (array_key_exists('parent',$value)&&(--$maxDeep>0)) - - $record+=($value = $this->db[strtolower($value['parent'])]); - break; - } - } - - switch ($this->return_format) { - case "array": - return $record; - break; - case "object": - return ((object)$record); - break; - } - return $record; - } - - /** - * Returns part of the passed string based on regex match rules - * contained as keys in an ini file. - * - * @param string - * @access public - * @return string - */ - function match($haystack) { - - foreach ($this->db as $key => $value) { - //print_r($this->db); - if (preg_match($value, $haystack, $tmp)): - $needle = $tmp; - //print_r($tmp); - endif; - - } - - return $needle; - } - - /** - * Fetch a record set and perfrom a regex replace on the name - * - * @param string $haystack - * @return string - */ - function fetch_replace($haystack) { - - $record = $this->fetch($haystack); - - //print_r($record); - - $new_record = preg_replace($record->regex, $record->name, $haystack); - - return $new_record; - } - - /** - * Reads INI file - * - * @param string $filename - * @param string $commentchar - * @return array - */ - function readINIfile ($filename, $commentchar) { - $array1 = file($filename); - $section = ''; - foreach ($array1 as $filedata) { - $dataline = trim($filedata); - $firstchar = substr($dataline, 0, 1); - if ($firstchar!=$commentchar && $dataline!='') { - //It's an entry (not a comment and not a blank line) - if ($firstchar == '[' && substr($dataline, -1, 1) == ']') { - //It's a section - $section = strtolower(substr($dataline, 1, -1)); - }else{ - //It's a key... - $delimiter = strpos($dataline, '='); - if ($delimiter > 0) { - //...with a value - $key = strtolower(trim(substr($dataline, 0, $delimiter))); - $value = trim(substr($dataline, $delimiter + 1)); - if (substr($value, 1, 1) == '"' && substr($value, -1, 1) == '"') { $value = substr($value, 1, -1); } - $array2[$section][$key] = stripcslashes($value); - }else{ - //...without a value - $array2[$section][strtolower(trim($dataline))]=''; - } - } - }else{ - //It's a comment or blank line. Ignore. - } - } - return $array2; - } - -} - -?> + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category wa + * @package wa + * @version $Revision$ + * @since wa 1.0.0 + */ +class ini_db { + + /** + * Data file + * + * @var unknown_type + */ + var $ini_file; + + /** + * Result Format + * + * @var string + */ + var $return_format; + + /** + * Cache flag + * + * @var boolean + */ + var $cache = true; + + /** + * Configuration + * + * @var array + */ + var $config; + + /** + * Database Access Object + * + * @var object + */ + var $db; + + /** + * Constructor + * + * @param string $ini_file + * @param string_type $sections + * @param string $return_format + * @access public + * @return ini_db + */ + function ini_db($ini_file, $sections = null, $return_format = 'object') { + + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); + $this->ini_file = $ini_file; + $this->return_format = $return_format; + + if (!empty($sections)): + $this->db = $this->readINIfile($this->ini_file, ';'); + else: + $this->db = file($this->ini_file); + endif; + return; + } + + /** + * Returns a section from an ini file based on regex match rule + * contained as keys in an ini file. + * + * @param string + * @access public + */ + function fetch($haystack) { + + $record = null; + + foreach ($this->db as $key=>$value) { + if (($key!='#*#')&&(!array_key_exists('parent',$value))) continue; + + $keyEreg = '#'.$key.'#'; + + if (preg_match($keyEreg, $haystack)) { + $record=array('regex'=>strtolower($keyEreg),'pattern'=>$key)+$value; + + $maxDeep=8; + while (array_key_exists('parent',$value)&&(--$maxDeep>0)) + + $record+=($value = $this->db[strtolower($value['parent'])]); + break; + } + } + + switch ($this->return_format) { + case "array": + return $record; + break; + case "object": + return ((object)$record); + break; + } + return $record; + } + + /** + * Returns part of the passed string based on regex match rules + * contained as keys in an ini file. + * + * @param string + * @access public + * @return string + */ + function match($haystack) { + + foreach ($this->db as $key => $value) { + //print_r($this->db); + if (preg_match($value, $haystack, $tmp)): + $needle = $tmp; + //print_r($tmp); + endif; + + } + + return $needle; + } + + /** + * Fetch a record set and perfrom a regex replace on the name + * + * @param string $haystack + * @return string + */ + function fetch_replace($haystack) { + + $record = $this->fetch($haystack); + + //print_r($record); + + $new_record = preg_replace($record->regex, $record->name, $haystack); + + return $new_record; + } + + /** + * Reads INI file + * + * @param string $filename + * @param string $commentchar + * @return array + */ + function readINIfile ($filename, $commentchar) { + $array1 = file($filename); + $section = ''; + foreach ($array1 as $filedata) { + $dataline = trim($filedata); + $firstchar = substr($dataline, 0, 1); + if ($firstchar!=$commentchar && $dataline!='') { + //It's an entry (not a comment and not a blank line) + if ($firstchar == '[' && substr($dataline, -1, 1) == ']') { + //It's a section + $section = strtolower(substr($dataline, 1, -1)); + }else{ + //It's a key... + $delimiter = strpos($dataline, '='); + if ($delimiter > 0) { + //...with a value + $key = strtolower(trim(substr($dataline, 0, $delimiter))); + $value = trim(substr($dataline, $delimiter + 1)); + if (substr($value, 1, 1) == '"' && substr($value, -1, 1) == '"') { $value = substr($value, 1, -1); } + $array2[$section][$key] = stripcslashes($value); + }else{ + //...without a value + $array2[$section][strtolower(trim($dataline))]=''; + } + } + }else{ + //It's a comment or blank line. Ignore. + } + } + return $array2; + } + +} + +?> \ No newline at end of file diff --git a/modules/base/classes/abstractJpGraphView.php b/modules/base/classes/abstractJpGraphView.php index e105c2dc9..484c554ae 100644 --- a/modules/base/classes/abstractJpGraphView.php +++ b/modules/base/classes/abstractJpGraphView.php @@ -64,7 +64,7 @@ function assembleView($data) { $this->graph->construct(); // outputs the graph - + $this->graph->graph->Stroke(); //debug_print_backtrace(); diff --git a/modules/base/classes/column.php b/modules/base/classes/column.php index 69a194d95..62182746c 100644 --- a/modules/base/classes/column.php +++ b/modules/base/classes/column.php @@ -28,7 +28,7 @@ * @since owa 1.0.0 */ - class owa_dbColumn { +class owa_dbColumn { var $value; diff --git a/modules/base/classes/column2.php b/modules/base/classes/column2.php index 026a5e8f3..235d8443b 100644 --- a/modules/base/classes/column2.php +++ b/modules/base/classes/column2.php @@ -15,5 +15,5 @@ function owa_dbColumn2() { } - ?> +?> \ No newline at end of file diff --git a/modules/base/classes/mailer.php b/modules/base/classes/mailer.php index 7afd7377f..d1ef5a374 100644 --- a/modules/base/classes/mailer.php +++ b/modules/base/classes/mailer.php @@ -1,105 +1,107 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_mailer extends PHPMailer { - - /** - * Configuration - * - * @var array - */ - var $config; - - /** - * Error Logger - * - * @var Object - */ - var $e; - - /** - * Constructor - * - * @return owa_mailer - */ - function owa_mailer() { - - $this->config = &owa_settings::get_settings(); - $this->e = &owa_error::get_instance(); - - if (!empty($this->config['mailer-from'])): - $this->From = $this->config['mailer-from']; - endif; - - if (!empty($this->config['mailer-fromName'])): - $this->FromName = $this->config['mailer-fromName']; - endif; - - if (!empty($this->config['mailer-host'])): - $this->Host = $this->config['mailer-host']; - endif; - - if (!empty($this->config['mailer-port'])): - $this->Port = $this->config['mailer-port']; - endif; - - if (!empty($this->config['mailer-smtpAuth'])): - $this->SMTPAuth = $this->config['mailer-smtpAuth']; - endif; - - if (!empty($this->config['mailer-username'])): - $this->Username = $this->config['mailer-username']; - endif; - - if (!empty($this->config['mailer-password'])): - $this->Password = $this->config['mailer-password']; - endif; - - return; - - } - - function sendMail() { - - if(!$this->Send()): - - return $this->e->debug(sprintf("Mailer Failure. Was not able to send to %s with subject of '%s'. Error Msgs: '%s'", $this->to, $this->Subject, $this->ErrorInfo)); - - else: - return $this->e->debug(sprintf("Mail sent to %s with the subject of '%s'.", $this->to, $this->Subject)); - endif; - - - } -} - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_mailer extends PHPMailer { + + /** + * Configuration + * + * @var array + */ + var $config; + + /** + * Error Logger + * + * @var Object + */ + var $e; + + /** + * Constructor + * + * @return owa_mailer + */ + function owa_mailer() { + + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); + + $this->e = &owa_error::get_instance(); + + if (!empty($this->config['mailer-from'])): + $this->From = $this->config['mailer-from']; + endif; + + if (!empty($this->config['mailer-fromName'])): + $this->FromName = $this->config['mailer-fromName']; + endif; + + if (!empty($this->config['mailer-host'])): + $this->Host = $this->config['mailer-host']; + endif; + + if (!empty($this->config['mailer-port'])): + $this->Port = $this->config['mailer-port']; + endif; + + if (!empty($this->config['mailer-smtpAuth'])): + $this->SMTPAuth = $this->config['mailer-smtpAuth']; + endif; + + if (!empty($this->config['mailer-username'])): + $this->Username = $this->config['mailer-username']; + endif; + + if (!empty($this->config['mailer-password'])): + $this->Password = $this->config['mailer-password']; + endif; + + return; + + } + + function sendMail() { + + if(!$this->Send()): + + return $this->e->debug(sprintf("Mailer Failure. Was not able to send to %s with subject of '%s'. Error Msgs: '%s'", $this->to, $this->Subject, $this->ErrorInfo)); + + else: + return $this->e->debug(sprintf("Mail sent to %s with the subject of '%s'.", $this->to, $this->Subject)); + endif; + + + } +} + ?> \ No newline at end of file diff --git a/modules/base/classes/settings.php b/modules/base/classes/settings.php new file mode 100644 index 000000000..9cec9c3dd --- /dev/null +++ b/modules/base/classes/settings.php @@ -0,0 +1,334 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + class owa_settings { + + /** + * Configuration Entity + * + * @var object configuration entity + */ + var $config; + + var $default_config; + + /** + * Constructor + * + * @param string id the id of the configuration array to load + */ + function owa_settings() { + + $this->config = owa_coreAPI::entityFactory('base.configuration'); + $this->config->set('settings', $this->getDefaultConfig()); + + return; + } + + function applyModuleOverrides($module, $config) { + + // merge default config with overrides + + if (!empty($config)): + + $in_place_config = $this->config->get('settings'); + + $old_array = $in_place_config[$module]; + + $new_array = array_merge($old_array, $config); + + $in_place_config[$module] = $new_array; + + $this->config->set('settings', $in_place_config); + + //print_r($this->config->get('settings')); + + endif; + + + + return; + + } + + /** + * Loads configuration from data store + * + * @param string id the id of the configuration array to load + */ + function load($id = 1) { + + if (!file_exists(OWA_BASE_MODULE_DIR.'config'.DIRECTORY_SEPARATOR.'base.php')): + + $db_config = owa_coreAPI::entityFactory('base.configuration'); + $db_config->getByPk('id', $id); + $db_settings = unserialize($db_config->get('settings')); + + $default = $this->config->get('settings'); + + // merge default config with overrides fetched from data store + + $new_config = array(); + + foreach ($db_settings as $k => $v) { + + $new_config[$k] = array_merge($default[$k], $db_settings[$k]); + + $this->config->set('settings', $new_config); + + } + + else: + ; // load config from file + endif; + + + return; + + } + + /** + * Fetches a modules entire configuration array + * + * @param string $module The name of module whose configuration values you want to fetch + * @return array Config values + */ + function fetch($module = '') { + $v = $this->config->get('settings'); + + if (!empty($module)): + + return $v[$module]; + else: + return $v['base']; + endif; + } + + /** + * updates or creates configuration values + * + * @return boolean + */ + function update() { + + return $this->config->update(); + + } + + /** + * Accessor Method + * + * @param string $module the name of the module + * @param string $key the configuration key + * @return boolean + */ + function get($module, $key) { + + $values = $this->config->get('settings'); + + return $values[$module][$key]; + } + + /** + * Sets configuration value + * + * @param string $module the name of the module + * @param string $key the configuration key + * @param string $value the configuration value + * @return boolean + */ + function set($module, $key, $value) { + + $values = $this->config->get('settings'); + + $values[$module][$key] = $value; + + $this->config->set('settings', $values); + + return; + } + + /** + * Alternate Constructor for base module settings + * Needed for backwards compatability with older classes + * + */ + function &get_settings($id = 1) { + + + static $config2; + + if (!isset($config2)): + print 'hello from alt constructor'; + $config2 = &owa_coreAPI::configSingleton(); + endif; + + return $config2->fetch('base'); + + } + + function getDefaultConfig() { + + $config = array('base' => array( + + 'ns' => 'owa_', + 'visitor_param' => 'v', + 'session_param' => 's', + 'last_request_param' => 'last_req', + 'first_hit_param' => 'first_hit', + 'feed_subscription_param' => 'sid', + 'source_param' => 'from', + 'graph_param' => 'graph', + 'period_param' => 'period', + 'document_param' => 'document', + 'referer_param' => 'referer', + 'site_id' => '', + 'configuration_id' => '1', + 'session_length' => '1800', + 'debug_to_screen' => false, + 'requests_table' => 'request', + 'sessions_table' => 'session', + 'referers_table' => 'referer', + 'ua_table' => 'ua', + 'os_table' => 'os', + 'documents_table' => 'document', + 'sites_table' => 'site', + 'hosts_table' => 'host', + 'config_table' => 'configuration', + 'version_table' => 'version', + 'feed_requests_table' => 'feed_request', + 'visitors_table' => 'visitor', + 'impressions_table' => 'impression', + 'clicks_table' => 'click', + 'exits_table' => 'exit', + 'users_table' => 'user', + 'db_class' => '', + 'db_type' => '', + 'db_name' => '', + 'db_user' => '', + 'db_password' => '', + 'db_host' => '', + 'resolve_hosts' => true, + 'log_feedreaders' => true, + 'log_robots' => false, + 'log_sessions' => true, + 'log_dom_clicks' => true, + 'delay_first_hit' => true, + 'async_db' => false, + 'clean_query_string' => true, + 'fetch_refering_page_info' => true, + 'query_string_filters' => '', + 'async_log_dir' => OWA_BASE_DIR . '/logs/', + 'async_log_file' => 'events.txt', + 'async_lock_file' => 'owa.lock', + 'async_error_log_file' => 'events_error.txt', + 'notice_email' => '', + 'error_handler' => 'development', + 'error_log_file' => OWA_BASE_DIR . '/logs/errors.txt', + 'browscap.ini' => OWA_BASE_DIR . '/modules/base/data/php_browscap.ini', + 'browscap_supplemental.ini' => OWA_BASE_DIR . '/conf/browscap_supplemental.ini', + 'search_engines.ini' => OWA_BASE_DIR . '/conf/search_engines.ini', + 'query_strings.ini' => OWA_BASE_DIR . '/conf/query_strings.ini', + 'os.ini' => OWA_BASE_DIR . '/conf/os.ini', + 'robots.ini' => OWA_BASE_DIR . '/conf/robots.ini', + 'db_class_dir' => OWA_BASE_DIR . '/plugins/db/', + 'templates_dir' => OWA_BASE_DIR . '/templates/', + 'plugin_dir' => OWA_BASE_DIR . '/plugins/', + 'module_dir' => OWA_BASE_DIR . '/modules', + 'install_plugin_dir' => OWA_BASE_DIR . '/plugins/install/', + 'reporting_dir' => OWA_BASE_DIR . '/public/reports/', + 'geolocation_lookup' => true, + 'geolocation_service' => 'hostip', + 'report_wrapper' => 'wrapper_default.tpl', + 'config_file_path' => OWA_BASE_DIR . '/conf/owa_config.php', + 'fetch_config_from_db' => true, + 'announce_visitors' => false, + 'public_url' => '', + 'action_url' => '', + 'images_url' => '', + 'reporting_url' => '', + 'p3p_policy' => 'NOI NID ADMa OUR IND UNI COM NAV', + 'inter_report_link_template' => '%s?%s', //base_url?report=report_name&get... DEPRICATED? + 'graph_link_template' => '%s?owa_action=graph&name=%s&%s', //action_url?... + 'link_template' => '%s?%s', // main_url?key=value.... + 'owa_user_agent' => 'Open Web Analytics Bot '.OWA_VERSION, + 'fetch_owa_news' => true, + 'owa_rss_url' => 'http://www.openwebanalytics.com/?feed=rss2', + 'use_summary_tables' => false, + 'summary_framework' => '', + 'click_drawing_mode' => 'center_on_page', + 'log_clicks' => true, + 'authentication' => 'simple', + 'owa_wiki_link_template' => 'http://wiki.openwebanalytics.com/index.php?title=%s', + 'password_length' => 4, + 'modules' => array('base'), + 'mailer-from' => '', + 'mailer-fromName' => 'OWA Mailer', + 'mailer-host' => '', + 'mailer-port' => '', + 'mailer-smtpAuth' => '', + 'mailer-username' => '', + 'mailer-password' => '', + 'cookie_domain' => $_SERVER['SERVER_NAME'] + + )); + + // Setup special public URLs + + $base_url = "http"; + + if(isset($_SERVER['HTTPS'])): + $base_url .= 's'; + endif; + + $base_url .= '://'.$_SERVER['SERVER_NAME']; + + if($_SERVER['SERVER_PORT'] != 80): + $base_url .= ':'.$_SERVER['SERVER_PORT']; + endif; + + $config['base']['public_url'] = $base_url . $OWA_CONFIG['public_url']; + $config['base']['main_url'] = $OWA_CONFIG['public_url']."/main.php"; + $config['base']['main_absolute_url'] = $base_url . $config['main_url']; + $config['base']['action_url'] = $config['main_url']; + $config['base']['log_url'] = $OWA_CONFIG['public_url']."/log.php"; + $config['base']['images_url'] = $OWA_CONFIG['public_url']."/i"; + $config['base']['reporting_url'] = $OWA_CONFIG['public_url']."/reports/index.php"; + $config['base']['home_url'] = $config['public_url']."/reports/index.php?page=dashboard_report.php"; + $config['base']['admin_url'] = $OWA_CONFIG['public_url']."/admin/index.php"; + + return $config; + + } + + } + + +?> \ No newline at end of file diff --git a/modules/base/classes/validation.php b/modules/base/classes/validation.php new file mode 100644 index 000000000..77d33e22d --- /dev/null +++ b/modules/base/classes/validation.php @@ -0,0 +1,91 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + class owa_validation extends owa_base { + + var $hasError; + + var $errorMsg; + + var $errorMsgTemplate; + + function owa_validation($conf) { + + $this->owa_base(); + + if (!empty($conf['errorMsgTemplate'])): + $this->errorMsgTemplate = $conf['errorMsgTemplate']; + endif; + + return; + } + + function validate($value) { + + return false; + } + + function getErrorMsg() { + + return $this->errorMsg; + } + + function setErrorMsgTemplate($string) { + + $this->errorMsgTemplate = $string; + + return; + } + + function setErrorMsg($msg) { + + $this->errorMsg = $msg; + $this->hasError = true; + + return; + + } + + function isValid() { + + if ($this->hasError == true): + return false; + else: + return true; + endif; + } + + + + + } + +?> + \ No newline at end of file diff --git a/modules/base/classes/validator.php b/modules/base/classes/validator.php new file mode 100644 index 000000000..62a402b1f --- /dev/null +++ b/modules/base/classes/validator.php @@ -0,0 +1,154 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + class owa_validator extends owa_base { + + /** + * Flag for whether or not a validation run produces errors + * + * @var boolean + */ + var $hasErrors; + + /** + * Error Msgs produced by Validations + * + * @var array + */ + var $errorMsgs; + + /** + * Validations to be performed in next validation run + * + * @var array + */ + var $validations; + + /** + * Validation objects + * + * @var array + */ + var $validators; + + function owa_validator() { + + $this->owa_base; + + return; + + } + + /** + * Adds a validation to be performed in next run + * + * @param string $name the name to be given to the validation and its results + * @param unknown $value the data value that is to be validated + * @param string $validation the name of the validation to run + * @param array $conf configuration array for the object being created + */ + function addValidation($name, $value, $validation, $conf) { + + $this->validations[$name] = array('value' => $value, 'validation' => $validation, 'conf' => $conf); + + return; + + } + + /** + * Factory method for producing validation objects + * + * @return Object + */ + function validationFactory($class_file, $conf) { + + if (!class_exists('owa_validation')): + require_once(OWA_BASE_CLASS_DIR.'validation.php'); + endif; + + return owa_lib::factory(OWA_PLUGINS_DIR.'/validations', 'owa_', $class_file, $conf, 'Validation'); + + } + + /** + * Performs a validation run + * + */ + function doValidations() { + + foreach ($this->validations as $k => $v) { + + // Construct validatation obj + $this->validators[$k] = $this->validationFactory($v['validation'], $v['conf']); + + $this->validators[$k]->validate($v['value']); + + if ($this->validators[$k]->hasError == true): + + $this->hasErrors = true; + $this->errorMsgs[$k] = $this->validators[$k]->errorMsg; + + if ($this->validators[$k]->conf['stopOnError'] == true): + break; + endif; + + endif; + } + } + + /** + * Check to see if the validation run was successful. + * + * @return boolean + */ + function isValid() { + + if ($this->hasErrors == true): + return false; + else: + return true; + endif; + } + + /** + * Accessor method for retrieving the error msgs produced by a validation run + * + * @return array + */ + function getErrorMsgs() { + + return $this->errorMsgs; + } + + + } + +?> + \ No newline at end of file diff --git a/modules/base/config/db_config.php b/modules/base/config/db_config.php new file mode 100644 index 000000000..09c3cc513 --- /dev/null +++ b/modules/base/config/db_config.php @@ -0,0 +1,38 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +define('OWA_DB_TYPE', ''); +define('OWA_DB_NAME', ''); +define('OWA_DB_HOST', ''); +define('OWA_DB_USER', ''); +define('OWA_DB_PASSWORD', ''); + +?> + \ No newline at end of file diff --git a/modules/base/entities/configuration.php b/modules/base/entities/configuration.php new file mode 100644 index 000000000..881f50e58 --- /dev/null +++ b/modules/base/entities/configuration.php @@ -0,0 +1,48 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_configuration extends owa_entity { + + var $id; // BIGINT, + var $settings; // varchar(255) + + function owa_configuration() { + + $this->owa_entity(); + + return; + + } + +} + + + +?> diff --git a/modules/base/graphDashboardTrend.php b/modules/base/graphDashboardTrend.php index 26c451e34..b47b83f53 100644 --- a/modules/base/graphDashboardTrend.php +++ b/modules/base/graphDashboardTrend.php @@ -63,9 +63,10 @@ function construct($data) { $new_result = owa_lib::deconstruct_assoc($result); //$new_result = ''; + if(empty($new_result['page_views']) && empty($new_result['sessions'])): - - $this->graph = owa_coreAPI::graphFactory('base.jpErrorGraph'); + + $this->graph = owa_coreAPI::graphFactory('base.jpErrorGraph'); $this->graph->params['width'] = 275; $this->graph->params['height'] = 100; $this->graph->params['error_msg'] = $this->getMsg(3500); diff --git a/modules/base/installCheckEnv.php b/modules/base/installCheckEnv.php index 0b612fc66..8d6a46026 100644 --- a/modules/base/installCheckEnv.php +++ b/modules/base/installCheckEnv.php @@ -1,124 +1,124 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_installCheckEnvView extends owa_view { - - function owa_installCheckEnvView($params) { - - $this->owa_view($params); - $this->priviledge_level = 'guest'; - - return; - } - - function construct($data) { - - //page title - $this->t->set('page_title', 'Installer Server Environment Check'); - $this->body->set('headline', 'Server Environment Check'); - $this->body->set('errors', $data['errors']); - $this->body->set('env', $data['env']); - // load body template - $this->body->set_template('install_check_env.tpl'); - - - - return; - } - - -} - -/** - * Server Environment Check Controller - * - * @author Peter Adams - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_installCheckEnvController extends owa_controller { - - function owa_installCheckEnvController($params) { - $this->owa_controller($params); - $this->priviledge_level = 'guest'; - } - - function action() { - - $errors = array(); - $warnings = array(); - $env = array(); - - // check PHP version - $env['php_version'] = phpversion(); - $version = split('\.',$env['php_version']); - - if ($version[0] < 4): - $errors['php_version'] = $this->getMsg(3301); - $errors['count'] = $errors['count']++; - endif; - - // Check DB connection status - $db = &owa_db::get_instance(); - if ($db->connection_status != true): - $errors['count'] = $errors['count']++; - $errors['db_status'] = $this->getMsg(3300); - $env['db_status'] = 'Failed'; - else: - $env['db_status'] = 'Success'; - endif; - - // Check socket connection - - // Check permissions on log directory - - $data['errors'] = $errors; - $data['env'] = $env; - $data['view_method'] = 'delegate'; - $data['view'] = 'base.install'; - $data['subview'] = 'base.installCheckEnv'; - - return $data; - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_installCheckEnvView extends owa_view { + + function owa_installCheckEnvView($params) { + + $this->owa_view($params); + $this->priviledge_level = 'guest'; + + return; + } + + function construct($data) { + + //page title + $this->t->set('page_title', 'Installer Server Environment Check'); + $this->body->set('headline', 'Server Environment Check'); + $this->body->set('errors', $data['errors']); + $this->body->set('env', $data['env']); + // load body template + $this->body->set_template('install_check_env.tpl'); + + + + return; + } + + +} + +/** + * Server Environment Check Controller + * + * @author Peter Adams + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_installCheckEnvController extends owa_controller { + + function owa_installCheckEnvController($params) { + $this->owa_controller($params); + $this->priviledge_level = 'guest'; + } + + function action() { + + $errors = array(); + $warnings = array(); + $env = array(); + + // check PHP version + $env['php_version'] = phpversion(); + $version = split('\.',$env['php_version']); + + if ($version[0] < 4): + $errors['php_version'] = $this->getMsg(3301); + $errors['count'] = $errors['count']++; + endif; + + // Check DB connection status + $db = &owa_coreAPI::dbSingleton(); + if ($db->connection_status != true): + $errors['count'] = $errors['count']++; + $errors['db_status'] = $this->getMsg(3300); + $env['db_status'] = 'Failed'; + else: + $env['db_status'] = 'Success'; + endif; + + // Check socket connection + + // Check permissions on log directory + + $data['errors'] = $errors; + $data['env'] = $env; + $data['view_method'] = 'delegate'; + $data['view'] = 'base.install'; + $data['subview'] = 'base.installCheckEnv'; + + return $data; + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/installEmbedded.php b/modules/base/installEmbedded.php index df6aa4b7d..8b8583c1b 100644 --- a/modules/base/installEmbedded.php +++ b/modules/base/installEmbedded.php @@ -20,7 +20,7 @@ require_once(OWA_BASE_DIR.'/owa_lib.php'); require_once(OWA_BASE_DIR.'/owa_controller.php'); require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_coreAPI.php'); -//require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_installer.php'); + /** diff --git a/modules/base/metrics/clickstream.php b/modules/base/metrics/clickstream.php index 09e4ae4fd..d812c528d 100644 --- a/modules/base/metrics/clickstream.php +++ b/modules/base/metrics/clickstream.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Clickstream Metric * diff --git a/modules/base/metrics/dashCoreByDay.php b/modules/base/metrics/dashCoreByDay.php index a7e1e433b..8b9a68ec5 100644 --- a/modules/base/metrics/dashCoreByDay.php +++ b/modules/base/metrics/dashCoreByDay.php @@ -16,9 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); -require_once(OWA_BASE_CLASSES_DIR.'owa_coreAPI.php'); - /** * Dashboard Core metrics By Day * @@ -62,9 +59,6 @@ function generate() { return $s->query($this->params); - - - } diff --git a/modules/base/metrics/dashCounts.php b/modules/base/metrics/dashCounts.php index 17f88d6c2..a4ff5bbd6 100644 --- a/modules/base/metrics/dashCounts.php +++ b/modules/base/metrics/dashCounts.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Dashboard Count Metrics * diff --git a/modules/base/metrics/feedFormatsCount.php b/modules/base/metrics/feedFormatsCount.php index bf53b8ce4..950210228 100644 --- a/modules/base/metrics/feedFormatsCount.php +++ b/modules/base/metrics/feedFormatsCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Feed Formats Count * @@ -59,27 +57,6 @@ function generate() { return $f->query($this->params); - /* - - SELECT - count(request_id) as count, - feed_format - FROM - %s as feed_requests - WHERE - true - %s - %s - GROUP BY - feed_format - ", - $this->setTable($this->config['feed_requests_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - */ - } diff --git a/modules/base/metrics/feedReaderTypesCount.php b/modules/base/metrics/feedReaderTypesCount.php index ea21017cc..66fa2beba 100644 --- a/modules/base/metrics/feedReaderTypesCount.php +++ b/modules/base/metrics/feedReaderTypesCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Feed Reader Types Count * @@ -48,9 +46,6 @@ function generate() { ua.ua as ua, ua.browser_type"; - - //$this->params['orderby'] = array('year', 'month', 'day'); - $this->setTimePeriod($this->params['period']); $f = owa_coreAPI::entityFactory('base.feed_request'); @@ -63,30 +58,6 @@ function generate() { return $f->query($this->params); - /* - - SELECT - count(distinct feed_requests.feed_reader_guid) as count, - ua.ua as ua, - ua.browser_type - FROM - %s as feed_requests, - %s as ua - WHERE - ua.id = ua_id - %s - %s - GROUP BY - ua.browser_type - ", - $this->setTable($this->config['feed_requests_table']), - $this->setTable($this->config['ua_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - */ - } diff --git a/modules/base/metrics/feedViewsTrend.php b/modules/base/metrics/feedViewsTrend.php index 0c9259833..e46262cfa 100644 --- a/modules/base/metrics/feedViewsTrend.php +++ b/modules/base/metrics/feedViewsTrend.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Dashboard Core metrics By Day * @@ -51,44 +49,12 @@ function generate() { day"; - //$this->params['orderby'] = array('year', 'month', 'day'); - $this->setTimePeriod($this->params['period']); $f = owa_coreAPI::entityFactory('base.feed_request'); return $f->query($this->params); - /* - - SELECT - count(request_id) as fetch_count, - count(distinct feed_reader_guid) as reader_count, - year, - month, - day - FROM - %s as feed_requests - WHERE - true - %s - %s - GROUP BY - feed_requests.%s - ORDER BY - year, - month, - day %s - ", - $this->setTable($this->config['feed_requests_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['group_by'], - $this->params['order'] - ); - - */ - } diff --git a/modules/base/metrics/latestVisits.php b/modules/base/metrics/latestVisits.php index 72c876990..158761024 100644 --- a/modules/base/metrics/latestVisits.php +++ b/modules/base/metrics/latestVisits.php @@ -1,66 +1,64 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_latestVisits extends owa_metric { - - function owa_latestVisits($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $s = owa_coreAPI::entityFactory('base.session'); - - $h = owa_coreAPI::entityFactory('base.host'); - $ua = owa_coreAPI::entityFactory('base.ua'); - $d = owa_coreAPI::entityFactory('base.document'); - $v = owa_coreAPI::entityFactory('base.visitor'); - $r = owa_coreAPI::entityFactory('base.referer'); - $this->params['related_objs'] = array('host_id' => $h, 'ua_id' => $ua, 'first_page_id' => $d, 'visitor_id' => $v, 'referer_id' => $r); - //$related_objs = array('ua_id' => $ua); - $this->setTimePeriod($this->params['period']); - - return $s->find($this->params); - - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_latestVisits extends owa_metric { + + function owa_latestVisits($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $s = owa_coreAPI::entityFactory('base.session'); + + $h = owa_coreAPI::entityFactory('base.host'); + $ua = owa_coreAPI::entityFactory('base.ua'); + $d = owa_coreAPI::entityFactory('base.document'); + $v = owa_coreAPI::entityFactory('base.visitor'); + $r = owa_coreAPI::entityFactory('base.referer'); + $this->params['related_objs'] = array('host_id' => $h, 'ua_id' => $ua, 'first_page_id' => $d, 'visitor_id' => $v, 'referer_id' => $r); + //$related_objs = array('ua_id' => $ua); + $this->setTimePeriod($this->params['period']); + + return $s->find($this->params); + + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/pageTypesCount.php b/modules/base/metrics/pageTypesCount.php index e910f2a4a..8a1383702 100644 --- a/modules/base/metrics/pageTypesCount.php +++ b/modules/base/metrics/pageTypesCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Page Types Count Metric * @@ -64,32 +62,6 @@ function generate() { return $r->query($this->params); - /* - SELECT - count(requests.request_id) as count, - documents.page_title, - documents.page_type, - documents.url, - documents.id - FROM - %s as requests, %s as documents - WHERE - requests.document_id = documents.id - %s - %s - GROUP BY - page_type - ORDER BY - count DESC - ", - $this->setTable($this->config['requests_table']), - $this->setTable($this->config['documents_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - */ - } diff --git a/modules/base/metrics/pageViewsByDay.php b/modules/base/metrics/pageViewsByDay.php index c4d5bae7e..72cbea8d7 100644 --- a/modules/base/metrics/pageViewsByDay.php +++ b/modules/base/metrics/pageViewsByDay.php @@ -1,96 +1,65 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_pageViewsByDay extends owa_metric { - - function owa_pageViewsByDay($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $s = owa_coreAPI::entityFactory('base.session'); - - $this->setTimePeriod($this->params['period']); - - $this->params['select'] = "sum(session.num_pageviews) as page_views, - session.month, - session.day, - session.year"; - - - $this->params['orderby'] = array('session.year', 'session.month', 'session.day'); - - return $s->query($this->params); - - /* - - $sql = sprintf("select - sum(sessions.num_pageviews) as page_views, - sessions.month, - sessions.day, - sessions.year - from - %s as sessions - where - %s - %s - group by - sessions.%s - ORDER BY - sessions.year %6\$s, - sessions.month %6\$s, - sessions.day %6\$s", - - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['group_by'], - $this->params['order'] - ); - - - - return $this->db->get_results($sql); - - */ - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_pageViewsByDay extends owa_metric { + + function owa_pageViewsByDay($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $s = owa_coreAPI::entityFactory('base.session'); + + $this->setTimePeriod($this->params['period']); + + $this->params['select'] = "sum(session.num_pageviews) as page_views, + session.month, + session.day, + session.year"; + + + $this->params['orderby'] = array('session.year', 'session.month', 'session.day'); + + return $s->query($this->params); + + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/pageViewsCount.php b/modules/base/metrics/pageViewsCount.php index df817dc3c..aafff8f37 100644 --- a/modules/base/metrics/pageViewsCount.php +++ b/modules/base/metrics/pageViewsCount.php @@ -1,68 +1,59 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_pageViewsCount extends owa_metric { - - function owa_pageViewsCount($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $sql = sprintf("select - sum(sessions.num_pageviews) as page_views - from - %s as sessions - where - true - %s - %s - ", - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - return $this->db->get_row($sql); - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_pageViewsCount extends owa_metric { + + function owa_pageViewsCount($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $s = owa_coreAPI::entityFactory('base.session'); + + $this->setTimePeriod($this->params['period']); + + $this->params['select'] = "sum(session.num_pageviews) as page_views"; + + return $s->query($this->params); + + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/requestCounts.php b/modules/base/metrics/requestCounts.php index 5bfa4ce6b..bd575f04a 100644 --- a/modules/base/metrics/requestCounts.php +++ b/modules/base/metrics/requestCounts.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Dashboard Core metrics By Day * @@ -48,8 +46,6 @@ function generate() { count(request.session_id) as sessions, count(request.id) as page_views"; - // $this->params['use_summary'] = true; - $this->params['result_format'] = 'single_array'; $this->setTimePeriod($this->params['period']); @@ -58,32 +54,6 @@ function generate() { return $r->query($this->params); - /* - - $sql = sprintf(" - SELECT - count(distinct requests.visitor_id) as unique_visitors, - count(requests.session_id) as sessions, - count(requests.request_id) as page_views - FROM - %s as requests - - WHERE - true - %s - %s - ", - $this->setTable($this->config['requests_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - return $this->db->get_row($sql); - - - - */ - } diff --git a/modules/base/metrics/requestCountsByDay.php b/modules/base/metrics/requestCountsByDay.php index 3cc423f31..448780d05 100644 --- a/modules/base/metrics/requestCountsByDay.php +++ b/modules/base/metrics/requestCountsByDay.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Dashboard Core metrics By Day * @@ -49,8 +47,6 @@ function generate() { count(distinct request.session_id) as sessions, count(request.id) as page_views "; - // $this->params['use_summary'] = true; - $this->params['orderby'] = array('year', 'month', 'day'); $this->setTimePeriod($this->params['period']); @@ -59,38 +55,6 @@ function generate() { return $r->query($this->params); - /* - - $sql = sprintf("select - requests.month, - requests.day, - requests.year, - count(distinct requests.visitor_id) as unique_visitors, - count(distinct requests.session_id) as sessions, - count(requests.request_id) as page_views - from - %s as requests - where - true - %s - %s - group by - requests.%s - ORDER BY - requests.year, - requests.month, - requests.day %s", - $this->setTable($this->config['requests_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['group_by'], - $this->params['order'] - ); - - - - */ - } diff --git a/modules/base/metrics/sessionBrowserTypes.php b/modules/base/metrics/sessionBrowserTypes.php index 8b53b0edf..3db31219b 100644 --- a/modules/base/metrics/sessionBrowserTypes.php +++ b/modules/base/metrics/sessionBrowserTypes.php @@ -1,100 +1,69 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_sessionBrowserTypes extends owa_metric { - - function owa_sessionBrowserTypes($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $s = owa_coreAPI::entityFactory('base.session'); - - $ua = owa_coreAPI::entityFactory('base.ua'); - - $this->params['related_objs'] = array('ua_id' => $ua); - - $this->setTimePeriod($this->params['period']); - - $this->params['select'] = "count(distinct session.id) as count, - ua.ua as ua, - ua.browser_type"; - - $this->params['groupby'] = array('ua.browser_type'); - - $this->params['orderby'] = array('count'); - - return $s->query($this->params); - - /* - $sql = sprintf(" - SELECT - count(distinct sessions.session_id) as count, - ua.ua as ua, - ua.browser_type - FROM - %s as sessions, - %s as ua - WHERE - ua.id = sessions.ua_id - %s - %s - GROUP BY - ua.browser_type - ORDER BY - count DESC - ", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['ua_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - return $this->db->get_results($sql); - - */ - - - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_sessionBrowserTypes extends owa_metric { + + function owa_sessionBrowserTypes($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $s = owa_coreAPI::entityFactory('base.session'); + + $ua = owa_coreAPI::entityFactory('base.ua'); + + $this->params['related_objs'] = array('ua_id' => $ua); + + $this->setTimePeriod($this->params['period']); + + $this->params['select'] = "count(distinct session.id) as count, + ua.ua as ua, + ua.browser_type"; + + $this->params['groupby'] = array('ua.browser_type'); + + $this->params['orderby'] = array('count'); + + return $s->query($this->params); + + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/sessionsCount.php b/modules/base/metrics/sessionsCount.php index 2675f0f35..46f4f1431 100644 --- a/modules/base/metrics/sessionsCount.php +++ b/modules/base/metrics/sessionsCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Dashboard Core metrics By Day * diff --git a/modules/base/metrics/topClicks.php b/modules/base/metrics/topClicks.php index e121a99ef..9c89ab4f8 100644 --- a/modules/base/metrics/topClicks.php +++ b/modules/base/metrics/topClicks.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Clicks Metric * @@ -64,36 +62,6 @@ function generate() { return $c->query($this->params); - - /* - SELECT - count(click_id) as count, - click_x, - click_y, - page_width, - page_height, - dom_element_x, - dom_element_y, - position - FROM - %s - WHERE - true - %s - %s - GROUP BY - position - ORDER BY - count DESC - LIMIT - %s", - $this->setTable($this->config['clicks_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - */ - } diff --git a/modules/base/metrics/topEntryPages.php b/modules/base/metrics/topEntryPages.php index 7af81e481..ec7501169 100644 --- a/modules/base/metrics/topEntryPages.php +++ b/modules/base/metrics/topEntryPages.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Entry Pages Metric * diff --git a/modules/base/metrics/topExitPages.php b/modules/base/metrics/topExitPages.php index a87cec320..60c1402fb 100644 --- a/modules/base/metrics/topExitPages.php +++ b/modules/base/metrics/topExitPages.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Exit Pages Metric * diff --git a/modules/base/metrics/topHosts.php b/modules/base/metrics/topHosts.php index fe13329f1..b5f0920b4 100644 --- a/modules/base/metrics/topHosts.php +++ b/modules/base/metrics/topHosts.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Hosts Metric * @@ -44,8 +42,8 @@ function owa_topHosts($params = null) { function generate() { - $this->params['select'] = "count(session.host_id) as count, " . - " host.id, + $this->params['select'] = "count(session.host_id) as count, + host.id, host.host, host.full_host, host.ip_address"; @@ -62,36 +60,6 @@ function generate() { return $s->query($this->params); - /* - - SELECT - count(sessions.host_id) as count, - hosts.id, - hosts.host, - hosts.full_host, - hosts.ip_address - - FROM - %s as sessions, %s as hosts - WHERE - sessions.host_id = hosts.id - %s - %s - GROUP BY - hosts.id - ORDER BY - count DESC - LIMIT - %s", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['hosts_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - - */ - } diff --git a/modules/base/metrics/topPages.php b/modules/base/metrics/topPages.php index 7475fe2ce..f6fd15ba3 100644 --- a/modules/base/metrics/topPages.php +++ b/modules/base/metrics/topPages.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Web Pages Metric * diff --git a/modules/base/metrics/topReferers.php b/modules/base/metrics/topReferers.php index 35e1e4e25..d478a1314 100644 --- a/modules/base/metrics/topReferers.php +++ b/modules/base/metrics/topReferers.php @@ -1,78 +1,75 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_topReferers extends owa_metric { - - function owa_topReferers($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $s = owa_coreAPI::entityFactory('base.session'); - - $r = owa_coreAPI::entityFactory('base.referer'); - - $this->params['related_objs'] = array('referer_id' => $r); - - $this->setTimePeriod($this->params['period']); - - $this->params['select'] = "count(referer.id) as count, - sum(session.num_pageviews) as page_views, - url, - page_title, - site_name, - query_terms, - snippet, - refering_anchortext, - is_searchengine"; - - $this->params['groupby'] = array('referer.url'); - - $this->params['orderby'] = array('count'); - - return $s->query($this->params); - - - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_topReferers extends owa_metric { + + function owa_topReferers($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $s = owa_coreAPI::entityFactory('base.session'); + + $r = owa_coreAPI::entityFactory('base.referer'); + + $this->params['related_objs'] = array('referer_id' => $r); + + $this->setTimePeriod($this->params['period']); + + $this->params['select'] = "count(referer.id) as count, + sum(session.num_pageviews) as page_views, + url, + page_title, + site_name, + query_terms, + snippet, + refering_anchortext, + is_searchengine"; + + $this->params['groupby'] = array('referer.url'); + + $this->params['orderby'] = array('count'); + + return $s->query($this->params); + + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/topReferingAnchors.php b/modules/base/metrics/topReferingAnchors.php index c1ec62d85..02631cf29 100644 --- a/modules/base/metrics/topReferingAnchors.php +++ b/modules/base/metrics/topReferingAnchors.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Anchors Metric * @@ -62,35 +60,6 @@ function generate() { return $s->query($this->params); - /* - - SELECT - count(sessions.session_id) as count, - referers.refering_anchortext - FROM - %s as referers, - %s as sessions - WHERE - referers.id != 0 - AND refering_anchortext != '' - AND referers.is_searchengine = '0' - AND referers.id = sessions.referer_id - %s - %s - GROUP BY - referers.refering_anchortext - ORDER BY - count DESC - LIMIT - %s", - $this->setTable($this->config['referers_table']), - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - - */ - } diff --git a/modules/base/metrics/topReferingHosts.php b/modules/base/metrics/topReferingHosts.php index 9e9eb56a8..21a2d0370 100644 --- a/modules/base/metrics/topReferingHosts.php +++ b/modules/base/metrics/topReferingHosts.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Refering Hosts Metric * @@ -60,34 +58,6 @@ function generate() { return $s->query($this->params); - /* - - SELECT - count(sessions.session_id) as count, - referers.site - FROM - %s as referers, - %s as sessions - WHERE - referers.id != 0 - AND referers.id = sessions.referer_id - %s - %s - GROUP BY - referers.site - ORDER BY - count DESC - LIMIT - %s", - $this->setTable($this->config['referers_table']), - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - - */ - } diff --git a/modules/base/metrics/topReferingKeywords.php b/modules/base/metrics/topReferingKeywords.php index 34ceb31f3..2f02834e0 100644 --- a/modules/base/metrics/topReferingKeywords.php +++ b/modules/base/metrics/topReferingKeywords.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Top Refering Keywords Metric * @@ -61,35 +59,6 @@ function generate() { return $s->query($this->params); - /* - - SELECT - count(sessions.session_id) as count, - referers.query_terms - FROM - %s as referers, - %s as sessions - WHERE - referers.id != 0 - and query_terms != '' - AND referers.id = sessions.referer_id - %s - %s - GROUP BY - referers.query_terms - ORDER BY - count DESC - LIMIT - %s", - $this->setTable($this->config['referers_table']), - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - - */ - } diff --git a/modules/base/metrics/topVisitors.php b/modules/base/metrics/topVisitors.php index 561eec859..7f695e49a 100644 --- a/modules/base/metrics/topVisitors.php +++ b/modules/base/metrics/topVisitors.php @@ -1,97 +1,66 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_topVisitors extends owa_metric { - - function owa_topVisitors($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $s = owa_coreAPI::entityFactory('base.session'); - - $this->setTimePeriod($this->params['period']); - - $this->params['select'] = "count(visitor_id) as count, - visitor_id as vis_id, - user_name, - user_email"; - - $this->params['groupby'] = array('vis_id'); - - $this->params['orderby'] = array('count'); - - return $s->query($this->params); - - /* - - $sql = sprintf(" - SELECT - count(visitor_id) as count, - visitor_id as vis_id, - user_name, - user_email - FROM - %s - WHERE - true - %s - %s - GROUP BY - vis_id - ORDER BY - count DESC - LIMIT - %s", - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - - return $this->db->get_results($sql); - - */ - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_topVisitors extends owa_metric { + + function owa_topVisitors($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $s = owa_coreAPI::entityFactory('base.session'); + + $this->setTimePeriod($this->params['period']); + + $this->params['select'] = "count(visitor_id) as count, + visitor_id as vis_id, + user_name, + user_email"; + + $this->params['groupby'] = array('vis_id'); + + $this->params['orderby'] = array('count'); + + return $s->query($this->params); + + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/visitorTypesCount.php b/modules/base/metrics/visitorTypesCount.php index 3a31a4765..b33d2f1ee 100644 --- a/modules/base/metrics/visitorTypesCount.php +++ b/modules/base/metrics/visitorTypesCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * New and Repeat user Counts * diff --git a/modules/base/metrics/visitorsAge.php b/modules/base/metrics/visitorsAge.php index bd7bba43e..20938da40 100644 --- a/modules/base/metrics/visitorsAge.php +++ b/modules/base/metrics/visitorsAge.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_metric.php'); - /** * Visitors Age * @@ -64,37 +62,6 @@ function generate() { return $s->query($this->params); - /* - $sql = sprintf(" - SELECT - count(distinct sessions.visitor_id) as count, - visitors.first_session_year, - visitors.first_session_month, - visitors.first_session_day, - visitors.first_session_timestamp as timestamp - FROM - %s as sessions, %s as visitors - WHERE - sessions.visitor_id = visitors.visitor_id - %s - %s - GROUP BY - visitors.first_session_year, - visitors.first_session_month, - visitors.first_session_day - ORDER BY - visitors.first_session_year DESC, - visitors.first_session_month DESC, - visitors.first_session_day DESC", - - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['visitors_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - return $this->db->get_results($sql); - */ } diff --git a/modules/base/metrics/visitorsList.php b/modules/base/metrics/visitorsList.php index 0a28394c7..aa86d9ca3 100644 --- a/modules/base/metrics/visitorsList.php +++ b/modules/base/metrics/visitorsList.php @@ -1,75 +1,73 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_visitorsList extends owa_metric { - - function owa_visitorsList($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $sql = sprintf(" - SELECT - distinct sessions.visitor_id as visitor_id, - visitors.user_name, - visitors.user_email - FROM - %s as sessions, - %s as visitors - WHERE - sessions.visitor_id = visitors.visitor_id - %s - %s - LIMIT - %s", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['visitors_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']), - $this->params['limit'] - ); - - return $this->db->get_results($sql); - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_visitorsList extends owa_metric { + + function owa_visitorsList($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $sql = sprintf(" + SELECT + distinct sessions.visitor_id as visitor_id, + visitors.user_name, + visitors.user_email + FROM + %s as sessions, + %s as visitors + WHERE + sessions.visitor_id = visitors.visitor_id + %s + %s + LIMIT + %s", + $this->setTable($this->config['sessions_table']), + $this->setTable($this->config['visitors_table']), + $this->time_period($this->params['period']), + $this->add_constraints($this->params['constraints']), + $this->params['limit'] + ); + + return $this->db->get_results($sql); + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/metrics/visitorsUserAgentCount.php b/modules/base/metrics/visitorsUserAgentCount.php index c3da75d18..6631e4e26 100644 --- a/modules/base/metrics/visitorsUserAgentCount.php +++ b/modules/base/metrics/visitorsUserAgentCount.php @@ -1,77 +1,75 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_visitorsUserAgentCount extends owa_metric { - - function owa_visitorsUserAgentCount($params = null) { - - $this->params = $params; - - $this->owa_metric(); - - return; - - } - - function generate() { - - $sql = sprintf(" - SELECT - count(distinct sessions.session_id) as count, - ua.ua as ua, - ua.browser_type - FROM - %s as sessions, - %s as ua - WHERE - ua.id = sessions.ua_id - %s - %s - GROUP BY - ua.browser_type - ORDER BY - count DESC - ", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['ua_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - ); - - return $this->db->get_results($sql); - } - - -} - - -?> + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_visitorsUserAgentCount extends owa_metric { + + function owa_visitorsUserAgentCount($params = null) { + + $this->params = $params; + + $this->owa_metric(); + + return; + + } + + function generate() { + + $sql = sprintf(" + SELECT + count(distinct sessions.session_id) as count, + ua.ua as ua, + ua.browser_type + FROM + %s as sessions, + %s as ua + WHERE + ua.id = sessions.ua_id + %s + %s + GROUP BY + ua.browser_type + ORDER BY + count DESC + ", + $this->setTable($this->config['sessions_table']), + $this->setTable($this->config['ua_table']), + $this->time_period($this->params['period']), + $this->add_constraints($this->params['constraints']) + ); + + return $this->db->get_results($sql); + } + + +} + + +?> diff --git a/modules/base/metrics/visitsFromDirectNavCount.php b/modules/base/metrics/visitsFromDirectNavCount.php index aa783db7f..73a2ac3c3 100644 --- a/modules/base/metrics/visitsFromDirectNavCount.php +++ b/modules/base/metrics/visitsFromDirectNavCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Visits From Direct Navigation Count Metric * @@ -58,22 +56,6 @@ function generate() { $this->params['constraints']['source'] = array('operator' => '=', 'value' => ''); return $s->query($this->params); - /* - - SELECT - count(sessions.session_id) as count - FROM - %s as sessions - WHERE - sessions.referer_id = '0' - AND sessions.source = '' - %s - %s", - $this->setTable($this->config['sessions_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - - */ } diff --git a/modules/base/metrics/visitsFromFeedsCount.php b/modules/base/metrics/visitsFromFeedsCount.php index f887c3a1b..c86625ca2 100644 --- a/modules/base/metrics/visitsFromFeedsCount.php +++ b/modules/base/metrics/visitsFromFeedsCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Visits From Feeds Count Metric * @@ -58,26 +56,6 @@ function generate() { $this->params['constraints']['referer.is_searchengine'] = array('operator' => '!=', 'value' => 1); return $s->query($this->params); - /* - - $sql = sprintf("select - count(sessions.session_id) as source_count - FROM - %s as sessions, - %s as referers - WHERE - sessions.referer_id = referers.id - AND sessions.source = 'feed' - AND referers.is_searchengine = 0 - %s - %s - ", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['referers_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - - */ } diff --git a/modules/base/metrics/visitsFromSearchEnginesCount.php b/modules/base/metrics/visitsFromSearchEnginesCount.php index 687d48f6a..98fc19d27 100644 --- a/modules/base/metrics/visitsFromSearchEnginesCount.php +++ b/modules/base/metrics/visitsFromSearchEnginesCount.php @@ -16,8 +16,6 @@ // $Id$ // -require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); - /** * Visits From Search Engines Count Metric * @@ -57,25 +55,6 @@ function generate() { $this->params['constraints']['referer.is_searchengine'] = 1; return $s->query($this->params); - /* - - $sql = sprintf("select - count(sessions.session_id) as se_count - FROM - %s as sessions, - %s as referers - WHERE - sessions.referer_id = referers.id - AND referers.is_searchengine = 1 - AND referers.id != 0 - %s - %s", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['referers_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - - */ } diff --git a/modules/base/metrics/visitsFromSitesCount.php b/modules/base/metrics/visitsFromSitesCount.php index d0d0eea18..3450d7ebf 100644 --- a/modules/base/metrics/visitsFromSitesCount.php +++ b/modules/base/metrics/visitsFromSitesCount.php @@ -59,26 +59,6 @@ function generate() { $this->params['constraints']['source'] = array('operator' => '=', 'value' => ''); return $s->query($this->params); - /* - - $sql = sprintf("select - count(sessions.session_id) as site_count - FROM - %s as sessions, - %s as referers - WHERE - sessions.referer_id = referers.id - AND referers.is_searchengine = 0 - AND sessions.source = '' - AND referers.id != 0 - %s - %s", - $this->setTable($this->config['sessions_table']), - $this->setTable($this->config['referers_table']), - $this->time_period($this->params['period']), - $this->add_constraints($this->params['constraints']) - - */ } diff --git a/modules/base/module.php b/modules/base/module.php index 42415586d..a574317ba 100644 --- a/modules/base/module.php +++ b/modules/base/module.php @@ -41,6 +41,7 @@ function owa_baseModule() { $this->author = 'Peter Adams'; $this->version = '1.0'; $this->description = 'Base functionality for OWA.'; + $this->config_required = false; $this->owa_module(); @@ -70,6 +71,12 @@ function registerAdminPanels() { 'anchortext' => 'Site Roster', 'group' => 'General', 'order' => 3)); + + $this->addAdminPanel(array('do' => 'base.optionsModules', + 'priviledge' => 'admin', + 'anchortext' => 'Modules Admin', + 'group' => 'General', + 'order' => 3)); return; @@ -78,13 +85,48 @@ function registerAdminPanels() { function registerNavigation() { $this->addNavigationLink(array('view' => 'base.reportDocument', + 'nav_name' => 'subnav', 'ref' => 'base.reportClicks', 'priviledge' => 'viewer', 'anchortext' => 'Click Map Report', 'order' => 1)); - + $this->addNavigationLink(array('view' => 'base.report', + 'nav_name' => 'top_level_report_nav', + 'ref' => 'base.reportDashboard', + 'priviledge' => 'viewer', + 'anchortext' => 'Dashboard', + 'order' => 1)); + + $this->addNavigationLink(array('view' => 'base.report', + 'nav_name' => 'top_level_report_nav', + 'ref' => 'base.reportVisitors', + 'priviledge' => 'viewer', + 'anchortext' => 'Visitors', + 'order' => 3)); + + $this->addNavigationLink(array('view' => 'base.report', + 'nav_name' => 'top_level_report_nav', + 'ref' => 'base.reportTraffic', + 'priviledge' => 'viewer', + 'anchortext' => 'Traffic Sources', + 'order' => 2)); + + $this->addNavigationLink(array('view' => 'base.report', + 'nav_name' => 'top_level_report_nav', + 'ref' => 'base.reportContent', + 'priviledge' => 'viewer', + 'anchortext' => 'Content', + 'order' => 4)); + + $this->addNavigationLink(array('view' => 'base.report', + 'nav_name' => 'top_level_report_nav', + 'ref' => 'base.reportFeeds', + 'priviledge' => 'viewer', + 'anchortext' => 'Feeds', + 'order' => 5)); + return; } diff --git a/modules/base/optionsGeneral.php b/modules/base/optionsGeneral.php index 60a6f2c41..6718d6660 100644 --- a/modules/base/optionsGeneral.php +++ b/modules/base/optionsGeneral.php @@ -1,64 +1,68 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_optionsGeneralView extends owa_view { - - function owa_optionsGeneralView($params) { - - $this->owa_view($params); - //set priviledge level - $this->_setPriviledgeLevel('admin'); - //set page type - $this->_setPageType('Administration Page'); - - return; - } - - function construct() { - - // load template - $this->body->set_template('options_general.tpl'); - // fetch admin links from all modules - $this->body->set('headline', 'General Configuration Options'); - - // assign config data - $this->body->set('config', $this->config); - - return; - } - - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_optionsGeneralView extends owa_view { + + function owa_optionsGeneralView($params) { + + $this->owa_view($params); + //set priviledge level + $this->_setPriviledgeLevel('admin'); + //set page type + $this->_setPageType('Administration Page'); + + return; + } + + function construct($data) { + + // load template + $this->body->set_template('options_general.tpl'); + // fetch admin links from all modules + $this->body->set('headline', 'General Configuration Options'); + + if (empty($data['configuration'])): + $data['configuration'] = $this->c->fetch('base'); + endif; + + //print_r($data['config']); + // assign config data + $this->body->set('config', $data['configuration']); + + return; + } + + +} + + ?> \ No newline at end of file diff --git a/modules/base/optionsModules.php b/modules/base/optionsModules.php new file mode 100644 index 000000000..02bb472f3 --- /dev/null +++ b/modules/base/optionsModules.php @@ -0,0 +1,142 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_optionsModulesController extends owa_controller { + + function owa_optionsModulesController($params) { + $this->owa_controller($params); + $this->priviledge_level = 'admin'; + + return; + } + + function action() { + + $path = OWA_BASE_CLASSES_DIR.'modules'.DIRECTORY_SEPARATOR; + $dirs = array(); + + if ($handle = opendir($path)): + while (($file = readdir($handle)) !== false) { + + // test for '.' in dir name + if (strpos($file, '.') === false): + + // test for whether file is a dir + if (is_dir($path.$file)): + + $mod = owa_coreAPI::moduleClassFactory($file); + $dirs[$file]['name'] = $mod->name; + $dirs[$file]['display_name'] = $mod->display_name; + $dirs[$file]['author'] = $mod->author; + $dirs[$file]['group'] = $mod->group; + $dirs[$file]['version'] = $mod->version; + $dirs[$file]['description'] = $mod->description; + $dirs[$file]['config_required'] = $mod->config_required; + //$dirs['stats'] = lstat($path.$file); + + endif; + + endif; + } + endif; + + closedir($handle); + + ksort($dirs); + + // remove base module so it can't be deactivated + unset($dirs['base']); + + $active_modules = $this->c->get('base', 'modules'); + + foreach ($active_modules as $module) { + + if (!empty($dirs[$module])): + $dirs[$module]['status'] = 'active'; + endif; + } + + $data = array(); + $data['view'] = 'base.options'; + $data['subview'] = 'base.optionsModules'; + $data['view_method'] = 'delegate'; + $data['modules'] = $dirs; + + return $data; + + } + +} + +/** + * Options Modules View + * + * @author Peter Adams + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_optionsModulesView extends owa_view { + + function owa_optionsModulesView($params) { + + $this->owa_view($params); + //set priviledge level + $this->_setPriviledgeLevel('admin'); + //set page type + $this->_setPageType('Administration Page'); + + return; + } + + function construct($data) { + + // load template + $this->body->set_template('options_modules.tpl'); + // fetch admin links from all modules + $this->body->set('headline', 'Modules Administration'); + + $this->body->set('modules', $data['modules']); + + return; + } + + +} + + +?> \ No newline at end of file diff --git a/modules/base/optionsUpdate.php b/modules/base/optionsUpdate.php index 85489acc0..584f4a26d 100644 --- a/modules/base/optionsUpdate.php +++ b/modules/base/optionsUpdate.php @@ -1,78 +1,77 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_optionsUpdateController extends owa_controller { - - function owa_optionsUpdateController($params) { - $this->owa_controller($params); - $this->priviledge_level = 'admin'; - - return; - } - - function action() { - - //create the new config array - $new_config = array(); - - // needed for following DB queries just in case the various - // implementations of the GUI does not allow you to set this. - $new_config['configuration_id'] = $this->config['configuration_id']; - - foreach ($this->params['config'] as $key => $value) { - - // update exising config, needed? - $this->config[$key] = $value; - //add to config going to the db - $new_config[$key] = $value; - - } - - owa_settings::save($new_config); - - $this->e->notice("Configuration changes saved to database."); - - $data = array(); - $data['view'] = 'base.options'; - $data['subview'] = 'base.optionsGeneral'; - $data['view_method'] = 'delegate'; - $data['status_msg'] = $this->getMsg(2500); - - return $data; - - } - -} - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_optionsUpdateController extends owa_controller { + + function owa_optionsUpdateController($params) { + $this->owa_controller($params); + $this->priviledge_level = 'admin'; + + return; + } + + function action() { + + + $c = owa_coreAPI::entityFactory('base.configuration'); + $c->getByPk('id', $this->config['configuration_id']); + + $db_settings = array('base' => $this->params['config']); + + $c->set('settings', serialize($db_settings)); + + $v = $c->get('id'); + + if (empty($v)): + $c->set('id', $this->config['configuration_id']); + $c->create(); + else: + $c->update(); + endif; + + $this->e->notice("Configuration changes saved to database."); + + $data = array(); + $data['view'] = 'base.options'; + $data['subview'] = 'base.optionsGeneral'; + $data['view_method'] = 'delegate'; + $data['configuration'] = $db_settings['base']; + $data['status_msg'] = $this->getMsg(2500); + + return $data; + + } + +} + + ?> \ No newline at end of file diff --git a/modules/base/report.php b/modules/base/report.php index a61f289ba..b7d4dce65 100644 --- a/modules/base/report.php +++ b/modules/base/report.php @@ -107,6 +107,11 @@ function construct($data) { $this->body->set('news', $news); + $api = &owa_coreAPI::singleton(); + $data['nav'] = $api->getNavigation('base.report', 'top_level_report_nav'); + + $this->body->set('top_level_report_nav', $data['nav']); + // load body template $this->body->set_template('report.tpl'); diff --git a/modules/base/reportDocument.php b/modules/base/reportDocument.php index 1e683585a..9298ae206 100644 --- a/modules/base/reportDocument.php +++ b/modules/base/reportDocument.php @@ -102,7 +102,7 @@ function action() { )); // get navigation - $data['nav'] = $api->getNavigation('base.reportDocument'); + $data['nav'] = $api->getNavigation('base.reportDocument', 'subnav'); $data['view'] = 'base.report'; $data['subview'] = 'base.reportDocument'; diff --git a/modules/base/sites.php b/modules/base/sites.php index abdaefe8e..eb79abb49 100644 --- a/modules/base/sites.php +++ b/modules/base/sites.php @@ -54,7 +54,6 @@ function construct() { $s = owa_coreAPI::entityFactory('base.site'); $sites = $s->find(); - print_r($sites); $this->body->set('sites', $sites); return; diff --git a/modules/base/sitesAdd.php b/modules/base/sitesAdd.php index 75dcb1bb0..729bde38c 100644 --- a/modules/base/sitesAdd.php +++ b/modules/base/sitesAdd.php @@ -79,29 +79,31 @@ function construct($data) { class owa_sitesAddController extends owa_controller { function owa_sitesAddController($params) { + $this->owa_controller($params); + $this->priviledge_level = 'admin'; + + // Config for the domain validation + $domain_conf = array('substring' => 'http', 'position' => 0, 'operator' => '!=', 'errorMsgTemplate' => 'Please remove the "http://" from your begining of your domain.'); + + // Add validations to the run + $this->addValidation('domain', $this->params['domain'], 'subStringPosition', $domain_conf); + $this->addValidation('domain', $this->params['domain'], 'required'); + + return; } function action() { - - if (empty($this->params['domain'])): - $data['view_method'] = 'delegate'; // Delegate, redirect - $data['view'] = 'base.install'; - $data['subview'] = 'base.installDefaultSiteProfile'; - $data['error_msg'] = $this->getMsg(3307); - $data['site'] = $this->params; - - return $data; - endif; + $this->params['domain'] = $this->params['protocol'].$this->params['domain']; $s = owa_coreAPI::entityFactory('base.site'); $s->getByColumn('domain', $this->params['domain']); $id = $s->get('id'); - - if(empty($id)): + if(empty($id)): + $site = owa_coreAPI::entityFactory('base.site'); $site->set('site_id', owa_lib::setStringGuid($this->params['domain'])); $site->set('name', $this->params['name']); @@ -109,22 +111,34 @@ function action() { $site->set('description', $this->params['description']); $site->set('site_family', $this->params['site_family']); $site->create(); - + $data['view_method'] = 'redirect'; $data['view'] = 'base.options'; $data['subview'] = 'base.sites'; $data['status_code'] = 3202; - + else: - + $data['view_method'] = 'delegate'; $data['view'] = 'base.options'; $data['subview'] = 'base.sitesAdd'; $data['error_msg'] = $this->getMsg(3206); $data['site'] = $this->params; - + endif; + + return $data; + } + + function errorAction() { + $data['view_method'] = 'delegate'; + $data['view'] = 'base.options'; + $data['subview'] = 'base.sitesAdd'; + $data['error_msg'] = $this->getMsg(3307); + $data['site'] = $this->params; + $data['validation_errors'] = $this->getValidationErrorMsgs(); + return $data; } diff --git a/modules/base/sitesDelete.php b/modules/base/sitesDelete.php index 5f51e30cd..5b225ced8 100644 --- a/modules/base/sitesDelete.php +++ b/modules/base/sitesDelete.php @@ -17,7 +17,6 @@ // require_once(OWA_BASE_DIR.'/owa_controller.php'); -require_once(OWA_BASE_DIR.'/owa_user.php'); /** * Delete Site Controller diff --git a/modules/base/templates/css.tpl b/modules/base/templates/css.tpl index 5ad038558..3bedb024f 100644 --- a/modules/base/templates/css.tpl +++ b/modules/base/templates/css.tpl @@ -14,6 +14,7 @@ fieldset{margin: 7px; border:1px solid #cccccc;} /* NAVIGATION */ #sub_nav {padding:5px;} +.top_level_nav{font-size:20px;} .nav_links {list-style:none; margin:0px; padding:0px;} .nav_links li {float: left; padding-right:20px;} .nav_links li a {text-decoration: none; } @@ -27,18 +28,20 @@ fieldset{margin: 7px; border:1px solid #cccccc;} .inline_h3 {font-size:16px;} .inline_h4 {font-size:14px;} .headline {font-size:20px; background-color:#E0EEEE;color:;border-color:#000000;padding:6px; font-weight:bold;margin: 0px 0px 0px 0px;} -.panel_headline {font-size:18px; background-color:#FFF8DC;padding:6px;font-weight:bold;margin: 0px 0px 10px 0px;border-bottom:solid 1px} +.panel_headline {font-size:18px; background-color:#FFF8DC;padding:10px;font-weight:bold;margin: 0px 0px 20px 0px;border-bottom:solid 1px} .sub-legend {font-size:16px;font-weight:bold; } /* DATA TABLES */ .h_label {font-size:14px; font-weight:bold;} .indented_header_row {padding:0px 0px 0px 20px;} -#layout_panels {border:1px solid;border-collapse: collapse; width:100%;} -#layout_panels td {border:1px solid;border-collapse: collapse;} +#layout_panels {border:1px solid;border-collapse: collapse; width:100%; vertical-align:top;} +#layout_panels td {border:1px solid;border-collapse: collapse; vertical-align:top;} #panel {border-collapse: collapse; width:;border:0px;padding:10px; vertical-align:top;} -#panel td {margin: 0px; width:100%;border-collapse: collapse;border:0px;} +#panel td {margin: 0px; padding-top:0px;width:;border-collapse: collapse;border:0px;} .layout_subview {margin: 0px; padding:0px;border-collapse: collapse;} .subview_content{padding:10px;} +.data_table table {border:0px; solid #000000} +.subview_content td {padding:20ps;} #nav_left {width:240px;} .data {white-space:nowrap; width:auto;} .form {width:;} @@ -84,6 +87,8 @@ fieldset{margin: 7px; border:1px solid #cccccc;} .error{color: #ffffff; border: 2px solid #000000; padding: 5px; background-color: red; font-size: 14px; font-weight:bold;} .tiny_icon{width:10px;padding-left:0px;} .wrap {margin:0px;padding:10px;} +.validation_error {color:red;} + /* LAYOUT */ #admin_nav{font-size:12px;} diff --git a/modules/base/templates/error_validation_summary.tpl b/modules/base/templates/error_validation_summary.tpl new file mode 100644 index 000000000..34c9a31f9 --- /dev/null +++ b/modules/base/templates/error_validation_summary.tpl @@ -0,0 +1,6 @@ +The form that you completed had some errors: +
    + $v): ?> +
  • + +
\ No newline at end of file diff --git a/modules/base/templates/options.tpl b/modules/base/templates/options.tpl index 2af5abfbf..e051654c0 100644 --- a/modules/base/templates/options.tpl +++ b/modules/base/templates/options.tpl @@ -1,36 +1,40 @@ - -
- News - -
- -
- - - - - - - - - - - - - -
- -
-

Open Web Analytics has several configuraion options that can be set using the controls below. Once changes are made click the save button to save the configuration to the database. To learn more about configuring OWA, visit the OWA Wiki

-
+ +
+ News + +
+ +
+ + + + + + + + + + + + + +
+ +
+

Open Web Analytics has several configuraion options that can be set using the controls below. Once changes are made click the save button to save the configuration to the database. To learn more about configuring OWA, visit the OWA Wiki

+
diff --git a/modules/base/templates/options_modules.tpl b/modules/base/templates/options_modules.tpl new file mode 100644 index 000000000..392fb9384 --- /dev/null +++ b/modules/base/templates/options_modules.tpl @@ -0,0 +1,41 @@ +
+
+ + + + + + + + + + + + $v): ?> + + + + + + + + + + +
ModuleVersionDescription
+ + + Deactivate + + Activate + + +
+ + + +There are no additional modules installed. + + + +
\ No newline at end of file diff --git a/modules/base/templates/report.tpl b/modules/base/templates/report.tpl index 221c22f00..8f21f3d6c 100644 --- a/modules/base/templates/report.tpl +++ b/modules/base/templates/report.tpl @@ -1,8 +1,13 @@ - - -
- Report Filters - -
- +
+ + makeNavigation($top_level_report_nav);?> + +
+

+ +

+ Report Filters + +
+ \ No newline at end of file diff --git a/modules/base/templates/report_nav.tpl b/modules/base/templates/report_nav.tpl index ec1238567..99a809136 100644 --- a/modules/base/templates/report_nav.tpl +++ b/modules/base/templates/report_nav.tpl @@ -1,16 +1,2 @@ -
- - - - - - - - - - - - -
-
+ diff --git a/modules/base/templates/sites_addoredit.tpl b/modules/base/templates/sites_addoredit.tpl index e555cda89..0e4348709 100644 --- a/modules/base/templates/sites_addoredit.tpl +++ b/modules/base/templates/sites_addoredit.tpl @@ -1,46 +1,55 @@ -
-
-
- - Add/Edit - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Site ID:
Domain:
Site Name:
Description: - -
- - -
- -
- -
+
+
+
+ + Add/Edit + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Site ID:
Domain: + + + +
+ +
Site Name:
Description: + +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/owa_api.php b/owa_api.php index 161e55a51..7c51ebed0 100644 --- a/owa_api.php +++ b/owa_api.php @@ -1,209 +1,210 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ -class owa_api { - - /** - * Plugins - * - * @var array - */ - var $plugins = array(); - - /** - * API calls from plugins - * - * @var array - */ - var $api_calls = array(); - - /** - * Plugins Directory - * - * @var string - */ - var $plugins_dir; - - /** - * API Type - * - * @var string - */ - var $api_type; - - /** - * Class prefix - * - * @var string - */ - var $class_prefix; - - /** - * Configuration - * - * @var array - */ - var $config; - - /** - * Configuration - * - * @var array - */ - var $e; - - /** - * Constructor - * - * @return owa_api - */ - function owa_api() { - - $this->config = &owa_settings::get_settings(); - $this->e = &owa_error::get_instance(); - - return; - } - - /** - * Get instance of API - * - * @param string $api_type - * @return object $api - * @access public - */ - function get_instance($api_type, $params = null) { - - $api = new owa_api; - - switch ($api_type) { - - case "metric": - require_once(OWA_BASE_DIR.'/owa_metric.php'); - $api->api_type = $api_type; - $api->plugins_dir = OWA_METRICS_DIR; - $api->class_prefix = 'owa_metric_'; - break; - case "graph": - require_once(OWA_BASE_DIR.'/owa_graph.php'); - $api->api_type = $api_type; - $api->plugins_dir = OWA_GRAPHS_DIR; - $api->class_prefix = 'owa_graph_'; - break; - } - - $api->load_plugins(); - - return $api; - } - - /** - * Load Plugins - * - * @access private - */ - function load_plugins($params = null) { - - if ($dir = opendir($this->plugins_dir)): - while (($file = readdir($dir)) !== false) { - - if (strstr($file, '.php') && - substr($file, -1, 1) != "~" && - substr($file, 0, 1) != "#") : - - if (require_once($this->plugins_dir . $file)): - $this->plugins[] = substr($file, 0, -4); - $class = $this->class_prefix . substr($file, 0, -4); - - //print $class; - - $plugin = new $class($params); - - //print get_class($plugin); - - foreach ($plugin->api_calls as $api_call) { - - if (!isset($this->api_calls[$api_call])): - $this->api_calls[$plugin->api_type][$api_call] = $plugin; - else: - $this->e->err(sprintf('API Call "%s" already registered.', $api_call)); - endif; - } - - else: - $this->e->err(sprintf('Cannot load plugin "%s".', substr($file, 0, -4))); - endif; - - endif; - - } - - @closedir($dir); - - endif; - - return; - } - - /** - * Get object - * - * @param array $request_params - * @return array $result - */ - function get($request_params) { - - //need to add error here incase the api call does not exist. - $result = $this->api_calls[$this->api_type][$request_params['api_call']]->generate($request_params); - - switch ($request_params['result_format']) { - - case "assoc_array": - return $result; - break; - case "inverted_array": - - if ($result): - return owa_lib::deconstruct_assoc($result); - else: - return; - endif; - - break; - } - - return $result; - } - -} - -?> + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ +class owa_api { + + /** + * Plugins + * + * @var array + */ + var $plugins = array(); + + /** + * API calls from plugins + * + * @var array + */ + var $api_calls = array(); + + /** + * Plugins Directory + * + * @var string + */ + var $plugins_dir; + + /** + * API Type + * + * @var string + */ + var $api_type; + + /** + * Class prefix + * + * @var string + */ + var $class_prefix; + + /** + * Configuration + * + * @var array + */ + var $config; + + /** + * Configuration + * + * @var array + */ + var $e; + + /** + * Constructor + * + * @return owa_api + */ + function owa_api() { + + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); + $this->e = &owa_error::get_instance(); + + return; + } + + /** + * Get instance of API + * + * @param string $api_type + * @return object $api + * @access public + */ + function get_instance($api_type, $params = null) { + + $api = new owa_api; + + switch ($api_type) { + + case "metric": + require_once(OWA_BASE_DIR.'/owa_metric.php'); + $api->api_type = $api_type; + $api->plugins_dir = OWA_METRICS_DIR; + $api->class_prefix = 'owa_metric_'; + break; + case "graph": + require_once(OWA_BASE_DIR.'/owa_graph.php'); + $api->api_type = $api_type; + $api->plugins_dir = OWA_GRAPHS_DIR; + $api->class_prefix = 'owa_graph_'; + break; + } + + $api->load_plugins(); + + return $api; + } + + /** + * Load Plugins + * + * @access private + */ + function load_plugins($params = null) { + + if ($dir = opendir($this->plugins_dir)): + while (($file = readdir($dir)) !== false) { + + if (strstr($file, '.php') && + substr($file, -1, 1) != "~" && + substr($file, 0, 1) != "#") : + + if (require_once($this->plugins_dir . $file)): + $this->plugins[] = substr($file, 0, -4); + $class = $this->class_prefix . substr($file, 0, -4); + + //print $class; + + $plugin = new $class($params); + + //print get_class($plugin); + + foreach ($plugin->api_calls as $api_call) { + + if (!isset($this->api_calls[$api_call])): + $this->api_calls[$plugin->api_type][$api_call] = $plugin; + else: + $this->e->err(sprintf('API Call "%s" already registered.', $api_call)); + endif; + } + + else: + $this->e->err(sprintf('Cannot load plugin "%s".', substr($file, 0, -4))); + endif; + + endif; + + } + + @closedir($dir); + + endif; + + return; + } + + /** + * Get object + * + * @param array $request_params + * @return array $result + */ + function get($request_params) { + + //need to add error here incase the api call does not exist. + $result = $this->api_calls[$this->api_type][$request_params['api_call']]->generate($request_params); + + switch ($request_params['result_format']) { + + case "assoc_array": + return $result; + break; + case "inverted_array": + + if ($result): + return owa_lib::deconstruct_assoc($result); + else: + return; + endif; + + break; + } + + return $result; + } + +} + +?> diff --git a/owa_auth.php b/owa_auth.php index c3495a35e..24eda762c 100644 --- a/owa_auth.php +++ b/owa_auth.php @@ -155,13 +155,13 @@ function authenticateUser($necessary_role = '') { return $data; endif; endif; - + // lookup user if not already done. if ($this->_is_user == false): // check to see if they are a user. $this->isUser(); endif; - + if ($this->_is_user == true): // check to see if their account is priviledged enough. $priviledged = $this->isPriviledged($necessary_role); @@ -191,13 +191,16 @@ function authenticateUser($necessary_role = '') { * @return object */ function &get_instance() { - - $config = &owa_settings::get_settings(); + + $c = &owa_coreAPI::configSingleton(); + $config = $c->fetch('base'); $auth = &owa_lib::singleton($config['plugin_dir'].'/auth/', 'owa_auth_', $config['authentication']); + + return $auth; } @@ -364,5 +367,4 @@ function encryptPassword($password) { } - ?> \ No newline at end of file diff --git a/owa_base.php b/owa_base.php index 77dd6726e..a79e03cca 100644 --- a/owa_base.php +++ b/owa_base.php @@ -1,4 +1,4 @@ -config = &owa_settings::get_settings(); + $this->c = &owa_coreAPI::configSingleton(); + $this->config = $this->c->fetch('base'); $this->e = &owa_error::get_instance(); return; + } /** @@ -109,7 +119,7 @@ function getMsg($code, $s1 = null, $s2 = null, $s3 = null, $s4 = null) { return $msg; } - + /** * Sets object attributes * @@ -144,5 +154,4 @@ function _setArrayValues($array) { } - ?> \ No newline at end of file diff --git a/owa_browscap.php b/owa_browscap.php index 1fb431af0..2e6f4f2db 100644 --- a/owa_browscap.php +++ b/owa_browscap.php @@ -1,143 +1,141 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_browscap extends owa_base { - - - /** - * main browscap_db maintained by Gary Keith's - * Browser Capabilities project. - * - * @var array - */ - var $browscap_db; - - /** - * Browscap Record for current User agent - * - * @var unknown_type - */ - var $browser; - - /** - * Current user Agent - * - * @var string - */ - var $ua; - - function owa_browscap($ua = '') { - - $this->owa_base(); - - // set user agent - $this->ua = $ua; - - // Load main browscap - $this->browscap_db = $this->load($this->config['browscap.ini']); - - //lookup robot in main browscap db - $this->browser = $this->lookup($this->ua); - $this->e->debug('Browser Name: '. $this->browser->Browser); - - return; - } - - function robotCheck() { - - if ($this->browser->Crawler == true): - return true; - else: - if($this->robotRegexCheck() == true): - return true; - else: - return false; - endif; - endif; - } - - function lookup($user_agent) { - - $cap=null; - - foreach ($this->browscap_db as $key=>$value) { - if (($key!='*')&&(!array_key_exists('Parent',$value))) continue; - $keyEreg='^'.str_replace( - array('\\','.','?','*','^','$','[',']','|','(',')','+','{','}','%'), - array('\\\\','\\.','.','.*','\\^','\\$','\\[','\\]','\\|','\\(','\\)','\\+','\\{','\\}','\\%'), - $key).'$'; - if (preg_match('%'.$keyEreg.'%i',$user_agent)) - { - $cap=array('browser_name_regex'=>strtolower($keyEreg),'browser_name_pattern'=>$key)+$value; - $maxDeep=8; - while (array_key_exists('Parent',$value)&&(--$maxDeep>0)) - $cap += ($value = $this->browscap_db[$value['Parent']]); - break; - } - } - - return ((object)$cap); - - } - - - - function load($file) { - - return parse_ini_file($file, true); - - } - - function robotRegexCheck() { - - $db = new ini_db($this->config['robots.ini']); - $match = $db->match($this->ua); - - if (!empty($match)): - $this->e->debug(sprintf('Last chance robot detect string: %s', $match[0])); - $this->browser->Crawler = true; - return true; - else: - return false; - endif; - - } - - -} - - - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_browscap extends owa_base { + + + /** + * main browscap_db maintained by Gary Keith's + * Browser Capabilities project. + * + * @var array + */ + var $browscap_db; + + /** + * Browscap Record for current User agent + * + * @var unknown_type + */ + var $browser; + + /** + * Current user Agent + * + * @var string + */ + var $ua; + + function owa_browscap($ua = '') { + + $this->owa_base(); + + // set user agent + $this->ua = $ua; + + // Load main browscap + $this->browscap_db = $this->load($this->config['browscap.ini']); + + //lookup robot in main browscap db + $this->browser = $this->lookup($this->ua); + $this->e->debug('Browser Name: '. $this->browser->Browser); + + return; + } + + function robotCheck() { + + if ($this->browser->Crawler == true): + return true; + else: + if($this->robotRegexCheck() == true): + return true; + else: + return false; + endif; + endif; + } + + function lookup($user_agent) { + + $cap=null; + + foreach ($this->browscap_db as $key=>$value) { + if (($key!='*')&&(!array_key_exists('Parent',$value))) continue; + $keyEreg='^'.str_replace( + array('\\','.','?','*','^','$','[',']','|','(',')','+','{','}','%'), + array('\\\\','\\.','.','.*','\\^','\\$','\\[','\\]','\\|','\\(','\\)','\\+','\\{','\\}','\\%'), + $key).'$'; + if (preg_match('%'.$keyEreg.'%i',$user_agent)) + { + $cap=array('browser_name_regex'=>strtolower($keyEreg),'browser_name_pattern'=>$key)+$value; + $maxDeep=8; + while (array_key_exists('Parent',$value)&&(--$maxDeep>0)) + $cap += ($value = $this->browscap_db[$value['Parent']]); + break; + } + } + + return ((object)$cap); + + } + + + + function load($file) { + + return parse_ini_file($file, true); + + } + + function robotRegexCheck() { + + $db = new ini_db($this->config['robots.ini']); + $match = $db->match($this->ua); + + if (!empty($match)): + $this->e->debug(sprintf('Last chance robot detect string: %s', $match[0])); + $this->browser->Crawler = true; + return true; + else: + return false; + endif; + + } + + +} + ?> \ No newline at end of file diff --git a/owa_caller.php b/owa_caller.php index 6712593a1..fa30d95df 100644 --- a/owa_caller.php +++ b/owa_caller.php @@ -1,4 +1,4 @@ -owa_base(); - $this->config = &owa_settings::get_settings(); + if (empty($config['configuration_id'])): + $config['configuration_id'] = 1; + endif; - $this->apply_caller_config($config); + // Applies config from db or cache + $this->c->load($config['configuration_id']); - if ($this->config['fetch_config_from_db'] == true): - $this->load_config_from_db(); - - // Needed to dump the error logger because it was loaded initially with the default setting - // and not the setting stored in the DB. - $this->e = null; - $this->e = owa_error::get_instance(); - endif; + // Applies run time config overrides + $this->c->applyModuleOverrides('base', $config); + // re-fetch the array now that overrides have been applied. + // needed for backwards compatability + $this->config = $this->c->fetch('base'); + + // reloads error logger now that final config values are in place + $this->e = null; + $this->e = owa_error::get_instance(); + // Create Request Container $this->params = &owa_requestContainer::getInstance(); // Load the core API $this->api = &owa_coreAPI::singleton(); + // should only be called once to load all modules $this->api->setupFramework(); - - //ob_end_clean(); - return; } @@ -97,49 +106,6 @@ function handleRequestFromUrl() { } - /** - * Applies caller specific configuration params on top of - * those specified on the global OWA config file. - * - * @param array $config - */ - function apply_caller_config($config) { - - if (!empty($config)): - - foreach ($config as $key => $value) { - - $this->config[$key] = $value; - - } - - endif; - - return; - - } - - /** - * Fetches instance specific configuration params from the database - * - */ - function load_config_from_db() { - - $config_from_db = &owa_settings::fetch($this->config['configuration_id']); - - if (!empty($config_from_db)): - - foreach ($config_from_db as $key => $value) { - - $this->config[$key] = $value; - - } - - endif; - - return; - } - /** * Logs a Page Request * @@ -300,6 +266,7 @@ function performAction($action) { //perfrom authentication $auth = &owa_auth::get_instance(); + $data = $auth->authenticateUser($controller->priviledge_level); // if auth was success then procead to do action specified in the intended controller. @@ -359,7 +326,7 @@ function handleRequest($caller_params = null) { unset($this->params['action']); elseif (!empty($this->params['do'])): - $result = $this->performAction($this->params['do']); + $result = $this->performAction($this->params['do']); //unset($this->params['action']); elseif ($this->params['view']): @@ -374,7 +341,7 @@ function handleRequest($caller_params = null) { //clean up any open db connection if ($this->config['async_db'] == false): - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); $db->close(); endif; @@ -384,4 +351,4 @@ function handleRequest($caller_params = null) { } -?> +?> \ No newline at end of file diff --git a/owa_controller.php b/owa_controller.php index a1f64f922..807937b57 100644 --- a/owa_controller.php +++ b/owa_controller.php @@ -1,90 +1,137 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - - -class owa_controller extends owa_base { - - /** - * Request Parameters passed in from caller - * - * @var array - */ - var $params; - - /** - * The priviledge level required to access this controller - * - * @var string - */ - var $priviledge_level; - - /** - * Constructor - * - * @param array $params - * @return owa_controller - */ - function owa_controller($params) { - - $this->owa_base(); - $this->params = $params; - - return; - - } - - /** - * Handles request from caller - * - */ - function doAction() { - - $this->e->debug('Performing Action: '.get_class($this)); - - return $this->action(); - - } - - function logEvent($event_type, $properties) { - - if (!class_exists('eventQueue')): - require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'eventQueue.php'); - endif; - - $eq = &eventQueue::get_instance(); - return $eq->log($properties, $event_type); - } - -} - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + +class owa_controller extends owa_base { + + /** + * Request Parameters passed in from caller + * + * @var array + */ + var $params; + + /** + * The priviledge level required to access this controller + * + * @var string + */ + var $priviledge_level; + + /** + * data validation control object + * + * @var Object + */ + var $v; + + /** + * Constructor + * + * @param array $params + * @return owa_controller + */ + function owa_controller($params) { + + $this->owa_base(); + $this->params = $params; + + return; + + } + + /** + * Handles request from caller + * + */ + function doAction() { + + $this->e->debug('Performing Action: '.get_class($this)); + + if (!empty($this->v)): + + $this->v->doValidations(); + + if ($this->v->hasErrors == true): + + return $this->errorAction(); + + else: + + return $this->action(); + + endif; + + endif; + + return $this->action(); + + } + + function logEvent($event_type, $properties) { + + if (!class_exists('eventQueue')): + require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'eventQueue.php'); + endif; + + $eq = &eventQueue::get_instance(); + return $eq->log($properties, $event_type); + } + + function createValidator() { + + $this->v = owa_coreAPI::supportClassFactory('base', 'validator'); + + return; + + } + + function addValidation($name, $value, $validation, $conf = array()) { + + if (empty($this->v)): + $this->createValidator(); + endif; + + return $this->v->addValidation($name, $value, $validation, $conf); + + } + + function getValidationErrorMsgs() { + + return $this->v->getErrorMsgs(); + + } + +} + ?> \ No newline at end of file diff --git a/owa_coreAPI.php b/owa_coreAPI.php index f70af036b..6485af387 100644 --- a/owa_coreAPI.php +++ b/owa_coreAPI.php @@ -64,6 +64,57 @@ function &singleton($params = array()) { return $api; } + function &dbSingleton() { + + static $db; + + if (!isset($db)): + + //$c = &owa_coreAPI::configSingleton(); + //$config = $c->fetch('base'); + //$e = &owa_error::get_instance(); + + if (!class_exists('owa_db')): + require_once(OWA_BASE_CLASSES_DIR.'owa_db.php'); + endif; + + $connection_class = "owa_db_" . OWA_DB_TYPE; + $connection_class_path = OWA_PLUGINS_DIR.'/db/' . $connection_class . ".php"; + + if (!include($connection_class_path)): + $e->emerg(sprintf('Cannot locate proper db class at %s. Exiting.', + $connection_class_path)); + return; + else: + $db = new $connection_class; + + //$this->e->debug(sprintf('Using db class at %s.', $connection_class_path)); + endif; + + endif; + + return $db; + + } + + function &configSingleton($params = array()) { + + static $config; + + if(!isset($config)): + + if (!class_exists('owa_settings')): + require_once(OWA_BASE_CLASS_DIR.'settings.php'); + endif; + + $config = owa_coreAPI::supportClassFactory('base', 'settings'); + + endif; + + return $config; + } + + function setupFramework() { if ($this->init != true): @@ -78,14 +129,31 @@ function setupFramework() { function _loadModules() { foreach ($this->config['modules'] as $k => $module) { - require_once(OWA_BASE_DIR.'/modules/'.$module.'/module.php'); - $m = owa_lib::factory(OWA_BASE_DIR.'/'.$module, 'owa_', $module.'Module'); + + $m = owa_coreAPI::moduleClassFactory($module); $this->modules[$m->name] = $m; } return; } + /** + * Produces Module Classes (module.php) + * + * @return Object module class object + */ + function moduleClassFactory($module) { + + if (!class_exists('owa_module')): + require_once(OWA_BASE_CLASSES_DIR.'owa_module.php'); + endif; + + require_once(OWA_BASE_DIR.'/modules/'.$module.'/module.php'); + + return owa_lib::factory(OWA_BASE_CLASSES_DIR.$module, 'owa_', $module.'Module'); + + } + function _loadEntities() { foreach ($this->modules as $k => $module) { @@ -226,7 +294,14 @@ function entityFactory($entity_name) { */ function getMetric($metric_name, $params) { + if (!class_exists('owa_metric')): + + require_once(OWA_BASE_CLASSES_DIR.'owa_metric.php'); + + endif; + $m = owa_coreAPI::moduleSpecificFactory($metric_name, 'metrics', '', $this->params, false); + $m->applyOverrides($params); return $m->generate(); @@ -300,25 +375,51 @@ function getAdminPanels() { /** * Returns a consolidated list of nav links from all active modules for a particular view + * and named navigation element. * + * @param string nav_name the name of the navigation element that you want links for + * @param string sortby the array value to sort the navigation array by * @return array */ - function getNavigation($view) { + function getNavigation($view, $nav_name, $sortby ='order') { $links = array(); foreach ($this->modules as $k => $v) { - $v->registerNavigation(); + + // If the module does not have nav links, register them. needed in case this function is called twice on + // same view. + if (empty($v->nav_links)): + $v->registerNavigation(); + endif; + $module_nav = $v->getNavigationLinks(); + //print_r($module_nav); + + // assemble the navigation for a specific view's named navigation element' foreach ($module_nav as $key => $value) { - $links[$value['view']][] = $value; + $links[$value['view']][$value['nav_name']][] = $value; } } - return $links[$view]; + //print_r($links[$view][$nav_name]); + + // anonymous sorting function, takes sort by variable. + $code = "return strnatcmp(\$a['$sortby'], \$b['$sortby']);"; + + // sort the array + $ret = usort($links[$view][$nav_name], create_function('$a,$b', $code)); + + return $links[$view][$nav_name]; + + } + + function getNavSort($a, $b) { + + return strnatcmp($a['order'], $b['order']); } /** @@ -403,6 +504,6 @@ function stripDocumentUrl($url) { } - } + ?> \ No newline at end of file diff --git a/owa_db.php b/owa_db.php index afac6f00b..94e3f89e6 100644 --- a/owa_db.php +++ b/owa_db.php @@ -1,205 +1,210 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ -class owa_db extends owa_base { - - /** - * Connection string - * - * @var string - */ - var $connection; - - /** - * Number of queries - * - * @var integer - */ - var $num_queries; - - /** - * Raw result object - * - * @var object - */ - var $new_result; - - /** - * Rows - * - * @var array - */ - var $result; - - /** - * Caller Params - * - * @var array - */ - var $params = array(); - - /** - * Status of selecting a databse - * - * @var boolean - */ - var $database_selection; - - /** - * Status of connection - * - * @var boolean - */ - var $connection_status; - - /** - * Number of rows in result set - * - * @var integer - */ - var $num_rows; - - /** - * Number of rows affected by insert/update/delete statements - * - * @var integer - */ - var $rows_affected; - - /** - * Microtime Start of Query - * - * @var unknown_type - */ - var $_start_time; - - /** - * Total Elapsed time of query - * - * @var unknown_type - */ - var $_total_time; - - /** - * Constructor - * - * @return owa_db - * @access public - */ - function owa_db() { - - $this->owa_base(); - - return; - } - - /** - * Connection object factory - * - * @return object - * @access public - * @static - */ - function &get_instance($params = array()) { - - static $db; - - if (!isset($db)): - $this->config = &owa_settings::get_settings(); - $this->e = &owa_error::get_instance(); - - if (empty($this->config['db_class'])): - $class = $this->config['db_type']; - else: - $class = $this->config['db_class']; - endif; - - $connection_class = "owa_db_" . $class; - $connection_class_path = $this->config['db_class_dir'] . $connection_class . ".php"; - - if (!@include($connection_class_path)): - $this->e->emerg(sprintf('Cannot locate proper db class at %s. Exiting.', - $connection_class_path)); - return; - else: - $db = new $connection_class; - - //$this->e->debug(sprintf('Using db class at %s.', $connection_class_path)); - endif; - endif; - - return $db; - } - - /** - * Prepare string - * - * @param string $string - * @return string - */ - function prepare_string($string) { - - $chars = array("\t", "\n"); - return str_replace($chars, " ", $string); - } - - /** - * Starts the query microtimer - * - */ - function _timerStart() { - - $mtime = microtime(); - //$mtime = explode(' ', $mtime); - //$this->_start_time = $mtime[1].substr(round($mtime[0], 4), 1); - $this->_start_time = microtime(); - return; - } - - /** - * Ends the query microtimer and populates $this->_total_time - * - */ - function _timerEnd() { - - $mtime = microtime(); - //$mtime = explode(" ", $mtime); - //$endtime = $mtime[1].substr(round($mtime[0], 4), 1); - $endtime = microtime(); - //$this->_total_time = bcsub($endtime, $this->_start_time, 4); - $this->_total_time = number_format(((substr($endtime,0,9)) + (substr($endtime,-10)) - (substr($this->_start_time,0,9)) - (substr($this->_start_time,-10))),6); - - return; - - } -} - -?> + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ +class owa_db extends owa_base { + + /** + * Connection string + * + * @var string + */ + var $connection; + + /** + * Number of queries + * + * @var integer + */ + var $num_queries; + + /** + * Raw result object + * + * @var object + */ + var $new_result; + + /** + * Rows + * + * @var array + */ + var $result; + + /** + * Caller Params + * + * @var array + */ + var $params = array(); + + /** + * Status of selecting a databse + * + * @var boolean + */ + var $database_selection; + + /** + * Status of connection + * + * @var boolean + */ + var $connection_status; + + /** + * Number of rows in result set + * + * @var integer + */ + var $num_rows; + + /** + * Number of rows affected by insert/update/delete statements + * + * @var integer + */ + var $rows_affected; + + /** + * Microtime Start of Query + * + * @var unknown_type + */ + var $_start_time; + + /** + * Total Elapsed time of query + * + * @var unknown_type + */ + var $_total_time; + + /** + * Constructor + * + * @return owa_db + * @access public + */ + function owa_db() { + + $this->owa_base(); + + return; + } + + /** + * Connection object factory + * + * @return object + * @access public + * @static + */ + function &get_instance($params = array()) { + + static $db; + + if (!isset($db)): + //print 'hello from db'; + $c = &owa_coreAPI::configSingleton(); + $config = $c->fetch('base'); + + $e = &owa_error::get_instance(); + + if (empty($config['db_class'])): + $class = $config['db_type']; + else: + $class = $config['db_class']; + endif; + + $connection_class = "owa_db_" . $class; + $connection_class_path = $config['db_class_dir'] . $connection_class . ".php"; + + if (!@include($connection_class_path)): + + $e->emerg(sprintf('Cannot locate proper db class at %s. Exiting.', + $connection_class_path)); + return; + else: + $db = new $connection_class; + + //$this->e->debug(sprintf('Using db class at %s.', $connection_class_path)); + endif; + + endif; + + return $db; + } + + /** + * Prepare string + * + * @param string $string + * @return string + */ + function prepare_string($string) { + + $chars = array("\t", "\n"); + return str_replace($chars, " ", $string); + } + + /** + * Starts the query microtimer + * + */ + function _timerStart() { + + $mtime = microtime(); + //$mtime = explode(' ', $mtime); + //$this->_start_time = $mtime[1].substr(round($mtime[0], 4), 1); + $this->_start_time = microtime(); + return; + } + + /** + * Ends the query microtimer and populates $this->_total_time + * + */ + function _timerEnd() { + + $mtime = microtime(); + //$mtime = explode(" ", $mtime); + //$endtime = $mtime[1].substr(round($mtime[0], 4), 1); + $endtime = microtime(); + //$this->_total_time = bcsub($endtime, $this->_start_time, 4); + $this->_total_time = number_format(((substr($endtime,0,9)) + (substr($endtime,-10)) - (substr($this->_start_time,0,9)) - (substr($this->_start_time,-10))),6); + + return; + + } +} + +?> diff --git a/owa_entity.php b/owa_entity.php index 20dcaf036..50107f6a4 100644 --- a/owa_entity.php +++ b/owa_entity.php @@ -76,7 +76,7 @@ function getColumns() { function create() { // Setup databse access object - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); $all_cols = $this->getColumns(); @@ -113,7 +113,7 @@ function update($where = '') { endif; // Setup databse access object - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); // Persist object $status = $db->update($this->_getProperties(), $constraint, get_class($this)); @@ -140,7 +140,7 @@ function partialUpdate($named_properties, $where) { } // Setup databse access object - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); // Persist object $status = $db->update($properties, $where, get_class($this)); @@ -157,7 +157,7 @@ function partialUpdate($named_properties, $where) { function delete($id, $col = '') { // Setup databse access object - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); if (empty($col)): $col = 'id'; @@ -179,7 +179,7 @@ function getByPk($col, $value) { function getByColumn($col, $value) { // Setup databse access object - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); $constraint = array($col => $value); @@ -191,7 +191,7 @@ function getByColumn($col, $value) { function find($params = array()) { - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); $params['primary_obj'] = $this; @@ -201,7 +201,7 @@ function find($params = array()) { function query($params) { - $db = &owa_db::get_instance(); + $db = &owa_coreAPI::dbSingleton(); $params['primary_obj'] = $this; diff --git a/owa_env.php b/owa_env.php index 43a9a4cfa..99ec04080 100644 --- a/owa_env.php +++ b/owa_env.php @@ -31,6 +31,7 @@ define('OWA_BASE_DIR', dirname(__FILE__)); define('OWA_BASE_CLASSES_DIR', dirname(__FILE__). DIRECTORY_SEPARATOR); define('OWA_BASE_CLASS_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR); +define('OWA_BASE_MODULE_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR); define('OWA_INCLUDE_DIR', OWA_BASE_DIR.'/includes/'); define('OWA_PEARLOG_DIR', OWA_BASE_DIR.'/includes/Log-1.9.9'); define('OWA_PHPMAILER_DIR', OWA_BASE_DIR.'/includes/phpmailer-1.73/'); @@ -40,4 +41,4 @@ define('OWA_GRAPHS_DIR', OWA_BASE_DIR.'/plugins/graphs/'); define('OWA_VERSION', '1.0'); -?> +?> \ No newline at end of file diff --git a/owa_error.php b/owa_error.php index 7c76b54b1..df2b0d674 100644 --- a/owa_error.php +++ b/owa_error.php @@ -17,7 +17,6 @@ // require_once 'owa_env.php'; require_once (OWA_PEARLOG_DIR . '/Log.php'); -require_once (OWA_PLUGINS_DIR . '/log/winstatic.php'); /** * Error handler @@ -64,7 +63,8 @@ function &get_instance() { if (!isset($logger)): - $config = &owa_settings::get_settings(); + $c = &owa_coreAPI::configSingleton(); + $config = $c->fetch('base'); switch ($config['error_handler']) { @@ -288,7 +288,8 @@ function handlePhpError($errno = null, $errmsg, $filename, $linenum, $vars) { $err .= "\n\n"; $conf = array('mode' => 0600, 'timeFormat' => '%X %x'); - $config = &owa_settings::get_settings(); + $c = &owa_coreAPI::configSingleton(); + $config = $c->fetch('base'); $logger = &Log::singleton('file', $config['error_log_file'], posix_getpid(), $conf); $file_mask = PEAR_LOG_ALL; $logger->setMask($file_mask); @@ -296,13 +297,7 @@ function handlePhpError($errno = null, $errmsg, $filename, $linenum, $vars) { return; } - /* - function log($errmsg, $priority) { - - return $this->logger->log($errmsg, $priority); - } - */ -} +} ?> \ No newline at end of file diff --git a/owa_httpRequest.php b/owa_httpRequest.php index 3b671d814..7499868e4 100644 --- a/owa_httpRequest.php +++ b/owa_httpRequest.php @@ -16,11 +16,10 @@ // $Id$ // -require_once('owa_env.php'); - if(!class_exists('snoopy')): require_once(OWA_INCLUDE_DIR.'/Snoopy.class.php'); endif; + /** * Wrapper for Snoopy http request class * @@ -73,7 +72,8 @@ class owa_http extends Snoopy { function owa_http() { - $this->config = &owa_settings::get_settings(); + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); $this->e = &owa_error::get_instance(); $this->agent = $this->config['owa_user_agent']; diff --git a/owa_install.php b/owa_install.php index 4dfe422ab..00ebb5a07 100644 --- a/owa_install.php +++ b/owa_install.php @@ -1,94 +1,93 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ -class owa_install extends owa_base{ - - /** - * Data access object - * - * @var object - */ - var $db; - - /** - * Version of string - * - * @var string - */ - var $version; - - /** - * Params array - * - * @var array - */ - var $params; - - /** - * Module name - * - * @var unknown_type - */ - var $module; - - /** - * Constructor - * - * @return owa_install - */ - - function owa_install() { - - $this->owa_base(); - $this->db = &owa_db::get_instance(); - - return; - } - - function addDefaultSite() { - - $site = new owa_site; - $site->name = $this->params['name']; - $site->description = $this->params['description']; - if (!empty($site->site_family)): - $site->site_family = $this->params['description']; - else: - $site->site_family = 1; - endif; - $site_id = $site->save(); - - return; - } - -} - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ +class owa_install extends owa_base{ + + /** + * Data access object + * + * @var object + */ + var $db; + + /** + * Version of string + * + * @var string + */ + var $version; + + /** + * Params array + * + * @var array + */ + var $params; + + /** + * Module name + * + * @var unknown_type + */ + var $module; + + /** + * Constructor + * + * @return owa_install + */ + + function owa_install() { + + $this->owa_base(); + $this->db = &owa_coreAPI::dbSingleton(); + + return; + } + + function addDefaultSite() { + + $site = new owa_site; + $site->name = $this->params['name']; + $site->description = $this->params['description']; + if (!empty($site->site_family)): + $site->site_family = $this->params['description']; + else: + $site->site_family = 1; + endif; + $site_id = $site->save(); + + return; + } + +} + ?> \ No newline at end of file diff --git a/owa_lib.php b/owa_lib.php index 8ebb2a8a3..0870c38eb 100644 --- a/owa_lib.php +++ b/owa_lib.php @@ -19,7 +19,7 @@ require_once 'owa_env.php'; require_once(OWA_PEARLOG_DIR . '/Log.php'); require_once(OWA_INCLUDE_DIR.'/class.inputfilter.php'); -require_once(OWA_BASE_DIR.'/owa_settings_class.php'); +//require_once(OWA_BASE_CLASS_DIR.'settings.php'); /** * Utility Functions @@ -391,64 +391,6 @@ function get_current_url() { return $url; } - /** - * Builds date param array from GET - * - * @return array - */ - function getRestparams() { - - $config = &owa_settings::get_settings(); - - $params = array(); - - $params['owa_action'] = $_GET['owa_action']; - $params['owa_page'] = $_GET['owa_page']; - $params['year'] = $_GET['year']; - $params['month'] = $_GET['month']; - $params['day'] = $_GET['day']; - $params['dayofyear'] = $_GET['dayofyear']; - $params['weekofyear'] = $_GET['weekofyear']; - $params['hour'] = $_GET['hour']; - $params['minute'] = $_GET['minute']; - $params['year2'] = $_GET['year2']; - $params['month2'] = $_GET['month2']; - $params['day2'] = $_GET['day2']; - $params['dayofyear2'] = $_GET['dayofyear2']; - $params['weekofyear2'] = $_GET['weekofyear2']; - $params['hour2'] = $_GET['hour2']; - $params['minute2'] = $_GET['minute2']; - $params['limit'] = $_GET['limit']; - $params['offset'] = $_GET['offset']; - $params['sortby'] = $_GET['sortby']; - $params['period'] = $_GET['period']; - $params['site_id'] = $_GET['site_id']; - $params['type'] = $_GET['type']; - $params['api_call'] = $_GET['name']; - $params['session_id'] = $_GET['session_id']; - $params['visitor_id'] = $_GET['visitor_id']; - $params['document_id'] = $_GET['document_id']; - $params['referer_id'] = $_GET['referer_id']; - $params['source'] = $_GET['source']; - $params['page_url'] = base64_decode($_GET['page_url']); - $params['target_url'] = base64_decode($_GET['target_url']); - $params['dom_element_name'] = $_GET['dom_element_name']; - $params['dom_element_value'] = $_GET['dom_element_value']; - $params['dom_element_id'] = $_GET['dom_element_id']; - $params['dom_element_x'] = $_GET['dom_element_x']; - $params['dom_element_y'] = $_GET['dom_element_y']; - $params['dom_element_text'] = $_GET['dom_element_text']; - $params['dom_element_tag'] = $_GET['dom_element_tag']; - $params['click_x'] = $_GET['click_x']; - $params['click_y'] = $_GET['click_y']; - $params['page_width'] = $_GET['page_width']; - $params['page_height'] = $_GET['page_height']; - - - return $params; - - } - function inputFilter($array) { $f = new InputFilter; @@ -466,11 +408,11 @@ function inputFilter($array) { * @param array $conf * @return object */ - function &factory($class_dir, $class_prefix, $class_name, $conf = array()) { + function &factory($class_dir, $class_prefix, $class_name, $conf = array(), $class_suffix = '') { - $class_dir = strtolower($class_dir).'/'; + $class_dir = strtolower($class_dir).DIRECTORY_SEPARATOR; $classfile = $class_dir . $class_name . '.php'; - $class = $class_prefix . $class_name; + $class = $class_prefix . $class_name . $class_suffix; /* * Attempt to include a version of the named class, but don't treat @@ -591,7 +533,9 @@ function getRequestParams() { function stripParams($params) { - $config = & owa_settings::get_settings(); + + $c = &owa_coreAPI::configSingleton(); + $config = $c->fetch('base'); $striped_params = array(); @@ -658,7 +602,9 @@ function moduleFactory($modulefile, $class_suffix = null, $params = '') { */ function redirectToView($data) { - $config = &owa_settings::get_settings(); + //$config = &owa_settings::get_settings(); + $c = &owa_coreAPI::configSingleton(); + $config = $c->fetch('base'); $control_params = array('view_method', 'auth_status'); @@ -791,4 +737,4 @@ function addConstraints($constraints) { } -?> +?> \ No newline at end of file diff --git a/owa_location.php b/owa_location.php index 90f497970..6f84546f7 100644 --- a/owa_location.php +++ b/owa_location.php @@ -1,124 +1,108 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ -class owa_location { - - /** - * City - * - * @var string - */ - var $city; - - /** - * Country - * - * @var string - */ - var $country; - - /** - * Latitude coordinates - * - * @var string - */ - var $latitude; - - /** - * Longitude coordinates - * - * @var string - */ - var $longitude; - - /** - * Location of concrete class plugins - * - * @var unknown_type - */ - var $plugin_dir; - - /** - * Configuration - * - * @var array - */ - var $config; - - /** - * error handler - * - * @var object - */ - var $e; - - /** - * Constructor - * - * @return owa_location - */ - function owa_location() { - - $this->config = &owa_settings::get_settings(); - $this->e = &owa_error::get_instance(); - return; - } - - function &factory($class_path, $plugin, $name = '', $ident = '', $conf = array()) { - - $classfile = $class_path . $plugin . '.php'; - - $class = 'owa_'.$plugin; - - /* - * Attempt to include our version of the named class, but don't treat - * a failure as fatal. The caller may have already included their own - * version of the named class. - */ - if (!class_exists($class)) { - include_once $classfile; - } - - /* If the class exists, return a new instance of it. */ - if (class_exists($class)) { - $obj = new $class; - return $obj; - } - - return null; - } - -} - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ +class owa_location extends owa_base { + + /** + * City + * + * @var string + */ + var $city; + + /** + * Country + * + * @var string + */ + var $country; + + /** + * Latitude coordinates + * + * @var string + */ + var $latitude; + + /** + * Longitude coordinates + * + * @var string + */ + var $longitude; + + /** + * Location of concrete class plugins + * + * @var unknown_type + */ + var $plugin_dir; + + /** + * Constructor + * + * @return owa_location + */ + function owa_location() { + + $this->owa_base(); + + return; + } + + function &factory($class_path, $plugin, $name = '', $ident = '', $conf = array()) { + + $classfile = $class_path . $plugin . '.php'; + + $class = 'owa_'.$plugin; + + /* + * Attempt to include our version of the named class, but don't treat + * a failure as fatal. The caller may have already included their own + * version of the named class. + */ + if (!class_exists($class)) { + include_once $classfile; + } + + /* If the class exists, return a new instance of it. */ + if (class_exists($class)) { + $obj = new $class; + return $obj; + } + + return null; + } + +} + ?> \ No newline at end of file diff --git a/owa_metric.php b/owa_metric.php index e111754fa..c87b23948 100644 --- a/owa_metric.php +++ b/owa_metric.php @@ -16,10 +16,7 @@ // $Id$ // -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_base.php'); require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_lib.php'); -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_db.php'); -require_once(OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa_requestContainer.php'); /** * Metric @@ -48,26 +45,12 @@ class owa_metric extends owa_base { */ var $data; - /** - * Databse Access Object - * - * @var object - */ - var $db; - /** * The params of the caller, either a report or graph * * @var array */ var $params = array(); - - /** - * Summary Framework Object - * - * @var object - */ - var $summaryFramework; /** * Constructor @@ -76,29 +59,20 @@ class owa_metric extends owa_base { * @return owa_metric */ function owa_metric() { - - //$this->db = &owa_db::get_instance(); - + // Setup time and query periods $this->time_now = owa_lib::time_now(); - if ($this->config['use_summary_tables']): - // This is a stub for getting Summary Framework object - ;//$this->summaryFramework = &owa_summary::get_instance(); - endif; - return; } /* - * Applies specific overrides specified in the request to the params of the metric. + * Applies overrides specified in the request to the params of the metric. * */ function applyOverrides($params = array()) { - //$params = & owa_requestContainer::getInstance(); - foreach ($params as $k => $v) { if (!empty($v)): @@ -107,19 +81,6 @@ function applyOverrides($params = array()) { } - /*if (!empty($params['limit'])): - $this->params['limit'] = $params['limit']; - endif; - - if (!empty($params['offset'])): - $this->params['offset'] = $params['offset']; - endif; - - if (!empty($params['site_id'])): - $this->params['site_id'] = $params['site_id']; - endif; - */ - return; } diff --git a/owa_news.php b/owa_news.php index d9ef1821d..7f2d5ec4a 100644 --- a/owa_news.php +++ b/owa_news.php @@ -1,160 +1,161 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_news extends lastRSS { - - /** - * Configuration - * - * @var array - */ - var $config; - - /** - * Error handler - * - * @var object - */ - var $e; - - var $crawler; - - function owa_news() { - - $this->config = &owa_settings::get_settings(); - $this->e = &owa_error::get_instance(); - $this->crawler = new owa_http; - $this->cache_dir = ''; - $this->date_format = "F j, Y"; - $this->CDATA = 'content'; - $this->items_limit = 3; - return; - } - - /** - * This is a redefined Parse function that uses Snoopy to fetch - * the file instead of fopen. - * - * @param unknown_type $rss_url - * @return unknown - */ - function Parse ($rss_url) { - // Open and load RSS file - - $this->crawler->fetch($rss_url); - $rss_content = $this->crawler->results; - - if (!empty($rss_content)) { - - // Parse document encoding - $result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content); - // if document codepage is specified, use it - if ($result['encoding'] != '') - { $this->rsscp = $result['encoding']; } // This is used in my_preg_match() - // otherwise use the default codepage - else - { $this->rsscp = $this->default_cp; } // This is used in my_preg_match() - - // Parse CHANNEL info - preg_match("'(.*?)'si", $rss_content, $out_channel); - foreach($this->channeltags as $channeltag) - { - $temp = $this->my_preg_match("'<$channeltag.*?>(.*?)'si", $out_channel[1]); - if ($temp != '') $result[$channeltag] = $temp; // Set only if not empty - } - // If date_format is specified and lastBuildDate is valid - if ($this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !==-1) { - // convert lastBuildDate to specified date format - $result['lastBuildDate'] = date($this->date_format, $timestamp); - } - - // Parse TEXTINPUT info - preg_match("']*[^/])>(.*?)'si", $rss_content, $out_textinfo); - // This a little strange regexp means: - // Look for tag with or without any attributes, but skip truncated version (it's not beggining tag) - if (isset($out_textinfo[2])) { - foreach($this->textinputtags as $textinputtag) { - $temp = $this->my_preg_match("'<$textinputtag.*?>(.*?)'si", $out_textinfo[2]); - if ($temp != '') $result['textinput_'.$textinputtag] = $temp; // Set only if not empty - } - } - // Parse IMAGE info - preg_match("'(.*?)'si", $rss_content, $out_imageinfo); - if (isset($out_imageinfo[1])) { - foreach($this->imagetags as $imagetag) { - $temp = $this->my_preg_match("'<$imagetag.*?>(.*?)'si", $out_imageinfo[1]); - if ($temp != '') $result['image_'.$imagetag] = $temp; // Set only if not empty - } - } - // Parse ITEMS - preg_match_all("'(.*?)'si", $rss_content, $items); - $rss_items = $items[2]; - $i = 0; - $result['items'] = array(); // create array even if there are no items - foreach($rss_items as $rss_item) { - // If number of items is lower then limit: Parse one item - if ($i < $this->items_limit || $this->items_limit == 0) { - foreach($this->itemtags as $itemtag) { - $temp = $this->my_preg_match("'<$itemtag.*?>(.*?)'si", $rss_item); - if ($temp != '') $result['items'][$i][$itemtag] = $temp; // Set only if not empty - } - // Strip HTML tags and other bullshit from DESCRIPTION - if ($this->stripHTML && $result['items'][$i]['description']) - $result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description']))); - // Strip HTML tags and other bullshit from TITLE - if ($this->stripHTML && $result['items'][$i]['title']) - $result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title']))); - // If date_format is specified and pubDate is valid - if ($this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !==-1) { - // convert pubDate to specified date format - $result['items'][$i]['pubDate'] = date($this->date_format, $timestamp); - } - // Item counter - $i++; - } - } - - $result['items_count'] = $i; - return $result; - } - else // Error in opening return False - { - print 'no rss content'; - return False; - } - } - -} - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_news extends lastRSS { + + /** + * Configuration + * + * @var array + */ + var $config; + + /** + * Error handler + * + * @var object + */ + var $e; + + var $crawler; + + function owa_news() { + + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); + $this->e = &owa_error::get_instance(); + $this->crawler = new owa_http; + $this->cache_dir = ''; + $this->date_format = "F j, Y"; + $this->CDATA = 'content'; + $this->items_limit = 3; + return; + } + + /** + * This is a redefined Parse function that uses Snoopy to fetch + * the file instead of fopen. + * + * @param unknown_type $rss_url + * @return unknown + */ + function Parse ($rss_url) { + // Open and load RSS file + + $this->crawler->fetch($rss_url); + $rss_content = $this->crawler->results; + + if (!empty($rss_content)) { + + // Parse document encoding + $result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content); + // if document codepage is specified, use it + if ($result['encoding'] != '') + { $this->rsscp = $result['encoding']; } // This is used in my_preg_match() + // otherwise use the default codepage + else + { $this->rsscp = $this->default_cp; } // This is used in my_preg_match() + + // Parse CHANNEL info + preg_match("'(.*?)'si", $rss_content, $out_channel); + foreach($this->channeltags as $channeltag) + { + $temp = $this->my_preg_match("'<$channeltag.*?>(.*?)'si", $out_channel[1]); + if ($temp != '') $result[$channeltag] = $temp; // Set only if not empty + } + // If date_format is specified and lastBuildDate is valid + if ($this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !==-1) { + // convert lastBuildDate to specified date format + $result['lastBuildDate'] = date($this->date_format, $timestamp); + } + + // Parse TEXTINPUT info + preg_match("']*[^/])>(.*?)'si", $rss_content, $out_textinfo); + // This a little strange regexp means: + // Look for tag with or without any attributes, but skip truncated version (it's not beggining tag) + if (isset($out_textinfo[2])) { + foreach($this->textinputtags as $textinputtag) { + $temp = $this->my_preg_match("'<$textinputtag.*?>(.*?)'si", $out_textinfo[2]); + if ($temp != '') $result['textinput_'.$textinputtag] = $temp; // Set only if not empty + } + } + // Parse IMAGE info + preg_match("'(.*?)'si", $rss_content, $out_imageinfo); + if (isset($out_imageinfo[1])) { + foreach($this->imagetags as $imagetag) { + $temp = $this->my_preg_match("'<$imagetag.*?>(.*?)'si", $out_imageinfo[1]); + if ($temp != '') $result['image_'.$imagetag] = $temp; // Set only if not empty + } + } + // Parse ITEMS + preg_match_all("'(.*?)'si", $rss_content, $items); + $rss_items = $items[2]; + $i = 0; + $result['items'] = array(); // create array even if there are no items + foreach($rss_items as $rss_item) { + // If number of items is lower then limit: Parse one item + if ($i < $this->items_limit || $this->items_limit == 0) { + foreach($this->itemtags as $itemtag) { + $temp = $this->my_preg_match("'<$itemtag.*?>(.*?)'si", $rss_item); + if ($temp != '') $result['items'][$i][$itemtag] = $temp; // Set only if not empty + } + // Strip HTML tags and other bullshit from DESCRIPTION + if ($this->stripHTML && $result['items'][$i]['description']) + $result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description']))); + // Strip HTML tags and other bullshit from TITLE + if ($this->stripHTML && $result['items'][$i]['title']) + $result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title']))); + // If date_format is specified and pubDate is valid + if ($this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !==-1) { + // convert pubDate to specified date format + $result['items'][$i]['pubDate'] = date($this->date_format, $timestamp); + } + // Item counter + $i++; + } + } + + $result['items_count'] = $i; + return $result; + } + else // Error in opening return False + { + print 'no rss content'; + return False; + } + } + +} + ?> \ No newline at end of file diff --git a/owa_observer.php b/owa_observer.php index d1abea790..acc3c0d71 100644 --- a/owa_observer.php +++ b/owa_observer.php @@ -1,143 +1,145 @@ - - * @copyright Copyright © 2006 Peter Adams - * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 - * @category owa - * @package owa - * @version $Revision$ - * @since owa 1.0.0 - */ - -class owa_observer extends Log_observer { - - /** - * The type of event that an observer would want to hear about. - * - * @var array - * @access private - */ - var $_event_type = array(); - - /** - * Error handler - * - * @var object - */ - var $e; - - /** - * Event Message - * - * @var array - */ - var $m; - - /** - * Configuration - * - * @var array - */ - var $config; - - var $api; - - /** - * Creates a new basic Log_observer instance. - * - * @param integer $priority The highest priority at which to receive - * log event notifications. - * - * @access public - */ - function owa_observer($priority = PEAR_LOG_INFO) - { - $this->Log_observer($priority); - $this->config = &owa_settings::get_settings(); - $this->e = &owa_error::get_instance(); - $this->api = &owa_coreAPI::singleton(); - return; - } - - function handleEvent($action) { - - // Create controller, passing event message as params - $controller = $this->api->moduleFactory($action, 'Controller', $this->m); - - // Run controller - $data = $controller->doAction(); - $this->e->debug(sprintf("Handled Event with Controller: %s", $action.'Controller')); - - // Create View if called for - if ($data['view']): - - // Determine what to do with view - switch ($data['view_method']) { - case 'email-html': - - require_once(OWA_BASE_CLASS_DIR.'mailer.php'); - - $mailer = new owa_mailer; - - $mailer->Subject = $data['subject']; - $mailer->Body = $this->api->displayView($data); - - $mailer->AltBody = $this->api->displayView($data, $data['plainTextView']); - $mailer->AddAddress($data['email_address'], $data['name']); - - $mailer->sendMail(); - break; - - case 'email': - - require_once(OWA_BASE_CLASS_DIR.'mailer.php'); - - $mailer = new owa_mailer; - - $mailer->Subject = $data['subject']; - $mailer->Body = $this->api->displayView($data); - - $mailer->AddAddress($data['email_address'], $data['name']); - - $mailer->sendMail(); - break; - } - - $this->e->debug(sprintf("Handled Event. Assembled View: %s", $data['view'].'View')); - - endif; - - return; - - } - - function sendMail($email_address, $subject, $msg) { - - mail($email_address, $subject, $msg); - $this->e->debug('Sent e-mail with subject of "'.$subject.'" to: '.$email_address); - return; - } - -} + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + +class owa_observer extends Log_observer { + + /** + * The type of event that an observer would want to hear about. + * + * @var array + * @access private + */ + var $_event_type = array(); + + /** + * Error handler + * + * @var object + */ + var $e; + + /** + * Event Message + * + * @var array + */ + var $m; + + /** + * Configuration + * + * @var array + */ + var $config; + + var $api; + + /** + * Creates a new basic Log_observer instance. + * + * @param integer $priority The highest priority at which to receive + * log event notifications. + * + * @access public + */ + function owa_observer($priority = PEAR_LOG_INFO) + { + $this->Log_observer($priority); + + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); + $this->e = &owa_error::get_instance(); + $this->api = &owa_coreAPI::singleton(); + return; + } + + function handleEvent($action) { + + // Create controller, passing event message as params + $controller = $this->api->moduleFactory($action, 'Controller', $this->m); + + // Run controller + $data = $controller->doAction(); + $this->e->debug(sprintf("Handled Event with Controller: %s", $action.'Controller')); + + // Create View if called for + if ($data['view']): + + // Determine what to do with view + switch ($data['view_method']) { + case 'email-html': + + require_once(OWA_BASE_CLASS_DIR.'mailer.php'); + + $mailer = new owa_mailer; + + $mailer->Subject = $data['subject']; + $mailer->Body = $this->api->displayView($data); + + $mailer->AltBody = $this->api->displayView($data, $data['plainTextView']); + $mailer->AddAddress($data['email_address'], $data['name']); + + $mailer->sendMail(); + break; + + case 'email': + + require_once(OWA_BASE_CLASS_DIR.'mailer.php'); + + $mailer = new owa_mailer; + + $mailer->Subject = $data['subject']; + $mailer->Body = $this->api->displayView($data); + + $mailer->AddAddress($data['email_address'], $data['name']); + + $mailer->sendMail(); + break; + } + + $this->e->debug(sprintf("Handled Event. Assembled View: %s", $data['view'].'View')); + + endif; + + return; + + } + + function sendMail($email_address, $subject, $msg) { + + mail($email_address, $subject, $msg); + $this->e->debug('Sent e-mail with subject of "'.$subject.'" to: '.$email_address); + return; + } + +} diff --git a/owa_settings_class.php b/owa_settings_class.php index 751649ea7..a1e66f205 100644 --- a/owa_settings_class.php +++ b/owa_settings_class.php @@ -29,7 +29,7 @@ * @version $Revision$ * @since owa 1.0.0 */ -class owa_settings { +class owa_settings_old { /** * Databse access object @@ -82,13 +82,13 @@ function &get_settings() { $config = &owa_settings::get_default_config(); //load overrides from config file - if (file_exists($config['config_file_path'])): - include_once ($config['config_file_path']); + if (file_exists($config['base']['config_file_path'])): + include_once ($config['base']['config_file_path']); if (isset($OWA_CONFIG)): if (!empty($OWA_CONFIG)): foreach ($OWA_CONFIG as $key => $value) { // update current config - $config[$key] = $value; + $config['base'][$key] = $value; } endif; endif; @@ -106,21 +106,20 @@ function &get_settings() { $base_url .= ':'.$_SERVER['SERVER_PORT']; endif; - $config['public_url'] = $base_url . $OWA_CONFIG['public_url']; - $config['main_url'] = $OWA_CONFIG['public_url']."/main.php"; - $config['main_absolute_url'] = $base_url . $config['main_url']; - //$config['action_url'] = $OWA_CONFIG['public_url']."/action.php"; - $config['action_url'] = $config['main_url']; - $config['log_url'] = $OWA_CONFIG['public_url']."/log.php"; - $config['images_url'] = $OWA_CONFIG['public_url']."/i"; - $config['reporting_url'] = $OWA_CONFIG['public_url']."/reports/index.php"; - $config['home_url'] = $config['public_url']."/reports/index.php?page=dashboard_report.php"; - $config['admin_url'] = $OWA_CONFIG['public_url']."/admin/index.php"; + $config['base']['public_url'] = $base_url . $OWA_CONFIG['public_url']; + $config['base']['main_url'] = $OWA_CONFIG['public_url']."/main.php"; + $config['base']['main_absolute_url'] = $base_url . $config['main_url']; + $config['base']['action_url'] = $config['main_url']; + $config['base']['log_url'] = $OWA_CONFIG['public_url']."/log.php"; + $config['base']['images_url'] = $OWA_CONFIG['public_url']."/i"; + $config['base']['reporting_url'] = $OWA_CONFIG['public_url']."/reports/index.php"; + $config['base']['home_url'] = $config['public_url']."/reports/index.php?page=dashboard_report.php"; + $config['base']['admin_url'] = $OWA_CONFIG['public_url']."/admin/index.php"; endif; endif; - return $config; + return $config['base']; } /** @@ -130,7 +129,7 @@ function &get_settings() { */ function get_default_config() { - return array( + return array('base' => array( 'ns' => 'owa_', 'visitor_param' => 'v', @@ -209,8 +208,7 @@ function get_default_config() { 'images_url' => '', 'reporting_url' => '', 'p3p_policy' => 'NOI NID ADMa OUR IND UNI COM NAV', - 'inter_report_link_template' => '%s?%s', //base_url?report=report_name&get... - 'inter_admin_link_template' => '%s?admin=%s&%s', //base_url?report=report_name&get... DEPRICATED + 'inter_report_link_template' => '%s?%s', //base_url?report=report_name&get... DEPRICATED? 'graph_link_template' => '%s?owa_action=graph&name=%s&%s', //action_url?... 'link_template' => '%s?%s', // main_url?key=value.... 'owa_user_agent' => 'Open Web Analytics Bot '.OWA_VERSION, @@ -233,7 +231,7 @@ function get_default_config() { 'mailer-password' => '', 'cookie_domain' => $_SERVER['SERVER_NAME'] - ); + )); } /** diff --git a/owa_template.php b/owa_template.php index 39fa463a9..2c6a97ac2 100644 --- a/owa_template.php +++ b/owa_template.php @@ -18,7 +18,7 @@ require_once(OWA_INCLUDE_DIR.'/template_class.php'); require_once(OWA_BASE_DIR.'/owa_lib.php'); -require_once(OWA_BASE_DIR.'/owa_settings_class.php'); +require_once(OWA_BASE_CLASS_DIR.'settings.php'); require_once(OWA_BASE_DIR.'/owa_auth.php'); /** @@ -53,7 +53,8 @@ function owa_template($module = null, $caller_params = null) { $this->caller_params = $caller_params; - $this->config = &owa_settings::get_settings(); + $c = &owa_coreAPI::configSingleton(); + $this->config = $c->fetch('base'); // set template dir if(!empty($caller_params['module'])): @@ -328,6 +329,8 @@ function makeAbsoluteLink($params, $url = '') { } + + } diff --git a/owa_view.php b/owa_view.php index e77366c85..68afe56b0 100644 --- a/owa_view.php +++ b/owa_view.php @@ -154,9 +154,6 @@ function assembleView($data) { $this->t->set('authStatus', true); endif; - //array or errors usually used for field validations - $this->body->set('errors', $data['errors']); - // get error msg from error code passed on the query string from a redirect. if (!empty($data['error_code'])): $this->t->set('error_msg', $this->getMsg($data['error_code'])); @@ -170,6 +167,10 @@ function assembleView($data) { // construct main view. This might set some properties of the subview. $this->construct($this->data); + + //array of errors usually used for field validations + $this->body->set('validation_errors', $data['validation_errors']); + $this->subview->body->set('validation_errors', $data['validation_errors']); // assemble subview if (!empty($this->data['subview'])): @@ -179,6 +180,14 @@ function assembleView($data) { $this->body->set('subview', $this->subview_rendered); endif; + if (!empty($data['validation_errors'])): + $ves = new owa_template('base'); + $ves->set_template('error_validation_summary.tpl'); + $ves->set('validation_errors', $data['validation_errors']); + $validation_errors_summary = $ves->fetch(); + $this->t->set('error_msg', $validation_errors_summary); + endif; + //Assign body to main template $this->t->set('body', $this->body); diff --git a/owa_wp.php b/owa_wp.php index f0d52b31d..fae688224 100644 --- a/owa_wp.php +++ b/owa_wp.php @@ -1,4 +1,4 @@ -owa_db(); - $connectionString = sprintf( - '%s', - $this->config['db_host'] - ); - - $this->connection = @mysql_connect( - $connectionString, - $this->config['db_user'], - $this->config['db_password'], + //$connectionString = sprintf('%s', OWA_DB_HOST); + + $this->connection = mysql_connect( + OWA_DB_HOST, + OWA_DB_USER, + OWA_DB_PASSWORD, true ); - $this->database_selection = @mysql_select_db($this->config['db_name'], $this->connection); + $this->database_selection = mysql_select_db(OWA_DB_NAME, $this->connection); if (!$this->connection || !$this->database_selection): $this->e->alert('Could not connect to database. '); @@ -524,4 +521,4 @@ function makeDelimitedList($values, $delimiter = ', ') { } -?> +?> \ No newline at end of file diff --git a/plugins/log/winstatic.php b/plugins/log/winstatic.php index ad08e5260..fdb2229e6 100644 --- a/plugins/log/winstatic.php +++ b/plugins/log/winstatic.php @@ -1,272 +1,274 @@ - - * @since OWA 1.0.0 - * @package OWA - * - * @example winstatic.php Using the window handler. - */ -class Log_winstatic extends Log -{ - /** - * The name of the output window. - * @var string - * @access private - */ - var $_name = 'LogWindow'; - - /** - * The title of the output window. - * @var string - * @access private - */ - var $_title = 'Log Output Window'; - - /** - * Mapping of log priorities to colors. - * @var array - * @access private - */ - var $_colors = array( - PEAR_LOG_EMERG => 'red', - PEAR_LOG_ALERT => 'orange', - PEAR_LOG_CRIT => 'yellow', - PEAR_LOG_ERR => 'green', - PEAR_LOG_WARNING => 'blue', - PEAR_LOG_NOTICE => 'indigo', - PEAR_LOG_INFO => 'violet', - PEAR_LOG_DEBUG => 'black' - ); - - /** - * String buffer that holds line that are pending output. - * @var array - * @access private - */ - var $_buffer = array(); - - /** - * Constructs a new Log_win object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_winstatic($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - - $this->_id = md5(microtime()); - $this->_name = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - // fetches the static array that will store output to be printed later - $this->debug = &owa_error::get_msgs(); - - if (isset($conf['title'])) { - $this->_title = $conf['title']; - } - if (isset($conf['colors']) && is_array($conf['colors'])) { - $this->_colors = $conf['colors']; - } - - register_shutdown_function(array(&$this, '_Log_winstatic')); - } - - /** - * Destructor - */ - function _Log_winstatic() - { - if ($this->_opened || (count($this->_buffer) > 0)) { - $this->close(); - } - } - - /** - * The first time open() is called, it will open a new browser window and - * prepare it for output. - * - * This is implicitly called by log(), if necessary. - * - * @access public - */ - function open() - { - if (!$this->_opened) { - $win = $this->_name; - - if (!empty($this->_ident)) { - $identHeader = "$win.document.writeln('Ident')"; - } else { - $identHeader = ''; - } - - $this->debug .= <<< END_OF_SCRIPT - -END_OF_SCRIPT; - $this->_opened = true; - } - - return $this->_opened; - } - - /** - * Closes the output stream if it is open. If there are still pending - * lines in the output buffer, the output window will be opened so that - * the buffer can be drained. - * - * @access public - */ - function close() - { - /* - * If there are still lines waiting to be written, open the output - * window so that we can drain the buffer. - */ - if (!$this->_opened && (count($this->_buffer) > 0)) { - $this->open(); - } - - if ($this->_opened) { - $this->_writeln(''); - $this->_writeln(''); - $this->_opened = false; - } - - return ($this->_opened === false); - } - - /** - * Writes a single line of text to the output window. - * - * @param string $line The line of text to write. - * - * @access private - */ - function _writeln($line) - { - /* Add this line to our output buffer. */ - $this->_buffer[] = $line; - - /* Buffer the output until this page's headers have been sent. */ - if (!headers_sent()) { - // return; - } - - /* If we haven't already opened the output window, do so now. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Drain the buffer to the output window. */ - $win = $this->_name; - foreach ($this->_buffer as $line) { - $this->debug .= "\n"; - } - - /* Now that the buffer has been drained, clear it. */ - $this->_buffer = array(); - } - - /** - * Logs $message to the output window. The message is also passed along - * to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - list($usec, $sec) = explode(' ', microtime()); - - /* Build the output line that contains the log entry row. */ - $line = ''; - $line .= sprintf('%s.%s', - strftime('%T', $sec), substr($usec, 2, 2)); - if (!empty($this->_ident)) { - $line .= '' . $this->_ident . ''; - } - $line .= '' . ucfirst($this->priorityToString($priority)) . ''; - $line .= sprintf('%s', - $this->_colors[$priority], - preg_replace('/\r\n|\n|\r/', '
', $message)); - $line .= ''; - - $this->_writeln($line); - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } - -} + + * @since OWA 1.0.0 + * @package OWA + * + * @example winstatic.php Using the window handler. + */ +class Log_winstatic extends Log { + + + /** + * The name of the output window. + * @var string + * @access private + */ + var $_name = 'LogWindow'; + + /** + * The title of the output window. + * @var string + * @access private + */ + var $_title = 'Log Output Window'; + + /** + * Mapping of log priorities to colors. + * @var array + * @access private + */ + var $_colors = array( + PEAR_LOG_EMERG => 'red', + PEAR_LOG_ALERT => 'orange', + PEAR_LOG_CRIT => 'yellow', + PEAR_LOG_ERR => 'green', + PEAR_LOG_WARNING => 'blue', + PEAR_LOG_NOTICE => 'indigo', + PEAR_LOG_INFO => 'violet', + PEAR_LOG_DEBUG => 'black' + ); + + /** + * String buffer that holds line that are pending output. + * @var array + * @access private + */ + var $_buffer = array(); + + /** + * Constructs a new Log_win object. + * + * @param string $name Ignored. + * @param string $ident The identity string. + * @param array $conf The configuration array. + * @param int $level Log messages up to and including this level. + * @access public + */ + function Log_winstatic($name, $ident = '', $conf = array(), + $level = PEAR_LOG_DEBUG) + { + + $this->_id = md5(microtime()); + $this->_name = $name; + $this->_ident = $ident; + $this->_mask = Log::UPTO($level); + + // fetches the static array that will store output to be printed later + $this->debug = &owa_error::get_msgs(); + + if (isset($conf['title'])) { + $this->_title = $conf['title']; + } + if (isset($conf['colors']) && is_array($conf['colors'])) { + $this->_colors = $conf['colors']; + } + + register_shutdown_function(array(&$this, '_Log_winstatic')); + } + + /** + * Destructor + */ + function _Log_winstatic() + { + if ($this->_opened || (count($this->_buffer) > 0)) { + $this->close(); + } + } + + /** + * The first time open() is called, it will open a new browser window and + * prepare it for output. + * + * This is implicitly called by log(), if necessary. + * + * @access public + */ + function open() + { + if (!$this->_opened) { + $win = $this->_name; + + if (!empty($this->_ident)) { + $identHeader = "$win.document.writeln('Ident')"; + } else { + $identHeader = ''; + } + + $this->debug .= <<< END_OF_SCRIPT + +END_OF_SCRIPT; + $this->_opened = true; + } + + return $this->_opened; + } + + /** + * Closes the output stream if it is open. If there are still pending + * lines in the output buffer, the output window will be opened so that + * the buffer can be drained. + * + * @access public + */ + function close() + { + /* + * If there are still lines waiting to be written, open the output + * window so that we can drain the buffer. + */ + if (!$this->_opened && (count($this->_buffer) > 0)) { + $this->open(); + } + + if ($this->_opened) { + $this->_writeln(''); + $this->_writeln(''); + $this->_opened = false; + } + + return ($this->_opened === false); + } + + /** + * Writes a single line of text to the output window. + * + * @param string $line The line of text to write. + * + * @access private + */ + function _writeln($line) + { + /* Add this line to our output buffer. */ + $this->_buffer[] = $line; + + /* Buffer the output until this page's headers have been sent. */ + if (!headers_sent()) { + // return; + } + + /* If we haven't already opened the output window, do so now. */ + if (!$this->_opened && !$this->open()) { + return false; + } + + /* Drain the buffer to the output window. */ + $win = $this->_name; + foreach ($this->_buffer as $line) { + $this->debug .= "\n"; + } + + /* Now that the buffer has been drained, clear it. */ + $this->_buffer = array(); + } + + /** + * Logs $message to the output window. The message is also passed along + * to any Log_observer instances that are observing this Log. + * + * @param mixed $message String or object containing the message to log. + * @param string $priority The priority of the message. Valid + * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, + * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, + * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. + * @return boolean True on success or false on failure. + * @access public + */ + function log($message, $priority = null) + { + /* If a priority hasn't been specified, use the default value. */ + if ($priority === null) { + $priority = $this->_priority; + } + + /* Abort early if the priority is above the maximum logging level. */ + if (!$this->_isMasked($priority)) { + return false; + } + + /* Extract the string representation of the message. */ + $message = $this->_extractMessage($message); + + list($usec, $sec) = explode(' ', microtime()); + + /* Build the output line that contains the log entry row. */ + $line = ''; + $line .= sprintf('%s.%s', + strftime('%T', $sec), substr($usec, 2, 2)); + if (!empty($this->_ident)) { + $line .= '' . $this->_ident . ''; + } + $line .= '' . ucfirst($this->priorityToString($priority)) . ''; + $line .= sprintf('%s', + $this->_colors[$priority], + preg_replace('/\r\n|\n|\r/', '
', $message)); + $line .= ''; + + $this->_writeln($line); + + $this->_announce(array('priority' => $priority, 'message' => $message)); + + return true; + } + +} +?> \ No newline at end of file diff --git a/plugins/validations/required.php b/plugins/validations/required.php new file mode 100644 index 000000000..eb3f30a39 --- /dev/null +++ b/plugins/validations/required.php @@ -0,0 +1,55 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + class owa_requiredValidation extends owa_validation { + + function owa_requiredValidation($conf) { + + $this->setErrorMsgTemplate('Required field was empty.'); + $this->owa_validation($conf); + return; + } + + function validate($value) { + + if (!empty($value)): + return true; + else: + $this->setErrorMsg($this->errorMsgTemplate); + return false; + endif; + + } + + } + + +?> + \ No newline at end of file diff --git a/plugins/validations/subStringPosition.php b/plugins/validations/subStringPosition.php new file mode 100644 index 000000000..d0eb8ac00 --- /dev/null +++ b/plugins/validations/subStringPosition.php @@ -0,0 +1,88 @@ + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + class owa_subStringPositionValidation extends owa_validation { + + var $position; + + var $subString; + + var $operator; + + function owa_subStringPositionValidation($conf) { + + $this->subString = $conf['substring']; + $this->position = $conf['position']; + $this->operator = $conf['operator']; + $this->setErrorMsgTemplate('The string "%s" was found within the value at position %d'); + $this->owa_validation($conf); + return; + } + + function validate($value) { + + $pos = strpos($value, $this->subString); + + //print $pos; + //print_r($this); + switch ($this->operator) { + + case "=": + + if ($pos === $this->position): + $valid = true; + endif; + + break; + + case "!=": + + if ($pos === $this->position): + $valid = false; + endif; + + break; + } + + if ($valid === false): + $this->setErrorMsg(sprintf($this->errorMsgTemplate, $this->subString, $pos)); + return false; + else: + return true; + endif; + + + } + + } + + +?> + \ No newline at end of file diff --git a/wp_plugin.php b/wp_plugin.php index ca7b1ea80..2d18f4e0b 100644 --- a/wp_plugin.php +++ b/wp_plugin.php @@ -10,7 +10,6 @@ */ require_once 'owa_env.php'; -require_once 'owa_settings_class.php'; require_once 'owa_wp.php'; /** @@ -26,15 +25,16 @@ //print md5(get_settings('siteurl')); - +$owa_config = array(); // Caller Configuration overides $owa_config['report_wrapper'] = 'wrapper_wordpress.tpl'; -$owa_config['db_name'] = DB_NAME; // The name of the database -$owa_config['db_user'] = DB_USER; // Your db username -$owa_config['db_password'] = DB_PASSWORD; // ...and password -$owa_config['db_host'] = DB_HOST; // The host of your db -$owa_config['db_type'] = 'mysql'; // The host of your db -$owa_config['db_class'] = 'mysql'; // The host of your db + +define('OWA_DB_TYPE', 'mysql'); +define('OWA_DB_NAME', DB_NAME); +define('OWA_DB_HOST', DB_HOST); +define('OWA_DB_USER', DB_USER); +define('OWA_DB_PASSWORD', DB_PASSWORD); + $owa_config['fetch_config_from_db'] = true; // The host of your db $owa_config['images_url'] = '../wp-content/plugins/owa/public/i'; $owa_config['public_url'] = '../wp-content/plugins/owa/public'; @@ -97,9 +97,7 @@ */ function owa_set_user_level() { - global $user_level, $user_login, $user_ID, $user_email, $user_identity; - - $owa_wp = &new owa_wp; + global $owa_wp, $user_level, $user_login, $user_ID, $user_email, $user_identity; $owa_wp->params['caller']['wordpress']['user_data'] = array( @@ -142,6 +140,8 @@ function owa_main() { function owa_log() { + global $owa_wp; + // WORDPRESS SPECIFIC DATA // // Get the type of page @@ -172,7 +172,7 @@ function owa_log() { //$app_params['site_id'] = ''; // Process the request by calling owa - $owa_wp = &new owa_wp; + $owa_wp->log($app_params); return; } @@ -254,7 +254,7 @@ function owa_get_page_type() { */ function add_feed_sid($binfo) { - $owa_wp = &new owa_wp; + global $owa_wp; if (strstr($binfo, "feed=")): @@ -307,8 +307,10 @@ function owa_install() { if ($user_level < 8): return; else: - $conf = &owa_settings::get_settings(); - $conf['fetch_config_from_db'] = false; + //$conf = &owa_settings::get_settings(); + //['fetch_config_from_db'] = false; + + $owa_wp->config['fetch_config_from_db'] = false; $owa_wp->config['db_type'] = 'mysql'; @@ -396,4 +398,4 @@ function owa_parse_version($version) { } -?> +?> \ No newline at end of file