68 changed files with 3813 additions and 4401 deletions
@ -0,0 +1,13 @@
|
||||
root = true |
||||
|
||||
[*] |
||||
end_of_line = lf |
||||
charset = utf-8 |
||||
trim_trailing_whitespace = true |
||||
insert_final_newline = true |
||||
indent_style = tab |
||||
indent_size = 4 |
||||
|
||||
[*.{json,yml,xml}] |
||||
indent_style = space |
||||
indent_size = 2 |
@ -1,2 +1,2 @@
|
||||
# Created by .gitignore support plugin (hsz.mobi) |
||||
.idea/ |
||||
node_modules |
||||
_book |
@ -0,0 +1,39 @@
|
||||
language: php |
||||
|
||||
notifications: |
||||
email: false |
||||
|
||||
php: |
||||
- '5.5' |
||||
- '5.6' |
||||
- '7.0' |
||||
|
||||
services: |
||||
- mysql |
||||
|
||||
env: |
||||
global: |
||||
- CI_HOME=`pwd` |
||||
matrix: |
||||
- CODEIGNITER_VERSION="3.1.2" |
||||
|
||||
before_install: |
||||
- mkdir ${CI_HOME}/testing_base && mv !(testing_base) ${CI_HOME}/testing_base |
||||
- composer require satooshi/php-coveralls:dev-master |
||||
- curl -o CI-${CODEIGNITER_VERSION}.zip https://codeload.github.com/bcit-ci/CodeIgniter/zip/${CODEIGNITER_VERSION} |
||||
- unzip -qq CI-${CODEIGNITER_VERSION}.zip |
||||
- rm -f CI-${CODEIGNITER_VERSION}.zip |
||||
- cd CodeIgniter-${CODEIGNITER_VERSION} |
||||
- composer require "kenjis/ci-phpunit-test:dev-master" |
||||
- php vendor/kenjis/ci-phpunit-test/install.php -s |
||||
- rm -f application/tests/controllers/Welcome_test.php |
||||
- cp -R ${CI_HOME}/testing_base/* ${CI_HOME}/CodeIgniter-${CODEIGNITER_VERSION}/application/ |
||||
- ls -R ${CI_HOME}/CodeIgniter-${CODEIGNITER_VERSION}/application/tests/models |
||||
- cd ${CI_HOME}/CodeIgniter-${CODEIGNITER_VERSION}/application/tests |
||||
|
||||
before_script: |
||||
- mysql -e 'create database aauth_test;' |
||||
|
||||
script: |
||||
- phpunit --coverage-clover ${CI_HOME}/CodeIgniter-${CODEIGNITER_VERSION}/application/build/logs/clover.xml |
||||
- cd ${CI_HOME}/CodeIgniter-${CODEIGNITER_VERSION}/application/ && travis_retry bash <(curl -s https://codecov.io/bash) |
@ -1,151 +0,0 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
/* |
||||
| ------------------------------------------------------------------- |
||||
| Aauth Config |
||||
| ------------------------------------------------------------------- |
||||
| A library Basic Authorization for CodeIgniter 2.x and 3.x |
||||
| |
||||
| ------------------------------------------------------------------- |
||||
| EXPLANATION |
||||
| ------------------------------------------------------------------- |
||||
| |
||||
| ['no_permission'] If user don't have permisssion to see the page he will be redirected the page spesificed. |
||||
| |
||||
| ['admin_group'] Name of admin group |
||||
| ['default_group'] Name of default group, the new user is added in it |
||||
| ['public_group'] Name of Public group , people who not logged in |
||||
| |
||||
| ['db_profile'] The configuration database profile (definied in config/database.php) |
||||
| |
||||
| ['users'] The table which contains users |
||||
| ['groups'] The table which contains groups |
||||
| ['user_to_group'] The table which contains join of users and groups |
||||
| ['perms'] The table which contains permissions |
||||
| ['perm_to_group'] The table which contains permissions for groups |
||||
| ['perm_to_user'] The table which contains permissions for users |
||||
| ['pms'] The table which contains private messages |
||||
| ['user_variables'] The table which contains users variables |
||||
| ['login_attempts'] The table which contains login attempts |
||||
| |
||||
| ['remember'] Remember time (in relative format) elapsed after connecting and automatic LogOut for usage with Cookies |
||||
| Relative Format (e.g. '+ 1 week', '+ 1 month', '+ first day of next month') |
||||
| for details see http://php.net/manual/de/datetime.formats.relative.php |
||||
| |
||||
| ['max'] Maximum char long for Password |
||||
| ['min'] Minimum char long for Password |
||||
| |
||||
| ['additional_valid_chars'] Additional valid chars for username. Non alphanumeric characters that are allowed by default |
||||
| |
||||
| ['ddos_protection'] Enables the DDoS Protection, user will be banned temporary when he exceed the login 'try' |
||||
| |
||||
| ['recaptcha_active'] Enables reCAPTCHA (for details see www.google.com/recaptcha/admin) |
||||
| ['recaptcha_login_attempts'] Login Attempts to display reCAPTCHA |
||||
| ['recaptcha_siteKey'] The reCAPTCHA siteKey |
||||
| ['recaptcha_secret'] The reCAPTCHA secretKey |
||||
| |
||||
| ['totp_active'] Enables the Time-based One-time Password Algorithm |
||||
| ['totp_only_on_ip_change'] TOTP only on IP Change |
||||
| ['totp_reset_over_reset_password'] TOTP reset over reset Password |
||||
| ['totp_two_step_login'] Enables TOTP two step login |
||||
| ['totp_two_step_login_redirect'] Redirect path to TOTP Verification page used by control() & is_allowed() |
||||
| |
||||
| ['max_login_attempt'] Login attempts time interval (default 10 times in one hour) |
||||
| ['max_login_attempt_time_period'] Period of time for max login attempts (default "5 minutes") |
||||
| ['remove_successful_attempts'] Enables removing login attempt after successful login |
||||
| |
||||
| ['login_with_name'] Login Identificator, if TRUE username needed to login else email address. |
||||
| |
||||
| ['email'] Sender email address, used for remind_password, send_verification and reset_password |
||||
| ['name'] Sender name, used for remind_password, send_verification and reset_password |
||||
| ['email_config'] Array of Config for CI's Email Library |
||||
| |
||||
| ['verification'] User Verification, if TRUE sends a verification email on account creation. |
||||
| ['verification_link'] Link for verification without site_url or base_url |
||||
| ['reset_password_link'] Link for reset_password without site_url or base_url |
||||
| |
||||
| ['hash'] Name of selected hashing algorithm (e.g. "md5", "sha256", "haval160,4", etc..) |
||||
| Please, run hash_algos() for know your all supported algorithms |
||||
| ['use_password_hash'] Enables to use PHP's own password_hash() function with BCrypt, needs PHP5.5 or higher |
||||
| ['password_hash_algo'] password_hash algorithm (PASSWORD_DEFAULT, PASSWORD_BCRYPT) |
||||
| for details see http://php.net/manual/de/password.constants.php |
||||
| ['password_hash_options'] password_hash options array |
||||
| for details see http://php.net/manual/en/function.password-hash.php |
||||
| |
||||
| ['pm_encryption'] Enables PM Encryption, needs configured CI Encryption Class. |
||||
| for details see: http://www.codeigniter.com/userguide2/libraries/encryption.html |
||||
| ['pm_cleanup_max_age'] PM Cleanup max age (in relative format), PM's are older than max age get deleted with 'cleanup_pms()' |
||||
| Relative Format (e.g. '2 week', '1 month') |
||||
| for details see http://php.net/manual/de/datetime.formats.relative.php |
||||
| |
||||
*/ |
||||
$config_aauth = array(); |
||||
|
||||
$config_aauth["default"] = array( |
||||
'no_permission' => FALSE, |
||||
|
||||
'admin_group' => 'admin', |
||||
'default_group' => 'default', |
||||
'public_group' => 'public', |
||||
|
||||
'db_profile' => 'default', |
||||
|
||||
'users' => 'aauth_users', |
||||
'groups' => 'aauth_groups', |
||||
'group_to_group' => 'aauth_group_to_group', |
||||
'user_to_group' => 'aauth_user_to_group', |
||||
'perms' => 'aauth_perms', |
||||
'perm_to_group' => 'aauth_perm_to_group', |
||||
'perm_to_user' => 'aauth_perm_to_user', |
||||
'pms' => 'aauth_pms', |
||||
'user_variables' => 'aauth_user_variables', |
||||
'login_attempts' => 'aauth_login_attempts', |
||||
|
||||
'remember' => ' +3 days', |
||||
|
||||
'max' => 13, |
||||
'min' => 5, |
||||
|
||||
'additional_valid_chars' => array(), |
||||
|
||||
'ddos_protection' => true, |
||||
|
||||
'recaptcha_active' => false, |
||||
'recaptcha_login_attempts' => 4, |
||||
'recaptcha_siteKey' => '', |
||||
'recaptcha_secret' => '', |
||||
|
||||
'totp_active' => false, |
||||
'totp_only_on_ip_change' => false, |
||||
'totp_reset_over_reset_password' => false, |
||||
'totp_two_step_login_active' => false, |
||||
'totp_two_step_login_redirect' => '/account/twofactor_verification/', |
||||
|
||||
'max_login_attempt' => 10, |
||||
'max_login_attempt_time_period' => "5 minutes", |
||||
'remove_successful_attempts' => true, |
||||
|
||||
'login_with_name' => false, |
||||
|
||||
'email' => 'admin@admin.com', |
||||
'name' => 'Emre Akay', |
||||
'email_config' => false, |
||||
|
||||
'verification' => false, |
||||
'verification_link' => '/account/verification/', |
||||
'reset_password_link' => '/account/reset_password/', |
||||
|
||||
'hash' => 'sha256', |
||||
'use_password_hash' => false, |
||||
'password_hash_algo' => PASSWORD_DEFAULT, |
||||
'password_hash_options' => array(), |
||||
|
||||
'pm_encryption' => false, |
||||
'pm_cleanup_max_age' => "3 months", |
||||
); |
||||
|
||||
$config['aauth'] = $config_aauth['default']; |
||||
|
||||
/* End of file aauth.php */ |
||||
/* Location: ./application/config/aauth.php */ |
@ -1,376 +0,0 @@
|
||||
<?php |
||||
|
||||
if (!defined('BASEPATH')) |
||||
exit('No direct script access allowed'); |
||||
|
||||
/** |
||||
* |
||||
* @property Login_control $Login_control |
||||
* @property Aauth $aauth Description |
||||
* @version 1.0 |
||||
*/ |
||||
class Example extends CI_Controller { |
||||
|
||||
public function __construct() { |
||||
parent::__construct(); |
||||
// Your own constructor code |
||||
$this->load->library("Aauth"); |
||||
} |
||||
|
||||
public function index() { |
||||
|
||||
if ($this->aauth->login('aa@a.com', '12345')) |
||||
echo 'tmm'; |
||||
else |
||||
echo 'hyr'; |
||||
//echo date("Y-m-d H:i:s"); |
||||
|
||||
$this->aauth->print_errors(); |
||||
} |
||||
|
||||
function debug(){ |
||||
|
||||
echo "<pre>"; |
||||
|
||||
print_r( |
||||
//$this->aauth->is_admin() |
||||
//$this->aauth->get_user() |
||||
//$this->aauth->control_group("Mod") |
||||
//$this->aauth->control_perm(1) |
||||
//$this->aauth->list_groups() |
||||
//$this->aauth->list_users() |
||||
//$this->aauth->is_allowed(1) |
||||
//$this->aauth->is_admin() |
||||
//$this->aauth->create_perm("deneme",'defff') |
||||
//$this->aauth->update_perm(3,'dess','asd') |
||||
//$this->aauth->allow(1,1) |
||||
//$this->aauth->add_member(1,1) |
||||
//$this->aauth->deny(1,1) |
||||
//$this->aauth->mail() |
||||
//$this->aauth->create_user('seass@asds.com','asdasdsdsdasd','asd') |
||||
//$this->aauth->verify_user(11, 'MLUguBbXpd9Eeu5B') |
||||
//$this->aauth->remind_password('seass@asds.com') |
||||
//$this->aauth->reset_password(11,'0ghUM3oIC95p7uMa') |
||||
//$this->aauth->is_allowed(1) |
||||
//$this->aauth->control(1) |
||||
//$this->aauth->send_pm(1,2,'asd') |
||||
//$this->session->flashdata('d') |
||||
//$this->aauth->add_member(1,1) |
||||
//$this->aauth->create_user('asd@asd.co','d') |
||||
//$this->aauth->send_pm(1,2,'asd','sad') |
||||
//$this->aauth->list_pms(1,0,3,1) |
||||
//$this->aauth->get_pm(6, false) |
||||
//$this->aauth->delete_pm(6) |
||||
//$this->aauth->set_as_read_pm(13) |
||||
//$this->aauth->create_group('aa') |
||||
$this->aauth->create_perm('asdda') |
||||
//'' |
||||
|
||||
); |
||||
|
||||
echo '<br>---- error --- <br>'; |
||||
echo $this->aauth->get_errors(); |
||||
|
||||
echo '<br>---- info --- <br>'; |
||||
echo $this->aauth->get_infos(); |
||||
|
||||
echo "</pre>"; |
||||
} |
||||
|
||||
function flash(){ |
||||
$d['a'] = 'asd'; |
||||
$d['3'] = 'asdasd'; |
||||
|
||||
$this->session->set_flashdata('d', $d); |
||||
|
||||
$d['4'] = 'tttt'; |
||||
|
||||
$this->session->set_flashdata('d', $d); |
||||
} |
||||
|
||||
|
||||
function settings() { |
||||
|
||||
//echo $this->aauth->_get_login_attempts(4); |
||||
//echo $this->aauth->get_user_id('emre@emreakay.com'); |
||||
//$this->aauth->_increase_login_attempts('emre@emreakay.com'); |
||||
//$this->aauth->_reset_login_attempts(1); |
||||
} |
||||
|
||||
public function login_fast(){ |
||||
$this->aauth->login_fast(1); |
||||
} |
||||
|
||||
public function is_loggedin() { |
||||
|
||||
if ($this->aauth->is_loggedin()) |
||||
echo 'girdin'; |
||||
|
||||
print_r( $this->aauth->get_user() ); |
||||
} |
||||
|
||||
public function logout() { |
||||
|
||||
$this->aauth->logout(); |
||||
} |
||||
|
||||
public function is_member() { |
||||
|
||||
if ($this->aauth->is_member('deneme',9)) |
||||
echo 'uye'; |
||||
} |
||||
|
||||
public function is_admin() { |
||||
|
||||
if ($this->aauth->is_member('Admin')) |
||||
echo 'adminovic'; |
||||
} |
||||
|
||||
function get_user_groups(){ |
||||
//print_r( $this->aauth->get_user_groups()); |
||||
|
||||
foreach($this->aauth->get_user_groups() as $a){ |
||||
|
||||
echo $a->id . " " . $a->name . "<br>"; |
||||
} |
||||
} |
||||
|
||||
public function get_group_name() { |
||||
|
||||
echo $this->aauth->get_group_name(1); |
||||
} |
||||
|
||||
public function get_group_id() { |
||||
|
||||
echo $this->aauth->get_group_id("Admin"); |
||||
} |
||||
|
||||
public function list_users() { |
||||
echo '<pre>'; |
||||
print_r($this->aauth->list_users()); |
||||
echo '</pre>'; |
||||
} |
||||
|
||||
public function list_groups() { |
||||
echo '<pre>'; |
||||
print_r($this->aauth->list_groups()); |
||||
echo '</pre>'; |
||||
} |
||||
|
||||
public function check_email() { |
||||
|
||||
if ($this->aauth->check_email("aa@a.com")) |
||||
echo 'uygun '; |
||||
else |
||||
echo 'alindi '; |
||||
|
||||
$this->aauth->print_errors(); |
||||
} |
||||
|
||||
public function get_user() { |
||||
print_r($this->aauth->get_user()); |
||||
} |
||||
|
||||
function create_user() { |
||||
|
||||
$a = $this->aauth->create_user("admin@admin.com", "12345", "Admin"); |
||||
|
||||
if ($a) |
||||
echo "tmm "; |
||||
else |
||||
echo "hyr "; |
||||
|
||||
|
||||
print_r($this->aauth->get_user($a)); |
||||
|
||||
$this->aauth->print_errors(); |
||||
} |
||||
|
||||
public function is_banned() { |
||||
print_r($this->aauth->is_banned(6)); |
||||
} |
||||
|
||||
function ban_user() { |
||||
|
||||
$a = $this->aauth->ban_user(6); |
||||
|
||||
print_r($a); |
||||
} |
||||
|
||||
function delete_user() { |
||||
|
||||
$a = $this->aauth->delete_user(7); |
||||
|
||||
print_r($a); |
||||
} |
||||
|
||||
function unban_user() { |
||||
|
||||
$a = $this->aauth->unban_user(6); |
||||
|
||||
print_r($a); |
||||
} |
||||
|
||||
function update_user() { |
||||
$a = $this->aauth->update_user(6, "a@a.com", "12345", "tested"); |
||||
|
||||
print_r($a); |
||||
} |
||||
|
||||
function update_activity() { |
||||
$a = $this->aauth->update_activity(); |
||||
|
||||
print_r($a); |
||||
} |
||||
|
||||
function update_login_attempt() { |
||||
$a = $this->aauth->update_login_attempts("a@a.com"); |
||||
|
||||
print_r($a); |
||||
} |
||||
|
||||
function create_group() { |
||||
|
||||
$a = $this->aauth->create_group("deneme"); |
||||
} |
||||
|
||||
function delete_group() { |
||||
|
||||
$a = $this->aauth->delete_group("deneme"); |
||||
} |
||||
|
||||
function update_group() { |
||||
|
||||
$a = $this->aauth->update_group("deneme", "zxxx"); |
||||
} |
||||
|
||||
function add_member() { |
||||
|
||||
$a = $this->aauth->add_member(8, "deneme"); |
||||
} |
||||
|
||||
function fire_member() { |
||||
|
||||
$a = $this->aauth->fire_member(8, "deneme"); |
||||
} |
||||
|
||||
|
||||
function create_perm() { |
||||
|
||||
$a = $this->aauth->create_perm("deneme","def"); |
||||
} |
||||
|
||||
|
||||
function update_perm() { |
||||
|
||||
$a = $this->aauth->update_perm("deneme","deneme","xxx"); |
||||
} |
||||
|
||||
function delete_perm() { |
||||
|
||||
$a = $this->aauth->update_perm("deneme","deneme","xxx"); |
||||
} |
||||
|
||||
function allow_user() { |
||||
|
||||
$a = $this->aauth->allow_user(9,"deneme"); |
||||
} |
||||
|
||||
|
||||
function deny_user() { |
||||
|
||||
$a = $this->aauth->deny_user(9,"deneme"); |
||||
} |
||||
|
||||
function allow_group() { |
||||
|
||||
$a = $this->aauth->allow_group("deneme","deneme"); |
||||
} |
||||
|
||||
function deny_group() { |
||||
|
||||
$a = $this->aauth->deny_group("deneme","deneme"); |
||||
} |
||||
|
||||
function list_perms() { |
||||
|
||||
$a = $this->aauth->list_perms(); |
||||
print_r($a); |
||||
} |
||||
|
||||
function get_perm_id() { |
||||
|
||||
$a = $this->aauth->get_perm_id("deneme"); |
||||
print_r($a); |
||||
} |
||||
|
||||
|
||||
function send_pm() { |
||||
|
||||
$a = $this->aauth->send_pm(1,8,'s',"w"); |
||||
$this->aauth->print_errors(); |
||||
} |
||||
|
||||
function list_pms(){ |
||||
|
||||
print_r( $this->aauth->list_pms() ); |
||||
} |
||||
|
||||
function get_pm(){ |
||||
|
||||
print_r( $this->aauth->get_pm(39,false)); |
||||
} |
||||
|
||||
function delete_pm(){ |
||||
|
||||
$this->aauth->delete_pm(41); |
||||
} |
||||
|
||||
|
||||
function count_unread_pms(){ |
||||
|
||||
echo $this->aauth->count_unread_pms(8); |
||||
} |
||||
|
||||
function error(){ |
||||
|
||||
$this->aauth->error("asd"); |
||||
$this->aauth->error("xasd"); |
||||
$this->aauth->keep_errors(); |
||||
$this->aauth->print_errors(); |
||||
|
||||
} |
||||
|
||||
function keep_errors(){ |
||||
|
||||
$this->aauth->print_errors(); |
||||
//$this->aauth->keep_errors(); |
||||
} |
||||
|
||||
function set_user_var(){ |
||||
$this->aauth->set_user_var("emre","akasy"); |
||||
} |
||||
|
||||
function unset_user_var(){ |
||||
$this->aauth->unset_user_var("emre"); |
||||
} |
||||
|
||||
function get_user_var(){ |
||||
echo $this->aauth->get_user_var("emre"); |
||||
} |
||||
|
||||
function set_system_var(){ |
||||
$this->aauth->set_system_var("emre","akay"); |
||||
} |
||||
|
||||
function unset_system_var(){ |
||||
$this->aauth->unset_system_var("emre"); |
||||
} |
||||
|
||||
function get_system_var(){ |
||||
echo $this->aauth->get_system_var("emre"); |
||||
} |
||||
|
||||
}//end |
||||
|
||||
/* End of file welcome.php */ |
@ -1,208 +0,0 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* PHP Class for handling Google Authenticator 2-factor authentication |
||||
* |
||||
* @author Michael Kliewe |
||||
* @copyright 2012 Michael Kliewe |
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
||||
* @link http://www.phpgangsta.de/ |
||||
*/ |
||||
|
||||
class PHPGangsta_GoogleAuthenticator |
||||
{ |
||||
protected $_codeLength = 6; |
||||
|
||||
/** |
||||
* Create new secret. |
||||
* 16 characters, randomly chosen from the allowed base32 characters. |
||||
* |
||||
* @param int $secretLength |
||||
* @return string |
||||
*/ |
||||
public function createSecret($secretLength = 16) |
||||
{ |
||||
$validChars = $this->_getBase32LookupTable(); |
||||
unset($validChars[32]); |
||||
|
||||
$secret = ''; |
||||
for ($i = 0; $i < $secretLength; $i++) { |
||||
$secret .= $validChars[array_rand($validChars)]; |
||||
} |
||||
return $secret; |
||||
} |
||||
|
||||
/** |
||||
* Calculate the code, with given secret and point in time |
||||
* |
||||
* @param string $secret |
||||
* @param int|null $timeSlice |
||||
* @return string |
||||
*/ |
||||
public function getCode($secret, $timeSlice = null) |
||||
{ |
||||
if ($timeSlice === null) { |
||||
$timeSlice = floor(time() / 30); |
||||
} |
||||
|
||||
$secretkey = $this->_base32Decode($secret); |
||||
|
||||
// Pack time into binary string |
||||
$time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice); |
||||
// Hash it with users secret key |
||||
$hm = hash_hmac('SHA1', $time, $secretkey, true); |
||||
// Use last nipple of result as index/offset |
||||
$offset = ord(substr($hm, -1)) & 0x0F; |
||||
// grab 4 bytes of the result |
||||
$hashpart = substr($hm, $offset, 4); |
||||
|
||||
// Unpak binary value |
||||
$value = unpack('N', $hashpart); |
||||
$value = $value[1]; |
||||
// Only 32 bits |
||||
$value = $value & 0x7FFFFFFF; |
||||
|
||||
$modulo = pow(10, $this->_codeLength); |
||||
return str_pad($value % $modulo, $this->_codeLength, '0', STR_PAD_LEFT); |
||||
} |
||||
|
||||
/** |
||||
* Get QR-Code URL for image, from google charts |
||||
* |
||||
* @param string $name |
||||
* @param string $secret |
||||
* @param string $title |
||||
* @return string |
||||
*/ |
||||
public function getQRCodeGoogleUrl($name, $secret, $title = null) { |
||||
$urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.''); |
||||
if(isset($title)) { |
||||
$urlencoded .= urlencode('&issuer='.urlencode($title)); |
||||
} |
||||
return 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl='.$urlencoded.''; |
||||
} |
||||
|
||||
/** |
||||
* Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now |
||||
* |
||||
* @param string $secret |
||||
* @param string $code |
||||
* @param int $discrepancy This is the allowed time drift in 30 second units (8 means 4 minutes before or after) |
||||
* @param int|null $currentTimeSlice time slice if we want use other that time() |
||||
* @return bool |
||||
*/ |
||||
public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null) |
||||
{ |
||||
if ($currentTimeSlice === null) { |
||||
$currentTimeSlice = floor(time() / 30); |
||||
} |
||||
|
||||
for ($i = -$discrepancy; $i <= $discrepancy; $i++) { |
||||
$calculatedCode = $this->getCode($secret, $currentTimeSlice + $i); |
||||
if ($calculatedCode == $code ) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* Set the code length, should be >=6 |
||||
* |
||||
* @param int $length |
||||
* @return PHPGangsta_GoogleAuthenticator |
||||
*/ |
||||
public function setCodeLength($length) |
||||
{ |
||||
$this->_codeLength = $length; |
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Helper class to decode base32 |
||||
* |
||||
* @param $secret |
||||
* @return bool|string |
||||
*/ |
||||
protected function _base32Decode($secret) |
||||
{ |
||||
if (empty($secret)) return ''; |
||||
|
||||
$base32chars = $this->_getBase32LookupTable(); |
||||
$base32charsFlipped = array_flip($base32chars); |
||||
|
||||
$paddingCharCount = substr_count($secret, $base32chars[32]); |
||||
$allowedValues = array(6, 4, 3, 1, 0); |
||||
if (!in_array($paddingCharCount, $allowedValues)) return false; |
||||
for ($i = 0; $i < 4; $i++){ |
||||
if ($paddingCharCount == $allowedValues[$i] && |
||||
substr($secret, -($allowedValues[$i])) != str_repeat($base32chars[32], $allowedValues[$i])) return false; |
||||
} |
||||
$secret = str_replace('=','', $secret); |
||||
$secret = str_split($secret); |
||||
$binaryString = ""; |
||||
for ($i = 0; $i < count($secret); $i = $i+8) { |
||||
$x = ""; |
||||
if (!in_array($secret[$i], $base32chars)) return false; |
||||
for ($j = 0; $j < 8; $j++) { |
||||
$x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); |
||||
} |
||||
$eightBits = str_split($x, 8); |
||||
for ($z = 0; $z < count($eightBits); $z++) { |
||||
$binaryString .= ( ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ) ? $y:""; |
||||
} |
||||
} |
||||
return $binaryString; |
||||
} |
||||
|
||||
/** |
||||
* Helper class to encode base32 |
||||
* |
||||
* @param string $secret |
||||
* @param bool $padding |
||||
* @return string |
||||
*/ |
||||
protected function _base32Encode($secret, $padding = true) |
||||
{ |
||||
if (empty($secret)) return ''; |
||||
|
||||
$base32chars = $this->_getBase32LookupTable(); |
||||
|
||||
$secret = str_split($secret); |
||||
$binaryString = ""; |
||||
for ($i = 0; $i < count($secret); $i++) { |
||||
$binaryString .= str_pad(base_convert(ord($secret[$i]), 10, 2), 8, '0', STR_PAD_LEFT); |
||||
} |
||||
$fiveBitBinaryArray = str_split($binaryString, 5); |
||||
$base32 = ""; |
||||
$i = 0; |
||||
while ($i < count($fiveBitBinaryArray)) { |
||||
$base32 .= $base32chars[base_convert(str_pad($fiveBitBinaryArray[$i], 5, '0'), 2, 10)]; |
||||
$i++; |
||||
} |
||||
if ($padding && ($x = strlen($binaryString) % 40) != 0) { |
||||
if ($x == 8) $base32 .= str_repeat($base32chars[32], 6); |
||||
elseif ($x == 16) $base32 .= str_repeat($base32chars[32], 4); |
||||
elseif ($x == 24) $base32 .= str_repeat($base32chars[32], 3); |
||||
elseif ($x == 32) $base32 .= $base32chars[32]; |
||||
} |
||||
return $base32; |
||||
} |
||||
|
||||
/** |
||||
* Get array with all 32 characters for decoding from/encoding to base32 |
||||
* |
||||
* @return array |
||||
*/ |
||||
protected function _getBase32LookupTable() |
||||
{ |
||||
return array( |
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 7 |
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 15 |
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 23 |
||||
'Y', 'Z', '2', '3', '4', '5', '6', '7', // 31 |
||||
'=' // padding char |
||||
); |
||||
} |
||||
} |
@ -1,140 +0,0 @@
|
||||
<?php |
||||
/** |
||||
* This is a PHP library that handles calling reCAPTCHA. |
||||
* - Documentation and latest version |
||||
* https://developers.google.com/recaptcha/docs/php |
||||
* - Get a reCAPTCHA API Key |
||||
* https://www.google.com/recaptcha/admin/create |
||||
* - Discussion group |
||||
* http://groups.google.com/group/recaptcha |
||||
* |
||||
* @copyright Copyright (c) 2014, Google Inc. |
||||
* @link http://www.google.com/recaptcha |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice shall be included in |
||||
* all copies or substantial portions of the Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
* THE SOFTWARE. |
||||
*/ |
||||
|
||||
/** |
||||
* A ReCaptchaResponse is returned from checkAnswer(). |
||||
*/ |
||||
class ReCaptchaResponse |
||||
{ |
||||
public $success; |
||||
public $errorCodes; |
||||
} |
||||
|
||||
class ReCaptcha |
||||
{ |
||||
private static $_signupUrl = "https://www.google.com/recaptcha/admin"; |
||||
private static $_siteVerifyUrl = |
||||
"https://www.google.com/recaptcha/api/siteverify?"; |
||||
private $_secret; |
||||
private static $_version = "php_1.0"; |
||||
|
||||
/** |
||||
* Constructor. |
||||
* |
||||
* @param string $secret shared secret between site and ReCAPTCHA server. |
||||
*/ |
||||
public function __construct($secret) |
||||
{ |
||||
if ($secret == null || $secret == "") { |
||||
die("To use reCAPTCHA you must get an API key from <a href='" |
||||
. self::$_signupUrl . "'>" . self::$_signupUrl . "</a>"); |
||||
} |
||||
$this->_secret=$secret; |
||||
} |
||||
|
||||
/** |
||||
* Encodes the given data into a query string format. |
||||
* |
||||
* @param array $data array of string elements to be encoded. |
||||
* |
||||
* @return string - encoded request. |
||||
*/ |
||||
private function _encodeQS($data) |
||||
{ |
||||
$req = ""; |
||||
foreach ($data as $key => $value) { |
||||
$req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
||||
} |
||||
|
||||
// Cut the last '&' |
||||
$req=substr($req, 0, strlen($req)-1); |
||||
return $req; |
||||
} |
||||
|
||||
/** |
||||
* Submits an HTTP GET to a reCAPTCHA server. |
||||
* |
||||
* @param string $path url path to recaptcha server. |
||||
* @param array $data array of parameters to be sent. |
||||
* |
||||
* @return array response |
||||
*/ |
||||
private function _submitHTTPGet($path, $data) |
||||
{ |
||||
$req = $this->_encodeQS($data); |
||||
$response = file_get_contents($path . $req); |
||||
return $response; |
||||
} |
||||
|
||||
/** |
||||
* Calls the reCAPTCHA siteverify API to verify whether the user passes |
||||
* CAPTCHA test. |
||||
* |
||||
* @param string $remoteIp IP address of end user. |
||||
* @param string $response response string from recaptcha verification. |
||||
* |
||||
* @return ReCaptchaResponse |
||||
*/ |
||||
public function verifyResponse($remoteIp, $response) |
||||
{ |
||||
// Discard empty solution submissions |
||||
if ($response == null || strlen($response) == 0) { |
||||
$recaptchaResponse = new ReCaptchaResponse(); |
||||
$recaptchaResponse->success = false; |
||||
$recaptchaResponse->errorCodes = 'missing-input'; |
||||
return $recaptchaResponse; |
||||
} |
||||
|
||||
$getResponse = $this->_submitHttpGet( |
||||
self::$_siteVerifyUrl, |
||||
array ( |
||||
'secret' => $this->_secret, |
||||
'remoteip' => $remoteIp, |
||||
'v' => self::$_version, |
||||
'response' => $response |
||||
) |
||||
); |
||||
$answers = json_decode($getResponse, true); |
||||
$recaptchaResponse = new ReCaptchaResponse(); |
||||
|
||||
if (trim($answers['success']) == true) { |
||||
$recaptchaResponse->success = true; |
||||
} else { |
||||
$recaptchaResponse->success = false; |
||||
$recaptchaResponse->errorCodes = $answers['error-codes']; |
||||
} |
||||
|
||||
return $recaptchaResponse; |
||||
} |
||||
} |
||||
|
||||
?> |
@ -1,56 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'Vérification de Compte'; |
||||
$lang['aauth_email_verification_code'] = 'Votre code de vérification est: '; |
||||
$lang['aauth_email_verification_text'] = " Vous pouvez également cliquer sur (ou copier coller) le lien suivant.\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'Réinitialiser le mot de passe'; |
||||
$lang['aauth_email_reset_text'] = "Pour réinitialiser votre mot de passe cliquez sur (ou copiez collez dans la barre d'adresse de votre navigateur) le lien ci-dessous:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = "Réinitialisation de mot de passe réussie"; |
||||
$lang['aauth_email_reset_success_new_password'] = "Votre mot de passe a été réinitialisé avec succès. Votre nouveau mot de passe est: "; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = "Cette adresse email est déjà utilisée. Si vous avez oublié votre mot de passe cliquez sur le lien ci-dessous."; |
||||
$lang['aauth_error_username_exists'] = "Un compte avec ce nom d'utilisateur existe déjà. Merci de renseigner un nom d'utilisateur différent. Si vous avez oublié votre mot de passe cliquez sur le lien ci-dessous."; |
||||
$lang['aauth_error_email_invalid'] = "Adresse email invalide"; |
||||
$lang['aauth_error_password_invalid'] = "Mot de passe invalide"; |
||||
$lang['aauth_error_username_invalid'] = "Nom d'utilisateur invalide"; |
||||
$lang['aauth_error_username_required'] = "Nom d'utilisateur requis"; |
||||
$lang['aauth_error_totp_code_required'] = "Code TOTP requis"; |
||||
$lang['aauth_error_totp_code_invalid'] = "Code TOTP invalide"; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = "Cette adresse email est déjà utilisée. Merci de renseigner une adresse email différente."; |
||||
$lang['aauth_error_update_username_exists'] = "Ce nom d'utilisateur est déjà utilisé. Merci de renseigner un nom d'utilisateur différent."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = "Désolé, vous n'avez pas accès à cette ressource."; |
||||
$lang['aauth_error_login_failed_email'] = "L'adresse email et le mot de passe ne correspondent pas."; |
||||
$lang['aauth_error_login_failed_name'] = "Le nom d'utilisateur et le mot de passe ne correspondent pas."; |
||||
$lang['aauth_error_login_failed_all'] = "L'adresse email, le nom d'utilisateur ou le mot de passe ne correspondent pas."; |
||||
$lang['aauth_error_login_attempts_exceeded'] = "Vous avez dépassé le nombre de tentatives de connexion autorisées, votre compte a été bloqué."; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'Désolé, le texte renseigné pour le reCAPTCHA est incorrect.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = "L'utilisateur n'existe pas."; |
||||
$lang['aauth_error_account_not_verified'] = "Votre compte n'a pas été confirmé. Merci de vérifier vos email et de confirmer votre compte."; |
||||
$lang['aauth_error_no_group'] = "Le groupe n'existe pas"; |
||||
$lang['aauth_error_self_pm'] = "Il impossible de vous envoyer un message à vous-même."; |
||||
$lang['aauth_error_no_pm'] = "Message privé introuvable"; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = "L'utilisateur est déjà membre de ce groupe"; |
||||
$lang['aauth_info_group_exists'] = "Ce nom de groupe existe déjà"; |
||||
$lang['aauth_info_perm_exists'] = "Ce nom de permission existe déjà"; |
@ -1,58 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'Account Bestätigung'; |
||||
$lang['aauth_email_verification_code'] = 'Dein Bestätigungscode lautet: '; |
||||
$lang['aauth_email_verification_text'] = " Du kannst auch den Link anklicken (oder deinem Browser aufrufen) \n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'Passwort zurücksetzen'; |
||||
$lang['aauth_email_reset_text'] = "Um dein Passwort zurückzusetzen folge (oder ruf ihn im Browser auf) diesem Link:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = 'Passwort zurückgesetzt'; |
||||
$lang['aauth_email_reset_success_new_password'] = 'Du hast dein Passwort erfolgreich zurückgesetzt. Dein neues Passwort lautet: '; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = 'Diese E-Mail-Adresse ist bereits registriert. Wenn du dein Passwort vergessen hast, folge dem Link unten.'; |
||||
$lang['aauth_error_username_exists'] = "Der Benutzername wird bereits verwendet. Bitte wähle einen anderen Benutzernamen. Wenn du dein Passwort vergessen hast, folge dem Link unten."; |
||||
$lang['aauth_error_email_invalid'] = 'Ungültige E-Mail-Adresse'; |
||||
$lang['aauth_error_password_invalid'] = 'Ungültiges Passwort'; |
||||
$lang['aauth_error_username_invalid'] = 'Ungültiger Benutzername'; |
||||
$lang['aauth_error_username_required'] = 'Benutzername wird benötigt'; |
||||
$lang['aauth_error_totp_code_required'] = 'Bestätigungscode wird benötigt'; |
||||
$lang['aauth_error_totp_code_invalid'] = 'Ungültiger Bestätigungscode'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = 'Diese E-Mail-Adresse ist bereits registriert. Bitte gib eine andere E-Mail-Adresse ein.'; |
||||
$lang['aauth_error_update_username_exists'] = "Der Benutzername wird bereits verwendet. Bitte gib einen anderen Benutzernamen ein."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = 'Entschuldige, aber du hast kein Zugriffsrecht auf die angeforderte Seite.'; |
||||
$lang['aauth_error_login_failed_email'] = 'E-Mail-Adresse oder Passwort falsch.'; |
||||
$lang['aauth_error_login_failed_name'] = 'Benutzername oder Passwort falsch.'; |
||||
$lang['aauth_error_login_failed_all'] = 'E-Mail-Adresse, Benutzername oder Passwort falsch.'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = 'Du hast die maximale Anzahl Login versuche erreicht, dein Account wurde gesperrt.'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'Hupps, der eingegebene reCAPTCHA Text war falsch.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = 'Der Benutzer existiert nicht'; |
||||
$lang['aauth_error_account_not_verified'] = 'Dein Account wurde bisher nicht bestätigt. Bitte prüfe deine E-Mails und bestätige deine Registrierung.'; |
||||
$lang['aauth_error_no_group'] = 'Die Gruppe existiert nicht'; |
||||
$lang['aauth_error_no_subgroup'] = 'Die Untergruppe existiert nicht'; |
||||
$lang['aauth_error_self_pm'] = 'Du kannst keine Nachrichten an dich selbst senden.'; |
||||
$lang['aauth_error_no_pm'] = 'Du hast keine privaten Nachrichten'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = 'Der Benutzer ist bereits in dieser Gruppe'; |
||||
$lang['aauth_info_already_subgroup'] = 'Diese Untergruppe ist bereits dieser gruppe zugeordnet'; |
||||
$lang['aauth_info_group_exists'] = 'Diese Gruppe existiert bereits'; |
||||
$lang['aauth_info_perm_exists'] = 'Der Berechtigungs-Regel-Name wurde bereits verwendet'; |
@ -1,56 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'Verifikasi Akun'; |
||||
$lang['aauth_email_verification_code'] = 'Kode verifikasi anda adalah: '; |
||||
$lang['aauth_email_verification_text'] = "Anda juga bisa klik (atau salin dan tempel) tautan berikut ini\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'Ganti Kata Sandi'; |
||||
$lang['aauth_email_reset_text'] = "Untuk mengganti kata sandi klik (atau salin dan tempel) tautan dibawah ini:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = 'Berhasil mengubah kata sandi'; |
||||
$lang['aauth_email_reset_success_new_password'] = 'Kata sandi anda berhasil diubah. Kata sandi baru anda adalah : '; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = 'Email sudah digunakan di sistem. Jika anda lupa kata sandi, silahkan klik tautan dibawah ini.'; |
||||
$lang['aauth_error_username_exists'] = "Username telah digunakan oleh akun lain pada sistem. Silahkan masukan username lain, atau jika anda lupa kata sandi, silahkan klik tautan dibawah ini."; |
||||
$lang['aauth_error_email_invalid'] = 'Alamat email tidak valid'; |
||||
$lang['aauth_error_password_invalid'] = 'kata sandi tidak valid'; |
||||
$lang['aauth_error_username_invalid'] = 'Username tidak valid'; |
||||
$lang['aauth_error_username_required'] = 'Username tidak boleh kosong'; |
||||
$lang['aauth_error_totp_code_required'] = 'Kode autentikasi tidak boleh kosong'; |
||||
$lang['aauth_error_totp_code_invalid'] = 'Kode autentikasi tidak valid'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = 'Alamat email telah digunakan pada sistem. Silahkan masukan alamat email lainya.'; |
||||
$lang['aauth_error_update_username_exists'] = "Username telah digunakan pada sistem. Silahkan masukan username lainya."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = 'Maaf, Anda tidak memiliki akses ke sumber daya yang Anda minta.'; |
||||
$lang['aauth_error_login_failed_email'] = 'Email dan sandi yang anda masukkan tidak cocok.'; |
||||
$lang['aauth_error_login_failed_name'] = 'Username dan sandi yang Anda masukkan tidak cocok.'; |
||||
$lang['aauth_error_login_failed_all'] = 'Email, username dan sandi yang Anda masukkan tidak cocok.'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = 'Anda telah melebihi upaya login anda, akun anda telah diblokir.'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'Maaf, teks reCAPTCHA yang anda dimasukkan salah.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = 'Pengguna tidak ada'; |
||||
$lang['aauth_error_account_not_verified'] = 'Akun anda belum diverifikasi. Silakan cek email anda dan verifikasi akun anda .'; |
||||
$lang['aauth_error_no_group'] = 'Grup tidak ada'; |
||||
$lang['aauth_error_self_pm'] = 'Tidak dapat mengirim pesan kepada diri sendiri.'; |
||||
$lang['aauth_error_no_pm'] = 'Pesan Pribadi tidak ditemukan'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = 'Pengguna sudah anggota grup'; |
||||
$lang['aauth_info_group_exists'] = 'Nama grup sudah ada'; |
||||
$lang['aauth_info_perm_exists'] = 'Nama izin sudah ada'; |
@ -1,58 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'تایید حساب کاربری'; |
||||
$lang['aauth_email_verification_code'] = 'کد تایید شما: '; |
||||
$lang['aauth_email_verification_text'] = "شما همچنین میتوانید بر روی لینک زیر کلیک کنید و یا آن را در نوار آدرس مرورگر وارد کنید\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'بازنشانی کلمه عبور'; |
||||
$lang['aauth_email_reset_text'] = "برای تغییر کلمه عبور خود بر روی لینک زیر کلیک کنید و یا آن را در نوار آدرس مرورگر وارد کنید\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = 'کلمه عبور با موفقیت بازنشانی شد'; |
||||
$lang['aauth_email_reset_success_new_password'] = 'کلمه عبور شما با موفقیت تغییر کرد. کلمه عبور جدید شما: '; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = 'آدرس ایمیل در سیستم موجود است. در صورتی که کلمه عبور خود را فراموش کردید، میتوانید بر روی لینک زیر کلیک کنید.'; |
||||
$lang['aauth_error_username_exists'] = "نام کاربری وارد شده در سیستم موجود هست. لطفا یک نام کاربری دیگر انتخاب کنید، و یا اگر کلمه عبور خود را فراموش کرده اید بر روی لینک زیر کلیک کنید."; |
||||
$lang['aauth_error_email_invalid'] = 'آدرس ایمیل نامعتبر است'; |
||||
$lang['aauth_error_password_invalid'] = 'کلمه عبور نامعتبر است'; |
||||
$lang['aauth_error_username_invalid'] = 'نام کاربری نامعتبر است'; |
||||
$lang['aauth_error_username_required'] = 'ورود نام کاربری الزامی است'; |
||||
$lang['aauth_error_totp_code_required'] = 'ورود کد احراز هویت الزامی است'; |
||||
$lang['aauth_error_totp_code_invalid'] = 'کد احراز هویت نامعتبر است'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = 'ایمیل وارد شده در سیستم موجود می باشد. لطفا ایمیل دیگری انتخاب کنید.'; |
||||
$lang['aauth_error_update_username_exists'] = "نام کاربری وارد شده در سیستم موجود می باشد. لطفا نام کاربری دیگری انتخاب کنید."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = 'متاسفانه شما به منبع درخواست شده دسترسی ندارید.'; |
||||
$lang['aauth_error_login_failed_email'] = 'ایمیل و کلمه عبور همخوانی ندارند.'; |
||||
$lang['aauth_error_login_failed_name'] = 'نام کاربری و کلمه عبور همخوانی ندارند.'; |
||||
$lang['aauth_error_login_failed_all'] = 'ایمیل یا نام کاربری با کلمه عبور همخوانی ندارد.'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = 'شما بیش از حد مجاز برای ورود به سایت تلاش کردید. حساب کاربری شما موقتا غیر فعال شد.'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'کد کپتچا به درستی وارد نشده.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = 'نام کاربری وجود ندارد'; |
||||
$lang['aauth_error_account_not_verified'] = 'حساب کاربری شما تایید نشده است. لطفا ایمیل خود را برای تایید حسا کاربری بررسی کنید.'; |
||||
$lang['aauth_error_no_group'] = 'گروه موجود نیست'; |
||||
$lang['aauth_error_no_subgroup'] = 'زیرگروه موجود نیست'; |
||||
$lang['aauth_error_self_pm'] = 'شما نمیتوانید به خودتان پیام ارسال کنید.'; |
||||
$lang['aauth_error_no_pm'] = 'پیامی یافت نشد'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = 'کاربر از قبل عضو این گروه می باشد'; |
||||
$lang['aauth_info_already_subgroup'] = 'زیرگروه از قبل شامل این گروه می باشد'; |
||||
$lang['aauth_info_group_exists'] = 'نام گروه از قبل موجود است'; |
||||
$lang['aauth_info_perm_exists'] = 'سطح دسترسی از قبل موجود است'; |
@ -1,58 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'Подтверждение аккаунта'; |
||||
$lang['aauth_email_verification_code'] = 'Ваш код подтверждения: '; |
||||
$lang['aauth_email_verification_text'] = " Так же вы можете нажать (или скопировать/вставить в адресную строку браузера) следующую ссылку\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'Сброс пароля'; |
||||
$lang['aauth_email_reset_text'] = "Для сброса пароля нажмите (или скопируйте/вставьте в адресную строку браузера) ссылку:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = 'Сброс пароля выполнен'; |
||||
$lang['aauth_email_reset_success_new_password'] = 'Ваш пароль сброшен. Ваш новый пароль : '; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = 'Email уже зарегистрирован в системе. Если вы забыли ваш пароль, нажмите на ссылку ниже.'; |
||||
$lang['aauth_error_username_exists'] = "Аккаунт с этим именен пользователя уже есть в системе. Введите другое имя пользователя, или если вы забыли ваш пароль, нажмите на ссылку ниже."; |
||||
$lang['aauth_error_email_invalid'] = 'Некорректный адрес e-mail'; |
||||
$lang['aauth_error_password_invalid'] = 'Некорректный пароль'; |
||||
$lang['aauth_error_username_invalid'] = 'Некорректное имя пользователя'; |
||||
$lang['aauth_error_username_required'] = 'Логин обязателен'; |
||||
$lang['aauth_error_totp_code_required'] = 'Требуется код аутентификации'; |
||||
$lang['aauth_error_totp_code_invalid'] = 'Неверный код аутентификации'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = 'Указанный Email уже есть в системе. Введите другой адрес.'; |
||||
$lang['aauth_error_update_username_exists'] = "Указаное имя пользователя уже есть в системе. Введите другое имя пользователя."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = 'Извините, у вас нет доступа к запрашиваемому ресурсу.'; |
||||
$lang['aauth_error_login_failed_email'] = 'Неверный email или пароль.'; |
||||
$lang['aauth_error_login_failed_name'] = 'Неверное имя пользователя или пароль.'; |
||||
$lang['aauth_error_login_failed_all'] = 'Неверный E-mail, имя пользователя или пароль.'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = 'Количество попыток входа превышено, ваш аккаунт временно заблокирован.'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'Извините, текст с reCAPTCHA введен неверно.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = 'Пользователь не существует'; |
||||
$lang['aauth_error_account_not_verified'] = 'Ваш акккаунт не подтвержден. Проверьте ваш ящик e-mail и подтвердите аккаунт.'; |
||||
$lang['aauth_error_no_group'] = 'Группа не существует'; |
||||
$lang['aauth_error_no_subgroup'] = 'Подгруппа не существует'; |
||||
$lang['aauth_error_self_pm'] = 'Нельзя отправить сообщение самому себе.'; |
||||
$lang['aauth_error_no_pm'] = 'Личное сообщение не найдено'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = 'Пользователь уже состоит в группе'; |
||||
$lang['aauth_info_already_subgroup'] = 'Подгруппа состоит в группе'; |
||||
$lang['aauth_info_group_exists'] = 'Такое имя группы уже есть'; |
||||
$lang['aauth_info_perm_exists'] = 'Такое имя разрешений уже есть'; |
@ -1,63 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/** |
||||
* @author Translated by Terry Lin ( |
||||
* @link https://github.com/terrylinooo) |
||||
*/ |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = '帐户验证'; |
||||
$lang['aauth_email_verification_code'] = '您的验证码:'; |
||||
$lang['aauth_email_verification_text'] = "您可以点击(或者复制贴上)以下链接\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = '重设密码'; |
||||
$lang['aauth_email_reset_text'] = "欲重设你的密码请点击(或者复制贴上到浏览器网址列)下方链接:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = '密码重设成功'; |
||||
$lang['aauth_email_reset_success_new_password'] = '您的密码已寄出成功。您的新密码是:'; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = '电邮地址已存在系统中。如果您忘了密码,可以按下方链接。 '; |
||||
$lang['aauth_error_username_exists'] = "此用户名的帐户已存在系统中,请输入不同的用户名。如果是忘了密码,请按下方链接。"; |
||||
$lang['aauth_error_email_invalid'] = '无效的电子邮件地址'; |
||||
$lang['aauth_error_password_invalid'] = '无效的密码'; |
||||
$lang['aauth_error_username_invalid'] = '无效的用户名'; |
||||
$lang['aauth_error_username_required'] = '需要用户名'; |
||||
$lang['aauth_error_totp_code_required'] = '需要证认码'; |
||||
$lang['aauth_error_totp_code_invalid'] = '无效的证认码'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = '电邮地址已存在系统中。请输入不同的电邮地址。 '; |
||||
$lang['aauth_error_update_username_exists'] = "用户名已存在系统中,请输入不同的用户名。"; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = '对不起,您无法存取您需要的资源。 '; |
||||
$lang['aauth_error_login_failed_email'] = '电邮地址和密码不符'; |
||||
$lang['aauth_error_login_failed_name'] = '用户名和密码不符'; |
||||
$lang['aauth_error_login_failed_all'] = '电邮地址、用户名和或密码不符'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = '您已达到登入尝试限制数,您的帐户已被锁住。 '; |
||||
$lang['aauth_error_recaptcha_not_correct'] = '对不起,reCAPTCHA 验证码输入错误。 '; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = '用户不存在'; |
||||
$lang['aauth_error_account_not_verified'] = '您的帐户尚未验证,请检查信箱并验证帐户。 '; |
||||
$lang['aauth_error_no_group'] = '群组不存在'; |
||||
$lang['aauth_error_no_subgroup'] = '子群组不存在'; |
||||
$lang['aauth_error_self_pm'] = '传信息给您自己是不可能的。 '; |
||||
$lang['aauth_error_no_pm'] = '找不到私人信息'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = '用户已是群组成员'; |
||||
$lang['aauth_info_already_subgroup'] = '子群组已是群组成员'; |
||||
$lang['aauth_info_group_exists'] = '群组名称已存在'; |
||||
$lang['aauth_info_perm_exists'] = '权限名称已存在'; |
@ -1,56 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'Verificación de Cuenta'; |
||||
$lang['aauth_email_verification_code'] = 'Tu código de verificación es: '; |
||||
$lang['aauth_email_verification_text'] = " También puedes hacer click (o copia y pega en tu navegador) en el siguiente link. \n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'Reiniciar contraseña'; |
||||
$lang['aauth_email_reset_text'] = "Para reiniciar la contraseña click (o copia y pega en tu navegador) el siguiente link:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = 'Constraseña reiniciada exitosamente'; |
||||
$lang['aauth_email_reset_success_new_password'] = 'Tu contraseña ha sido correctamente reiniciada. Tu nueva contraseña es : '; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = 'El correo electrónico ya existe. Si olvidaste tu contraseña, puedes hacer click en el siguiente link.'; |
||||
$lang['aauth_error_username_exists'] = "Ya existe una cuenta con ese nombre de usuario. Por favor ingrese un nombre de usuario diferente, o si olvidaste tu contraseña puedes hacer click en el siguiente link."; |
||||
$lang['aauth_error_email_invalid'] = 'Correo electrónico inválido'; |
||||
$lang['aauth_error_password_invalid'] = 'Contraseña invalida'; |
||||
$lang['aauth_error_username_invalid'] = 'Nombre de usuario invalido'; |
||||
$lang['aauth_error_username_required'] = 'Nombre de usuario obligatorio'; |
||||
$lang['aauth_error_totp_code_required'] = 'El código TOTP es obligatorio'; |
||||
$lang['aauth_error_totp_code_invalid'] = 'Código TOTP obligatorio'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = 'El correo electrónico ya existe, por favor ingresa un correo electrónico diferente.'; |
||||
$lang['aauth_error_update_username_exists'] = "El nombre de usuario ya existe, por favor ingresa un nombre de usuario diferente."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = 'Ups, lo siento, no tienes permiso para ver el recurso solicitado.'; |
||||
$lang['aauth_error_login_failed_email'] = 'El Correo electrónico y contraseña no coinciden.'; |
||||
$lang['aauth_error_login_failed_name'] = 'El Nombre de usuario y contraseña no coinciden.'; |
||||
$lang['aauth_error_login_failed_all'] = 'El Correo electrónico, nombre de usuario y contraseña no coinciden.'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = 'Has excedido el número de intentos de inicio de sesión, tu cuenta ha sido bloqueada.'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'Ups, El texto ingresado es incorrecto.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = 'El usuario no existe.'; |
||||
$lang['aauth_error_account_not_verified'] = 'Tu cuenta aún no ha sido verificada, por favor revisa tu correo electrónico y verifica tu cuenta.'; |
||||
$lang['aauth_error_no_group'] = 'El grupo no existe'; |
||||
$lang['aauth_error_self_pm'] = 'No es posible enviarte un mensaje a ti mismo.'; |
||||
$lang['aauth_error_no_pm'] = 'Mensaje privado no encontrado'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = 'El usuario ya es miembro del grupo'; |
||||
$lang['aauth_info_group_exists'] = 'El nombre del grupo ya existe'; |
||||
$lang['aauth_info_perm_exists'] = 'El nombre del permiso ya existe'; |
@ -1,58 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = 'Bekräfta konto'; |
||||
$lang['aauth_email_verification_code'] = 'Din bekräftelsekod är: '; |
||||
$lang['aauth_email_verification_text'] = " Du kan även trycka på (eller kopiera och klistra in) följande länk\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = 'Återställ lösenord'; |
||||
$lang['aauth_email_reset_text'] = "För att återställa ditt lösenord, tryck på (eller kopiera och klistra in i din webbläsares adressfält) länken nedan:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = 'Lösenordsåterställning skickad'; |
||||
$lang['aauth_email_reset_success_new_password'] = 'Ditt lösenord har blivit återställt. Ditt nya lösenord är: '; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = 'E-postadressen finns redan i systemet. Om du glömt ditt lösenord kan du trycka på länken nedan.'; |
||||
$lang['aauth_error_username_exists'] = "Det finns redan ett konto i systemet med det användarnamnet. Var vänlig ange ett annat användarnamn. Om du lömt ditt lösenord var vänlig tryck på länken nedan."; |
||||
$lang['aauth_error_email_invalid'] = 'Ogiltig e-postadress'; |
||||
$lang['aauth_error_password_invalid'] = 'Ogiltigt lösenord'; |
||||
$lang['aauth_error_username_invalid'] = 'Ogiltigt användarnamn'; |
||||
$lang['aauth_error_username_required'] = 'Användarnamn obligatoriskt'; |
||||
$lang['aauth_error_totp_code_required'] = 'Bekräftelsekod behövs'; |
||||
$lang['aauth_error_totp_code_invalid'] = 'Ogiltig bekräftelsekod'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = 'E-postadressen finns redan i systemet. Var vänlig ange en annan e-postadress.'; |
||||
$lang['aauth_error_update_username_exists'] = "Användarnamnet finns redan i systemet. Var vänlig ange ett annan användarnamn."; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = 'Du har tyvärr inte rättighet att visa den här resursen.'; |
||||
$lang['aauth_error_login_failed_email'] = 'E-postadressen och lösenordet stämmer inte överens.'; |
||||
$lang['aauth_error_login_failed_name'] = 'Användarnamnet och lösenordet stämmer inte överens.'; |
||||
$lang['aauth_error_login_failed_all'] = 'E-postadress, användarnamn och lösenord stämmer inte överens.'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = 'Du har förbrukat dina försök att logga in, ditt konto har blivit låst.'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = 'Tyvärr, reCAPTCHA-texten var felaktig.'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = 'Användaren finns inte.'; |
||||
$lang['aauth_error_account_not_verified'] = 'Ditt konto är inte bekräftat. Var vänlig kolla din e-post och bekräfta ditt konto.'; |
||||
$lang['aauth_error_no_group'] = 'Gruppen finns inte.'; |
||||
$lang['aauth_error_no_subgroup'] = 'Undergruppen finns inte.'; |
||||
$lang['aauth_error_self_pm'] = 'Det är inte möjligt att skicka meddelanden till dig själv.'; |
||||
$lang['aauth_error_no_pm'] = 'Meddelande hittades inte.'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = 'Användaren är redan med i gruppen.'; |
||||
$lang['aauth_info_already_subgroup'] = 'Undergruppen är redan med i gruppen.'; |
||||
$lang['aauth_info_group_exists'] = 'Gruppnamnet finns redan.'; |
||||
$lang['aauth_info_perm_exists'] = 'Rättighetsnamnet finns redan.'; |
@ -1,63 +0,0 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
||||
|
||||
/** |
||||
* @author Translated by Terry Lin ( |
||||
* @link https://github.com/terrylinooo) |
||||
*/ |
||||
|
||||
/* E-mail Messages */ |
||||
|
||||
// Account verification |
||||
$lang['aauth_email_verification_subject'] = '帳號驗證'; |
||||
$lang['aauth_email_verification_code'] = '您的驗證碼:'; |
||||
$lang['aauth_email_verification_text'] = "您可以點擊(或者複製貼上)以下連結\n\n"; |
||||
|
||||
// Password reset |
||||
$lang['aauth_email_reset_subject'] = '重設密碼'; |
||||
$lang['aauth_email_reset_text'] = "欲重設你的密碼請點擊(或者複製貼上到瀏覽器網址列)下方連結:\n\n"; |
||||
|
||||
// Password reset success |
||||
$lang['aauth_email_reset_success_subject'] = '密碼重設成功'; |
||||
$lang['aauth_email_reset_success_new_password'] = '您的密碼已寄出成功。您的新密碼是:'; |
||||
|
||||
|
||||
/* Error Messages */ |
||||
|
||||
// Account creation errors |
||||
$lang['aauth_error_email_exists'] = '電郵地址已存在系統中。如果您忘了密碼,可以按下方連結。'; |
||||
$lang['aauth_error_username_exists'] = "此用戶名的帳號已存在系統中,請輸入不同的用戶名。如果是忘了密碼,請按下方連結。"; |
||||
$lang['aauth_error_email_invalid'] = '無效的電子郵件地址'; |
||||
$lang['aauth_error_password_invalid'] = '無效的密碼'; |
||||
$lang['aauth_error_username_invalid'] = '無效的用戶名'; |
||||
$lang['aauth_error_username_required'] = '需要用戶名'; |
||||
$lang['aauth_error_totp_code_required'] = '需要證認碼'; |
||||
$lang['aauth_error_totp_code_invalid'] = '無效的證認碼'; |
||||
|
||||
|
||||
// Account update errors |
||||
$lang['aauth_error_update_email_exists'] = '電郵地址已存在系統中。請輸入不同的電郵地址。'; |
||||
$lang['aauth_error_update_username_exists'] = "用戶名已存在系統中,請輸入不同的用戶名。"; |
||||
|
||||
|
||||
// Access errors |
||||
$lang['aauth_error_no_access'] = '對不起,您無法存取您需要的資源。'; |
||||
$lang['aauth_error_login_failed_email'] = '電郵地址和密碼不符'; |
||||
$lang['aauth_error_login_failed_name'] = '用戶名和密碼不符'; |
||||
$lang['aauth_error_login_failed_all'] = '電郵地址、用戶名和或密碼不符'; |
||||
$lang['aauth_error_login_attempts_exceeded'] = '您已達到登入嘗試限制數,您的帳號已被鎖住。'; |
||||
$lang['aauth_error_recaptcha_not_correct'] = '對不起,reCAPTCHA 驗證碼輸入錯誤。'; |
||||
|
||||
// Misc. errors |
||||
$lang['aauth_error_no_user'] = '用戶不存在'; |
||||
$lang['aauth_error_account_not_verified'] = '您的帳號尚未驗證,請檢查信箱並驗證帳號。'; |
||||
$lang['aauth_error_no_group'] = '群組不存在'; |
||||
$lang['aauth_error_no_subgroup'] = '子群組不存在'; |
||||
$lang['aauth_error_self_pm'] = '傳訊息給您自己是不可能的。'; |
||||
$lang['aauth_error_no_pm'] = '找不到私人訊息'; |
||||
|
||||
|
||||
/* Info messages */ |
||||
$lang['aauth_info_already_member'] = '用戶已是群組成員'; |
||||
$lang['aauth_info_already_subgroup'] = '子群組已是群組成員'; |
||||
$lang['aauth_info_group_exists'] = '群組名稱已存在'; |
||||
$lang['aauth_info_perm_exists'] = '權限名稱已存在'; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
||||
{ |
||||
"root": "./docs", |
||||
"gitbook": ">=3.0.0", |
||||
"plugins": [ "phpclassdisplayer@1.0.4" ], |
||||
"pluginsConfig": { |
||||
"phpclassdisplayer": { |
||||
"scope": "->", |
||||
"anchors": true, |
||||
"hint_iconcenter": true, |
||||
"hint_iconsize": "fa-3x" |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,81 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
$config_aauth = array(); |
||||
|
||||
|
||||
$config_aauth = array( |
||||
'database' => array( |
||||
'_profile' => 'default', |
||||
'users' => 'aauth_users', |
||||
'login_attempts' => 'aauth_login_attempts', |
||||
'user_variables' => 'aauth_user_variables', |
||||
'groups' => 'aauth_groups', |
||||
'group_to_user' => 'aauth_user_to_group', |
||||
'group_to_subgroup' => 'aauth_group_to_group', |
||||
'permissions' => 'aauth_perms', |
||||
'permission_to_user' => 'aauth_perm_to_user', |
||||
'permission_to_group' => 'aauth_perm_to_group', |
||||
), |
||||
|
||||
'group' => array( |
||||
'admin' => 'admin', |
||||
'default' => 'default', |
||||
'public' => 'public', |
||||
), |
||||
|
||||
'login' => array( |
||||
'remember_time' => '3 days', |
||||
'use_username' => FALSE, |
||||
), |
||||
|
||||
'username' => array( |
||||
'additional_valid_chars' => array(), |
||||
), |
||||
|
||||
'password' => array( |
||||
'min_length' => 5, |
||||
'max_length' => 13, |
||||
'hash_algo' => PASSWORD_DEFAULT, |
||||
'hash_options' => array(), |
||||
), |
||||
|
||||
'email' => array( |
||||
'email' => 'admin@admin.com', |
||||
'name' => 'Emre Akay', |
||||
), |
||||
|
||||
'ddos_protection' => array( |
||||
'enabled' => TRUE, |
||||
'time_period' => '5 minutes', |
||||
'max_attempts' => 10, |
||||
'remove_successful_attempts' => TRUE, |
||||
), |
||||
|
||||
'totp' => array( |
||||
'enabled' => FALSE, |
||||
'only_on_ip_change' => FALSE, |
||||
'reset_over_reset_password' => FALSE, |
||||
'two_step_login_active' => FALSE, |
||||
), |
||||
|
||||
'recaptcha' => array( |
||||
'enabled' => FALSE, |
||||
'login_attempts' => 4, |
||||
'site_key' => '', |
||||
'secret' => '', |
||||
), |
||||
|
||||
'redirect' => array( |
||||
'no_permission' => FALSE, |
||||
), |
||||
|
||||
'link' => array( |
||||
'verification' => '/account/verification/', |
||||
'reset_password' => '/account/reset_password/', |
||||
'two_step_login' => '/account/twofactor_verification/', |
||||
), |
||||
); |
||||
|
||||
|
||||
|
||||
$config['aauth'] = $config_aauth; |
@ -0,0 +1,30 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Enable/Disable Aauth Init |
||||
|-------------------------------------------------------------------------- |
||||
*/ |
||||
$config['aauthinit_enabled'] = TRUE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Aauth Init table |
||||
|-------------------------------------------------------------------------- |
||||
*/ |
||||
$config['aauthinit_table'] = 'aauth_init'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Auto Update To Latest |
||||
|-------------------------------------------------------------------------- |
||||
*/ |
||||
$config['aauthinit_auto_latest'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| updates Path |
||||
|-------------------------------------------------------------------------- |
||||
*/ |
||||
$config['aauthinit_path'] = APPPATH.'libraries/Aauth_init/'; |
@ -0,0 +1,513 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Base Site URL |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| URL to your CodeIgniter root. Typically this will be your base URL, |
||||
| WITH a trailing slash: |
||||
| |
||||
| http://example.com/ |
||||
| |
||||
| WARNING: You MUST set this value! |
||||
| |
||||
| If it is not set, then CodeIgniter will try guess the protocol and path |
||||
| your installation, but due to security concerns the hostname will be set |
||||
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise. |
||||
| The auto-detection mechanism exists only for convenience during |
||||
| development and MUST NOT be used in production! |
||||
| |
||||
| If you need to allow multiple domains, remember that this file is still |
||||
| a PHP script and you can easily do that on your own. |
||||
| |
||||
*/ |
||||
$config['base_url'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Index File |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Typically this will be your index.php file, unless you've renamed it to |
||||
| something else. If you are using mod_rewrite to remove the page set this |
||||
| variable so that it is blank. |
||||
| |
||||
*/ |
||||
$config['index_page'] = 'index.php'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| URI PROTOCOL |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This item determines which server global should be used to retrieve the |
||||
| URI string. The default setting of 'REQUEST_URI' works for most servers. |
||||
| If your links do not seem to work, try one of the other delicious flavors: |
||||
| |
||||
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI'] |
||||
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING'] |
||||
| 'PATH_INFO' Uses $_SERVER['PATH_INFO'] |
||||
| |
||||
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded! |
||||
*/ |
||||
$config['uri_protocol'] = 'REQUEST_URI'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| URL suffix |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This option allows you to add a suffix to all URLs generated by CodeIgniter. |
||||
| For more information please see the user guide: |
||||
| |
||||
| https://codeigniter.com/user_guide/general/urls.html |
||||
*/ |
||||
$config['url_suffix'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Default Language |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This determines which set of language files should be used. Make sure |
||||
| there is an available translation if you intend to use something other |
||||
| than english. |
||||
| |
||||
*/ |
||||
$config['language'] = 'english'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Default Character Set |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This determines which character set is used by default in various methods |
||||
| that require a character set to be provided. |
||||
| |
||||
| See http://php.net/htmlspecialchars for a list of supported charsets. |
||||
| |
||||
*/ |
||||
$config['charset'] = 'UTF-8'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Enable/Disable System Hooks |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| If you would like to use the 'hooks' feature you must enable it by |
||||
| setting this variable to TRUE (boolean). See the user guide for details. |
||||
| |
||||
*/ |
||||
$config['enable_hooks'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Class Extension Prefix |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This item allows you to set the filename/classname prefix when extending |
||||
| native libraries. For more information please see the user guide: |
||||
| |
||||
| https://codeigniter.com/user_guide/general/core_classes.html |
||||
| https://codeigniter.com/user_guide/general/creating_libraries.html |
||||
| |
||||
*/ |
||||
$config['subclass_prefix'] = 'MY_'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Composer auto-loading |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Enabling this setting will tell CodeIgniter to look for a Composer |
||||
| package auto-loader script in application/vendor/autoload.php. |
||||
| |
||||
| $config['composer_autoload'] = TRUE; |
||||
| |
||||
| Or if you have your vendor/ directory located somewhere else, you |
||||
| can opt to set a specific path as well: |
||||
| |
||||
| $config['composer_autoload'] = '/path/to/vendor/autoload.php'; |
||||
| |
||||
| For more information about Composer, please visit http://getcomposer.org/ |
||||
| |
||||
| Note: This will NOT disable or override the CodeIgniter-specific |
||||
| autoloading (application/config/autoload.php) |
||||
*/ |
||||
$config['composer_autoload'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Allowed URL Characters |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| This lets you specify which characters are permitted within your URLs. |
||||
| When someone tries to submit a URL with disallowed characters they will |
||||
| get a warning message. |
||||
| |
||||
| As a security measure you are STRONGLY encouraged to restrict URLs to |
||||
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_- |
||||
| |
||||
| Leave blank to allow all characters -- but only if you are insane. |
||||
| |
||||
| The configured value is actually a regular expression character group |
||||
| and it will be executed as: ! preg_match('/^[<permitted_uri_chars>]+$/i |
||||
| |
||||
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!! |
||||
| |
||||
*/ |
||||
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Enable Query Strings |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| By default CodeIgniter uses search-engine friendly segment based URLs: |
||||
| example.com/who/what/where/ |
||||
| |
||||
| By default CodeIgniter enables access to the $_GET array. If for some |
||||
| reason you would like to disable it, set 'allow_get_array' to FALSE. |
||||
| |
||||
| You can optionally enable standard query string based URLs: |
||||
| example.com?who=me&what=something&where=here |
||||
| |
||||
| Options are: TRUE or FALSE (boolean) |
||||
| |
||||
| The other items let you set the query string 'words' that will |
||||
| invoke your controllers and its functions: |
||||
| example.com/index.php?c=controller&m=function |
||||
| |
||||
| Please note that some of the helpers won't work as expected when |
||||
| this feature is enabled, since CodeIgniter is designed primarily to |
||||
| use segment based URLs. |
||||
| |
||||
*/ |
||||
$config['allow_get_array'] = TRUE; |
||||
$config['enable_query_strings'] = FALSE; |
||||
$config['controller_trigger'] = 'c'; |
||||
$config['function_trigger'] = 'm'; |
||||
$config['directory_trigger'] = 'd'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Error Logging Threshold |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| You can enable error logging by setting a threshold over zero. The |
||||
| threshold determines what gets logged. Threshold options are: |
||||
| |
||||
| 0 = Disables logging, Error logging TURNED OFF |
||||
| 1 = Error Messages (including PHP errors) |
||||
| 2 = Debug Messages |
||||
| 3 = Informational Messages |
||||
| 4 = All Messages |
||||
| |
||||
| You can also pass an array with threshold levels to show individual error types |
||||
| |
||||
| array(2) = Debug Messages, without Error Messages |
||||
| |
||||
| For a live site you'll usually only enable Errors (1) to be logged otherwise |
||||
| your log files will fill up very fast. |
||||
| |
||||
*/ |
||||
$config['log_threshold'] = 0; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Error Logging Directory Path |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Leave this BLANK unless you would like to set something other than the default |
||||
| application/logs/ directory. Use a full server path with trailing slash. |
||||
| |
||||
*/ |
||||
$config['log_path'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Log File Extension |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| The default filename extension for log files. The default 'php' allows for |
||||
| protecting the log files via basic scripting, when they are to be stored |
||||
| under a publicly accessible directory. |
||||
| |
||||
| Note: Leaving it blank will default to 'php'. |
||||
| |
||||
*/ |
||||
$config['log_file_extension'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Log File Permissions |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| The file system permissions to be applied on newly created log files. |
||||
| |
||||
| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal |
||||
| integer notation (i.e. 0700, 0644, etc.) |
||||
*/ |
||||
$config['log_file_permissions'] = 0644; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Date Format for Logs |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Each item that is logged has an associated date. You can use PHP date |
||||
| codes to set your own date formatting |
||||
| |
||||
*/ |
||||
$config['log_date_format'] = 'Y-m-d H:i:s'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Error Views Directory Path |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Leave this BLANK unless you would like to set something other than the default |
||||
| application/views/errors/ directory. Use a full server path with trailing slash. |
||||
| |
||||
*/ |
||||
$config['error_views_path'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Cache Directory Path |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Leave this BLANK unless you would like to set something other than the default |
||||
| application/cache/ directory. Use a full server path with trailing slash. |
||||
| |
||||
*/ |
||||
$config['cache_path'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Cache Include Query String |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Whether to take the URL query string into consideration when generating |
||||
| output cache files. Valid options are: |
||||
| |
||||
| FALSE = Disabled |
||||
| TRUE = Enabled, take all query parameters into account. |
||||
| Please be aware that this may result in numerous cache |
||||
| files generated for the same page over and over again. |
||||
| array('q') = Enabled, but only take into account the specified list |
||||
| of query parameters. |
||||
| |
||||
*/ |
||||
$config['cache_query_string'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Encryption Key |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| If you use the Encryption class, you must set an encryption key. |
||||
| See the user guide for more info. |
||||
| |
||||
| https://codeigniter.com/user_guide/libraries/encryption.html |
||||
| |
||||
*/ |
||||
$config['encryption_key'] = ''; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Session Variables |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| 'sess_driver' |
||||
| |
||||
| The storage driver to use: files, database, redis, memcached |
||||
| |
||||
| 'sess_cookie_name' |
||||
| |
||||
| The session cookie name, must contain only [0-9a-z_-] characters |
||||
| |
||||
| 'sess_expiration' |
||||
| |
||||
| The number of SECONDS you want the session to last. |
||||
| Setting to 0 (zero) means expire when the browser is closed. |
||||
| |
||||
| 'sess_save_path' |
||||
| |
||||
| The location to save sessions to, driver dependent. |
||||
| |
||||
| For the 'files' driver, it's a path to a writable directory. |
||||
| WARNING: Only absolute paths are supported! |
||||
| |
||||
| For the 'database' driver, it's a table name. |
||||
| Please read up the manual for the format with other session drivers. |
||||
| |
||||
| IMPORTANT: You are REQUIRED to set a valid save path! |
||||
| |
||||
| 'sess_match_ip' |
||||
| |
||||
| Whether to match the user's IP address when reading the session data. |
||||
| |
||||
| WARNING: If you're using the database driver, don't forget to update |
||||
| your session table's PRIMARY KEY when changing this setting. |
||||
| |
||||
| 'sess_time_to_update' |
||||
| |
||||
| How many seconds between CI regenerating the session ID. |
||||
| |
||||
| 'sess_regenerate_destroy' |
||||
| |
||||
| Whether to destroy session data associated with the old session ID |
||||
| when auto-regenerating the session ID. When set to FALSE, the data |
||||
| will be later deleted by the garbage collector. |
||||
| |
||||
| Other session cookie settings are shared with the rest of the application, |
||||
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here. |
||||
| |
||||
*/ |
||||
$config['sess_driver'] = 'files'; |
||||
$config['sess_cookie_name'] = 'ci_session'; |
||||
$config['sess_expiration'] = 7200; |
||||
$config['sess_save_path'] = '/application/tmp'; |
||||
$config['sess_match_ip'] = FALSE; |
||||
$config['sess_time_to_update'] = 300; |
||||
$config['sess_regenerate_destroy'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Cookie Related Variables |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions |
||||
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies |
||||
| 'cookie_path' = Typically will be a forward slash |
||||
| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists. |
||||
| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript) |
||||
| |
||||
| Note: These settings (with the exception of 'cookie_prefix' and |
||||
| 'cookie_httponly') will also affect sessions. |
||||
| |
||||
*/ |
||||
$config['cookie_prefix'] = ''; |
||||
$config['cookie_domain'] = ''; |
||||
$config['cookie_path'] = '/'; |
||||
$config['cookie_secure'] = FALSE; |
||||
$config['cookie_httponly'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Standardize newlines |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Determines whether to standardize newline characters in input data, |
||||
| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value. |
||||
| |
||||
| This is particularly useful for portability between UNIX-based OSes, |
||||
| (usually \n) and Windows (\r\n). |
||||
| |
||||
*/ |
||||
$config['standardize_newlines'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Global XSS Filtering |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Determines whether the XSS filter is always active when GET, POST or |
||||
| COOKIE data is encountered |
||||
| |
||||
| WARNING: This feature is DEPRECATED and currently available only |
||||
| for backwards compatibility purposes! |
||||
| |
||||
*/ |
||||
$config['global_xss_filtering'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Cross Site Request Forgery |
||||
|-------------------------------------------------------------------------- |
||||
| Enables a CSRF cookie token to be set. When set to TRUE, token will be |
||||
| checked on a submitted form. If you are accepting user data, it is strongly |
||||
| recommended CSRF protection be enabled. |
||||
| |
||||
| 'csrf_token_name' = The token name |
||||
| 'csrf_cookie_name' = The cookie name |
||||
| 'csrf_expire' = The number in seconds the token should expire. |
||||
| 'csrf_regenerate' = Regenerate token on every submission |
||||
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks |
||||
*/ |
||||
$config['csrf_protection'] = FALSE; |
||||
$config['csrf_token_name'] = 'csrf_test_name'; |
||||
$config['csrf_cookie_name'] = 'csrf_cookie_name'; |
||||
$config['csrf_expire'] = 7200; |
||||
$config['csrf_regenerate'] = TRUE; |
||||
$config['csrf_exclude_uris'] = array(); |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Output Compression |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Enables Gzip output compression for faster page loads. When enabled, |
||||
| the output class will test whether your server supports Gzip. |
||||
| Even if it does, however, not all browsers support compression |
||||
| so enable only if you are reasonably sure your visitors can handle it. |
||||
| |
||||
| Only used if zlib.output_compression is turned off in your php.ini. |
||||
| Please do not use it together with httpd-level output compression. |
||||
| |
||||
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it |
||||
| means you are prematurely outputting something to your browser. It could |
||||
| even be a line of whitespace at the end of one of your scripts. For |
||||
| compression to work, nothing can be sent before the output buffer is called |
||||
| by the output class. Do not 'echo' any values with compression enabled. |
||||
| |
||||
*/ |
||||
$config['compress_output'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Master Time Reference |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Options are 'local' or any PHP supported timezone. This preference tells |
||||
| the system whether to use your server's local time as the master 'now' |
||||
| reference, or convert it to the configured one timezone. See the 'date |
||||
| helper' page of the user guide for information regarding date handling. |
||||
| |
||||
*/ |
||||
$config['time_reference'] = 'local'; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Rewrite PHP Short Tags |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| If your PHP installation does not have short tag support enabled CI |
||||
| can rewrite the tags on-the-fly, enabling you to utilize that syntax |
||||
| in your view files. Options are TRUE or FALSE (boolean) |
||||
| |
||||
| Note: You need to have eval() enabled for this to work. |
||||
| |
||||
*/ |
||||
$config['rewrite_short_tags'] = FALSE; |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Reverse Proxy IPs |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| If your server is behind a reverse proxy, you must whitelist the proxy |
||||
| IP addresses from which CodeIgniter should trust headers such as |
||||
| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify |
||||
| the visitor's IP address. |
||||
| |
||||
| You can use both an array or a comma-separated list of proxy addresses, |
||||
| as well as specifying whole subnets. Here are a few examples: |
||||
| |
||||
| Comma-separated: '10.0.1.200,192.168.5.0/24' |
||||
| Array: array('10.0.1.200', '192.168.5.0/24') |
||||
*/ |
||||
$config['proxy_ips'] = ''; |
@ -0,0 +1,96 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
/* |
||||
| ------------------------------------------------------------------- |
||||
| DATABASE CONNECTIVITY SETTINGS |
||||
| ------------------------------------------------------------------- |
||||
| This file will contain the settings needed to access your database. |
||||
| |
||||
| For complete instructions please consult the 'Database Connection' |
||||
| page of the User Guide. |
||||
| |
||||
| ------------------------------------------------------------------- |
||||
| EXPLANATION OF VARIABLES |
||||
| ------------------------------------------------------------------- |
||||
| |
||||
| ['dsn'] The full DSN string describe a connection to the database. |
||||
| ['hostname'] The hostname of your database server. |
||||
| ['username'] The username used to connect to the database |
||||
| ['password'] The password used to connect to the database |
||||
| ['database'] The name of the database you want to connect to |
||||
| ['dbdriver'] The database driver. e.g.: mysqli. |
||||
| Currently supported: |
||||
| cubrid, ibase, mssql, mysql, mysqli, oci8, |
||||
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv |
||||
| ['dbprefix'] You can add an optional prefix, which will be added |
||||
| to the table name when using the Query Builder class |
||||
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection |
||||
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed. |
||||
| ['cache_on'] TRUE/FALSE - Enables/disables query caching |
||||
| ['cachedir'] The path to the folder where cache files should be stored |
||||
| ['char_set'] The character set used in communicating with the database |
||||
| ['dbcollat'] The character collation used in communicating with the database |
||||
| NOTE: For MySQL and MySQLi databases, this setting is only used |
||||
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 |
||||
| (and in table creation queries made with DB Forge). |
||||
| There is an incompatibility in PHP with mysql_real_escape_string() which |
||||
| can make your site vulnerable to SQL injection if you are using a |
||||
| multi-byte character set and are running versions lower than these. |
||||
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected. |
||||
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix |
||||
| ['encrypt'] Whether or not to use an encrypted connection. |
||||
| |
||||
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE |
||||
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options: |
||||
| |
||||
| 'ssl_key' - Path to the private key file |
||||
| 'ssl_cert' - Path to the public key certificate file |
||||
| 'ssl_ca' - Path to the certificate authority file |
||||
| 'ssl_capath' - Path to a directory containing trusted CA certificats in PEM format |
||||
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':') |
||||
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only) |
||||
| |
||||
| ['compress'] Whether or not to use client compression (MySQL only) |
||||
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections |
||||
| - good for ensuring strict SQL while developing |
||||
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections. |
||||
| ['failover'] array - A array with 0 or more data for connections if the main should fail. |
||||
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries. |
||||
| NOTE: Disabling this will also effectively disable both |
||||
| $this->db->last_query() and profiling of DB queries. |
||||
| When you run a query, with this setting set to TRUE (default), |
||||
| CodeIgniter will store the SQL statement for debugging purposes. |
||||
| However, this may cause high memory usage, especially if you run |
||||
| a lot of SQL queries ... disable this to avoid that problem. |
||||
| |
||||
| The $active_group variable lets you choose which connection group to |
||||
| make active. By default there is only one group (the 'default' group). |
||||
| |
||||
| The $query_builder variables lets you determine whether or not to load |
||||
| the query builder class. |
||||
*/ |
||||
$active_group = 'default'; |
||||
$query_builder = TRUE; |
||||
|
||||
$db['default'] = array( |
||||
'dsn' => '', |
||||
'hostname' => '127.0.0.1', |
||||
'username' => 'root', |
||||
'password' => '', |
||||
'database' => 'aauth_test', |
||||
'dbdriver' => 'mysqli', |
||||
'dbprefix' => '', |
||||
'pconnect' => FALSE, |
||||
'db_debug' => (ENVIRONMENT !== 'production'), |
||||
'cache_on' => FALSE, |
||||
'cachedir' => '', |
||||
'char_set' => 'utf8', |
||||
'dbcollat' => 'utf8_general_ci', |
||||
'swap_pre' => '', |
||||
'encrypt' => FALSE, |
||||
'compress' => FALSE, |
||||
'stricton' => FALSE, |
||||
'failover' => array(), |
||||
'save_queries' => TRUE |
||||
); |
@ -0,0 +1,27 @@
|
||||
# CodeIgniter-Aauth |
||||
|
||||
Aauth is a User Authorization Library for CodeIgniter 2.x and 3.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite its ease of use, it has also very advanced features like private messages, groupping, access management, and public access. |
||||
|
||||
*** |
||||
### Features |
||||
* User Management and Operations (login, logout, register, verification via e-mail, forgotten password, user ban, login DDoS protection) |
||||
* Group Operations (creating/deleting groups, membership management) |
||||
* Admin and Public Group support (Public permissions) |
||||
* Permission Management (creating/deleting permissions, allow/deny groups, public permissions, permission checking) |
||||
* Group Permissions |
||||
* User Permissions |
||||
* User and System Variables |
||||
* Login DDoS Protection |
||||
* Private Messages (between users) |
||||
* Error Messages and Validations |
||||
* Langugage and config file support |
||||
* Flexible implementation |
||||
|
||||
*** |
||||
### What is new in Version 2 |
||||
* User Permissions |
||||
* User and System Variables |
||||
* Login DDoS Protection |
||||
* Updated functions (check documentation for details) |
||||
* Bugs fixes |
||||
* TOTP (Time-based One-time Password) |
@ -0,0 +1,14 @@
|
||||
# Summary |
||||
|
||||
* [Introduction](README.md) |
||||
* [Models](models/README.md) |
||||
* [Users](models/users.md) |
||||
* [User Variables](models/user-variables.md) |
||||
* [Login Attempts](models/login-attempts.md) |
||||
* [Groups](models/groups.md) |
||||
* [Group to User](models/group_to_user.md) |
||||
* [Group to SubGroup](models/group_to_subgroup.md) |
||||
* [Permissions](models/permissions.md) |
||||
* [Permission to User](models/permission_to_user.md) |
||||
* [Permission to Group](models/permission_to_group.md) |
||||
|
After Width: | Height: | Size: 46 KiB |
@ -0,0 +1,7 @@
|
||||
# Functions |
||||
* [User](user.md) |
||||
* [Examples](user.md#examples) |
||||
* [References](user.md#references) |
||||
* [Login](login.md) |
||||
* [Examples](login.md#examples) |
||||
* [References](login.md#references) |
@ -0,0 +1,93 @@
|
||||
# Login Functions |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Aauth" %} |
||||
User Authorization Library for CodeIgniter 2.x and 3.x |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "login($identifier, $pass [, $remember = FALSE, $totp_code = NULL ])" %} |
||||
Login User |
||||
{% param "$identifier", type="string" %} |
||||
User's Identifier (email or name definied by Config-Var `login_with_name`) |
||||
{% param "$pass", type="string" %} |
||||
User's Password |
||||
{% param "$remember", type="bool" %} |
||||
Remember |
||||
{% param "$totp_code", type="string" %} |
||||
TOTP Code |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "is_loggedin()" %} |
||||
Checks if user is logged in |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` if not logged in. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "is_loggedin()" %} |
||||
Log a user out / Kills user session |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "login_fast($user_id)" %} |
||||
Login User only with user_id |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "reset_login_attempts()" %} |
||||
Removes login attempts based on IP-Address & Timestamp |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "remind_password($email)" %} |
||||
Sends a user a link to reset password |
||||
{% param "$email", type="string" %} |
||||
User's email address |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "reset_password($ver_code)" %} |
||||
Generate new password and email it to the user |
||||
{% param "$ver_code", type="string" %} |
||||
Verification code |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update_last_login([ $user_id = FALSE ])" %} |
||||
Updates last login timestamp |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update_login_attempts()" %} |
||||
Update login attempt |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` if login attempt exceeded. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update_remember($user_id [, $expression = NULL, $expire = NULL ])" %} |
||||
Update amount of time a user is remembered for |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$expression", type="string" %} |
||||
Expression |
||||
{% param "$expire", type="string" %} |
||||
Expire Date |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` if login attempt exceeded. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,57 @@
|
||||
# User Functions |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Aauth" %} |
||||
User Authorization Library for CodeIgniter 2.x and 3.x |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create_user($email, $pass [, $name = FALSE ])" %} |
||||
Update amount of time a user is remembered for |
||||
{% param "$email", type="string" %} |
||||
User's email address |
||||
{% param "$pass", type="string" %} |
||||
User's password |
||||
{% param "$name", type="string" %} |
||||
User's name |
||||
{% return %} |
||||
Either `User_ID` of created user, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update_user($user_id [, $email = FALSE, $pass = FALSE, $name = FALSE ])" %} |
||||
Update amount of time a user is remembered for |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$email", type="bool|string" %} |
||||
User's email address |
||||
{% param "$pass", type="bool|string" %} |
||||
User's password |
||||
{% param "$name", type="bool|string" %} |
||||
User's name |
||||
{% return %} |
||||
Either `TRUE`, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "list_users([ $group_par = FALSE, $limit = FALSE, $offset = FALSE, $include_banneds = FALSE ])" %} |
||||
Return users as an object array |
||||
{% param "$group_par", type="int|string" %} |
||||
Specify group, to list all users in specific group |
||||
{% param "$limit", type="int" %} |
||||
Limit of users to be returned |
||||
{% param "$offset", type="int" %} |
||||
Offset for limited number of users |
||||
{% param "$include_banneds", type="bool" %} |
||||
Includes banned users |
||||
{% return %} |
||||
Array of objects. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_user([ $user_id = FALSE ])" %} |
||||
Get user information |
||||
{% param "$user_id", type="bool|int" %} |
||||
User's ID or `FALSE` for current user |
||||
{% return %} |
||||
Either object, or `FALSE` on failure. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,20 @@
|
||||
# Models |
||||
|
||||
* [Users](users.md) |
||||
* [Examples](user.md#examples) |
||||
* [References](user.md#references) |
||||
* [User Variables](user-variables.md) |
||||
* [Examples](user-variables.md#examples) |
||||
* [References](user-variables.md#references) |
||||
* [Login Attempts](login-attempts.md) |
||||
* [Examples](login-attempts.md#examples) |
||||
* [References](login-attempts.md#references) |
||||
* [Groups](groups.md) |
||||
* [Examples](groups.md#examples) |
||||
* [References](groups.md#references) |
||||
* [Group to User](group_to_user.md) |
||||
* [Examples](group_to_user.md#examples) |
||||
* [References](group_to_user.md#references) |
||||
* [Group to SubGroup](group_to_subgroup.md) |
||||
* [Examples](group_to_subgroup.md#examples) |
||||
* [References](group_to_subgroup.md#references) |
@ -0,0 +1,54 @@
|
||||
# Group to Subgroup Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Group_to_subgroup_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($group_id, $subgroup_id)" %} |
||||
Assigns a group to a subgroup. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$subgroup_id", type="int" %} |
||||
Sub-Groub's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($group_id, $subgroup_id)" %} |
||||
Removes a assigned group from a subgroup. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$subgroup_id", type="int" %} |
||||
Sub-Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_subgroup($subgroup_id)" %} |
||||
Removes all assigned groups from a subgroup. |
||||
{% param "$subgroup_id", type="int" %} |
||||
Sub-Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_group($group_id)" %} |
||||
Removes all assigned subgroups from a group. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "exist($group_id, $subgroup_id)" %} |
||||
Checks if a group is already assigned to a subgroup. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$subgroup_id", type="int" %} |
||||
Sub-Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,54 @@
|
||||
# Group to User Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Group_to_user_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($group_id, $user_id)" %} |
||||
Assigns a group to a user. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($group_id, $user_id)" %} |
||||
Removes a assigned group from a user. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_user($user_id)" %} |
||||
Removes all assigned groups from a user. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_group($group_id)" %} |
||||
Removes a groups from any user. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "exist($group_id, $user_id)" %} |
||||
Checks if a group is already assigned to a user. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,60 @@
|
||||
# Groups Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Groups_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($name [, $definition = ''])" %} |
||||
Adds a group to database. |
||||
{% param "$name", type="string" %} |
||||
Group's name |
||||
{% param "$definition", type="string" %} |
||||
Group's definition |
||||
{% return %} |
||||
Either `Group_ID` of created group, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update($group_id [, $name = NULL, $definition = NULL])" %} |
||||
Updates a group in database. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% param "$name", type="string" %} |
||||
Group's name |
||||
{% param "$definition", type="string" %} |
||||
Group's definition |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($group_id)" %} |
||||
Removes a group from database. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get($group_id)" %} |
||||
Retrieves a group from database. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_id($name)" %} |
||||
Retrieves a group id from database. |
||||
{% param "$name", type="int" %} |
||||
Group's name |
||||
{% return %} |
||||
Either `Group_ID`, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_all()" %} |
||||
Retrieves all groups from database. |
||||
{% return %} |
||||
Array of all groups as object. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,26 @@
|
||||
# Login Attempts Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Login_Attempts_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get()" %} |
||||
Retrieves a login attempt from database, based on IP-Address and timestamp. |
||||
{% return %} |
||||
Value of login attempts |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update()" %} |
||||
Updates/Created a login attempt in database, based on IP-Address and timestamp. |
||||
{% return %} |
||||
Either `TRUE` if login attempt below `max_attempts`, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete()" %} |
||||
Removes a login attempt from database, based on IP-Address and timestamp. |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,54 @@
|
||||
# Permission to Group Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Permission_to_group_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($permission_id, $group_id)" %} |
||||
Assigns a permission to a group. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($permission_id, $group_id)" %} |
||||
Removes a assigned permission from a group. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_group($group_id)" %} |
||||
Removes all assigned permissions from a group. |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_permission($permission_id)" %} |
||||
Remove a permission from any group. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "exist($permission_id, $group_id)" %} |
||||
Checks if a permission is already assigned to a group. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$group_id", type="int" %} |
||||
Group's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,54 @@
|
||||
# Permission to User Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Permission_to_user_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($permission_id, $user_id)" %} |
||||
Assigns a permission to a user. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($permission_id, $user_id)" %} |
||||
Removes a assigned permission from a user. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_user($user_id)" %} |
||||
Removes all assigned permissions from a user. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete_by_permission($permission_id)" %} |
||||
Remove a permission from any user. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "exist($permission_id, $user_id)" %} |
||||
Checks if a permission is already assigned to a user. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,60 @@
|
||||
# Permissions Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Permissions_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($name [, $definition = ''])" %} |
||||
Creates a permission. |
||||
{% param "$name", type="string" %} |
||||
Permission's name |
||||
{% param "$definition", type="string" %} |
||||
Permission's definition |
||||
{% return %} |
||||
Either `Permission_ID` of created permission, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update($permission_id [, $name = NULL, $definition = NULL])" %} |
||||
Updates a permission. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% param "$name", type="string" %} |
||||
Permission's name |
||||
{% param "$definition", type="string" %} |
||||
Permission's definition |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($id)" %} |
||||
Removes a permission. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get($permission_id)" %} |
||||
Retrieves a permission. |
||||
{% param "$permission_id", type="int" %} |
||||
Permission's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_id($name)" %} |
||||
Retrieves permission_id. |
||||
{% param "$name", type="int" %} |
||||
Permission's name |
||||
{% return %} |
||||
Either `Permission_ID`, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_all()" %} |
||||
Retrieves all permissions. |
||||
{% return %} |
||||
Array of all permission as object. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,48 @@
|
||||
# User Variables Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "User_Variables_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update($user_id, $key, $value)" %} |
||||
Updates/Creates a user uariable for a user in database. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$key", type="string" %} |
||||
User Variable Key |
||||
{% param "$value", type="string" %} |
||||
User Variable Value |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get($user_id, $key)" %} |
||||
Retrieves a user variable from a user in database. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$key", type="string" %} |
||||
User Variable Key |
||||
{% return %} |
||||
Either the value of the user variable, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_by_user_id($user_id)" %} |
||||
Retrieves all user variables from a user in database. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either a array of all user variables, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($user_id [, $key = NULL])" %} |
||||
Removes all user variables or only one user variable from a user in database. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$key", type="string" %} |
||||
User Variable Key |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
@ -0,0 +1,135 @@
|
||||
# Users Model |
||||
|
||||
## Examples |
||||
|
||||
## References |
||||
|
||||
{% PHPclassDisplayer "Users_model" %} |
||||
{% endPHPclassDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "create($email, $pass [, $username = '' ])" %} |
||||
Adds a user to the database. |
||||
{% param "$email", type="string" %} |
||||
User's email address |
||||
{% param "$pass", type="string" %} |
||||
User's password |
||||
{% param "$name", type="string" %} |
||||
User's name |
||||
{% return %} |
||||
Either `User_ID` of created user, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update($user_id, $data)" %} |
||||
Updates data of a user in database. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$data", type="array" %} |
||||
Array of data to update |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "delete($user_id)" %} |
||||
Removes a user from database. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_all([$options = array()])" %} |
||||
Retrieves all users from database. |
||||
{% hint %} |
||||
Available options: |
||||
- `filters` (_array_) - A associative array with 'column'-name as key and value |
||||
- `include_banneds` (_bool_) - Whether to include banned user's |
||||
- `only_banneds` (_bool_) - Whether to include only banned user's |
||||
- `offset` (_int_) - Number of rows to limit the results to |
||||
- `limit` (_int_) - Number of rows to skip |
||||
{% param "$options", type="array" %} |
||||
Array of options. |
||||
{% return %} |
||||
Array of all users as object. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "ban($user_id [, $ver_code = NULL])" %} |
||||
Bans/Unverfies a user. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$ver_code", type="string" %} |
||||
Verification Code |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "unban($user_id [, $ver_code = NULL])" %} |
||||
Unbans/Verfies a user. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$ver_code", type="string" %} |
||||
Verification Code |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "update_($user_id, $type)" %} |
||||
Updates last_activity or last_login of a user. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$type", type="string" %} |
||||
Update Type |
||||
{% hint %} |
||||
Available types: |
||||
- `activity` |
||||
- `last_login` |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "exist_by_($filters = array())" %} |
||||
Checks if a user exist in database depending on filters. |
||||
{% param "$filters", type="array" %} |
||||
A associative array with 'column'-name as key and value |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_($filters, $result_column)" %} |
||||
Retrieves a user depending on filters with a result column. |
||||
{% param "$filters", type="array" %} |
||||
A associative array with 'column'-name as key and value |
||||
{% param "$result_column", type="string" %} |
||||
Column name thats get returned |
||||
{% return %} |
||||
Either `value` of selected column on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "get_by_($filters [, $options = NULL])" %} |
||||
Retrieves users from database depending on filters and options. |
||||
{% param "$filters", type="array" %} |
||||
A associative array with column name as key and value |
||||
{% param "$options", type="array" %} |
||||
Array of options. |
||||
{% hint %} |
||||
Available options: |
||||
- `select` (_bool_) - Single column name or Multiple column names comma separeated |
||||
- `offset` (_int_) - Number of rows to limit the results to |
||||
- `limit` (_int_) - Number of rows to skip |
||||
{% return %} |
||||
CI's Database `get()` |
||||
{% endPHPmethodDisplayer %} |
||||
|
||||
{% PHPmethodDisplayer "is_($user_id, $type)" %} |
||||
Checks if a user is banned or verified. |
||||
{% param "$user_id", type="int" %} |
||||
User's ID |
||||
{% param "$type", type="string" %} |
||||
Is Type |
||||
{% hint %} |
||||
Available types: |
||||
- `banned` |
||||
- `verified` |
||||
{% return %} |
||||
Either `TRUE` on success, or `FALSE`. |
||||
{% endPHPmethodDisplayer %} |
||||
|
@ -0,0 +1,146 @@
|
||||
# Quck Start |
||||
|
||||
Let's get started :) |
||||
|
||||
First, we will load the Aauth Library into the system |
||||
```php |
||||
$this->load->library("Aauth"); |
||||
``` |
||||
|
||||
That was easy! |
||||
|
||||
Now let's create two new users, `Frodo` and `Legolas`. |
||||
|
||||
```php |
||||
$this->aauth->create_user('frodo@example.com','frodopass','Frodo Baggins'); |
||||
$this->aauth->create_user('legolas@example.com','legolaspass','Legolas'); |
||||
``` |
||||
|
||||
We now we have two users. |
||||
|
||||
OK, now we can create two groups, `hobbits` and `elves`. |
||||
```php |
||||
$this->aauth->create_group('hobbits'); |
||||
$this->aauth->create_group('elves'); |
||||
``` |
||||
|
||||
Now, let's create a user with power, Gandalf (for our example, let's assume he was given the `id` of 12). |
||||
```php |
||||
$this->aauth->create_user('gandalf@example.com', 'gandalfpass', 'Gandalf the Gray'); |
||||
``` |
||||
|
||||
OK, now we have two groups and three users. |
||||
|
||||
Let's create two permissions `walk_unseen` and `immortality` |
||||
|
||||
```php |
||||
$this->aauth->create_perm('walk_unseen'); |
||||
$this->aauth->create_perm('immortality'); |
||||
``` |
||||
|
||||
Ok, now let's give accesses to our groups. The Hobbits seem to have ability to walk unseen, so we will assign that privilage to them. The Elves have imortality, so we will assign that privilage to them. |
||||
We will assign access with `allow_group()` function. |
||||
|
||||
```php |
||||
$this->aauth->allow_group('hobbits','walk_unseen'); |
||||
$this->aauth->allow_group('elves','immortality'); |
||||
|
||||
|
||||
$this->aauth->allow_group('hobbits','immortality'); |
||||
``` |
||||
|
||||
Wait a minute! Hobbits should not have `immortality`. We need to fix this, we can use `deny_group()` to remove the permission. |
||||
|
||||
```php |
||||
$this->aauth->deny_group('hobbits','immortality'); |
||||
``` |
||||
|
||||
Gandalf can also live forever. |
||||
|
||||
```php |
||||
$this->aauth->allow_user(12,'immortality'); |
||||
``` |
||||
|
||||
Ok now let's check if Hobbits have `immortality`. |
||||
|
||||
```php |
||||
if($this->aauth->is_group_allowed('hobbits','immortality')){ |
||||
echo "Hobbits are immortal"; |
||||
} else { |
||||
echo "Hobbits are NOT immortal"; |
||||
} |
||||
``` |
||||
Results: |
||||
``` |
||||
Hobbits are NOT immortal |
||||
``` |
||||
|
||||
Does Gandalf have the ability to live forever? |
||||
|
||||
```php |
||||
if($this->aauth->is_allowed(12,'immortality')){ |
||||
echo "Gandalf is immortal"; |
||||
} else { |
||||
echo "Gandalf is NOT immortal"; |
||||
} |
||||
``` |
||||
Results: |
||||
``` |
||||
Gandalf is immortal |
||||
``` |
||||
|
||||
Since we don't accually live in Middle Earth, we are not aware of actual immortality. Alas, we must delete the permission. |
||||
|
||||
```php |
||||
$this->aauth->delete_perm('immortality'); |
||||
``` |
||||
It is gone. |
||||
|
||||
#### Un-authenticated Users |
||||
|
||||
So, how about un-authenticated users? In Aauth they are part of the `public` group. Let's give them permissions to `travel`. |
||||
We will assume we already have a permission set up named `travel`. |
||||
|
||||
```php |
||||
$this->aauth->allow_group('public','travel'); |
||||
``` |
||||
|
||||
#### Admin Users |
||||
What about the Admin users? The `Admin` user and any member of the `Admin` group is a superuser who had access everthing, There is no need to grant additional permissions. |
||||
|
||||
#### User Parameters/Variables |
||||
For each user, variables can be defined as individual key/value pairs. |
||||
|
||||
```php |
||||
$this->aauth->set_user_var("key","value"); |
||||
``` |
||||
|
||||
For example, if you want to store a user's phone number. |
||||
```php |
||||
$this->aauth->set_user_var("phone","1-507-555-1234"); |
||||
``` |
||||
|
||||
To retreive value you will use `get_user_var()`: |
||||
```php |
||||
$this->aauth->get_user_var("key"); |
||||
``` |
||||
|
||||
Aauth also permits you to define System Variables. These can be which can be accesed by all users in the system. |
||||
```php |
||||
$this->aauth->set_system_var("key","value"); |
||||
$this->aauth->get_system_var("key"); |
||||
``` |
||||
|
||||
#### Private Messages |
||||
OK, let's look at private messages. Frodo (`id` = 3) will send a PM to Legolas (`id` = 4); |
||||
|
||||
```php |
||||
$this->aauth->send_pm(3,4,'New cloaks','These new cloaks are fantastic!') |
||||
``` |
||||
|
||||
#### Banning users |
||||
|
||||
Frodo has broke the rules and will now need to be banned from the system. |
||||
```php |
||||
$this->aauth->ban_user(3); |
||||
``` |
@ -0,0 +1,16 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Aauth { |
||||
|
||||
public $version = '3.00'; |
||||
public $CII; |
||||
public $config_vars; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->CII = &get_instance(); |
||||
|
||||
$this->CII->load->library('aauth_init'); |
||||
$this->CII->aauth_init->version('v'.$this->version); |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Aauth_init { |
||||
|
||||
protected $_enabled = FALSE; |
||||
protected $_path = NULL; |
||||
protected $_version = 0; |
||||
protected $_table = 'aauth_init'; |
||||
protected $_auto_latest = FALSE; |
||||
protected $_regex = NULL; |
||||
protected $_error_string = ''; |
||||
|
||||
public function __construct($config = array()) |
||||
{ |
||||
foreach ($config as $key => $val) |
||||
{ |
||||
$key = str_replace('aauthinit', '', $key); |
||||
$this->{$key} = $val; |
||||
} |
||||
|
||||
$this->_regex = '/^(\w+)_v(\d{1})\.(\d{2})$/';'' !== $this->_path OR $this->_path = APPPATH.'libraries/Aauth_init/'; |
||||
$this->_path = rtrim($this->_path, '/').'/'; |
||||
$this->CII = &get_instance(); |
||||
$this->CII->config->load('aauth'); |
||||
$this->config_vars = $this->CII->config->item('aauth'); |
||||
$this->aauth_db = $this->CII->load->database($this->config_vars['database']['_profile'], TRUE); |
||||
$this->aauth_db_forge = $this->CII->load->dbforge($this->aauth_db, TRUE); |
||||
|
||||
if ( ! $this->aauth_db->table_exists($this->_table)) |
||||
{ |
||||
$this->aauth_db_forge->add_field(array( |
||||
'version' => array('type' => 'VARCHAR', 'constraint' => 20), |
||||
)); |
||||
|
||||
$this->aauth_db_forge->create_table($this->_table, TRUE); |
||||
$this->aauth_db->insert($this->_table, array('version' => 0)); |
||||
} |
||||
} |
||||
|
||||
public function version($target_version) |
||||
{ |
||||
$current_version = $this->_get_version(); |
||||
$target_version = (string) $target_version; |
||||
$updates = $this->find_updates(); |
||||
$previous = FALSE; |
||||
|
||||
if ($current_version == 0) |
||||
{ |
||||
$method = 'install'; |
||||
} |
||||
else if ($target_version > $current_version) |
||||
{ |
||||
$method = 'update'; |
||||
} |
||||
foreach ($updates as $number => $file) |
||||
{ |
||||
include_once $file; |
||||
$class = 'Aauth_v'.str_replace('.', '', $number); |
||||
$previous = $number; |
||||
|
||||
if ( |
||||
($method === 'install' && $number > $current_version && $number <= $target_version) OR |
||||
($method === 'update' && $number > $current_version && $number <= $target_version) |
||||
) |
||||
{ |
||||
$instance = new $class(); |
||||
|
||||
if (is_callable(array($instance, $method))) |
||||
{ |
||||
call_user_func(array($instance, $method)); |
||||
$current_version = $number; |
||||
$this->_update_version($current_version); |
||||
} |
||||
} |
||||
} |
||||
if ($current_version !== $target_version) |
||||
{ |
||||
$current_version = $target_version; |
||||
$this->_update_version($current_version); |
||||
} |
||||
|
||||
return $current_version; |
||||
} |
||||
|
||||
public function find_updates() |
||||
{ |
||||
$updates = array(); |
||||
|
||||
foreach (glob($this->_path.'*_v*.php') as $file) |
||||
{ |
||||
$name = basename($file, '.php'); |
||||
|
||||
if (preg_match($this->_regex, $name)) |
||||
{ |
||||
$number = $this->_get_number($name); |
||||
$updates[$number] = $file; |
||||
} |
||||
} |
||||
|
||||
ksort($updates); |
||||
return $updates; |
||||
} |
||||
|
||||
protected function _get_number($update) |
||||
{ |
||||
return str_replace('Aauth_v', '', $update); |
||||
} |
||||
|
||||
protected function _get_version() |
||||
{ |
||||
$row = $this->aauth_db->select('version')->get($this->_table)->row(); |
||||
return $row->version; |
||||
} |
||||
|
||||
protected function _update_version($update) |
||||
{ |
||||
$update = str_replace('v', '', $update); |
||||
$this->aauth_db->update($this->_table, array( |
||||
'version' => $update, |
||||
)); |
||||
} |
||||
} |
@ -0,0 +1,219 @@
|
||||
<?php |
||||
|
||||
class Aauth_v300 { |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->CII = &get_instance(); |
||||
$this->config_vars = $this->CII->config->item('aauth'); |
||||
$this->CII->aauth_db = $this->CII->load->database($this->config_vars['database']['_profile'], TRUE); |
||||
$this->CII->aauth_db_forge = $this->CII->load->dbforge($this->CII->aauth_db, TRUE); |
||||
} |
||||
|
||||
public function install() |
||||
{ |
||||
// Users TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
'auto_increment' => TRUE, |
||||
), |
||||
'email' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '254', |
||||
), |
||||
'username' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '150', |
||||
'null' => TRUE, |
||||
), |
||||
'password' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '60', |
||||
), |
||||
'banned' => array( |
||||
'type' => 'TINYINT', |
||||
'constraint' => '1', |
||||
'null' => TRUE, |
||||
'default' => '0', |
||||
), |
||||
'created_since' => array( |
||||
'type' => 'DATETIME', |
||||
'default' => NULL, |
||||
), |
||||
'last_ip_address' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '39', |
||||
'default' => '', |
||||
), |
||||
'last_login' => array( |
||||
'type' => 'DATETIME', |
||||
'default' => NULL, |
||||
), |
||||
'last_activity' => array( |
||||
'type' => 'DATETIME', |
||||
'default' => NULL, |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key('id', TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['users'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Login Attempts TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
'auto_increment' => TRUE, |
||||
), |
||||
'ip_address' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '39', |
||||
'default' => '0', |
||||
), |
||||
'timestamp' => array( |
||||
'type' => 'DATETIME', |
||||
'default' => NULL, |
||||
), |
||||
'login_attempts' => array( |
||||
'type' => 'TINYINT', |
||||
'constraint' => '2', |
||||
'default' => '0', |
||||
), |
||||
|
||||
)); |
||||
$this->CII->aauth_db_forge->add_key('id', TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['login_attempts'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// User Variables TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
'auto_increment' => TRUE, |
||||
), |
||||
'user_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
'data_key' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '100', |
||||
), |
||||
'data_value' => array( |
||||
'type' => 'text', |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key('id', TRUE); |
||||
$this->CII->aauth_db_forge->add_key('user_id'); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['user_variables'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Groups TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
'auto_increment' => TRUE, |
||||
), |
||||
'name' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '100', |
||||
), |
||||
'definition' => array( |
||||
'type' => 'TEXT', |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key('id', TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['groups'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Group To User TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'group_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
'user_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key(array('group_id','user_id'), TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['group_to_user'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Group To SubGroup TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'group_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
'subgroup_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key(array('group_id','subgroup_id'), TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['group_to_subgroup'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Permissions TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
'auto_increment' => TRUE, |
||||
), |
||||
'name' => array( |
||||
'type' => 'VARCHAR', |
||||
'constraint' => '100', |
||||
), |
||||
'definition' => array( |
||||
'type' => 'TEXT', |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key('id', TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['permissions'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Permission To User TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'permission_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
'user_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key(array('permission_id','user_id'), TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['permission_to_user'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
// Permission To Group TABLE |
||||
$this->CII->aauth_db_forge->add_field(array( |
||||
'permission_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
'group_id' => array( |
||||
'type' => 'INT', |
||||
'constraint' => 11, |
||||
'unsigned' => TRUE, |
||||
), |
||||
)); |
||||
$this->CII->aauth_db_forge->add_key(array('permission_id','group_id'), TRUE); |
||||
$this->CII->aauth_db_forge->create_table($this->config_vars['database']['permission_to_group'], FALSE, array('ENGINE' => 'InnoDB')); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,77 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Group_to_subgroup_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->cii->load->model('aauth/Groups_model', 'groups'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($group_id, $subgroup_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id) && $this->cii->groups->get_id($subgroup_id) && ! $this->exist($group_id, $subgroup_id) && $group_id != $subgroup_id) |
||||
{ |
||||
$data['group_id'] = $group_id; |
||||
$data['subgroup_id'] = $subgroup_id; |
||||
return $this->db->insert($this->config_vars['database']['group_to_subgroup'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($group_id, $subgroup_id) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
$this->db->where('subgroup_id', $subgroup_id); |
||||
return $this->db->delete($this->config_vars['database']['group_to_subgroup']); |
||||
} |
||||
|
||||
public function delete_by_subgroup($subgroup_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($subgroup_id)) |
||||
{ |
||||
$this->db->where('subgroup_id', $subgroup_id); |
||||
return $this->db->delete($this->config_vars['database']['group_to_subgroup']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete_by_group($group_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id)) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
return $this->db->delete($this->config_vars['database']['group_to_subgroup']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function exist($group_id, $subgroup_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id) && $this->cii->groups->get_id($subgroup_id)) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
$this->db->where('subgroup_id', $subgroup_id); |
||||
$query = $this->db->get($this->config_vars['database']['group_to_subgroup']); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
} |
@ -0,0 +1,78 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Group_to_user_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->cii->load->model('aauth/Users_model', 'users'); |
||||
$this->cii->load->model('aauth/Groups_model', 'groups'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($group_id, $user_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id) && $this->cii->users->exist_by_(array('id' => $user_id)) && ! $this->exist($group_id, $user_id)) |
||||
{ |
||||
$data['group_id'] = $group_id; |
||||
$data['user_id'] = $user_id; |
||||
return $this->db->insert($this->config_vars['database']['group_to_user'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($group_id, $user_id) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
$this->db->where('user_id', $user_id); |
||||
return $this->db->delete($this->config_vars['database']['group_to_user']); |
||||
} |
||||
|
||||
public function delete_by_user($user_id) |
||||
{ |
||||
if ($this->cii->users->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
$this->db->where('user_id', $user_id); |
||||
return $this->db->delete($this->config_vars['database']['group_to_user']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete_by_group($group_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id)) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
return $this->db->delete($this->config_vars['database']['group_to_user']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function exist($group_id, $user_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id) && $this->cii->users->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
$this->db->where('user_id', $user_id); |
||||
$query = $this->db->get($this->config_vars['database']['group_to_user']); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
} |
@ -0,0 +1,111 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Groups_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($name, $definition = '') |
||||
{ |
||||
if ($name && ! $this->get_id($name)) |
||||
{ |
||||
$data['name'] = $name; |
||||
$data['definition'] = $definition; |
||||
$this->db->insert($this->config_vars['database']['groups'], $data); |
||||
return $this->db->insert_id(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function update($group_id, $name = NULL, $definition = NULL) |
||||
{ |
||||
$group_id = $this->get_id($group_id); |
||||
|
||||
if ($group_id) |
||||
{ |
||||
if ($name) |
||||
{ |
||||
$data['name'] = $name; |
||||
} |
||||
if ($definition) |
||||
{ |
||||
$data['definition'] = $definition; |
||||
} |
||||
|
||||
$this->db->where('id', $group_id); |
||||
return $this->db->update($this->config_vars['database']['groups'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($group_id) |
||||
{ |
||||
$this->cii->load->model('aauth/Group_to_subgroup_model', 'group_to_subgroup'); |
||||
$this->cii->load->model('aauth/Group_to_user_model', 'group_to_user'); |
||||
|
||||
$this->cii->group_to_user->delete_by_group($group_id); |
||||
$this->cii->group_to_subgroup->delete_by_group($group_id); |
||||
//DELETE PERM_TO_GROUP |
||||
$this->db->where('id', $group_id); |
||||
return $this->db->delete($this->config_vars['database']['groups']); |
||||
} |
||||
|
||||
public function get($group_id) |
||||
{ |
||||
$query = $this->_get(array('id' => $group_id)); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return $query->row(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_id($name) |
||||
{ |
||||
if (is_numeric($name)) |
||||
{ |
||||
$query = $this->_get(array('id' => $name)); |
||||
} |
||||
else if ( ! is_numeric($name)) |
||||
{ |
||||
$query = $this->_get(array('name' => $name)); |
||||
} |
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return $query->row()->id; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_all() |
||||
{ |
||||
$query = $this->_get(); |
||||
|
||||
if ($query->num_rows() !== 0) |
||||
{ |
||||
return $query->result(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
private function _get($where = array()) |
||||
{ |
||||
$this->db->where($where); |
||||
return $this->db->get($this->config_vars['database']['groups']); |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Login_attempts_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function get() |
||||
{ |
||||
$query = $this->_get(); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return $query->row()->login_attempts; |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
public function update() |
||||
{ |
||||
$query = $this->_get(); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
$row = $query->row(); |
||||
$data['timestamp'] = date('Y-m-d H:i:s'); |
||||
$data['login_attempts'] = $row->login_attempts + 1; |
||||
$this->db->update($this->config_vars['database']['login_attempts'], $data, array('id' => $row->id)); |
||||
|
||||
if ($data['login_attempts'] > $this->config_vars['ddos_protection']['max_attempts']) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
return TRUE; |
||||
} |
||||
|
||||
return $this->_create(); |
||||
} |
||||
|
||||
public function delete() |
||||
{ |
||||
$data['ip_address'] = $this->cii->input->ip_address(); |
||||
$data['timestamp >='] = date('Y-m-d H:i:s', strtotime('-'.$this->config_vars['ddos_protection']['time_period'])); |
||||
$this->db->where($data); |
||||
return $this->db->delete($this->config_vars['database']['login_attempts']); |
||||
} |
||||
|
||||
private function _create() |
||||
{ |
||||
$data['ip_address'] = $this->cii->input->ip_address(); |
||||
$data['timestamp'] = date('Y-m-d H:i:s'); |
||||
$data['login_attempts'] = 1; |
||||
return $this->db->insert($this->config_vars['database']['login_attempts'], $data); |
||||
} |
||||
|
||||
private function _get() |
||||
{ |
||||
$data['ip_address'] = $this->cii->input->ip_address(); |
||||
$data['timestamp >='] = date('Y-m-d H:i:s', strtotime('-'.$this->config_vars['ddos_protection']['time_period'])); |
||||
$this->db->where($data); |
||||
return $this->db->get($this->config_vars['database']['login_attempts']); |
||||
} |
||||
} |
@ -0,0 +1,78 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Permission_to_group_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->cii->load->model('aauth/Groups_model', 'groups'); |
||||
$this->cii->load->model('aauth/Permissions_model', 'permissions'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($permission_id, $group_id) |
||||
{ |
||||
if ($this->cii->permissions->get_id($permission_id) && $this->cii->groups->get_id($group_id) && ! $this->exist($permission_id, $group_id)) |
||||
{ |
||||
$data['permission_id'] = $permission_id; |
||||
$data['group_id'] = $group_id; |
||||
return $this->db->insert($this->config_vars['database']['permission_to_group'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($permission_id, $group_id) |
||||
{ |
||||
$this->db->where('permission_id', $permission_id); |
||||
$this->db->where('group_id', $group_id); |
||||
return $this->db->delete($this->config_vars['database']['permission_to_group']); |
||||
} |
||||
|
||||
public function delete_by_group($group_id) |
||||
{ |
||||
if ($this->cii->groups->get_id($group_id)) |
||||
{ |
||||
$this->db->where('group_id', $group_id); |
||||
return $this->db->delete($this->config_vars['database']['permission_to_group']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete_by_permission($permission_id) |
||||
{ |
||||
if ($this->cii->permissions->get_id($permission_id)) |
||||
{ |
||||
$this->db->where('permission_id', $permission_id); |
||||
return $this->db->delete($this->config_vars['database']['permission_to_group']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function exist($permission_id, $group_id) |
||||
{ |
||||
if ($this->cii->permissions->get_id($permission_id) && $this->cii->groups->get_id($group_id)) |
||||
{ |
||||
$this->db->where('permission_id', $permission_id); |
||||
$this->db->where('group_id', $group_id); |
||||
$query = $this->db->get($this->config_vars['database']['permission_to_group']); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
} |
@ -0,0 +1,78 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Permission_to_user_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->cii->load->model('aauth/Users_model', 'users'); |
||||
$this->cii->load->model('aauth/Permissions_model', 'permissions'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($permission_id, $user_id) |
||||
{ |
||||
if ($this->cii->permissions->get_id($permission_id) && $this->cii->users->exist_by_(array('id' => $user_id)) && ! $this->exist($permission_id, $user_id)) |
||||
{ |
||||
$data['permission_id'] = $permission_id; |
||||
$data['user_id'] = $user_id; |
||||
return $this->db->insert($this->config_vars['database']['permission_to_user'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($permission_id, $user_id) |
||||
{ |
||||
$this->db->where('permission_id', $permission_id); |
||||
$this->db->where('user_id', $user_id); |
||||
return $this->db->delete($this->config_vars['database']['permission_to_user']); |
||||
} |
||||
|
||||
public function delete_by_user($user_id) |
||||
{ |
||||
if ($this->cii->users->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
$this->db->where('user_id', $user_id); |
||||
return $this->db->delete($this->config_vars['database']['permission_to_user']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete_by_permission($permission_id) |
||||
{ |
||||
if ($this->cii->permissions->get_id($permission_id)) |
||||
{ |
||||
$this->db->where('permission_id', $permission_id); |
||||
return $this->db->delete($this->config_vars['database']['permission_to_user']); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function exist($permission_id, $user_id) |
||||
{ |
||||
if ($this->cii->permissions->get_id($permission_id) && $this->cii->users->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
$this->db->where('permission_id', $permission_id); |
||||
$this->db->where('user_id', $user_id); |
||||
$query = $this->db->get($this->config_vars['database']['permission_to_user']); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Permissions_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($name, $definition = '') |
||||
{ |
||||
if ($name && ! $this->get_id($name)) |
||||
{ |
||||
$data['name'] = $name; |
||||
$data['definition'] = $definition; |
||||
$this->db->insert($this->config_vars['database']['permissions'], $data); |
||||
return $this->db->insert_id(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function update($permission_id, $name = NULL, $definition = NULL) |
||||
{ |
||||
$permission_id = $this->get_id($permission_id); |
||||
|
||||
if ($permission_id) |
||||
{ |
||||
if ($name) |
||||
{ |
||||
$data['name'] = $name; |
||||
} |
||||
if ($definition) |
||||
{ |
||||
$data['definition'] = $definition; |
||||
} |
||||
|
||||
$this->db->where('id', $permission_id); |
||||
return $this->db->update($this->config_vars['database']['permissions'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($permission_id) |
||||
{ |
||||
//DELETE PERM_TO_USER |
||||
//DELETE PERM_TO_GROUP |
||||
$this->db->where('id', $permission_id); |
||||
return $this->db->delete($this->config_vars['database']['permissions']); |
||||
} |
||||
|
||||
public function get($permission_id) |
||||
{ |
||||
$query = $this->_get(array('id' => $permission_id)); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return $query->row(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_id($name) |
||||
{ |
||||
if (is_numeric($name)) |
||||
{ |
||||
$query = $this->_get(array('id' => $name)); |
||||
} |
||||
else if ( ! is_numeric($name)) |
||||
{ |
||||
$query = $this->_get(array('name' => $name)); |
||||
} |
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return $query->row()->id; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_all() |
||||
{ |
||||
$query = $this->_get(); |
||||
|
||||
if ($query->num_rows() !== 0) |
||||
{ |
||||
return $query->result(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
private function _get($where = array()) |
||||
{ |
||||
$this->db->where($where); |
||||
return $this->db->get($this->config_vars['database']['permissions']); |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class User_variables_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->cii->load->model('aauth/Users_model', 'users'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function update($user_id, $key, $value) |
||||
{ |
||||
if ($this->cii->users->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
$data['data_value'] = $value; |
||||
|
||||
if ($this->_exist($user_id, $key)) |
||||
{ |
||||
$this->db->where('data_key', $key); |
||||
$this->db->where('user_id', $user_id); |
||||
return $this->db->update($this->config_vars['database']['user_variables'], $data); |
||||
} |
||||
|
||||
$data['data_key'] = $key; |
||||
$data['user_id'] = $user_id; |
||||
return $this->db->insert($this->config_vars['database']['user_variables'], $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get($user_id, $key) |
||||
{ |
||||
if ($this->cii->users->exist_by_(array('id' => $user_id)) && $this->_exist($user_id, $key)) |
||||
{ |
||||
$query = $this->_get($user_id, $key); |
||||
return $query->row()->data_value; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_by_user_id($user_id) |
||||
{ |
||||
if ($this->cii->users->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
return $this->_get($user_id)->result(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($user_id, $key = NULL) |
||||
{ |
||||
if ($key) |
||||
{ |
||||
$this->db->where('data_key', $key); |
||||
} |
||||
|
||||
$this->db->where('user_id', $user_id); |
||||
return $this->db->delete($this->config_vars['database']['user_variables']); |
||||
} |
||||
|
||||
private function _exist($user_id, $key) |
||||
{ |
||||
if ($this->_get($user_id, $key)->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
private function _get($user_id, $key = NULL) |
||||
{ |
||||
if ($key) |
||||
{ |
||||
$where['data_key'] = $key; |
||||
} |
||||
|
||||
$where['user_id'] = $user_id; |
||||
$this->db->select('data_key, data_value'); |
||||
$this->db->where($where); |
||||
return $this->db->get($this->config_vars['database']['user_variables']); |
||||
} |
||||
} |
@ -0,0 +1,207 @@
|
||||
<?php |
||||
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||
|
||||
class Users_model extends CI_Model { |
||||
|
||||
protected $config_vars; |
||||
protected $cii; |
||||
|
||||
public function __construct() |
||||
{ |
||||
parent::__construct(); |
||||
$this->cii = &get_instance(); |
||||
$this->cii->config->load('aauth'); |
||||
$this->cii->load->model('aauth/User_variables_model', 'user_variables'); |
||||
$this->cii->load->model('aauth/Group_to_user_model', 'group_to_user'); |
||||
$this->config_vars = $this->cii->config->item('aauth'); |
||||
} |
||||
|
||||
public function create($email, $pass, $username = '') |
||||
{ |
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL) && ! $this->exist_by_(array('email' => $email)) && ( ! empty($username) && ! $this->exist_by_(array('username' => $username)))) |
||||
{ |
||||
$data = array(); |
||||
$data['email'] = $email; |
||||
$data['username'] = $username; |
||||
$data['password'] = password_hash($pass, $this->config_vars['password']['hash_algo'], $this->config_vars['password']['hash_options']); |
||||
$data['created_since'] = date('Y-m-d H:i:s'); |
||||
$this->db->insert($this->config_vars['database']['users'], $data); |
||||
|
||||
return $this->db->insert_id(); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function update($user_id, $data = array()) |
||||
{ |
||||
if ($this->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
return $this->db->update($this->config_vars['database']['users'], $data, array('id' => $user_id)); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function delete($user_id) |
||||
{ |
||||
$this->cii->user_variables->delete($user_id); |
||||
$this->cii->group_to_user->delete_by_user($user_id); |
||||
return $this->db->delete($this->config_vars['database']['users'], array('id' => $user_id)); |
||||
} |
||||
|
||||
public function get_all($options = array()) |
||||
{ |
||||
$filters = array(); |
||||
$args = array(); |
||||
$filters['banned'] = '0'; |
||||
|
||||
if (isset($options['filters'])) |
||||
{ |
||||
$filters = $options['filters']; |
||||
} |
||||
if (isset($options['include_banneds']) && $options['include_banneds']) |
||||
{ |
||||
unset($filters['banned']); |
||||
} |
||||
if (isset($options['only_banneds']) && $options['only_banneds']) |
||||
{ |
||||
$filters['banned'] = '1'; |
||||
} |
||||
if (isset($options['offset'])) |
||||
{ |
||||
$args['offset'] = $options['offset']; |
||||
} |
||||
if (isset($options['limit'])) |
||||
{ |
||||
$args['limit'] = $options['limit']; |
||||
} |
||||
|
||||
$query = $this->get_by_($filters, $args); |
||||
return $query->result(); |
||||
} |
||||
|
||||
public function ban($user_id, $ver_code = NULL) |
||||
{ |
||||
if ($this->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
if ($ver_code) |
||||
{ |
||||
$this->cii->user_variables->update($user_id, 'verification_code', $ver_code); |
||||
} |
||||
|
||||
$data['banned'] = '1'; |
||||
return $this->update($user_id, $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function unban($user_id, $ver_code = NULL) |
||||
{ |
||||
if ($this->exist_by_(array('id' => $user_id)) && $this->is_($user_id, 'banned')) |
||||
{ |
||||
if ( ! $this->is_($user_id, 'verified')) |
||||
{ |
||||
if ($this->cii->user_variables->get($user_id, 'verification_code') !== $ver_code) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
$this->cii->user_variables->delete($user_id, 'verification_code'); |
||||
} |
||||
|
||||
return $this->update($user_id, array('banned' => '0')); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function update_($user_id, $type) |
||||
{ |
||||
if ($this->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
if ($type === 'activity') |
||||
{ |
||||
$data['last_activity'] = date('Y-m-d H:i:s'); |
||||
} |
||||
else if ($type === 'last_login') |
||||
{ |
||||
$data['last_login'] = date('Y-m-d H:i:s'); |
||||
$data['last_ip_address'] = $this->input->ip_address(); |
||||
} |
||||
|
||||
return $this->update($user_id, $data); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function exist_by_($filters = array()) |
||||
{ |
||||
if ($this->get_by_($filters)->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_($filters, $result_column) |
||||
{ |
||||
$query = $this->get_by_($filters, array('select' => $result_column)); |
||||
|
||||
if ($query->num_rows() === 1) |
||||
{ |
||||
return $query->row($result_column); |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
public function get_by_($filters, $options = NULL) |
||||
{ |
||||
if ($filters) |
||||
{ |
||||
foreach ($filters as $column => $value) |
||||
{ |
||||
$this->db->where($column, $value); |
||||
} |
||||
} |
||||
if (isset($options['limit'])) |
||||
{ |
||||
$this->db->limit($options['limit']); |
||||
} |
||||
if (isset($options['offset'])) |
||||
{ |
||||
$this->db->offset($options['offset']); |
||||
} |
||||
if (isset($options['select'])) |
||||
{ |
||||
$this->db->select($options['select']); |
||||
} |
||||
|
||||
return $this->db->get($this->config_vars['database']['users']); |
||||
} |
||||
|
||||
public function is_($user_id, $type) |
||||
{ |
||||
if ($this->exist_by_(array('id' => $user_id))) |
||||
{ |
||||
$data['banned'] = '1'; |
||||
$data['id'] = $user_id; |
||||
$query = $this->get_by_($data); |
||||
|
||||
if ($type === 'banned' && $query->num_rows() === 1) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
else if ($type === 'verified' && ! $this->cii->user_variables->get($user_id, 'verification_code')) |
||||
{ |
||||
return TRUE; |
||||
} |
||||
} |
||||
|
||||
return FALSE; |
||||
} |
||||
} |
@ -1,178 +0,0 @@
|
||||
/* |
||||
Aauth SQL Table Structure |
||||
*/ |
||||
|
||||
SET FOREIGN_KEY_CHECKS=0; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_groups` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_groups`; |
||||
CREATE TABLE `aauth_groups` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`name` varchar(100), |
||||
`definition` text, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_groups |
||||
-- ---------------------------- |
||||
INSERT INTO `aauth_groups` VALUES ('1', 'Admin', 'Super Admin Group'); |
||||
INSERT INTO `aauth_groups` VALUES ('2', 'Public', 'Public Access Group'); |
||||
INSERT INTO `aauth_groups` VALUES ('3', 'Default', 'Default Access Group'); |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_perms` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_perms`; |
||||
CREATE TABLE `aauth_perms` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`name` varchar(100), |
||||
`definition` text, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_perms |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_perm_to_group` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_perm_to_group`; |
||||
CREATE TABLE `aauth_perm_to_group` ( |
||||
`perm_id` int(11) unsigned NOT NULL, |
||||
`group_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`perm_id`,`group_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_perm_to_group |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_perm_to_user` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_perm_to_user`; |
||||
CREATE TABLE `aauth_perm_to_user` ( |
||||
`perm_id` int(11) unsigned NOT NULL, |
||||
`user_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`perm_id`,`user_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_perm_to_user |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_pms` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_pms`; |
||||
CREATE TABLE `aauth_pms` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`sender_id` int(11) unsigned NOT NULL, |
||||
`receiver_id` int(11) unsigned NOT NULL, |
||||
`title` varchar(255) NOT NULL, |
||||
`message` text, |
||||
`date_sent` datetime DEFAULT NULL, |
||||
`date_read` datetime DEFAULT NULL, |
||||
`pm_deleted_sender` int(1) DEFAULT NULL, |
||||
`pm_deleted_receiver` int(1) DEFAULT NULL, |
||||
PRIMARY KEY (`id`), |
||||
KEY `full_index` (`id`,`sender_id`,`receiver_id`,`date_read`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_pms |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_users` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_users`; |
||||
CREATE TABLE `aauth_users` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`email` varchar(100) COLLATE utf8_general_ci NOT NULL, |
||||
`pass` varchar(64) COLLATE utf8_general_ci NOT NULL, |
||||
`username` varchar(100) COLLATE utf8_general_ci, |
||||
`banned` tinyint(1) DEFAULT '0', |
||||
`last_login` datetime DEFAULT NULL, |
||||
`last_activity` datetime DEFAULT NULL, |
||||
`date_created` datetime DEFAULT NULL, |
||||
`forgot_exp` text COLLATE utf8_general_ci, |
||||
`remember_time` datetime DEFAULT NULL, |
||||
`remember_exp` text COLLATE utf8_general_ci, |
||||
`verification_code` text COLLATE utf8_general_ci, |
||||
`totp_secret` varchar(16) COLLATE utf8_general_ci DEFAULT NULL, |
||||
`ip_address` text COLLATE utf8_general_ci, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_users |
||||
-- ---------------------------- |
||||
INSERT INTO `aauth_users` VALUES ('1', 'admin@example.com', 'dd5073c93fb477a167fd69072e95455834acd93df8fed41a2c468c45b394bfe3', 'Admin', '0', null, null, null, null, null, null, null, null, '0'); |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_user_to_group` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_user_to_group`; |
||||
CREATE TABLE `aauth_user_to_group` ( |
||||
`user_id` int(11) unsigned NOT NULL, |
||||
`group_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`user_id`,`group_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_user_to_group |
||||
-- ---------------------------- |
||||
INSERT INTO `aauth_user_to_group` VALUES ('1', '1'); |
||||
INSERT INTO `aauth_user_to_group` VALUES ('1', '3'); |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_user_variables` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_user_variables`; |
||||
CREATE TABLE `aauth_user_variables` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`user_id` int(11) unsigned NOT NULL, |
||||
`data_key` varchar(100) NOT NULL, |
||||
`value` text, |
||||
PRIMARY KEY (`id`), |
||||
KEY `user_id_index` (`user_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_user_variables |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_group_to_group` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_group_to_group`; |
||||
CREATE TABLE `aauth_group_to_group` ( |
||||
`group_id` int(11) unsigned NOT NULL, |
||||
`subgroup_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`group_id`,`subgroup_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_group_to_group |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_login_attempts` |
||||
-- ---------------------------- |
||||
|
||||
CREATE TABLE IF NOT EXISTS `aauth_login_attempts` ( |
||||
`id` int(11) NOT NULL AUTO_INCREMENT, |
||||
`ip_address` varchar(39) DEFAULT '0', |
||||
`timestamp` datetime DEFAULT NULL, |
||||
`login_attempts` tinyint(2) DEFAULT '0', |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_login_attempts |
||||
-- ---------------------------- |
@ -1,178 +0,0 @@
|
||||
/* |
||||
Aauth SQL Table Structure |
||||
*/ |
||||
|
||||
SET FOREIGN_KEY_CHECKS=0; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_groups` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_groups`; |
||||
CREATE TABLE `aauth_groups` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`name` varchar(100), |
||||
`definition` text, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_groups |
||||
-- ---------------------------- |
||||
INSERT INTO `aauth_groups` VALUES ('1', 'Admin', 'Super Admin Group'); |
||||
INSERT INTO `aauth_groups` VALUES ('2', 'Public', 'Public Access Group'); |
||||
INSERT INTO `aauth_groups` VALUES ('3', 'Default', 'Default Access Group'); |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_perms` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_perms`; |
||||
CREATE TABLE `aauth_perms` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`name` varchar(100), |
||||
`definition` text, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_perms |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_perm_to_group` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_perm_to_group`; |
||||
CREATE TABLE `aauth_perm_to_group` ( |
||||
`perm_id` int(11) unsigned NOT NULL, |
||||
`group_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`perm_id`,`group_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_perm_to_group |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_perm_to_user` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_perm_to_user`; |
||||
CREATE TABLE `aauth_perm_to_user` ( |
||||
`perm_id` int(11) unsigned NOT NULL, |
||||
`user_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`perm_id`,`user_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_perm_to_user |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_pms` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_pms`; |
||||
CREATE TABLE `aauth_pms` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`sender_id` int(11) unsigned NOT NULL, |
||||
`receiver_id` int(11) unsigned NOT NULL, |
||||
`title` varchar(255) NOT NULL, |
||||
`message` text, |
||||
`date_sent` datetime DEFAULT NULL, |
||||
`date_read` datetime DEFAULT NULL, |
||||
`pm_deleted_sender` int(1) DEFAULT NULL, |
||||
`pm_deleted_receiver` int(1) DEFAULT NULL, |
||||
PRIMARY KEY (`id`), |
||||
KEY `full_index` (`id`,`sender_id`,`receiver_id`,`date_read`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_pms |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_users` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_users`; |
||||
CREATE TABLE `aauth_users` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`email` varchar(100) COLLATE utf8_general_ci NOT NULL, |
||||
`pass` varchar(60) COLLATE utf8_general_ci NOT NULL, |
||||
`username` varchar(100) COLLATE utf8_general_ci, |
||||
`banned` tinyint(1) DEFAULT '0', |
||||
`last_login` datetime DEFAULT NULL, |
||||
`last_activity` datetime DEFAULT NULL, |
||||
`date_created` datetime DEFAULT NULL, |
||||
`forgot_exp` text COLLATE utf8_general_ci, |
||||
`remember_time` datetime DEFAULT NULL, |
||||
`remember_exp` text COLLATE utf8_general_ci, |
||||
`verification_code` text COLLATE utf8_general_ci, |
||||
`totp_secret` varchar(16) COLLATE utf8_general_ci DEFAULT NULL, |
||||
`ip_address` text COLLATE utf8_general_ci, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_users |
||||
-- ---------------------------- |
||||
INSERT INTO `aauth_users` VALUES ('1', 'admin@example.com', '$2y$10$h19Lblcr6amOIUL1TgYW2.VVZOhac/e1kHMgAwCubMTlYXZrL0wS2', 'Admin', '0', null, null, null, null, null, null, null, null, '0'); |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_user_to_group` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_user_to_group`; |
||||
CREATE TABLE `aauth_user_to_group` ( |
||||
`user_id` int(11) unsigned NOT NULL, |
||||
`group_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`user_id`,`group_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_user_to_group |
||||
-- ---------------------------- |
||||
INSERT INTO `aauth_user_to_group` VALUES ('1', '1'); |
||||
INSERT INTO `aauth_user_to_group` VALUES ('1', '3'); |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_user_variables` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_user_variables`; |
||||
CREATE TABLE `aauth_user_variables` ( |
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, |
||||
`user_id` int(11) unsigned NOT NULL, |
||||
`data_key` varchar(100) NOT NULL, |
||||
`value` text, |
||||
PRIMARY KEY (`id`), |
||||
KEY `user_id_index` (`user_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_user_variables |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_group_to_group` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `aauth_group_to_group`; |
||||
CREATE TABLE `aauth_group_to_group` ( |
||||
`group_id` int(11) unsigned NOT NULL, |
||||
`subgroup_id` int(11) unsigned NOT NULL, |
||||
PRIMARY KEY (`group_id`,`subgroup_id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_group_to_group |
||||
-- ---------------------------- |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `aauth_login_attempts` |
||||
-- ---------------------------- |
||||
|
||||
CREATE TABLE IF NOT EXISTS `aauth_login_attempts` ( |
||||
`id` int(11) NOT NULL AUTO_INCREMENT, |
||||
`ip_address` varchar(39) DEFAULT '0', |
||||
`timestamp` datetime DEFAULT NULL, |
||||
`login_attempts` tinyint(2) DEFAULT '0', |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of aauth_login_attempts |
||||
-- ---------------------------- |
@ -1,8 +0,0 @@
|
||||
Aauth V2 Database |
||||
----------------- |
||||
|
||||
- First open your database (or create one if you have not already done so) |
||||
- Execute sql "Aauth_v2.sql" file in your database |
||||
- If you have not already, don't forget to change database connection settings in application/config/database.php |
||||
|
||||
That's All :) |
@ -0,0 +1,122 @@
|
||||
<?php |
||||
|
||||
// This is from: https://github.com/bcit-ci/CodeIgniter/blob/develop/tests/mocks/autoloader.php |
||||
|
||||
// This autoloader provide convinient way to working with mock object |
||||
// make the test looks natural. This autoloader support cascade file loading as well |
||||
// within mocks directory. |
||||
// |
||||
// Prototype : |
||||
// |
||||
// $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php |
||||
// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php |
||||
// and so on... |
||||
function autoload($class) |
||||
{ |
||||
$dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR; |
||||
|
||||
$ci_core = array( |
||||
'Benchmark', |
||||
'Config', |
||||
'Controller', |
||||
'Exceptions', |
||||
'Hooks', |
||||
'Input', |
||||
'Lang', |
||||
'Loader', |
||||
'Log', |
||||
'Model', |
||||
'Output', |
||||
'Router', |
||||
'Security', |
||||
'URI', |
||||
'Utf8', |
||||
); |
||||
|
||||
$ci_libraries = array( |
||||
'Calendar', |
||||
'Cart', |
||||
'Driver_Library', |
||||
'Email', |
||||
'Encrypt', |
||||
'Encryption', |
||||
'Form_validation', |
||||
'Ftp', |
||||
'Image_lib', |
||||
'Javascript', |
||||
'Migration', |
||||
'Pagination', |
||||
'Parser', |
||||
'Profiler', |
||||
'Table', |
||||
'Trackback', |
||||
'Typography', |
||||
'Unit_test', |
||||
'Upload', |
||||
'User_agent', |
||||
'Xmlrpc', |
||||
'Zip', |
||||
); |
||||
|
||||
$ci_drivers = array('Session', 'Cache'); |
||||
|
||||
if (strpos($class, 'Mock_') === 0) |
||||
{ |
||||
$class = strtolower(str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class)); |
||||
} |
||||
elseif (strpos($class, 'CI_') === 0) |
||||
{ |
||||
$subclass = substr($class, 3); |
||||
|
||||
if (in_array($subclass, $ci_core)) |
||||
{ |
||||
$dir = SYSTEM_PATH.'core'.DIRECTORY_SEPARATOR; |
||||
$class = $subclass; |
||||
} |
||||
elseif (in_array($subclass, $ci_libraries)) |
||||
{ |
||||
$dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR; |
||||
$class = ($subclass === 'Driver_Library') ? 'Driver' : $subclass; |
||||
} |
||||
elseif (in_array($subclass, $ci_drivers)) |
||||
{ |
||||
$dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR.$subclass.DIRECTORY_SEPARATOR; |
||||
$class = $subclass; |
||||
} |
||||
elseif (in_array(($parent = strtok($subclass, '_')), $ci_drivers)) |
||||
{ |
||||
$dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR.$parent.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; |
||||
$class = $subclass; |
||||
} |
||||
elseif (preg_match('/^CI_DB_(.+)_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 4) |
||||
{ |
||||
$driver_path = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; |
||||
$dir = $driver_path.$m[1].DIRECTORY_SEPARATOR.'subdrivers'.DIRECTORY_SEPARATOR; |
||||
$file = $dir.$m[1].'_'.$m[2].'_'.$m[3].'.php'; |
||||
} |
||||
elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 3) |
||||
{ |
||||
$driver_path = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; |
||||
$dir = $driver_path.$m[1].DIRECTORY_SEPARATOR; |
||||
$file = $dir.$m[1].'_'.$m[2].'.php'; |
||||
} |
||||
elseif (strpos($class, 'CI_DB') === 0) |
||||
{ |
||||
$dir = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR; |
||||
$file = $dir.str_replace(array('CI_DB', 'active_record'), array('DB', 'active_rec'), $subclass).'.php'; |
||||
} |
||||
else |
||||
{ |
||||
$class = strtolower($class); |
||||
} |
||||
} |
||||
|
||||
$file = isset($file) ? $file : $dir.$class.'.php'; |
||||
|
||||
if ( ! file_exists($file)) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
include_once $file; |
||||
} |
@ -0,0 +1,58 @@
|
||||
<?php |
||||
/** |
||||
* Part of CI PHPUnit Test |
||||
* |
||||
* @author Kenji Suzuki <https://github.com/kenjis> |
||||
* @license MIT License |
||||
* @copyright 2015 Kenji Suzuki |
||||
* @link https://github.com/kenjis/ci-phpunit-test |
||||
*/ |
||||
|
||||
class Mock_Libraries_Email |
||||
{ |
||||
private $data = array(); |
||||
|
||||
/** |
||||
* @var bool return value of send() |
||||
*/ |
||||
public $return_send = TRUE; |
||||
|
||||
public function initialize() |
||||
{ |
||||
} |
||||
|
||||
public function from($from) |
||||
{ |
||||
$this->data['from'] = $from; |
||||
} |
||||
|
||||
public function to($to) |
||||
{ |
||||
$this->data['to'] = $to; |
||||
} |
||||
|
||||
public function bcc($bcc) |
||||
{ |
||||
$this->data['bcc'] = $bcc; |
||||
} |
||||
|
||||
public function subject($subject) |
||||
{ |
||||
$this->data['subject'] = $subject; |
||||
} |
||||
|
||||
public function message($message) |
||||
{ |
||||
$this->data['message'] = $message; |
||||
} |
||||
|
||||
public function send() |
||||
{ |
||||
return $this->return_send; |
||||
} |
||||
|
||||
public function _get_data() |
||||
{ |
||||
return $this->data; |
||||
} |
||||
} |
@ -0,0 +1,120 @@
|
||||
<?php |
||||
|
||||
class Users_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Users_model', 'users', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->users; |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$AT_create = $this->obj->create('admin@example.com', 'password', 'Admin'); |
||||
$this->assertInternalType('int', $AT_create); |
||||
$AF_email_exist = $this->obj->create('admin@example.com', 'password'); |
||||
$this->assertFalse($AF_email_exist); |
||||
$AF_username_exist = $this->obj->create('admin@examples.com', 'password', 'Admin'); |
||||
$this->assertFalse($AF_username_exist); |
||||
$AF_email_wrong = $this->obj->create('adminexample.com', 'password', 'Admin'); |
||||
$this->assertFalse($AF_email_wrong); |
||||
} |
||||
|
||||
public function test_update() |
||||
{ |
||||
$AT_update = $this->obj->update(1, array('username' => 'Admin1')); |
||||
$this->assertTrue($AT_update); |
||||
$AF_userid_false = $this->obj->update(0, array('username' => 'Admin1')); |
||||
$this->assertFalse($AF_userid_false); |
||||
$AF_column_unkown = $this->obj->update(0, array('user' => 'Admin1')); |
||||
$this->assertFalse($AF_column_unkown); |
||||
} |
||||
|
||||
public function test_delete() |
||||
{ |
||||
$this->obj->create('admin@examples.com', 'password', 'Admin'); |
||||
$AT_delete = $this->obj->delete(2); |
||||
$this->assertTrue($AT_delete); |
||||
} |
||||
|
||||
public function test_get_all() |
||||
{ |
||||
$this->obj->create('admin@examples.com', 'password', 'Admin'); |
||||
$AE_default = $this->obj->get_all(); |
||||
$this->assertEquals(2, count($AE_default)); |
||||
$this->obj->ban($this->obj->get_(array('email' => 'admin@examples.com'), 'id')); |
||||
$AE_include_banneds = $this->obj->get_all(array('include_banneds' => TRUE)); |
||||
$this->assertEquals(2, count($AE_include_banneds)); |
||||
$AE_only_banneds = $this->obj->get_all(array('only_banneds' => TRUE)); |
||||
$this->assertEquals(1, count($AE_only_banneds)); |
||||
$AE_filters = $this->obj->get_all(array('filters' => array('username =' => 'TestUser'))); |
||||
$this->assertEquals(0, count($AE_filters)); |
||||
$AE_offset_preTest = $this->obj->get_all(array('include_banneds' => TRUE)); |
||||
$this->assertEquals(2, count($AE_offset_preTest)); |
||||
$AE_offset_1 = $this->obj->get_all(array('limit' => 1, 'offset' => 1, 'include_banneds' => TRUE)); |
||||
$this->assertEquals($this->obj->get_(array('email' => 'admin@examples.com'), 'id'), $AE_offset_1[0]->id); |
||||
$AE_limit_1 = $this->obj->get_all(array('limit' => 1)); |
||||
$this->assertEquals(1, count($AE_limit_1)); |
||||
|
||||
} |
||||
|
||||
public function test_ban() |
||||
{ |
||||
$AT_ban = $this->obj->ban($this->obj->get_(array('email' => 'admin@examples.com'), 'id')); |
||||
$this->assertTrue($AT_ban); |
||||
$AT_is_banned = $this->obj->is_($this->obj->get_(array('email' => 'admin@examples.com'), 'id'), 'banned'); |
||||
$this->assertTrue($AT_is_banned); |
||||
$AT_ban_verifiy = $this->obj->ban($this->obj->get_(array('email' => 'admin@examples.com'), 'id'), 'verifiy'); |
||||
$this->assertTrue($AT_ban_verifiy); |
||||
$AF_is_not_verified = $this->obj->is_($this->obj->get_(array('email' => 'admin@examples.com'), 'id'), 'verified'); |
||||
$this->assertFalse($AF_is_not_verified); |
||||
$AF_userid_false = $this->obj->ban(0); |
||||
$this->assertFalse($AF_userid_false); |
||||
} |
||||
|
||||
public function test_unban() |
||||
{ |
||||
$this->obj->ban(1); |
||||
$AT_unban = $this->obj->unban(1); |
||||
$this->assertTrue($AT_unban); |
||||
$AT_unban_verifiy = $this->obj->unban($this->obj->get_(array('email' => 'admin@examples.com'), 'id'), 'verifiy'); |
||||
$this->assertTrue($AT_unban_verifiy); |
||||
$this->obj->ban($this->obj->get_(array('email' => 'admin@examples.com'), 'id'), 'verifiy'); |
||||
$AF_no_verCode = $this->obj->unban($this->obj->get_(array('email' => 'admin@examples.com'), 'id')); |
||||
$this->assertFalse($AF_no_verCode); |
||||
$AF_userid_false = $this->obj->unban(0); |
||||
$this->assertFalse($AF_userid_false); |
||||
$AF_not_banned = $this->obj->unban(1); |
||||
$this->assertFalse($AF_not_banned); |
||||
|
||||
} |
||||
|
||||
public function test_update_() |
||||
{ |
||||
$AT_activity = $this->obj->update_(1, 'activity'); |
||||
$this->assertTrue($AT_activity); |
||||
$AT_last_login = $this->obj->update_(1, 'last_login'); |
||||
$this->assertTrue($AT_last_login); |
||||
$AF_userid_false = $this->obj->update_(0, 'activity'); |
||||
$this->assertFalse($AF_userid_false); |
||||
} |
||||
|
||||
public function test_is_() |
||||
{ |
||||
$AT_verified = $this->obj->is_(1, 'verified'); |
||||
$this->assertTrue($AT_verified); |
||||
$AF_userid_false = $this->obj->is_(0, 'verified'); |
||||
$this->assertFalse($AF_userid_false); |
||||
$this->obj->delete($this->obj->get_(array('email' => 'admin@examples.com'), 'id')); |
||||
} |
||||
|
||||
public function test_get_() |
||||
{ |
||||
$AF_user_unknown = $this->obj->get_(array('email' => 'admin@examples.com'), 'id'); |
||||
$this->assertFalse($AF_user_unknown); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
<?php |
||||
|
||||
class User_variables_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/User_variables_model', 'user_variables', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->user_variables; |
||||
} |
||||
|
||||
public function test_update() |
||||
{ |
||||
$AT_create_user_var = $this->obj->update(1, 'test_key', 'test_var'); |
||||
$this->assertTrue($AT_create_user_var); |
||||
$AE_create_user_var = $this->obj->get(1, 'test_key'); |
||||
$this->assertEquals('test_var', $AE_create_user_var); |
||||
$AT_update_user_var = $this->obj->update(1, 'test_key', 'test_var_var'); |
||||
$this->assertTrue($AT_update_user_var); |
||||
$AE_update_user_var = $this->obj->get(1, 'test_key'); |
||||
$this->assertEquals('test_var_var', $AE_update_user_var); |
||||
$AF_wrong_user_id = $this->obj->update(0, 'test_key', 'test_var_var'); |
||||
$this->assertFalse($AF_wrong_user_id); |
||||
} |
||||
|
||||
public function test_get() |
||||
{ |
||||
$AF_wrong_user_id = $this->obj->get(0, 'test_key'); |
||||
$this->assertFalse($AF_wrong_user_id); |
||||
} |
||||
|
||||
public function test_get_by_user_id() |
||||
{ |
||||
$this->obj->update(1, 'test_key2', 'test_var'); |
||||
$this->obj->update(1, 'test_key3', 'test_var'); |
||||
$this->obj->update(1, 'test_key4', 'test_var'); |
||||
|
||||
$AE_get_user_vars_1 = $this->obj->get_by_user_id(1); |
||||
$this->assertEquals(4, count($AE_get_user_vars_1)); |
||||
$AT_delete_by_user_var = $this->obj->delete(1, 'test_key'); |
||||
$this->assertTrue($AT_delete_by_user_var); |
||||
$AE_get_user_vars_2 = $this->obj->get_by_user_id(1); |
||||
$this->assertEquals(3, count($AE_get_user_vars_2)); |
||||
$AT_delete_by_user_vars = $this->obj->delete(1); |
||||
$this->assertTrue($AT_delete_by_user_vars); |
||||
$AE_get_user_vars_3 = $this->obj->get_by_user_id(1); |
||||
$this->assertEquals(0, count($AE_get_user_vars_3)); |
||||
$AF_wrong_user_id = $this->obj->get_by_user_id(0); |
||||
$this->assertFalse($AF_wrong_user_id); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,44 @@
|
||||
<?php |
||||
|
||||
class Login_attempts_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Login_attempts_model', 'login_attempts', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->login_attempts; |
||||
} |
||||
|
||||
public function test_update() |
||||
{ |
||||
$AE_get_0 = $this->obj->get(); |
||||
$this->assertEquals(0, $AE_get_0); |
||||
$AT_update_create = $this->obj->update(); |
||||
$this->assertTrue($AT_update_create); |
||||
$AE_get_1 = $this->obj->get(); |
||||
$this->assertEquals(1, $AE_get_1); |
||||
$AT_update_update = $this->obj->update(); |
||||
$this->assertTrue($AT_update_update); |
||||
$AE_get_2 = $this->obj->get(); |
||||
$this->assertEquals(2, $AE_get_2); |
||||
|
||||
for ($i=$this->obj->get(); $i < $this->config_vars['ddos_protection']['max_attempts']; $i++) { |
||||
$this->obj->update(); |
||||
} |
||||
|
||||
$this->assertEquals($this->config_vars['ddos_protection']['max_attempts'], $this->obj->get()); |
||||
$AF_max_attempts = $this->obj->update(); |
||||
$this->assertFalse($AF_max_attempts); |
||||
} |
||||
|
||||
public function test_delete() |
||||
{ |
||||
$AT_delete = $this->obj->delete(); |
||||
$this->assertTrue($AT_delete); |
||||
$AE_get_0 = $this->obj->get(); |
||||
$this->assertEquals(0, $AE_get_0); |
||||
} |
||||
} |
@ -0,0 +1,65 @@
|
||||
<?php |
||||
|
||||
class Groups_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Groups_model', 'groups', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->groups; |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$AIT_create = $this->obj->create('test_group'); |
||||
$this->assertInternalType('int', $AIT_create); |
||||
$AF_same_group = $this->obj->create('test_group'); |
||||
$this->assertFalse($AF_same_group); |
||||
$AF_no_group = $this->obj->create(''); |
||||
$this->assertFalse($AF_no_group); |
||||
|
||||
} |
||||
|
||||
public function test_update() |
||||
{ |
||||
$AT_update_1 = $this->obj->update(1, 'new_test_group'); |
||||
$this->assertTrue($AT_update_1); |
||||
$AE_update_1_confirm = $this->obj->get_id('new_test_group'); |
||||
$this->assertEquals('1', $AE_update_1_confirm); |
||||
$AT_update_2 = $this->obj->update(1, 'test_group', 'testGroup'); |
||||
$this->assertTrue($AT_update_2); |
||||
$AE_update_2_confirm = $this->obj->get($this->obj->get_id('test_group')); |
||||
$this->assertEquals('testGroup', $AE_update_2_confirm->definition); |
||||
$AF_wrong_id = $this->obj->update(0, 'test_group_1', 'test grp 1'); |
||||
$this->assertFalse($AF_wrong_id); |
||||
} |
||||
|
||||
public function test_get_id() |
||||
{ |
||||
$AF_wrong_name = $this->obj->get_id(''); |
||||
$this->assertFalse($AF_wrong_name); |
||||
$AIT_id_given = $this->obj->get_id(1); |
||||
$this->assertEquals('1', $AIT_id_given); |
||||
} |
||||
|
||||
public function test_get() |
||||
{ |
||||
$AF_wrong_name = $this->obj->get($this->obj->get_id('testGrp')); |
||||
$this->assertFalse($AF_wrong_name); |
||||
} |
||||
|
||||
public function test_get_all() |
||||
{ |
||||
$AE_get_all = $this->obj->get_all(); |
||||
$this->assertEquals(1, count($AE_get_all)); |
||||
$AT_delete = $this->obj->delete(1); |
||||
$this->assertTrue($AT_delete); |
||||
$AF_get_all = $this->obj->get_all(); |
||||
$this->assertFalse($AF_get_all); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,61 @@
|
||||
<?php |
||||
|
||||
class Group_to_user_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Group_to_user_model', 'group_to_user', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->CI->load->model('aauth/Groups_model', 'groups', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->group_to_user; |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$this->CI->groups->create('test_group'); |
||||
$test_group_id = $this->CI->groups->get_id('test_group'); |
||||
$AT_create = $this->obj->create($test_group_id, 1); |
||||
$this->assertTrue($AT_create); |
||||
$AF_already_member = $this->obj->create($test_group_id, 1); |
||||
$this->assertFalse($AF_already_member); |
||||
$AF_wrong_user = $this->obj->create($test_group_id, 0); |
||||
$this->assertFalse($AF_wrong_user); |
||||
$AF_wrong_group = $this->obj->create(0, 1); |
||||
$this->assertFalse($AF_wrong_group); |
||||
} |
||||
|
||||
public function test_delete() |
||||
{ |
||||
$test_group_id = $this->CI->groups->get_id('test_group'); |
||||
$AT_pre_test = $this->obj->exist($test_group_id, 1); |
||||
$this->assertTrue($AT_pre_test); |
||||
$AT_delete = $this->obj->delete($test_group_id, 1); |
||||
$this->assertTrue($AT_delete); |
||||
$AF_after_test = $this->obj->exist($test_group_id, 1); |
||||
$this->assertFalse($AF_after_test); |
||||
} |
||||
|
||||
public function test_delete_by_user() |
||||
{ |
||||
$AF_wrong_user = $this->obj->delete_by_user(0); |
||||
$this->assertFalse($AF_wrong_user); |
||||
} |
||||
|
||||
public function test_delete_by_group() |
||||
{ |
||||
$AF_wrong_group = $this->obj->delete_by_group(0); |
||||
$this->assertFalse($AF_wrong_group); |
||||
} |
||||
|
||||
public function test_exist() |
||||
{ |
||||
$AF_wrong_user = $this->obj->exist(1, 0); |
||||
$this->assertFalse($AF_wrong_user); |
||||
$AF_wrong_group = $this->obj->exist(0, 1); |
||||
$this->assertFalse($AF_wrong_group); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
<?php |
||||
|
||||
class Group_to_subgroup_test extends TestCase |
||||
{ |
||||
|
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Group_to_subgroup_model', 'group_to_subgroup', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->CI->load->model('aauth/Groups_model', 'groups', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->group_to_subgroup; |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$this->CI->groups->create('test_subgroup_1'); |
||||
$this->CI->groups->create('test_subgroup_2'); |
||||
$test_maingroup_id = $this->CI->groups->get_id('test_subgroup_1'); |
||||
$test_subgroup_id = $this->CI->groups->get_id('test_subgroup_2'); |
||||
$AT_create = $this->obj->create($test_maingroup_id, $test_subgroup_id); |
||||
$this->assertTrue($AT_create); |
||||
$AF_already_member = $this->obj->create($test_maingroup_id, $test_subgroup_id); |
||||
$this->assertFalse($AF_already_member); |
||||
$AF_wrong_subgroup = $this->obj->create($test_maingroup_id, 0); |
||||
$this->assertFalse($AF_wrong_subgroup); |
||||
$AF_wrong_maingroup = $this->obj->create(0, $test_subgroup_id); |
||||
$this->assertFalse($AF_wrong_maingroup); |
||||
$AF_same_group = $this->obj->create($test_subgroup_id, $test_subgroup_id); |
||||
$this->assertFalse($AF_same_group); |
||||
} |
||||
|
||||
public function test_delete() |
||||
{ |
||||
$test_maingroup_id = $this->CI->groups->get_id('test_subgroup_1'); |
||||
$test_subgroup_id = $this->CI->groups->get_id('test_subgroup_2'); |
||||
$AT_pre_test = $this->obj->exist($test_maingroup_id, $test_subgroup_id); |
||||
$this->assertTrue($AT_pre_test); |
||||
$AT_delete = $this->obj->delete($test_maingroup_id, $test_subgroup_id); |
||||
$this->assertTrue($AT_delete); |
||||
$AF_after_test = $this->obj->exist($test_maingroup_id, $test_subgroup_id); |
||||
$this->assertFalse($AF_after_test); |
||||
} |
||||
|
||||
public function test_delete_by_subgroup() |
||||
{ |
||||
$test_maingroup_id = $this->CI->groups->get_id('test_subgroup_1'); |
||||
$test_subgroup_id = $this->CI->groups->get_id('test_subgroup_2'); |
||||
$AT_create = $this->obj->create($test_maingroup_id, $test_subgroup_id); |
||||
$AT_delete_by_subgroup = $this->obj->delete_by_subgroup($test_subgroup_id); |
||||
$this->assertTrue($AT_delete_by_subgroup); |
||||
|
||||
$AF_wrong_subgroup = $this->obj->delete_by_subgroup(0); |
||||
$this->assertFalse($AF_wrong_subgroup); |
||||
} |
||||
|
||||
public function test_delete_by_group() |
||||
{ |
||||
$test_maingroup_id = $this->CI->groups->get_id('test_subgroup_1'); |
||||
$test_subgroup_id = $this->CI->groups->get_id('test_subgroup_2'); |
||||
$AT_create = $this->obj->create($test_maingroup_id, $test_subgroup_id); |
||||
$AT_delete_by_group = $this->obj->delete_by_group($test_maingroup_id); |
||||
$this->assertTrue($AT_delete_by_group); |
||||
$AF_wrong_group = $this->obj->delete_by_group(0); |
||||
$this->assertFalse($AF_wrong_group); |
||||
} |
||||
|
||||
public function test_exist() |
||||
{ |
||||
$test_maingroup_id = $this->CI->groups->get_id('test_subgroup_1'); |
||||
$test_subgroup_id = $this->CI->groups->get_id('test_subgroup_2'); |
||||
$AF_wrong_subgroup = $this->obj->exist($test_maingroup_id, 0); |
||||
$this->assertFalse($AF_wrong_subgroup); |
||||
$AF_wrong_group = $this->obj->exist(0, $test_subgroup_id); |
||||
$this->assertFalse($AF_wrong_group); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,65 @@
|
||||
<?php |
||||
|
||||
class Permissions_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Permissions_model', 'permissions', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->permissions; |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$AIT_create = $this->obj->create('test_permission'); |
||||
$this->assertInternalType('int', $AIT_create); |
||||
$AF_same_permission = $this->obj->create('test_permission'); |
||||
$this->assertFalse($AF_same_permission); |
||||
$AF_no_permission = $this->obj->create(''); |
||||
$this->assertFalse($AF_no_permission); |
||||
|
||||
} |
||||
|
||||
public function test_update() |
||||
{ |
||||
$AT_update_1 = $this->obj->update(1, 'new_test_permission'); |
||||
$this->assertTrue($AT_update_1); |
||||
$AE_update_1_confirm = $this->obj->get_id('new_test_permission'); |
||||
$this->assertEquals('1', $AE_update_1_confirm); |
||||
$AT_update_2 = $this->obj->update(1, 'test_permission', 'testPermission'); |
||||
$this->assertTrue($AT_update_2); |
||||
$AE_update_2_confirm = $this->obj->get($this->obj->get_id('test_permission')); |
||||
$this->assertEquals('testPermission', $AE_update_2_confirm->definition); |
||||
$AF_wrong_id = $this->obj->update(0, 'test_permission_1', 'test perm 1'); |
||||
$this->assertFalse($AF_wrong_id); |
||||
} |
||||
|
||||
public function test_get_id() |
||||
{ |
||||
$AF_wrong_name = $this->obj->get_id(''); |
||||
$this->assertFalse($AF_wrong_name); |
||||
$AIT_id_given = $this->obj->get_id(1); |
||||
$this->assertEquals('1', $AIT_id_given); |
||||
} |
||||
|
||||
public function test_get() |
||||
{ |
||||
$AF_wrong_name = $this->obj->get($this->obj->get_id('testPerm')); |
||||
$this->assertFalse($AF_wrong_name); |
||||
} |
||||
|
||||
public function test_get_all() |
||||
{ |
||||
$AE_get_all = $this->obj->get_all(); |
||||
$this->assertEquals(1, count($AE_get_all)); |
||||
$AT_delete = $this->obj->delete(1); |
||||
$this->assertTrue($AT_delete); |
||||
$AF_get_all = $this->obj->get_all(); |
||||
$this->assertFalse($AF_get_all); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,69 @@
|
||||
<?php |
||||
|
||||
class Permissions_to_user_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Permission_to_user_model', 'permission_to_user', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->CI->load->model('aauth/Permissions_model', 'permissions', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->permission_to_user; |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$this->CI->permissions->create('test_permission'); |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$AT_create = $this->obj->create($test_permission_id, 1); |
||||
$this->assertTrue($AT_create); |
||||
$AF_already_member = $this->obj->create($test_permission_id, 1); |
||||
$this->assertFalse($AF_already_member); |
||||
$AF_wrong_user = $this->obj->create($test_permission_id, 0); |
||||
$this->assertFalse($AF_wrong_user); |
||||
$AF_wrong_permission = $this->obj->create(0, 1); |
||||
$this->assertFalse($AF_wrong_permission); |
||||
} |
||||
|
||||
public function test_delete() |
||||
{ |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$AT_pre_test = $this->obj->exist($test_permission_id, 1); |
||||
$this->assertTrue($AT_pre_test); |
||||
$AT_delete = $this->obj->delete($test_permission_id, 1); |
||||
$this->assertTrue($AT_delete); |
||||
$AF_after_test = $this->obj->exist($test_permission_id, 1); |
||||
$this->assertFalse($AF_after_test); |
||||
} |
||||
|
||||
public function test_delete_by_user() |
||||
{ |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$this->obj->create(1, $test_permission_id); |
||||
$AT_delete_by_user = $this->obj->delete_by_user(1); |
||||
$this->assertTrue($AT_delete_by_user); |
||||
$AF_wrong_user = $this->obj->delete_by_user(0); |
||||
$this->assertFalse($AF_wrong_user); |
||||
} |
||||
|
||||
public function test_delete_by_permission() |
||||
{ |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$this->obj->create(1, $test_permission_id); |
||||
$AT_delete_by_permission = $this->obj->delete_by_permission($test_permission_id); |
||||
$this->assertTrue($AT_delete_by_permission); |
||||
$AF_wrong_permission = $this->obj->delete_by_permission(0); |
||||
$this->assertFalse($AF_wrong_permission); |
||||
} |
||||
|
||||
public function test_exist() |
||||
{ |
||||
$AF_wrong_user = $this->obj->exist(1, 0); |
||||
$this->assertFalse($AF_wrong_user); |
||||
$AF_wrong_permission = $this->obj->exist(0, 1); |
||||
$this->assertFalse($AF_wrong_permission); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,72 @@
|
||||
<?php |
||||
|
||||
class Permissions_to_group_test extends TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->resetInstance(); |
||||
$this->CI->config->load('aauth'); |
||||
$this->config_vars = $this->CI->config->item('aauth'); |
||||
$this->CI->load->library('aauth'); |
||||
$this->CI->load->model('aauth/Permission_to_group_model', 'permission_to_group', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->CI->load->model('aauth/Permissions_model', 'permissions', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->CI->load->model('aauth/Groups_model', 'groups', $this->CI->load->database($this->config_vars['database']['_profile'])); |
||||
$this->obj = $this->CI->permission_to_group; |
||||
$this->CI->groups->create('test_group'); |
||||
$this->test_group_id = $this->CI->groups->get_id('test_group'); |
||||
} |
||||
|
||||
public function test_create() |
||||
{ |
||||
$this->CI->permissions->create('test_permission'); |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$AT_create = $this->obj->create($test_permission_id, $this->test_group_id); |
||||
$this->assertTrue($AT_create); |
||||
$AF_already_member = $this->obj->create($test_permission_id, $this->test_group_id); |
||||
$this->assertFalse($AF_already_member); |
||||
$AF_wrong_group = $this->obj->create($test_permission_id, 0); |
||||
$this->assertFalse($AF_wrong_group); |
||||
$AF_wrong_permission = $this->obj->create(0, $this->test_group_id); |
||||
$this->assertFalse($AF_wrong_permission); |
||||
} |
||||
|
||||
public function test_delete() |
||||
{ |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$AT_pre_test = $this->obj->exist($test_permission_id, $this->test_group_id); |
||||
$this->assertTrue($AT_pre_test); |
||||
$AT_delete = $this->obj->delete($test_permission_id, $this->test_group_id); |
||||
$this->assertTrue($AT_delete); |
||||
$AF_after_test = $this->obj->exist($test_permission_id, $this->test_group_id); |
||||
$this->assertFalse($AF_after_test); |
||||
} |
||||
|
||||
public function test_delete_by_group() |
||||
{ |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$this->obj->create($test_permission_id, $this->test_group_id); |
||||
$AT_delete_by_group = $this->obj->delete_by_group($this->test_group_id); |
||||
$this->assertTrue($AT_delete_by_group); |
||||
$AF_wrong_group = $this->obj->delete_by_group(0); |
||||
$this->assertFalse($AF_wrong_group); |
||||
} |
||||
|
||||
public function test_delete_by_permission() |
||||
{ |
||||
$test_permission_id = $this->CI->permissions->get_id('test_permission'); |
||||
$this->obj->create($test_permission_id, $this->test_group_id); |
||||
$AT_delete_by_permission = $this->obj->delete_by_permission($test_permission_id); |
||||
$this->assertTrue($AT_delete_by_permission); |
||||
$AF_wrong_permission = $this->obj->delete_by_permission(0); |
||||
$this->assertFalse($AF_wrong_permission); |
||||
} |
||||
|
||||
public function test_exist() |
||||
{ |
||||
$AF_wrong_group = $this->obj->exist(1, 0); |
||||
$this->assertFalse($AF_wrong_group); |
||||
$AF_wrong_permission = $this->obj->exist(0, $this->test_group_id); |
||||
$this->assertFalse($AF_wrong_permission); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
<phpunit |
||||
bootstrap="./Bootstrap.php" |
||||
colors="true"> |
||||
<testsuites> |
||||
<testsuite name="CodeIgniter Application Test Suite"> |
||||
<directory suffix="test.php">./models</directory> |
||||
<directory suffix="test.php">./controllers</directory> |
||||
<directory suffix="test.php">./language</directory> |
||||
<directory suffix="test.php">./libraries</directory> |
||||
<directory suffix="test.php">./views</directory> |
||||
<exclude>./_ci_phpunit_test/</exclude> |
||||
</testsuite> |
||||
</testsuites> |
||||
<filter> |
||||
<whitelist> |
||||
<file>../config/aauth.php</file> |
||||
<file>../config/aauth_init.php</file> |
||||
<directory suffix=".php">../controllers</directory> |
||||
<directory suffix=".php">../models/aauth</directory> |
||||
<directory suffix=".php">../language</directory> |
||||
<directory suffix=".php">../libraries</directory> |
||||
<directory suffix=".php">../views</directory> |
||||
<exclude> |
||||
<directory suffix=".php">../views</directory> |
||||
<directory suffix=".php">../controllers</directory> |
||||
<directory suffix=".php">../language</directory> |
||||
<!--<directory suffix=".php">../libraries/Aauth_init</directory> --> |
||||
</exclude> |
||||
</whitelist> |
||||
</filter> |
||||
<logging> |
||||
<log type="coverage-html" target="build/coverage"/> |
||||
</logging> |
||||
</phpunit> |
Loading…
Reference in new issue