code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231
values | license stringclasses 13
values | size int64 1 2.01M |
|---|---|---|---|---|---|
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
body{background-image:none;background-color:white;color:#231e18;background-repeat:no-repeat;margin:0;font-family:Helvetica;font-size:12px;}
#container{width:1000px;margin:0 auto;}
#header{width:100%;margin:0;padding:0;}
#logo{width:1000px;margin:0 auto;color:#231e18;}
#nav_bg{background:#231e18;width:100%;height:52px;}
ul#navigation{list-style-type:none;width:1000px;margin:0 auto;}
ul#navigation li a{color:white;font-size:18px;float:left;padding:15px 20px 20px 20px;margin-right:10px;}
ul#navigation li a:hover{color:#231e18;background:white;font-size:18px;float:left;padding:15px 20px 20px 20px;margin-right:10px;}
ul#navigation li a.selected{color:#231e18;background:white;font-size:18px;float:left;padding:15px 20px 20px 20px;}
#login{margin:0 auto;margin-left:40px;}
.box{width:726px;margin:0;padding:0;}
p{margin-left:40px;}
input.clean{padding:4px;border:1px solid #231e18;}
table{width:900px;text-align:left;margin:20px 0 0 0;}
table tr.alt{background:#ECECEC;}
a{color:#231e18;margin-right:10px;}
</style>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css" />
<title>The Authentication Library Control Panel</title>
</head>
<body>
<div id="header">
<div id="logo">
<h1>The Authentication Library Admin Panel</h1>
</div>
</div>
<div id="nav_bg">
<?php $this->load->view($this->config->item('auth_views_root') . 'nav'); ?>
</div>
<div id="container"> | 101-code | sparks/Auth/2.0.5/views/auth/header.php | PHP | gpl3 | 1,649 |
<div id="login">
<h2>Logout</h2>
<div class="box">
You have been successfully logged out!
</div>
</div> | 101-code | sparks/Auth/2.0.5/views/auth/pages/logout.php | Hack | gpl3 | 111 |
<div id="login">
<h2>Login</h2>
<div class="box">
<form method="POST">
Username/Email:<br />
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" class="form" /><?php echo form_error('username'); ?><br /><br />
Password:<br />
<input type="password" name="password" value="<?php echo set_value('password'); ?>" size="50" class="form" /><?php echo form_error('password'); ?><br /><br />
<input type="submit" value="Login" name="login" />
</form>
</div>
</div> | 101-code | sparks/Auth/2.0.5/views/auth/pages/login.php | PHP | gpl3 | 521 |
<div id="login">
<?php if(empty($username)) { ?>
<h2>Register</h2>
<?php } else { ?>
<h2>Update</h2>
<?php } ?>
<div class="box">
<form method="post">
<?php if(empty($username)) { ?>
Username:<br />
<input type="text" name="username" size="50" class="form" value="<?php echo set_value('username'); ?>" /><br /><?php echo form_error('username'); ?><br />
Password:<br />
<input type="password" name="password" size="50" class="form" value="<?php echo set_value('password'); ?>" /><?php echo form_error('password'); ?><br /><br />
Password confirmation:<br />
<input type="password" name="password_conf" size="50" class="form" value="<?php echo set_value('conf_password'); ?>" /><?php echo form_error('conf_password'); ?><br /><br />
<?php } ?>
Email:<br />
<?php if(empty($username)){ ?>
<input type="text" name="email" size="50" class="form" value="<?php echo set_value('email'); ?>" /><?php echo form_error('email'); ?><br /><br />
<?php }else{ ?>
<input type="text" name="email" size="50" class="form" value="<?php echo set_value('email', $email); ?>" /><?php echo form_error('email'); ?><br /><br />
<?php } if(empty($username)) { ?>
<input type="submit" value="Register" name="register" />
<?php } else { ?>
<input type="submit" value="Update" name="register" />
<?php } ?>
</form>
</div>
</div> | 101-code | sparks/Auth/2.0.5/views/auth/pages/register.php | PHP | gpl3 | 1,375 |
<h2>Message</h2>
<p><?php echo $message; ?></p> | 101-code | sparks/Auth/2.0.5/views/auth/pages/message.php | PHP | gpl3 | 48 |
<h2>User Successfully Deleted</h2>
<p>The user has now been deleted.</p> | 101-code | sparks/Auth/2.0.5/views/auth/pages/users/delete_success.php | PHP | gpl3 | 73 |
<h2>Manage Users</h2>
<?php echo $this->table->generate(); ?> | 101-code | sparks/Auth/2.0.5/views/auth/pages/users/manage.php | PHP | gpl3 | 62 |
<div id="login">
<h2>Success!</h2>
<div class="box">
<?php echo $msg; ?>
</div>
</div> | 101-code | sparks/Auth/2.0.5/views/auth/pages/reg_success.php | PHP | gpl3 | 98 |
<h2>Dashboard</h2>
<p>Welcome <?php echo username(); ?>.</p> | 101-code | sparks/Auth/2.0.5/views/auth/pages/dashboard.php | PHP | gpl3 | 61 |
</div>
</body>
</html> | 101-code | sparks/Auth/2.0.5/views/auth/footer.php | Hack | gpl3 | 25 |
<?php
$this->load->view($this->config->item('auth_views_root') . 'header');
if(isset($data))
{
$this->load->view($this->config->item('auth_views_root') . 'pages/'.$page, $data);
}
else
{
$this->load->view($this->config->item('auth_views_root') . 'pages/'.$page);
}
$this->load->view($this->config->item('auth_views_root') . 'footer');
?> | 101-code | sparks/Auth/2.0.5/views/auth/index.php | PHP | gpl3 | 343 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | sparks/Auth/2.0.5/views/index.html | HTML | gpl3 | 123 |
<?php
function logged_in()
{
$CI =& get_instance();
if($CI->ag_auth->logged_in() == TRUE)
{
return TRUE;
}
return FALSE;
}
function username()
{
$CI =& get_instance();
return $CI->session->userdata('username');
}
function user_group($group)
{
$CI =& get_instance();
$system_group = $CI->ag_auth->config['auth_groups'][$group];
if($system_group === $CI->session->userdata('group_id'))
{
return TRUE;
}
}
function user_table()
{
$CI =& get_instance();
return $CI->ag_auth->user_table;
}
function group_table()
{
$CI =& get_instance();
return $CI->ag_auth->group_table;
}
?> | 101-code | sparks/Auth/2.0.5/helpers/ag_auth_helper.php | PHP | gpl3 | 607 |
<?php
function logged_in()
{
$CI =& get_instance();
if($CI->ag_auth->logged_in() == TRUE)
{
return TRUE;
}
return FALSE;
}
function username()
{
$CI =& get_instance();
return $CI->session->userdata('username');
}
function user_group($group)
{
$CI =& get_instance();
$system_group = $CI->ag_auth->config['auth_groups'][$group];
if($system_group === $CI->session->userdata('group_id'))
{
return TRUE;
}
}
function user_table()
{
$CI =& get_instance();
return $CI->ag_auth->user_table;
}
function group_table()
{
$CI =& get_instance();
return $CI->ag_auth->group_table;
}
?> | 101-code | sparks/Auth/2.0.5/helpers/auth_helper.php | PHP | gpl3 | 607 |
<?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://adamgriffiths.co.uk
* @version 2.0.3
* @copyright Adam Griffiths 2011
*
* Auth provides a powerful, lightweight and simple interface for user authentication .
*/
ob_start();
class AG_Auth
{
var $CI; // The CI object
var $config; // The config items
/**
* @author Adam Griffiths
* @param array
*
* The constructor public function loads the libraries dependancies and creates the
* login attempts cookie if it does not already exist.
*/
public function __construct($config)
{
log_message('debug', 'Auth Library Loaded');
$this->config = $config;
$this->CI =& get_instance();
$this->CI->load->database();
$this->CI->load->library('session');
$this->CI->load->helper('email');
$this->CI->load->model('ag_auth_model');
$this->CI->lang->load('ag_auth', 'english');
if($this->logged_in() == FALSE)
{
if(!array_key_exists('login_attempts', $_COOKIE))
{
setcookie("login_attempts", 0, time()+900, '/');
}
}
}
/**
* Restricts access to a page
*
* Takes a user level (e.g. admin, user etc) and restricts access to that user and above.
* Example, users can access a profile page, but so can admins (who are above users)
*
* @access public
* @param string
* @return bool
*/
public function restrict($group = NULL, $single = NULL)
{
if($group === NULL)
{
if($this->logged_in() == TRUE)
{
return TRUE;
}
else
{
show_error($this->CI->lang->line('insufficient_privs'));
}
}
elseif($this->logged_in() == TRUE)
{
$level = $this->config['auth_groups'][$group];
$user_level = $this->CI->session->userdata('group');
if($user_level > $level OR $single == TRUE && $user_level !== $level)
{
show_error($this->CI->lang->line('insufficient_privs'));
}
return TRUE;
}
else
{
redirect($this->config['auth_incorrect_login'], 'refresh');
}
} // public function restrict()
/**
* @author Adam Griffiths
* @return bool
*
* Checks the session data as to whether or not a user is logged in.
*/
public function logged_in()
{
if($this->CI->session->userdata('logged_in') === TRUE)
{
return TRUE;
}
else
{
return FALSE;
}
}
/**
* @author Adam Griffiths
* @param string
* @return string
*
* Uses the encryption key set in application/config/config.php to salt the password passed.
*/
public function salt($password)
{
return hash("haval256,5", $this->CI->config->item('encryption_key') . $password);
}
/**
* @author Adam Griffiths
* @param string
* @param string
* @return string / bool
*
* Takes a username & optional username type (email/username) and returns the user data
*/
public function get_user($username, $field_type = 'username')
{
$user = $this->CI->ag_auth_model->login_check($username, $field_type);
return $user;
}
/**
* @author Adam Griffiths
* @param string
* @param string
* @param string
* @return bool
*
* Creates a new user account
*/
public function register($username, $password, $email)
{
return $this->CI->ag_auth_model->register($username, $password, $email);
}
/**
* @author Adam Griffiths
* @param array
*
* Takes the user array, adds the logged_in portion and sets the session data from that.
*/
public function login_user($user)
{
$user['logged_in'] = TRUE;
$this->CI->session->set_userdata($user);
}
/**
* Destroys the user session.
*
* @access public
*/
public function logout()
{
$this->CI->session->sess_destroy();
redirect($this->CI->config->item('auth_logout'));
}
/**
* Generate a new token/identifier from random.org
*
* @author Adam Griffiths
* @access private
* @param string
*/
private function _generate()
{
$username = $this->CI->session->userdata('username');
// No love either way, generate a random string ourselves
$length = 20;
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$token = "";
for ($i = 0; $i < $length; $i++)
{
$token .= $characters[mt_rand(0, strlen($characters)-1)];
}
$identifier = $username . $token;
$identifier = $this->_salt($identifier);
$this->CI->db->query("UPDATE `$this->user_table` SET `identifier` = '$identifier', `token` = '$token' WHERE `username` = '$username'");
setcookie("logged_in", $identifier, time()+3600, '/');
}
/**
* Verify that a user has a cookie, if not generate one. If the cookie doesn't match the database, log the user out and show them an error.
*
* @access private
* @param string
*/
private function _verify_cookie()
{
if((array_key_exists('login_attempts', $_COOKIE)) && ($_COOKIE['login_attempts'] <= 5))
{
$username = $this->CI->session->userdata('username');
$userdata = $this->CI->db->query("SELECT * FROM `$this->user_table` WHERE `username` = '$username'");
$result = $userdata->row();
$identifier = $result->username . $result->token;
$identifier = $this->_salt($identifier);
if($identifier !== $_COOKIE['logged_in'])
{
$this->CI->session->sess_destroy();
show_error($this->CI->lang->line('logout_perms_error'));
}
}
else
{
$this->_generate();
}
}
/**
* Load an auth specific view
*
* @access private
* @param string
*/
public function view($page, $params = NULL)
{
if($params !== NULL)
{
$data['data'] = $params;
}
$data['page'] = $page;
$this->CI->load->view($this->config['auth_views_root'].'index', $data);
}
}
/* End of file: AG_Auth.php */
/* Location: application/libraries/AG_Auth.php */ | 101-code | sparks/Auth/2.0.5/libraries/AG_Auth.php | PHP | gpl3 | 5,670 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | sparks/Auth/2.0.5/libraries/index.html | HTML | gpl3 | 123 |
<?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://adamgriffiths.co.uk
* @version 2.0.3
* @copyright Adam Griffiths 2011
*
* Auth provides a powerful, lightweight and simple interface for user authentication .
*/
class AG_Auth_model extends CI_Model
{
var $user_table; // The user table (prefix + config)
var $group_table; // The group table (prefix + config)
public function __construct()
{
parent::__construct();
log_message('debug', 'Auth Model Loaded');
$this->config->load('ag_auth');
$this->load->database();
$this->user_table = $this->config->item('auth_user_table');
$this->group_table = $this->config->item('auth_group_table');
}
public function login_check($username, $field_type)
{
$query = $this->db->get_where($this->user_table, array($field_type => $username));
$result = $query->row_array();
return $result;
}
public function register($username, $password, $email)
{
if($this->db->set('username', $username)->set('password', $password)->set('email', $email)->set('group_id', '100')->insert($this->user_table))
{
return TRUE;
}
return FALSE;
}
public function field_exists($value)
{
$field_name = (valid_email($value) ? 'email' : 'username');
$query = $this->db->get_where($this->user_table, array($field_name => $value));
if($query->num_rows() <> 0)
{
return FALSE;
}
return TRUE;
}
}
/* End of file: ag_auth_model.php */
/* Location: application/models/auth_model.php */ | 101-code | sparks/Auth/2.0.5/models/ag_auth_model.php | PHP | gpl3 | 1,552 |
<?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://adamgriffiths.co.uk
* @version 2.0.3
* @copyright Adam Griffiths 2011
*
* Auth provides a powerful, lightweight and simple interface for user authentication .
*/
class Application extends CI_Controller
{
public function __construct()
{
parent::__construct();
log_message('debug', 'Application Loaded');
$this->load->library(array('form_validation', 'ag_auth'));
$this->load->helper(array('url', 'email', 'ag_auth'));
$this->config->load('ag_auth');
}
public function field_exists($value)
{
$field_name = (valid_email($value) ? 'email' : 'username');
$user = $this->ag_auth->get_user($value, $field_name);
if(array_key_exists('id', $user))
{
$this->form_validation->set_message('field_exists', 'The ' . $field_name . ' provided already exists, please use another.');
return FALSE;
}
else
{
return TRUE;
} // if($this->field_exists($value) === TRUE)
} // public function field_exists($value)
public function register()
{
$this->form_validation->set_rules('username', 'Username', 'required|min_length[6]|callback_field_exists');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[6]|matches[password_conf]');
$this->form_validation->set_rules('password_conf', 'Password Confirmation', 'required|min_length[6]|matches[password]');
$this->form_validation->set_rules('email', 'Email Address', 'required|min_length[6]|valid_email|callback_field_exists');
if($this->form_validation->run() == FALSE)
{
$this->ag_auth->view('register');
}
else
{
$username = set_value('username');
$password = $this->ag_auth->salt(set_value('password'));
$email = set_value('email');
if($this->ag_auth->register($username, $password, $email) === TRUE)
{
$data['message'] = "The user account has now been created.";
$this->ag_auth->view('message', $data);
} // if($this->ag_auth->register($username, $password, $email) === TRUE)
else
{
$data['message'] = "The user account has not been created.";
$this->ag_auth->view('message', $data);
}
} // if($this->form_validation->run() == FALSE)
} // public function register()
public function login($redirect = NULL)
{
if($redirect === NULL)
{
$redirect = $this->ag_auth->config['auth_login'];
}
$this->form_validation->set_rules('username', 'Username', 'required|min_length[6]');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[6]');
if($this->form_validation->run() == FALSE)
{
$this->ag_auth->view('login');
}
else
{
$username = set_value('username');
$password = $this->ag_auth->salt(set_value('password'));
$field_type = (valid_email($username) ? 'email' : 'username');
$user_data = $this->ag_auth->get_user($username, $field_type);
if($user_data['password'] === $password)
{
unset($user_data['password']);
unset($user_data['id']);
$this->ag_auth->login_user($user_data);
redirect($redirect);
} // if($user_data['password'] === $password)
else
{
$data['message'] = "The username and password did not match.";
$this->ag_auth->view('message', $data);
}
} // if($this->form_validation->run() == FALSE)
} // login()
public function logout()
{
$this->ag_auth->logout();
}
}
/* End of file: MY_Controller.php */
/* Location: application/core/MY_Controller.php */ | 101-code | sparks/Auth/2.0.5/core/MY_Controller.php | PHP | gpl3 | 3,558 |
<?php
class Users extends Application
{
public function __construct()
{
parent::__construct();
$this->ag_auth->restrict('admin'); // restrict this controller to admins only
}
public function manage()
{
$this->load->library('table');
$data = $this->db->get($this->ag_auth->config['auth_user_table']);
$result = $data->result_array();
$this->table->set_heading('Username', 'Email', 'Actions'); // Setting headings for the table
foreach($result as $value => $key)
{
$actions = anchor("admin/users/delete/".$key['id']."/", "Delete"); // Build actions links
$this->table->add_row($key['username'], $key['email'], $actions); // Adding row to table
}
$this->ag_auth->view('users/manage'); // Load the view
}
public function delete($id)
{
$this->db->where('id', $id)->delete($this->ag_auth->config['auth_user_table']);
$this->ag_auth->view('users/delete_success');
}
// WOKRING ON PROPER IMPLEMENTATION OF ADDING & EDITING USER ACCOUNTS
}
?> | 101-code | sparks/Auth/2.0.5/controllers/admin/users.php | PHP | gpl3 | 998 |
<?php
class Admin extends Application
{
public function __construct()
{
parent::__construct();
}
public function index()
{
if(logged_in())
{
$this->ag_auth->view('dashboard');
}
else
{
$this->login();
}
}
}
/* End of file: dashboard.php */
/* Location: application/controllers/admin/dashboard.php */ | 101-code | sparks/Auth/2.0.5/controllers/admin/admin.php | PHP | gpl3 | 330 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | sparks/Auth/2.0.5/controllers/index.html | HTML | gpl3 | 123 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['scaffolding_trigger'] = 'scaffolding';
|
| This route lets you set a "secret" word that will trigger the
| scaffolding feature for added security. Note: Scaffolding must be
| enabled in the controller in which you intend to use it. The reserved
| routes must come before any wildcard or regular expression routes.
|
*/
$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";
// BEGIN AUTHENTICATION LIBRARY ROUTES
$route['login'] = "admin/admin/login";
$route['logout'] = "admin/admin/logout";
$route['register'] = "admin/admin/register";
$route['admin/dashboard'] = "admin/admin/index";
// END AUTHENTICATION LIBRARY ROUTES
/* End of file routes.php */
/* Location: ./system/application/config/routes.php */ | 101-code | sparks/Auth/2.0.5/config/routes.php | PHP | gpl3 | 1,957 |
<?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://adamgriffiths.co.uk
* @version 1.0.6
* @copyright Adam Griffiths 2009
*
* Auth provides a powerful, lightweight and simple interface for user authentication
*/
/**
* The array which holds your user groups and their ID.
* If you have a database table for groups, these ID's must be the same as in the database.
*/
$config['auth_groups'] = array(
'admin' => '1',
'editor' => '2',
'user' => '100'
);
/**
* The default URI string to redirect to after a successful login.
*/
$config['auth_login'] = 'admin/dashboard';
/**
* The default URI string to redirect to after a successful logout.
*/
$config['auth_logout'] = 'login';
/**
* The URI string to redirect to when a user entered incorrect login details or is not authenticated
*/
$config['auth_incorrect_login'] = 'login';
/**
* bool TRUE / FALSE
* Determines whether or not users will be remembered by the auth library
*/
$config['auth_remember'] = TRUE;
/**
* The following options provide the ability to easily rename the directories
* for your auth views, models, and controllers.
*
* Remember to also update your routes file if you change the controller directory
* MUST HAVE A TRAILING SLASH!
*/
$config['auth_controllers_root'] = 'admin/';
$config['auth_models_root'] = '';
$config['auth_views_root'] = 'auth/';
/**
* Set the names for your user tables below (sans prefix, which will be automatically added)
* ex.: your table is named `ci_users` with 'ci_' defined as your dbprefix in config/database.php, so set it to 'users' below
*/
$config['auth_user_table'] = 'users';
$config['auth_group_table'] = 'groups';
?> | 101-code | sparks/Auth/2.0.5/config/ag_auth.php | PHP | gpl3 | 1,736 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | sparks/Auth/2.0.5/index.html | HTML | gpl3 | 123 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Catalan
*
* Author: Wilfrido García Espinosa
* contacto@wilfridogarcia.com
* @wilfridogarcia
*
* Translation: Oriol Navascuez
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 05.04.2010
*
* Description: Catalan language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Compte creat amb èxit';
$lang['account_creation_unsuccessful'] = 'No ha estat possible crear al compte';
$lang['account_creation_duplicate_email'] = 'Email en ús o invàlid';
$lang['account_creation_duplicate_username'] = 'Nom d'usuari en ús o invàlid';
// Password
$lang['password_change_successful'] = 'Password canviat amb èxit';
$lang['password_change_unsuccessful'] = 'No ha estat possible canviar el password';
$lang['forgot_password_successful'] = 'Nou password enviat per email';
$lang['forgot_password_unsuccessful'] = 'No ha estat possible crear un nou password';
// Activation
$lang['activate_successful'] = 'Compte activat';
$lang['activate_unsuccessful'] = 'No ha estat possible activar el compte';
$lang['deactivate_successful'] = 'Compte desactivat';
$lang['deactivate_unsuccessful'] = 'No ha estat possible desactivar el compte';
$lang['activation_email_successful'] = 'Email d'activació enviat';
$lang['activation_email_unsuccessful'] = 'No ha estat possible enviar l'email d'activació';
// Login / Logout
$lang['login_successful'] = 'Sessió iniciada amb èxit';
$lang['login_unsuccessful'] = 'No ha estat possible iniciar sessió';
$lang['logout_successful'] = 'Sessiò finalitzada amb èxit';
// Account Changes
$lang['update_successful'] = 'Informació del compte actualitzat amb èxit';
$lang['update_unsuccessful'] = 'No s'ha pogut actualitzar la informació del compte';
$lang['delete_successful'] = 'Usuari eliminat';
$lang['delete_unsuccessful'] = 'No s'ha pogut Eliminar l'usuari';
?>
| 101-code | sparks/Ion_auth/language/catalan/ion_auth_lang.php | PHP | gpl3 | 2,097 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Spanish
*
* Author: Wilfrido Garc�a Espinosa
* contacto@wilfridogarcia.com
* @wilfridogarcia
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 05.04.2010
*
* Description: Spanish language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Cuenta creada con éxito';
$lang['account_creation_unsuccessful'] = 'No se ha podido crear la cuenta';
$lang['account_creation_duplicate_email'] = 'Email en uso o inválido';
$lang['account_creation_duplicate_username'] = 'Nombre de usuario en uso o inválido';
// Password
$lang['password_change_successful'] = 'Password cambiado con éxito';
$lang['password_change_unsuccessful'] = 'No se ha podido cambiar el password';
$lang['forgot_password_successful'] = 'Nuevo password enviado por email';
$lang['forgot_password_unsuccessful'] = 'No se ha podido crear un nuevo password';
// Activation
$lang['activate_successful'] = 'Cuenta activada';
$lang['activate_unsuccessful'] = 'No se ha podido activar la cuenta';
$lang['deactivate_successful'] = 'Cuenta desactivada';
$lang['deactivate_unsuccessful'] = 'No se ha podido desactivar la cuenta';
$lang['activation_email_successful'] = 'Email de activación enviado';
$lang['activation_email_unsuccessful'] = 'No se ha podido enviar el email de activación';
// Login / Logout
$lang['login_successful'] = 'Sesión iniciada con éxito';
$lang['login_unsuccessful'] = 'No se ha podido iniciar sesión';
$lang['logout_successful'] = 'Sesión finalizada con éxito';
// Account Changes
$lang['update_successful'] = 'Información de la cuenta actualizada con éxito';
$lang['update_unsuccessful'] = 'No se ha podido actualizar la información de la cuenta';
$lang['delete_successful'] = 'Usuario eliminado';
$lang['delete_unsuccessful'] = 'No se ha podido Eliminar el usuario';
?>
| 101-code | sparks/Ion_auth/language/spanish/ion_auth_lang.php | PHP | gpl3 | 2,070 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Finnish
*
* Author: Jarno Fabritius
* jarno.fabritius@meisso.com
* @meisso_jarno
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 01.03.2011
*
* Description: Finnish language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Tili luotiin onnistuneesti!';
$lang['account_creation_unsuccessful'] = 'Tilin luonti epäonnistui';
$lang['account_creation_duplicate_email'] = 'Sähköpostiosoite on virheellinen tai se on jo käytössä';
$lang['account_creation_duplicate_username'] = 'Tunnus on virheellinen tai se on jo käytössä';
// Password
$lang['password_change_successful'] = 'Salasana vaihdettu!';
$lang['password_change_unsuccessful'] = 'Salasanan vaihto epäonnistui';
$lang['forgot_password_successful'] = 'Salasanan resetointiohjeet lähetettiin sähköpostiin';
$lang['forgot_password_unsuccessful'] = 'Salasanan resetointi epäonnistui';
// Activation
$lang['activate_successful'] = 'Tili aktivoitu!';
$lang['activate_unsuccessful'] = 'Tilin aktivointi epäonnistui';
$lang['deactivate_successful'] = 'Tili suljettu';
$lang['deactivate_unsuccessful'] = 'Tilin sulkeminen epäonnistui';
$lang['activation_email_successful'] = 'Aktivointiviesti lähetetty';
$lang['activation_email_unsuccessful'] = 'Aktivointiviestiä ei voitu lähettää';
// Login / Logout
$lang['login_successful'] = 'Olet nyt kirjautunut sisään!';
$lang['login_unsuccessful'] = 'Kirjautuminen epäonnistui';
$lang['logout_successful'] = 'Olet nyt kirjautunut ulos';
// Account Changes
$lang['update_successful'] = 'Tilin tiedot päivitetty!';
$lang['update_unsuccessful'] = 'Tietojen päivitys epäonnistui';
$lang['delete_successful'] = 'Tili poistettu';
$lang['delete_unsuccessful'] = 'Tilin poisto epäonnistui'; | 101-code | sparks/Ion_auth/language/finnish/ion_auth_lang.php | PHP | gpl3 | 2,008 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Norwegian
*
* Author: Tomas E. Sandven
* tomas191191@gmail.com
* @codemonkey1991
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 01.01.2012
*
* Description: Norwegian language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Konto opprettet';
$lang['account_creation_unsuccessful'] = 'Klarte ikke å opprette konto';
$lang['account_creation_duplicate_email'] = 'E-mail adressen er allerede i bruk eller ugyldig';
$lang['account_creation_duplicate_username'] = 'Brukernavnet er allerede i bruk eller ugyldig';
// Password
$lang['password_change_successful'] = 'Passordet har blitt endret';
$lang['password_change_unsuccessful'] = 'Klarte ikke å endre passord';
$lang['forgot_password_successful'] = 'E-mail for passord tilbakestilling har blitt sendt';
$lang['forgot_password_unsuccessful'] = 'Klarte ikke å tilbakestille passord';
// Activation
$lang['activate_successful'] = 'Kontoen har blitt aktivert';
$lang['activate_unsuccessful'] = 'Klarte ikke å aktivere konto';
$lang['deactivate_successful'] = 'Kontoen har blitt deaktivert';
$lang['deactivate_unsuccessful'] = 'Klarte ikke å deaktivere konto';
$lang['activation_email_successful'] = 'E-mail for aktivering av konto har blitt sendt';
$lang['activation_email_unsuccessful'] = 'Klarte ikke å sende e-mail for aktivering av konto';
// Login / Logout
$lang['login_successful'] = 'Logget inn';
$lang['login_unsuccessful'] = 'Feil brukernavn eller passord';
$lang['logout_successful'] = 'Logget ut';
// Account Changes
$lang['update_successful'] = 'Konto informasjon oppdatert';
$lang['update_unsuccessful'] = 'Klarte ikke å oppdatere konto informasjon';
$lang['delete_successful'] = 'Konto fjernet';
$lang['delete_unsuccessful'] = 'Klarte ikke å fjerne konto'; | 101-code | sparks/Ion_auth/language/norwegian/ion_auth_lang.php | PHP | gpl3 | 2,031 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Polish
*
* Author: Bart Majewski
* hello@bartoszmajewski.pl
* @bart_majewski
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.23.2010
*
* Description: Polish language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Konto zostało pomyślnie założone';
$lang['account_creation_unsuccessful'] = 'Nie można utworzyć konta';
$lang['account_creation_duplicate_email'] = 'Podany adres Email jest nieprawidłowy lub został już użyty';
$lang['account_creation_duplicate_username'] = 'Podana nazwa użytkownika jest nieprawidłowa lub została już użyta';
// Password
$lang['password_change_successful'] = 'Hasło zostało pomyślnie zmienione';
$lang['password_change_unsuccessful'] = 'Nie można zmienić hasła';
$lang['forgot_password_successful'] = 'Nowe hasło zostało wysłane';
$lang['forgot_password_unsuccessful'] = 'Nie można zresetować hasła';
// Activation
$lang['activate_successful'] = 'Konto zostało aktywowane';
$lang['activate_unsuccessful'] = 'Nie można aktywować konta';
$lang['deactivate_successful'] = 'Konto zostało deaktywowane';
$lang['deactivate_unsuccessful'] = 'Nie można deaktywować konta';
$lang['activation_email_successful'] = 'Na twój adres E-mail został wysłany link aktywacyjny';
$lang['activation_email_unsuccessful'] = 'Nie można wysłać linku aktywacyjnego';
// Login / Logout
$lang['login_successful'] = 'Użytkownik został pomyślnie zalogowany';
$lang['login_unsuccessful'] = 'Nieprawidłowy login';
$lang['logout_successful'] = 'Użytkownik został pomyślnie wylogowany';
// Account Changes
$lang['update_successful'] = 'Konto zostało pomyślnie uaktualnione';
$lang['update_unsuccessful'] = 'Nie można uaktualnić konta';
$lang['delete_successful'] = 'Użytkownik został skasowany';
$lang['delete_unsuccessful'] = 'Nie można skasować użytkownika';
?>
| 101-code | sparks/Ion_auth/language/polish/ion_auth_lang.php | PHP | gpl3 | 2,065 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Turkish (UTF-8)
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
* Translation: Acipayamli Ozi
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 05.01.2010
*
* Description: Turkish language file for Ion Auth messages and errors
*/
// Account Creation
$lang['account_creation_successful'] = 'Üyelik Kaydınız Başarıyla Tamamlandı';
$lang['account_creation_unsuccessful'] = 'Üyelik Kaydınız Yapılamadı';
$lang['account_creation_duplicate_email'] = 'E-mail Adresi Geçersiz ya da Daha Önceden Alınmış';
$lang['account_creation_duplicate_username'] = 'Kullanıcı Adı Geçersiz ya da Daha Önceden Alınmış';
// Password
$lang['password_change_successful'] = 'Şifreniz Değiştirildi';
$lang['password_change_unsuccessful'] = 'Şifreniz Değiştirelemedi';
$lang['forgot_password_successful'] = 'Yen Şifreniz E-mail Adresinize Yollandı';
$lang['forgot_password_unsuccessful'] = 'Şifreniz Değiştirilemedi';
// Activation
$lang['activate_successful'] = 'Hesap Kullanıma Açıldı';
$lang['activate_unsuccessful'] = 'Hesap Kullanıma Açılamadı';
$lang['deactivate_successful'] = 'Hesap Kullanıma Kapatıldı';
$lang['deactivate_unsuccessful'] = 'Hesap Kullanıma Kapatılamadı';
$lang['activation_email_successful'] = 'Aktivasyon Maili Yollandı';
$lang['activation_email_unsuccessful'] = 'Aktivasyon Maili Yollanamadı';
// Login / Logout
$lang['login_successful'] = 'Giriş Başarılı';
$lang['login_unsuccessful'] = 'Giriş Başarısız';
$lang['logout_successful'] = 'Çıkış Başarılı';
// Account Changes
$lang['update_successful'] = 'Üyelik Bilgileri Güncellendi';
$lang['update_unsuccessful'] = 'Üyelik Bilgileri Güncellenemedi';
$lang['delete_successful'] = 'Kullanıcı Silindi';
$lang['delete_unsuccessful'] = 'Kullanıcı Silinemedi';
?>
| 101-code | sparks/Ion_auth/language/turkish/ion_auth_lang.php | PHP | gpl3 | 2,044 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - German
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
* Translation: Bernd Hückstädt
* akademie@joytopia.net
*
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 04.02.2010
*
* Description: German language file for Ion Auth messages and errors
* Beschreibung: Deutsche Sprach-Datei für Ion Auth System- und Fehlermeldungen
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Das Benutzerkonto wurde erfolgreich erstellt';
$lang['account_creation_unsuccessful'] = 'Das Benutzerkonto konnte nicht erstellt werden';
$lang['account_creation_duplicate_email'] = 'Die E-Mail-Adresse ist ungültig oder wird bereits verwendet';
$lang['account_creation_duplicate_username'] = 'Der Benutzername ist ungültig oder wird bereits verwendet';
// Password
$lang['password_change_successful'] = 'Das Passwort wurde erfolgreich geändert';
$lang['password_change_unsuccessful'] = 'Das Passwort konnte nicht geändert werden';
$lang['forgot_password_successful'] = 'Es wurde eine E-Mail zum Zurücksetzen des Passwortes versandt';
$lang['forgot_password_unsuccessful'] = 'Das Passwort konnte nicht zurückgesetzt werden';
// Activation
$lang['activate_successful'] = 'Das Benutzerkonto wurde aktiviert';
$lang['activate_unsuccessful'] = 'Das Benutzerkonto konnte nicht aktiviert werden';
$lang['deactivate_successful'] = 'Das Benutzerkonto wurde deaktiviert';
$lang['deactivate_unsuccessful'] = 'Das Benutzerkonto konnte nicht deaktiviert werden';
$lang['activation_email_successful'] = 'Es wurde eine E-Mail zum Aktivieren des Benutzerkontos versandt';
$lang['activation_email_unsuccessful'] = 'Die Aktivierungs-E-Mail konnte nicht versandt werden';
// Login / Logout
$lang['login_successful'] = 'Login erfolgreich';
$lang['login_unsuccessful'] = 'Login fehlgeschlagen';
$lang['logout_successful'] = 'Logout erfolgreich';
// Account Changes
$lang['update_successful'] = 'Die Konto-Informationen wurden erfolgreich geändert';
$lang['update_unsuccessful'] = 'Die Konto-Informationen konnten nicht geändert werden';
$lang['delete_successful'] = 'Das Benutzerkonto wurde gelöscht';
$lang['delete_unsuccessful'] = 'Das Benutzerkonto konnte nicht gelöscht werden';
?>
| 101-code | sparks/Ion_auth/language/german/ion_auth_lang.php | PHP | gpl3 | 2,511 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Swedish
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.14.2010
*
* Description: Swedish language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Kontot har nu skapats';
$lang['account_creation_unsuccessful'] = 'Det gick inte att skapa kontot';
$lang['account_creation_duplicate_email'] = 'E-postadressen är ogiltig eller används redan';
$lang['account_creation_duplicate_username'] = 'Användarnamnet är ogiltigt eller används redan';
// Password
$lang['password_change_successful'] = 'Lösenordet har nu ändrats';
$lang['password_change_unsuccessful'] = 'Det gick inte att ändra lösenordet';
$lang['forgot_password_successful'] = 'E-postadressen för återställning av lösenord har nu skickats';
$lang['forgot_password_unsuccessful'] = 'Det gick inte att återställa lösenordet';
// Activation
$lang['activate_successful'] = 'Kontot aktiverades';
$lang['activate_unsuccessful'] = 'Det gick inte att aktivera kontot';
$lang['deactivate_successful'] = 'Kontot inaktiverades';
$lang['deactivate_unsuccessful'] = 'Det gick inte att inaktivera kontot';
$lang['activation_email_successful'] = 'En aktveringslänk har skickats till din e-post';
$lang['activation_email_unsuccessful'] = 'E-post med aktiveringslänk kunde inte skickas';
// Login / Logout
$lang['login_successful'] = 'Du är nu inloggad';
$lang['login_unsuccessful'] = 'Inloggningen misslyckades';
$lang['logout_successful'] = 'Du är nu utloggad';
// Account Changes
$lang['update_successful'] = 'Kontouppgifterna uppdaterades';
$lang['update_unsuccessful'] = 'Det gick inte att uppdatera kontouppgifterna';
$lang['delete_successful'] = 'Användaren är borttagen';
$lang['delete_unsuccessful'] = 'Det gick inte att ta bort användaren'; | 101-code | sparks/Ion_auth/language/swedish/ion_auth_lang.php | PHP | gpl3 | 2,094 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Russian (UTF-8)
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
* Translation: Petrosyan R.
* for@petrosyan.rv.ua
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.26.2010
*
* Description: Russian language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Учетная запись успешно создана';
$lang['account_creation_unsuccessful'] = 'Невозможно создать учетную запись';
$lang['account_creation_duplicate_email'] = 'Электронная почта используется или некорректна';
$lang['account_creation_duplicate_username'] = 'Имя пользователя существует или некорректно';
// Password
$lang['password_change_successful'] = 'Пароль успешно изменен';
$lang['password_change_unsuccessful'] = 'Пароль невозможно изменить';
$lang['forgot_password_successful'] = 'Пароль сброшен. На электронную почту отправлено сообщение';
$lang['forgot_password_unsuccessful'] = 'Невозможен сброс пароля';
// Activation
$lang['activate_successful'] = 'Учетная запись активирована';
$lang['activate_unsuccessful'] = 'Не удалось активировать учетную запись';
$lang['deactivate_successful'] = 'Учетная запись деактивирована';
$lang['deactivate_unsuccessful'] = 'Невозможно деактивировать учетную запись';
$lang['activation_email_successful'] = 'Сообщение об активации отправлено';
$lang['activation_email_unsuccessful'] = 'Сообщение об активации невозможно отправить';
// Login / Logout
$lang['login_successful'] = 'Авторизация прошла успешно';
$lang['login_unsuccessful'] = 'Логин не верен';
$lang['logout_successful'] = 'Выход успешный';
// Account Changes
$lang['update_successful'] = 'Учетная запись успешно обновлена';
$lang['update_unsuccessful'] = 'Невозможно обновить учетную запись';
$lang['delete_successful'] = 'Учетная запись удалена';
$lang['delete_unsuccessful'] = 'Невозможно удалить учетную запись';
?> | 101-code | sparks/Ion_auth/language/russian/ion_auth_lang.php | PHP | gpl3 | 2,703 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - English
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.14.2010
*
* Description: English language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Account Successfully Created';
$lang['account_creation_unsuccessful'] = 'Unable to Create Account';
$lang['account_creation_duplicate_email'] = 'Email Already Used or Invalid';
$lang['account_creation_duplicate_username'] = 'Username Already Used or Invalid';
// Password
$lang['password_change_successful'] = 'Password Successfully Changed';
$lang['password_change_unsuccessful'] = 'Unable to Change Password';
$lang['forgot_password_successful'] = 'Password Reset Email Sent';
$lang['forgot_password_unsuccessful'] = 'Unable to Reset Password';
// Activation
$lang['activate_successful'] = 'Account Activated';
$lang['activate_unsuccessful'] = 'Unable to Activate Account';
$lang['deactivate_successful'] = 'Account De-Activated';
$lang['deactivate_unsuccessful'] = 'Unable to De-Activate Account';
$lang['activation_email_successful'] = 'Activation Email Sent';
$lang['activation_email_unsuccessful'] = 'Unable to Send Activation Email';
// Login / Logout
$lang['login_successful'] = 'Logged In Successfully';
$lang['login_unsuccessful'] = 'In-Correct Login';
$lang['logout_successful'] = 'Logged Out Successfully';
// Account Changes
$lang['update_successful'] = 'Account Information Successfully Updated';
$lang['update_unsuccessful'] = 'Unable to Update Account Information';
$lang['delete_successful'] = 'User Deleted';
$lang['delete_unsuccessful'] = 'Unable to Delete User'; | 101-code | sparks/Ion_auth/language/english/ion_auth_lang.php | PHP | gpl3 | 1,906 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Greek
*
* Author: Vagelis Papaloukas
* vagelispapalou@yahoo.gr
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 02.04.2011
*
* Description: Greek language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Ο Λογαριασμός Δημιουργήθηκε Επιτυχώς';
$lang['account_creation_unsuccessful'] = 'Αποτυχία Δημιουργίας Λογαριασμού';
$lang['account_creation_duplicate_email'] = 'Το Email χρησιμποιείται ήδη ή είναι λάθος';
$lang['account_creation_duplicate_username'] = 'Ο Χρήστης υπάρχει ήδη ή είναι λάθος';
// Password
$lang['password_change_successful'] = 'Επιτυχής Αλλαγή Κωδικού';
$lang['password_change_unsuccessful'] = 'Αδυναμία Αλλαγής Κωδικού';
$lang['forgot_password_successful'] = 'Εστάλη Email Κωδικού Επαναφοράς';
$lang['forgot_password_unsuccessful'] = 'Αδυναμία Επαναφοράς Κωδικού';
// Activation
$lang['activate_successful'] = 'Ο Λογαριασμός Ενεργοποιήθηκε';
$lang['activate_unsuccessful'] = 'Αδυναμία Ενεργοποίησης Λογαριασμού';
$lang['deactivate_successful'] = 'Ο Λογαριασμός Απενεργοποιήθηκε';
$lang['deactivate_unsuccessful'] = 'Αδυναμία Απενεργοποίησης Λογαριασμού';
$lang['activation_email_successful'] = 'Εστάλη Email Ενεργοποίησης Λογαριασμού';
$lang['activation_email_unsuccessful'] = 'Αδυναμία Αποστολής Email Ενεργοποίησης';
// Login / Logout
$lang['login_successful'] = 'Συνδεθήκατε Επιτυχώς';
$lang['login_unsuccessful'] = 'Λάθος Στοιχεία';
$lang['logout_successful'] = 'Αποσυνδεθήκατε Επιτυχώς';
// Account Changes
$lang['update_successful'] = 'Οι Πληροφορίες του Λογαριασμού Ενημερώθηκαν Επιτυχώς';
$lang['update_unsuccessful'] = 'Αδυναμία Ενημέρωσης Πληροφοριών Λογαριασμού';
$lang['delete_successful'] = 'Ο Χρήστης Διαγράφηκε';
$lang['delete_unsuccessful'] = 'Αδυναμία Διαγραφής Χρήστη'; | 101-code | sparks/Ion_auth/language/greek/ion_auth_lang.php | PHP | gpl3 | 2,583 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Ukraine (UTF-8)
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
* Translation: Petrosyan R.
* for@petrosyan.rv.ua
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.27.2010
*
* Description: Ukraine language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Обліковий запис успішно створено';
$lang['account_creation_unsuccessful'] = 'Неможливо створити обліковий запис';
$lang['account_creation_duplicate_email'] = 'Електронна пошта використовується або некоректна';
$lang['account_creation_duplicate_username'] = 'Ім`я користувача існує або некоректне';
// Password
$lang['password_change_successful'] = 'Пароль успішно змінено';
$lang['password_change_unsuccessful'] = 'Пароль неможливо змінити';
$lang['forgot_password_successful'] = 'Пароль скинутий. На електронну пошту відправлено повідомлення';
$lang['forgot_password_unsuccessful'] = 'Неможливе скидання пароля';
// Activation
$lang['activate_successful'] = 'Обліковий запис активовано';
$lang['activate_unsuccessful'] = 'Не вдалося активувати обліковий запис';
$lang['deactivate_successful'] = 'Обліковий запис деактивовано';
$lang['deactivate_unsuccessful'] = 'Неможливо деактивувати обліковий запис';
$lang['activation_email_successful'] = 'Повідомлення про активацію відправлено';
$lang['activation_email_unsuccessful'] = 'Повідомлення про активацію неможливо відправити';
// Login / Logout
$lang['login_successful'] = 'Авторизація пройшла успішно';
$lang['login_unsuccessful'] = 'Логін невірний';
$lang['logout_successful'] = 'Вихід успішний';
// Account Changes
$lang['update_successful'] = 'Обліковий запис успішно оновлено';
$lang['update_unsuccessful'] = 'Неможливо оновити обліковий запис';
$lang['delete_successful'] = 'Обліковий запис видалено';
$lang['delete_unsuccessful'] = 'Неможливо видалити обліковий запис';
?> | 101-code | sparks/Ion_auth/language/ukrainian/ion_auth_lang.php | PHP | gpl3 | 2,772 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - French
*
* Author: Stan
* tfspir@gmail.com
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.23.2010
*
* Description: French language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Compte créé avec succès';
$lang['account_creation_unsuccessful'] = 'Impossible de créer le compte';
$lang['account_creation_duplicate_email'] = 'Email déjà utilisé ou invalide';
$lang['account_creation_duplicate_username'] = 'Nom d\'utilisateur déjà utilisé ou invalide';
// Password
$lang['password_change_successful'] = 'Le mot de passe a été changé avec succès';
$lang['password_change_unsuccessful'] = 'Impossible de changer le mot de passe';
$lang['forgot_password_successful'] = 'Mail de réinitialisation du mot de passe envoyé';
$lang['forgot_password_unsuccessful'] = 'Impossible de réinitialiser le mot de passe';
// Activation
$lang['activate_successful'] = 'Compte activé';
$lang['activate_unsuccessful'] = 'Impossible d\'activer le compte';
$lang['deactivate_successful'] = 'Compte désactivé';
$lang['deactivate_unsuccessful'] = 'Impossible de désactiver le compte';
$lang['activation_email_successful'] = 'Email d\'activation envoyé avec succès';
$lang['activation_email_unsuccessful'] = 'Impossible d\'envoyer le mail d\'activation';
// Login / Logout
$lang['login_successful'] = 'Connecté avec succès';
$lang['login_unsuccessful'] = 'Erreur lors de la connexion';
$lang['logout_successful'] = 'Déconnexion effectuée avec succès';
// Account Changes
$lang['update_successful'] = 'Compte utilisateur mis à jour avec succès';
$lang['update_unsuccessful'] = 'Impossible de mettre à jour le compte utilisateur';
$lang['delete_successful'] = 'Utilisateur supprimé';
$lang['delete_unsuccessful'] = 'Impossible de supprimer l\'utilisateur';
?>
| 101-code | sparks/Ion_auth/language/french/ion_auth_lang.php | PHP | gpl3 | 1,959 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Arabic
*
* Author: Emad Elsaid
* blazeeboy@gmail.com
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 30.08.2010
*
* Description: Arabic language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'تم انشاء حسابك بنجاح';
$lang['account_creation_unsuccessful'] = 'حدث خطأ اثناء انشاء حسابك لدينا';
$lang['account_creation_duplicate_email'] = 'هذا البريد الإلكترونى تم استخدامه من قبل او غير صحيح';
$lang['account_creation_duplicate_username'] = 'اسم المستخدم تم التسجيل به من قبل او غير صحيح';
// Password
$lang['password_change_successful'] = 'تم تغيير كلمة السر';
$lang['password_change_unsuccessful'] = 'لا يمكن تغيير كلمة السر';
$lang['forgot_password_successful'] = 'تم ارسال بريد لإستعادة كلمة السر';
$lang['forgot_password_unsuccessful'] = 'لا يمكن استعادة كلمة السر';
// Activation
$lang['activate_successful'] = 'تم تفعيل حسابك';
$lang['activate_unsuccessful'] = 'لا يمكن تفعيل حسابك';
$lang['deactivate_successful'] = 'تم إيقاف حسابك';
$lang['deactivate_unsuccessful'] = 'لا يمكن إيقاف حسابك';
$lang['activation_email_successful'] = 'تم إرسال بريد التفعيل';
$lang['activation_email_unsuccessful'] = 'لا يمكن ارسال بريد التفعيل';
// Login / Logout
$lang['login_successful'] = 'تم تسجيل الدخول بنجاح';
$lang['login_unsuccessful'] = 'معلومات الدخول غير صحيحة';
$lang['logout_successful'] = 'تم تسجيل خروجك';
// Account Changes
$lang['update_successful'] = 'تم تعديل معلومات حسابك';
$lang['update_unsuccessful'] = 'لا يمكن تعديل معلومات الحساب';
$lang['delete_successful'] = 'تم إلغاء المستخدم';
$lang['delete_unsuccessful'] = 'لا يمكن إلغاء المستخدم';
| 101-code | sparks/Ion_auth/language/arabic/ion_auth_lang.php | PHP | gpl3 | 2,285 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Dutch
*
* Author: Jeroen van der Gulik
* jeroen@isset.nl
*
* Adjustments by Dieter
*
* Location: http://github.com/benedmunds/CodeIgniter-Ion-Auth
*
* Created: 05.01.2010
*
* Description: Dutch language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Account is aangemaakt';
$lang['account_creation_unsuccessful'] = 'Account aanmaken is mislukt';
$lang['account_creation_duplicate_email'] = 'E-mail is al in gebruik of ongeldig';
$lang['account_creation_duplicate_username'] = 'Gebruikersnaam is al in gebruik of ongeldig';
// Password
$lang['password_change_successful'] = 'Wachtwoord succesvol gewijzigd';
$lang['password_change_unsuccessful'] = 'Wachtwoord wijzigen is mislukt';
$lang['forgot_password_successful'] = 'E-mail om het wachtwoord te Resetten is verzonden';
$lang['forgot_password_unsuccessful'] = 'Wachtwoord resetten is mislukt';
// Activation
$lang['activate_successful'] = 'Account is geactiveerd';
$lang['activate_unsuccessful'] = 'Account activeren is mislukt';
$lang['deactivate_successful'] = 'Account is gedeactiveerd';
$lang['deactivate_unsuccessful'] = 'Accound deactiveren is mislukt';
$lang['activation_email_successful'] = 'Activatie e-mail is verzonden';
$lang['activation_email_unsuccessful'] = 'Activatie e-mail verzenden is mislukt';
// Login / Logout
$lang['login_successful'] = 'U bent ingelogd';
$lang['login_unsuccessful'] = 'Login is incorrect';
$lang['logout_successful'] = 'U bent uitgelogd';
// Account Changes
$lang['update_successful'] = 'Account is bijgewerkt';
$lang['update_unsuccessful'] = 'Account bijwerken is mislukt';
$lang['delete_successful'] = 'Gebruiker is verwijderd';
$lang['delete_unsuccessful'] = 'Gebruiker verwijderen is mislukt';
/* End of file ion_auth_lang.php */
/* Location: ./system/application/language/dutch/ion_auth_lang.php */
| 101-code | sparks/Ion_auth/language/dutch/ion_auth_lang.php | PHP | gpl3 | 2,090 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Estonian
*
* Author: Esko Lehtme
* esko@tsoon.com
* @eskolehtme
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 01.09.2011
*
* Description: Estonian language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Konto on loodud';
$lang['account_creation_unsuccessful'] = 'Konto loomine ebaõnnestus';
$lang['account_creation_duplicate_email'] = 'E-posti aadress on juba kasutusel või vigane.';
$lang['account_creation_duplicate_username'] = 'Kasutajanimi on juba kasutusel või vigane.';
// Password
$lang['password_change_successful'] = 'Salasõna on muudetud.';
$lang['password_change_unsuccessful'] = 'Salasõna muutmine ebaõnnestus.';
$lang['forgot_password_successful'] = 'Sinu e-postile saadeti kiri edasise juhendiga.';
$lang['forgot_password_unsuccessful'] = 'Salasõna muutmine ebaõnnestus.';
// Activation
$lang['activate_successful'] = 'Konto on aktiveeritud';
$lang['activate_unsuccessful'] = 'Konto aktiveerimine ebaõnnestus.';
$lang['deactivate_successful'] = 'Konto on taas aktiivne';
$lang['deactivate_unsuccessful'] = 'Konto aktiveerimine ebaõnnestus.';
$lang['activation_email_successful'] = 'Sinu e-postile saadeti kiri edasise juhendiga.';
$lang['activation_email_unsuccessful'] = 'Aktiveerimiskirja saatmine ebaõnnestus.';
// Login / Logout
$lang['login_successful'] = 'Oled sisse logitud';
$lang['login_unsuccessful'] = 'Sisenemine ebaõnnestus.';
$lang['logout_successful'] = 'Oled välja logitud';
// Account Changes
$lang['update_successful'] = 'Sinu andmed on muudetud';
$lang['update_unsuccessful'] = 'Andmete muutmine ebaõnnestus.';
$lang['delete_successful'] = 'Kasutaja on eemaldatud';
$lang['delete_unsuccessful'] = 'Kasutajat eemaldamine ebaõnnestus.'; | 101-code | sparks/Ion_auth/language/estonian/ion_auth_lang.php | PHP | gpl3 | 2,142 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Italian
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 07.08.2010
*
* Description: Italian language file for Ion Auth messages and errors
* translation: Antonio Frignani (www.thinkers.it)
*/
// Account Creation
$lang['account_creation_successful'] = 'Account creato con successo.';
$lang['account_creation_unsuccessful'] = 'Impossibile creare l\'account.';
$lang['account_creation_duplicate_email'] = 'Email già in uso o non valida.';
$lang['account_creation_duplicate_username'] = 'Nome utente già in uso o non valido.';
// Password
$lang['password_change_successful'] = 'Password modificata con successo.';
$lang['password_change_unsuccessful'] = 'Impossibile modificare la password.';
$lang['forgot_password_successful'] = 'Email di reset della password inviata.';
$lang['forgot_password_unsuccessful'] = 'Impossibile resettare la password.';
// Activation
$lang['activate_successful'] = 'Account attivato.';
$lang['activate_unsuccessful'] = 'Impossibile attivare l\'account.';
$lang['deactivate_successful'] = 'Account disattivato.';
$lang['deactivate_unsuccessful'] = 'Impossibile disattivare l\'account.';
$lang['activation_email_successful'] = 'Email di attivazione inviata.';
$lang['activation_email_unsuccessful'] = 'Impossibile inviare l\'email di attivazione.';
// Login / Logout
$lang['login_successful'] = 'Login effettuato con successo.';
$lang['login_unsuccessful'] = 'Login non corretto.';
$lang['logout_successful'] = 'Logout effettuato con successo.';
// Account Changes
$lang['update_successful'] = 'Informazioni dell\'account aggiornate con successo.';
$lang['update_unsuccessful'] = 'Impossibile aggiornare le informazioni dell\'account.';
$lang['delete_successful'] = 'Utente eliminato.';
$lang['delete_unsuccessful'] = 'Impossibile eliminare l\'utente.';
?> | 101-code | sparks/Ion_auth/language/italian/ion_auth_lang.php | PHP | gpl3 | 2,122 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Japanese
*
* Author: Nobuo Kihara
* softark@gmail.com
*
* Created: 2010-10-30
*
* Description: Japanese language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'アカウントを作成しました';
$lang['account_creation_unsuccessful'] = 'アカウントを作成することが出来ません';
$lang['account_creation_duplicate_email'] = 'メール・アドレスが登録済みまたは不正です';
$lang['account_creation_duplicate_username'] = 'ユーザー名が登録済みまたは不正です';
// Password
$lang['password_change_successful'] = 'パスワードを変更しました';
$lang['password_change_unsuccessful'] = 'パスワードを変更することが出来ません';
$lang['forgot_password_successful'] = 'パスワード再設定メールを送信しました';
$lang['forgot_password_unsuccessful'] = 'パスワードを再設定することが出来ません';
// Activation
$lang['activate_successful'] = 'アカウントを有効にしました';
$lang['activate_unsuccessful'] = 'アカウントを有効にすることが出来ません';
$lang['deactivate_successful'] = 'アカウントを無効にしました';
$lang['deactivate_unsuccessful'] = 'アカウントを無効にすることが出来ません';
$lang['activation_email_successful'] = 'アクティベーション・メールを送信しました';
$lang['activation_email_unsuccessful'] = 'アクティベーション・メールを送信できません';
// Login / Logout
$lang['login_successful'] = 'ログインしました';
$lang['login_unsuccessful'] = 'ログイン出来ません';
$lang['logout_successful'] = 'ログアウトしました';
// Account Changes
$lang['update_successful'] = 'アカウント情報を更新しました';
$lang['update_unsuccessful'] = 'アカウント情報を更新することが出来ません';
$lang['delete_successful'] = 'ユーザーを削除しました';
$lang['delete_unsuccessful'] = 'ユーザーを削除することが出来ません';
| 101-code | sparks/Ion_auth/language/japanese/ion_auth_lang.php | PHP | gpl3 | 2,251 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
* Every application needs to support the famous pirate language
*
* @author Yorick Peterse <info [at] yorickpeterse [dot] com>
* @link http://www.yorickpeterse.com/
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Ahoy, Welcome Aboard Landlubber!';
$lang['account_creation_unsuccessful'] = 'Avast, Unable to Commandeer Ship';
$lang['account_creation_duplicate_email'] = 'Letter in the Bottle Already Used or Invalid';
$lang['account_creation_duplicate_username'] = 'Pirate Name Already Used or Invalid';
// Password
$lang['password_change_successful'] = 'Secret Code Successfully Changed';
$lang['password_change_unsuccessful'] = 'Unable to Change Secret Code';
$lang['forgot_password_successful'] = 'Secret Code Reset Letter Sent';
$lang['forgot_password_unsuccessful'] = 'Unable to Reset Secret Code';
// Activation
$lang['activate_successful'] = 'Ahoy, Your Ship Be Ready For Sailing The Seven Seas';
$lang['activate_unsuccessful'] = 'Avast, Furner be having trouble!';
$lang['deactivate_successful'] = 'Furner be burned down by the Navy';
$lang['deactivate_unsuccessful'] = 'Shiver me timbers! Account not Deactivated';
$lang['activation_email_successful'] = 'Letter in the Bottle Sent';
$lang['activation_email_unsuccessful'] = 'Unable to Send Letter in the Bottle';
// Login / Logout
$lang['login_successful'] = 'Yarr, welcome aboard!';
$lang['login_unsuccessful'] = 'In-Correct Secret Code';
$lang['logout_successful'] = 'Be Seeying ya Matey';
// Account Changes
$lang['update_successful'] = 'Ship Information Successfully Updated';
$lang['update_unsuccessful'] = 'Unable to Update Ship Information';
$lang['delete_successful'] = 'Pirate Sent to Davy Jones\' Locker';
$lang['delete_unsuccessful'] = 'Avast, The Pirate be Still Alive'; | 101-code | sparks/Ion_auth/language/pirate/ion_auth_lang.php | PHP | gpl3 | 1,969 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Chinese Traditional
*
* Author: Bo-Yi Wu
* appleboy.tw@gmail.com
* @taiwan
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 03.14.2011
*
* Description: Chinese language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = '帳號建立成功';
$lang['account_creation_unsuccessful'] = '無法建立帳號';
$lang['account_creation_duplicate_email'] = '電子郵件已被使用或不合法';
$lang['account_creation_duplicate_username'] = '帳號已存在或不合法';
// Password
$lang['password_change_successful'] = '密碼變更成功';
$lang['password_change_unsuccessful'] = '密碼變更失敗';
$lang['forgot_password_successful'] = '密碼已重設,請收取電子郵件';
$lang['forgot_password_unsuccessful'] = '密碼重設失敗';
// Activation
$lang['activate_successful'] = '帳號已啟動';
$lang['activate_unsuccessful'] = '啟動帳號失敗';
$lang['deactivate_successful'] = '帳號已關閉';
$lang['deactivate_unsuccessful'] = '關閉帳號失敗';
$lang['activation_email_successful'] = '已寄送啟動帳號電子郵件';
$lang['activation_email_unsuccessful'] = '啟動帳號電子郵件失敗';
// Login / Logout
$lang['login_successful'] = '登入成功';
$lang['login_unsuccessful'] = '登入失敗';
$lang['logout_successful'] = '登出成功';
// Account Changes
$lang['update_successful'] = '帳號資料更新成功';
$lang['update_unsuccessful'] = '更新帳號資料失敗';
$lang['delete_successful'] = '帳號已刪除';
$lang['delete_unsuccessful'] = '刪除帳號失敗';
| 101-code | sparks/Ion_auth/language/zh_tw/ion_auth_lang.php | PHP | gpl3 | 1,819 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Lang - Indonesian
*
* Author: Toni Haryanto
* toha.samba@gmail.com
* @yllumi
*
* Location: https://github.com/yllumi/CodeIgniter-Ion-Auth
*
* Created: 11.15.2011
*
* Description: Indonesian language file for Ion Auth messages and errors
*
*/
// Account Creation
$lang['account_creation_successful'] = 'Akun Berhasil Dibuat';
$lang['account_creation_unsuccessful'] = 'Tidak Dapat Membuat Akun';
$lang['account_creation_duplicate_email'] = 'Email Sudah Digunakan atau Tidak Valid';
$lang['account_creation_duplicate_username'] = 'Username Sudah Digunakan atau Tidak Valid';
// Password
$lang['password_change_successful'] = 'Kata Sandi Berhasil Diubah';
$lang['password_change_unsuccessful'] = 'Tidak Dapat Mengganti Kata Sandi';
$lang['forgot_password_successful'] = 'Email untuk Set Ulang Kata Sandi Telah Dikirim';
$lang['forgot_password_unsuccessful'] = 'Tidak Dapat Set Ulang Kata Sandi';
// Activation
$lang['activate_successful'] = 'Akun Telah Diaktifkan';
$lang['activate_unsuccessful'] = 'Tidak Dapat Mengaktifkan Akun';
$lang['deactivate_successful'] = 'Akun Telah Dinonaktifkan';
$lang['deactivate_unsuccessful'] = 'Tidak Dapat Menonaktifkan Akun';
$lang['activation_email_successful'] = 'Email untuk Aktivasi Telah Dikirim';
$lang['activation_email_unsuccessful'] = 'Tidak Dapat Mengirimkan Email Aktivasi';
// Login / Logout
$lang['login_successful'] = 'Log In Berhasil';
$lang['login_unsuccessful'] = 'Log In Gagal';
$lang['logout_successful'] = 'Log Out Berhasil';
// Account Changes
$lang['update_successful'] = 'Informasi Akun Berhasil Diperbaharui';
$lang['update_unsuccessful'] = 'Tidak Dapat Memperbaharui Informasi Akun';
$lang['delete_successful'] = 'Pengguna Telah Dihapus';
$lang['delete_unsuccessful'] = 'Tidak Dapat Menghapus Pengguna';
| 101-code | sparks/Ion_auth/language/indonesian/ion_auth_lang.php | PHP | gpl3 | 1,993 |
<div class='mainInfo'>
<div class="pageTitle">Login</div>
<div class="pageTitleBorder"></div>
<p>Please login with your email/username and password below.</p>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open("auth/login");?>
<p>
<label for="identity">Email/Username:</label>
<?php echo form_input($identity);?>
</p>
<p>
<label for="password">Password:</label>
<?php echo form_input($password);?>
</p>
<p>
<label for="remember">Remember Me:</label>
<?php echo form_checkbox('remember', '1', FALSE);?>
</p>
<p><?php echo form_submit('submit', 'Login');?></p>
<?php echo form_close();?>
</div>
| 101-code | sparks/Ion_auth/views/auth/login.php | PHP | gpl3 | 758 |
<h1>Change Password</h1>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open("auth/change_password");?>
<p>Old Password:<br />
<?php echo form_input($old_password);?>
</p>
<p>New Password:<br />
<?php echo form_input($new_password);?>
</p>
<p>Confirm New Password:<br />
<?php echo form_input($new_password_confirm);?>
</p>
<?php echo form_input($user_id);?>
<p><?php echo form_submit('submit', 'Change');?></p>
<?php echo form_close();?> | 101-code | sparks/Ion_auth/views/auth/change_password.php | PHP | gpl3 | 555 |
<div class='mainInfo'>
<h1>Edit User</h1>
<p>Please enter the users information below.</p>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open("admin/edit_user/".$this->uri->segment(3));?>
<p>First Name:<br />
<?php echo form_input($firstName);?>
</p>
<p>Last Name:<br />
<?php echo form_input($lastName);?>
</p>
<p>Company Name:<br />
<?php echo form_input($company);?>
</p>
<p>Email:<br />
<?php echo form_input($email);?>
</p>
<p>Phone:<br />
<?php echo form_input($phone1);?>-<?php echo form_input($phone2);?>-<?php echo form_input($phone3);?>
</p>
<p>
<input type=checkbox name="reset_password"> <label for="reset_password">Reset Password</label>
</p>
<?php echo form_input($user_id);?>
<p><?php echo form_submit('submit', 'Submit');?></p>
<?php echo form_close();?>
</div>
| 101-code | sparks/Ion_auth/views/auth/edit_user.php | PHP | gpl3 | 987 |
<div class='mainInfo'>
<h1>Create User</h1>
<p>Please enter the users information below.</p>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open("auth/create_user");?>
<p>First Name:<br />
<?php echo form_input($first_name);?>
</p>
<p>Last Name:<br />
<?php echo form_input($last_name);?>
</p>
<p>Company Name:<br />
<?php echo form_input($company);?>
</p>
<p>Email:<br />
<?php echo form_input($email);?>
</p>
<p>Phone:<br />
<?php echo form_input($phone1);?>-<?php echo form_input($phone2);?>-<?php echo form_input($phone3);?>
</p>
<p>Password:<br />
<?php echo form_input($password);?>
</p>
<p>Confirm Password:<br />
<?php echo form_input($password_confirm);?>
</p>
<p><?php echo form_submit('submit', 'Create User');?></p>
<?php echo form_close();?>
</div>
| 101-code | sparks/Ion_auth/views/auth/create_user.php | PHP | gpl3 | 995 |
<div class='mainInfo'>
<div class="pageTitle">Deactivate User</div>
<div class="pageTitleBorder"></div>
<p>Are you sure you want to deactivate the user '<?php echo $user->username; ?>'</p>
<?php echo form_open("auth/deactivate/".$user->id);?>
<p>
<label for="confirm">Yes:</label>
<input type="radio" name="confirm" value="yes" checked="checked" />
<label for="confirm">No:</label>
<input type="radio" name="confirm" value="no" />
</p>
<?php echo form_hidden($csrf); ?>
<?php echo form_hidden(array('id'=>$user->id)); ?>
<p><?php echo form_submit('submit', 'Submit');?></p>
<?php echo form_close();?>
</div>
| 101-code | sparks/Ion_auth/views/auth/deactivate_user.php | PHP | gpl3 | 695 |
<h1>Forgot Password</h1>
<p>Please enter your email address so we can send you an email to reset your password.</p>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open("auth/forgot_password");?>
<p>Email Address:<br />
<?php echo form_input($email);?>
</p>
<p><?php echo form_submit('submit', 'Submit');?></p>
<?php echo form_close();?> | 101-code | sparks/Ion_auth/views/auth/forgot_password.php | PHP | gpl3 | 397 |
<html>
<body>
<h1>New Password for <?php echo $identity;?></h1>
<p>Your password has been reset to: <?php echo $new_password;?></p>
</body>
</html> | 101-code | sparks/Ion_auth/views/auth/email/new_password.tpl.php | PHP | gpl3 | 151 |
<html>
<body>
<h1>Reset Password for <?php echo $identity;?></h1>
<p>Please click this link to <?php echo anchor('auth/reset_password/'. $forgotten_password_code, 'Reset Your Password');?>.</p>
</body>
</html> | 101-code | sparks/Ion_auth/views/auth/email/forgot_password.tpl.php | PHP | gpl3 | 211 |
<html>
<body>
<h1>Activate account for <?php echo $identity;?></h1>
<p>Please click this link to <?php echo anchor('auth/activate/'. $id .'/'. $activation, 'Activate Your Account');?>.</p>
</body>
</html> | 101-code | sparks/Ion_auth/views/auth/email/activate.tpl.php | PHP | gpl3 | 206 |
<div class='mainInfo'>
<h1>Users</h1>
<p>Below is a list of the users.</p>
<div id="infoMessage"><?php echo $message;?></div>
<table cellpadding=0 cellspacing=10>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Groups</th>
<th>Status</th>
</tr>
<?php foreach ($users as $user):?>
<tr>
<td><?php echo $user->first_name;?></td>
<td><?php echo $user->last_name;?></td>
<td><?php echo $user->email;?></td>
<td>
<?php foreach ($user->groups as $group):?>
<?php echo $group->name;?><br />
<?php endforeach?>
</td>
<td><?php echo ($user->active) ? anchor("auth/deactivate/".$user->id, 'Active') : anchor("auth/activate/". $user->id, 'Inactive');?></td>
</tr>
<?php endforeach;?>
</table>
<p><a href="<?php echo site_url('auth/create_user');?>">Create a new user</a></p>
</div>
| 101-code | sparks/Ion_auth/views/auth/index.php | PHP | gpl3 | 881 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ion Auth</title>
<style type='text/css' media='all'>@import url('./userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />
</head>
<body>
<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner">
<table cellpadding="0" cellspacing="0" border="0" style="width:98%">
<tr>
<td class="td" valign="top">
<h3>Author Info</h3>
<ul>
<li><a href="http://benedmunds.com">Ben Edmunds</a></li>
<li><a href="http://github.com/benedmunds">GitHub</a></li>
</ul>
<h3>Basic Info</h3>
<ul>
<li><a href="#license">License</a></li>
<li><a href="http://github.com/benedmunds/CodeIgniter-Ion-Auth">GitHub Repo</a></li>
</ul>
<h3>Introduction</h3>
<ul>
<li><a href="#install">Installation</a></li>
<li><a href="#loading">Loading the Library</a></li>
</ul>
</td>
<td class="td_sep" valign="top">
<h3>Configuration</h3>
<ul>
<li><a href="#config">General</a></li>
<li><a href="#use_config">Config Options</a></li>
</ul>
<h3>Class Functions</h3>
<ul>
<li><a href="#login">login()</a></li>
<li><a href="#logout">logout()</a></li>
<li><a href="#register">register()</a></li>
<li><a href="#update_user">update_user()</a></li>
<li><a href="#delete_user">delete_user()</a></li>
<li><a href="#forgotten_password">forgotten_password()</a></li>
<li><a href="#forgotten_password_complete">forgotten_password_complete()</a></li>
<li><a href="#logged_in">logged_in()</a></li>
<li><a href="#is_admin">is_admin()</a></li>
<li><a href="#is_group">is_group()</a></li>
<li><a href="#username_check">username_check()</a></li>
<li><a href="#email_check">email_check()</a></li>
<li><a href="#identity_check">identity_check()</a></li>
<li><a href="#user">user()</a></li>
<li><a href="#users">users()</a></li>
<li><a href="#group">group()</a></li>
<li><a href="#groups">groups()</a></li>
<li><a href="#messages">messages()</a></li>
<li><a href="#set_message_delimiters">set_message_delimiters()</a></li>
<li><a href="#errors">errors()</a></li>
<li><a href="#set_error_delimiters">set_error_delimiters()</a></li>
</ul>
</td>
</tr>
</table>
</div></div>
<div id="nav2"><a name="top"> </a><a href="#" id="toggle_toc"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>Documentation</h1></td>
<td id="breadcrumb_right">Author:<a href="http://benedmunds.com">Ben Edmunds</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->
<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://benedmunds.com/ion_auth">Ion Auth</a> ›
Documentation
</td>
</tr>
</table>
<!-- END BREADCRUMB -->
<br clear="all" />
<!-- START CONTENT -->
<div id="content">
<h1>Ion Auth</h1>
<p>Ion Auth is a simple and lightweight authentication library for the CodeIgniter framework</p>
<a name="license"></a>
<h2>License</h2>
<p>Ion Auth is released under the Apache License v2.0. You can read the license here: <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a></p>
<a name="install"></a>
<h2>Installation</h2>
<ol>
<li>Download the latest version: <a href="http://github.com/benedmunds/CodeIgniter-Ion-Auth/zipball/master">http://github.com/benedmunds/CodeIgniter-Ion-Auth/zipball/master</a></li>
<li>Copy the files from this package to the correspoding folder in your application folder. For example, copy Ion_auth/config/ion_auth.php to system/application/config/ion_auth.php.</li>
</ol>
<p>The default login is:</p>
<ul>
<li>Email: admin@admin.com</li>
<li>Password: password</li>
</ul>
<a name="loading"></a>
<h2>Loading Ion Auth</h2>
<p>You load Ion Auth just link any other library:</p>
<pre>$this->load->library('ion_auth');</pre>
<p>You can also autoload the library.</p>
<a name="config"></a>
<h2>Configuration Options</h2>
<p>Ion Auth is extremely configurable. The following configuration options are available:</p>
<ul>
<li>$config['tables']['groups']</li>
<li>$config['tables']['users']</li>
<li>$config['tables']['meta']</li>
<li>$config['site_title']</li>
<li>$config['admin_email']</li>
<li>$config['default_group']</li>
<li>$config['admin_group']</li>
<li>$config['join']</li>
<li>$config['columns']</li>
<li>$config['identity']</li>
<li>$config['min_password_length']</li>
<li>$config['max_password_length']</li>
<li>$config['email_activation']</li>
<li>$config['remember_users']</li>
<li>$config['user_expire']</li>
<li>$config['user_extend_on_login']</li>
<li>$config['email_templates']</li>
<li>$config['email_activate']</li>
<li>$config['email_forgot_password']</li>
<li>$config['email_forgot_password_complete'] </li>
<li>$config['salt_length']</li>
<li>$config['store_salt'] </li>
<li>$config['message_start_delimiter']</li>
<li>$config['message_end_delimiter']</li>
<li>$config['error_start_delimiter']</li>
<li>$config['error_end_delimiter']</li>
</ul>
<a name="use_config"></a>
<h2>Using Config File</h2>
<p>To change configuration options simply edit the config/ion_auth.php file.</p>
<h3>Config</h3>
<p>Edit the ion_auth $config array as needed:</p>
<ul>
<li>'tables['groups']' - The table name to use for the groups table. DEFAULT is 'groups'.</li>
<li>'tables['users']' - The table name to use for the users table. DEFAULT is 'users'.</li>
<li>'tables['meta']' - The table name to use for the meta table. DEFAULT is 'meta'.</li>
<li>'site_title' - The title of your site, used for email.</li>
<li>'admin_email' - Your administrator email address. DEFAULT is 'admin@example.com'.</li>
<li>'default_group' - Name of the default user group. DEFAULT is 'members'.</li>
<li>'admin_group' - Name of the admin group. DEFAULT is 'admin'.</li>
<li>'join' - Column to use for joining users and meta table. DEFAULT is 'user_id'.</li>
<li>'columns' - The columns in the meta table. DEFAULT is 'array('first_name', 'last_name', 'company', 'phone')'.</li>
<li>'identity' - Column to use for uniquely identifing user/logging in/etc. Usual choices are 'email' OR 'username'. You should add an index in the users table for whatever you set this option to. DEFAULT is 'email'.</li>
<li>'min_password_length' - Minimum length of passwords. DEFAULT is '8'.</li>
<li>'max_password_length' - Maximum length of passwords. DEFAULT is '20'.</li>
<li>'email_activation' - TRUE or FALSE. Sets whether to require email activation or not. DEFAULT is 'false'.</li>
<li>'remember_users' - TRUE or FALSE. Sets whether to enable 'remember me' functionality or not. DEFAULT is 'true'.</li>
<li>'user_expire' - Sets how long to remember the user for in seconds. DEFAULT is '86500'.</li>
<li>'user_extend_on_login' - TRUE or FALSE. Extend the users session expiration on login. DEFAULT is 'false'.</li>
<li>'email_templates' - Folder where the email view templates are stored. DEFAULT is 'auth/email/'.</li>
<li>'email_activate' - Filname of the email activation view template. DEFAULT is 'activate.tpl.php'.</li>
<li>'email_forgot_password' - Filname of the forgot password email view template. DEFAULT is 'forgot_password.tpl.php'.</li>
<li>'email_forgot_password_complete' - Filname of the forgot password complete email view template. DEFAULT is 'new_password.tpl.php'.</li>
<li>'salt_length' - Length of the encryption salt. DEFAULT is '10'.</li>
<li>'store_salt' - TRUE or FALSE. Store the salt in a separate database column or not. This can be useful for integrating with existing apps. DEFAULT is 'false'.</li>
<li>'message_start_delimiter' - Starting delimiter for messages. DEFAULT is '<p>'.</li>
<li>'message_end_delimiter' - Ending delimiter for messages. DEFAULT is '</p>'.</li>
<li>'error_start_delimiter' - Starting delimiter for errors. DEFAULT is '<p>'.</li>
<li>'error_end_delimiter' - Ending delimiter for errors. DEFAULT is '</p>'.</li>
</ul>
<br />
<h1>Class Function Reference</h1>
<p class="important"><strong>NOTE:</strong> Methods available in the model are called through the controller using PHP5 magic. You should never use ion_auth_model->method() in your applications.</p>
<a name="login"></a>
<h2>login()</h2>
<p>Logs the user into the system.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Username' - string REQUIRED. Usually username or email but depends on your config.</li>
<li>'Password' - string REQUIRED.</li>
<li>'Remember' - boolean OPTIONAL. TRUE sets the user to be remembered if enabled in the config</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user was successfully logged in FALSE if the user was not logged in.</li>
</ul>
<p><b>Usage</b></p>
<pre>
$identity = 'ben.edmunds@gmail.com';
$password = '12345678';
$remember = TRUE; // remember the user
$this->ion_auth->login($identity, $password, $remember);
</pre>
<br />
<a name="logout"></a>
<h2>logout()</h2>
<p>Logs the user out of the system.</p>
<p><b>Usage</b></p>
<pre>
$this->ion_auth->logout();
</pre>
<br />
<a name="register"></a>
<h2>register()</h2>
<p>Register (create) a new user.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Username' - string REQUIRED.</li>
<li>'Password' - string REQUIRED.</li>
<li>'Email' - string REQUIRED.</li>
<li>'Additional Data' - multidimensional array REQUIRED.</li>
<li>'Group' - array OPTIONAL. If not passed the default group name set in the config will be used.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user was successfully created FALSE if the user was not created.</li>
</ul>
<p><b>Usage</b></p>
<pre>
$username = 'ben.edmunds@gmail.com';
$password = '12345678';
$email = 'benedmunds';
$additional_data = array(
'first_name' => 'Ben',
'last_name' => 'Edmunds',
);
$group = array('1'); // Sets user to admin. No need for array('1', '2') as user is always set to member by default
$this->ion_auth->register($username, $password, $email, $additional_data, $group)
</pre>
<br />
<a name="update_user"></a>
<h2>update_user()</h2>
<p>Update a user.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Id' - integer REQUIRED.</li>
<li>'Data' - multidimensional array REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user was successfully updated FALSE if the user was not updated.</li>
</ul>
<p><b>Usage</b></p>
<pre>
$id = 12;
$data = array(
'first_name' => 'Ben',
'last_name' => 'Edmunds',
'password' => '123456789',
);
$this->ion_auth->update_user($id, $data)
</pre>
<br />
<a name="delete_user"></a>
<h2>delete_user()</h2>
<p>Delete a user.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Id' - integer REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user was successfully deleted FALSE if the user was not deleted.</li>
</ul>
<p><b>Usage</b></p>
<pre>
$id = 12;
$this->ion_auth->delete_user($id)
</pre>
<br />
<a name="forgotten_password"></a>
<h2>forgotten_password()</h2>
<p>Resets a users password by emailing the user a reset code.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Identity' - string REQUIRED. (as defined in config/ion_auth.php)</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the users password was successfully reset FALSE if the users password was not reset.</li>
</ul>
<p><b>Usage</b></p>
<p> - this example assumes you have 'email' selected as the identity in config/ion_auth.php
<pre>
//Working code for this example is in the example Auth controller in the github repo
function forgot_password()
{
$this->form_validation->set_rules('email', 'Email Address', 'required');
if ($this->form_validation->run() == false) {
//setup the input
$this->data['email'] = array('name' => 'email',
'id' => 'email',
);
//set any errors and display the form
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->load->view('auth/forgot_password', $this->data);
}
else {
//run the forgotten password method to email an activation code to the user
$forgotten = $this->ion_auth->forgotten_password($this->input->post('email'));
if ($forgotten) { //if there were no errors
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth/login", 'refresh'); //we should display a confirmation page here instead of the login page
}
else {
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("auth/forgot_password", 'refresh');
}
}
}
</pre>
<br />
<a name="forgotten_password_complete"></a>
<h2>forgotten_password_complete()</h2>
<p>Final step of resetting a users password. The user comes to this page from their email.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Code' - string REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>string. The users new password.</li>
</ul>
<p><b>Usage</b></p>
<pre>
//Working code for this example is in the example Auth controller in the github repo
public function reset_password($code)
{
$reset = $this->ion_auth->forgotten_password_complete($code);
if ($reset) { //if the reset worked then send them to the login page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth/login", 'refresh');
}
else { //if the reset didnt work then send them back to the forgot password page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("auth/forgot_password", 'refresh');
}
}
</pre>
<br />
<a name="logged_in"></a>
<h2>logged_in()</h2>
<p>Check to see if a user is logged in.</p>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user is logged in FALSE if the user is not logged in.</li>
</ul>
<p><b>Usage</b></p>
<pre>
if (!$this->ion_auth->logged_in())
{
redirect('auth/login');
}
</pre>
<br />
<a name="is_admin"></a>
<h2>is_admin()</h2>
<p>Check to see if the currently logged in user is an admin.</p>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user is an admin FALSE if the user is not an admin.</li>
</ul>
<p><b>Usage</b></p>
<pre>
if (!$this->ion_auth->is_admin())
{
$this->session->set_flashdata('message', 'You must be an admin to view this page');
redirect('welcome/index');
}
</pre>
<br />
<a name="is_group"></a>
<h2>is_group()</h2>
<p>Check to see if the currently logged in user is in the passed in group.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Group Name' - string or array of stringsREQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user is in the group FALSE if the user is not in the group.</li>
</ul>
<p><b>Usage</b></p>
<pre>
$group = 'gangstas';
if (!$this->ion_auth->is_group($group))
{
$this->session->set_flashdata('message', 'You must be a gangsta to view this page');
redirect('welcome/index');
}
</pre>
<br />
<a name="username_check"></a>
<h2>username_check()</h2>
<p>Check to see if the username is already registered.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Username' - string REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user is registered FALSE if the user is not registered.</li>
</ul>
<p><b>Usage</b></p>
<pre>
//This is a lame example but it works. Usually you would use this method with form_validation.
$username = $this->input->post('username');
$password = $this->input->post('password');
$email = $this->input->post('email');
$additional_data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
);
if (!$this->ion_auth->username_check($username))
{
$group_name = 'users';
$this->ion_auth->register($username, $password, $email, $additional_data, $group_name)
}
</pre>
<br />
<a name="email_check"></a>
<h2>email_check()</h2>
<p>Check to see if the email is already registered.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Email' - string REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user is registered FALSE if the user is not registered.</li>
</ul>
<p><b>Usage</b></p>
<pre>
//This is a lame example but it works. Usually you would use this method with form_validation.
$username = $this->input->post('username');
$password = $this->input->post('password');
$email = $this->input->post('email');
$additional_data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
);
if (!$this->ion_auth->email_check($email))
{
$group_name = 'users';
$this->ion_auth->register($username, $password, $email, $additional_data, $group_name)
}
</pre>
<br />
<a name="identity_check"></a>
<h2>identity_check()</h2>
<p>Check to see if the identity is already registered.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Identity' - string REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>boolean. TRUE if the user is registered FALSE if the user is not registered.</li>
</ul>
<p><b>Usage</b></p>
<pre>
//This is a lame example but it works.
$user = $this->ion_auth->user();
$data = array(
'identity' => $this->input->post('identity'),
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
);
if ($data['identity'] === $user->username || $data['identity'] === $user->email || $this->ion_auth->identity_check($data['identity']) === FALSE)
{
$this->ion_auth->update_user($user->id, $data)
}
</pre>
<br />
<a name="user"></a>
<h2>user()</h2>
<p>Get a user.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Id' - integer OPTIONAL. If a user id is not passed the id of the currently logged in user will be used.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>
<pre>
stdClass Object (
[id] => 1
[group_id] => 1
[ip_address] => 127.0.0.1
[username] => administrator
[password] => 59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4
[salt] => 9462e8eee0
[email] => admin@admin.com
[activation_code] => 19e181f2ccc2a7ea58a2c0aa2b69f4355e636ef4
[forgotten_password_code] => 81dce1d0bc2c10fbdec7a87f1ff299ed7e4c9e4a
[remember_code] => 9d029802e28cd9c768e8e62277c0df49ec65c48c
[created_on] => 1268889823
[last_login] => 1279464628
[active] => 0
[group] => admin
[group_description] => Administrator
[first_name] => Admin
[last_name] => Account
[company] => Some Corporation
[phone] => (123)456-7890
)
</pre>
</li>
</ul>
<p><b>Usage</b></p>
<pre>
$user = $this->ion_auth->user();
echo $user->email;
</pre>
<br />
<a name="users"></a>
<h2>users()</h2>
<p>Get the users.</p>
<p><strong>Return</strong></p>
<ul>
<li>array of objects</li>
</ul>
<p><b>Usage</b></p>
<pre>
$admin_users = $this->ion_auth->users();
</pre>
<br />
<a name="group"></a>
<h2>group()</h2>
<p>Get a group.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Id' - integer REQUIRED.</li>
</ol>
<p><strong>Return</strong></p>
<ul>
<li>object</li>
</ul>
<p><b>Usage</b></p>
<pre>
$group_id = 2;
$group = $this->ion_auth->group($group_id);
</pre>
<br />
<a name="groups"></a>
<h2>groups()</h2>
<p>Get the groups.</p>
<p><strong>Return</strong></p>
<ul>
<li>array of objects</li>
</ul>
<p><b>Usage</b></p>
<pre>
$groups = $this->ion_auth->groups();
</pre>
<br />
<a name="messages"></a>
<h2>messages()</h2>
<p>Get messages.</p>
<p><strong>Return</strong></p>
<ul>
<li>string</li>
</ul>
<p><b>Usage</b></p>
<pre>
$id = 12;
$data = array(
'first_name' => 'Ben',
'last_name' => 'Edmunds',
);
if ($this->ion_auth->update_user($id, $data))
{
$messages = $this->ion_auth->messages();
echo $messages;
}
else
{
$errors = $this->ion_auth->errors();
echo $errors;
}
</pre>
<br />
<a name="set_message_delimiters"></a>
<h2>set_message_delimiters()</h2>
<p>Set the message delimiters.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Start Delimiter' - string REQUIRED.</li>
<li>'End Delimiter' - string REQUIRED.</li>
</ol>
<p><b>Usage</b></p>
<pre>
$id = 12;
$data = array(
'first_name' => 'Ben',
'last_name' => 'Edmunds',
);
if ($this->ion_auth->update_user($id, $data))
{
$this->ion_auth->set_message_delimiters('<p><strong>','</strong></p>');
$messages = $this->ion_auth->messages();
echo $messages;
}
else
{
$this->ion_auth->set_error_delimiters('<p><strong>','</strong></p>');
$errors = $this->ion_auth->errors();
echo $errors;
}
</pre>
<br />
<a name="errors"></a>
<h2>errors()</h2>
<p>Get the errors.</p>
<p><strong>Return</strong></p>
<ul>
<li>string</li>
</ul>
<p><b>Usage</b></p>
<pre>
$id = 12;
$data = array(
'first_name' => 'Ben',
'last_name' => 'Edmunds',
);
if ($this->ion_auth->update_user($id, $data))
{
$messages = $this->ion_auth->messages();
echo $messages;
}
else
{
$errors = $this->ion_auth->errors();
echo $errors;
}
</pre>
<br />
<a name="set_error_delimiters"></a>
<h2>set_error_delimiters()</h2>
<p>Set the error delimiters.</p>
<p><strong>Parameters</strong></p>
<ol>
<li>'Start Delimiter' - string REQUIRED.</li>
<li>'End Delimiter' - string REQUIRED.</li>
</ol>
<p><b>Usage</b></p>
<pre>
$id = 12;
$data = array(
'first_name' => 'Ben',
'last_name' => 'Edmunds',
);
if ($this->ion_auth->update_user($id, $data))
{
$this->ion_auth->set_message_delimiters('<p><strong>','</strong></p>');
$messages = $this->ion_auth->messages();
echo $messages;
}
else
{
$this->ion_auth->set_error_delimiters('<p><strong>','</strong></p>');
$errors = $this->ion_auth->errors();
echo $errors;
}
</pre>
<br />
</div>
<!-- END CONTENT -->
<div id="footer">
<p><a href="#top">Top of Page</a></p>
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2010 Ben Edmunds · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
</div>
</body>
</html> | 101-code | sparks/Ion_auth/userguide/index.html | HTML | gpl3 | 23,491 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
*
* Added Awesomeness: Phil Sturgeon
*
* Location: http://github.com/benedmunds/CodeIgniter-Ion-Auth
*
* Created: 10.01.2009
*
* Description: Modified auth system based on redux_auth with extensive customization. This is basically what Redux Auth 2 should be.
* Original Author name has been kept but that does not mean that the method has not been modified.
*
* Requirements: PHP5 or above
*
*/
class Ion_auth
{
/**
* CodeIgniter global
*
* @var string
**/
protected $ci;
/**
* account status ('not_activated', etc ...)
*
* @var string
**/
protected $status;
/**
* extra where
*
* @var array
**/
public $_extra_where = array();
/**
* extra set
*
* @var array
**/
public $_extra_set = array();
/**
* __construct
*
* @return void
* @author Ben
**/
public function __construct()
{
$this->ci =& get_instance();
$this->ci->load->config('ion_auth', TRUE);
$this->ci->load->library('email');
$this->ci->load->library('session');
$this->ci->lang->load('ion_auth');
$this->ci->load->model('ion_auth_model');
$this->ci->load->helper('cookie');
//auto-login the user if they are remembered
if (!$this->logged_in() && get_cookie('identity') && get_cookie('remember_code'))
{
$this->ci->ion_auth = $this;
$this->ci->ion_auth_model->login_remembered_user();
}
$this->ci->ion_auth_model->trigger_events('library_constructor');
}
/**
* __call
*
* Acts as a simple way to call model methods without loads of stupid alias'
*
**/
public function __call($method, $arguments)
{
if (!method_exists( $this->ci->ion_auth_model, $method) )
{
throw new Exception('Undefined method Ion_auth::' . $method . '() called');
}
return call_user_func_array( array($this->ci->ion_auth_model, $method), $arguments);
}
/**
* forgotten password feature
*
* @return void
* @author Mathew
**/
public function forgotten_password($identity) //changed $email to $identity
{
if ( $this->ci->ion_auth_model->forgotten_password($identity) ) //changed
{
// Get user information
$user = $this->where($this->ci->config->item('identity', 'ion_auth'), $identity)->users()->row(); //changed to get_user_by_identity from email
if ($user)
{
$data = array(
'identity' => $user->{$this->ci->config->item('identity', 'ion_auth')},
'forgotten_password_code' => $user->forgotten_password_code
);
$message = $this->ci->load->view($this->ci->config->item('email_templates', 'ion_auth').$this->ci->config->item('email_forgot_password', 'ion_auth'), $data, true);
$this->ci->email->clear();
$this->ci->email->set_newline("\r\n");
$this->ci->email->from($this->ci->config->item('admin_email', 'ion_auth'), $this->ci->config->item('site_title', 'ion_auth'));
$this->ci->email->to($user->email);
$this->ci->email->subject($this->ci->config->item('site_title', 'ion_auth') . ' - Forgotten Password Verification');
$this->ci->email->message($message);
if ($this->ci->email->send())
{
$this->set_message('forgot_password_successful');
return TRUE;
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
/**
* forgotten_password_complete
*
* @return void
* @author Mathew
**/
public function forgotten_password_complete($code)
{
$this->ci->ion_auth_model->trigger_events('pre_password_change');
$identity = $this->ci->config->item('identity', 'ion_auth');
$profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile
if (!is_object($profile))
{
$this->ci->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful'));
$this->set_error('password_change_unsuccessful');
return FALSE;
}
$new_password = $this->ci->ion_auth_model->forgotten_password_complete($code, $profile->salt);
if ($new_password)
{
$data = array(
'identity' => $profile->{$identity},
'new_password' => $new_password
);
$message = $this->ci->load->view($this->ci->config->item('email_templates', 'ion_auth').$this->ci->config->item('email_forgot_password_complete', 'ion_auth'), $data, true);
$this->ci->email->clear();
$this->ci->email->set_newline("\r\n");
$this->ci->email->from($this->ci->config->item('admin_email', 'ion_auth'), $this->ci->config->item('site_title', 'ion_auth'));
$this->ci->email->to($profile->email);
$this->ci->email->subject($this->ci->config->item('site_title', 'ion_auth') . ' - New Password');
$this->ci->email->message($message);
if ($this->ci->email->send())
{
$this->set_message('password_change_successful');
$this->ci->ion_auth_model->trigger_events(array('post_password_change', 'password_change_successful'));
return TRUE;
}
else
{
$this->set_error('password_change_unsuccessful');
$this->ci->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful'));
return FALSE;
}
}
$this->ci->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful'));
return FALSE;
}
/**
* register
*
* @return void
* @author Mathew
**/
public function register($username, $password, $email, $additional_data = array(), $group_name = array()) //need to test email activation
{
$this->ci->ion_auth_model->trigger_events('pre_account_creation');
$email_activation = $this->ci->config->item('email_activation', 'ion_auth');
if (!$email_activation)
{
$id = $this->ci->ion_auth_model->register($username, $password, $email, $additional_data, $group_name);
if ($id !== FALSE)
{
$this->set_message('account_creation_successful');
$this->ci->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful'));
return $id;
}
else
{
$this->set_error('account_creation_unsuccessful');
$this->ci->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful'));
return FALSE;
}
}
else
{
$id = $this->ci->ion_auth_model->register($username, $password, $email, $additional_data, $group_name);
if (!$id)
{
$this->set_error('account_creation_unsuccessful');
return FALSE;
}
$deactivate = $this->ci->ion_auth_model->deactivate($id);
if (!$deactivate)
{
$this->set_error('deactivate_unsuccessful');
$this->ci->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful'));
return FALSE;
}
$activation_code = $this->ci->ion_auth_model->activation_code;
$identity = $this->ci->config->item('identity', 'ion_auth');
$user = $this->ci->ion_auth_model->user($id)->row();
$data = array(
'identity' => $user->{$identity},
'id' => $user->id,
'email' => $email,
'activation' => $activation_code,
);
$message = $this->ci->load->view($this->ci->config->item('email_templates', 'ion_auth').$this->ci->config->item('email_activate', 'ion_auth'), $data, true);
$this->ci->email->clear();
$this->ci->email->set_newline("\r\n");
$this->ci->email->from($this->ci->config->item('admin_email', 'ion_auth'), $this->ci->config->item('site_title', 'ion_auth'));
$this->ci->email->to($email);
$this->ci->email->subject($this->ci->config->item('site_title', 'ion_auth') . ' - Account Activation');
$this->ci->email->message($message);
if ($this->ci->email->send() == TRUE)
{
$this->ci->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful', 'activation_email_successful'));
$this->set_message('activation_email_successful');
return $id;
}
$this->ci->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful', 'activation_email_unsuccessful'));
$this->set_error('activation_email_unsuccessful');
return FALSE;
}
}
/**
* logout
*
* @return void
* @author Mathew
**/
public function logout()
{
$this->ci->ion_auth_model->trigger_events('logout');
$identity = $this->ci->config->item('identity', 'ion_auth');
$this->ci->session->unset_userdata($identity);
$this->ci->session->unset_userdata('id');
$this->ci->session->unset_userdata('user_id');
//delete the remember me cookies if they exist
if (get_cookie('identity'))
{
delete_cookie('identity');
}
if (get_cookie('remember_code'))
{
delete_cookie('remember_code');
}
$this->ci->session->sess_destroy();
$this->set_message('logout_successful');
return TRUE;
}
/**
* logged_in
*
* @return bool
* @author Mathew
**/
public function logged_in()
{
$this->ci->ion_auth_model->trigger_events('logged_in');
$identity = $this->ci->config->item('identity', 'ion_auth');
return (bool) $this->ci->session->userdata($identity);
}
/**
* is_admin
*
* @return bool
* @author Ben Edmunds
**/
public function is_admin()
{
$this->ci->ion_auth_model->trigger_events('is_admin');
$admin_group = $this->ci->config->item('admin_group', 'ion_auth');
return $this->in_group($admin_group);
}
/**
* in_group
*
* @return bool
* @author Phil Sturgeon
**/
public function in_group($check_group, $id=false)
{
$this->ci->ion_auth_model->trigger_events('in_group');
$users_groups = $this->ci->ion_auth_model->get_users_groups($id)->result();
$groups = array();
foreach ($users_groups as $group)
{
$groups[] = $group->name;
}
if (is_array($check_group))
{
foreach($check_group as $key => $value)
{
if (in_array($value, $groups))
{
return TRUE;
}
}
}
else
{
if (in_array($check_group, $groups))
{
return TRUE;
}
}
return FALSE;
}
} | 101-code | sparks/Ion_auth/libraries/Ion_auth.php | PHP | gpl3 | 10,150 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Model
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
*
* Added Awesomeness: Phil Sturgeon
*
* Location: http://github.com/benedmunds/CodeIgniter-Ion-Auth
*
* Created: 10.01.2009
*
* Description: Modified auth system based on redux_auth with extensive customization. This is basically what Redux Auth 2 should be.
* Original Author name has been kept but that does not mean that the method has not been modified.
*
* Requirements: PHP5 or above
*
*/
class Ion_auth_model extends CI_Model
{
/**
* Holds an array of tables used
*
* @var string
**/
public $tables = array();
/**
* activation code
*
* @var string
**/
public $activation_code;
/**
* forgotten password key
*
* @var string
**/
public $forgotten_password_code;
/**
* new password
*
* @var string
**/
public $new_password;
/**
* Identity
*
* @var string
**/
public $identity;
/**
* Where
*
* @var array
**/
public $_ion_where = array();
/**
* Limit
*
* @var string
**/
public $_ion_limit = NULL;
/**
* Offset
*
* @var string
**/
public $_ion_offset = NULL;
/**
* Order By
*
* @var string
**/
public $_ion_order_by = NULL;
/**
* Order
*
* @var string
**/
public $_ion_order = NULL;
/**
* Hooks
*
* @var object
**/
protected $_ion_hooks;
/**
* Response
*
* @var string
**/
protected $response = NULL;
/**
* message (uses lang file)
*
* @var string
**/
protected $messages;
/**
* error message (uses lang file)
*
* @var string
**/
protected $errors;
/**
* error start delimiter
*
* @var string
**/
protected $error_start_delimiter;
/**
* error end delimiter
*
* @var string
**/
protected $error_end_delimiter;
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->config('ion_auth', TRUE);
$this->load->helper('cookie');
$this->load->helper('date');
$this->load->library('session');
$this->lang->load('ion_auth');
//initialize db tables data
$this->tables = $this->config->item('tables', 'ion_auth');
//initialize data
$this->identity_column = $this->config->item('identity', 'ion_auth');
$this->store_salt = $this->config->item('store_salt', 'ion_auth');
$this->salt_length = $this->config->item('salt_length', 'ion_auth');
$this->join = $this->config->item('join', 'ion_auth');
//initialize messages and error
$this->messages = array();
$this->errors = array();
$this->message_start_delimiter = $this->config->item('message_start_delimiter', 'ion_auth');
$this->message_end_delimiter = $this->config->item('message_end_delimiter', 'ion_auth');
$this->error_start_delimiter = $this->config->item('error_start_delimiter', 'ion_auth');
$this->error_end_delimiter = $this->config->item('error_end_delimiter', 'ion_auth');
//initialize our hooks object
$this->_ion_hooks = new stdClass;
$this->trigger_events('model_constructor');
}
/**
* Misc functions
*
* Hash password : Hashes the password to be stored in the database.
* Hash password db : This function takes a password and validates it
* against an entry in the users table.
* Salt : Generates a random salt value.
*
* @author Mathew
*/
/**
* Hashes the password to be stored in the database.
*
* @return void
* @author Mathew
**/
public function hash_password($password, $salt=false)
{
if (empty($password))
{
return FALSE;
}
if ($this->store_salt && $salt)
{
return sha1($password . $salt);
}
else
{
$salt = $this->salt();
return $salt . substr(sha1($salt . $password), 0, -$this->salt_length);
}
}
/**
* This function takes a password and validates it
* against an entry in the users table.
*
* @return void
* @author Mathew
**/
public function hash_password_db($id, $password)
{
if (empty($id) || empty($password))
{
return FALSE;
}
$this->trigger_events('extra_where');
$query = $this->db->select('password')
->select('salt')
->where('id', $id)
->limit(1)
->get($this->tables['users']);
$hash_password_db = $query->row();
if ($query->num_rows() !== 1)
{
return FALSE;
}
if ($this->store_salt)
{
return sha1($password . $hash_password_db->salt);
}
else
{
$salt = substr($hash_password_db->password, 0, $this->salt_length);
return $salt . substr(sha1($salt . $password), 0, -$this->salt_length);
}
}
/**
* Generates a random salt value.
*
* @return void
* @author Mathew
**/
public function salt()
{
return substr(md5(uniqid(rand(), true)), 0, $this->salt_length);
}
/**
* Activation functions
*
* Activate : Validates and removes activation code.
* Deactivae : Updates a users row with an activation code.
*
* @author Mathew
*/
/**
* activate
*
* @return void
* @author Mathew
**/
public function activate($id, $code = false)
{
$this->trigger_events('pre_activate');
if ($code !== FALSE)
{
$query = $this->db->select($this->identity_column)
->where('activation_code', $code)
->limit(1)
->get($this->tables['users']);
$result = $query->row();
if ($query->num_rows() !== 1)
{
$this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
$this->set_error('activate_unsuccessful');
return FALSE;
}
$identity = $result->{$this->identity_column};
$data = array(
'activation_code' => NULL,
'active' => 1
);
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array($this->identity_column => $identity));
}
else
{
$data = array(
'activation_code' => NULL,
'active' => 1
);
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array('id' => $id));
}
$return = $this->db->affected_rows() == 1;
if ($return)
{
$this->trigger_events(array('post_activate', 'post_activate_successful'));
$this->set_message('activate_successful');
}
else
{
$this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
$this->set_error('activate_unsuccessful');
}
return $return;
}
/**
* Deactivate
*
* @return void
* @author Mathew
**/
public function deactivate($id = NULL)
{
$this->trigger_events('deactivate');
if (!isset($id))
{
$this->set_error('deactivate_unsuccessful');
return FALSE;
}
$activation_code = sha1(md5(microtime()));
$this->activation_code = $activation_code;
$data = array(
'activation_code' => $activation_code,
'active' => 0
);
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array('id' => $id));
$return = $this->db->affected_rows() == 1;
if ($return)
$this->set_message('deactivate_successful');
else
$this->set_error('deactivate_unsuccessful');
return $return;
}
/**
* change password
*
* @return bool
* @author Mathew
**/
public function change_password($identity, $old, $new)
{
$this->trigger_events('pre_change_password');
$this->trigger_events('extra_where');
$query = $this->db->select('id, password, salt')
->where($this->identity_column, $identity)
->limit(1)
->get($this->tables['users']);
$result = $query->row();
$db_password = $result->password;
$old = $this->hash_password_db($result->id, $old);
$new = $this->hash_password($new, $result->salt);
if ($db_password === $old)
{
//store the new password and reset the remember code so all remembered instances have to re-login
$data = array(
'password' => $new,
'remember_code' => NULL,
);
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array($this->identity_column => $identity));
$return = $this->db->affected_rows() == 1;
if ($return)
{
$this->trigger_events(array('post_change_password', 'post_change_password_successful'));
$this->set_message('password_change_successful');
}
else
{
$this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful'));
$this->set_error('password_change_unsuccessful');
}
return $return;
}
$this->set_error('password_change_unsuccessful');
return FALSE;
}
/**
* Checks username
*
* @return bool
* @author Mathew
**/
public function username_check($username = '')
{
$this->trigger_events('username_check');
if (empty($username))
{
return FALSE;
}
$this->trigger_events('extra_where');
return $this->db->where('username', $username)
->count_all_results($this->tables['users']) > 0;
}
/**
* Checks email
*
* @return bool
* @author Mathew
**/
public function email_check($email = '')
{
$this->trigger_events('email_check');
if (empty($email))
{
return FALSE;
}
$this->trigger_events('extra_where');
return $this->db->where('email', $email)
->count_all_results($this->tables['users']) > 0;
}
/**
* Identity check
*
* @return bool
* @author Mathew
**/
protected function identity_check($identity = '')
{
$this->trigger_events('identity_check');
if (empty($identity))
{
return FALSE;
}
return $this->db->where($this->identity_column, $identity)
->count_all_results($this->tables['users']) > 0;
}
/**
* Insert a forgotten password key.
*
* @return bool
* @author Mathew
* @updated Ryan
**/
public function forgotten_password($identity)
{
if (empty($identity))
{
$this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful'));
return FALSE;
}
$key = $this->hash_password(microtime().$identity);
$this->forgotten_password_code = $key;
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], array('forgotten_password_code' => $key), array($this->identity_column => $identity));
$return = $this->db->affected_rows() == 1;
if ($return)
$this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_successful'));
else
$this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful'));
return $return;
}
/**
* Forgotten Password Complete
*
* @return string
* @author Mathew
**/
public function forgotten_password_complete($code, $salt=FALSE)
{
$this->trigger_events('pre_forgotten_password_complete');
if (empty($code))
{
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
$this->db->where('forgotten_password_code', $code);
if ($this->db->count_all_results($this->tables['users']) > 0)
{
$password = $this->salt();
$data = array(
'password' => $this->hash_password($password, $salt),
'forgotten_password_code' => NULL,
'active' => 1,
);
$this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code));
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_successful'));
return $password;
}
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
/**
* register
*
* @return bool
* @author Mathew
**/
public function register($username, $password, $email, $additional_data = array(), $groups = array())
{
$this->trigger_events('pre_register');
if ($this->identity_column == 'email' && $this->email_check($email))
{
$this->set_error('account_creation_duplicate_email');
return FALSE;
}
elseif ($this->identity_column == 'username' && $this->username_check($username))
{
$this->set_error('account_creation_duplicate_username');
return FALSE;
}
// If username is taken, use username1 or username2, etc.
if ($this->identity_column != 'username')
{
$original_username = $username;
for($i = 0; $this->username_check($username); $i++)
{
if($i > 0)
{
$username = $original_username . $i;
}
}
}
// IP Address
$ip_address = $this->input->ip_address();
$salt = $this->store_salt ? $this->salt() : FALSE;
$password = $this->hash_password($password, $salt);
// Users table.
$data = array(
'username' => $username,
'password' => $password,
'email' => $email,
'ip_address' => sprintf('%u', ip2long($ip_address)),
'created_on' => time(),
'last_login' => time(),
'active' => 1
);
if ($this->store_salt)
{
$data['salt'] = $salt;
}
//filter out any data passed that doesnt have a matching column in the users table
//and merge the set user data and the additional data
$user_data = array_merge($this->_filter_data($this->tables['users'], $additional_data), $data);
$this->trigger_events('extra_set');
$this->db->insert($this->tables['users'], $user_data);
$id = $this->db->insert_id();
if (!empty($groups))
{
//add to groups
foreach ($groups as $group)
{
$this->add_to_group($group, $id);
}
}
//add to default group if not already set
$default_group = $this->where('name', $this->config->item('default_group', 'ion_auth'))->group()->row();
if (isset($default_group->id) && isset($groups) && !empty($groups) && !in_array($default_group->id, $groups) || !isset($groups) || empty($groups))
{
$this->add_to_group($default_group->id, $id);
}
$this->trigger_events('post_register');
return (isset($id)) ? $id : FALSE;
}
/**
* login
*
* @return bool
* @author Mathew
**/
public function login($identity, $password, $remember=FALSE)
{
$this->trigger_events('pre_login');
if (empty($identity) || empty($password))
{
$this->set_error('login_unsuccessful');
return FALSE;
}
$this->trigger_events('extra_where');
$query = $this->db->select('username, email, id, password, last_login')
->where(sprintf('(username = "%1$s" OR email = "%1$s")', $this->db->escape_str($identity)))
->where('active', 1)
->limit(1)
->get($this->tables['users']);
$user = $query->row();
if ($query->num_rows() == 1)
{
$password = $this->hash_password_db($user->id, $password);
if ($user->password === $password)
{
$session_data = array(
'username' => $user->username,
'email' => $user->email,
'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id
'old_last_login' => $user->last_login
);
$this->update_last_login($user->id);
$this->session->set_userdata($session_data);
if ($remember && $this->config->item('remember_users', 'ion_auth'))
{
$this->remember_user($user->id);
}
$this->trigger_events(array('post_login', 'post_login_successful'));
$this->set_message('login_successful');
return TRUE;
}
}
$this->trigger_events('post_login_unsuccessful');
$this->set_error('login_unsuccessful');
return FALSE;
}
public function limit($limit)
{
$this->trigger_events('limit');
$this->_ion_limit = $limit;
return $this;
}
public function offset($offset)
{
$this->trigger_events('offset');
$this->_ion_offset = $offset;
return $this;
}
public function where($where, $value = NULL)
{
$this->trigger_events('where');
if (!is_array($where))
{
$where = array($where => $value);
}
array_push($this->_ion_where, $where);
return $this;
}
public function order_by($by, $order='desc')
{
$this->trigger_events('order_by');
$this->_ion_order_by = $by;
$this->_ion_order = $order;
return $this;
}
public function row()
{
$this->trigger_events('row');
$row = $this->response->row();
$this->response->free_result();
return $row;
}
public function row_array()
{
$this->trigger_events(array('row', 'row_array'));
$row = $this->response->row_array();
$this->response->free_result();
return $row;
}
public function result()
{
$this->trigger_events('result');
$result = $this->response->result();
$this->response->free_result();
return $result;
}
public function result_array()
{
$this->trigger_events(array('result', 'result_array'));
$result = $this->response->result_array();
$this->response->free_result();
return $result;
}
/**
* users
*
* @return object Users
* @author Ben Edmunds
**/
public function users()
{
$this->trigger_events('users');
$this->db->select(array(
$this->tables['users'].'.*',
));
$this->trigger_events('extra_where');
//run each where that was passed
if (isset($this->_ion_where))
{
foreach ($this->_ion_where as $where)
{
$this->db->where($where);
}
$this->_ion_where = array();
}
if (isset($this->_ion_limit) && isset($this->_ion_offset))
{
$this->db->limit($this->_ion_limit, $this->_ion_offset);
$this->_ion_limit = NULL;
$this->_ion_offset = NULL;
}
//set the order
if (isset($this->_ion_order_by) && isset($this->_ion_order))
{
$this->db->order_by($this->_ion_order_by, $this->_ion_order);
$this->_ion_order = NULL;
$this->_ion_order_by = NULL;
}
$this->response = $this->db->get($this->tables['users']);
return $this;
}
/**
* user
*
* @return object
* @author Ben Edmunds
**/
public function user($id = NULL)
{
$this->trigger_events('user');
//if no id was passed use the current users id
$id || $id = $this->session->userdata('user_id');
$this->limit(1);
$this->where($this->tables['users'].'.id', $id);
$this->users();
return $this;
}
/**
* get_users_groups
*
* @return array
* @author Ben Edmunds
**/
public function get_users_groups($id=FALSE)
{
$this->trigger_events('get_users_group');
//if no id was passed use the current users id
$id || $id = $this->session->userdata('user_id');
return $this->db->select($this->tables['users_groups'].'.'.$this->join['groups'].' as id, '.$this->tables['groups'].'.name, '.$this->tables['groups'].'.description')
->where($this->tables['users_groups'].'.'.$this->join['users'], $id)
->join($this->tables['groups'], $this->tables['users_groups'].'.'.$this->join['groups'].'='.$this->tables['groups'].'.id')
->get($this->tables['users_groups']);
}
/**
* add_to_group
*
* @return bool
* @author Ben Edmunds
**/
public function add_to_group($group_id, $user_id=false)
{
$this->trigger_events('add_to_group');
//if no id was passed use the current users id
$user_id || $user_id = $this->session->userdata('user_id');
return $this->db->insert($this->tables['users_groups'], array( $this->join['groups'] => (int)$group_id, $this->join['users'] => (int)$user_id));
}
/**
* remove_from_group
*
* @return bool
* @author Ben Edmunds
**/
public function remove_from_group($group_id, $user_id=false)
{
$this->trigger_events('remove_from_group');
//if no id was passed use the current users id
$user_id || $user_id = $this->session->userdata('user_id');
return $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => (int)$group_id, $this->join['users'] => (int)$user_id));
}
/**
* groups
*
* @return object
* @author Ben Edmunds
**/
public function groups()
{
$this->trigger_events('groups');
//run each where that was passed
if (isset($this->_ion_where))
{
foreach ($this->_ion_where as $where)
{
$this->db->where($where);
}
$this->_ion_where = array();
}
if (isset($this->_ion_limit) && isset($this->_ion_offset))
{
$this->db->limit($this->_ion_limit, $this->_ion_offset);
$this->_ion_limit = NULL;
$this->_ion_offset = NULL;
}
//set the order
if (isset($this->_ion_order_by) && isset($this->_ion_order))
{
$this->db->order_by($this->_ion_order_by, $this->_ion_order);
}
$this->response = $this->db->get($this->tables['groups']);
return $this;
}
/**
* group
*
* @return object
* @author Ben Edmunds
**/
public function group()
{
$this->trigger_events('group');
$this->limit(1);
return $this->groups();
}
/**
* update
*
* @return bool
* @author Phil Sturgeon
**/
public function update($id, array $data)
{
$this->trigger_events('pre_update_user');
$user = $this->user($id)->row();
$this->db->trans_begin();
if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column])
{
$this->db->trans_rollback();
$this->set_error('account_creation_duplicate_'.$this->identity_column);
$this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
$this->set_error('update_unsuccessful');
return FALSE;
}
// Filter the data passed
$data = $this->_filter_data($this->tables['users'], $data);
if (array_key_exists('username', $data) || array_key_exists('password', $data) || array_key_exists('email', $data))
{
if (array_key_exists('password', $data))
{
$data['password'] = $this->hash_password($data['password'], $user->salt);
}
}
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array('id' => $user->id));
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
$this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful'));
$this->set_error('update_unsuccessful');
return FALSE;
}
$this->db->trans_commit();
$this->trigger_events(array('post_update_user', 'post_update_user_successful'));
$this->set_message('update_successful');
return TRUE;
}
/**
* delete_user
*
* @return bool
* @author Phil Sturgeon
**/
public function delete_user($id)
{
$this->trigger_events('pre_delete_user');
$this->db->trans_begin();
$this->db->delete($this->tables['users'], array('id' => $id));
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
$this->trigger_events(array('post_delete_user', 'post_delete_user_unsuccessful'));
$this->set_error('delete_unsuccessful');
return FALSE;
}
$this->db->trans_commit();
$this->trigger_events(array('post_delete_user', 'post_delete_user_successful'));
$this->set_message('delete_successful');
return TRUE;
}
/**
* update_last_login
*
* @return bool
* @author Ben Edmunds
**/
public function update_last_login($id)
{
$this->trigger_events('update_last_login');
$this->load->helper('date');
$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], array('last_login' => time()), array('id' => $id));
return $this->db->affected_rows() == 1;
}
/**
* set_lang
*
* @return bool
* @author Ben Edmunds
**/
public function set_lang($lang = 'en')
{
$this->trigger_events('set_lang');
set_cookie(array(
'name' => 'lang_code',
'value' => $lang,
'expire' => $this->config->item('user_expire', 'ion_auth') + time()
));
return TRUE;
}
/**
* remember_user
*
* @return bool
* @author Ben Edmunds
**/
private function remember_user($id)
{
$this->trigger_events('pre_remember_user');
if (!$id)
{
return FALSE;
}
$user = $this->user($id)->row();
$salt = sha1($user->password);
$this->db->update($this->tables['users'], array('remember_code' => $salt), array('id' => $id));
if ($this->db->affected_rows() > -1)
{
set_cookie(array(
'name' => 'identity',
'value' => $user->{$this->identity_column},
'expire' => $this->config->item('user_expire', 'ion_auth'),
));
set_cookie(array(
'name' => 'remember_code',
'value' => $salt,
'expire' => $this->config->item('user_expire', 'ion_auth'),
));
$this->trigger_events(array('post_remember_user', 'remember_user_successful'));
return TRUE;
}
$this->trigger_events(array('post_remember_user', 'remember_user_unsuccessful'));
return FALSE;
}
/**
* login_remembed_user
*
* @return bool
* @author Ben Edmunds
**/
public function login_remembered_user()
{
$this->trigger_events('pre_login_remembered_user');
//check for valid data
if (!get_cookie('identity') || !get_cookie('remember_code') || !$this->identity_check(get_cookie('identity')))
{
$this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful'));
return FALSE;
}
//get the user
$this->trigger_events('extra_where');
$query = $this->db->select($this->identity_column.', id')
->where($this->identity_column, get_cookie('identity'))
->where('remember_code', get_cookie('remember_code'))
->limit(1)
->get($this->tables['users']);
//if the user was found, sign them in
if ($query->num_rows() == 1)
{
$user = $query->row();
$this->update_last_login($user->id);
$session_data = array(
$this->identity_column => $user->{$this->identity_column},
'id' => $user->id, //kept for backwards compatibility
'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id
);
$this->session->set_userdata($session_data);
//extend the users cookies if the option is enabled
if ($this->config->item('user_extend_on_login', 'ion_auth'))
{
$this->remember_user($user->id);
}
$this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_successful'));
return TRUE;
}
$this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful'));
return FALSE;
}
public function set_hook($event, $name, $class, $method, $arguments)
{
$this->_ion_hooks->{$event}[$name] = new stdClass;
$this->_ion_hooks->{$event}[$name]->class = $class;
$this->_ion_hooks->{$event}[$name]->method = $method;
$this->_ion_hooks->{$event}[$name]->arguments = $arguments;
}
public function remove_hook($event, $name)
{
if (isset($this->_ion_hooks->{$event}[$name]))
{
unset($this->_ion_hooks->{$event}[$name]);
}
}
public function remove_hooks($event)
{
if (isset($this->_ion_hooks->$event))
{
unset($this->_ion_hooks->$event);
}
}
protected function _call_hook($event, $name)
{
if (isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method))
{
$hook = $this->_ion_hooks->{$event}[$name];
return call_user_func_array(array($hook->class, $hook->method), $hook->arguments);
}
return FALSE;
}
public function trigger_events($events)
{
if (is_array($events) && !empty($events))
{
foreach ($events as $event)
{
$this->trigger_events($event);
}
}
else
{
if (isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events))
{
foreach ($this->_ion_hooks->$events as $name => $hook)
{
$this->_call_hook($events, $name);
}
}
}
}
/**
* set_message_delimiters
*
* Set the message delimiters
*
* @return void
* @author Ben Edmunds
**/
public function set_message_delimiters($start_delimiter, $end_delimiter)
{
$this->message_start_delimiter = $start_delimiter;
$this->message_end_delimiter = $end_delimiter;
return TRUE;
}
/**
* set_error_delimiters
*
* Set the error delimiters
*
* @return void
* @author Ben Edmunds
**/
public function set_error_delimiters($start_delimiter, $end_delimiter)
{
$this->error_start_delimiter = $start_delimiter;
$this->error_end_delimiter = $end_delimiter;
return TRUE;
}
/**
* set_message
*
* Set a message
*
* @return void
* @author Ben Edmunds
**/
public function set_message($message)
{
$this->messages[] = $message;
return $message;
}
/**
* messages
*
* Get the messages
*
* @return void
* @author Ben Edmunds
**/
public function messages()
{
$_output = '';
foreach ($this->messages as $message)
{
$_output .= $this->message_start_delimiter . $this->lang->line($message) . $this->message_end_delimiter;
}
return $_output;
}
/**
* set_error
*
* Set an error message
*
* @return void
* @author Ben Edmunds
**/
public function set_error($error)
{
$this->errors[] = $error;
return $error;
}
/**
* errors
*
* Get the error message
*
* @return void
* @author Ben Edmunds
**/
public function errors()
{
$_output = '';
foreach ($this->errors as $error)
{
$_output .= $this->error_start_delimiter . $this->lang->line($error) . $this->error_end_delimiter;
}
return $_output;
}
protected function _filter_data($table, $data)
{
$filtered_data = array();
$columns = $this->db->list_fields($table);
if (is_array($data))
{
foreach ($columns as $column)
{
if (array_key_exists($column, $data))
$filtered_data[$column] = $data[$column];
}
}
return $filtered_data;
}
} | 101-code | sparks/Ion_auth/models/ion_auth_model.php | PHP | gpl3 | 29,437 |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->library('session');
$this->load->library('form_validation');
$this->load->database();
$this->load->helper('url');
}
//redirect if needed, otherwise display the user list
function index()
{
if (!$this->ion_auth->logged_in())
{
//redirect them to the login page
redirect('auth/login', 'refresh');
}
elseif (!$this->ion_auth->is_admin())
{
//redirect them to the home page because they must be an administrator to view this
redirect($this->config->item('base_url'), 'refresh');
}
else
{
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
//list the users
$this->data['users'] = $this->ion_auth->users()->result();
foreach ($this->data['users'] as $k => $user)
{
$this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
}
$this->load->view('auth/index', $this->data);
}
}
//log the user in
function login()
{
$this->data['title'] = "Login";
//validate form input
$this->form_validation->set_rules('identity', 'Identity', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == true)
{ //check to see if the user is logging in
//check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
{ //if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect($this->config->item('base_url'), 'refresh');
}
else
{ //if the login was un-successful
//redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{ //the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
$this->load->view('auth/login', $this->data);
}
}
//log the user out
function logout()
{
$this->data['title'] = "Logout";
//log the user out
$logout = $this->ion_auth->logout();
//redirect them back to the page they came from
redirect('auth', 'refresh');
}
//change password
function change_password()
{
$this->form_validation->set_rules('old', 'Old password', 'required');
$this->form_validation->set_rules('new', 'New Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]');
$this->form_validation->set_rules('new_confirm', 'Confirm New Password', 'required');
if (!$this->ion_auth->logged_in())
{
redirect('auth/login', 'refresh');
}
$user = $this->ion_auth->user()->row();
if ($this->form_validation->run() == false)
{ //display the form
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['old_password'] = array(
'name' => 'old',
'id' => 'old',
'type' => 'password',
);
$this->data['new_password'] = array(
'name' => 'new',
'id' => 'new',
'type' => 'password',
);
$this->data['new_password_confirm'] = array(
'name' => 'new_confirm',
'id' => 'new_confirm',
'type' => 'password',
);
$this->data['user_id'] = array(
'name' => 'user_id',
'id' => 'user_id',
'type' => 'hidden',
'value' => $user->id,
);
//render
$this->load->view('auth/change_password', $this->data);
}
else
{
$identity = $this->session->userdata($this->config->item('identity', 'ion_auth'));
$change = $this->ion_auth->change_password($identity, $this->input->post('old'), $this->input->post('new'));
if ($change)
{ //if the password was successfully changed
$this->session->set_flashdata('message', $this->ion_auth->messages());
$this->logout();
}
else
{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('auth/change_password', 'refresh');
}
}
}
//forgot password
function forgot_password()
{
$this->form_validation->set_rules('email', 'Email Address', 'required');
if ($this->form_validation->run() == false)
{
//setup the input
$this->data['email'] = array('name' => 'email',
'id' => 'email',
);
//set any errors and display the form
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->load->view('auth/forgot_password', $this->data);
}
else
{
//run the forgotten password method to email an activation code to the user
$forgotten = $this->ion_auth->forgotten_password($this->input->post('email'));
if ($forgotten)
{ //if there were no errors
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth/login", 'refresh'); //we should display a confirmation page here instead of the login page
}
else
{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("auth/forgot_password", 'refresh');
}
}
}
//reset password - final step for forgotten password
public function reset_password($code)
{
$reset = $this->ion_auth->forgotten_password_complete($code);
if ($reset)
{ //if the reset worked then send them to the login page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth/login", 'refresh');
}
else
{ //if the reset didnt work then send them back to the forgot password page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("auth/forgot_password", 'refresh');
}
}
//activate the user
function activate($id, $code=false)
{
if ($code !== false)
$activation = $this->ion_auth->activate($id, $code);
else if ($this->ion_auth->is_admin())
$activation = $this->ion_auth->activate($id);
if ($activation)
{
//redirect them to the auth page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth", 'refresh');
}
else
{
//redirect them to the forgot password page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("auth/forgot_password", 'refresh');
}
}
//deactivate the user
function deactivate($id = NULL)
{
// no funny business, force to integer
$id = (int) $id;
$this->load->library('form_validation');
$this->form_validation->set_rules('confirm', 'confirmation', 'required');
$this->form_validation->set_rules('id', 'user ID', 'required|is_natural');
if ($this->form_validation->run() == FALSE)
{
// insert csrf check
$this->data['csrf'] = $this->_get_csrf_nonce();
$this->data['user'] = $this->ion_auth->user($id)->row();
$this->load->view('auth/deactivate_user', $this->data);
}
else
{
// do we really want to deactivate?
if ($this->input->post('confirm') == 'yes')
{
// do we have a valid request?
if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id'))
{
show_404();
}
// do we have the right userlevel?
if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin())
{
$this->ion_auth->deactivate($id);
}
}
//redirect them back to the auth page
redirect('auth', 'refresh');
}
}
//create a new user
function create_user()
{
$this->data['title'] = "Create User";
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
{
redirect('auth', 'refresh');
}
//validate form input
$this->form_validation->set_rules('first_name', 'First Name', 'required|xss_clean');
$this->form_validation->set_rules('last_name', 'Last Name', 'required|xss_clean');
$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
$this->form_validation->set_rules('phone1', 'First Part of Phone', 'required|xss_clean|min_length[3]|max_length[3]');
$this->form_validation->set_rules('phone2', 'Second Part of Phone', 'required|xss_clean|min_length[3]|max_length[3]');
$this->form_validation->set_rules('phone3', 'Third Part of Phone', 'required|xss_clean|min_length[4]|max_length[4]');
$this->form_validation->set_rules('company', 'Company Name', 'required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
$this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required');
if ($this->form_validation->run() == true)
{
$username = strtolower($this->input->post('first_name')) . ' ' . strtolower($this->input->post('last_name'));
$email = $this->input->post('email');
$password = $this->input->post('password');
$additional_data = array('first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'company' => $this->input->post('company'),
'phone' => $this->input->post('phone1') . '-' . $this->input->post('phone2') . '-' . $this->input->post('phone3'),
);
}
if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data))
{ //check to see if we are creating the user
//redirect them back to the admin page
$this->session->set_flashdata('message', "User Created");
redirect("auth", 'refresh');
}
else
{ //display the create user form
//set the flash data error message if there is one
$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
$this->data['first_name'] = array('name' => 'first_name',
'id' => 'first_name',
'type' => 'text',
'value' => $this->form_validation->set_value('first_name'),
);
$this->data['last_name'] = array('name' => 'last_name',
'id' => 'last_name',
'type' => 'text',
'value' => $this->form_validation->set_value('last_name'),
);
$this->data['email'] = array('name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email'),
);
$this->data['company'] = array('name' => 'company',
'id' => 'company',
'type' => 'text',
'value' => $this->form_validation->set_value('company'),
);
$this->data['phone1'] = array('name' => 'phone1',
'id' => 'phone1',
'type' => 'text',
'value' => $this->form_validation->set_value('phone1'),
);
$this->data['phone2'] = array('name' => 'phone2',
'id' => 'phone2',
'type' => 'text',
'value' => $this->form_validation->set_value('phone2'),
);
$this->data['phone3'] = array('name' => 'phone3',
'id' => 'phone3',
'type' => 'text',
'value' => $this->form_validation->set_value('phone3'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
'value' => $this->form_validation->set_value('password'),
);
$this->data['password_confirm'] = array('name' => 'password_confirm',
'id' => 'password_confirm',
'type' => 'password',
'value' => $this->form_validation->set_value('password_confirm'),
);
$this->load->view('auth/create_user', $this->data);
}
}
function _get_csrf_nonce()
{
$this->load->helper('string');
$key = random_string('alnum', 8);
$value = random_string('alnum', 20);
$this->session->set_flashdata('csrfkey', $key);
$this->session->set_flashdata('csrfvalue', $value);
return array($key => $value);
}
function _valid_csrf_nonce()
{
if ($this->input->post($this->session->flashdata('csrfkey')) !== FALSE &&
$this->input->post($this->session->flashdata('csrfkey')) == $this->session->flashdata('csrfvalue'))
{
return TRUE;
}
else
{
return FALSE;
}
}
}
| 101-code | sparks/Ion_auth/controllers/auth.php | PHP | gpl3 | 12,804 |
<?php
# Load the Ion Auth library when the spark is loaded
$autoload['libraries'] = array('ion_auth');
| 101-code | sparks/Ion_auth/config/autoload.php | PHP | gpl3 | 105 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Ion Auth Config
*
* Author: Ben Edmunds
* ben.edmunds@gmail.com
* @benedmunds
*
* Added Awesomeness: Phil Sturgeon
*
* Location: http://github.com/benedmunds/ion_auth/
*
* Created: 10.01.2009
*
* Description: Modified auth system based on redux_auth with extensive customization. This is basically what Redux Auth 2 should be.
* Original Author name has been kept but that does not mean that the method has not been modified.
*
*/
/**
* Tables.
**/
$config['tables']['groups'] = 'groups';
$config['tables']['users'] = 'users';
$config['tables']['users_groups'] = 'users_groups';
/**
* Site Title, example.com
*/
$config['site_title'] = "Example.com";
/**
* Admin Email, admin@example.com
*/
$config['admin_email'] = "admin@example.com";
/**
* Default group, use name
*/
$config['default_group'] = 'members';
/**
* Default administrators group, use name
*/
$config['admin_group'] = 'admin';
/**
* Users table column and Group table column you want to join WITH.
* Joins from users.id
* Joins from groups.id
**/
$config['join']['users'] = 'user_id';
$config['join']['groups'] = 'group_id';
/**
* A database column which is used to
* login with.
**/
$config['identity'] = 'email';
/**
* Minimum Required Length of Password
**/
$config['min_password_length'] = 8;
/**
* Maximum Allowed Length of Password
**/
$config['max_password_length'] = 20;
/**
* Email Activation for registration
**/
$config['email_activation'] = false;
/**
* Allow users to be remembered and enable auto-login
**/
$config['remember_users'] = true;
/**
* How long to remember the user (seconds)
**/
$config['user_expire'] = 86500;
/**
* Extend the users cookies everytime they auto-login
**/
$config['user_extend_on_login'] = false;
/**
* Folder where email templates are stored.
* Default : auth/
**/
$config['email_templates'] = 'auth/email/';
/**
* activate Account Email Template
* Default : activate.tpl.php
**/
$config['email_activate'] = 'activate.tpl.php';
/**
* Forgot Password Email Template
* Default : forgot_password.tpl.php
**/
$config['email_forgot_password'] = 'forgot_password.tpl.php';
/**
* Forgot Password Complete Email Template
* Default : new_password.tpl.php
**/
$config['email_forgot_password_complete'] = 'new_password.tpl.php';
/**
* Salt Length
**/
$config['salt_length'] = 10;
/**
* Should the salt be stored in the database?
* This will change your password encryption algorithm,
* default password, 'password', changes to
* fbaa5e216d163a02ae630ab1a43372635dd374c0 with default salt.
**/
$config['store_salt'] = false;
/**
* Message Start Delimiter
**/
$config['message_start_delimiter'] = '<p>';
/**
* Message End Delimiter
**/
$config['message_end_delimiter'] = '</p>';
/**
* Error Start Delimiter
**/
$config['error_start_delimiter'] = '<p>';
/**
* Error End Delimiter
**/
$config['error_end_delimiter'] = '</p>';
/* End of file ion_auth.php */
/* Location: ./system/application/config/ion_auth.php */
| 101-code | sparks/Ion_auth/config/ion_auth.php | PHP | gpl3 | 3,347 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/language/english/index.html | HTML | gpl3 | 114 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/logs/index.html | HTML | gpl3 | 114 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#body{
margin: 0 15px 0 15px;
}
p.footer{
text-align: right;
font-size: 11px;
border-top: 1px solid #D0D0D0;
line-height: 32px;
padding: 0 10px 0 10px;
margin: 20px 0 0 0;
}
#container{
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
</style>
</head>
<body>
<div id="container">
<div id="body">
<h1>Building site</h1>
<dl>
<dt>Creating session database</dt>
<dd><?=$session_table?></dd>
<dt>Checking session is writable</dt>
<dd><?=$session_check?></dd>
<dt>Creating config file</dt>
<dd>TODO</dd>
<dt>Collecting information</dt>
<dd>TODO</dd>
</dl>
</div>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>
</body>
</html> | 101-code | application/views/admin/install/build.php | PHP | gpl3 | 1,729 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#body{
margin: 0 15px 0 15px;
}
p.footer{
text-align: right;
font-size: 11px;
border-top: 1px solid #D0D0D0;
line-height: 32px;
padding: 0 10px 0 10px;
margin: 20px 0 0 0;
}
#container{
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
</style>
</head>
<body>
<div id="container">
<div id="body">
<h1>Installation</h1>
<p>It looks like you don't have an installation in place.</p>
<p>If you click this button below, it could cause issues with any existing data.</p>
<p><strong>Proceed with caution!</strong></p>
<?=form_open('/admin/install/build', array('id'=>'proceed')) ?>
<?=form_submit('proceed', 'Initiate install'); ?>
<?=form_close()?>
</div>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>
</body>
</html> | 101-code | application/views/admin/install/check.php | PHP | gpl3 | 1,801 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/views/errors/index.html | HTML | gpl3 | 114 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/views/pages/index.html | HTML | gpl3 | 114 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/views/template/index.html | HTML | gpl3 | 114 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/views/index.html | HTML | gpl3 | 114 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/views/includes/index.html | HTML | gpl3 | 114 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
<link rel="stylesheet" type="text/css" href="<?php asset('public/css/style.css') ?>" />
</head>
<body>
<div id="container">
<h1>Welcome to CodeIgniter!</h1>
<div id="body">
<p>
<img src="<?php asset('public/images/test2.jpg')?>" alt="test image" />
<img src="<?php asset('public/images/element_test48.gif')?>" alt="test image 2" />
<img src="<?php asset('public/images/small.jpg')?>" alt="small image " />
</p>
<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
<p>If you would like to edit this page you'll find it located at:</p>
<code>application/views/welcome_message.php</code>
<p>The corresponding controller for this page is found at:</p>
<code>application/controllers/welcome.php</code>
<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
</div>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
<p class="footer">The time is <?php echo date('m/d/Y h:i:s a') ?> </p>
</div>
</body>
</html> | 101-code | application/views/welcome_message.php | PHP | gpl3 | 1,184 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('asset'))
{
function asset($param, $group = FALSE, $ignore = FALSE)
{
// Get the superobject
$CI =& get_instance();
// Load the asset config file, if not loaded already
$CI->load->config('asset_manager', TRUE);
// If the ignore flag is set for this asset OR the config is switched off, then just return the file
if ($ignore || ! $CI->config->item('active', 'asset_manager'))
{
// Load the helper, if it's not already
$CI->load->helper('url');
// Now just return the file made relative to the site with the site_url function
echo site_url($param);
}
else
{
// What query library are we using?
$CI->load->library('asset_manager/am_'.$CI->config->item('query', 'asset_manager').'_query', FALSE,'am_query');
// Now call it up
echo $CI->am_query->get_asset_src($param, $group);
}
}
}
if ( ! function_exists('get_cdn_bucket'))
{
function get_cdn_bucket()
{
$CI =& get_instance();
$CI->load->helper('url');
return $CI->config->item('cdn_bucket', 'asset_manager') ?
$CI->config->item('cdn_bucket', 'asset_manager') : parse_url(site_url(), PHP_URL_HOST);
}
}
if ( ! function_exists('cdn_url'))
{
function get_cdn_url($remote)
{
$CI =& get_instance();
return $CI->config->item('cdn_url', 'asset_manager').get_cdn_bucket().'/'.$remote;
}
} | 101-code | application/helpers/asset_helper.php | PHP | gpl3 | 1,402 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('optimize_image'))
{
function optimize_image($file, $quality = 90)
{
// Check that the file isn't already compressed
if (preg_match('/^\.compressed\./', pathinfo($file, PATHINFO_FILENAME)))
{
return $file;
}
// What's the new filename?
$new_file = pathinfo($asset['file'], PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_BASENAME).
'.optimized.'.pathinfo($file, PATHINFO_EXTENSION);
// What's the current image string
$image_string = imagecreatefromstring(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/'.$file));
// Go through the different image files and optimize
switch (pathinfo(strtolower($file), PATHINFO_EXTENSION))
{
case 'jpg':
case 'jpeg':
imagejpeg($image_string, $_SERVER['DOCUMENT_ROOT'].'/'.$new_file, $quality);
break;
case 'png':
imagepng($image_string, $_SERVER['DOCUMENT_ROOT'].'/'.$new_file, $quality);
break;
case 'gif':
$im = new Imagick($image_string);
$im->optimizeImageLayers();
$im->writeimage($_SERVER['DOCUMENT_ROOT'].'/'.$new_file);
break;
}
return $new_file;
}
} | 101-code | application/helpers/optimize_helper.php | PHP | gpl3 | 1,173 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/helpers/index.html | HTML | gpl3 | 114 |
<!DOCTYPE html>
<html lang="en">
<head>
<title>Database Error</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
</body>
</html> | 101-code | application/errors/error_db.php | PHP | gpl3 | 1,156 |
<!DOCTYPE html>
<html lang="en">
<head>
<title>404 Page Not Found</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
</body>
</html> | 101-code | application/errors/error_404.php | PHP | gpl3 | 1,160 |
<!DOCTYPE html>
<html lang="en">
<head>
<title>Error</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
</body>
</html> | 101-code | application/errors/error_general.php | PHP | gpl3 | 1,147 |
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: <?php echo $severity; ?></p>
<p>Message: <?php echo $message; ?></p>
<p>Filename: <?php echo $filepath; ?></p>
<p>Line Number: <?php echo $line; ?></p>
</div> | 101-code | application/errors/error_php.php | PHP | gpl3 | 288 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/errors/index.html | HTML | gpl3 | 114 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
abstract class Asset_manager {
/**
* CI
*
* CodeIgniter super object
*
* @access private
* @var object
*/
protected $CI; // The CodeIgniter super object, we'll need this
protected $param ='';
protected $group = FALSE;
/**
* Constructor
*
* The constructor gets the CodeIgniter super object and calls in the configuration variables
* for use in the class.
*
* @access public
* @since 2012-05-25
* @return void
*/
public function __construct()
{
log_message('debug', '[ASSETS] Class initialized');
$this->CI =& get_instance();
$this->CI->load->config('asset_manager', TRUE);
}
protected function cron() {}
protected function process_queue() {}
protected function check_asset($asset)
{
// Check the base64
// Check for optmization
// Check for CDN
return $asset;
}
/**
* process asset
*
* Checks if the asset exists in the database. If it does, it returns the asset location.
* If it doesn't, it returns the original passed location and queues the asset for processing.
*
* @access private
* @since 2012-05-25
* @param string $file
* @param integer $identifier
* @return string
*/
protected function process_new_asset($file, $group = FALSE)
{
$this->CI->load->library('asset_manager/am_handler');
$this->CI->build_new_asset($file, $group);
return $this->CI->am_handler->queue_or_do();
}
/**
* Single Asset Src
*
* Okay, so the asset exists in the database, but we want to check if everything that needs doing to it is done,
* then queue or do it and return the relevant src string for the output handler
*
* @param unknown_type $asset
*/
protected function single_asset_src($asset)
{
log_message('error', print_r($asset, true));
// Base64 is our first check
if ($this->CI->config->item('base64_limit', 'asset_manager') && isset($asset['base64']) &&
$this->CI->config->item('base64_limit', 'asset_manager') <= $asset['filesize'])
{
return $asset['base64'];
} // Now see if there's a cdn file and CDN is turned on, then go get the file
elseif (isset($asset['cdn']) && $this->CI->config->item('cdn', 'asset_manager'))
{
return get_cdn_url($asset['cdn']);
} // If not, just default to the original file, which will be represented as a 0
elseif (isset($asset['file']))
{
return $asset['file'];
}
// Log a message, somethings wrong here
log_message('error', "[ASSET MANAGER] [AM_HANDLER] Malformed asset array [".var_dump($asset, TRUE)."]");
}
} | 101-code | application/libraries/Asset_manager.php | PHP | gpl3 | 3,417 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
require_once(APPPATH.'libraries/asset_manager/am_handler.php');
class Asset_manager_queue extends Am_handler
{
public function __construct()
{
parent::__construct();
}
/**
* Process Queue
*
* Simply get's the queue and process it
*
* @access public
* @since 2012-05-25
* @return void
*/
public function process_queue()
{
foreach($this->get_queue()->result_array() as $asset)
{
$this->process_asset($asset);
}
}
/**
* Delete Queued Asset
*
* Removes the asset from the queue once we've processed it
*
* @access private
* @since 2012-05-25
* @param integer $asset_id
* @return boolean
*/
private function delete_queued_asset($asset_id)
{
return $this->CI->db->delete($this->CI->config->item('queue_table', 'asset_manager'),
array('id' => $id));
}
/**
* Get Queue
*
* Returns the queue from the database
*
* @access private
* @since 2012-05-25
* @return object
*/
private function get_queue()
{
return $this->CI->db->from($this->CI->config->item('queue_table', 'asset_manager'))->get();
}
/**
* Queue Asset
*
* Sticks an asset in the queue to process later
*
* @access private
* @since 2012-05-29
* @param array $asset
* @return boolean
*/
private function queue_asset($asset)
{
return $this->CI->db->insert($this->CI->config->item('queue_table', 'asset_manager'), $asset);
}
} | 101-code | application/libraries/asset_manager/am_handler/Am_handler_queue.php | PHP | gpl3 | 2,321 |
<?php
| 101-code | application/libraries/asset_manager/Am_combine.php | PHP | gpl3 | 6 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CDN Amazon Library
*
* The Handler library deals with getting the information in and out of the
* CDN.
*
* @package Asset Manager
* @subpackage CDNs
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
require_once(APPPATH.'libraries/asset_manager/Am_cdn.php');
class Am_cdn_amazon extends Am_cdn {
private $s3;
private $bucket;
private $private_key;
private $secret_key;
public function __construct($bucket = FALSE)
{
parent::__construct();
log_message('debug', '[CDN_AMAZON] Cdn_amazon loaded');
require_once(APPPATH.'libraries/asset_manager/am_cdn/am_cdn_amazon/s3.php');
$this->s3 = new S3();
$this->bucket = $bucket ? $bucket : get_cdn_bucket();
$this->s3->setAuth($this->CI->config->item('cdn_access_key', 'asset_manager'),
$this->CI->config->item('cdn_secret_key', 'asset_manager'));
}
public function put_file($file, $content_type)
{
$this->create_bucket();
return $this->s3->putObjectFile($_SERVER['DOCUMENT_ROOT'].'/'.$file, $this->bucket, $file,
S3::ACL_PUBLIC_READ, array("Cache-Control" => "max-age=315360000",
"Expires" => gmdate("D, d M Y H:i:s T", strtotime("+5 years"))), $content_type);
}
public function check_bucket_exists()
{
return $this->CI->config->item('cdn_check_bucket', 'asset_manager') ?
in_array($this->bucket, $this->s3->listBuckets()) : TRUE;
}
public function create_bucket()
{
return $this->check_bucket_exists() ? TRUE :
$this->s3->putBucket($this->bucket, S3::ACL_PUBLIC_READ) ;
}
} | 101-code | application/libraries/asset_manager/am_cdn/Am_cdn_amazon.php | PHP | gpl3 | 2,079 |
<?php
/**
* $Id$
*
* Copyright (c) 2011, Donovan Schönknecht. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Amazon S3 is a trademark of Amazon.com, Inc. or its affiliates.
*/
/**
* Amazon S3 PHP class
*
* @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
* @version 0.5.0-dev
*/
class S3
{
// ACL flags
const ACL_PRIVATE = 'private';
const ACL_PUBLIC_READ = 'public-read';
const ACL_PUBLIC_READ_WRITE = 'public-read-write';
const ACL_AUTHENTICATED_READ = 'authenticated-read';
const STORAGE_CLASS_STANDARD = 'STANDARD';
const STORAGE_CLASS_RRS = 'REDUCED_REDUNDANCY';
private static $__accessKey = null; // AWS Access key
private static $__secretKey = null; // AWS Secret key
private static $__sslKey = null;
public static $endpoint = 's3.amazonaws.com';
public static $proxy = null;
public static $useSSL = false;
public static $useSSLValidation = true;
public static $useExceptions = false;
// SSL CURL SSL options - only needed if you are experiencing problems with your OpenSSL configuration
public static $sslKey = null;
public static $sslCert = null;
public static $sslCACert = null;
private static $__signingKeyPairId = null; // AWS Key Pair ID
private static $__signingKeyResource = false; // Key resource, freeSigningKey() must be called to clear it from memory
/**
* Constructor - if you're not using the class statically
*
* @param string $accessKey Access key
* @param string $secretKey Secret key
* @param boolean $useSSL Enable SSL
* @return void
*/
public function __construct($accessKey = null, $secretKey = null, $useSSL = false, $endpoint = 's3.amazonaws.com')
{
if ($accessKey !== null && $secretKey !== null)
self::setAuth($accessKey, $secretKey);
self::$useSSL = $useSSL;
self::$endpoint = $endpoint;
}
/**
* Set the sertvice endpoint
*
* @param string $host Hostname
* @return void
*/
public function setEndpoint($host)
{
self::$endpoint = $host;
}
/**
* Set AWS access key and secret key
*
* @param string $accessKey Access key
* @param string $secretKey Secret key
* @return void
*/
public static function setAuth($accessKey, $secretKey)
{
self::$__accessKey = $accessKey;
self::$__secretKey = $secretKey;
}
/**
* Check if AWS keys have been set
*
* @return boolean
*/
public static function hasAuth() {
return (self::$__accessKey !== null && self::$__secretKey !== null);
}
/**
* Set SSL on or off
*
* @param boolean $enabled SSL enabled
* @param boolean $validate SSL certificate validation
* @return void
*/
public static function setSSL($enabled, $validate = true)
{
self::$useSSL = $enabled;
self::$useSSLValidation = $validate;
}
/**
* Set SSL client certificates (experimental)
*
* @param string $sslCert SSL client certificate
* @param string $sslKey SSL client key
* @param string $sslCACert SSL CA cert (only required if you are having problems with your system CA cert)
* @return void
*/
public static function setSSLAuth($sslCert = null, $sslKey = null, $sslCACert = null)
{
self::$sslCert = $sslCert;
self::$sslKey = $sslKey;
self::$sslCACert = $sslCACert;
}
/**
* Set proxy information
*
* @param string $host Proxy hostname and port (localhost:1234)
* @param string $user Proxy username
* @param string $pass Proxy password
* @param constant $type CURL proxy type
* @return void
*/
public static function setProxy($host, $user = null, $pass = null, $type = CURLPROXY_SOCKS5)
{
self::$proxy = array('host' => $host, 'type' => $type, 'user' => null, 'pass' => 'null');
}
/**
* Set the error mode to exceptions
*
* @param boolean $enabled Enable exceptions
* @return void
*/
public static function setExceptions($enabled = true)
{
self::$useExceptions = $enabled;
}
/**
* Set signing key
*
* @param string $keyPairId AWS Key Pair ID
* @param string $signingKey Private Key
* @param boolean $isFile Load private key from file, set to false to load string
* @return boolean
*/
public static function setSigningKey($keyPairId, $signingKey, $isFile = true)
{
self::$__signingKeyPairId = $keyPairId;
if ((self::$__signingKeyResource = openssl_pkey_get_private($isFile ?
file_get_contents($signingKey) : $signingKey)) !== false) return true;
self::__triggerError('S3::setSigningKey(): Unable to open load private key: '.$signingKey, __FILE__, __LINE__);
return false;
}
/**
* Free signing key from memory, MUST be called if you are using setSigningKey()
*
* @return void
*/
public static function freeSigningKey()
{
if (self::$__signingKeyResource !== false)
openssl_free_key(self::$__signingKeyResource);
}
/**
* Internal error handler
*
* @internal Internal error handler
* @param string $message Error message
* @param string $file Filename
* @param integer $line Line number
* @param integer $code Error code
* @return void
*/
private static function __triggerError($message, $file, $line, $code = 0)
{
if (self::$useExceptions)
throw new S3Exception($message, $file, $line, $code);
else
trigger_error($message, E_USER_WARNING);
}
/**
* Get a list of buckets
*
* @param boolean $detailed Returns detailed bucket list when true
* @return array | false
*/
public static function listBuckets($detailed = false)
{
$rest = new S3Request('GET', '', '', self::$endpoint);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::listBuckets(): [%s] %s", $rest->error['code'],
$rest->error['message']), __FILE__, __LINE__);
return false;
}
$results = array();
if (!isset($rest->body->Buckets)) return $results;
if ($detailed)
{
if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName))
$results['owner'] = array(
'id' => (string)$rest->body->Owner->ID, 'name' => (string)$rest->body->Owner->ID
);
$results['buckets'] = array();
foreach ($rest->body->Buckets->Bucket as $b)
$results['buckets'][] = array(
'name' => (string)$b->Name, 'time' => strtotime((string)$b->CreationDate)
);
} else
foreach ($rest->body->Buckets->Bucket as $b) $results[] = (string)$b->Name;
return $results;
}
/*
* Get contents for a bucket
*
* If maxKeys is null this method will loop through truncated result sets
*
* @param string $bucket Bucket name
* @param string $prefix Prefix
* @param string $marker Marker (last file listed)
* @param string $maxKeys Max keys (maximum number of keys to return)
* @param string $delimiter Delimiter
* @param boolean $returnCommonPrefixes Set to true to return CommonPrefixes
* @return array | false
*/
public static function getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null, $returnCommonPrefixes = false)
{
$rest = new S3Request('GET', $bucket, '', self::$endpoint);
if ($maxKeys == 0) $maxKeys = null;
if ($prefix !== null && $prefix !== '') $rest->setParameter('prefix', $prefix);
if ($marker !== null && $marker !== '') $rest->setParameter('marker', $marker);
if ($maxKeys !== null && $maxKeys !== '') $rest->setParameter('max-keys', $maxKeys);
if ($delimiter !== null && $delimiter !== '') $rest->setParameter('delimiter', $delimiter);
$response = $rest->getResponse();
if ($response->error === false && $response->code !== 200)
$response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
if ($response->error !== false)
{
self::__triggerError(sprintf("S3::getBucket(): [%s] %s",
$response->error['code'], $response->error['message']), __FILE__, __LINE__);
return false;
}
$results = array();
$nextMarker = null;
if (isset($response->body, $response->body->Contents))
foreach ($response->body->Contents as $c)
{
$results[(string)$c->Key] = array(
'name' => (string)$c->Key,
'time' => strtotime((string)$c->LastModified),
'size' => (int)$c->Size,
'hash' => substr((string)$c->ETag, 1, -1)
);
$nextMarker = (string)$c->Key;
}
if ($returnCommonPrefixes && isset($response->body, $response->body->CommonPrefixes))
foreach ($response->body->CommonPrefixes as $c)
$results[(string)$c->Prefix] = array('prefix' => (string)$c->Prefix);
if (isset($response->body, $response->body->IsTruncated) &&
(string)$response->body->IsTruncated == 'false') return $results;
if (isset($response->body, $response->body->NextMarker))
$nextMarker = (string)$response->body->NextMarker;
// Loop through truncated results if maxKeys isn't specified
if ($maxKeys == null && $nextMarker !== null && (string)$response->body->IsTruncated == 'true')
do
{
$rest = new S3Request('GET', $bucket, '', self::$endpoint);
if ($prefix !== null && $prefix !== '') $rest->setParameter('prefix', $prefix);
$rest->setParameter('marker', $nextMarker);
if ($delimiter !== null && $delimiter !== '') $rest->setParameter('delimiter', $delimiter);
if (($response = $rest->getResponse(true)) == false || $response->code !== 200) break;
if (isset($response->body, $response->body->Contents))
foreach ($response->body->Contents as $c)
{
$results[(string)$c->Key] = array(
'name' => (string)$c->Key,
'time' => strtotime((string)$c->LastModified),
'size' => (int)$c->Size,
'hash' => substr((string)$c->ETag, 1, -1)
);
$nextMarker = (string)$c->Key;
}
if ($returnCommonPrefixes && isset($response->body, $response->body->CommonPrefixes))
foreach ($response->body->CommonPrefixes as $c)
$results[(string)$c->Prefix] = array('prefix' => (string)$c->Prefix);
if (isset($response->body, $response->body->NextMarker))
$nextMarker = (string)$response->body->NextMarker;
} while ($response !== false && (string)$response->body->IsTruncated == 'true');
return $results;
}
/**
* Put a bucket
*
* @param string $bucket Bucket name
* @param constant $acl ACL flag
* @param string $location Set as "EU" to create buckets hosted in Europe
* @return boolean
*/
public static function putBucket($bucket, $acl = self::ACL_PRIVATE, $location = false)
{
$rest = new S3Request('PUT', $bucket, '', self::$endpoint);
$rest->setAmzHeader('x-amz-acl', $acl);
if ($location !== false)
{
$dom = new DOMDocument;
$createBucketConfiguration = $dom->createElement('CreateBucketConfiguration');
$locationConstraint = $dom->createElement('LocationConstraint', $location);
$createBucketConfiguration->appendChild($locationConstraint);
$dom->appendChild($createBucketConfiguration);
$rest->data = $dom->saveXML();
$rest->size = strlen($rest->data);
$rest->setHeader('Content-Type', 'application/xml');
}
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::putBucket({$bucket}, {$acl}, {$location}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Delete an empty bucket
*
* @param string $bucket Bucket name
* @return boolean
*/
public static function deleteBucket($bucket)
{
$rest = new S3Request('DELETE', $bucket, '', self::$endpoint);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 204)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::deleteBucket({$bucket}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Create input info array for putObject()
*
* @param string $file Input file
* @param mixed $md5sum Use MD5 hash (supply a string if you want to use your own)
* @return array | false
*/
public static function inputFile($file, $md5sum = true)
{
if (!file_exists($file) || !is_file($file) || !is_readable($file))
{
self::__triggerError('S3::inputFile(): Unable to open input file: '.$file, __FILE__, __LINE__);
return false;
}
return array('file' => $file, 'size' => filesize($file), 'md5sum' => $md5sum !== false ?
(is_string($md5sum) ? $md5sum : base64_encode(md5_file($file, true))) : '');
}
/**
* Create input array info for putObject() with a resource
*
* @param string $resource Input resource to read from
* @param integer $bufferSize Input byte size
* @param string $md5sum MD5 hash to send (optional)
* @return array | false
*/
public static function inputResource(&$resource, $bufferSize, $md5sum = '')
{
if (!is_resource($resource) || $bufferSize < 0)
{
self::__triggerError('S3::inputResource(): Invalid resource or buffer size', __FILE__, __LINE__);
return false;
}
$input = array('size' => $bufferSize, 'md5sum' => $md5sum);
$input['fp'] =& $resource;
return $input;
}
/**
* Put an object
*
* @param mixed $input Input data
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param constant $acl ACL constant
* @param array $metaHeaders Array of x-amz-meta-* headers
* @param array $requestHeaders Array of request headers or content type as a string
* @param constant $storageClass Storage class constant
* @return boolean
*/
public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(), $storageClass = self::STORAGE_CLASS_STANDARD)
{
if ($input === false) return false;
$rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
if (is_string($input)) $input = array(
'data' => $input, 'size' => strlen($input),
'md5sum' => base64_encode(md5($input, true))
);
// Data
if (isset($input['fp']))
$rest->fp =& $input['fp'];
elseif (isset($input['file']))
$rest->fp = @fopen($input['file'], 'rb');
elseif (isset($input['data']))
$rest->data = $input['data'];
// Content-Length (required)
if (isset($input['size']) && $input['size'] >= 0)
$rest->size = $input['size'];
else {
if (isset($input['file']))
$rest->size = filesize($input['file']);
elseif (isset($input['data']))
$rest->size = strlen($input['data']);
}
// Custom request headers (Content-Type, Content-Disposition, Content-Encoding)
if (is_array($requestHeaders))
foreach ($requestHeaders as $h => $v) $rest->setHeader($h, $v);
elseif (is_string($requestHeaders)) // Support for legacy contentType parameter
$input['type'] = $requestHeaders;
// Content-Type
if (!isset($input['type']))
{
if (isset($requestHeaders['Content-Type']))
$input['type'] =& $requestHeaders['Content-Type'];
elseif (isset($input['file']))
$input['type'] = self::__getMimeType($input['file']);
else
$input['type'] = 'application/octet-stream';
}
if ($storageClass !== self::STORAGE_CLASS_STANDARD) // Storage class
$rest->setAmzHeader('x-amz-storage-class', $storageClass);
// We need to post with Content-Length and Content-Type, MD5 is optional
if ($rest->size >= 0 && ($rest->fp !== false || $rest->data !== false))
{
$rest->setHeader('Content-Type', $input['type']);
if (isset($input['md5sum'])) $rest->setHeader('Content-MD5', $input['md5sum']);
$rest->setAmzHeader('x-amz-acl', $acl);
foreach ($metaHeaders as $h => $v) $rest->setAmzHeader('x-amz-meta-'.$h, $v);
$rest->getResponse();
} else
$rest->response->error = array('code' => 0, 'message' => 'Missing input parameters');
if ($rest->response->error === false && $rest->response->code !== 200)
$rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
if ($rest->response->error !== false)
{
self::__triggerError(sprintf("S3::putObject(): [%s] %s",
$rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Put an object from a file (legacy function)
*
* @param string $file Input file path
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param constant $acl ACL constant
* @param array $metaHeaders Array of x-amz-meta-* headers
* @param string $contentType Content type
* @return boolean
*/
public static function putObjectFile($file, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $contentType = null)
{
return self::putObject(self::inputFile($file), $bucket, $uri, $acl, $metaHeaders, $contentType);
}
/**
* Put an object from a string (legacy function)
*
* @param string $string Input data
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param constant $acl ACL constant
* @param array $metaHeaders Array of x-amz-meta-* headers
* @param string $contentType Content type
* @return boolean
*/
public static function putObjectString($string, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $contentType = 'text/plain')
{
return self::putObject($string, $bucket, $uri, $acl, $metaHeaders, $contentType);
}
/**
* Get an object
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param mixed $saveTo Filename or resource to write to
* @return mixed
*/
public static function getObject($bucket, $uri, $saveTo = false)
{
$rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
if ($saveTo !== false)
{
if (is_resource($saveTo))
$rest->fp =& $saveTo;
else
if (($rest->fp = @fopen($saveTo, 'wb')) !== false)
$rest->file = realpath($saveTo);
else
$rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: '.$saveTo);
}
if ($rest->response->error === false) $rest->getResponse();
if ($rest->response->error === false && $rest->response->code !== 200)
$rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
if ($rest->response->error !== false)
{
self::__triggerError(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
$rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
return false;
}
return $rest->response;
}
/**
* Get object information
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param boolean $returnInfo Return response information
* @return mixed | false
*/
public static function getObjectInfo($bucket, $uri, $returnInfo = true)
{
$rest = new S3Request('HEAD', $bucket, $uri, self::$endpoint);
$rest = $rest->getResponse();
if ($rest->error === false && ($rest->code !== 200 && $rest->code !== 404))
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::getObjectInfo({$bucket}, {$uri}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return $rest->code == 200 ? $returnInfo ? $rest->headers : true : false;
}
/**
* Copy an object
*
* @param string $bucket Source bucket name
* @param string $uri Source object URI
* @param string $bucket Destination bucket name
* @param string $uri Destination object URI
* @param constant $acl ACL constant
* @param array $metaHeaders Optional array of x-amz-meta-* headers
* @param array $requestHeaders Optional array of request headers (content type, disposition, etc.)
* @param constant $storageClass Storage class constant
* @return mixed | false
*/
public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(), $storageClass = self::STORAGE_CLASS_STANDARD)
{
$rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
$rest->setHeader('Content-Length', 0);
foreach ($requestHeaders as $h => $v) $rest->setHeader($h, $v);
foreach ($metaHeaders as $h => $v) $rest->setAmzHeader('x-amz-meta-'.$h, $v);
if ($storageClass !== self::STORAGE_CLASS_STANDARD) // Storage class
$rest->setAmzHeader('x-amz-storage-class', $storageClass);
$rest->setAmzHeader('x-amz-acl', $acl); // Added rawurlencode() for $srcUri (thanks a.yamanoi)
$rest->setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, rawurlencode($srcUri)));
if (sizeof($requestHeaders) > 0 || sizeof($metaHeaders) > 0)
$rest->setAmzHeader('x-amz-metadata-directive', 'REPLACE');
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return isset($rest->body->LastModified, $rest->body->ETag) ? array(
'time' => strtotime((string)$rest->body->LastModified),
'hash' => substr((string)$rest->body->ETag, 1, -1)
) : false;
}
/**
* Set logging for a bucket
*
* @param string $bucket Bucket name
* @param string $targetBucket Target bucket (where logs are stored)
* @param string $targetPrefix Log prefix (e,g; domain.com-)
* @return boolean
*/
public static function setBucketLogging($bucket, $targetBucket, $targetPrefix = null)
{
// The S3 log delivery group has to be added to the target bucket's ACP
if ($targetBucket !== null && ($acp = self::getAccessControlPolicy($targetBucket, '')) !== false)
{
// Only add permissions to the target bucket when they do not exist
$aclWriteSet = false;
$aclReadSet = false;
foreach ($acp['acl'] as $acl)
if ($acl['type'] == 'Group' && $acl['uri'] == 'http://acs.amazonaws.com/groups/s3/LogDelivery')
{
if ($acl['permission'] == 'WRITE') $aclWriteSet = true;
elseif ($acl['permission'] == 'READ_ACP') $aclReadSet = true;
}
if (!$aclWriteSet) $acp['acl'][] = array(
'type' => 'Group', 'uri' => 'http://acs.amazonaws.com/groups/s3/LogDelivery', 'permission' => 'WRITE'
);
if (!$aclReadSet) $acp['acl'][] = array(
'type' => 'Group', 'uri' => 'http://acs.amazonaws.com/groups/s3/LogDelivery', 'permission' => 'READ_ACP'
);
if (!$aclReadSet || !$aclWriteSet) self::setAccessControlPolicy($targetBucket, '', $acp);
}
$dom = new DOMDocument;
$bucketLoggingStatus = $dom->createElement('BucketLoggingStatus');
$bucketLoggingStatus->setAttribute('xmlns', 'http://s3.amazonaws.com/doc/2006-03-01/');
if ($targetBucket !== null)
{
if ($targetPrefix == null) $targetPrefix = $bucket . '-';
$loggingEnabled = $dom->createElement('LoggingEnabled');
$loggingEnabled->appendChild($dom->createElement('TargetBucket', $targetBucket));
$loggingEnabled->appendChild($dom->createElement('TargetPrefix', $targetPrefix));
// TODO: Add TargetGrants?
$bucketLoggingStatus->appendChild($loggingEnabled);
}
$dom->appendChild($bucketLoggingStatus);
$rest = new S3Request('PUT', $bucket, '', self::$endpoint);
$rest->setParameter('logging', null);
$rest->data = $dom->saveXML();
$rest->size = strlen($rest->data);
$rest->setHeader('Content-Type', 'application/xml');
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::setBucketLogging({$bucket}, {$uri}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Get logging status for a bucket
*
* This will return false if logging is not enabled.
* Note: To enable logging, you also need to grant write access to the log group
*
* @param string $bucket Bucket name
* @return array | false
*/
public static function getBucketLogging($bucket)
{
$rest = new S3Request('GET', $bucket, '', self::$endpoint);
$rest->setParameter('logging', null);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::getBucketLogging({$bucket}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
if (!isset($rest->body->LoggingEnabled)) return false; // No logging
return array(
'targetBucket' => (string)$rest->body->LoggingEnabled->TargetBucket,
'targetPrefix' => (string)$rest->body->LoggingEnabled->TargetPrefix,
);
}
/**
* Disable bucket logging
*
* @param string $bucket Bucket name
* @return boolean
*/
public static function disableBucketLogging($bucket)
{
return self::setBucketLogging($bucket, null);
}
/**
* Get a bucket's location
*
* @param string $bucket Bucket name
* @return string | false
*/
public static function getBucketLocation($bucket)
{
$rest = new S3Request('GET', $bucket, '', self::$endpoint);
$rest->setParameter('location', null);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::getBucketLocation({$bucket}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return (isset($rest->body[0]) && (string)$rest->body[0] !== '') ? (string)$rest->body[0] : 'US';
}
/**
* Set object or bucket Access Control Policy
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param array $acp Access Control Policy Data (same as the data returned from getAccessControlPolicy)
* @return boolean
*/
public static function setAccessControlPolicy($bucket, $uri = '', $acp = array())
{
$dom = new DOMDocument;
$dom->formatOutput = true;
$accessControlPolicy = $dom->createElement('AccessControlPolicy');
$accessControlList = $dom->createElement('AccessControlList');
// It seems the owner has to be passed along too
$owner = $dom->createElement('Owner');
$owner->appendChild($dom->createElement('ID', $acp['owner']['id']));
$owner->appendChild($dom->createElement('DisplayName', $acp['owner']['name']));
$accessControlPolicy->appendChild($owner);
foreach ($acp['acl'] as $g)
{
$grant = $dom->createElement('Grant');
$grantee = $dom->createElement('Grantee');
$grantee->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
if (isset($g['id']))
{ // CanonicalUser (DisplayName is omitted)
$grantee->setAttribute('xsi:type', 'CanonicalUser');
$grantee->appendChild($dom->createElement('ID', $g['id']));
}
elseif (isset($g['email']))
{ // AmazonCustomerByEmail
$grantee->setAttribute('xsi:type', 'AmazonCustomerByEmail');
$grantee->appendChild($dom->createElement('EmailAddress', $g['email']));
}
elseif ($g['type'] == 'Group')
{ // Group
$grantee->setAttribute('xsi:type', 'Group');
$grantee->appendChild($dom->createElement('URI', $g['uri']));
}
$grant->appendChild($grantee);
$grant->appendChild($dom->createElement('Permission', $g['permission']));
$accessControlList->appendChild($grant);
}
$accessControlPolicy->appendChild($accessControlList);
$dom->appendChild($accessControlPolicy);
$rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
$rest->setParameter('acl', null);
$rest->data = $dom->saveXML();
$rest->size = strlen($rest->data);
$rest->setHeader('Content-Type', 'application/xml');
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::setAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Get object or bucket Access Control Policy
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @return mixed | false
*/
public static function getAccessControlPolicy($bucket, $uri = '')
{
$rest = new S3Request('GET', $bucket, $uri, self::$endpoint);
$rest->setParameter('acl', null);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
$acp = array();
if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName))
$acp['owner'] = array(
'id' => (string)$rest->body->Owner->ID, 'name' => (string)$rest->body->Owner->DisplayName
);
if (isset($rest->body->AccessControlList))
{
$acp['acl'] = array();
foreach ($rest->body->AccessControlList->Grant as $grant)
{
foreach ($grant->Grantee as $grantee)
{
if (isset($grantee->ID, $grantee->DisplayName)) // CanonicalUser
$acp['acl'][] = array(
'type' => 'CanonicalUser',
'id' => (string)$grantee->ID,
'name' => (string)$grantee->DisplayName,
'permission' => (string)$grant->Permission
);
elseif (isset($grantee->EmailAddress)) // AmazonCustomerByEmail
$acp['acl'][] = array(
'type' => 'AmazonCustomerByEmail',
'email' => (string)$grantee->EmailAddress,
'permission' => (string)$grant->Permission
);
elseif (isset($grantee->URI)) // Group
$acp['acl'][] = array(
'type' => 'Group',
'uri' => (string)$grantee->URI,
'permission' => (string)$grant->Permission
);
else continue;
}
}
}
return $acp;
}
/**
* Delete an object
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @return boolean
*/
public static function deleteObject($bucket, $uri)
{
$rest = new S3Request('DELETE', $bucket, $uri, self::$endpoint);
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 204)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::deleteObject(): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Get a query string authenticated URL
*
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param integer $lifetime Lifetime in seconds
* @param boolean $hostBucket Use the bucket name as the hostname
* @param boolean $https Use HTTPS ($hostBucket should be false for SSL verification)
* @return string
*/
public static function getAuthenticatedURL($bucket, $uri, $lifetime, $hostBucket = false, $https = false)
{
$expires = time() + $lifetime;
$uri = str_replace(array('%2F', '%2B'), array('/', '+'), rawurlencode($uri)); // URI should be encoded (thanks Sean O'Dea)
return sprintf(($https ? 'https' : 'http').'://%s/%s?AWSAccessKeyId=%s&Expires=%u&Signature=%s',
// $hostBucket ? $bucket : $bucket.'.s3.amazonaws.com', $uri, self::$__accessKey, $expires,
$hostBucket ? $bucket : 's3.amazonaws.com/'.$bucket, $uri, self::$__accessKey, $expires,
urlencode(self::__getHash("GET\n\n\n{$expires}\n/{$bucket}/{$uri}")));
}
/**
* Get a CloudFront signed policy URL
*
* @param array $policy Policy
* @return string
*/
public static function getSignedPolicyURL($policy)
{
$data = json_encode($policy);
$signature = '';
if (!openssl_sign($data, $signature, self::$__signingKeyResource)) return false;
$encoded = str_replace(array('+', '='), array('-', '_', '~'), base64_encode($data));
$signature = str_replace(array('+', '='), array('-', '_', '~'), base64_encode($signature));
$url = $policy['Statement'][0]['Resource'] . '?';
foreach (array('Policy' => $encoded, 'Signature' => $signature, 'Key-Pair-Id' => self::$__signingKeyPairId) as $k => $v)
$url .= $k.'='.str_replace('%2F', '/', rawurlencode($v)).'&';
return substr($url, 0, -1);
}
/**
* Get a CloudFront canned policy URL
*
* @param string $string URL to sign
* @param integer $lifetime URL lifetime
* @return string
*/
public static function getSignedCannedURL($url, $lifetime)
{
return self::getSignedPolicyURL(array(
'Statement' => array(
array('Resource' => $url, 'Condition' => array(
'DateLessThan' => array('AWS:EpochTime' => time() + $lifetime)
))
)
));
}
/**
* Get upload POST parameters for form uploads
*
* @param string $bucket Bucket name
* @param string $uriPrefix Object URI prefix
* @param constant $acl ACL constant
* @param integer $lifetime Lifetime in seconds
* @param integer $maxFileSize Maximum filesize in bytes (default 5MB)
* @param string $successRedirect Redirect URL or 200 / 201 status code
* @param array $amzHeaders Array of x-amz-meta-* headers
* @param array $headers Array of request headers or content type as a string
* @param boolean $flashVars Includes additional "Filename" variable posted by Flash
* @return object
*/
public static function getHttpUploadPostParams($bucket, $uriPrefix = '', $acl = self::ACL_PRIVATE, $lifetime = 3600,
$maxFileSize = 5242880, $successRedirect = "201", $amzHeaders = array(), $headers = array(), $flashVars = false)
{
// Create policy object
$policy = new stdClass;
$policy->expiration = gmdate('Y-m-d\TH:i:s\Z', (time() + $lifetime));
$policy->conditions = array();
$obj = new stdClass; $obj->bucket = $bucket; array_push($policy->conditions, $obj);
$obj = new stdClass; $obj->acl = $acl; array_push($policy->conditions, $obj);
$obj = new stdClass; // 200 for non-redirect uploads
if (is_numeric($successRedirect) && in_array((int)$successRedirect, array(200, 201)))
$obj->success_action_status = (string)$successRedirect;
else // URL
$obj->success_action_redirect = $successRedirect;
array_push($policy->conditions, $obj);
if ($acl !== self::ACL_PUBLIC_READ)
array_push($policy->conditions, array('eq', '$acl', $acl));
array_push($policy->conditions, array('starts-with', '$key', $uriPrefix));
if ($flashVars) array_push($policy->conditions, array('starts-with', '$Filename', ''));
foreach (array_keys($headers) as $headerKey)
array_push($policy->conditions, array('starts-with', '$'.$headerKey, ''));
foreach ($amzHeaders as $headerKey => $headerVal)
{
$obj = new stdClass;
$obj->{$headerKey} = (string)$headerVal;
array_push($policy->conditions, $obj);
}
array_push($policy->conditions, array('content-length-range', 0, $maxFileSize));
$policy = base64_encode(str_replace('\/', '/', json_encode($policy)));
// Create parameters
$params = new stdClass;
$params->AWSAccessKeyId = self::$__accessKey;
$params->key = $uriPrefix.'${filename}';
$params->acl = $acl;
$params->policy = $policy; unset($policy);
$params->signature = self::__getHash($params->policy);
if (is_numeric($successRedirect) && in_array((int)$successRedirect, array(200, 201)))
$params->success_action_status = (string)$successRedirect;
else
$params->success_action_redirect = $successRedirect;
foreach ($headers as $headerKey => $headerVal) $params->{$headerKey} = (string)$headerVal;
foreach ($amzHeaders as $headerKey => $headerVal) $params->{$headerKey} = (string)$headerVal;
return $params;
}
/**
* Create a CloudFront distribution
*
* @param string $bucket Bucket name
* @param boolean $enabled Enabled (true/false)
* @param array $cnames Array containing CNAME aliases
* @param string $comment Use the bucket name as the hostname
* @param string $defaultRootObject Default root object
* @param string $originAccessIdentity Origin access identity
* @param array $trustedSigners Array of trusted signers
* @return array | false
*/
public static function createDistribution($bucket, $enabled = true, $cnames = array(), $comment = null, $defaultRootObject = null, $originAccessIdentity = null, $trustedSigners = array())
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::createDistribution({$bucket}, ".(int)$enabled.", [], '$comment'): %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
$useSSL = self::$useSSL;
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('POST', '', '2010-11-01/distribution', 'cloudfront.amazonaws.com');
$rest->data = self::__getCloudFrontDistributionConfigXML(
$bucket.'.s3.amazonaws.com',
$enabled,
(string)$comment,
(string)microtime(true),
$cnames,
$defaultRootObject,
$originAccessIdentity,
$trustedSigners
);
$rest->size = strlen($rest->data);
$rest->setHeader('Content-Type', 'application/xml');
$rest = self::__getCloudFrontResponse($rest);
self::$useSSL = $useSSL;
if ($rest->error === false && $rest->code !== 201)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::createDistribution({$bucket}, ".(int)$enabled.", [], '$comment'): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
} elseif ($rest->body instanceof SimpleXMLElement)
return self::__parseCloudFrontDistributionConfig($rest->body);
return false;
}
/**
* Get CloudFront distribution info
*
* @param string $distributionId Distribution ID from listDistributions()
* @return array | false
*/
public static function getDistribution($distributionId)
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::getDistribution($distributionId): %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
$useSSL = self::$useSSL;
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('GET', '', '2010-11-01/distribution/'.$distributionId, 'cloudfront.amazonaws.com');
$rest = self::__getCloudFrontResponse($rest);
self::$useSSL = $useSSL;
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::getDistribution($distributionId): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
elseif ($rest->body instanceof SimpleXMLElement)
{
$dist = self::__parseCloudFrontDistributionConfig($rest->body);
$dist['hash'] = $rest->headers['hash'];
$dist['id'] = $distributionId;
return $dist;
}
return false;
}
/**
* Update a CloudFront distribution
*
* @param array $dist Distribution array info identical to output of getDistribution()
* @return array | false
*/
public static function updateDistribution($dist)
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::updateDistribution({$dist['id']}): %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
$useSSL = self::$useSSL;
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('PUT', '', '2010-11-01/distribution/'.$dist['id'].'/config', 'cloudfront.amazonaws.com');
$rest->data = self::__getCloudFrontDistributionConfigXML(
$dist['origin'],
$dist['enabled'],
$dist['comment'],
$dist['callerReference'],
$dist['cnames'],
$dist['defaultRootObject'],
$dist['originAccessIdentity'],
$dist['trustedSigners']
);
$rest->size = strlen($rest->data);
$rest->setHeader('If-Match', $dist['hash']);
$rest = self::__getCloudFrontResponse($rest);
self::$useSSL = $useSSL;
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::updateDistribution({$dist['id']}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
} else {
$dist = self::__parseCloudFrontDistributionConfig($rest->body);
$dist['hash'] = $rest->headers['hash'];
return $dist;
}
return false;
}
/**
* Delete a CloudFront distribution
*
* @param array $dist Distribution array info identical to output of getDistribution()
* @return boolean
*/
public static function deleteDistribution($dist)
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::deleteDistribution({$dist['id']}): %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
$useSSL = self::$useSSL;
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('DELETE', '', '2008-06-30/distribution/'.$dist['id'], 'cloudfront.amazonaws.com');
$rest->setHeader('If-Match', $dist['hash']);
$rest = self::__getCloudFrontResponse($rest);
self::$useSSL = $useSSL;
if ($rest->error === false && $rest->code !== 204)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::deleteDistribution({$dist['id']}): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
return true;
}
/**
* Get a list of CloudFront distributions
*
* @return array
*/
public static function listDistributions()
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::listDistributions(): [%s] %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
$useSSL = self::$useSSL;
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('GET', '', '2010-11-01/distribution', 'cloudfront.amazonaws.com');
$rest = self::__getCloudFrontResponse($rest);
self::$useSSL = $useSSL;
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
self::__triggerError(sprintf("S3::listDistributions(): [%s] %s",
$rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
return false;
}
elseif ($rest->body instanceof SimpleXMLElement && isset($rest->body->DistributionSummary))
{
$list = array();
if (isset($rest->body->Marker, $rest->body->MaxItems, $rest->body->IsTruncated))
{
//$info['marker'] = (string)$rest->body->Marker;
//$info['maxItems'] = (int)$rest->body->MaxItems;
//$info['isTruncated'] = (string)$rest->body->IsTruncated == 'true' ? true : false;
}
foreach ($rest->body->DistributionSummary as $summary)
$list[(string)$summary->Id] = self::__parseCloudFrontDistributionConfig($summary);
return $list;
}
return array();
}
/**
* List CloudFront Origin Access Identities
*
* @return array
*/
public static function listOriginAccessIdentities()
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::listOriginAccessIdentities(): [%s] %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('GET', '', '2010-11-01/origin-access-identity/cloudfront', 'cloudfront.amazonaws.com');
$rest = self::__getCloudFrontResponse($rest);
$useSSL = self::$useSSL;
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
trigger_error(sprintf("S3::listOriginAccessIdentities(): [%s] %s",
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
return false;
}
if (isset($rest->body->CloudFrontOriginAccessIdentitySummary))
{
$identities = array();
foreach ($rest->body->CloudFrontOriginAccessIdentitySummary as $identity)
if (isset($identity->S3CanonicalUserId))
$identities[(string)$identity->Id] = array('id' => (string)$identity->Id, 's3CanonicalUserId' => (string)$identity->S3CanonicalUserId);
return $identities;
}
return false;
}
/**
* Invalidate objects in a CloudFront distribution
*
* Thanks to Martin Lindkvist for S3::invalidateDistribution()
*
* @param string $distributionId Distribution ID from listDistributions()
* @param array $paths Array of object paths to invalidate
* @return boolean
*/
public static function invalidateDistribution($distributionId, $paths)
{
if (!extension_loaded('openssl'))
{
self::__triggerError(sprintf("S3::invalidateDistribution(): [%s] %s",
"CloudFront functionality requires SSL"), __FILE__, __LINE__);
return false;
}
$useSSL = self::$useSSL;
self::$useSSL = true; // CloudFront requires SSL
$rest = new S3Request('POST', '', '2010-08-01/distribution/'.$distributionId.'/invalidation', 'cloudfront.amazonaws.com');
$rest->data = self::__getCloudFrontInvalidationBatchXML($paths, (string)microtime(true));
$rest->size = strlen($rest->data);
$rest = self::__getCloudFrontResponse($rest);
self::$useSSL = $useSSL;
if ($rest->error === false && $rest->code !== 201)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false)
{
trigger_error(sprintf("S3::invalidate('{$distributionId}',{$paths}): [%s] %s",
$rest->error['code'], $rest->error['message']), E_USER_WARNING);
return false;
}
return true;
}
/**
* Get a InvalidationBatch DOMDocument
*
* @internal Used to create XML in invalidateDistribution()
* @param array $paths Paths to objects to invalidateDistribution
* @return string
*/
private static function __getCloudFrontInvalidationBatchXML($paths, $callerReference = '0') {
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$invalidationBatch = $dom->createElement('InvalidationBatch');
foreach ($paths as $path)
$invalidationBatch->appendChild($dom->createElement('Path', $path));
$invalidationBatch->appendChild($dom->createElement('CallerReference', $callerReference));
$dom->appendChild($invalidationBatch);
return $dom->saveXML();
}
/**
* Get a DistributionConfig DOMDocument
*
* http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/index.html?PutConfig.html
*
* @internal Used to create XML in createDistribution() and updateDistribution()
* @param string $bucket S3 Origin bucket
* @param boolean $enabled Enabled (true/false)
* @param string $comment Comment to append
* @param string $callerReference Caller reference
* @param array $cnames Array of CNAME aliases
* @param string $defaultRootObject Default root object
* @param string $originAccessIdentity Origin access identity
* @param array $trustedSigners Array of trusted signers
* @return string
*/
private static function __getCloudFrontDistributionConfigXML($bucket, $enabled, $comment, $callerReference = '0', $cnames = array(), $defaultRootObject = null, $originAccessIdentity = null, $trustedSigners = array())
{
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$distributionConfig = $dom->createElement('DistributionConfig');
$distributionConfig->setAttribute('xmlns', 'http://cloudfront.amazonaws.com/doc/2010-11-01/');
$origin = $dom->createElement('S3Origin');
$origin->appendChild($dom->createElement('DNSName', $bucket));
if ($originAccessIdentity !== null) $origin->appendChild($dom->createElement('OriginAccessIdentity', $originAccessIdentity));
$distributionConfig->appendChild($origin);
if ($defaultRootObject !== null) $distributionConfig->appendChild($dom->createElement('DefaultRootObject', $defaultRootObject));
$distributionConfig->appendChild($dom->createElement('CallerReference', $callerReference));
foreach ($cnames as $cname)
$distributionConfig->appendChild($dom->createElement('CNAME', $cname));
if ($comment !== '') $distributionConfig->appendChild($dom->createElement('Comment', $comment));
$distributionConfig->appendChild($dom->createElement('Enabled', $enabled ? 'true' : 'false'));
$trusted = $dom->createElement('TrustedSigners');
foreach ($trustedSigners as $id => $type)
$trusted->appendChild($id !== '' ? $dom->createElement($type, $id) : $dom->createElement($type));
$distributionConfig->appendChild($trusted);
$dom->appendChild($distributionConfig);
//var_dump($dom->saveXML());
return $dom->saveXML();
}
/**
* Parse a CloudFront distribution config
*
* See http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/index.html?GetDistribution.html
*
* @internal Used to parse the CloudFront DistributionConfig node to an array
* @param object &$node DOMNode
* @return array
*/
private static function __parseCloudFrontDistributionConfig(&$node)
{
if (isset($node->DistributionConfig))
return self::__parseCloudFrontDistributionConfig($node->DistributionConfig);
$dist = array();
if (isset($node->Id, $node->Status, $node->LastModifiedTime, $node->DomainName))
{
$dist['id'] = (string)$node->Id;
$dist['status'] = (string)$node->Status;
$dist['time'] = strtotime((string)$node->LastModifiedTime);
$dist['domain'] = (string)$node->DomainName;
}
if (isset($node->CallerReference))
$dist['callerReference'] = (string)$node->CallerReference;
if (isset($node->Enabled))
$dist['enabled'] = (string)$node->Enabled == 'true' ? true : false;
if (isset($node->S3Origin))
{
if (isset($node->S3Origin->DNSName))
$dist['origin'] = (string)$node->S3Origin->DNSName;
$dist['originAccessIdentity'] = isset($node->S3Origin->OriginAccessIdentity) ?
(string)$node->S3Origin->OriginAccessIdentity : null;
}
$dist['defaultRootObject'] = isset($node->DefaultRootObject) ? (string)$node->DefaultRootObject : null;
$dist['cnames'] = array();
if (isset($node->CNAME))
foreach ($node->CNAME as $cname)
$dist['cnames'][(string)$cname] = (string)$cname;
$dist['trustedSigners'] = array();
if (isset($node->TrustedSigners))
foreach ($node->TrustedSigners as $signer)
{
if (isset($signer->Self))
$dist['trustedSigners'][''] = 'Self';
elseif (isset($signer->KeyPairId))
$dist['trustedSigners'][(string)$signer->KeyPairId] = 'KeyPairId';
elseif (isset($signer->AwsAccountNumber))
$dist['trustedSigners'][(string)$signer->AwsAccountNumber] = 'AwsAccountNumber';
}
$dist['comment'] = isset($node->Comment) ? (string)$node->Comment : null;
return $dist;
}
/**
* Grab CloudFront response
*
* @internal Used to parse the CloudFront S3Request::getResponse() output
* @param object &$rest S3Request instance
* @return object
*/
private static function __getCloudFrontResponse(&$rest)
{
$rest->getResponse();
if ($rest->response->error === false && isset($rest->response->body) &&
is_string($rest->response->body) && substr($rest->response->body, 0, 5) == '<?xml')
{
$rest->response->body = simplexml_load_string($rest->response->body);
// Grab CloudFront errors
if (isset($rest->response->body->Error, $rest->response->body->Error->Code,
$rest->response->body->Error->Message))
{
$rest->response->error = array(
'code' => (string)$rest->response->body->Error->Code,
'message' => (string)$rest->response->body->Error->Message
);
unset($rest->response->body);
}
}
return $rest->response;
}
/**
* Get MIME type for file
*
* @internal Used to get mime types
* @param string &$file File path
* @return string
*/
public static function __getMimeType(&$file)
{
$type = false;
// Fileinfo documentation says fileinfo_open() will use the
// MAGIC env var for the magic file
if (extension_loaded('fileinfo') && isset($_ENV['MAGIC']) &&
($finfo = finfo_open(FILEINFO_MIME, $_ENV['MAGIC'])) !== false)
{
if (($type = finfo_file($finfo, $file)) !== false)
{
// Remove the charset and grab the last content-type
$type = explode(' ', str_replace('; charset=', ';charset=', $type));
$type = array_pop($type);
$type = explode(';', $type);
$type = trim(array_shift($type));
}
finfo_close($finfo);
// If anyone is still using mime_content_type()
} elseif (function_exists('mime_content_type'))
$type = trim(mime_content_type($file));
if ($type !== false && strlen($type) > 0) return $type;
// Otherwise do it the old fashioned way
static $exts = array(
'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png',
'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'ico' => 'image/x-icon',
'swf' => 'application/x-shockwave-flash', 'pdf' => 'application/pdf',
'zip' => 'application/zip', 'gz' => 'application/x-gzip',
'tar' => 'application/x-tar', 'bz' => 'application/x-bzip',
'bz2' => 'application/x-bzip2', 'txt' => 'text/plain',
'asc' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html',
'css' => 'text/css', 'js' => 'text/javascript',
'xml' => 'text/xml', 'xsl' => 'application/xsl+xml',
'ogg' => 'application/ogg', 'mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav',
'avi' => 'video/x-msvideo', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg',
'mov' => 'video/quicktime', 'flv' => 'video/x-flv', 'php' => 'text/x-php'
);
$ext = strtolower(pathInfo($file, PATHINFO_EXTENSION));
return isset($exts[$ext]) ? $exts[$ext] : 'application/octet-stream';
}
/**
* Generate the auth string: "AWS AccessKey:Signature"
*
* @internal Used by S3Request::getResponse()
* @param string $string String to sign
* @return string
*/
public static function __getSignature($string)
{
return 'AWS '.self::$__accessKey.':'.self::__getHash($string);
}
/**
* Creates a HMAC-SHA1 hash
*
* This uses the hash extension if loaded
*
* @internal Used by __getSignature()
* @param string $string String to sign
* @return string
*/
private static function __getHash($string)
{
return base64_encode(extension_loaded('hash') ?
hash_hmac('sha1', $string, self::$__secretKey, true) : pack('H*', sha1(
(str_pad(self::$__secretKey, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) .
pack('H*', sha1((str_pad(self::$__secretKey, 64, chr(0x00)) ^
(str_repeat(chr(0x36), 64))) . $string)))));
}
}
final class S3Request
{
private $endpoint, $verb, $bucket, $uri, $resource = '', $parameters = array(),
$amzHeaders = array(), $headers = array(
'Host' => '', 'Date' => '', 'Content-MD5' => '', 'Content-Type' => ''
);
public $fp = false, $size = 0, $data = false, $response;
/**
* Constructor
*
* @param string $verb Verb
* @param string $bucket Bucket name
* @param string $uri Object URI
* @return mixed
*/
function __construct($verb, $bucket = '', $uri = '', $endpoint = 's3.amazonaws.com')
{
$this->endpoint = $endpoint;
$this->verb = $verb;
$this->bucket = $bucket;
$this->uri = $uri !== '' ? '/'.str_replace('%2F', '/', rawurlencode($uri)) : '/';
//if ($this->bucket !== '')
// $this->resource = '/'.$this->bucket.$this->uri;
//else
// $this->resource = $this->uri;
if ($this->bucket !== '')
{
if ($this->__dnsBucketName($this->bucket))
{
$this->headers['Host'] = $this->bucket.'.'.$this->endpoint;
$this->resource = '/'.$this->bucket.$this->uri;
}
else
{
$this->headers['Host'] = $this->endpoint;
$this->uri = $this->uri;
if ($this->bucket !== '') $this->uri = '/'.$this->bucket.$this->uri;
$this->bucket = '';
$this->resource = $this->uri;
}
}
else
{
$this->headers['Host'] = $this->endpoint;
$this->resource = $this->uri;
}
$this->headers['Date'] = gmdate('D, d M Y H:i:s T');
$this->response = new STDClass;
$this->response->error = false;
}
/**
* Set request parameter
*
* @param string $key Key
* @param string $value Value
* @return void
*/
public function setParameter($key, $value)
{
$this->parameters[$key] = $value;
}
/**
* Set request header
*
* @param string $key Key
* @param string $value Value
* @return void
*/
public function setHeader($key, $value)
{
$this->headers[$key] = $value;
}
/**
* Set x-amz-meta-* header
*
* @param string $key Key
* @param string $value Value
* @return void
*/
public function setAmzHeader($key, $value)
{
$this->amzHeaders[$key] = $value;
}
/**
* Get the S3 response
*
* @return object | false
*/
public function getResponse()
{
$query = '';
if (sizeof($this->parameters) > 0)
{
$query = substr($this->uri, -1) !== '?' ? '?' : '&';
foreach ($this->parameters as $var => $value)
if ($value == null || $value == '') $query .= $var.'&';
// Parameters should be encoded (thanks Sean O'Dea)
else $query .= $var.'='.rawurlencode($value).'&';
$query = substr($query, 0, -1);
$this->uri .= $query;
if (array_key_exists('acl', $this->parameters) ||
array_key_exists('location', $this->parameters) ||
array_key_exists('torrent', $this->parameters) ||
array_key_exists('website', $this->parameters) ||
array_key_exists('logging', $this->parameters))
$this->resource .= $query;
}
$url = (S3::$useSSL ? 'https://' : 'http://') . ($this->headers['Host'] !== '' ? $this->headers['Host'] : $this->endpoint) . $this->uri;
//var_dump('bucket: ' . $this->bucket, 'uri: ' . $this->uri, 'resource: ' . $this->resource, 'url: ' . $url);
// Basic setup
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');
if (S3::$useSSL)
{
// SSL Validation can now be optional for those with broken OpenSSL installations
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, S3::$useSSLValidation ? 1 : 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, S3::$useSSLValidation ? 1 : 0);
if (S3::$sslKey !== null) curl_setopt($curl, CURLOPT_SSLKEY, S3::$sslKey);
if (S3::$sslCert !== null) curl_setopt($curl, CURLOPT_SSLCERT, S3::$sslCert);
if (S3::$sslCACert !== null) curl_setopt($curl, CURLOPT_CAINFO, S3::$sslCACert);
}
curl_setopt($curl, CURLOPT_URL, $url);
if (S3::$proxy != null && isset(S3::$proxy['host']))
{
curl_setopt($curl, CURLOPT_PROXY, S3::$proxy['host']);
curl_setopt($curl, CURLOPT_PROXYTYPE, S3::$proxy['type']);
if (isset(S3::$proxy['user'], S3::$proxy['pass']) && $proxy['user'] != null && $proxy['pass'] != null)
curl_setopt($curl, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', S3::$proxy['user'], S3::$proxy['pass']));
}
// Headers
$headers = array(); $amz = array();
foreach ($this->amzHeaders as $header => $value)
if (strlen($value) > 0) $headers[] = $header.': '.$value;
foreach ($this->headers as $header => $value)
if (strlen($value) > 0) $headers[] = $header.': '.$value;
// Collect AMZ headers for signature
foreach ($this->amzHeaders as $header => $value)
if (strlen($value) > 0) $amz[] = strtolower($header).':'.$value;
// AMZ headers must be sorted
if (sizeof($amz) > 0)
{
sort($amz);
$amz = "\n".implode("\n", $amz);
} else $amz = '';
if (S3::hasAuth())
{
// Authorization string (CloudFront stringToSign should only contain a date)
if ($this->headers['Host'] == 'cloudfront.amazonaws.com')
$headers[] = 'Authorization: ' . S3::__getSignature($this->headers['Date']);
else
{
$headers[] = 'Authorization: ' . S3::__getSignature(
$this->verb."\n".
$this->headers['Content-MD5']."\n".
$this->headers['Content-Type']."\n".
$this->headers['Date'].$amz."\n".
$this->resource
);
}
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__responseWriteCallback'));
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this, '__responseHeaderCallback'));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
// Request types
switch ($this->verb)
{
case 'GET': break;
case 'PUT': case 'POST': // POST only used for CloudFront
if ($this->fp !== false)
{
curl_setopt($curl, CURLOPT_PUT, true);
curl_setopt($curl, CURLOPT_INFILE, $this->fp);
if ($this->size >= 0)
curl_setopt($curl, CURLOPT_INFILESIZE, $this->size);
}
elseif ($this->data !== false)
{
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
curl_setopt($curl, CURLOPT_POSTFIELDS, $this->data);
}
else
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
break;
case 'HEAD':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD');
curl_setopt($curl, CURLOPT_NOBODY, true);
break;
case 'DELETE':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
default: break;
}
// Execute, grab errors
if (curl_exec($curl))
$this->response->code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
else
$this->response->error = array(
'code' => curl_errno($curl),
'message' => curl_error($curl),
'resource' => $this->resource
);
@curl_close($curl);
// Parse body into XML
if ($this->response->error === false && isset($this->response->headers['type']) &&
$this->response->headers['type'] == 'application/xml' && isset($this->response->body))
{
$this->response->body = simplexml_load_string($this->response->body);
// Grab S3 errors
if (!in_array($this->response->code, array(200, 204, 206)) &&
isset($this->response->body->Code, $this->response->body->Message))
{
$this->response->error = array(
'code' => (string)$this->response->body->Code,
'message' => (string)$this->response->body->Message
);
if (isset($this->response->body->Resource))
$this->response->error['resource'] = (string)$this->response->body->Resource;
unset($this->response->body);
}
}
// Clean up file resources
if ($this->fp !== false && is_resource($this->fp)) fclose($this->fp);
return $this->response;
}
/**
* CURL write callback
*
* @param resource &$curl CURL resource
* @param string &$data Data
* @return integer
*/
private function __responseWriteCallback(&$curl, &$data)
{
if (in_array($this->response->code, array(200, 206)) && $this->fp !== false)
return fwrite($this->fp, $data);
else
$this->response->body .= $data;
return strlen($data);
}
/**
* Check DNS conformity
*
* @param string $bucket Bucket name
* @return boolean
*/
private function __dnsBucketName($bucket)
{
if (strlen($bucket) > 63 || !preg_match("/[^a-z0-9\.-]/", $bucket)) return false;
if (strstr($bucket, '-.') !== false) return false;
if (strstr($bucket, '..') !== false) return false;
if (!preg_match("/^[0-9a-z]/", $bucket)) return false;
if (!preg_match("/[0-9a-z]$/", $bucket)) return false;
return true;
}
/**
* CURL header callback
*
* @param resource &$curl CURL resource
* @param string &$data Data
* @return integer
*/
private function __responseHeaderCallback(&$curl, &$data)
{
if (($strlen = strlen($data)) <= 2) return $strlen;
if (substr($data, 0, 4) == 'HTTP')
$this->response->code = (int)substr($data, 9, 3);
else
{
$data = trim($data);
if (strpos($data, ': ') === false) return $strlen;
list($header, $value) = explode(': ', $data, 2);
if ($header == 'Last-Modified')
$this->response->headers['time'] = strtotime($value);
elseif ($header == 'Content-Length')
$this->response->headers['size'] = (int)$value;
elseif ($header == 'Content-Type')
$this->response->headers['type'] = $value;
elseif ($header == 'ETag')
$this->response->headers['hash'] = $value{0} == '"' ? substr($value, 1, -1) : $value;
elseif (preg_match('/^x-amz-meta-.*$/', $header))
$this->response->headers[$header] = is_numeric($value) ? (int)$value : $value;
}
return $strlen;
}
}
class S3Exception extends Exception {
function __construct($message, $file, $line, $code = 0)
{
parent::__construct($message, $code);
$this->file = $file;
$this->line = $line;
}
} | 101-code | application/libraries/asset_manager/am_cdn/am_cdn_amazon/s3.php | PHP | gpl3 | 65,363 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Single Query Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
require_once(APPPATH.'libraries/asset_manager/Am_single_query.php');
class Am_single_query_output extends Am_single_query{
/**
* $output
*
* Page output for returning once manipulated by the library
*
* @access public //TODO why is this public? Should be protected for later classes possibly?
* @var string
*/
public $output = '';
public function __construct()
{
$this->CI =& get_instance();
$this->output = $this->CI->output->get_output();
}
/**
* Process Output
*
* Using the output provided, most probably in a MY_Output class, we shall go through the files and id's that are
* set in the views or controllers/models and replace the unique identifiers with the correct db entry, or process
* the entries by getting the DB entries or pushing them out to be processed by the handler to the CDN/base64
*
* @access public
* @since 2012-06-08
* @param string $output
* @return string $output
*/
public function process_output()
{
// If the single query config setting is on, let's go for it
if (! $this->CI->config->item('query', 'asset_manager') == 'single')
{
// It's off, just return the output, don't do anything here
return $this->output;
}
// Get the existing Single Query object
$object = $this->CI->load->is_loaded('am_single_query');
// Check the object exists, and that it has asset information
if (isset($this->CI->$object) && is_object($this->CI->$object) && ! empty($this->CI->$object->_page_assets))
{
// Use the object to create a database result object for processing
$db_assets = $this->get_db_assets($this->CI->$object->_page_assets);
// Now, cross reference the page_assets to the database assets, see what's left over so we can process those
$left_overs = $db_assets->num_rows ? $this->replace_output($this->CI->$object->_page_assets,
$db_assets->result_array()) : $this->CI->$object->_page_assets;
// If we have any left_overs, let's process them and get them in the db
$left_overs ? $this->eat_leftovers($left_overs) : NULL;
}
else
{
// Oops, there is no single query object?
log_message('error', "[ASSETS] There is no single_query object to reference");
}
return $this->output;
}
/**
* Get DB Assets
*
* Gets the assests from the database, doesn't need much description.
*
* @access private
* @since 2012-06-08
* @param object $page_assets
* @return CI_DB_active_record
*/
private function get_db_assets($page_assets)
{
// Start a query, we'll need the id, base64, cdn, file and group from the assets table
$this->CI->db->select('id, base64, cdn, file, group, filesize, filetype')
->from($this->CI->config->item('asset_table', 'asset_manager'));
// Go through the assets and build up a nice query
foreach ($page_assets as $asset)
{
is_array($asset) ? $this->CI->db->or_where("(`file` = '${asset[0]}'".($asset[1] ? " AND `group` = ".
"${asset[1]}" : NULL ). ")") : $ids[] = $asset;
}
// If there are some ids, this is the most efficient query, what we want users to do ideally, do a where in
isset($ids) ? $this->CI->db->where_in('id', $ids) : NULL;
// return the database object
return $this->CI->db->get();
}
/**
* Eat Leftovers
*
* Takes all the leftover assets that aren't in the database and tries to process them through
*
* @access private
* @since 2012-06-08
* @param array $assets
* @reutrn void
*/
private function eat_leftovers($leftovers)
{
// go through the left over assets that aren't in the database and process them
foreach ($leftovers as $key => $leftover)
{
// Send the two bits of information to the parent handler
if ($data = $this->process_asset($leftover[0], $leftover[1]))
{
// Now update the output with the asset data and the key
$this->update_output($data, $key);
}
else
{
// Oh no! Something's gone wrong there, let's just process with the original data for now
log_message('error', "[ASSETS SINGLE_QUERY_OUTPUT] Processing the asset has failed");
$this->update_output($leftover[0], $key);
}
}
}
/**
* Replace output
*
* Cross references the page assets against the database assets. If the asset is in the database, it will process
* that and remove it from the array ready to return to the eat leftovers function.
*
* @access private
* @since 2012-06-08
* @param array $page_assets
* @param object $db_assets
* @return object
*/
private function replace_output($page_assets, $db_assets)
{
// Go through each of the params detailed in $object and see if they're in the database object
foreach ($page_assets as $page_asset_key => $page_asset_data)
{
foreach ($db_assets as $db_asset)
{
// Is the $page_asset_data an array AND the database record file equals the page_asset_data OR
// if the $page_asset_data is an integer and the page asset id matches the database id, then carry on
if ((is_array($page_asset_data) && $db_asset['file'] === $page_asset_data[0] &&
$db_asset['group'] == $page_asset_data[1]) ||
(is_int($page_asset_data) && $db_asset['id ']=== $page_asset_data))
{
// We need to check each asset to make sure it doesn't need updating...
$db_asset = $this->check_asset($db_asset);
// Replace the unique key with the database data in the output
$this->update_output($db_asset, $page_asset_key);
// Now take it out of the object, should make things faster
unset($page_assets[$page_asset_key]);
}
}
}
// Return what's left
return $page_assets;
}
/**
* Update Output
*
* Takes the asset and updates the output depending upon what state the asset is in. If it's a base64, it will
* use that, if it's a cdn file, it will turn it into a cdn_url and use that, otherwise, it'll just use the
* original file
*
* @access private
* @since 2012-06-08
* @param array $data
* @param string $key
* @return void
*/
private function update_output($asset, $key)
{
// Read the asset information and work out what we're doing with it...
$src = $this->single_asset_src($asset);
// How did we get on?
if (! $src)
{
// Bugger, somethings gone wrong...
log_message('error', "[ASSETS SINGLE_QUERY] There is something wrong with the asset data passed to ".
"udpate_output key: [$key], data is [".var_export($asset, TRUE)."]");
$src = '';
}
// search and replace the output
$this->output = preg_replace('/'.$key.'/', $src, $this->output);
}
}
| 101-code | application/libraries/asset_manager/am_single_query/Am_single_query_output.php | PHP | gpl3 | 7,437 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Single Query Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
require_once(APPPATH.'libraries/assets/Am_optimize.php');
class Optimize_images extends Am_optimize {
private $_asset;
/**
* Constructor
*
* @access public
* @since 2012-05-22
* @return void
*/
public function __construct($asset)
{
parent::__construct($asset);
}
private function get_image_string($file)
{
return imagecreatefromstring(file_get_contents($this->get_absolute_location($file)));
}
public function optimize($quality = 90)
{
// Firstly, can we base64 this mother?
if ($this->CI->config->item('base64_limit', 'asset_manager') &&
$this->_asset['filesize'] <= $this->CI->config->item('base64_limit', 'asset_manager') &&
in_array(pathinfo($this->_asset['file'], PATHINFO_EXTENSION), array('jpg', 'gif', 'png')))
{
return $this->base64_asset($this->_asset);
}
// Check that the file isn't already compressed
if ($this->check_if_compressed($file))
{
return $asset;
}
// Get the new filename
$new_file = $this->get_optimized_filename($file);
// What's the current image string
$image_string = $this->get_image_string($file);
// Go through the different image files and optimize
switch (pathinfo(strtolower($asset['file']), PATHINFO_EXTENSION))
{
case 'jpg':
case 'jpeg':
imagejpeg($this->get_image_string($file), $this->get_absolute_location($new_file),
$this->CI->config->item('compress_images', 'assets'));
break;
case 'png':
imagepng($this->get_image_string($file), $this->get_absolute_location($new_file),
$this->CI->config->item('compress_images', 'assets'));
break;
case 'gif':
$im = new Imagick($image_string);
$im->optimizeImageLayers();
$im->writeimage($this->get_absolute_location($new_file));
break;
}
return $new_file;
}
/**
* Base64 Asset
*
* Simply converts the file to base64 and plonks that in the db
*
* @access private
* @since 2012-05-25
* @param array $asset
* @return void
*/
private function base64_asset($asset)
{
$asset['base64'] = "data:{$asset['filetype']};base64,".
base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/'.$asset['file']));
return $asset;
}
} | 101-code | application/libraries/asset_manager/am_optimize/Am_optimize_images.php | PHP | gpl3 | 3,101 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Single Query Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
class Am_optimize_html {
public function output($output)
{
return preg_replace(
'%# Collapse whitespace everywhere but in blacklisted elements.
(?> # Match all whitespans other than single space.
[^\S ]\s* # Either one [\t\r\n\f\v] and zero or more ws,
| \s{2,} # or two or more consecutive-any-whitespace.
) # Note: The remaining regex consumes no text at all...
(?= # Ensure we are not in a blacklist tag.
[^<]*+ # Either zero or more non-"<" {normal*}
(?: # Begin {(special normal*)*} construct
< # or a < starting a non-blacklist tag.
(?!/?(?:textarea|pre|script)\b)
[^<]*+ # more non-"<" {normal*}
)*+ # Finish "unrolling-the-loop"
(?: # Begin alternation group.
< # Either a blacklist start tag.
(?>textarea|pre|script)\b
| \z # or end of file.
) # End alternation group.
) # If we made it here, we are not in a blacklist tag.
%Six', " ", $output);
}
}
| 101-code | application/libraries/asset_manager/am_optimize/Am_optimize_html.php | PHP | gpl3 | 1,871 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Single Query Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
require_once(APPPATH.'libraries/Asset_manager.php');
class Am_single_query extends Asset_manager {
/**
* $_page_assets
*
* An array of page assets for processing later
*
* @access protcted
* @var array
*/
public $_page_assets = array();
/**
* Construct
*
* @access public
* @since 2012-06-09
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Do Work
*
* Replaces assets with unique codes in the output ready for processing later.
*
* @access public
* @since 2012-06-08
* @param mixed $param
* @param integer $group
* @return string $unique
*/
public function get_asset_src($param, $group = FALSE)
{
// Set a unique key which we can reference when we alter the output later
$unique = 'asset_'.mt_rand();
// If the $param is an integer and $group is false, then the asset is being called directly by it's id
$this->_page_assets[$unique] = (is_int($param) && ! $group) ? $param : array($param, $group);
// return the $unique identifier to put as a placeholder in the output
return $unique;
}
} | 101-code | application/libraries/asset_manager/Am_single_query.php | PHP | gpl3 | 2,030 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Optimize Library
*
* The Handler library deals with getting the information in and out of the
* CDN.
*
* @package Asset Manager
* @subpackage Optimize
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
abstract class Am_optimize {
protected $CI;
public function construct()
{
log_message('debug', '[ASSETS] Class initialized');
$this->CI =& get_instance();
}
protected function check_if_compressed($file)
{
// Check that the file isn't already compressed
return preg_match('/^\.compressed\./', pathinfo($asset['file'], PATHINFO_FILENAME));
}
protected function get_optimized_filename($file)
{
return pathinfo($asset['file'], PATHINFO_DIRNAME).'/'.pathinfo($asset['file'], PATHINFO_BASENAME).
'.optimized.'.pathinfo($asset['file'], PATHINFO_EXTENSION);
}
protected function get_absolute_location($file)
{
return $_SERVER['DOCUMENT_ROOT'].'/'.$file;
}
protected function get_file_type($file)
{
switch (pathinfo($file, PATHINFO_EXTENSION))
{
}
}
protected function queue($file)
{
}
protected function process($file)
{
}
private function base64($file)
{
}
} | 101-code | application/libraries/asset_manager/Am_optimize.php | PHP | gpl3 | 1,719 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Single Query Assets Library
*
* The Asset library simply checks the asset database and returns the asset location. If the asset
* is not in the database, then it calls the asset library and queues the asset for processing.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
require_once(APPPATH.'libraries/Asset_manager.php');
class Am_multiple_query extends Asset_manager {
/**
* Constructor
*
* @access public
* @since 2012-05-22
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Do work
*
* Does all the work on the fly as the page is being constrcuted. Different to the single query method which is
* much more efficient.
*
* @access protected
* @since 2012-05-22
* @param mixed $param
* @param integer $group
* @return mixed
*/
public function get_asset_src($param, $group = FALSE)
{
// Get the asset by either the integer id or the dual file and group identifier
$asset = is_int($param) ? $this->get_asset_by_id($param) : $this->get_asset($param, $group);
// If that's in the database, then we're good to go
if ($asset->num_rows)
{
// Get the asset row and let's start working with it
$asset = $asset->row();
// Check the asset, see if it needs some attention
$asset = $this->check_asset($asset);
// Return the asset src
return $this->single_asset_src($asset);
}
// Okay, we're still here, is $param an integer? Then we don't have that in the database
if (is_int($param))
{
log_message('error', "[ASSETS] id: [$id] doesn't exist in the database");
return FALSE;
}
// Well that asset is new then, let's process it
return $this->process_asset($param, $group);
}
/**
* Get Asset
*
* Returns the asset from the database
*
* @access private
* @since 2012-05-30
* @param string $file
* @param integer $group
* @return mixed
*/
private function get_asset($param, $group = FALSE)
{
$params['file'] = $this->param;
$group ? $params['group'] = $group : NULL;
return $this->CI->db->select('cdn, base64, filetype')
->from($this->CI->config->item('asset_table', 'asset_manager'))
->where($params)->get();
}
/**
* Get Asset By Id
*
* If you want to use the unique identifier for speed and you've made your system clever enough
* just get the asset location by id. Bit rough and dirty, if the asset's not there, it'll
* just return false.
*
* @access public
* @since 2012-05-25
* @param integer $id
* @return mixed
*/
private function get_asset_by_id($param)
{
return $this->CI->db->select('cdn, base64, filetype')
->from($this->CI->config->item('asset_table', 'asset_manager'))->where(array('id' => $param))
->get();
}
} | 101-code | application/libraries/asset_manager/Am_multiple_query.php | PHP | gpl3 | 3,387 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Email Class
*
* Permits email to be sent using Mail, Sendmail, or SMTP.
*
* @package Asset Manager
* @subpackage CDNs
* @category Libraries
* @author ExpressionEngine Dev Team
*/
class Am_cdn {
protected $CI;
public function __construct()
{
log_message('debug', '[CDN] Class initialized');
$this->CI =& get_instance();
$this->CI->load->config('asset_manager', TRUE);
}
public function put_asset($asset)
{
if ($this->put_file($asset['file'], $asset['filetype']))
{
$asset['cdn'] = $asset['file'];
return $asset;
}
else
{
return FALSE;
}
}
/**
* Check Asset
*
* Enter description here ...
*
* @access private
* @since 2012-05-29
* @param object $asset
* @return string
*/
protected function check_asset($asset)
{
$cdn = get_cdn_url($asset['cdn']);
if (! fopen($cdn,'r'))
{
log_message('warning', "[ASSETS] Asset does not exist in the CDN [$cdn]");
return FALSE;
}
return $cdn;
}
} | 101-code | application/libraries/asset_manager/Am_cdn.php | PHP | gpl3 | 1,524 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Handler Library
*
* The Handler library deals with getting the information in and out of the
* CDN.
*
* @package Asset Manager
* @subpackage Handler
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
class Am_handler {
/**
* CI
*
* CodeIgniter super object
*
* @access private
* @var object
*/
private $CI;
private $_asset;
/**
* Constructor
*
* The constructor gets the CodeIgniter super object.
*
* @access public
* @since 2012-05-25
* @return void
*/
public function __construct()
{
log_message('debug', '[HANDLER] Class initialized');
// Set the CI object for use throughout the class
$this->CI =& get_instance();
// We'll need this
$this->CI->load->config('asset_manager', TRUE);
}
public function build_new_asset($param, $group)
{
// We need a file to play with... If it's not there, cause a fuss.
if (! file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$param))
{
// Log a message and return FALSE
log_message('error', "[ASSETS HANDLER] The file [$param] doesn't exist in the file system");
return FALSE;
}
// Set the asset variable, enriching it with the information we'll need.
$this->_asset = $this->enrich_asset($param, $group);
}
public function set_existing_asset($asset)
{
$this->_asset = $asset;
}
/**
* Queue or do
*
* Queues up the file if the config setting is on, otherwise, it processes the file immediately and the browser will
* wait until the file is ready before drawing the page.
*
* @access public
* @since 2012-05-29
* @param string $file
* @param integer $identifier
* @return boolean
*/
public function queue_or_do()
{
// Does this asset want optimizing?
$this->queue_or_do_optimize();
// Does this asset want CDN'ing?
$this->queue_or_do_cdn();
// Now do the db work
$this->process_asset();
// Return the asset
return $this->_asset;
}
private function queue_or_do_optimize()
{
log_message('error', "I'm not sure I want to optimize");
// Get our filetype for the naming convention
$type = $this->get_asset_type($this->_asset['filetype']);
// Does that type of file want to be optimized
if ($this->CI->config->item("queue_optimize_$type", 'asset_manager'))
{
// Does it need queuing?
if ($this->CI->config->item("queue_optimize_$type", 'asset_manager'))
{
// Load up the handler queue library and queue it
$this->CI->load->library('asset_manager/am_handler/am_handler_queue');
$this->CI->am_handler_queue->queue($this->_asset, $type);
}
else
{
log_message('error', "I want to optimize");
// Load up the correct library for that filetype and process immediately
$this->CI->load->library("asset_manager/am_optimize/am_optimize_$type", 'optimize');
$this->_asset = $this->CI->optimize->process($this->_asset);
}
}
}
private function queue_or_do_cdn()
{
// Are we CDN'ing?
if ($this->CI->config->item('cdn', 'asset_manager'))
{
// Are we queueing or processing?
if ($this->CI->config->item('queue_cdn', 'asset_manager'))
{
$this->CI->load->library('asset_manager/am_handler/am_handler_queue');
$this->CI->am_handler_queue->queue($this->_asset, 'cdn');
}
else
{
// Process_immediately
$provider = 'am_cdn_'.$this->CI->config->item('cdn_host', 'asset_manager');
$this->CI->load->library("asset_manager/am_cdn/$provider");
$this->_asset = $this->CI->$provider->put_asset($this->_asset);
}
}
}
/**
* Process Asset
*
* Processes an individual asset
*
* @access protected
* @since 2012-05-25
* @param array $asset
* @return boolean
*/
protected function process_asset()
{
// Delete the file from the database, if it exists
$this->delete_asset_db($this->_asset['file']);
// And pop it back in with our new details
$this->CI->db->insert($this->CI->config->item('asset_table', 'asset_manager'), $this->_asset);
}
/**
* Delete Asset DB
*
* Deletes the asset from the database
*
* @access protected
* @since 2012-05-28
* @param string $file
* @return boolean
*/
private function delete_asset_db($file)
{
return $this->CI->db->delete($this->CI->config->item('asset_table', 'asset_manager'),
array('file' => $file));
}
/**
* Enrich Asset
*
* Adds more information to the asset for reference later
*
* @access private
* @since 2012-05-29
* @param string $file
* @param ingeger $group
* @return array
*/
private function enrich_asset($file, $group = FALSE)
{
$this->CI->load->helper('file');
$asset = array(
'file' => $file,
'filesize' => floor(filesize($file)/1024),
'filedate' => filemtime($file),
'filetype' => get_mime_by_extension($file)
);
$group ? $asset['group'] = $group : NULL;
return $asset;
}
/**
* Get Asset Type
*
* Get's the asset type so we can work out what library to call to get things done
*
* @access private
* @since 2012-06-13
* @param string $mimetype
* @return string
*/
private function get_asset_type($mimetype)
{
foreach (array('image' => 'images', 'css' => 'css', 'js|javascript' => 'js') as $type => $result)
{
if (preg_match("/$type/", $mimetype))
{
return $type;
}
}
}
} | 101-code | application/libraries/asset_manager/Am_handler.php | PHP | gpl3 | 5,849 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/libraries/index.html | HTML | gpl3 | 114 |
<?php
Class Pre_system {
/**
*
* Enter description here ...
*/
function install_check()
{
if ( ! preg_match('/admin\/install/', $_SERVER['REQUEST_URI']) &&
! file_exists(APPPATH.'config/base.php'))
{
// Log a little message so we know where we are
log_message('error', 'Config file "base.php" doesn\'t exist');
// Oh dear, the config file isn't there! Does the install controller still exist?
if (! file_exists(APPPATH.'controllers/admin/install.php'))
{
// Oh dear, the installation must be corrupt, display an error
log_message('error', 'Install controller has been removed, exiting...');
show_error('Fatal error, site not installed', 500);
}
else
{
// No helpers are loaded, so let's redirect the old fashioned way!
header("Refresh:0;url=admin/install/");
}
}
return TRUE;
}
} | 101-code | application/hooks/Pre_system.php | PHP | gpl3 | 849 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/hooks/index.html | HTML | gpl3 | 114 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Install_model extends CI_Model {
function __construct()
{
parent::__construct();
$this->load->dbforge();
}
function check_dirs()
{
}
function check_database()
{
}
function create_config_file()
{
}
function edit_setting($setting, $value)
{
}
function check_session()
{
$this->load->library('session');
$this->session->set_userdata('test', 'yes');
return $this->session->userdata('test') === 'yes' ? TRUE : FALSE;
}
function create_ci_session_table($table = 'ci_sessions')
{
$this->dbforge->drop_table($table);
$this->dbforge->add_field(
array(
'session_id' => array(
'type' => 'VARCHAR',
'constraint' => 40,
'default' => 0,
'null' => FALSE
),
'ip_address' => array(
'type' => 'VARCHAR',
'constraint' => 16,
'default' => 0
),
'user_agent' => array(
'type' => 'VARCHAR',
'constraint' => 120
),
'last_activity' => array(
'type' => 'INT',
'constraint' => 10,
'unsigned' => TRUE,
'default' => 0
),
'user_data' => array(
'type' => 'text'
),
)
);
$this->dbforge->add_key('session_id', TRUE); // primary key
$this->dbforge->create_table($table, TRUE);
// Nasty hack here until dbforge can have different key -> field names
$this->db->query("ALTER TABLE `$table` ADD KEY `last_activity_idx` ".
"(`last_activity`)");
return TRUE;
}
} | 101-code | application/models/admin/install_model.php | PHP | gpl3 | 1,482 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Base Model
*
* A base model for all functions which will be used site-wide
*
* IMPORTANT - if your function will not be used site wide, do not put it in here!
*
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
class Base_model extends CI_Model {
/**
*
* Enter description here ...
*/
function __construct()
{
parent::__construct();
}
} | 101-code | application/models/base/base_model.php | PHP | gpl3 | 467 |
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html> | 101-code | application/models/index.html | HTML | gpl3 | 114 |
<?php
class User extends CI_Model {
function __construct()
{
parent::__construct();
echo "<h1>Yes</h1>";
}
}
| 101-code | application/models/user.php | PHP | gpl3 | 139 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Asset Manager
*
* Software to automatically manage how assets are delivered on a website
*
* @package Asset Manager
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @copyright Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
* @license http://bestservedcold.com/license.html
* @link http://bestservedcold.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MY_Ouput class
*
* Wasn't sure if this should be a hook or just to extend the Output class... This simply calls the parent _display
* function after it's altered the output to search and replace the assets, as long as it's setup in the config.
*
* @package Asset Manager
* @subpackage Assets
* @category Libraries
* @author Adam Lewis <adam.lewis@bestservedcold.com>
* @since 2012-05-22
*/
class MY_Output extends CI_Output {
/**
* Construct
*
* Simply calls the parent constructer so we have all the methods we need
*
* @access public
* @since 2012-06-09
* @return void
*/
public function __construct()
{
log_message('debug', '[MY_Output] class loaded');
parent::__construct();
}
/**
* (non-PHPdoc)
* @see CI_Output::_display()
*/
public function _display()
{
// Get our info and get started...
$CI = get_instance();
$output = $this->get_output();
// Firstly, let's get asset manager involved to see if it needs to do anything...
if ($CI->config->item('query', 'asset_manager') == 'single')
{
$CI->load->library('asset_manager/am_single_query/am_single_query_output');
$output = $CI->am_single_query_output->process_output();
}
// bit of optimization if the config wants it
if ($compress_output = $CI->config->item('minify_output', 'asset_manager'))
{
if ($compress_output == 'minify')
{
require_once(APPPATH.'libraries/minify/min/lib/Minify/HTML.php');
$output = Minify_HTML::minify($output);
}
else
{
$CI->load->library('asset_manager/am_optimize/am_optimize_html');
$output = $CI->am_optimize_html->output($output);
}
}
// All done, set the output
$this->set_output($output);
// Let CodeIgniter do it's bits...
parent::_display();
}
} | 101-code | application/core/MY_Output.php | PHP | gpl3 | 2,308 |