Esempio n. 1
0
 public function actionIndex()
 {
     $product_count_main_page = FL::fileGetContents('product_count_main_page.txt');
     $product_count_catalog_page = FL::fileGetContents('product_count_catalog_page.txt');
     $product_count_category_page = FL::fileGetContents('product_count_category_page.txt');
     if (isset($_POST['submit'])) {
         if (isset($_POST['productCountMainPage'])) {
             $productCountMainPage = FL::clearInt($_POST['productCountMainPage']);
             AdminModel::filePutContents(ROOT . '/config/product_count_main_page.txt', $productCountMainPage);
         }
         if (isset($_POST['productCountCatalogPage'])) {
             $productCountCatalogPage = FL::clearInt($_POST['productCountCatalogPage']);
             AdminModel::filePutContents(ROOT . '/config/product_count_catalog_page.txt', $productCountCatalogPage);
         }
         if (isset($_POST['productCountCategoryPage'])) {
             $productCountCategoryPage = FL::clearInt($_POST['productCountCategoryPage']);
             AdminModel::filePutContents(ROOT . '/config/product_count_category_page.txt', $productCountCategoryPage);
         }
         FL::redirectTo('/admin/view');
     }
     $view = new View();
     $view->product_count_main_page = $product_count_main_page;
     $view->product_count_catalog_page = $product_count_catalog_page;
     $view->product_count_category_page = $product_count_category_page;
     $view->display('admin_view/index.php');
     return true;
 }
Esempio n. 2
0
 public function actionDelete($id)
 {
     if ($id) {
         ProductOrderModel::delete($id);
         FL::redirectTo('/admin/order');
     }
     return true;
 }
Esempio n. 3
0
 public static function getUser($key)
 {
     if (isset($_SESSION[$key])) {
         $value = $_SESSION[$key];
         return unserialize($value);
     } elseif (isset($_COOKIE[$key])) {
         $str = 'avtobus12troleibus23h23';
         $encrypted = $_COOKIE[$key];
         $email = FL::decrypted($encrypted, $str);
         return UserModel::getByColumn('email', $email);
     } else {
         return false;
     }
 }
 public function actionDelete($id)
 {
     $product = ProductModel::getById($id);
     if (isset($_POST['delNo'])) {
         FL::redirectTo('/admin/product');
     }
     if (isset($_POST['delYes'])) {
         $result = ProductModel::delete($id);
         if ($result) {
             FL::redirectTo('/admin/product');
         }
     }
     $view = new View();
     $view->product = $product;
     $view->display('admin_product/delete.php');
     return true;
 }
Esempio n. 5
0
 public function actionEdit($id)
 {
     $id = (int) $id;
     $name = '';
     $password = '';
     $errors = [];
     $user = UserModel::getUser('user');
     if (!$user) {
         FL::redirectTo('/');
     }
     $categories = CategoryModel::getAllUsingColumns();
     if (isset($_POST['submit'])) {
         $name = FL::clearStr($_POST['name']);
         $password = FL::clearStr($_POST['password']);
         if (!FL::isValue($name)) {
             $errors[] = 'Имя не может быть пустым';
         }
         if (!FL::isPassword($password)) {
             $errors[] = 'Пароль должен быть больше 5 символов';
         }
         if (empty($errors)) {
             $user = UserModel::getById($id);
             $user->name = $name;
             $user->password = $password;
             Session::deleteSession('user');
             Cookie::deleteCookie('user');
             $result = $user->save(false, true);
             if ($result) {
                 FL::redirectTo('/cabinet');
             }
         }
     }
     $view = new View();
     $view->categories = $categories;
     $view->id = $id;
     $view->errors = $errors;
     $view->password = $password;
     $view->user = $user;
     $view->display('cabinet/edit.php');
     return true;
 }
Esempio n. 6
0
 public function actionContact()
 {
     $email = '';
     $subject = '';
     $message = '';
     $result = '';
     $errors = [];
     $categories = CategoryModel::getAllUsingColumns();
     if (isset($_POST['submit'])) {
         $email = FL::clearStr($_POST['email']);
         $subject = FL::clearStr($_POST['subject']);
         $message = nl2br(FL::clearStr($_POST['message']));
         if (!FL::isEmail($email)) {
             $errors[] = 'Некорректный email';
         }
         if (!FL::isValue($subject)) {
             $errors[] = 'Тема не может быть пустым';
         }
         if (!FL::isValue($message)) {
             $errors[] = 'Сообщение не может быть пустым';
         }
         if (empty($errors)) {
             $adminEmail = '*****@*****.**';
             $subject = "Тема письма: {$subject}. От: {$email}";
             $message = "Текст письма: {$message}";
             $result = mail($adminEmail, $subject, $message);
         }
     }
     $view = new View();
     $view->categories = $categories;
     $view->email = $email;
     $view->subject = $subject;
     $view->message = $message;
     $view->errors = $errors;
     $view->result = $result;
     $view->display('site/contact.php');
     return true;
 }
