function requestPage() { $page = _::int('page', 0, $_GET); if ($page > 0) { return $page; } $page = strtolower(_::str('page', '', $_GET)); if ($page !== '') { return $page; } return 0; }
<?php require "include/connect.php"; // Соединение с БД /** @section Бизнес-логика */ /** @section Обработка запросов */ $response = array(); $method = strtolower(_::str('method')); switch ($method) { /** @subsection Обработка запросов к Api */ /** @subsection Обработка ошибочного запроса */ default: Api::error(0, $method . ' : Неверный запрос к Api'); // Все прочие запросы игнорируются } Api::out($response);
case 'group.all': $response = Page::all(); break; case 'group.get': $response = Group::get(_::int('group')); break; case 'group.student': $response = Group::student(_::int('group'), _::int('student')); break; case 'group.notify': $response = Group::notify(_::int('group'), _::int('author'), _::str('header'), _::str('text')); break; case 'page.add': $response = Page::add(_::str('title'), _::raw('text'), _::int('author')); break; case 'page.all': $response = Page::all(); break; case 'page.get': $response = Page::get(_::int('id')); break; case 'page.edit': $response = Page::edit(_::int('id'), _::str('title'), _::raw('text')); break; /** @subsection Обработка ошибочного запроса */ /** @subsection Обработка ошибочного запроса */ default: Api::error(0, $method . ' : Неверный запрос к Api'); // Все прочие запросы игнорируются } Api::out($response);