Esempio n. 1
0
/**
* controller
*
* @author     Dac Chartrand <*****@*****.**>
* @license    http://www.fsf.org/licensing/licenses/gpl-3.0.html
*/
function sux($action, $params = null)
{
    switch ($action) {
        case 'banned':
            $g = new globals();
            $g->banned();
            break;
        case 'e404':
            $g = new globals();
            $g->e404();
            break;
    }
}
Esempio n. 2
0
 /**
  * Сохранение предупреждения
  * @param array $data массив данных
  * @return null
  */
 protected function save($data)
 {
     $admin_file = globals::g('admin_file');
     $id = (int) $data['id'];
     $cols = array('user' => 'username', 'reason', 'notify');
     extract(rex($data, $cols));
     $notify = (bool) $notify;
     /* @var $etc etc */
     $etc = n("etc");
     if ($user || !$id) {
         $r = $etc->select_user(null, $user, "id,email,warnings_count");
         $uid = $r["id"];
         $email = $r["email"];
         $warns = $r["warnings_count"];
     }
     if (!$uid && !$id || !$reason) {
         throw new EngineException('warnings_no_user');
     }
     $etc->warn_user($uid, $reason, $warns, $notify, $email, $id);
     if ($id) {
         $this->show($id);
         return;
     } else {
         furl::o()->location($admin_file);
     }
 }
Esempio n. 3
0
 /**
  * Сохранение бана
  * @param array $data массив данных
  * @return null
  * @throws EngineException 
  */
 protected function save($data)
 {
     $admin_file = globals::g('admin_file');
     $id = (int) $data['id'];
     $cols = array('user' => 'username', 'email', 'ip_f', 'ip_t', 'reason', 'period', 'up' => 'update');
     extract(rex($data, $cols));
     $ip_f = ip2ulong($ip_f);
     $ip_t = ip2ulong($ip_t);
     $period = (double) $period;
     /* @var $etc etc */
     $etc = n("etc");
     $uid = 0;
     if ($user) {
         $r = $etc->select_user(null, $user, "id");
         $uid = $r["id"];
     }
     if (!$uid && !$email && !$ip_f && !$ip_t) {
         throw new EngineException("bans_nothing_banned");
     }
     $etc->ban_user($uid, !$id || $up ? $period : 0, $reason, $email, $ip_f, $ip_t, $id);
     if ($id) {
         $this->show($id);
         return;
     } else {
         furl::o()->location($admin_file);
     }
 }
