From cc33b8f810efef6666693ac2d9de3325d17c2339 Mon Sep 17 00:00:00 2001 From: origami11 Date: Thu, 4 May 2017 15:51:19 +0300 Subject: [PATCH 01/14] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D1=87=D0=BD=D0=BE=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Action.php | 5 +++ src/Database.php | 2 +- src/Model/Factory.php | 33 ++++++++++++++++++++ src/Validator/Rule/IsFile.php | 2 +- src/Validator/Validator.php | 2 +- src/View/Pages.php | 57 +++++++++++++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 src/Model/Factory.php create mode 100644 src/View/Pages.php diff --git a/src/Controller/Action.php b/src/Controller/Action.php index 6e314e2..67b213a 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -372,4 +372,9 @@ class Controller_Action { $this->_getActionPath()->getPath($this, ($action) ? $action : $request->getAction()); } + + function redirect($action) { + header('location: ' . $this->fUrl($action)); + exit(); + } } diff --git a/src/Database.php b/src/Database.php index c4cd264..eb87479 100644 --- a/src/Database.php +++ b/src/Database.php @@ -1,6 +1,6 @@ -require_once "database/pdostatement.php"; +require_once "Database/PDOStatement.php"; /** * Класс оболочка для PDO для замены Creole */ diff --git a/src/Model/Factory.php b/src/Model/Factory.php new file mode 100644 index 0000000..82ec890 --- /dev/null +++ b/src/Model/Factory.php @@ -0,0 +1,33 @@ +db = $db; + $this->_registry = $_registry; + } + + /** + * Создает модель + * @param string $name + * @return model + */ + public function getModel ($name) + { + require_once (Shortcut::getUrl(self::$shortcut, strtolower($name))); + $modelName = $name . "Mapper"; + $model = new $modelName(); + $model->db = $this->db; + $model->factory = $this; + $model->_registry = $this->_registry; + $model->setUp(); + // + return $model; + } +} diff --git a/src/Validator/Rule/IsFile.php b/src/Validator/Rule/IsFile.php index c19cf12..64d5f97 100644 --- a/src/Validator/Rule/IsFile.php +++ b/src/Validator/Rule/IsFile.php @@ -3,7 +3,7 @@ /** * Проверка формата времени */ -class Validator_Rule_IsFile extends Rule_Abstract +class Validator_Rule_IsFile extends Validator_Rule_Abstract { private $type = array(); private $maxsize = 1024; diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index fe3ea2e..06b8213 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -68,7 +68,7 @@ class Validator_Validator } } - public function addRule(/*.any.*/&$rule) { + public function addRule(/*.any.*/$rule) { if (is_array($rule)) { $this->chain = array_merge($this->chain, $rule); } else { diff --git a/src/View/Pages.php b/src/View/Pages.php new file mode 100644 index 0000000..736a861 --- /dev/null +++ b/src/View/Pages.php @@ -0,0 +1,57 @@ + $n) $page = $n; + if ($page < 1) $page = 1; + $url = 'page='; + $result = array(); + for ($i = max($page - self::$range, 1); $i <= min($n, $page + self::$range); $i++) { + $result [] = array('page' => $i, 'href' => ($i != $page) ? self::href($prefix, $url . $i) : false); + } + return array( + 'all' => ($n > 1), + 'list' => $result, + 'first' => self::href($prefix, $url . 1), + 'last' => self::href($prefix, $url . $n), + 'next' => ($page == $n)? false : self::href($prefix, $url . ($page + 1)) , + 'prev' => ($page == 1)? false : self::href($prefix, $url . ($page - 1))); + } + + /** + * @deprecated + * @param $page int номер страницы + * @param $onpage int количество элем на странице + * @return string + */ + static function getLimit(/*.number.*/$page, /*.number.*/$onpage) { + if ($page <= 0) { $page = 1; } + return "LIMIT $onpage OFFSET " . ($page - 1) * $onpage; + } + + /** + * @param $page int номер страницы + * @param $onpage int количество элем на странице + * @return array + */ + static function _getLimit($page, $onpage) { + if ($page <= 0) { $page = 1; } + return array( + 'count' => $onpage, + 'start' => ($page - 1) * $onpage, + ); + } + + static function href($prefix, $x) { + return $prefix . $x; + } + +} + From b3f11fc85f4cd9463a4a59eddae36e3bd1fb4e89 Mon Sep 17 00:00:00 2001 From: origami11 Date: Fri, 12 May 2017 14:13:41 +0300 Subject: [PATCH 02/14] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20action=20=D1=83=20=D0=BA=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 8 +++++++- src/Mail.php | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 0a8220c..5d56d24 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -66,7 +66,13 @@ class Controller_Component function execute(HttpRequest $request, $has_id = true) { $crequest = new ComponentRequest($this->component_id, $request); - $action = 'action' . ucfirst($request->get('action', 'index')); + + $_action = $request->get('action', 'index'); + if (is_array($_action)) { + $action = 'action' . ucfirst(Arr::get($_action, $this->component_id, 'index')); + } else { + $action = 'action' . ucfirst($_action); + } $this->before(); if (method_exists($this, $action)) { diff --git a/src/Mail.php b/src/Mail.php index f27a0a8..1f4eda4 100644 --- a/src/Mail.php +++ b/src/Mail.php @@ -40,6 +40,10 @@ class Mail $this->_to = $name; } + function replyTo($name) // recipient + { + } + /** * Установка получателей копии */ From abd514139f9b01e657b831549d0d16a96cf691a1 Mon Sep 17 00:00:00 2001 From: origami11 Date: Mon, 5 Jun 2017 10:18:28 +0300 Subject: [PATCH 03/14] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Validator/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index fe3ea2e..d838d65 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -61,7 +61,7 @@ class Validator_Validator $ruleObj->$p_name = $p_value; } $this->addRule($ruleObj); - } else { + } else if (!empty($rule)) { throw new Exception('Unknown validation rule "' . $rule . "'"); } } From 785da9007ae76fa88b46c333cfbd3da78a7a26cc Mon Sep 17 00:00:00 2001 From: origami11 Date: Mon, 5 Jun 2017 15:50:19 +0300 Subject: [PATCH 04/14] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=20=D0=BF=D1=83=D1=82=D0=B5=D0=B9=20=D0=BA=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 5d56d24..7115b22 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -318,11 +318,7 @@ class Controller_Component } function addRequireJsPath($name, $path, $shim = null) { - global $requireJsConfig; - $requireJsConfig['paths'][$name] = $path; - if ($shim) { - $requireJsConfig['shim'][$name] = $shim; - } + Controller_Site::addRequireJsPath($name, $path, $shim); } function actionIndex(/*.ComponentRequest.*/ $request) { From 4507f7f9d53b26bcecce945645f25987708f0336 Mon Sep 17 00:00:00 2001 From: origami11 Date: Tue, 6 Jun 2017 10:16:44 +0300 Subject: [PATCH 05/14] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Connection/HttpRequest.php | 2 +- src/Validator/Validator.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Connection/HttpRequest.php b/src/Connection/HttpRequest.php index 28d0515..87a2561 100644 --- a/src/Connection/HttpRequest.php +++ b/src/Connection/HttpRequest.php @@ -81,7 +81,7 @@ class Connection_HttpRequest $port = ($this->proxy_port) ? $this->proxy_port : $this->port; $errno = 0; $errstr = ''; - $socket = fsockopen($host, $port, $errno, $errstr, 30); + $socket = @fsockopen($host, $port, $errno, $errstr, 30); if (is_resource($socket)) { $header = $this->getHeader(); fwrite($socket, $header); diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index fe3ea2e..d838d65 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -61,7 +61,7 @@ class Validator_Validator $ruleObj->$p_name = $p_value; } $this->addRule($ruleObj); - } else { + } else if (!empty($rule)) { throw new Exception('Unknown validation rule "' . $rule . "'"); } } From ebeb72771720a218999cb3cfe97c21573b4fdffd Mon Sep 17 00:00:00 2001 From: origami11 Date: Wed, 7 Jun 2017 13:54:45 +0300 Subject: [PATCH 06/14] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Database.php | 2 +- src/Filter/Authorization.php | 8 ++++---- src/{security.php => Security.php} | 0 3 files changed, 5 insertions(+), 5 deletions(-) rename src/{security.php => Security.php} (100%) 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/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/security.php b/src/Security.php similarity index 100% rename from src/security.php rename to src/Security.php From 7dad5d30ac220faa3039092590c071b2272bd6b0 Mon Sep 17 00:00:00 2001 From: origami11 Date: Thu, 22 Jun 2017 16:08:58 +0300 Subject: [PATCH 07/14] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Action.php | 1 + src/Controller/Component.php | 2 +- src/Form/Form.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Controller/Action.php b/src/Controller/Action.php index 67b213a..9c72537 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 { diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 5d56d24..cbb5514 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/Form/Form.php b/src/Form/Form.php index 585f06a..3ea0a59 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); From a48bce855265b36a4ad0b11d0799bc3731fb7b8d Mon Sep 17 00:00:00 2001 From: origami11 Date: Thu, 22 Jun 2017 16:11:08 +0300 Subject: [PATCH 08/14] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/Factory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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; From dd08a235c0abfd681390cec191cd16056ecda797 Mon Sep 17 00:00:00 2001 From: origami11 Date: Fri, 23 Jun 2017 15:51:38 +0300 Subject: [PATCH 09/14] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D1=89?= =?UTF-8?q?=D0=B8=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B0=D0=B9=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Installer.php | 14 ++++++++------ src/Database/JsonInstall.php | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) 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/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; } From a3c988b2c3f12436f37f72206a98141a5c9f8ece Mon Sep 17 00:00:00 2001 From: origami11 Date: Tue, 25 Jul 2017 11:02:11 +0300 Subject: [PATCH 10/14] =?UTF-8?q?=D0=91=D0=B0=D0=B3=20=D1=81=20=D0=BE?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B0.=20=D0=90?= =?UTF-8?q?=D0=BB=D1=8C=D1=82=D0=B5=D1=80=D0=BD=D0=B0=D1=82=D0=B8=D0=B2?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D0=BF=D0=BE=D1=87=D1=82=D0=B0.=20=D0=92?= =?UTF-8?q?=D1=8B=D0=B1=D0=BE=D1=80=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Action.php | 3 +- src/Form/Form.php | 1 + src/MailAlt.php | 90 +++++++++++++++++++++++++++++++++++++ src/Validator/Validator.php | 1 + 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/MailAlt.php diff --git a/src/Controller/Action.php b/src/Controller/Action.php index 9c72537..9d5753f 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -211,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/Form/Form.php b/src/Form/Form.php index 3ea0a59..f0e6922 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -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/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); From e46867b1348cd22659315da34fd1405c0b89e75b Mon Sep 17 00:00:00 2001 From: origami11 Date: Mon, 2 Oct 2017 14:16:49 +0300 Subject: [PATCH 11/14] =?UTF-8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=B5=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Excel/Document.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Excel/Document.php b/src/Excel/Document.php index e46ff31..365dba3 100644 --- a/src/Excel/Document.php +++ b/src/Excel/Document.php @@ -76,7 +76,9 @@ class Excel_Document { function save($filename) { $doc = new XMLWriter(); - $doc->openURI($filename); + if (!$doc->openURI($filename)) { + throw new Exception("unknown file " . $filename); + } $doc->setIndent(false); $doc->startDocument('1.0','utf-8'); $doc->startElement('Workbook'); From 32510683954d97d043ce77666f2ae3dd0ee06c5e Mon Sep 17 00:00:00 2001 From: origami11 Date: Mon, 2 Oct 2017 14:19:11 +0300 Subject: [PATCH 12/14] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Validator/Rule/Code.php | 2 +- src/Validator/Rule/Count.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Validator/Rule/Code.php b/src/Validator/Rule/Code.php index 54514e2..2bcfbf8 100644 --- a/src/Validator/Rule/Code.php +++ b/src/Validator/Rule/Code.php @@ -3,7 +3,7 @@ /** * Проверка формата электронной почты */ -class Validator_Rule_Code extends Rule_Abstract +class Validator_Rule_Code extends Validator_Rule_Abstract { public function getErrorMsg() { diff --git a/src/Validator/Rule/Count.php b/src/Validator/Rule/Count.php index f8c1800..2afd612 100644 --- a/src/Validator/Rule/Count.php +++ b/src/Validator/Rule/Count.php @@ -3,7 +3,7 @@ /** * Проверка формата даты */ -class Validator_Rule_Count extends Rule_Abstract +class Validator_Rule_Count extends Validator_Rule_Abstract { public $size = 1; public $max = false; From c680b8c3227462d7c25d4ef59a9db0d23f7f084b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=91=D0=B4=D0=BE=D1=80=20=D0=9F=D0=BE=D0=B4=D0=BB?= =?UTF-8?q?=D0=B5=D1=81=D0=BD=D0=BE=D0=B2?= Date: Fri, 24 Nov 2017 15:32:03 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D1=85.=20=D0=90=D0=BB=D1=8C=D1=82=D0=B5=D1=80=D0=BD=D0=B0?= =?UTF-8?q?=D1=82=D0=B8=D0=B2=D0=BD=D0=B0=D1=8F=20=D0=BF=D0=BE=D1=87=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 13 +----- src/Controller/Installer.php | 8 ++-- src/Form/Form.php | 1 + src/MailAlt.php | 89 ++++++++++++++++++++++++++++++++++++ src/Validator/Validator.php | 1 + 5 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 src/MailAlt.php diff --git a/src/Controller/Component.php b/src/Controller/Component.php index e1ab83c..99ca77c 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -131,14 +131,6 @@ class Controller_Component return Path::join($this->webPath[0], 'templates', 'modern'); } - /** - * @param $name Имя модели - */ - private function getModelPath($name) - { - return Path::join (CMS_PATH, "model", $name . ".php"); - } - /** * Создает модель * @param string $name @@ -146,9 +138,8 @@ class Controller_Component */ public function getModel($name) { - require_once ($this->getModelPath ($name)); - $modelName = $name . "Mapper"; - $model = new $modelName (); + $modelName = "Mapper_" . $name; + $model = new $modelName(); $model->db = $this->db; return $model; } diff --git a/src/Controller/Installer.php b/src/Controller/Installer.php index dcc4562..f7f5147 100644 --- a/src/Controller/Installer.php +++ b/src/Controller/Installer.php @@ -48,7 +48,7 @@ class Controller_Installer foreach ($sql as $version => $install) { if (version_compare($version, $version_new, "<=") && version_compare($version, $version_old, ">")) { $file = Path::join(call_user_func($this->installPath, $name), "sql", $install); - $json_installer->install($file,null); + $json_installer->install($file, null); $result[] = $version; } } @@ -64,6 +64,7 @@ class Controller_Installer $this->_registry->removeKey($name); $this->_registry->write(); } + // Устанавливает обновления если есть function doUpdates($name, $force = false) // Установка модуля { @@ -83,6 +84,7 @@ class Controller_Installer $version_old = "0.0"; $registry->writeKey(array($name), array()); } +// echo $version_old, $settings->get('version'); if (version_compare($version_old, $settings->get('version'), "!=")) { $sql = $settings->get('sql'); if (is_array($sql)) { @@ -104,8 +106,8 @@ class Controller_Installer 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); + $json_installer->install($dbinit_path, $dbfill_path); } } diff --git a/src/Form/Form.php b/src/Form/Form.php index 3ea0a59..f0e6922 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -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..43160cf --- /dev/null +++ b/src/MailAlt.php @@ -0,0 +1,89 @@ +mailer = new PHPMailer(); + } + + /** + * Установка отправителя + */ + 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/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); From 5c421805bf1cf53f168a28d8dd2864318bade708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=91=D0=B4=D0=BE=D1=80=20=D0=9F=D0=BE=D0=B4=D0=BB?= =?UTF-8?q?=D0=B5=D1=81=D0=BD=D0=BE=D0=B2?= Date: Tue, 5 Dec 2017 14:04:16 +0300 Subject: [PATCH 14/14] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 4 +++- src/Controller/Installer.php | 1 - src/Filter/Authorization.php | 10 +++++----- src/Form/Form.php | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 99ca77c..f698f50 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -112,7 +112,9 @@ class Controller_Component $tpl->set('common', Path::join(WWW_PATH, '../', 'common')); $tpl->set('script', Path::join(WWW_PATH, 'js')); $tpl->set('media', Path::join(TEMPLATE_WEB, $template)); - $tpl->set('site_template', SITE_WWW_PATH . '/templates' . $registry->readKey(array('system', 'template'))); + if ($registry) { + $tpl->set('site_template', SITE_WWW_PATH . '/templates' . $registry->readKey(array('system', 'template'))); + } $tpl->set('base', SITE_WWW_PATH); $tpl->set('component_base', $this->webPath[$selected]); diff --git a/src/Controller/Installer.php b/src/Controller/Installer.php index 0b4a6ce..d20a93d 100644 --- a/src/Controller/Installer.php +++ b/src/Controller/Installer.php @@ -85,7 +85,6 @@ class Controller_Installer $version_old = "0.0"; $registry->writeKey(array($name), array()); } -// echo $version_old, $settings->get('version'); if (version_compare($version_old, $settings->get('version'), "!=")) { $sql = $settings->get('sql'); if (is_array($sql)) { diff --git a/src/Filter/Authorization.php b/src/Filter/Authorization.php index 2666465..5afd556 100644 --- a/src/Filter/Authorization.php +++ b/src/Filter/Authorization.php @@ -4,14 +4,14 @@ class Filter_Authorization { const SESSION_BROWSER_SIGN_SECRET = '@w3dsju45Msk#'; const SESSION_BROWSER_SIGN_KEYNAME = 'session.app.browser.sign'; - static function isLogged() { + static function isLogged($group = 'access') { +// echo session_status(); if (session_status() == PHP_SESSION_NONE) { session_start(); } $hash = self::getBrowserSign(); // Если $hash не совпадает $_SESSION['hash'] то удаляем сессию -// print_r($_SESSION); - if (isset($_SESSION['access']) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { + if (isset($_SESSION[$group]) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { if ($hash == $_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME]) { // UserAccess::getUserById($_SESSION ['access']); // Поиск по идентификатору return true; @@ -22,14 +22,14 @@ class Filter_Authorization { return false; } - static function enter($id) + static function enter($id, $group = 'access') { // $db->executeQuery("UPDATE visitor SET sid = '' WHERE id_visitor = " . $result->getInt('id_user')); // session_register("access"); // session_register("time"); // $_SESSION ["group"] = $result->getInt('access'); - $_SESSION ["access"] = $id; // id_user + $_SESSION [$group] = $id; // id_user $_SESSION [self::SESSION_BROWSER_SIGN_KEYNAME] = self::getBrowserSign(); $_SESSION ["time"] = time(); } diff --git a/src/Form/Form.php b/src/Form/Form.php index f0e6922..f79c9f3 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -288,7 +288,7 @@ class Form_Form extends View_View { 'color' => 'TColor', 'textarea' => 'TTextArea', - 'text' => 'TTextArea', + 'text' => 'TTextArea', 'multiselect' => 'TSelectMany', // 'selectmany' => 'TSelectMany', 'select1' => 'TSelectOne',