Skip to content

Commit

Permalink
added authentication plugin scheme for authenticating user when they
Browse files Browse the repository at this point in the history
-- This line, and those below, will be ignored--

M    owa_click.php
M    conf/query_strings.ini
M    wp_plugin.php
A    owa_base.php
M    owa_template.php
A    owa_user.php
M    public/admin/options.php
M    public/admin/install.php
AM   public/i/user_icon_large.jpg
AM   public/i/user_icon_small.jpg
M    public/reports/document_report.php
M    public/reports/traffic_report.php
M    public/reports/visitor_report.php
M    public/reports/visitors_report.php
M    public/reports/session_report.php
M    public/reports/click_report.php
M    public/reports/feeds_report.php
M    public/reports/dashboard_report.php
M    public/reports/content_report.php
M    public/reports/index.php
A    public/login.php
M    owa_settings_class.php
A    plugins/event_handlers/observer_password_reset.php
A    plugins/auth
A    plugins/auth/simple.php
A    plugins/auth/none.php
M    plugins/install/mysql/owa_install_update_to_1_0.php
M    plugins/install/mysql/owa_install_base.php
A    owa_auth.php
A    templates/status.tpl
A    templates/password_reset_request_email.tpl
A    templates/reset_password_form.tpl
A    templates/options_user_roster.tpl
M    templates/error.tpl
A    templates/login_form.tpl
A    templates/request_password_form.tpl
A    templates/password_reset_email.tpl
A    templates/options_edit_user_profile.tpl
M    templates/css.tpl
M    templates/options.tpl
A    templates/installer_set_admin_user.tpl
M    owa_lib.php
M    owa_report.php
  • Loading branch information
padams committed Sep 8, 2006
1 parent 6d53d3a commit a412cf5
Show file tree
Hide file tree
Showing 42 changed files with 1,784 additions and 46 deletions.
1 change: 1 addition & 0 deletions conf/query_strings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
[\?(?:.+&|)sc=(.+?)(?:&|$)]
[\?(?:.+&|)search=(.+?)(?:&|$)]
[\?(?:.+&|)search2=(.+?)(?:&|$)]
[\?(?:.+&|)searchfor=(.+?)(?:&|$)]
[\?(?:.+&|)searchText=(.+?)(?:&|$)]
[\?(?:.+&|)srch=(.+?)(?:&|$)]
[\?(?:.+&|)string=(.+?)(?:&|$)]
Expand Down
125 changes: 125 additions & 0 deletions owa_auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?

//
// Open Web Analytics - An Open Source Web Analytics Framework
//
// Copyright 2006 Peter Adams. All rights reserved.
//
// Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Id$
//
require_once(OWA_BASE_DIR.'/owa_base.php');
/**
* User Authentication Object
*
* @author Peter Adams <[email protected]>
* @copyright Copyright &copy; 2006 Peter Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GPL v2.0
* @category owa
* @package owa
* @version $Revision$
* @since owa 1.0.0
*/
class owa_auth extends owa_base {

/**
* User object
*
* @var unknown_type
*/
var $u;

/**
* Array of permission roles that users can have
*
* @var array
*/
var $roles;

/**
* Database Access Object
*
* @var unknown_type
*/
var $db;

var $status_msg;

/**
* Abstract class Constructor
*
* @return owa_auth
*/
function owa_auth() {

$this->owa_base();
$this->setRoles();

return;

}

/**
* Sets the permission levels of each role.
*
*/
function setRoles() {

$this->roles = array('admin' => array('level' => 10, 'label' => 'Administrator'),
'viewer' => array('level' => 2, 'label' => 'Report Viewer'),
'guest' => array('level' => 1, 'label' => 'Guest')

);

return;

}

/**
* Looks up the priviledge level for a particular role
*
* @param unknown_type $role
* @return unknown
*/
function getLevel($role) {

return $this->roles['role']['level'];
}

function authenticateUser() {

return;
}

/**
* Creates the concrete auth class
*
* @return object
*/
function &get_instance() {

$config = &owa_settings::get_settings();
return owa_lib::singleton($config['plugin_dir'].'/auth/',
'owa_auth_',
$config['authentication']);
}

function setCookies() {

setcookie($this->config['ns'].'u', $this->u->user_id, time()+3600*24*365*30, '/', $_SERVER['SERVER_NAME']);
setcookie($this->config['ns'].'p', $this->u->password, time()+3600*24*365*30, '/', $_SERVER['SERVER_NAME']);

return;
}

}


?>
65 changes: 65 additions & 0 deletions owa_base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?

//
// Open Web Analytics - An Open Source Web Analytics Framework
//
// Copyright 2006 Peter Adams. All rights reserved.
//
// Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Id$
//

