public function renderForm() { $uid = isset($_GET['uid']) ? (int) $_GET['uid'] : 1; $result = $this->getUserData($uid); $access = $this->getAccessList(); $form = new HTMLForm(); $form->open('edituser', '', 'POST'); $form->setInput('login')->setAttr('type|text')->setAttr(isset($result['userData']['login']) ? 'value|' . $result['userData']['login'] : '')->setRules('notempty|trim')->setErrorText('Введите логин пользователя')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('uid')->setAttr('type|hidden')->setAttr('value|' . $result['userData']['uid'])->addInput(); $form->setInput('password')->setAttr('type|text')->setAttr(isset($result['userData']['password']) ? 'value|' . $result['userData']['password'] : '')->setRules('notempty|trim|length[40|40]')->setErrorText('Введите hash пароля пользователя (можно получить в генераторе под формой)')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('email')->setAttr('type|text')->setAttr(isset($result['userData']['email']) ? 'value|' . $result['userData']['email'] : '')->setRules('email')->setErrorText('Введён не корректный email пользователя')->setAttr('class|form-control input-lg')->addInput(); $form->setSelect('access')->setAttr('class|form-control')->setAttr('style|width:300px')->setRules('notempty')->addSelect(); $form->setInput('edituser')->setAttr('type|submit')->setAttr('class|btn btn-primary btn-lg addpage')->setAttr('value|Сохранить')->addInput(); foreach ($access as $k => $v) { if (!in_array($v['acid'], array(2))) { $form->setOption($v['aname'])->setAttr('value|' . $v['acid'])->setAttr($result['userData']['isadmin'] == $v['acid'] ? 'selected|selected' : '')->addOption('access'); } } $formUserData = $form->close(); Bufer::set(array('errors' => isset($result['errors']) ? $result['errors'] : array(), 'userData' => $result['userData'], 'formUserData' => $formUserData)); if (!$form->sendForm('edituser')) { $errors = $form->getErrors(); Bufer::set(array('errors' => $errors, 'formUserData' => $formUserData)); } else { $data = $form->getData(); $data = array('uid' => $uid, 'login' => $this->model->escape($data['login']), 'password' => $this->model->escape($data['password']), 'email' => $this->model->escape($data['email']), 'access' => $this->model->escape($data['access'])); $saveUser = $this->saveUser($data); if (!isset($saveUser['error'])) { Route::go('?mode=admin&route=edituser&uid=' . $uid); } else { Bufer::set(array('errors' => $saveUser['error'], '$formUserData' => $formUserData)); } } }
public function renderForm() { $model = $this->model; $form = new HTMLForm(); $form->open('addsection', '', 'POST'); $form->setInput('sname')->setAttr('type|text')->setAttr('onkeyup|document.getElementById(\'child\').value=translit(this.value)')->setAttr(isset($_POST['sname']) ? 'value|' . $_POST['sname'] : '')->setRules('notempty')->setErrorText('Введите наименование раздела')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('sindex')->setAttr('type|text')->setAttr('id|child')->setAttr(isset($_POST['sindex']) ? 'value|' . $_POST['sindex'] : '')->setRules('notempty|regexp[#([a-z]){3,}#i]')->setErrorText('Введите псевдоним раздела (от 3х букв)')->setAttr('class|form-control input-lg')->addInput(); $form->setTextarea('sdescription')->setAttr('class|form-control')->setRules('notempty')->setText(isset($_POST['sdescription']) ? $_POST['sdescription'] : '')->setErrorText('Введите описание раздела')->addTextarea(); $form->setInput('createsection')->setAttr('type|submit')->setAttr('class|btn btn-primary btn-lg addpage')->setAttr('value|Создать')->addInput(); $formAddsection = $form->close(); Bufer::set(array('formAddsection' => $formAddsection)); if (!$form->sendForm('createsection')) { $errors = $form->getErrors(); Bufer::add(array('errors' => $errors)); } else { $data = $form->getData(); $data = array('sname' => $this->model->escape($data['sname']), 'sdescription' => $this->model->escape($data['sdescription']), 'sindex' => $this->model->escape($data['sindex'])); $checkIndexSection = $this->model->checkIndexSection($data); if (!isset($checkIndexSection['errors'])) { $result = $this->addsection($data, $formAddsection); if ($result['errors']) { Bufer::add(array('errors' => $result['errors'])); } } else { Bufer::add(array('errors' => $checkIndexSection['errors'])); } } }
public function renderForm() { $acid = isset($_GET['acid']) ? (int) $_GET['acid'] : 0; $groupUsersData = $this->model->getGroupUsersData($acid); //echo '<pre>' . print_r($groupUsersData, 1) . '</pre>'; $form = new HTMLForm(); $form->open('editgroupusers', '', 'POST'); $form->setInput('aname')->setAttr('type|text')->setAttr('value|' . $groupUsersData['groupUsersData']['aname'])->setRules('notempty|trim')->setErrorText('Введите наименование группы')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('editgroupusers')->setAttr('type|submit')->setAttr('class|btn btn-primary btn-lg addpage')->setAttr('value|Сохранить')->addInput(); $formEditGroupUsers = $form->close(); Bufer::set(array('formEditGroupUsers' => $formEditGroupUsers)); if ($groupUsersData['success'] === false) { Bufer::add(array('errors' => $groupUsersData['error'])); } if (!$form->sendForm('editgroupusers')) { $errors = $form->getErrors(); Bufer::add(array('errors' => $errors)); } else { $data = $form->getData(); $data = array('acid' => $acid, 'aname' => $this->model->escape($data['aname'])); $checkName = $this->checkName($data); if ($checkName['success'] === true) { $result = $this->saveGroupUsers($data); if ($result['success'] === false) { Bufer::add(array('errors' => $result['error'])); } else { Route::go('?mode=admin&route=editgroupusers&acid=' . $acid); } } else { Bufer::add(array('errors' => $checkName['error'])); } } }
public function renderForm() { $form = new HTMLForm(); $form->open('addgroupusers', '', 'POST'); $form->setInput('aname')->setAttr('type|text')->setRules('notempty|trim')->setErrorText('Введите наименование группы')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('addgroupusers')->setAttr('type|submit')->setAttr('class|btn btn-primary btn-lg addpage')->setAttr('value|Создать')->addInput(); $formAddGroupUsers = $form->close(); Bufer::set(array('formAddGroupUsers' => $formAddGroupUsers)); if (!$form->sendForm('addgroupusers')) { $errors = $form->getErrors(); Bufer::add(array('errors' => $errors)); } else { $data = $form->getData(); $checkName = $this->checkName($data['aname']); if ($checkName['success'] === false) { Bufer::add(array('errors' => $checkName['error'])); } else { $data = array('aname' => $this->model->escape($data['aname'])); $result = $this->addGroupUsers($data); if ($result['success'] === false) { Bufer::add(array('errors' => $result['error'])); } else { Route::go('?mode=admin&route=groupsusers'); } } } }
public function deleteSection($sid) { $result = $this->model->deleteSection($sid); if ($result['success'] === false) { Bufer::set(array('errors' => $result['errors'])); } }
public function renderForm() { $model = $this->model; $pid = isset($_GET['pid']) ? (int) $_GET['pid'] : 0; $pageData = $this->getPage($pid); if (isset($pageData['errors'])) { Bufer::set(array('errors' => $pageData['errors'])); } else { Bufer::set(array('pageData' => $pageData['pageData'])); } $errors = isset($pageData['errors']) ? $pageData['errors'] : false; $dataPage = isset($pageData['pageData'][0]) ? $pageData['pageData'][0] : false; $getSections = $model->returnData("select * from section"); $form = new HTMLForm(); $form->open('addpage', '', 'POST'); $form->setInput('title')->setAttr('type|text')->setAttr('onkeyup|document.getElementById(\'child\').value=translit(this.value)')->setAttr(isset($dataPage['title']) ? 'value|' . $dataPage['title'] : '')->setRules('notempty|trim')->setErrorText('Введите Title страницы')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('pid')->setAttr('type|hidden')->setAttr('value|' . $pid)->setRules('notempty')->addInput(); $form->setInput('description')->setAttr('type|text')->setAttr(isset($dataPage['description']) ? 'value|' . $dataPage['description'] : '')->setRules('notempty')->setErrorText('Введите описание для страницы')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('keywords')->setAttr('type|text')->setAttr(isset($dataPage['keywords']) ? 'value|' . $dataPage['keywords'] : '')->setRules('notempty')->setErrorText('Введите ключевые слова для страницы')->setAttr('class|form-control input-lg')->addInput(); $form->setInput('index')->setAttr('type|text')->setAttr('id|child')->setAttr(isset($dataPage['name']) ? 'value|' . $dataPage['name'] : '')->setRules('notempty')->setErrorText('Введите псевдоним страницы')->setAttr('class|form-control input-lg')->addInput(); $form->setSelect('section')->setAttr('class|form-control')->setAttr('style|width:300px')->setRules('notempty')->addSelect(); foreach ($getSections as $s) { $form->setOption($s['sname'] . ' (' . $s['sindex'] . ')')->setAttr('value|' . $s['sid'])->setAttr(isset($dataPage['sid']) && $dataPage['sid'] == $s['sid'] ? 'selected|selected' : '')->addOption('section'); } $form->setSelect('display')->setAttr('class|form-control')->setAttr('style|width:300px')->setRules('notempty')->addSelect(); $display = array(1 => 'да', 2 => 'нет', 3 => 'только для администрации'); foreach ($display as $k => $v) { $form->setOption($v)->setAttr('value|' . $k)->setAttr(isset($dataPage['display']) && $dataPage['display'] == $k ? 'selected|selected' : '')->addOption('display'); } $form->setTextarea('preview')->setAttr('id|preview')->setText(isset($dataPage['preview']) ? $dataPage['preview'] : '')->setAttr('class|preview form-control')->setRules('trim')->addTextarea(); $form->setTextarea('content')->setAttr('id|content')->setText(isset($dataPage['content']) ? $dataPage['content'] : '')->setAttr('class|addpage form-control content')->setRules('notempty')->addTextarea(); $form->setInput('editpage')->setAttr('type|submit')->setAttr('class|btn btn-primary btn-lg addpage')->setAttr('value|Сохранить')->addInput(); $formEditpage = $form->close(); Bufer::set(array('errors' => $errors, 'formEditpage' => $formEditpage, 'titlePage' => isset($dataPage['title']) ? $dataPage['title'] : '')); /** * Провервка отправленной формы */ if (!$form->sendForm('editpage')) { $errors = $form->getErrors(); Bufer::set(array('errors' => $errors, 'formEditpage' => $formEditpage, 'titlePage' => isset($dataPage['title']) ? $dataPage['title'] : '')); } else { $data = $form->getData(); $data = array('pid' => (int) $data['pid'], 'title' => $this->model->escape($data['title']), 'description' => $this->model->escape($data['description']), 'keywords' => $this->model->escape($data['keywords']), 'index' => $this->model->escape($data['index']), 'sid' => (int) $data['section'], 'display' => (int) $data['display'], 'preview' => $this->model->escape($data['preview']), 'content' => $this->model->escape($data['content'])); $savePage = $this->savePage($data); $checkIndexPage = $this->model->checkIndexPage($data); if (!isset($checkIndexPage['error'])) { $result = $this->savePage($data, $formEditpage); if (!isset($savePage['errors'])) { Route::go('?mode=admin&route=editpage&pid=' . $data['pid']); } else { Bufer::set(array('errors' => $savePage['error'], 'formEditpage' => $formEditpage, 'titlePage' => isset($data['title']) ? $data['title'] : '')); } } else { Bufer::set(array('errors' => $checkIndexPage['error'], 'formEditpage' => $formEditpage, 'titlePage' => isset($data['title']) ? $data['title'] : '')); } } }
public function getListGalery() { $listGalery = $this->model->getListGelery(); if ($listGalery['success'] === false) { Bufer::set(array('errors' => array($listGalery['error']))); } else { Bufer::set(array('galeryList' => $listGalery['data'], 'paginate' => !empty($listGalery['paginate']) ? $listGalery['paginate'] : false)); } //echo '<pre>' . print_r(bufer::getData(), 1) . '<pre>'; }
public function getDataHtmlSnippet($hsid) { $hsid = isset($_GET['hsid']) ? (int) $_GET['hsid'] : 0; $result = $this->model->getDataHtmlSnippet($hsid); if ($result['success'] === false) { Bufer::set(array('errors' => $result['error'])); } else { return $result['data']; } }
public function getGaleryData($glid) { $result = $this->model->getGaleryData($glid); if ($result['success'] === false) { Bufer::set(array('errors' => array('error'))); return false; } else { Bufer::add(array('data' => $result['data'])); return $result['data']; } }
/** * Реакция на правильно заполненную форму * @param array - ассоц. массив значений полей формы * @param array - массив с элементами формы из renderForm() */ public function access($data, $form) { $login = $this->model->escape($data['login']); $password = sha1(SALT . $data['password']); $result = $this->model->sqlQuery("select \r\n *\r\n from \r\n users \r\n where \r\n isadmin=1 and login='******' and password='******'"); if ($result->num_rows > 0) { $_SESSION['fw'][INDEX_SESSION_ADMIN] = true; Route::go('?mode=admin&route=pages'); } else { Bufer::set(array('errors' => array('Не верный логин или пароль!'), 'formAutorize' => $form)); } }
public function checkIndexPage($data) { $sql_for_search_index_page = "select * from pages where `name` = '" . $data['index'] . "' and pid !=" . $data['pid']; $result = $this->sqlQuery($sql_for_search_index_page); if ($result->num_rows > 0) { $errors = array('name' => 'Страница с данным псевдонимом уже существует!'); Bufer::set(array('errors' => $errors)); return array('success' => false, 'error' => $errors); } else { return array('success' => true); } }
$this->setModel('Htmlsnippets'); } public function getHtmlSnippets() { $snippets = $this->model->getHtmlSnippets(); if ($snippets === false) { return false; } else { return array('data' => $snippets, 'paginate' => $this->paginate()); } } public function deleteHtmlSnippet($hsid) { $hsid = isset($_GET['delete']) ? (int) $_GET['delete'] : 0; $result = $this->model->deleteHtmlSnippet($hsid); if ($result['success'] === false) { Bufer::add(array('errors' => $result['error'])); } else { header("location:" . Route::getUrl('?mode=admin&route=htmlsnippets')); } } } $controller = new HtmlsnippetsController(); Bufer::set(array('HtmlSnippetsList' => $controller->getHtmlSnippets())); if (isset($_GET['delete'])) { $hsid = isset($_GET['delete']) ? (int) $_GET['delete'] : 0; $controller->deleteHtmlSnippet($hsid); } $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/htmlsnippets.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
} public function deleteUser($uid) { $result = $this->model->deleteUser($uid); if ($result['success'] === true) { header("location:" . Route::getUrl('?mode=admin&route=users')); } else { Bufer::add(array('errors' => $result['error'])); } } } $controller = new UsersController(); Bufer::set(array('usersList' => array('data' => $controller->model->getUsersList(), 'paginate' => $controller->paginate()), 'accessList' => $controller->getAccessList())); if (isset($_GET['updateAccess'])) { $temp = explode(',', $_GET['updateAccess']); $uid = (int) $temp[0]; $access = (int) $temp[1]; $result = $controller->changeAccess($uid, $access); if ($result === false) { Bufer::set(array('errors' => array('Произошла ошибка при смене прав пользователя'), 'usersList' => array('data' => $controller->model->getUsersList(), 'paginate' => $controller->paginate()), 'accessList' => $controller->getAccessList())); } else { header("location: " . Route::getUrl('?mode=admin&route=users')); } } $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/users.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl'); if (isset($_GET['deleteuser'])) { $uid = (int) $_GET['deleteuser']; $controller->deleteUser($uid); }
public function renderForm() { $form = new HTMLForm(); $form->open('images', '', 'POST', 'enctype|multipart/form-data'); $form->setInput('name_galery')->setAttr('type|text')->setAttr('onkeyup|document.getElementById(\'child\').value=translit(this.value)')->setAttr('class|form-control input-lg')->setRules('notempty|trim')->setAttr('value|' . (isset($_POST['name_galery']) ? $_POST['name_galery'] : ''))->setErrorText('Укажите название новой галереи (3-30 знаков)')->addInput(); $form->setInput('sinonim_galery')->setAttr('type|text')->setAttr('id|child')->setAttr('class|form-control input-lg')->setAttr('value|' . (isset($_POST['sinonim_galery']) ? $_POST['sinonim_galery'] : ''))->setRules('notempty|trim|regexp[#[a-z0-9\\-_\\.]#]')->setErrorText('Укажите синоним галереи')->addInput(); $form->setTextarea('gdescription')->setAttr('class|form-control')->setText(isset($_POST['gdescription']) ? $_POST['gdescription'] : '')->setRules('notempty|trim')->setErrorText('Укажите описание галереи')->addTextarea(); $form->setInput('images[]')->setAttr('type|file')->setAttr('multiple|multiple')->addInput(); $form->setInput('resize')->setAttr('type|checkbox')->setAttr(isset($_POST['resize']) ? 'checked|checked' : '')->addInput(); $form->setInput('resize_w')->setAttr('type|text')->setAttr('value|' . (isset($_POST['resize_w']) ? (int) $_POST['resize_w'] : 800))->setRules('regexp[#[0-9]*#]')->setErrorText('Укажите ширину картинки для ресайза')->setAttr('class|form-control input-lg notlong')->addInput(); $form->setInput('resize_h')->setAttr('type|text')->setAttr('value|' . (isset($_POST['resize_h']) ? (int) $_POST['resize_h'] : 0))->setRules('regexp[#[0-9]*#]')->setErrorText('Укажите высоту картинки для ресайза')->setAttr('class|form-control input-lg notlong')->addInput(); $form->setInput('preview')->setAttr('type|checkbox')->setAttr('checked')->setAttr('disabled|disabled')->addInput(); $form->setInput('preview_w')->setAttr('type|text')->setAttr('value|' . (isset($_POST['preview_w']) ? (int) $_POST['preview_w'] : 150))->setAttr('class|form-control input-lg notlong')->setRules('regexp[#[0-9]*#]')->setErrorText('Укажите ширину картинки для превью')->addInput(); $form->setInput('preview_h')->setAttr('type|text')->setAttr('value|' . (isset($_POST['preview_h']) ? (int) $_POST['preview_h'] : 0))->setAttr('class|form-control input-lg notlong')->setRules('regexp[#[0-9]*#]')->setErrorText('Укажите высоту картинки для preview')->addInput(); $form->setInput('watermark')->setAttr('type|checkbox')->setAttr(isset($_POST['watermark']) ? 'checked|checked' : '')->addInput(); $form->setInput('watermarkfile')->setAttr('type|file')->addInput(); $form->setSelect('wm_position')->setAttr('class|form-control')->setAttr('style|width:300px')->setRules('notempty')->addSelect(); $form->setOption('Слева наверху')->setAttr('value|top_left')->addOption('wm_position'); $form->setOption('Справа наверху')->setAttr('value|top_right')->addOption('wm_position'); $form->setOption('Внизу слева')->setAttr('value|bottom_left')->addOption('wm_position'); $form->setOption('Внизу справа')->setAttr('value|bottom_right')->setAttr('selected|selected')->addOption('wm_position'); $form->setSelect('image_quality')->setAttr('class|form-control')->setAttr('style|width:300px')->setRules('notempty')->addSelect(); $form->setOption('Исходное качество')->setAttr('value|100')->addOption('image_quality'); $form->setOption('90%')->setAttr('value|90')->addOption('image_quality'); $form->setOption('80%')->setAttr('value|80')->addOption('image_quality'); $form->setOption('70%')->setAttr('value|70')->addOption('image_quality'); $form->setOption('60%')->setAttr('value|60')->addOption('image_quality'); $form->setInput('wm_text')->setAttr('type|text')->setAttr('class|form-control input-lg small')->setAttr('value|' . $_SERVER['SERVER_NAME'])->setAttr('style|width:200px!important')->addInput(); $form->setInput('color')->setAttr('type|text')->setAttr('class|form-control input-lg small')->setAttr('value|' . (isset($_POST['color']) ? $_POST['color'] : 'ffffff'))->setAttr('onblur|setColor(this)')->setAttr('maxlength|6')->setAttr('size|6')->setAttr('id|colorpickerField')->setAttr('style|text-align:center;width:200px')->addInput(); $form->setSelect('size')->setAttr('class|form-control')->setAttr('style|width:200px')->setRules('notempty')->addSelect(); $form->setOption('9 px')->setAttr('value|9')->addOption('size'); $form->setOption('10 px')->setAttr('value|10')->addOption('size'); $form->setOption('12 px')->setAttr('value|12')->addOption('size'); $form->setOption('15 px')->setAttr('value|15')->setAttr('selected|selected')->addOption('size'); $form->setOption('20 px')->setAttr('value|20')->addOption('size'); $form->setSelect('alfa')->setAttr('class|form-control')->setAttr('style|width:300px')->setRules('notempty')->addSelect(); $form->setOption('Не прозрачный')->setAttr('value|1')->addOption('alfa'); $form->setOption('50%')->setAttr('value|50')->addOption('alfa'); $form->setOption('60%')->setAttr('value|60')->addOption('alfa'); $form->setOption('70%')->setAttr('value|70')->addOption('alfa'); $form->setOption('80%')->setAttr('value|80')->addOption('alfa'); $form->setOption('90%')->setAttr('value|90')->addOption('alfa'); $form->setInput('addimages')->setAttr('type|submit')->setAttr('class|btn btn-primary btn-lg')->setAttr('value|Создать галерею')->addInput(); $imagesForm = $form->close(); Bufer::set(array('imagesForm' => $imagesForm)); if (!$form->sendForm('addimages')) { $errors = $form->getErrors(); Bufer::add(array('errors' => $errors)); } else { $settings_upload = $this->getSettingsUploads(); $bufer = Bufer::getData(); //Ошибок нет, создадим строку в БД if (!isset($bufer['errors'])) { $gid = $this->addGaleryToDb(); } if (isset($gid) && $gid !== false) { if (!isset($bufer['errors'])) { $result = $this->creatFolders($gid); if ($result === true) { $result = $this->copyFiles($settings_upload, $gid); } } else { $this->model->deleteGalery($gid); } } } }
public function createModule($module, $form) { $file_tpl_controller = DIR . '/' . PATH . 'app/createmodule/controller.tpl'; $file_tpl_model = DIR . '/' . PATH . 'app/createmodule/model.tpl'; $file_tpl_templte = DIR . '/' . PATH . 'app/createmodule/template.tpl'; $file_public_tpl_controller = DIR . '/' . PATH . 'app/createmodule/public/controller.tpl'; $file_public_tpl_model = DIR . '/' . PATH . 'app/createmodule/public/model.tpl'; $file_public_tpl_templte = DIR . '/' . PATH . 'app/createmodule/public/template.tpl'; if (!file_exists($file_tpl_templte) or !is_readable($file_tpl_templte)) { $errors[] = 'Не могу найти или прочитать файл шаблона *.tpl нового модуля'; } if (!file_exists($file_tpl_controller) or !is_readable($file_tpl_controller)) { $errors[] = 'Не могу найти или прочитать файл шаблона контроллера нового модуля'; } if (!file_exists($file_tpl_model) or !is_readable($file_tpl_model)) { $errors[] = 'Не могу найти или прочитать файл шаблона модели нового модуля'; } if (isset($errors)) { Bufer::add(array('errors' => $errors)); } else { $mode = $module['mode']; $namefilemodule = strtolower($module['name']); $nameclassmodule = ucfirst(strtolower($module['name'])); switch ($module['mode']) { case 1: //public module $dir_tpls = TPLS_DIR; $dir_controllers = CONTROLLERS_DIR; $dir_models = MODELS_DIR; $tpl = file_get_contents($file_public_tpl_templte); $controller = file_get_contents($file_public_tpl_controller); $model = file_get_contents($file_public_tpl_model); break; case 2: //admin module $dir_tpls = ADMIN_TPLS_DIR; $dir_controllers = ADMIN_CONTROLLERS_DIR; $dir_models = ADMIN_MODELS_DIR; $tpl = file_get_contents($file_tpl_templte); $controller = file_get_contents($file_tpl_controller); $model = file_get_contents($file_tpl_model); break; } $tpl = strtr($tpl, array('{namemodule}' => $nameclassmodule)); $controller = strtr($controller, array('{namemodule}' => $nameclassmodule, '{tpl}' => $namefilemodule)); $model = strtr($model, array('{namemodule}' => $nameclassmodule)); if (file_exists($dir_tpls . '/' . $namefilemodule . '.tpl')) { $errors[] = 'Шаблон с таким именем уже найден'; } if (file_exists($dir_controllers . '/' . $namefilemodule . '.php')) { $errors[] = 'Контроллер с таким именем уже найден'; } if (file_exists($dir_models . '/' . $namefilemodule . '.php')) { $errors[] = 'Модель с таким именем уже найдена'; } if (isset($errors)) { Bufer::add(array('errors' => $errors)); } if (!file_put_contents($dir_tpls . '/' . $namefilemodule . '.tpl', $tpl)) { $errors[] = 'Не могу сохранить файл шаблона нового модуля'; } if (!file_put_contents($dir_controllers . '/' . $namefilemodule . '.php', $controller)) { $errors[] = 'Не могу сохранить файл контроллера нового модуля'; } if (!file_put_contents($dir_models . '/' . $namefilemodule . '.php', $model)) { $errors[] = 'Не могу сохранить файл модели нового модуля'; } if (isset($errors)) { return Bufer::set(array('errors' => $errors, 'formAddModule' => $form)); } else { Route::go('?mode=admin&route=addmodule'); } } }
{ public function __construct() { parent::__construct(); RulesUrl::addRules('public', array('sections', 'page')); } public function getPageData($route) { return $this->model->getModel(ROUTE); } } $controller = new IndexController(); $controller->setModel('Index'); $model = $controller->model; $index = isset($_GET['page']) ? $_GET['page'] : 'index'; $pagesData = $model->getPageData($index); Bufer::set(array('pagesData' => $pagesData)); /** * Страницы имеют права доступа, как и посетители. * Необходимо сверить, чтобы уровень доступа посетителя совпадал * Эту проверку сделает класс ACCESS и вызов Access::validate(); * в в контроллере страниц /app/controllers/index.php * необходимо вложить в Session pid и acid страницы */ $_SESSION['fw']['pageAccess'] = array('pid' => $pagesData['pid'], 'acid' => $pagesData['acid']); if (!Access::validate()) { exit(MESSAGE_ACCESS_DENIED); } $controller->view(TPLS_DIR . '/header.tpl'); $controller->view(TPLS_DIR . '/index.tpl'); $controller->view(TPLS_DIR . '/footer.tpl');
public function __construct() { parent::__construct(); $this->setModel('Robots_txt'); } public function getFileRobots() { $file = DIR . '/' . PATH . 'robots.txt'; if (!file_exists($file)) { file_put_contents($file); } return Files::getData($file); } public function saveRobots($data) { $file = DIR . '/' . PATH . 'robots.txt'; if (!file_put_contents($file, $data)) { Bufer::add(array('errors' => 'Ошибка сохранения данных')); } else { header("location:" . Route::getUrl('?mode=admin&route=robots_txt&file=robots.txt')); } } } $controller = new Robots_txtController(); Bufer::set(array('Robots_txt' => $controller->getFileRobots())); if (isset($_POST['save_robots'])) { $controller->saveRobots($_POST['code_robots']); } $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/robots_txt.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
$listCss[$file] = $t[count($t) - 1]; } return $listCss; } public function getFileCSS($fileCss) { $path = DIR . '/' . PATH . 'app/css/'; return Files::getData($path . $fileCss); } public function saveCss($css, $fileCss) { $path = DIR . '/' . PATH . 'app/css/'; if (!file_put_contents($path . $fileCss, $css)) { Bufer::add(array('errors' => 'Ошибка сохранения данных')); } else { header("location:" . Route::getUrl('?mode=admin&route=css&file=' . $fileCss)); } } } $controller = new CssController(); $path = DIR . '/' . PATH . 'app/css/'; Bufer::set(array('listCss' => $controller->getListCss())); if (isset($_GET['file'])) { Bufer::add(array('fileData' => $controller->getFileCSS($_GET['file']))); } if (isset($_POST['save_css']) && isset($_GET['file'])) { $controller->saveCss($_POST['code_css'], $_GET['file']); } $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/css.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
<?php class PhpinfoController extends BaseController { public function __construct() { parent::__construct(); $this->setModel('Phpinfo'); } public function getPHPinfo() { return file_exists(DIR . '/' . PATH . '/phpinfo.php') ? true : false; } } $controller = new PhpinfoController(); Bufer::set(array('data' => $controller->getPHPinfo())); if (!$controller->getPHPinfo()) { Bufer::add(array('errors' => array('Отсутствует файл phpinfo.php в корне сайта'))); } $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/phpinfo.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
{ $result = $this->model->killPage($pid); return $result; } public function recoveryPage($pid) { $result = $this->model->recoveryPage($pid); return $result; } } $controller = new DeletedpagesController(); if (isset($_GET['killpage'])) { $delete = $controller->killPage((int) $_GET['killpage']); if ($delete === false) { Bufer::set(array('errors' => array('Ошибка при удалении страницы'), 'listPages' => array('data' => $controller->getListPages(), 'paginate' => $controller->paginate()), 'listSections' => $controller->getListSections())); } else { header("location: " . Route::getUrl('?mode=admin&route=deletedpages')); } } if (isset($_GET['recoverypage'])) { $delete = $controller->recoveryPage((int) $_GET['recoverypage']); if ($delete === false) { Bufer::set(array('errors' => array('Ошибка при восстановлении страницы'), 'listPages' => array('data' => $controller->getListPages(), 'paginate' => $controller->paginate()), 'listSections' => $controller->getListSections())); } else { header("location: " . Route::getUrl('?mode=admin&route=deletedpages')); } } Bufer::set(array('listPages' => array('data' => $controller->getListPages(), 'paginate' => $controller->paginate()), 'listSections' => $controller->getListSections())); $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/deletedpages.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
public function __construct() { parent::__construct(); $this->setModel('Groupsusers'); } public function getGroupsUsersList() { return $this->model->getGroupsUsersList(); } public function deleteGroupUsers($acid) { $result = $this->model->deleteGroupUsers($acid); if (isset($result['error'])) { Bufer::add(array('errors' => $result['error'])); } } } $controller = new GroupsusersController(); $acid = isset($_GET['deletegroupusers']) ? (int) $_GET['deletegroupusers'] : false; if ($acid !== false) { $result = $controller->deleteGroupUsers($acid); if ($result['success'] === false) { Bufer::add(array('errors' => $result['error'])); } else { header("location:" . Route::getUrl('?mode=admin&route=groupsusers')); } } Bufer::set(array('groupsUsersList' => $controller->getGroupsUsersList())); $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/groupsusers.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');