Esempio n. 7
0
 public function actionCategory($categoryId, $page = 1)
 {
     $limit = FL::fileGetContents('product_count_category_page.txt');
     if (!$limit) {
         $limit = 9;
     }
     $page = (int) $page;
     $categories = CategoryModel::getAllUsingColumns();
     $products = ProductModel::getByCategoryId($categoryId, $limit, $page);
     if (!$products) {
         $products = [];
     }
     $total = ProductModel::getTotal('category_id', $categoryId);
     $pagination = FL::buildPagination($total, $page, $limit, 'page-');
     $view = new View();
     $view->categories = $categories;
     $view->products = $products;
     $view->categoryId = $categoryId;
     if (isset($pagination)) {
         $view->pagination = $pagination;
     }
     $view->display('catalog/category.php');
     return true;
 }
Esempio n. 8
0
 protected function update($newDate, $rememberUser)
 {
     $arr = [];
     $params = [];
     if (isset($this->data['password'])) {
         $password = $this->data['password'];
         $password = password_hash($password, PASSWORD_DEFAULT);
         $this->data['password'] = $password;
     }
     foreach ($this->data as $key => $value) {
         $params[':' . $key] = $value;
         if ($key == 'id') {
             continue;
         }
         $arr[] = $key . ' = :' . $key;
     }
     if ($newDate) {
         $params[':date'] = date("Y-m-d H:i:s");
     }
     $sql = "UPDATE ";
     $sql .= static::$table;
     $sql .= " SET ";
     $sql .= implode(', ', $arr);
     $sql .= " WHERE id = :id ";
     $sql .= "LIMIT 1";
     $db = new DB();
     $result = $db->execute($sql, $params);
     if ($result) {
         if ($rememberUser) {
             // Вход с помощью сессии
             // $user = self::getByColumn('email', $this->data['email']);
             // Session::createSession('user', $user);
             // Вход с помощью cookie
             $key = 'avtobus12troleibus23h23';
             $encrypted = FL::encrypted($this->data['email'], $key);
             setcookie('user', $encrypted, 0x7fffffff, '/');
         }
         return $result;
     } else {
         throw new ModelException('Произошла ошибка при редактировании');
     }
 }
Esempio n. 9
0
 public function actionDelete($id)
 {
     UserModel::delete($id);
     FL::redirectTo('/admin/user');
     return true;
 }
Esempio n. 10
0
 public function actionOrder()
 {
     $userName = '';
     $errors = [];
     $categories = CategoryModel::getAllUsingColumns();
     $productsKeysArray = Session::getSession('products');
     if ($productsKeysArray) {
         $keysArray = array_keys($productsKeysArray);
         $keysString = implode(',', $keysArray);
         if ($keysString) {
             $products = ProductModel::getAll($keysString);
             $amountPrice = CartModel::amountProductsPriceInCart($productsKeysArray, $products);
         }
     }
     $user = UserModel::getUser('user');
     if ($user) {
         $userName = $user->name;
         $userId = $user->id;
     } else {
         $userId = 0;
     }
     if (isset($_POST['submit'])) {
         $name = FL::clearStr($_POST['name']);
         $phone = FL::clearStr($_POST['phone']);
         $comment = FL::clearStr($_POST['comment']);
         if (!FL::isValue($name)) {
             $errors[] = 'Имя не может быть пустым';
         }
         if (!FL::isValue($phone)) {
             $errors[] = 'Телефон не может быть пустым';
         }
         if (!FL::isPhone($phone)) {
             $errors[] = 'Невалидный телефон';
         }
         if (!FL::isValue($comment)) {
             $errors[] = 'Комментарий не может быть пустым';
         }
         if (empty($errors)) {
             $productsKeysArray = Session::getSession('products');
             if ($productsKeysArray) {
                 $products = json_encode($productsKeysArray);
             }
             $cart = new CartModel();
             $cart->user_name = $name;
             $cart->user_phone = $phone;
             $cart->user_comment = $comment;
             $cart->user_id = $userId;
             $cart->products = $products;
             $orderId = $cart->save();
             if ($orderId) {
                 Session::deleteSession('products');
                 Session::createSession('message', 'Заказ оформлен!');
                 FL::redirectTo('/cart');
             }
         }
     } else {
         $countProducts = CartModel::countProductsInCart();
         if ($countProducts <= 0) {
             FL::redirectTo('/');
         }
     }
     $view = new View();
     $view->categories = $categories;
     $view->amountPrice = $amountPrice;
     $view->userName = $userName;
     $view->errors = $errors;
     $view->display('cart/order.php');
     return true;
 }
