Merge branch 'master' of http://gitlab.edu.yar.ru/composer/PHP_Library
# Conflicts: # src/Filter/Login.php # src/View/Page.php
This commit is contained in:
commit
1660f8fa06
10 changed files with 56 additions and 27 deletions
|
|
@ -23,7 +23,8 @@ class ComponentRequest {
|
||||||
if ($key == 'active_page') {
|
if ($key == 'active_page') {
|
||||||
return $this->r->get($key);
|
return $this->r->get($key);
|
||||||
}
|
}
|
||||||
if ($arr = $this->r->get($key)) {
|
$arr = $this->r->get($key);
|
||||||
|
if ($arr !== NULL) {
|
||||||
if (is_array($arr)) {
|
if (is_array($arr)) {
|
||||||
return Arr::get($arr, $this->component_id, $default);
|
return Arr::get($arr, $this->component_id, $default);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -273,7 +274,7 @@ class Controller_Component
|
||||||
$instance->componentsConfig[] = $editor;
|
$instance->componentsConfig[] = $editor;
|
||||||
} else {
|
} else {
|
||||||
global $componentsConfig;
|
global $componentsConfig;
|
||||||
$componentsConfig[] = $editor;
|
$componentsConfig[] = $editor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,14 @@
|
||||||
*/
|
*/
|
||||||
class Controller_Service
|
class Controller_Service
|
||||||
{
|
{
|
||||||
public $viewPath = array();
|
public $viewPath = [];
|
||||||
|
public $webPath = [];
|
||||||
public $registry; // Registry->getInstance
|
public $registry; // Registry->getInstance
|
||||||
public $template;
|
public $template;
|
||||||
public $templatePath;
|
public $templatePath;
|
||||||
public $COMPONENTS_WEB;
|
public $COMPONENTS_WEB;
|
||||||
|
|
||||||
|
public $db;
|
||||||
|
|
||||||
public function getTemplatePath($name)
|
public function getTemplatePath($name)
|
||||||
{
|
{
|
||||||
|
|
@ -58,5 +61,14 @@ class Controller_Service
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getInfo() {
|
||||||
|
$filename = Path::join($this->viewPath[0], 'install.json');
|
||||||
|
if (file_exists($filename)) {
|
||||||
|
$settings = json_decode(File::getContents($filename), true);
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,14 @@ class Database extends PDO
|
||||||
{
|
{
|
||||||
parent::__construct($dsn, $username, $password);
|
parent::__construct($dsn, $username, $password);
|
||||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||||
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Database_PDOStatement', array()));
|
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Database_PDOStatement', array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepare($sql, $args = []) {
|
||||||
|
$result = parent::prepare($sql, $args);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDSN()
|
public function getDSN()
|
||||||
{
|
{
|
||||||
|
|
@ -35,6 +41,10 @@ class Database extends PDO
|
||||||
if ($dsn['phptype'] == 'pgsql') {
|
if ($dsn['phptype'] == 'pgsql') {
|
||||||
$connection->query('SET client_encoding="UTF-8"');
|
$connection->query('SET client_encoding="UTF-8"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($dsn['schema'])) {
|
||||||
|
$connection->query('SET search_path TO ' . $dsn['schema']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($dsn['phptype'] == 'sqlite') {
|
if ($dsn['phptype'] == 'sqlite') {
|
||||||
/*.Database.*/$connection = new static("{$dsn['phptype']}:{$dsn['database']}");
|
/*.Database.*/$connection = new static("{$dsn['phptype']}:{$dsn['database']}");
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ class Database_PDOStatement extends PDOStatement implements IteratorAggregate
|
||||||
}
|
}
|
||||||
|
|
||||||
function getString($name) {
|
function getString($name) {
|
||||||
return $this->fields[$name];
|
return isset($this->fields[$name]) ? $this->fields[$name]: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBoolean($name) {
|
function getBoolean($name) {
|
||||||
|
|
@ -92,4 +92,10 @@ class Database_PDOStatement extends PDOStatement implements IteratorAggregate
|
||||||
function getRecordCount() {
|
function getRecordCount() {
|
||||||
return count($this->cache);
|
return count($this->cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function execute($args = null) {
|
||||||
|
$result = parent::execute($args);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,33 +17,27 @@ class Database_Statement
|
||||||
$this->conn = $conn;
|
$this->conn = $conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setInt($n, $value)
|
function setInt($n, $value) {
|
||||||
{
|
|
||||||
$this->binds [] = array($n, $value, PDO::PARAM_INT);
|
$this->binds [] = array($n, $value, PDO::PARAM_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setString($n, $value)
|
function setString($n, $value) {
|
||||||
{
|
|
||||||
$this->binds [] = array($n, $value, PDO::PARAM_STR);
|
$this->binds [] = array($n, $value, PDO::PARAM_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBlob($n, $value)
|
function setBlob($n, $value) {
|
||||||
{
|
|
||||||
$this->binds [] = array($n, $value, PDO::PARAM_LOB);
|
$this->binds [] = array($n, $value, PDO::PARAM_LOB);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLimit($limit)
|
function setLimit($limit) {
|
||||||
{
|
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOffset($offset)
|
function setOffset($offset) {
|
||||||
{
|
|
||||||
$this->offset = $offset;
|
$this->offset = $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeQuery()
|
function executeQuery() {
|
||||||
{
|
|
||||||
if ($this->limit) {
|
if ($this->limit) {
|
||||||
$this->query .= " LIMIT {$this->limit} OFFSET {$this->offset}";
|
$this->query .= " LIMIT {$this->limit} OFFSET {$this->offset}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class Excel_Number
|
||||||
|
|
||||||
function __construct($value)
|
function __construct($value)
|
||||||
{
|
{
|
||||||
$this->value = intval($value);
|
$this->value = (int)($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getString()
|
function getString()
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,18 @@ class Filter_Login extends Filter_Filter
|
||||||
const SESSION_BROWSER_SIGN_SECRET = '@w3dsju45Msk#';
|
const SESSION_BROWSER_SIGN_SECRET = '@w3dsju45Msk#';
|
||||||
const SESSION_BROWSER_SIGN_KEYNAME = 'session.app.browser.sign';
|
const SESSION_BROWSER_SIGN_KEYNAME = 'session.app.browser.sign';
|
||||||
public $mode = 'ajax';
|
public $mode = 'ajax';
|
||||||
|
public $user;
|
||||||
|
|
||||||
//AJAX-Реквесты для которых не требуется авторизация, потребовалось для сбора статистики
|
//AJAX-Реквесты для которых не требуется авторизация, потребовалось для сбора статистики
|
||||||
public $whiteRequestList = [['module' => "requiredcontent", "action" => "getcount"],
|
public $whiteRequestList = [
|
||||||
['module' => "requiredcontent", "action" => "teststructure"],
|
['module' => "requiredcontent", "action" => "getcount"],
|
||||||
['module' => "requiredcontent", "action" => "specialdump"],
|
['module' => "requiredcontent", "action" => "teststructure"],
|
||||||
['module' => "requiredcontent", "action" => "OrgMonitoringSchema"]
|
['module' => "requiredcontent", "action" => "specialdump"],
|
||||||
];
|
['module' => "requiredcontent", "action" => "OrgMonitoring"],
|
||||||
|
['module' => "requiredcontent", "action" => "OrgMonitoringSchema"],
|
||||||
|
['module' => "appeals", "action" => "changestatus"],
|
||||||
|
['module' => "appeals", "action" => "savestatus"]
|
||||||
|
];
|
||||||
/**
|
/**
|
||||||
* Проверка авторизации
|
* Проверка авторизации
|
||||||
* @return Boolean Авторизовани пользователь или нет
|
* @return Boolean Авторизовани пользователь или нет
|
||||||
|
|
@ -30,6 +35,7 @@ class Filter_Login extends Filter_Filter
|
||||||
session_start();
|
session_start();
|
||||||
$db = $this->getConnection();
|
$db = $this->getConnection();
|
||||||
Filter_UserAccess::setUp($db); // Соединение
|
Filter_UserAccess::setUp($db); // Соединение
|
||||||
|
|
||||||
switch ($request->getAction()) {
|
switch ($request->getAction()) {
|
||||||
// Авторизация по постоянному паролю
|
// Авторизация по постоянному паролю
|
||||||
case 'login':
|
case 'login':
|
||||||
|
|
@ -52,10 +58,9 @@ class Filter_Login extends Filter_Filter
|
||||||
if (md5($password) == $userPassword) { // password
|
if (md5($password) == $userPassword) { // password
|
||||||
$this->enter($db, $result);
|
$this->enter($db, $result);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
$request->set('error', true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$request->set('error', true);
|
||||||
break;
|
break;
|
||||||
case 'logout': // Выход
|
case 'logout': // Выход
|
||||||
session_destroy();
|
session_destroy();
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class Filter_UserAccess
|
||||||
$time = time();
|
$time = time();
|
||||||
if ($time - $lasttime > self::LIFE_TIME) return null; // Вышло время сессии
|
if ($time - $lasttime > self::LIFE_TIME) return null; // Вышло время сессии
|
||||||
$id = self::$id;
|
$id = self::$id;
|
||||||
self::$db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время последнего обращения входа
|
// self::$db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время последнего обращения входа
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ class Tools_TemplateImage
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value->valign[0]) {
|
if ($value->valign[0]) {
|
||||||
$valign = Drawing::ALIGN_TOP;
|
$valign = Tools_Drawing::ALIGN_TOP;
|
||||||
} elseif ($value->valign[1]) {
|
} elseif ($value->valign[1]) {
|
||||||
$valign = Tools_Drawing::ALIGN_CENTER;
|
$valign = Tools_Drawing::ALIGN_CENTER;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class Validator_Rule_Date extends Validator_Rule_Abstract
|
||||||
public function isValid(Collection $container, $status = null)
|
public function isValid(Collection $container, $status = null)
|
||||||
{
|
{
|
||||||
$pattern = "/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/";
|
$pattern = "/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/";
|
||||||
|
$matches = [];
|
||||||
return (preg_match($pattern, $container->get($this->field), $matches)
|
return (preg_match($pattern, $container->get($this->field), $matches)
|
||||||
&& checkdate($matches[2], $matches[1], $matches[3]));
|
&& checkdate($matches[2], $matches[1], $matches[3]));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue