diff --git a/src/Controller/Action.php b/src/Controller/Action.php index 67b213a..9d5753f 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -62,6 +62,7 @@ class Controller_Action public function loadConfig($name) { $filename = Shortcut::getUrl('config', $name); + $settings = []; if (file_exists($filename)) { include($filename); } else { @@ -210,7 +211,8 @@ class Controller_Action public function nUrl($name, array $param = array()) { /*.Filter_ActionAccess.*/$access = $this->access; - if ($access != null || $access->checkAction($name)) { + + if ($access == null || $access->checkAction($name)) { return lcurry(array($this, 'postUrl'), $name, $param); } return null; diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 7115b22..e1ab83c 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -194,7 +194,7 @@ class Controller_Component $view->component_title = $settings['title']; } - static function loadComponent($expression, Database $db, Settings $registry) + static function loadComponent($expression, Database $db, /*.Settings.*/ $registry) { $expression = htmlspecialchars_decode($expression); diff --git a/src/Controller/Installer.php b/src/Controller/Installer.php index dcc4562..2c17f9a 100644 --- a/src/Controller/Installer.php +++ b/src/Controller/Installer.php @@ -69,6 +69,7 @@ class Controller_Installer { $result = array(); $setup = $this->getSetupFile($name); + if (file_exists($setup) && ($this->isChanged($name) || $force)) { $registry = $this->_registry; $settings = new Settings($setup); @@ -91,20 +92,21 @@ class Controller_Installer $result[]=$res; } } - } - // Обновление версии меню - $registry->removeKey($name); - $registry->writeKey(array($name), $settings->get('settings')); - $registry->writeKey(array($name), + // Обновление версии меню + $registry->removeKey($name); + $registry->writeKey(array($name), $settings->get('settings')); + $registry->writeKey(array($name), array('version' => $version_new, 'time' => filemtime($setup))); + } + $registry->write(); } return $result; } - function install($dbinit_path,$dbfill_path=null){ + function install($dbinit_path, $dbfill_path = null) { $json_installer = new Database_JsonInstall($this->db_manager); $json_installer->install($dbinit_path,$dbfill_path); } diff --git a/src/Database.php b/src/Database.php index 0d8813e..2ddc1f4 100644 --- a/src/Database.php +++ b/src/Database.php @@ -29,7 +29,7 @@ class Database extends PDO { if ($dsn['phptype'] == 'pgsql' || $dsn['phptype'] == 'mysql') { - $port = (isset($dsn['port'])) ? "port={$dsn['port']};" : ""; + $port = (isset($dsn['port'])) ? "port={$dsn['port']};" : ""; /*.Database.*/$connection = new static("{$dsn['phptype']}:host={$dsn['hostspec']}; $port dbname={$dsn['database']}", $dsn['username'], $dsn['password']); if ($dsn['phptype'] == 'pgsql') { $connection->query('SET client_encoding="UTF-8"'); diff --git a/src/Database/JsonInstall.php b/src/Database/JsonInstall.php index ee62cf3..54a7d6f 100644 --- a/src/Database/JsonInstall.php +++ b/src/Database/JsonInstall.php @@ -14,11 +14,11 @@ class Database_JsonInstall { if (is_string($dbinit_file)) { $initActions = json_decode($dbinit_file, true); if (!$initActions) { - echo "Invalid dbinit.json ".$dbinit_file; + echo "Invalid ".$dbinit_path; return 0; } } else { - echo "No dbinit.json"; + echo "No ".$dbinit_path; return 0; } diff --git a/src/Filter/Authorization.php b/src/Filter/Authorization.php index 17db6a6..2666465 100644 --- a/src/Filter/Authorization.php +++ b/src/Filter/Authorization.php @@ -10,8 +10,8 @@ class Filter_Authorization { } $hash = self::getBrowserSign(); // Если $hash не совпадает $_SESSION['hash'] то удаляем сессию - if (isset($_SESSION ['access']) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { - +// print_r($_SESSION); + if (isset($_SESSION['access']) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { if ($hash == $_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME]) { // UserAccess::getUserById($_SESSION ['access']); // Поиск по идентификатору return true; @@ -25,8 +25,8 @@ class Filter_Authorization { static function enter($id) { // $db->executeQuery("UPDATE visitor SET sid = '' WHERE id_visitor = " . $result->getInt('id_user')); - session_register("access"); - session_register("time"); +// session_register("access"); +// session_register("time"); // $_SESSION ["group"] = $result->getInt('access'); $_SESSION ["access"] = $id; // id_user diff --git a/src/Form/Form.php b/src/Form/Form.php index 585f06a..f0e6922 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -217,9 +217,9 @@ class OptionFactory { } else if (isset($input['options.db'])) { list($table, $keyvalue) = explode(":", $input['options.db']); list($key, $value) = explode(",", $keyvalue); - try{ + try { $query_result = $this->db->executeQuery("SELECT * FROM $table"); - }catch(Exception $ex){ + } catch(Exception $ex) { $query_result = []; } $field->options = $this->optionsDB($key, $value, $query_result); @@ -302,6 +302,7 @@ class Form_Form extends View_View { 'hidden' => 'THidden', 'radio' => 'TSelectOne', 'filebrowser' => 'TComponentBrowserInput', + 'documents' => 'TComponentBrowserInput', ); } diff --git a/src/MailAlt.php b/src/MailAlt.php new file mode 100644 index 0000000..f8761f6 --- /dev/null +++ b/src/MailAlt.php @@ -0,0 +1,90 @@ +mailer = new PHPMailer(); + $this->mailer->CharSet = 'UTF-8'; + } + + /** + * Установка отправителя + */ + function from($name) + { + $this->mailer->setFrom($name); + } + + /** + * Установка получателя + */ + function to($name) // recipient + { + $this->mailer->addAddress($name); + } + + function replyTo($name) // recipient + { + $this->mailer->AddReplyTo($name); + } + + /** + * Установка получателей копии + */ + function copy($name) // recipient cc + { + $this->addCC($name); + } + + function notify($notify) + { + $this->_notify = $notify; + } + + /** + * Тема письма + */ + function subject($subject) + { + $this->mailer->Subject = $subject; + } + + /** + * Текст письма + */ + function setContent($text) + { + $this->mailer->Body = $text; + } + + function setType($text) + { + $this->mailer->isHTML($text == 'text/html'); + } + + /** + * Кодировка текста в письме + */ + function setEncoding($encoding) + { + $this->encoding = $encoding; + } + + /** + * Добавление вложения из файла + */ + function addAttachment($filename, $name = false) + { + $this->mailer->addAttachment($filename, $name); + } + + /** + * Отправка почты + */ + function send() + { + return $this->mailer->send(); + } +} diff --git a/src/Model/Factory.php b/src/Model/Factory.php index 82ec890..30ceb8c 100644 --- a/src/Model/Factory.php +++ b/src/Model/Factory.php @@ -20,8 +20,7 @@ class Model_Factory */ public function getModel ($name) { - require_once (Shortcut::getUrl(self::$shortcut, strtolower($name))); - $modelName = $name . "Mapper"; + $modelName = "Mapper_" . $name; $model = new $modelName(); $model->db = $this->db; $model->factory = $this; diff --git a/src/security.php b/src/Security.php similarity index 100% rename from src/security.php rename to src/Security.php diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index 5a3bc4c..c429efe 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -44,6 +44,7 @@ class Validator_Validator // Список правил if (! isset($value['validate'])) continue; $rules = explode("|", $value['validate']); + foreach ($rules as $rule) { // Список параметров правила $rule_param = explode(",", $rule);