Esempio n. 4
0
 /**
  * Сохранение бота
  * @param array $data массив данных
  * @return null
  * @throws EngineException 
  */
 public function save($data)
 {
     $admin_file = globals::g('admin_file');
     $cols = array('id', 'name', 'firstip', 'lastip', 'agent');
     extract(rex($data, $cols));
     $id = (int) $id;
     /* @var $etc etc */
     $etc = n("etc");
     $etc->get_ips($firstip, $lastip, true);
     if (!$name) {
         throw new EngineException('bots_empty_name');
     }
     if (!$firstip && !$lastip && !$agent) {
         throw new EngineException('bots_empty_data');
     }
     $update = array('name' => $name, 'firstip' => $firstip, 'lastip' => $lastip, 'agent' => $agent);
     try {
         plugins::o()->pass_data(array("update" => &$update, "id" => $id), true)->run_hook('admin_bots_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     if (!$id) {
         db::o()->insert($update, 'bots');
         log_add('added_bot', 'admin');
     } else {
         db::o()->p($id)->update($update, 'bots', 'WHERE id=? LIMIT 1');
         log_add('changed_bot', 'admin', $id);
     }
     furl::o()->location($admin_file);
 }
Esempio n. 5
0
 function __construct($pms)
 {
     if (!globals::get('pantonescale')) {
         die("pantone.dat not found!");
     }
     $vals = globals::get('pantonescale');
     if (!arr::hasKey($vals, strtoupper($pms))) {
         throw new ColorException(sprintf("Pantone color %s not known!", $pms));
     }
     $val = $vals[strtoupper($pms)];
     $this->red = $val['r'];
     $this->green = $val['g'];
     $this->blue = $val['b'];
 }
Esempio n. 6
0
 /**
  * Инициализация модуля обратной связи
  * @return null
  */
 public function init()
 {
     $admin_file = globals::g('admin_file');
     lang::o()->get('admin/feedback');
     $act = $_GET["act"];
     switch ($act) {
         case "clear":
             /* @var $o feedback_man_ajax */
             $o = plugins::o()->get_module('feedback', 1, true);
             $o->clear();
             furl::o()->location($admin_file);
             break;
         default:
             $this->show($_GET['sort'], $_GET['type']);
             break;
     }
 }
Esempio n. 7
0
 /**
  * Сохранение стат. страницы
  * @param array $data массив данных
  * @return null
  * @throws EngineException 
  */
 public function save($data)
 {
     $admin_file = globals::g('admin_file');
     $cols = array('url', 'title', 'content', 'type');
     $update = rex($data, $cols);
     $id = (int) $data['id'];
     if (!validword($update['url'])) {
         throw new EngineException('static_empty_url');
     }
     if (!$update['title']) {
         throw new EngineException('static_empty_title');
     }
     if ($update['type'] == 'html') {
         $update['content'] = $data['html'];
     } elseif ($update['type'] == 'tpl') {
         $update['content'] = $data['tpl'];
         if (!validpath($update['content']) || !tpl::o()->template_exists($update['content'])) {
             throw new EngineException('static_tpl_not_exists');
         }
     }
     if (!$update['content']) {
         throw new EngineException('static_empty_content');
     }
     try {
         plugins::o()->pass_data(array("update" => &$update, "id" => $id), true)->run_hook('admin_static_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     if (!$id) {
         db::o()->insert($update, 'static');
         log_add('added_static', 'admin', $data['url']);
     } else {
         db::o()->p($id)->update($update, 'static', 'WHERE id=? LIMIT 1');
         log_add('changed_static', 'admin', $data['url']);
     }
     furl::o()->location($admin_file);
 }
Esempio n. 8
0
 /**
  * Функция проверки прав пользователей, в случае отсутствия прав - посылает на страницу логина
  * @param string $rule право пользователя(!без префикса can_!)
  * @param int $value значение права, от данного и выше.
  * @param int $def 2 - все
  * 1 - все, кроме гостей
  * 0 - все, кроме гостей и пользователей по-умолчанию
  * @return null
  * @throws EngineException
  */
 public function check_perms($rule = '', $value = 1, $def = 1)
 {
     if ($this->check_adminmode()) {
         return;
     }
     $default = $this->perms['guest'] || $this->perms['bot'] ? 2 : $this->perms['default'];
     $if = false;
     if ($rule) {
         $rule = $this->perms['can_' . $rule];
         $if = (int) $rule < (int) $value;
     }
     $if = $if || $default > $def;
     if ($if && $this->perm_exception) {
         throw new EngineException('not_enought_rights');
         if ($this->perm_exception !== 2) {
             $this->perm_exception(0);
         }
     }
     if ($if) {
         if (globals::g("ajax")) {
             print lang::o()->v('not_enought_rights');
         } else {
             furl::o()->location(furl::o()->construct("login", array("ref" => $_SERVER['REQUEST_URI'])));
         }
         die;
     }
 }
Esempio n. 9
0
 /**
  * Сохранение группы
  * @param array $data массив данных группы
  * @param array $fgroup изначальные права группы(для прав пользователя)
  * @return null
  * @throws EngineException 
  */
 public function save($data, $fgroup = null)
 {
     $admin_file = globals::g('admin_file');
     if (!$fgroup) {
         $cols = array('name', 'color', 'pm_count', 'system', 'default', 'bot', 'guest', 'content_count', 'karma_count', 'acp_modules', 'bonus_count');
         if ($data['id']) {
             $id = (int) $data['id'];
         }
         $update = rex($data, $cols);
         if (count($update) != count($cols) || !$update['name'] || !$update['color']) {
             throw new EngineException('groups_invalid_input');
         }
     }
     $r = db::o()->query('SELECT id, perm, allowed, dvalue FROM groups_perm');
     $perms = "";
     while ($row = db::o()->fetch_assoc($r)) {
         $p = 'can_' . $row['perm'];
         $dvalue = $fgroup ? $fgroup[$p] : $row['dvalue'];
         if (isset($data[$p]) && strval((int) $data[$p]) === $data[$p] && $data[$p] <= $row['allowed'] && (int) $data[$p] !== (int) $dvalue) {
             $perms .= ($perms ? ";" : "") . $row['id'] . ":" . $data[$p];
         }
     }
     if ($fgroup) {
         return $perms;
     }
     $update['perms'] = $perms;
     $update['acp_modules'] = implode(';', array_map('trim', (array) $update['acp_modules']));
     try {
         plugins::o()->pass_data(array("update" => &$update, "id" => $id), true)->run_hook('admin_groups_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     if ($id) {
         db::o()->p($id)->update($update, 'groups', 'WHERE id=? LIMIT 1');
         log_add('changed_group', 'admin', $id);
     } else {
         db::o()->insert($update, 'groups');
         log_add('added_group', 'admin');
     }
     db::o()->query('ALTER TABLE `groups` ORDER BY `sort`');
     cache::o()->remove('groups');
     furl::o()->location($admin_file);
 }
Esempio n. 10
0
 function __construct()
 {
     $this->conf = globals::get('config');
 }
Esempio n. 11
0
 /**
  * Функция переадресации
  * @param string $url URL переадресации
  * @param int $time время переадресации
  * @param bool $no_clean не очищать экран и не выполнять функцию die()?
  * @return null
  */
 public function location($url, $time = 0, $no_clean = false)
 {
     $baseurl = globals::g('baseurl');
     if ($this->denied_locations) {
         return;
     }
     if ($this->forlocation && $this->forlocation[1] == $url) {
         $url = $this->forlocation[0];
     }
     if ($time) {
         $no_clean = true;
     }
     if ($no_clean) {
         $contents = ob_get_contents();
     }
     ob_end_clean();
     if (!preg_match("/^http\\:\\/\\/(.*?)\$/siu", $url)) {
         $url = $baseurl . $url;
     }
     if (!$time) {
         @header("Location: " . $url);
     } else {
         @header("Refresh: " . $time . ", url=" . $url);
     }
     if (!$no_clean) {
         die;
     } else {
         print $contents;
     }
 }
Esempio n. 12
0
 /**
  * Инициализация AJAX-части модуля
  * @return null
  */
 public function init()
 {
     $POST = globals::g('POST');
     lang::o()->get('admin/config');
     $cprefix = config_man::config_prefix;
     $cprefix_length = strlen($cprefix);
     $keys = array();
     $newcfg = array();
     $i = 0;
     $sort = array();
     foreach ($POST as $key => $value) {
         if (strpos($key, $cprefix) !== 0) {
             continue;
         }
         $key = substr($key, $cprefix_length);
         if (!config::o()->visset($key)) {
             continue;
         }
         $keys[] = $key;
         $newcfg[$key] = $value;
         $sort[$key] = ++$i;
     }
     if (!$keys) {
         return;
     }
     try {
         plugins::o()->pass_data(array("newcfg" => &$newcfg, "sort" => &$sort), true)->run_hook('admin_config_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     $r = db::o()->p($keys)->query('SELECT name,type,allowed FROM config WHERE name IN(@' . count($keys) . '?)');
     $c = 0;
     while (list($name, $type, $allowed) = db::o()->fetch_row($r)) {
         if (!$this->check_type($type, $newcfg[$name], $allowed, $name)) {
             continue;
         }
         $c++;
         config::o()->set($name, $newcfg[$name], $sort[$name]);
     }
     db::o()->query('ALTER TABLE `config` ORDER BY `cat`, `sort`');
     log_add('changed_config', 'admin');
     print $c;
     die;
 }
Esempio n. 13
0
 /**
  * Модификатор для заголовка контента, добавляющий к нему иконку
  * @param string $title заголовок контента
  * @param string $image имя иконки(типа .png, хранящяяся в engine_images)
  * @param string $text подсказка к иконке
  * @return string заголовок с картинкой
  */
 public function prepend_title_icon($title, $image, $text = "")
 {
     $theme_path = globals::g('theme_path');
     $title = '<img src="' . $theme_path . '/engine_images/' . $image . '.png" alt="' . $text . '"
     title="' . $text . '" align="left">' . $title;
     return $title;
 }
Esempio n. 14
0
 /**
  * Сохранение типов файлов
  * @param array $data массив данных
  * @return null
  * @throws EngineException 
  */
 public function save($data)
 {
     $admin_file = globals::g('admin_file');
     $oname = $data['old_name'];
     $cols = array('name', 'image', 'types', 'MIMES', 'max_filesize', 'max_width', 'max_height', 'makes_preview', 'allowed');
     $update = rex($data, $cols);
     $update['makes_preview'] = (bool) $update['makes_preview'];
     $update['allowed'] = (bool) $update['allowed'];
     $update['max_filesize'] = (int) $update['max_filesize'];
     $update['max_width'] = (int) $update['max_width'];
     $update['max_height'] = (int) $update['max_height'];
     if (!validword($update['name'])) {
         throw new EngineException('allowedft_invalid_name');
     }
     if (!$update['max_filesize']) {
         throw new EngineException('allowedft_invalid_filesize');
     }
     if (!$update['types']) {
         throw new EngineException('allowedft_invalid_types');
     }
     try {
         plugins::o()->pass_data(array("update" => &$update, "oname" => $oname), true)->run_hook('admin_allowedft_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     if ($oname) {
         db::o()->p($oname)->update($update, 'allowed_ft', 'WHERE name=? LIMIT 1');
     } else {
         db::o()->insert($update, 'allowed_ft');
         log_add('added_filetype', 'admin', $update['name']);
     }
     furl::o()->location($admin_file);
 }
Esempio n. 15
0
unset($input);
unset($display);
unset($blocks);
unset($message);
/// Конец
/// Обнаруживаем IE
if (preg_match("/MSIE\\s*([0-9]+)/siu", $_SERVER['HTTP_USER_AGENT'], $matches)) {
    lang::o()->get("ie_error");
    // Выгоняем IE ниже 8 версии
    if ($matches[1] < 8) {
        tpl::o()->display('ie_error.tpl');
        die;
    }
    tpl::o()->assign('MSIE', $matches[1]);
}
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
    if (!empty($_GET)) {
        $_GET = strip_magic_quotes($_GET);
    }
    if (!empty($_POST)) {
        $_POST = strip_magic_quotes($_POST);
    }
    if (!empty($_COOKIE)) {
        $_COOKIE = strip_magic_quotes($_COOKIE);
    }
}
// INCLUDE BACK-END
globals::s('POST', $_POST);
$_POST = xss_array_protect($_POST);
$_GET = xss_array_protect($_GET);
$_REQUEST = $_POST + $_GET;
Esempio n. 16
0
 /**
  * Функция вывода ошибки(именно ошибки типа fatal error, а не сообщения об ошибке,
  * которое выводится через функцию message)
  * @param string|array $lang_var языковая переменная, в соответствии с коорой будет выводится на экран сообщение,
  * либо цельный текст, так же, может содержать в себе все остальные паремтры в качестве ассоциативного массива.
  * @param array $vars массив значений, включаемых в сообщение, работают, блягодаря функции vsprintf
  * @return null
  */
 public function error($lang_var, $vars = array())
 {
     $title = $this->params['title'];
     $this->params = array();
     $ajax = globals::g('ajax');
     ob_end_clean();
     if (!$title && !is_null($title)) {
         $title = lang::o()->v('error');
     } elseif ($title && lang::o()->visset($title)) {
         $title = lang::o()->v($title);
     }
     if (lang::o()->visset($lang_var)) {
         $vars = !is_array($vars) && $vars ? array($vars) : $vars;
         if (is_array($vars)) {
             $message = vsprintf(lang::o()->v($lang_var), $vars);
         } else {
             $message = lang::o()->v($lang_var);
         }
     } else {
         $message = $lang_var;
     }
     if ($ajax) {
         print $title . ": " . $message;
         die;
     }
     tpl::o()->assign('message', $message);
     tpl::o()->assign('title', $title);
     tpl::o()->display("error.tpl");
     die;
 }
Esempio n. 17
0
 /**
  * Установка цвета темы
  * @param string $color имя цвета
  * @return string установленный цвет
  */
 public function set_color($color)
 {
     $vars = $this->init_cfg(null, null);
     $def = strtolower($vars['default_name']);
     $defc = strtolower($vars['color_default']);
     $color = strtolower($color);
     $allowed = strtolower($vars['allowed_colors']);
     if ($color == strtolower($def)) {
         $color_path = "";
     } else {
         if (!checkpos($allowed, $color, "|")) {
             if (checkpos($allowed, $defc, "|")) {
                 $color = $defc;
             } else {
                 return $this->set_color($def);
             }
         }
         if (!validword($color)) {
             $color_path = "";
         } else {
             $color_path = COLORS_PATH . "/" . $color . "/";
         }
     }
     $this->assign('color_path', $color_path);
     globals::s('color_path', $color_path);
     return $color;
 }
Esempio n. 18
0
 * @todo                Магазин плагинов
 *
 * @page 	  	http://ctrev.cyber-tm.ru/
 * @copyright         	(c) 2008-2012, Cyber-Team
 * @author 	  	The Cheat <*****@*****.**>
 * @name 		"Ядро" системы
 * @version           	1.00
 */
if (!defined('INSITE')) {
    die('Remote access denied!');
}
require_once ROOT . 'include/system/allowed.php';
require_once ROOT . 'include/system/globals.php';
require_once ROOT . 'include/system/autoload.php';
require_once ROOT . 'include/functions.php';
globals::s('start', timer());
// Start time
require_once ROOT . 'include/smarty/Smarty.class.php';
require_once ROOT . 'include/functions_smarty.php';
@set_error_handler("myerror_report");
// Присваиваем функцию myerror_report, вместо стандартной, помогает избежать раскрытия путей.
db::o()->connect();
init_baseurl();
lang::o()->change_folder(config::o()->v('default_lang'));
init_spaths();
tpl::o()->register_modifier('lang', array(lang::o(), 'v'));
// языковая переменная
tpl::o()->register_modifier('getlang', array(lang::o(), 'get'));
// подключение языка прямо в шаблоне
tpl::o()->register_modifier('islang', array(lang::o(), 'visset'));
// языковая переменная
Esempio n. 19
0
 /**
  * Сохранение настроек плагина
  * @param array $data массив данных
  * @return null
  * @throws EngineException 
  */
 protected function save($data)
 {
     $admin_file = globals::g('admin_file');
     $id = $data['id'];
     $settings = serialize(modsettings::o()->save($id, $data));
     db::o()->p($id)->update(array('settings' => $settings), 'plugins', 'WHERE file=? LIMIT 1');
     plugins::o()->manager->uncache();
     furl::o()->location($admin_file);
 }
Esempio n. 20
0
/**
 * Выдаёт сообщение о том, что всё хорошо
 * @param bool $print функция print вместо die?
 * @return null
 */
function ok($print = false)
{
    if (globals::g('ok_denied')) {
        return;
    }
    if ($print) {
        print OK_MESSAGE;
    } else {
        die(OK_MESSAGE);
    }
}
Esempio n. 21
0
/**
 * Генератор пароля для шаблонов Smarty
 * @param array $params массив параметров(pname - имя поля пароля, paname - имя поля повтора пароля)
 * @return string HTML код генератора
 */
function smarty_passgen($params)
{
    $theme_path = globals::g('theme_path');
    $name = $params["pname"];
    $name2 = $params["paname"];
    return '<img src="' . $theme_path . 'engine_images/passgen.png" alt="' . lang::o()->v('passgen') . '" class="passgen clickable"
        title="' . lang::o()->v('passgen') . '" onclick="passgen(\'' . addslashes($name) . '\', \'' . addslashes($name2) . '\');">';
}
Esempio n. 22
0
 /**
  * "Ловля" исключений по-умолчанию
  * @param bool $eajax ручная настройка из Ajax или нет
  * @return null 
  */
 public function defaultCatch($eajax = null)
 {
     $ajax = globals::g('ajax');
     $eajax = is_null($eajax) ? $ajax : $eajax;
     if ($eajax) {
         print $this->getEMessage();
         die;
     } else {
         n("message")->stype("error")->sdie()->info($this->getMessage(), $this->getVars());
     }
 }
Esempio n. 23
0
 /**
  * Отправка сообщения с подстановкой переменных
  * @param string|array $email E-mail пользователя
  * @param string $shablon шаблон сообщения
  * @param array $vars массив переменных
  * @return string|int статус отыслки или список ошибок
  */
 public function send_mail($email, $shablon, $vars = array())
 {
     $baseurl = globals::g('baseurl');
     lang::o()->get("mail_shablons");
     $body = lang::o()->v("mail_body_" . $shablon);
     $vars['siteurl'] = $baseurl;
     $vars['sitename'] = $vars['site_title'] = config::o()->v('site_title');
     foreach ($vars as $key => $value) {
         $body = str_replace('$' . $key, $value, $body);
     }
     send_mail(lang::o()->v("mail_subject_" . $shablon), $body, $email, $error);
     return $error;
 }
Esempio n. 24
0
 /**
  * Инициализация AJAX-части модуля
  * @return null
  */
 public function init()
 {
     $POST = globals::g('POST');
     $act = $_GET['act'];
     $name = $_POST['id'];
     if (!validfolder($name, LANGUAGES_PATH)) {
         die;
     }
     switch ($act) {
         case "replace":
             $_POST['search'] = $POST['search'];
             $_POST['with'] = $POST['with'];
             $this->replace($name, $_POST);
             break;
         case "clone":
             $this->copy($name, $_POST['new']);
             break;
         case "delete":
             $this->delete($name);
             break;
         case "delete_file":
             $this->delete_file($name, $_POST['file']);
             break;
         case "default":
             $this->bydefault($name);
             break;
     }
     ok();
 }
Esempio n. 25
0
 /**
  * Сохранение блока
  * @param array $data массив данных блока
  * @return null
  * @throws EngineException 
  */
 public function save($data)
 {
     $admin_file = globals::g('admin_file');
     $cols = array('title', 'file', 'type', 'tpl', 'module', 'group_allowed', 'enabled');
     if ($data['id']) {
         $id = (int) $data['id'];
     }
     $update = rex($data, $cols);
     $update['enabled'] = (bool) $update['enabled'];
     $update['module'] = implode(';', (array) $update['module']);
     $update['group_allowed'] = implode(';', (array) $update['group_allowed']);
     if (!$update['title'] || !$update['file'] || !in_array($update['type'], self::$types)) {
         throw new EngineException('blocks_invalid_input');
     }
     $update['settings'] = serialize(modsettings::o()->change_type('blocks')->save($id, $data));
     try {
         plugins::o()->pass_data(array("update" => &$update, "id" => $id), true)->run_hook('admin_blocks_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     if ($id) {
         db::o()->p($id)->update($update, 'blocks', 'WHERE id=? LIMIT 1');
         log_add('changed_block', 'admin', $id);
     } else {
         db::o()->insert($update, 'blocks');
         log_add('added_block', 'admin');
     }
     db::o()->query('ALTER TABLE `blocks` ORDER BY `pos`');
     cache::o()->remove('blocks');
     furl::o()->location($admin_file);
 }
Esempio n. 26
0
// отложенная инициализация юзерей...
include_once "./include/include.php";
$module = $_GET['module'];
blocks::set_module($module ? $module : "index");
$this_file = globals::g('baseurl') . "index.php?module=" . $module;
tpl::o()->assign("this_file", $this_file);
$ajax = (bool) $_REQUEST['from_ajax'];
// Из AJAX
$nno = (bool) $_REQUEST['nno'];
// Стандартный класс(без постфикса '_ajax')
if (!$ajax && ($current = stats::o()->read(DATABASE_STATS)) != DATABASE_VERSION) {
    /* @var $m message */
    $m = n("message");
    $m->error('need_to_upgrade_database', array(DATABASE_VERSION, $current ? $current : "unknown"));
}
globals::s('ajax', $ajax);
tpl::o()->assign('from_ajax', $ajax);
tpl::o()->assign('module_loaded', $module);
if ($module) {
    if (!allowed::o()->is($module)) {
        die(lang::o()->v('module_not_exists'));
    }
    $mod = plugins::o()->get_module($module, false, $ajax && !$nno);
    if (!$mod) {
        die(lang::o()->v('module_not_exists'));
    }
    plugins::o()->call_init($mod, 'pre_init');
}
users_init();
// ...доседова
if ($module != "login") {
Esempio n. 27
0
 /**
  * Сохранение категории
  * @param array $data массив данных категории
  * @param array $type тип категории
  * @return null
  * @throws EngineException 
  */
 public function save($type, $data)
 {
     $admin_file = globals::g('admin_file');
     $cols = array('parent_id', 'name', 'transl_name', 'descr', 'post_allow', 'pattern');
     if ($data['id']) {
         $id = (int) $data['id'];
     }
     $update = rex($data, $cols);
     $update['type'] = $type;
     if (!$update['name'] || !$update['transl_name']) {
         throw new EngineException("cats_invalid_input");
     }
     if (!validword($update['transl_name'])) {
         throw new EngineException("cats_invalid_transl_name");
     }
     $update['pattern'] = (int) $update['pattern'];
     if (!$this->cats->get($update['parent_id'])) {
         $update['parent_id'] = 0;
     } else {
         $update['parent_id'] = (int) $update['parent_id'];
     }
     $update['post_allow'] = (bool) $update['post_allow'];
     try {
         plugins::o()->pass_data(array("update" => &$update, "id" => $id), true)->run_hook('admin_cats_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     if ($id) {
         db::o()->p($id)->update($update, 'categories', 'WHERE id=? LIMIT 1');
         log_add('changed_cat', 'admin', $id);
     } else {
         db::o()->insert($update, 'categories');
         log_add('added_cat', 'admin');
     }
     db::o()->query('ALTER TABLE `categories` ORDER BY `sort`');
     cache::o()->remove('categories');
     furl::o()->location($admin_file);
 }
Esempio n. 28
0
 /**
  * Сохранение шаблона
  * @param array $data массив данных шаблона
  * @return null
  * @throws EngineException 
  */
 public function save($data)
 {
     $admin_file = globals::g('admin_file');
     $cols = array('name', 'rname', 'type', 'size', 'values', 'html', 'descr', 'formdata');
     if ($data['id']) {
         $id = (int) $data['id'];
     }
     if (!$data['pattern_name']) {
         $data['pattern_name'] = 'tmp' . time();
     }
     // Меньше ошибок - лучше
     $update = array();
     $update['name'] = $data['pattern_name'];
     $pattern = rex($data, $cols);
     $pattern = $this->build_pattern($pattern);
     try {
         plugins::o()->pass_data(array("update" => &$update, "pattern" => &$pattern, "id" => $id), true)->run_hook('admin_patterns_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     $update['pattern'] = serialize($pattern);
     if ($id) {
         db::o()->p($id)->update($update, 'patterns', 'WHERE id=? LIMIT 1');
         cache::o()->remove('patterns/pattern-id' . $id);
         log_add('changed_pattern', 'admin', $id);
     } else {
         db::o()->insert($update, 'patterns');
         log_add('added_pattern', 'admin');
     }
     furl::o()->location($admin_file);
 }
Esempio n. 29
0
 /**
  * Выборка файлов(для АЦ)
  * @param string $path путь к дирректории
  * @param string $name имя дирректории
  * @param string $folder выбранная дирректория
  * @param array $apaths разрешённые дирректории внутри основной
  * @param bool $deny_delete запретить удалять?
  * @return null
  */
 public function filechooser($path, $name, $folder = null, $apaths = null, $deny_delete = false)
 {
     $ajax = globals::g('ajax');
     if (!validfolder($name, $path)) {
         return;
     }
     lang::o()->get('admin/filechooser');
     $npath = ($path ? $path . '/' : '') . $name;
     if ($apaths) {
         $apaths = (array) $apaths;
     }
     if ($folder) {
         $folder = preg_replace('/(?:^|^(.*)\\/)[^\\/]+\\/\\.\\.\\/$/siu', '\\1', $folder);
         $folder = rtrim($folder, '/');
         $folder = validpath($folder . '/', false, $apaths);
         $folder = rtrim($folder, '/');
         if ($folder) {
             $npath .= "/" . rtrim($folder, '/');
         }
     }
     $rows = file::o()->open_folder($npath, false, '^.+(\\.[a-z]+)?$');
     if ($rows === false) {
         return;
     }
     file::o()->sort($npath, $rows);
     $arr = array();
     foreach ($rows as $row) {
         $f = ROOT . $npath . '/' . $row;
         if (!$folder && $apaths && !validpath($row . '/', false, $apaths)) {
             continue;
         }
         if ($row == 'index.html') {
             continue;
         }
         $arr[$row] = array(is_dir($f), is_writable($f), filesize($f), filemtime($f));
     }
     tpl::o()->assign('id', $name);
     tpl::o()->assign('files', $arr);
     tpl::o()->assign('deny_add', false);
     if ($folder) {
         tpl::o()->assign('parent', $folder . '/');
     } elseif ($apaths) {
         tpl::o()->assign('deny_modify', true);
     }
     tpl::o()->assign('deny_delete', (bool) $deny_delete);
     if ($ajax) {
         ok(true);
     }
     tpl::o()->display('admin/filechooser.tpl');
 }
Esempio n. 30
0
users::o()->check_inadmin($module, false, true);
$eadmin_file = globals::g('eadmin_file');
$iadmin_file = $eadmin_file . '&item=' . $item;
tpl::o()->assign("iadmin_file", $iadmin_file);
if ($module) {
    $admin_file = $iadmin_file . '&module=' . $module;
    tpl::o()->assign("admin_file", $admin_file);
    $admin_page = null;
} elseif ($admin_page) {
    $module = $admin_page;
    $allowed = $allowed_admin_pages;
    $plugins_isblock = 2;
    $admin_file = $iadmin_file . '&page=' . $admin_page;
    tpl::o()->assign("admin_file", $admin_file);
}
globals::s('admin_file', $admin_file);
/**
 * Загружаем модуль, или индексную страничку во вкладке
 */
if (!$ajax) {
    tpl::o()->display("admin/header.tpl");
} else {
    db::o()->nt_error();
    tpl::o()->assign("from_ajax", 1);
}
if ($module) {
    if (!allowed::o()->is($module, $allowed)) {
        die(lang::o()->v('module_not_exists'));
    }
    $m = plugins::o()->get_module($module, $plugins_isblock, $ajax && !$nno);
    try {