require_once('owa_env.php');
require_once('owa_settings_class.php');
require_once('owa_error.php');
/**
* OWA Base Class
*
* @author Peter Adams <[email protected]>
* @copyright Copyright &copy; 2006 Peter Adams <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GPL v2.0
* @category owa
* @package owa
* @version $Revision$
* @since owa 1.0.0
*/
class owa_base {

/**
* Configuration
*
* @var array
*/
var $config;

/**
* Error Logger
*
* @var object
*/
var $e;

/**
* Base Constructor
*
* @return owa_base
*/
function owa_base() {

$this->config = &owa_settings::get_settings();
$this->e = &owa_error::get_instance();

return;
}

}


?>
6 changes: 4 additions & 2 deletions owa_click.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ function process() {
//$this->properties['os'] = $this->determine_os($this->properties['ua']);
//$this->properties['os_id'] = $this->set_string_guid($this->properties['os']);



// Make document id
$this->properties['page_url']= $this->stripDocumentUrl($this->properties['page_url']);
$this->properties['page_url']= $this->stripDocumentUrl(base64_decode($this->properties['page_url']));
$this->properties['document_id'] = $this->set_string_guid($this->properties['page_url']);

//$this->setDocumentProperties($this->properties['page_url']);
$this->properties['target_url'] = $this->stripDocumentUrl($this->properties['target_url']);
$this->properties['target_url'] = $this->stripDocumentUrl(base64_decode($this->properties['target_url']));
$this->properties['target_id'] = $this->set_string_guid($this->properties['target_url']);
// Resolve host name
if ($this->config['resolve_hosts'] = true):
Expand Down
123 changes: 123 additions & 0 deletions owa_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,129 @@ function inputFilter($array) {

}

/**
* Generic Factory method
*
* @param string $class_dir
* @param string $class_prefix
* @param string $class_name
* @param array $conf
* @return object
*/
function &factory($class_dir, $class_prefix, $class_name, $conf = array()) {

$class_dir = strtolower($class_dir);
$classfile = $class_dir . $class_name . '.php';
$class = $class_prefix . $class_name;

/*
* Attempt to include a 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;
endif;

/* If the class exists, return a new instance of it. */
if (class_exists($class)):
$obj = &new $class($conf);
return $obj;
endif;

$null = null;
return $null;
}

/**
* Generic Object Singleton
*
* @param string $class_dir
* @param string $class_prefix
* @param string $class_name
* @param array $conf
* @return object
*/
function &singleton($class_dir, $class_prefix, $class_name, $conf = array()) {

static $instance;

if (!isset($instance)):
$instance = &owa_lib::factory($class_dir, $class_prefix, $class_name, $conf = array());
endif;

return $instance;
}

/**
* 301 HTP redirect the user to a new url
*
* @param string $url
*/
function redirectBrowser($url) {

// 301 redirect to URL
header ('Location: '.$url);
header ('HTTP/1.0 301 Moved Permanently');
return;
}

/**
* Generates a link between admin screens
*
* @param array $query_params
* @return string
*/
function makeAdminLink($admin_page, $query_params = null, $make_query_string = true) {

if ($make_query_string == true):
$get = owa_lib::makeLinkQueryString($query_params);
else:
$get = '';
endif;

//Return URL
return sprintf($this->config['inter_admin_link_template'],
$this->config['admin_url'],
$admin_page,
$get);
}

function makeLinkQueryString($query_params) {

$new_query_params = array();

//Load params passed by caller
if (!empty($this->caller_params)):
foreach ($this->caller_params as $name => $value) {
if (!empty($value)):
$new_query_params[$name] = $value;
endif;
}
endif;

// Load overrides
if (!empty($query_params)):
foreach ($query_params as $name => $value) {
if (!empty($value)):
$new_query_params[$name] = $value;
endif;
}
endif;

// Construct GET request
if (!empty($new_query_params)):
foreach ($new_query_params as $name => $value) {
if (!empty($value)):
$get .= $name . "=" . $value . "&";
endif;
}
endif;

return $get;

}

}

?>
22 changes: 20 additions & 2 deletions owa_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require_once 'owa_api.php';
require_once 'owa_lib.php';
require_once 'owa_site.php';
require_once 'owa_auth.php';

/**
* Web Analytics Report
Expand Down Expand Up @@ -99,6 +100,8 @@ class owa_report {
*/
var $prefs = array();

var $auth;

/**
* Constructor
*
Expand All @@ -109,9 +112,18 @@ function owa_report() {

$this->config = &owa_settings::get_settings();

// User authentication object
$this->auth = &owa_auth::get_instance();

// Gets full set of params from URL
$this->_setParams(owa_lib::getRestparams());


//if (empty($_POST['go_params'])):
$this->_setParams(owa_lib::getRestparams());
//else:
// parse_str($_POST['go_params'], $post_params);
// $this->setParams($post_params);
//endif;

// Get default and user override display preferences.
$this->prefs = $this->getPrefs();

Expand Down Expand Up @@ -215,6 +227,12 @@ function getSitesList() {

}

function authenticateUser($role) {

return $this->auth->authenticateUser($role);

}

}

?>
Loading

0 comments on commit a412cf5

Please sign in to comment.