public function action_update()
 {
     Controller_admin::check_user();
     $items = News::get_one($_GET['id']);
     $viewer = new Views();
     $viewer->items = $items;
     $viewer->display('edit_views');
     if (!empty($_POST['delete'])) {
         $delete = new Controller_add();
         $delete->deleteNews();
     }
     if (!empty($_POST['title'])) {
         $article = new Add();
         $article->title = $_POST['title'];
         $article->content = $_POST['content'];
         $article->id_article = $_GET['id'];
         $article->save();
     }
 }
Example #2
0
 public function add_articles($sql, $params = [])
 {
     try {
         $sth = $this->dbh->prepare($sql);
         $sth->execute($params);
     } catch (PDOException $e) {
         Add::AddLogs($e->getMessage(), 'PDOException: ');
     }
 }
Example #3
0
<?php

use Application\Models\Add;
require_once __DIR__ . '/autoload.php';
$controllerName = isset($_GET['cln']) ? $_GET['cln'] : 'News';
$controllerAction = isset($_GET['act']) ? $_GET['act'] : 'all';
$controllerName = 'Controller_' . $controllerName;
$method = 'action_' . $controllerAction;
if (!class_exists($controllerName) or !method_exists($controllerName, $method)) {
    header('Location: views/404.php');
}
try {
    $controller = new $controllerName();
    $controller->{$method}();
} catch (E404Exception $eror404) {
    $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    Add::AddLogs($url, '404 Not Found: ');
    exit;
}
Example #4
0
    public function action_update()
    {
        $items = News::get_one($_GET['id']);
        $viewer = new Views;
        $viewer->items = $items;
        $viewer->display ('edit_views');

        //Обрабатываем нажатие кнопки "удалить"
        if (!empty($_POST['delete']))
        {
            $delete = new Controller_add;
            $delete->deleteNews();
        }

        //Сохраняем изменения
        if (!empty($_POST['title']))
        {
            $article = new Add;
            $article->title = $_POST['title'];
            $article->content = $_POST['content'];
            $article->id_article = $_GET['id'];
            $article->save();
        }
    }