Главная | Обратная связь | Поможем написать вашу работу!
МегаЛекции

.\aplication\classes\controller\admin\users.php




.. \aplication\classes\controller\admin\users. php

<? php defined('SYSPATH') or die('No direct script access. ');

class Controller_Admin_Users extends Adminverification // главный контроллер, наследуется от Adminverification

{  

       public $template = 'admin/title';    // основной вид страницы

public function action_index() // функция выполняемая по умолчанию index

       {     

   $data=array();

   $Searchuser = new Model_Searchuser();

   if(isset($_POST['SearchGo']))

                   {

       $SearchUsername = Security:: xss_clean(Arr:: get($_POST, 'username', ''));

              

       if($names=$Searchuser-> find($SearchUsername)and($SearchUsername< > " " ))     

       {

           $data['name']= $names;

           $data['findok'] = " ";       

       }

       else

       {

           $data[" findno" ] = " ";

       }  

   }

    $data['usercount']=$Searchuser-> usercount();

   $data['admincount']=$Searchuser-> admincount();

   $this-> template-> content = View:: factory('admin/usersview', $data);

       }

}

.. \aplication\classes\model\addrole. php

<? php defined('SYSPATH') or die('No direct script access. ');

class Model_Addrole extends ORM

{

       protected $_table_name = 'roles_users';

}

 

 

.. \aplication\classes\model\category. php

<? php defined('SYSPATH') or die('No direct script access. ');

class Model_Category

{

protected $nstree;

protected $tableName;

       protected $errors = array();

 

       public function __construct($tableName)

{

   $this-> nstree = new NSTree($tableName);

   $this-> tableName = $tableName;

}

 

       public function getTree()

{

                   return $this-> nstree-> getTree();

}

 

       public function catInsert($parentId, $data = array())

{

   $data = Arr:: extract($data, array('name'));

   $text=$data['name'];

   $generation = new Model_Generation;       

   $data['nametrans']=$generation-> TanslitGeneration($text);

   $vData = $data;

   $vData['parentId'] = $parentId;

   $nametrans=$data['nametrans'];

   $validation = Validation:: factory($vData);

  $validation-> rule('name', 'not_empty');

   $validation-> rule('name', 'regex', array(': value', '/^[A-я0-9]++$/iD'));

   $validation-> rule('name', 'min_length', array(': value', '3'));

   $validation-> rule('name', 'max_length', array(': value', '200'));

   $validation-> rule('parentId', 'check_id', array(': value', $this-> tableName));

   $validation-> rule('nametrans', array($this, 'unique_url'));

   if(! $validation-> check())

   {

                              $this-> errors = $validation-> errors('catErrors');

                              return FALSE;

   }

// Транслит для правильного исопльзования в url

                   $this-> nstree-> insert($parentId, $data);

   return TRUE;

}

       public function getErrors()

{

   return $this-> errors;

}

          

public function unique_url($nametrans)

{

return! DB:: select(array(DB:: expr('COUNT(nametrans)'), 'total'))

   -> from($this-> tableName)

   -> where('nametrans', '=', $nametrans)

   -> execute()

   -> get('total');

}

           

public function getCategoryIdByUrl($nametrans)

{

   $data = DB:: select('id')

   -> from($this-> tableName)

   -> where('nametrans', '=', $nametrans)

   -> execute()

   -> current();

   if(! isset($data['id'])) return FALSE;

   return $data['id'];

}

}

 

.. \aplication\classes\model\editmatcat. php

<? php defined('SYSPATH') or die('No direct script access. ');

class Model_Editmatcat

{  

public function Delmatsfromcategory($categoryId)

{

   $query = DB:: delete('materials')

   -> where('category_id', '=', $categoryId);  

   $result = $query-> as_object()-> execute();  

   $query = DB:: delete('tree')

   -> where('id', '=', $categoryId);  

   $result = $query-> as_object()-> execute();

   return true;

}

   

  public function Delmat($mid)

{

   $query = DB:: delete('materials')

   -> where('id', '=', $mid);  

   $result = $query-> as_object()-> execute();   

   return true;

}

 

public function ShowMatNameList($category_id)

{

   $query = DB:: select('name')

   -> from('materials')

   -> where('category_id', '=', $category_id);

   $result = $query-> execute()-> as_array();

   return $result;

}

}

 

.. \aplication\classes\model\generation. php

<? php defined('SYSPATH') or die('No direct script access. ');

class Model_Generation

{

public function PasswordGeneration ($symbols)//кол-во символов в пароле

{

$arr = array('a', 'b', 'c', 'd', 'e', 'f',

            'g', 'h', 'i', 'j', 'k', 'l',

            'w', 'q', 's', 'n', 'o', 'v',

            't', 'u', 'm', 'x', 'y', 'z',

            'A', 'B', 'C', 'D', 'E', 'F',

            'G', 'H', 'I', 'J', 'K', 'L',

            'W', 'Q', 'M', 'P', 'R', 'S',

            'U', 'T', 'V', 'I', 'Y', 'Z',

            '0', '2', '6', '4', '5', '3',

            '7', '8', '9', '1');   

//генерируем пасс

$pass = " ";

for($a=0; $a< $symbols; $a++)

{

   //вычисляем случайный индекс массива

   $index = rand(0, count($arr) - 1);

   $pass. = $arr[$index];

}

return $pass;                   

}

 

public function TanslitGeneration($str)

{

   $arr = array(

       " А" => " A", " Б" => " B", " В" => " V", " Г" => " G",

       " Д" => " D", " Е" => " E", " Ё" => " E", " Ж" => " J", " З" => " Z", " И" => " I",

       " Й" => " Y", " К" => " K", " Л" => " L", " М" => " M", " Н" => " N",

       " О" => " O", " П" => " P", " Р" => " R", " С" => " S", " Т" => " T",

       " У" => " U", " Ф" => " F", " Х" => " H", " Ц" => " TS", " Ч" => " CH",

       " Ш" => " SH", " Щ" => " SCH", " Ъ" => " ", " Ы" => " YI", " Ь" => " ",

       " Э" => " E", " Ю" => " YU", " Я" => " YA", " а" => " a", " б" => " b",

       " в" => " v", " г" => " g", " д" => " d", " е" => " e", " ё" => " e", " ж" => " j",

       " з" => " z", " и" => " i", " й" => " y", " к" => " k", " л" => " l",

       " м" => " m", " н" => " n", " о" => " o", " п" => " p", " р" => " r",

       " с" => " s", " т" => " t", " у" => " u", " ф" => " f", " х" => " h",

       " ц" => " ts", " ч" => " ch", " ш" => " sh", " щ" => " sch", " ъ" => " y",

       " ы" => " yi", " ь" => " ", " э" => " e", " ю" => " yu", " я" => " ya"

   );

   return strtr($str, $arr);

}

}

Поделиться:





Воспользуйтесь поиском по сайту:



©2015 - 2024 megalektsii.ru Все авторские права принадлежат авторам лекционных материалов. Обратная связь с нами...