Browse Source

Merge pull request #13 from emreakay/v2_dev

V2-beta
develop v2.0-beta
Emre Akay 11 years ago
parent
commit
2068800488
  1. 17
      application/config/aauth.php
  2. 195
      application/controllers/example.php
  3. 1343
      application/libraries/Aauth.php
  4. 171
      sql/Aauth_v2.sql
  5. 144
      sql/aauth.sql

17
application/config/aauth.php

@ -33,9 +33,14 @@ $config['aauth'] = array(
'perms' => 'aauth_perms',
// perms to group
'perm_to_group' => 'aauth_perm_to_group',
// perms to group
'perm_to_user' => 'aauth_perm_to_user',
// pm table
'pms' => 'aauth_pms',
// system variables
'system_variables' => 'aauth_system_variables',
// user variables
'user_variables' => 'aauth_user_variables',
// remember time
'remember' => ' +3 days',
@ -46,12 +51,13 @@ $config['aauth'] = array(
// non alphanumeric characters that are allowed in a name
'valid_chars' => array(' ', '\''),
// it limits login attempts
'dos_protection' => true,
// ddos protection,
//if it is true, the user will be banned temporary when he exceed the login 'try'
'ddos_protection' => true,
// login attempts time interval
// default 10 times in one minute
'try' => 10,
// default 20 times in one hour
'max_login_attempt' => 10,
// to register email verifitaion need? true / false
'verification' => false,
@ -85,6 +91,7 @@ $config['aauth'] = array(
'no_user' => 'User not Exist',
'not_verified' => 'Please verify your account.',
'group_exist' => 'Group already exists',
'no_group' => 'Group doesn\'t exists',
'self_pm' => 'It is not reasonable to send pm to yourself :)',
'no_pm' => 'Pm not found',

195
application/controllers/example.php

@ -19,10 +19,13 @@ class Example extends CI_Controller {
public function index() {
if ($this->aauth->login('admin@admin.com', 'password', true))
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(){
@ -94,11 +97,16 @@ class Example extends CI_Controller {
//$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() {
@ -108,7 +116,7 @@ class Example extends CI_Controller {
public function is_member() {
if ($this->aauth->is_member('Admin'))
if ($this->aauth->is_member('deneme',9))
echo 'uye';
}
@ -127,14 +135,19 @@ class Example extends CI_Controller {
}
}
public function group() {
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("Mod"));
print_r($this->aauth->list_users());
echo '</pre>';
}
@ -146,24 +159,31 @@ class Example extends CI_Controller {
public function check_email() {
if ($this->aauth->check_email("emre@emreakay.com"))
if ($this->aauth->check_email("aa@a.com"))
echo 'uygun ';
else
echo 'alindi ';
echo $this->aauth->get_errors();
echo ' sadsad';
$this->aauth->print_errors();
}
public function get_user() {
print_r($this->aauth->get_user(1));
print_r($this->aauth->get_user());
}
function create_user() {
$a = $this->aauth->create_user("ess@as.com", "asd", "asdasd");
$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() {
@ -177,39 +197,180 @@ class Example extends CI_Controller {
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(3, "xxx@ssdas.com", "asd", "asdasd");
$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("denemeee");
$a = $this->aauth->create_group("deneme");
}
function delete_group() {
$a = $this->aauth->delete_group(3);
$a = $this->aauth->delete_group("deneme");
}
function update_group() {
$a = $this->aauth->update_group(4, "zxxx");
$a = $this->aauth->update_group("deneme", "zxxx");
}
function add_member() {
$a = $this->aauth->add_member(1, 4);
$a = $this->aauth->add_member(8, "deneme");
}
function fire_member() {
$a = $this->aauth->fire_member(1, 4);
$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 */

1343
application/libraries/Aauth.php

File diff suppressed because it is too large Load Diff

171
sql/Aauth_v2.sql

@ -0,0 +1,171 @@
/*
Navicat MySQL Data Transfer
Source Server : local
Source Server Version : 50508
Source Host : localhost:3306
Source Database : aauth_v2_dev
Target Server Type : MYSQL
Target Server Version : 50508
File Encoding : 65001
Date: 2014-07-03 21:23:21
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `aauth_groups`
-- ----------------------------
DROP TABLE IF EXISTS `aauth_groups`;
CREATE TABLE `aauth_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
PRIMARY KEY (`id`),
KEY `id_index` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of aauth_groups
-- ----------------------------
INSERT INTO `aauth_groups` VALUES ('1', 'Admin');
INSERT INTO `aauth_groups` VALUES ('2', 'Public');
INSERT INTO `aauth_groups` VALUES ('3', 'Default');
-- ----------------------------
-- Table structure for `aauth_perms`
-- ----------------------------
DROP TABLE IF EXISTS `aauth_perms`;
CREATE TABLE `aauth_perms` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
`definition` text,
PRIMARY KEY (`id`),
KEY `id_index` (`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) DEFAULT NULL,
`group_id` int(11) DEFAULT NULL,
KEY `perm_id_group_id_index` (`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) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
KEY `perm_id_user_id_index` (`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) NOT NULL AUTO_INCREMENT,
`sender_id` int(11) NOT NULL,
`receiver_id` int(11) NOT NULL,
`title` text NOT NULL,
`message` text,
`date` datetime DEFAULT NULL,
`read` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `full_index` (`id`,`sender_id`,`receiver_id`,`read`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of aauth_pms
-- ----------------------------
-- ----------------------------
-- Table structure for `aauth_system_variables`
-- ----------------------------
DROP TABLE IF EXISTS `aauth_system_variables`;
CREATE TABLE `aauth_system_variables` (
`key` text NOT NULL,
`value` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of aauth_system_variables
-- ----------------------------
-- ----------------------------
-- Table structure for `aauth_users`
-- ----------------------------
DROP TABLE IF EXISTS `aauth_users`;
CREATE TABLE `aauth_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` text COLLATE utf8_turkish_ci NOT NULL,
`pass` text COLLATE utf8_turkish_ci NOT NULL,
`name` text COLLATE utf8_turkish_ci,
`banned` int(11) DEFAULT '0',
`last_login` datetime DEFAULT NULL,
`last_activity` datetime DEFAULT NULL,
`last_login_attempt` datetime DEFAULT NULL,
`forgot_exp` text COLLATE utf8_turkish_ci,
`remember_time` datetime DEFAULT NULL,
`remember_exp` text COLLATE utf8_turkish_ci,
`verification_code` text COLLATE utf8_turkish_ci,
`ip_address` text COLLATE utf8_turkish_ci,
`login_attempts` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `id_index` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci;
-- ----------------------------
-- Records of aauth_users
-- ----------------------------
INSERT INTO `aauth_users` VALUES ('1', 'admin@admin.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) NOT NULL DEFAULT '0',
`group_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`,`group_id`),
KEY `user_id_group_id_index` (`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` (
`user_id` int(11) NOT NULL,
`key` text NOT NULL,
`value` text,
KEY `user_id_index` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of aauth_user_variables
-- ----------------------------

144
sql/aauth.sql

@ -1,144 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Anamakine: localhost
-- Üretim Zamanı: 18 Eylül 2013 saat 10:18:09
-- Sunucu sürümü: 5.5.8
-- PHP Sürümü: 5.3.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Veritabanı: `aauth2`
--
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `aauth_groups`
--
CREATE TABLE IF NOT EXISTS `aauth_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
--
-- Tablo döküm verisi `aauth_groups`
--
INSERT INTO `aauth_groups` (`id`, `name`) VALUES
(1, 'admin'),
(2, 'public'),
(3, 'default');
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `aauth_perms`
--
CREATE TABLE IF NOT EXISTS `aauth_perms` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
`definition` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Tablo döküm verisi `aauth_perms`
--
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `aauth_perm_to_group`
--
CREATE TABLE IF NOT EXISTS `aauth_perm_to_group` (
`perm_id` int(11) DEFAULT NULL,
`group_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Tablo döküm verisi `aauth_perm_to_group`
--
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `aauth_pm`
--
CREATE TABLE IF NOT EXISTS `aauth_pm` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sender_id` int(11) NOT NULL,
`receiver_id` int(11) NOT NULL,
`message` text,
`date` datetime DEFAULT NULL,
`read` int(11) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Tablo döküm verisi `aauth_pm`
--
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `aauth_users`
--
CREATE TABLE IF NOT EXISTS `aauth_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` text COLLATE utf8_turkish_ci NOT NULL,
`pass` text COLLATE utf8_turkish_ci NOT NULL,
`name` text COLLATE utf8_turkish_ci,
`banned` int(11) DEFAULT '0',
`last_login` datetime DEFAULT NULL,
`last_activity` datetime DEFAULT NULL,
`last_login_attempt` datetime DEFAULT NULL,
`forgot_exp` text COLLATE utf8_turkish_ci,
`remember_time` datetime DEFAULT NULL,
`remember_exp` text COLLATE utf8_turkish_ci,
`verification_code` text COLLATE utf8_turkish_ci,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci AUTO_INCREMENT=2 ;
--
-- Tablo döküm verisi `aauth_users`
--
INSERT INTO `aauth_users` (`id`, `email`, `pass`, `name`, `banned`, `last_login`, `last_activity`, `last_login_attempt`, `forgot_exp`, `remember_time`, `remember_exp`, `verification_code`) VALUES
(1, 'admin@admin.com', 'admin pass', 'Admin', 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `aauth_user_to_group`
--
CREATE TABLE IF NOT EXISTS `aauth_user_to_group` (
`user_id` int(11) NOT NULL DEFAULT '0',
`group_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`,`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Tablo döküm verisi `aauth_user_to_group`
--
INSERT INTO `aauth_user_to_group` (`user_id`, `group_id`) VALUES
(1, 1);
Loading…
Cancel
Save