View file modules/admin/system/admin.php

File size: 2.73Kb
<?
/**
 * Автор скрипта Орёл
 * Распространение бесплатно
 * icq: 952042
 * E-mail [email protected]
 */
defined('IN_ACCESS') or die('<b>Доступ закрыт =)</b>');

class ADMIN_Controller extends Controller{
        function __construct(){
                parent :: __construct();
        }

        public function action_index(){
                if ($_GET['pass'] == $this->config['admin_pass']){
                        $_SESSION['admin'] = true;
                        redirect(URL);
                } else {
                        $errors = array();
                        if ($_GET['submit']) $errors[] = 'Неправильный пароль';
                        $tpl_data = array('errors' => $errors);

                        $this->tpl->assign($tpl_data);
                        $this->tpl->display('index');
                }
        }

        public function action_del(){
                if (IS_ADMIN){
                        if ($_GET['confirm']){
                                $file = DB :: $dbh->queryFetch('SELECT `file_nameserver` FROM `files` WHERE `file_id`=?', array($_GET['idfile']));
                                if (!empty($file)){
                                        @unlink(ROOT .'files/'. $file['file_nameserver']);
                                        DB :: $dbh->query('DELETE FROM `files` WHERE `file_id`=?', array($_GET['idfile']));
                                        redirect(p_url('catalog'));
                                }
                        }
                        confirm('Подтвердите удаление файла', p_url('admin/del', 'idfile='. $_GET['idfile'] .'&confirm=yes'), p_url('catalog'));
                }
        }

        public function action_conf(){
                if (IS_ADMIN){
                        if ($_POST['submit']){
                                foreach ($_POST as $key => $value){
                                        $this->config[$key] = $value;
                                }
                                $this->config['max_upload_byte'] = $this->config['max_upload_byte']*1024*1024;
                                unset($this->config['submit']);

                                Main :: update_inifile(ROOT.'local/ini/mainconfig.ini', $this->config);
                                notice('Настройки сохранены', p_url('admin/conf'));
                        }

                        $tpl_data = array(
                                'config'        => $this->config
                        );

                        $this->tpl->assign($tpl_data);
                        $this->tpl->display('conf');
                }
        }
}
?>