Программный комплекс управления сайтом с использованием "Kohana Framework"
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
ck {:100%;:90px;color:#000000;}
#bottom_bar_black {:100%;:80px;color:#000000;}
#nav_block {: 500px;:90px;:right;}
.nav_button {:#FFFFFF;family:Verdana, Arial, Helvetica, sans-serif;style: italic;size:12px;left:15px;top:35px;align:center;:left;}:hover{style: normal;weight: bold;: #fff; }{ decoration: none;style: italic;weight: normal;: #fff; family:Verdana, Arial, Helvetica, sans-serif;style: italic;size:12px; }
#header {:500px;top:50px;bottom:250px;: left;}
.header_content_mainline {size:35px;:#000000;:500px;style: italic;}
#header_content_boxline {size:35px;:#000000;:400px;style: italic;}
#header_content_lowerline {size:35px;:#FFFFFF;:400px;style: italic;}
#header_content_boxcontent {size:12px;:#333333;:400px;style: italic;}
#header_content_lowerboxcontent {size:12px;:#CCCCCC;:400px;}
#header_content_tagline {size:12px;:#333333;:500px;}
#header_lower {:400px;:left;right:40px;bottom:50px;}
#copywriteblock {: 10px auto;: 900px;:#333333;size:10px;family: verdana;align:right;decoration:none;}
#copywriteblock a{: #222;}
#copywriteblock a:hover{: #555;}
#clear{clear: both;}{: 0 10px;: 5px;}
..\aplication\classes\adminverification.php
<?php defined(SYSPATH) or die(No direct script access.);Adminverification extends Controller_Template
{
public function before()
{
$session = Session::instance();
$session->set(auth_redirect, $_SERVER[REQUEST_URI]);
$auth=Auth::instance();
if($auth->logged_in() == 0 ) Request::initial()->redirect(authformer);
if($auth->logged_in(admin) == 0 ) Request::initial()->redirect(netprav);
return parent::before();
}
}
..\aplication\classes\childrenbefore.php
<?php defined(SYSPATH) or die(No direct script access.);Childrenbefore extends Controller_Template
{
public function before()
{
$session = Session::instance(); // Создание эземпляра класса Session на основе метода Instance
$session->set(auth_redirect, $_SERVER[REQUEST_URI]); // запись в переменную session методом set страницы которую хотел посетить пользователь
$auth=Auth::instance(); // объявление экземпляра класса авторизации
if($auth->logged_in() == 0) Request::initial()->redirect(authformer); // если пользователь не авторизован переадресовать его на страницу авторизации
return parent::before();
}
}
..\aplication\classes\exception404.php
<?php defined(SYSPATH) or die(No direct script access.);Exception404
{static function handle(Exception $e) // На вход приходит ошибка
{(get_class($e))
{HTTP_Exception_404:// сравнивается с 404
$response = new Response;
$response->status(404);// в статус сервера 404
$view = new View(404view); // использовать вид view404
$view->message = $e->getMessage(); // записать в переменную $message сообщение из контроллера materials -- throw new HTTP_Exception_404(Страница не найдена!);$response->body($view)->send_headers()->body();// генерация отображения
return TRUE;;:// если не 404 обрабатывать стандартными методами Kohana
return Kohana_Exception::handler($e); ;
}
}
}
..\aplication\classes\loginverification.php
<?php defined(SYSPATH) or die(No direct script access.);Loginverification extends Controller_Template
{
public function before()
{
$session = Session::instance();
$session->set(auth_redirect, $_SERVER[REQUEST_URI]);
$auth=Auth::instance();
if($auth->logged_in() == 0 ) Request::initial()->redirect(authformer);
return parent::before();
}
}
..\aplication\classes\nstree.php (готовый модуль для работы категорий)
<?php defined(SYSPATH) or die(No direct script access.);
/*TABLE `tree` (
`id` INT(10) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`left_key` INT(10) NOT NULL,
`right_key` INT(10) NOT NULL,
`level` INT(10) NOT NULL,KEY (`id`),`key` (`left_key`, `right_key`, `level`)
)=utf8_general_ci=InnoDB
*/NSTree
{$table = NULL;function __construct($tablename)
{
$this->table = $tablename;
}
// Модифицирует ключиfunction modifyNodes($key, $delta)
{
$query =
UPDATE .Database::instance()->quote_table($this->table).right_key = right_key + .(int)$delta.right_key >= .(int)$key;::query(Database::UPDATE, $query)->execute();
$query =
UPDATE .Database::instance()->quote_table($this->table).left_key = left_key + .(int)$delta.left_key >= .(int)$key;::query(Database::UPDATE, $query)->execute();
}function getNode($id)
{
$result = DB::select()
>from($this->table)
>where(id, =, $id)
>execute();(count($result) == 0)new Exception(Node id=.$id. does not exist.);$result->current();
}function clear($extrafields=array())
{(!is_array($extrafields))new Exception($extrafields must be array.);::query(NULL, TRUNCATE .Database::instance()->quote_table($this->table))->execute();::delete($this->table)->execute();
$data = array(
id => 1,
name => ,
left_key => 1,
right_key => 2,
level => 0
);
$data = $data + $extrafields;($insert_id, $tmp) = DB::insert($this->table, array_keys($data))->values(array_values($data))->execute();$insert_id;
}function getTree($id=NULL)
{
$id = (int) $id;
$QTblName = Database::instance()->quote_table($this->table);($id != 0)
{
$node = $this->getNode($id);
$query =
SELECT *.$QTblName.left_key >= .(int)$node[left_key]. AND right_key <= .(int)$node[right_key].BY left_key;
}
{
$query =
SELECT *.$QTblName.BY left_key;
}
$result = DB::query(Database::SELECT, $query)->execute();$result;
}function getPath($id)
{
$node = $this->getNode($id);
$query =
SELECT *.Database::instance()->quote_table($this->table).right_key > .(int)$node[left_key]. AND left_key < .(int)$node[right_key].BY left_key;
$result = DB::query(Database::SELECT, $query)->execute();$result;
}function insert($id, $extrafields=array())
{(!is_array($extrafields))new Exception($extrafields must be array.);
// Находим родителя
$parent = $this->getNode($id);::query(NULL, START TRANSACTION)->execute();
// Обновляем ключи существующего дерева, узлы стоящие за родительским узлом
$this->modifyNodes((int)$parent[right_key], 2);
// Добавляем новый узел
$node = array(
id => NULL,
left_key => $parent[right_key],
right_key => $parent[right_key] + 1,
level => $parent[level] + 1
);
$node = $node + $extrafields;($insert_id, $tmp) = DB::insert($this->table, array_keys($node))->values(array_values($node))->execute();::query(NULL, COMMIT)->execute();$insert_id;
}function delete($id)
{
$node = $this->getNode($id);::query(NULL, START TRANSACTION)->execute();
// Удаляем узел (вместе с веткой)
$query =
DELETE FROM .Database::instance()->quote_table($this->table).left_key >= .(int)$node[left_key]. AND right_key execute();
$width = $node[right_key] - $node[left_key] + 1;
// Обновление последующих узлов
$this->modifyNodes((int)$node[right_key], -$width);::query(NULL, COMMIT)->execute();
}
// Метод перемещает ноду $id в родительскую ноду $parentId
public function move($id, $parentId)
{
$node = $this->getNode($id);::query(NULL, START TRANSACTION)->execute();
// Удаляем узел (вместе с веткой)
$query =
DELETE FROM .Database::instance()->quote_table($this->table).left_key >= .(int)$node[left_key]. AND right_key e
Copyright © 2008-2014 geum.ru рубрикатор по предметам рубрикатор по типам работ пользовательское соглашение