Merge branch 'master' of https://gitlab.edu.yar.ru/composer/PHP_Library
This commit is contained in:
commit
9b712cf1bc
11 changed files with 114 additions and 19 deletions
|
|
@ -62,6 +62,7 @@ class Controller_Action
|
||||||
|
|
||||||
public function loadConfig($name) {
|
public function loadConfig($name) {
|
||||||
$filename = Shortcut::getUrl('config', $name);
|
$filename = Shortcut::getUrl('config', $name);
|
||||||
|
$settings = [];
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
include($filename);
|
include($filename);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -210,7 +211,8 @@ class Controller_Action
|
||||||
public function nUrl($name, array $param = array())
|
public function nUrl($name, array $param = array())
|
||||||
{
|
{
|
||||||
/*.Filter_ActionAccess.*/$access = $this->access;
|
/*.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 lcurry(array($this, 'postUrl'), $name, $param);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ class Controller_Component
|
||||||
$view->component_title = $settings['title'];
|
$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);
|
$expression = htmlspecialchars_decode($expression);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ class Controller_Installer
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$setup = $this->getSetupFile($name);
|
$setup = $this->getSetupFile($name);
|
||||||
|
|
||||||
if (file_exists($setup) && ($this->isChanged($name) || $force)) {
|
if (file_exists($setup) && ($this->isChanged($name) || $force)) {
|
||||||
$registry = $this->_registry;
|
$registry = $this->_registry;
|
||||||
$settings = new Settings($setup);
|
$settings = new Settings($setup);
|
||||||
|
|
@ -91,20 +92,21 @@ class Controller_Installer
|
||||||
$result[]=$res;
|
$result[]=$res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Обновление версии меню
|
// Обновление версии меню
|
||||||
$registry->removeKey($name);
|
$registry->removeKey($name);
|
||||||
$registry->writeKey(array($name), $settings->get('settings'));
|
$registry->writeKey(array($name), $settings->get('settings'));
|
||||||
$registry->writeKey(array($name),
|
$registry->writeKey(array($name),
|
||||||
array('version' => $version_new,
|
array('version' => $version_new,
|
||||||
'time' => filemtime($setup)));
|
'time' => filemtime($setup)));
|
||||||
|
}
|
||||||
|
|
||||||
$registry->write();
|
$registry->write();
|
||||||
}
|
}
|
||||||
return $result;
|
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 = new Database_JsonInstall($this->db_manager);
|
||||||
$json_installer->install($dbinit_path,$dbfill_path);
|
$json_installer->install($dbinit_path,$dbfill_path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class Database extends PDO
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($dsn['phptype'] == 'pgsql' || $dsn['phptype'] == 'mysql') {
|
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']);
|
/*.Database.*/$connection = new static("{$dsn['phptype']}:host={$dsn['hostspec']}; $port dbname={$dsn['database']}", $dsn['username'], $dsn['password']);
|
||||||
if ($dsn['phptype'] == 'pgsql') {
|
if ($dsn['phptype'] == 'pgsql') {
|
||||||
$connection->query('SET client_encoding="UTF-8"');
|
$connection->query('SET client_encoding="UTF-8"');
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ class Database_JsonInstall {
|
||||||
if (is_string($dbinit_file)) {
|
if (is_string($dbinit_file)) {
|
||||||
$initActions = json_decode($dbinit_file, true);
|
$initActions = json_decode($dbinit_file, true);
|
||||||
if (!$initActions) {
|
if (!$initActions) {
|
||||||
echo "Invalid dbinit.json ".$dbinit_file;
|
echo "Invalid ".$dbinit_path;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "No dbinit.json";
|
echo "No ".$dbinit_path;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ class Filter_Authorization {
|
||||||
}
|
}
|
||||||
$hash = self::getBrowserSign();
|
$hash = self::getBrowserSign();
|
||||||
// Если $hash не совпадает $_SESSION['hash'] то удаляем сессию
|
// Если $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]) {
|
if ($hash == $_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME]) {
|
||||||
// UserAccess::getUserById($_SESSION ['access']); // Поиск по идентификатору
|
// UserAccess::getUserById($_SESSION ['access']); // Поиск по идентификатору
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -25,8 +25,8 @@ class Filter_Authorization {
|
||||||
static function enter($id)
|
static function enter($id)
|
||||||
{
|
{
|
||||||
// $db->executeQuery("UPDATE visitor SET sid = '' WHERE id_visitor = " . $result->getInt('id_user'));
|
// $db->executeQuery("UPDATE visitor SET sid = '' WHERE id_visitor = " . $result->getInt('id_user'));
|
||||||
session_register("access");
|
// session_register("access");
|
||||||
session_register("time");
|
// session_register("time");
|
||||||
|
|
||||||
// $_SESSION ["group"] = $result->getInt('access');
|
// $_SESSION ["group"] = $result->getInt('access');
|
||||||
$_SESSION ["access"] = $id; // id_user
|
$_SESSION ["access"] = $id; // id_user
|
||||||
|
|
|
||||||
|
|
@ -217,9 +217,9 @@ class OptionFactory {
|
||||||
} else if (isset($input['options.db'])) {
|
} else if (isset($input['options.db'])) {
|
||||||
list($table, $keyvalue) = explode(":", $input['options.db']);
|
list($table, $keyvalue) = explode(":", $input['options.db']);
|
||||||
list($key, $value) = explode(",", $keyvalue);
|
list($key, $value) = explode(",", $keyvalue);
|
||||||
try{
|
try {
|
||||||
$query_result = $this->db->executeQuery("SELECT * FROM $table");
|
$query_result = $this->db->executeQuery("SELECT * FROM $table");
|
||||||
}catch(Exception $ex){
|
} catch(Exception $ex) {
|
||||||
$query_result = [];
|
$query_result = [];
|
||||||
}
|
}
|
||||||
$field->options = $this->optionsDB($key, $value, $query_result);
|
$field->options = $this->optionsDB($key, $value, $query_result);
|
||||||
|
|
@ -302,6 +302,7 @@ class Form_Form extends View_View {
|
||||||
'hidden' => 'THidden',
|
'hidden' => 'THidden',
|
||||||
'radio' => 'TSelectOne',
|
'radio' => 'TSelectOne',
|
||||||
'filebrowser' => 'TComponentBrowserInput',
|
'filebrowser' => 'TComponentBrowserInput',
|
||||||
|
'documents' => 'TComponentBrowserInput',
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
90
src/MailAlt.php
Normal file
90
src/MailAlt.php
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class MailAlt
|
||||||
|
{
|
||||||
|
public $mailer;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
$this->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,8 +20,7 @@ class Model_Factory
|
||||||
*/
|
*/
|
||||||
public function getModel ($name)
|
public function getModel ($name)
|
||||||
{
|
{
|
||||||
require_once (Shortcut::getUrl(self::$shortcut, strtolower($name)));
|
$modelName = "Mapper_" . $name;
|
||||||
$modelName = $name . "Mapper";
|
|
||||||
$model = new $modelName();
|
$model = new $modelName();
|
||||||
$model->db = $this->db;
|
$model->db = $this->db;
|
||||||
$model->factory = $this;
|
$model->factory = $this;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ class Validator_Validator
|
||||||
// Список правил
|
// Список правил
|
||||||
if (! isset($value['validate'])) continue;
|
if (! isset($value['validate'])) continue;
|
||||||
$rules = explode("|", $value['validate']);
|
$rules = explode("|", $value['validate']);
|
||||||
|
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
// Список параметров правила
|
// Список параметров правила
|
||||||
$rule_param = explode(",", $rule);
|
$rule_param = explode(",", $rule);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue