Метод контроллер (отвечает за показ статей данной категории)
public function action_category_show()
{
$page = Arr::get($_GET, 'page', '1');
$limit = Arr::get($_GET, 'limit', '12');
$months = Date::months(Date::MONTHS_LONG);
$date = time();
$month = date('m', $date);
$parent = $this->request->param('category_url');
$session_data = $this->session->as_array();
$articles = Model::factory('Category')->get_all($page, $limit, $parent, $session_data);
$total_posts = Model::factory('Category')->get_count_article($parent);
$pagination = Pagination::factory(array(
'total_items' => $total_posts,
'items_per_page' => $limit,
));
$content = View::factory('category')
->bind('parent', $parent)
->bind('limit', $limit)
->bind('articles', $articles)
->bind('pagination', $pagination)
;
$this->template->content = $content;
}
Метод get_all из модели
Свернутый текст
public function get_all($page, $limit, $parent, $session_data)
{
$start = 0;
$count = $page - 1;
$user_id = !empty($session_data['user_id']) ? $session_data['user_id'] : 0;
$parent_id = DB::select('content_id')
->from('cs_content_list')
->where('url', '=', $parent)->execute()->get('content_id');
;
if ($count > 0) {$start = ($count * $limit) + 1;}
$query = DB::select('cs_product.*', array('cs_content_list.url', 'url'))
->from('cs_product')
->join('cs_products_cat')
->on('cs_products_cat.product_id', '=', 'cs_product.id')
->join('cs_content_list')
->on('cs_products_cat.cat_id', '=', 'cs_content_list.content_id')
->and_where('cs_products_cat.cat_id', '=', $parent_id)
->and_where('cs_product.enable', '=', 1)
->order_by('cs_product.id', 'DESC')
->limit($limit)
->offset($start)
;
$result = $query->execute()->as_array();
return $result;
}
Что неправильно написано в данном коде. Как нужно в кохане проверять данные такого типа
$this->request->param('category_url')
Какие советы можете дать. Хотелось бы привести эти два метода в правильный и безопасный с точки зрения всевозможных атак код)