Beispiel #1
0
<?php

$obj = new CategoryViewer();
$output = $obj->edit();
class CategoryViewer
{
    private $config;
    public function __construct()
    {
        $this->config = dirname(__FILE__) . '/config.dat';
    }
    public function edit()
    {
        if (empty($_GET['dir'])) {
            redirect('admin/plugins.php');
        }
        $config = json_decode(file_get_contents($this->config), true);
        $templates = glob(ROOT . '/template/*', GLOB_ONLYDIR);
        if ($templates) {
            foreach ($templates as &$t) {
                $t = substr(strrchr($t, '/'), 1);
            }
        }
        if (!empty($_POST)) {
            $errors = '';
            if (empty($_POST['template']) || !in_array($_POST['template'], $templates)) {
                $errors .= '<li>Выберите корректный шаблон</li>';
            }
            if (!empty($errors)) {
                $_SESSION['form_errors'] = '<ul class="error">' . $errors . '</ul>';
                redirect('admin/plugins.php?ac=edit&dir=' . $_GET['dir']);