Esempio n. 11
0
            echo \App\Components\FunctionLibrary::getStatus($cnt);
            ?>
&nbsp;&nbsp;
                                    </option>
                                    <?php 
            continue;
            ?>
                                    <?php 
        }
        ?>
                                    <option value="<?php 
        echo $cnt;
        ?>
">
                                        &nbsp;&nbsp;<?php 
        echo \App\Components\FunctionLibrary::getStatus($cnt);
        ?>
&nbsp;&nbsp;
                                    </option>
                                <?php 
    }
    ?>
                            </select>&nbsp;&nbsp;
                            <input type="submit" name="submit" value="Выбрать" class="btn btn-default">
                        </form>
                    <?php 
}
?>
                    </div>
                </div>
            </div>
Esempio n. 12
0
        ?>
</td>
                                <td><?php 
        echo htmlentities($order->user_phone);
        ?>
</td>
                                <td><?php 
        echo htmlentities($order->user_comment);
        ?>
</td>
                                <td><?php 
        echo \App\Components\FunctionLibrary::getDate($order->date, true);
        ?>
</td>
                                <td><?php 
        echo \App\Components\FunctionLibrary::getStatus($order->status);
        ?>
</td>
                                <td><a href="/admin/order/view/<?php 
        echo (int) $order->id;
        ?>
"><i class="fa fa-eye"></i></a></td>
                                <td><a href="/admin/order/edit/<?php 
        echo (int) $order->id;
        ?>
"><i class="fa fa-edit"></i></a></td>
                                <td>
                                    <a href="/admin/order/delete/<?php 
        echo (int) $order->id;
        ?>
" onclick="return confirm('Вы уверены что хотите удалить заказ?')">
Esempio n. 13
0
 public function actionDelete($id)
 {
     $blog = BlogModel::delete($id);
     if ($blog) {
         FL::redirectTo('/admin/blog');
     }
     return true;
 }
Esempio n. 14
0
 public function actionLogout()
 {
     Session::deleteSession('user');
     Cookie::deleteCookie('user');
     FL::redirectTo('/');
 }
 public function actionDelete($id)
 {
     CategoryModel::delete($id);
     FL::redirectTo('/admin/category');
     return true;
 }
Esempio n. 16
0
                </div>
            </div>
            <div class="col-sm-9 padding-right">
                <div class="features_items"><!--features_items-->
                    <h2 class="title text-center">Блог</h2>
                    <div class="app-block">
                        <?php 
if (!empty($blog)) {
    ?>
                            <h3 class="app-title-example app-grey-color"><?php 
    echo htmlentities($blog->title);
    ?>
</h3>
                            <br>
                            <p class="app-soft-grey-color"><i class="fa fa-calendar"></i> <?php 
    echo FL::getDate($blog->dt);
    ?>
</p>
                            <br>
                            <div><img src="/template<?php 
    echo htmlentities($blog->image);
    ?>
"</div>
                            <br>
                            <br>
                            <div><?php 
    echo htmlentities($blog->content);
    ?>
</div>
                        <?php 
}
Esempio n. 17
0
<?php

use App\Components\Router;
use App\Components\View;
use App\Components\Logger;
use App\Components\FunctionLibrary as FL;
// Front Controller
// 1. Общие настройки
ini_set('display_errors', 1);
error_reporting(E_ALL);
session_start();
// 2. Подключение системных файлов
define('ROOT', dirname(__FILE__));
require_once ROOT . '/components/autoload.php';
// 3. Вызов Router
try {
    $router = new Router();
    $router->run();
    FL::deleteLink();
} catch (Exception $e) {
    $logger = Logger::getInstance();
    $logger->setLog($e->getFile(), $e->getLine(), $e->getMessage());
    $view = new View();
    $view->error = $e->getMessage();
    $view->display('error.php');
}
Esempio n. 18
0
                        <h4 class="app-block app-grey-color">Пока записей нет!</h4>
                        <?php 
} else {
    ?>
                        <div class="row">
                            <div class="col-sm-12 app-box">
                            <?php 
    foreach ($blogs as $blog) {
        ?>
                            <div>
                                <h3 class="app-grey-color"><?php 
        echo htmlentities($blog->title);
        ?>
</h3>
                                <p class="app-grey-color"><i class="fa fa-calendar"></i> <?php 
        echo htmlentities(FL::getDate($blog->dt));
        ?>
</p>
                                <br>
                                <div class="row">
                                    <div class="col-lg-4 col-md-5 col-sm-6">
                                        <img src="/template<?php 
        echo htmlentities($blog->image);
        ?>
" class="img-responsive">
                                        <br>
                                    </div>
                                    <div class="col-ld-8 col-md-7 col-sm-6 app-blog-description-box app-grey-color">
                                        <?php 
        echo htmlentities($blog->description);
        ?>