Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c15ce2ed0 | ||
|
|
b4f506cc1f | ||
|
|
c54cb5f9e1 | ||
|
|
8cb0b860ea | ||
|
|
0146815e2d | ||
|
|
9708ec5419 | ||
|
|
12ee13c3d1 | ||
|
|
890d9b8e0d | ||
|
|
3f9dc5cd0b | ||
|
|
f6d6a88332 | ||
|
|
7c99505d9b | ||
|
|
0196d50ede | ||
|
|
f12c463c7a | ||
|
|
e740b13654 | ||
|
|
9cf87af0f7 | ||
|
|
0bf6f25a88 | ||
|
|
198b088727 |
No files matched your search
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Smartphone (please complete the following information):**
|
||||||
|
- Device: [e.g. iPhone6]
|
||||||
|
- OS: [e.g. iOS8.1]
|
||||||
|
- Browser [e.g. stock browser, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
name: Psalm Security Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ "main" ]
|
||||||
|
schedule:
|
||||||
|
- cron: '33 7 * * 6'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
php-security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read # for actions/checkout to fetch code
|
||||||
|
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
|
||||||
|
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Psalm Security Scan
|
||||||
|
uses: psalm/psalm-github-security-scan@f3e6fd9432bc3e44aec078572677ce9d2ef9c287
|
||||||
|
|
||||||
|
- name: Upload Security Analysis results to GitHub
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: results.sarif
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or
|
||||||
|
advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email
|
||||||
|
address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
e-mail rsgrinko@gmail.com.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.0, available at
|
||||||
|
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
https://www.contributor-covenant.org/faq. Translations are available at
|
||||||
|
https://www.contributor-covenant.org/translations.
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
# Delta Framework
|
# Delta Framework
|
||||||
|

|
||||||
|

|
||||||
## Описание
|
## Описание
|
||||||
Delta Framework - простой фреймворк для разработки веб-проектов. Его разработка была начата в свободное от работы время и выполнялась полность в свое удовольствие.
|
Delta Framework - простой фреймворк для разработки веб-проектов. Его разработка была начата в свободное от работы время и выполнялась полностью в свое удовольствие.
|
||||||
На текущий момент в нем имеется:
|
На текущий момент в нем имеется:
|
||||||
|
|
||||||
- [X] Авторизация
|
- [X] Авторизация
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Политика безопасности
|
||||||
|
|
||||||
|
Безопасность очень важна для данного проекта. Если вы обнаружите какие-либо проблемы, связанные с безопасностью - сообщите, отправив электронное письмо по адресу `rsgrinko@gmail.com`, указав в теме `Delta: Безопасность`.
|
||||||
|
Мы быстро отреагируем и исправим найденые проблемы безопасности.
|
||||||
|
|
||||||
|
> Пожалуйста, не проводите исследования, которые могут повлиять на других пользователей. Также, пожалуйста, делайте отчеты краткими и емкими. Если нам не удастся понять логику вашей ошибки - мы вам сообщим.
|
||||||
|
|
||||||
|
Delta Framerork — это проект с открытым исходным кодом, имеющий лицензию MIT, который можно использовать бесплатно и в коммерческих целях. Мы приветствуем все исправления, направленные на повышение безопасности, по электронной почте на адрес `rsgrinko@gmail.com`.
|
||||||
+2
-1
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
use Core\Helpers\Pagination;
|
use Core\Helpers\Pagination;
|
||||||
use Core\ExternalServices\RemoteHosts;
|
use Core\ExternalServices\RemoteHosts;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
Pagination::execute($_REQUEST['page'], RemoteHosts::getAllCount(), PAGINATION_LIMIT);
|
Pagination::execute($_REQUEST['page'], RemoteHosts::getAllCount(), SystemConfig::getValue('PAGINATION_LIMIT'));
|
||||||
$limit = Pagination::getLimit();
|
$limit = Pagination::getLimit();
|
||||||
|
|
||||||
$arHosts = RemoteHosts::getHosts($limit);
|
$arHosts = RemoteHosts::getHosts($limit);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
|
|
||||||
<title>Delta - CPanel</title>
|
<title>Delta - CPanel<?= isset($pageTitle) ? ' | ' . $pageTitle : '' ?></title>
|
||||||
|
|
||||||
<link href="//<?= $_SERVER['SERVER_NAME']; ?>/admin/styles/css/style.default.css" rel="stylesheet">
|
<link href="//<?= $_SERVER['SERVER_NAME']; ?>/admin/styles/css/style.default.css" rel="stylesheet">
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
@@ -59,11 +59,14 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
}
|
}
|
||||||
|
.telegramAuthButtonBox {
|
||||||
|
margin-top: 20px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<div class="headerwrapper">
|
<div class="headerwrapper">
|
||||||
<div class="header-left">
|
<div class="header-left">
|
||||||
|
|||||||
+4
-2
@@ -20,7 +20,9 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Core\Helpers\Cache;use Core\Helpers\Files;use Core\Models\{User, Roles};
|
use Core\Helpers\Cache;use Core\Helpers\Files;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
use Core\Models\{User, Roles};
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
?>
|
?>
|
||||||
@@ -96,7 +98,7 @@
|
|||||||
<h3 class="panel-title">Отладка</h3>
|
<h3 class="panel-title">Отладка</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<?= DEBUG ? 'Включена' : 'Отключена' ?>
|
<?= SystemConfig::getValue('DEBUG') ? 'Включена' : 'Отключена' ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+101
-32
@@ -20,35 +20,82 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Core\Helpers\Captcha;
|
use Core\Helpers\Captcha;
|
||||||
use Core\Models\User;
|
use Core\Helpers\SystemFunctions;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
use Core\Models\{User, UserMeta};
|
||||||
use Core\CoreException;
|
use Core\CoreException;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/bootstrap.php';
|
require_once __DIR__ . '/inc/bootstrap.php';
|
||||||
|
|
||||||
$captchaCorrect = true;
|
// Определяем тип авторизации
|
||||||
if (USE_CAPTCHA) {
|
$authType = isset($_REQUEST['authType']) && !empty($_REQUEST['authType']) ? $_REQUEST['authType'] : 'default';
|
||||||
$captchaCorrect = isset($_REQUEST['captchaCode']) && Captcha::isValidCaptcha($_REQUEST['captchaCode']);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* array(7) {
|
||||||
|
["id"]=> string(7) "1831337"
|
||||||
|
["first_name"]=> string(18) "Александр"
|
||||||
|
["last_name"]=> string(16) "Менщиков"
|
||||||
|
["username"]=> string(5) "n0str"
|
||||||
|
["photo_url"]=> string(36) "https://t.me/i/userpic/100/n0str.jpg"
|
||||||
|
["auth_date"]=> string(10) "1518168109"
|
||||||
|
["hash"]=> string(64) "abba<..>1345"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
switch ($authType) {
|
||||||
|
case 'telegram':
|
||||||
|
$data = [
|
||||||
|
'id' => $_REQUEST['id'],
|
||||||
|
'first_name' => $_REQUEST['first_name'],
|
||||||
|
'last_name' => $_REQUEST['last_name'],
|
||||||
|
'username' => $_REQUEST['username'],
|
||||||
|
'photo_url' => $_REQUEST['photo_url'],
|
||||||
|
'auth_date' => $_REQUEST['auth_date'],
|
||||||
|
'hash' => $_REQUEST['hash'],
|
||||||
|
];
|
||||||
|
$isCorrectTelegramAuth = SystemFunctions::checkTelegramAuthorization($data);
|
||||||
|
if ($isCorrectTelegramAuth) {
|
||||||
|
$res = UserMeta::getListByParams(['name' => 'telegramId', 'value' => $data['id']]);
|
||||||
|
if (!empty($res)) {
|
||||||
|
$userId = array_shift($res)['user_id'];
|
||||||
|
User::authorize($userId);
|
||||||
|
header('Location: index.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$auth = false;
|
||||||
|
$err_mess = true;
|
||||||
|
break;
|
||||||
|
case 'default':
|
||||||
|
$captchaCorrect = true;
|
||||||
|
if (USE_CAPTCHA) {
|
||||||
|
$captchaCorrect = isset($_REQUEST['captchaCode']) && Captcha::isValidCaptcha($_REQUEST['captchaCode']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (User::isAuthorized()) {
|
||||||
|
$auth = true;
|
||||||
|
} else {
|
||||||
|
$auth = false;
|
||||||
|
if ($captchaCorrect && !empty($_REQUEST['login'] && !empty($_REQUEST['pass']))) {
|
||||||
|
if (User::securityAuthorize(
|
||||||
|
$_REQUEST['login'],
|
||||||
|
$_REQUEST['pass'],
|
||||||
|
isset($_REQUEST['remember']) && $_REQUEST['remember'] === 'on'
|
||||||
|
)) {
|
||||||
|
$auth = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($auth === false && isset($_REQUEST['login']) && $_REQUEST['login'] !== '') {
|
||||||
|
$err_mess = true;
|
||||||
|
} else {
|
||||||
|
$err_mess = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (User::isAuthorized()) {
|
|
||||||
$auth = true;
|
|
||||||
} else {
|
|
||||||
$auth = false;
|
|
||||||
if ($captchaCorrect && !empty($_REQUEST['login'] && !empty($_REQUEST['pass']))) {
|
|
||||||
if (User::securityAuthorize(
|
|
||||||
$_REQUEST['login'],
|
|
||||||
$_REQUEST['pass'],
|
|
||||||
isset($_REQUEST['remember']) && $_REQUEST['remember'] === 'on'
|
|
||||||
)) {
|
|
||||||
$auth = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($auth === false && isset($_REQUEST['login']) && $_REQUEST['login'] !== '') {
|
|
||||||
$err_mess = true;
|
|
||||||
} else {
|
|
||||||
$err_mess = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($auth === true) {
|
if ($auth === true) {
|
||||||
global $USER;
|
global $USER;
|
||||||
@@ -56,6 +103,7 @@
|
|||||||
try {
|
try {
|
||||||
User::logout();
|
User::logout();
|
||||||
User::authorize($_REQUEST['loginAs']);
|
User::authorize($_REQUEST['loginAs']);
|
||||||
|
die();
|
||||||
} catch (CoreException $e) {
|
} catch (CoreException $e) {
|
||||||
die('Авторизация не удалась');
|
die('Авторизация не удалась');
|
||||||
}
|
}
|
||||||
@@ -70,23 +118,23 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
|
|
||||||
<title>Delta Framework - Авторизация</title>
|
<title>Delta Framework - Авторизация</title>
|
||||||
|
|
||||||
<link href="//<?php echo $_SERVER['SERVER_NAME']; ?>/admin/styles/css/style.default.css" rel="stylesheet">
|
<link href="//<?php echo $_SERVER['SERVER_NAME']; ?>/admin/styles/css/style.default.css" rel="stylesheet">
|
||||||
|
|
||||||
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="//<?= $_SERVER['SERVER_NAME']; ?>/admin/styles/js/html5shiv.js"></script>
|
<script src="//<?= $_SERVER['SERVER_NAME']; ?>/admin/styles/js/html5shiv.js"></script>
|
||||||
<script src="//<?= $_SERVER['SERVER_NAME']; ?>/admin/styles/js/respond.min.js"></script>
|
<script src="//<?= $_SERVER['SERVER_NAME']; ?>/admin/styles/js/respond.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
<style>
|
||||||
|
.telegramAuthButtonBox {
|
||||||
|
margin-top: 20px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="signin">
|
<body class="signin">
|
||||||
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|
||||||
<div class="panel panel-signin">
|
<div class="panel panel-signin">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="logo text-center">
|
<div class="logo text-center">
|
||||||
@@ -105,6 +153,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<form action="login.php" method="post">
|
<form action="login.php" method="post">
|
||||||
|
<input type="hidden" name="authType" value="default">
|
||||||
<div class="input-group mb15">
|
<div class="input-group mb15">
|
||||||
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
|
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
|
||||||
<input type="text" class="form-control" name="login" placeholder="Имя пользователя">
|
<input type="text" class="form-control" name="login" placeholder="Имя пользователя">
|
||||||
@@ -142,6 +191,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h4 class="text-center mb5">Вход через сторонний сервис</h4>
|
||||||
|
<p class="text-center">Вы можете использовать для авторизации один из вариантов ниже</p>
|
||||||
|
|
||||||
|
<div class="telegramAuthButtonBox">
|
||||||
|
<script async src="https://telegram.org/js/telegram-widget.js?22" data-telegram-login="<?= SystemConfig::getValue('TELEGRAM_BOT_USERNAME') ?>" data-size="large" data-onauth="onTelegramAuth(user)" data-request-access="write"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function onTelegramAuth(user) {
|
||||||
|
document.location.href = 'login.php?authType=telegram&hash='+ user.hash
|
||||||
|
+ '&id=' + user.id
|
||||||
|
+ '&auth_date=' + user.auth_date
|
||||||
|
+ '&first_name=' + user.first_name
|
||||||
|
+ '&last_name=' + user.last_name
|
||||||
|
+ '&photo_url=' + user.photo_url
|
||||||
|
+ '&username=' + user.username
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div><!-- panel-body -->
|
</div><!-- panel-body -->
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<a href="register.php" class="btn btn-primary btn-block">Регистрация в системе</a>
|
<a href="register.php" class="btn btn-primary btn-block">Регистрация в системе</a>
|
||||||
@@ -162,9 +229,11 @@
|
|||||||
<?php if (USE_CAPTCHA) { ?>
|
<?php if (USE_CAPTCHA) { ?>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var captchaSrc = $("#captchaCode").attr('src');
|
let $captchaImage = $('#captchaCode'),
|
||||||
$('#updateCaptcha').click(function () {
|
$captchaSrc = $captchaImage.attr('src'),
|
||||||
$("#captchaCode").attr('src', captchaSrc + `?v=${new Date().getTime()}`);
|
$updateBtn = $('#updateCaptcha');
|
||||||
|
$updateBtn.click(function () {
|
||||||
|
$captchaImage.attr('src', $captchaSrc + `?v=${new Date().getTime()}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+2
-1
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
use Core\Helpers\Pagination;
|
use Core\Helpers\Pagination;
|
||||||
use Core\Helpers\SystemFunctions;
|
use Core\Helpers\SystemFunctions;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
<?php
|
<?php
|
||||||
$nginxLogFile = $_SERVER['DOCUMENT_ROOT'].'/../../log/it-stories.ru_access';
|
$nginxLogFile = $_SERVER['DOCUMENT_ROOT'].'/../../log/it-stories.ru_access';
|
||||||
//$nginxLogFile = $_SERVER['DOCUMENT_ROOT'].'/../../log/test.log';
|
//$nginxLogFile = $_SERVER['DOCUMENT_ROOT'].'/../../log/test.log';
|
||||||
Pagination::execute($_REQUEST['page'], SystemFunctions::getNginxLogData($nginxLogFile, true), PAGINATION_LIMIT);
|
Pagination::execute($_REQUEST['page'], SystemFunctions::getNginxLogData($nginxLogFile, true), SystemConfig::getValue('PAGINATION_LIMIT'));
|
||||||
$limit = Pagination::getLimit();
|
$limit = Pagination::getLimit();
|
||||||
|
|
||||||
$arLogs = SystemFunctions::getNginxLogData($nginxLogFile, false, $limit, true);
|
$arLogs = SystemFunctions::getNginxLogData($nginxLogFile, false, $limit, true);
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@
|
|||||||
use Core\Models\File;
|
use Core\Models\File;
|
||||||
use Core\Models\Posts;
|
use Core\Models\Posts;
|
||||||
use Core\Models\User;
|
use Core\Models\User;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
?>
|
?>
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$objectPosts = new Posts();
|
$objectPosts = new Posts();
|
||||||
Pagination::execute($_REQUEST['page'], $objectPosts->getAllCount(), PAGINATION_LIMIT);
|
Pagination::execute($_REQUEST['page'], $objectPosts->getAllCount(), SystemConfig::getValue('PAGINATION_LIMIT'));
|
||||||
$limit = Pagination::getLimit();
|
$limit = Pagination::getLimit();
|
||||||
|
|
||||||
$arPosts = $objectPosts->getPosts($limit);
|
$arPosts = $objectPosts->getPosts($limit);
|
||||||
|
|||||||
+15
-1
@@ -19,7 +19,7 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Core\Models\{User, MQ};
|
use Core\Models\{User, UserMeta};
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
|
|
||||||
@@ -134,6 +134,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div><!-- form-group -->
|
</div><!-- form-group -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$telegramMetaParam = UserMeta::getListByParams(['user_id' => $objectUser->getId(), 'name' => 'telegramId']);
|
||||||
|
if (!empty($telegramMetaParam)) {
|
||||||
|
$telegramId = array_shift($telegramMetaParam)['value'];
|
||||||
|
?>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">Telegram ID</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" name="token" value="<?= $telegramId; ?>" class="form-control" disabled>
|
||||||
|
</div>
|
||||||
|
</div><!-- form-group -->
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<input type="submit" name="save" value="Сохранить" class="btn btn-primary">
|
<input type="submit" name="save" value="Сохранить" class="btn btn-primary">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+2
-1
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
use Core\Helpers\Pagination;
|
use Core\Helpers\Pagination;
|
||||||
use Core\Models\User;
|
use Core\Models\User;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/header.php';
|
require_once __DIR__ . '/inc/header.php';
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
Pagination::execute($_REQUEST['page'], User::getAllCount(), PAGINATION_LIMIT);
|
Pagination::execute($_REQUEST['page'], User::getAllCount(), SystemConfig::getValue('PAGINATION_LIMIT'));
|
||||||
$limit = Pagination::getLimit();
|
$limit = Pagination::getLimit();
|
||||||
|
|
||||||
$arUsers = User::getUsers($limit);
|
$arUsers = User::getUsers($limit);
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ body {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.main .input.captchaInput {
|
||||||
|
width: 98%;
|
||||||
|
}
|
||||||
|
|
||||||
.main .w100 {
|
.main .w100 {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -26,6 +26,7 @@
|
|||||||
use Core\Models\Router;
|
use Core\Models\Router;
|
||||||
use Core\Models\User;
|
use Core\Models\User;
|
||||||
use Core\Models\UTM;
|
use Core\Models\UTM;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
||||||
//error_reporting(E_ALL);
|
//error_reporting(E_ALL);
|
||||||
@@ -170,10 +171,10 @@
|
|||||||
// debug
|
// debug
|
||||||
function sendTelegram(?string $message, ?string $file = null): void
|
function sendTelegram(?string $message, ?string $file = null): void
|
||||||
{
|
{
|
||||||
(new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendMessage($message);
|
(new \Core\ExternalServices\TelegramSender(SystemConfig::getValue('TELEGRAM_BOT_TOKEN')))->setChat(SystemConfig::getValue('TELEGRAM_NOTIFICATION_CHANNEL'))->sendMessage($message);
|
||||||
|
|
||||||
if (!empty($file)) {
|
if (!empty($file)) {
|
||||||
(new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendDocument($file);
|
(new \Core\ExternalServices\TelegramSender(SystemConfig::getValue('TELEGRAM_BOT_TOKEN')))->setChat(SystemConfig::getValue('TELEGRAM_NOTIFICATION_CHANNEL'))->sendDocument($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -22,13 +22,13 @@
|
|||||||
/**
|
/**
|
||||||
* Версия сервиса
|
* Версия сервиса
|
||||||
*/
|
*/
|
||||||
const CORE_VERSION = '1.0.1_dev';
|
const CORE_VERSION = '1.0.2';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Флаг отладки
|
* Флаг отладки
|
||||||
*/
|
*/
|
||||||
if (!defined('DEBUG')) {
|
if (!defined('DEBUG')) {
|
||||||
define('DEBUG', true);
|
define('DEBUG', true); //SystemConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,6 +124,13 @@
|
|||||||
define('PATH_TO_TEMPLATES', ROOT_PATH . '/templates');
|
define('PATH_TO_TEMPLATES', ROOT_PATH . '/templates');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Имя телеграм бота
|
||||||
|
*/
|
||||||
|
if (!defined('TELEGRAM_BOT_USERNAME')) {
|
||||||
|
define('TELEGRAM_BOT_USERNAME', 'deltacore_bot');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Токен телеграм бота
|
* Токен телеграм бота
|
||||||
*/
|
*/
|
||||||
@@ -213,7 +220,7 @@
|
|||||||
* Флаг использования Captcha
|
* Флаг использования Captcha
|
||||||
*/
|
*/
|
||||||
if (!defined('USE_CAPTCHA')) {
|
if (!defined('USE_CAPTCHA')) {
|
||||||
define('USE_CAPTCHA', true);
|
define('USE_CAPTCHA', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,3 +229,8 @@
|
|||||||
if (!defined('USE_DDOS_PROTECTION')) {
|
if (!defined('USE_DDOS_PROTECTION')) {
|
||||||
define('USE_DDOS_PROTECTION', false);
|
define('USE_DDOS_PROTECTION', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Формат даты/времени
|
||||||
|
*/
|
||||||
|
const DATETIME_FORMAT = 'Y-m-d H:i:s';
|
||||||
+10
-35
@@ -23,45 +23,20 @@
|
|||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
use Core\Helpers\Log;
|
use Core\Helpers\Log;
|
||||||
use Core\Models\MQ;
|
|
||||||
|
|
||||||
if (empty($_SERVER['DOCUMENT_ROOT'])) {
|
if (empty($_SERVER['DOCUMENT_ROOT'])) {
|
||||||
$_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/..';
|
$_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/..';
|
||||||
}
|
}
|
||||||
require_once __DIR__ . '/bootstrap.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Запускаем воркер диспетчера очереди
|
$tasksDir = __DIR__ . '/cronTasks/';
|
||||||
exec('(php -f ' . $_SERVER['DOCUMENT_ROOT'] . '/core/runtime/threadsWorker.php & ) >> /dev/null 2>&1');
|
$list = scandir($tasksDir);
|
||||||
|
$logFileName = 'cron.log';
|
||||||
//$result = (new MQ())->setAttempts(3)->setPriority(1)->setCheckDuplicates(true)->createTask('Core\MQTasks', 'getMySLO');
|
foreach ($list as $file) {
|
||||||
|
if (in_array($file, ['.', '..', 'init.php'], true)) {
|
||||||
// Попытка получения валюты сайта за ежедневные авторизации
|
continue;
|
||||||
$cookieFile = $_SERVER['DOCUMENT_ROOT'] . '/uploads/visaviCookie.txt';
|
}
|
||||||
$logFileName = 'visavi.log';
|
$command = '(php -f ' . $tasksDir . $file . ' & ) >> /dev/null 2>&1';
|
||||||
|
Log::logToFile($command, $logFileName);
|
||||||
if (!file_exists($cookieFile) || time() - @filectime($cookieFile) > 60 * 60 * 23) {
|
exec($command);
|
||||||
Log::logToFile('Время пришло - начинаем попытку авторизации', $logFileName);
|
|
||||||
@unlink($cookieFile);
|
|
||||||
Log::logToFile('Файл куков удален', $logFileName);
|
|
||||||
|
|
||||||
$array = [
|
|
||||||
'login' => 'Nominal',
|
|
||||||
'password' => 'j2medit',
|
|
||||||
];
|
|
||||||
$ch = curl_init('https://visavi.net/login');
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array, '', '&'));
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
|
|
||||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
||||||
$html = curl_exec($ch);
|
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
unset($html);
|
|
||||||
|
|
||||||
Log::logToFile('Запрос на авторизацию произведен. Код ответа: ' . $httpCode, $logFileName);
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ignore_user_abort(true);
|
||||||
|
set_time_limit(0);
|
||||||
|
|
||||||
|
if (empty($_SERVER['DOCUMENT_ROOT'])) {
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../..';
|
||||||
|
}
|
||||||
|
require_once __DIR__ . '/../bootstrap.php';
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
require_once 'init.php';
|
||||||
|
|
||||||
|
use Core\Models\MQ;
|
||||||
|
|
||||||
|
(new MQ())->setCheckDuplicates(false)->setPriority(9)
|
||||||
|
->setAttempts(2)
|
||||||
|
->createTask(
|
||||||
|
'Core\MQTasks',
|
||||||
|
'getStory',
|
||||||
|
[]
|
||||||
|
);
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once 'init.php';
|
||||||
|
|
||||||
|
exec('(php -f ' . $_SERVER['DOCUMENT_ROOT'] . '/core/runtime/threadsWorker.php & ) >> /dev/null 2>&1');
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
use Core\Models\File;
|
use Core\Models\File;
|
||||||
use Core\Models\MQ;
|
use Core\Models\MQ;
|
||||||
use Core\Models\User;
|
use Core\Models\User;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс API контроллера
|
* Класс API контроллера
|
||||||
@@ -69,7 +70,7 @@
|
|||||||
if ($to !== null) {
|
if ($to !== null) {
|
||||||
$this->to = (int)$to;
|
$this->to = (int)$to;
|
||||||
} else {
|
} else {
|
||||||
$this->to = PAGINATION_LIMIT;
|
$this->to = SystemConfig::getValue('PAGINATION_LIMIT');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +290,7 @@
|
|||||||
null,
|
null,
|
||||||
$this->request->getProperty('subject'),
|
$this->request->getProperty('subject'),
|
||||||
$this->request->getProperty('body'),
|
$this->request->getProperty('body'),
|
||||||
MAIL_TEMPLATE_DEFAULT,
|
SystemConfig::getValue('MAIL_TEMPLATE_DEFAULT'),
|
||||||
['TITLE' => $this->request->getProperty('subject')],
|
['TITLE' => $this->request->getProperty('subject')],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace Core;
|
namespace Core;
|
||||||
|
|
||||||
|
use Core\Helpers\Captcha;
|
||||||
use Core\Helpers\Pagination;
|
use Core\Helpers\Pagination;
|
||||||
use Core\Helpers\Registry;
|
use Core\Helpers\Registry;
|
||||||
use Core\Helpers\SystemFunctions;
|
use Core\Helpers\SystemFunctions;
|
||||||
@@ -49,6 +50,8 @@
|
|||||||
$memoryUse = memory_get_usage() - START_MEMORY;
|
$memoryUse = memory_get_usage() - START_MEMORY;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'SITE_URL' => SITE_URL,
|
||||||
|
'USE_CAPTCHA' => USE_CAPTCHA,
|
||||||
'salt' => md5(random_int(1, 999999) . random_int(1, 999999) . random_int(1, 999999) . random_int(1, 999999)),
|
'salt' => md5(random_int(1, 999999) . random_int(1, 999999) . random_int(1, 999999) . random_int(1, 999999)),
|
||||||
'currentPage' => $currentPage,
|
'currentPage' => $currentPage,
|
||||||
'memoryUse' => SystemFunctions::convertBytes($memoryUse),
|
'memoryUse' => SystemFunctions::convertBytes($memoryUse),
|
||||||
@@ -86,7 +89,7 @@
|
|||||||
{
|
{
|
||||||
$buildInfo = [
|
$buildInfo = [
|
||||||
'Версия ядра' => CORE_VERSION,
|
'Версия ядра' => CORE_VERSION,
|
||||||
'Лимит пагинации' => PAGINATION_LIMIT,
|
'Лимит пагинации' => SystemConfig::getValue('PAGINATION_LIMIT'),
|
||||||
'Время для расчета онлайна' => USER_ONLINE_TIME,
|
'Время для расчета онлайна' => USER_ONLINE_TIME,
|
||||||
'Время жизни кеша' => CACHE_TTL,
|
'Время жизни кеша' => CACHE_TTL,
|
||||||
'E-Mail сайта' => SERVER_EMAIL,
|
'E-Mail сайта' => SERVER_EMAIL,
|
||||||
@@ -136,7 +139,7 @@
|
|||||||
|
|
||||||
public static function users()
|
public static function users()
|
||||||
{
|
{
|
||||||
Pagination::execute($_REQUEST['page'], User::getAllCount(), PAGINATION_LIMIT);
|
Pagination::execute($_REQUEST['page'], User::getAllCount(), SystemConfig::getValue('PAGINATION_LIMIT'));
|
||||||
$limit = Pagination::getLimit();
|
$limit = Pagination::getLimit();
|
||||||
$limit= '0, 10';
|
$limit= '0, 10';
|
||||||
$arUsers = User::getUsers($limit);
|
$arUsers = User::getUsers($limit);
|
||||||
@@ -149,20 +152,41 @@
|
|||||||
|
|
||||||
public static function test($a = null, $b = null, $c = null, $d = null)
|
public static function test($a = null, $b = null, $c = null, $d = null)
|
||||||
{
|
{
|
||||||
|
ddd($_SESSION);
|
||||||
print_r([$a, $b, $c, $d]);
|
print_r([$a, $b, $c, $d]);
|
||||||
self::render('test.twig');
|
self::render('test.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function logout()
|
public static function logout()
|
||||||
{
|
{
|
||||||
|
Captcha::clearSession();
|
||||||
User::logout();
|
User::logout();
|
||||||
header('Location: /');
|
header('Location: /');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loginAuthorize()
|
public static function loginAuthorize()
|
||||||
{
|
{
|
||||||
if (User::securityAuthorize($_REQUEST['login'], $_REQUEST['password'], false)) {
|
$captchaCorrect = true;
|
||||||
header('Location: /');
|
if (USE_CAPTCHA) {
|
||||||
|
if (empty($_REQUEST['captchaCode'])) {
|
||||||
|
$_SESSION['authErrorMessage'] = 'Не введен код с картинки';
|
||||||
|
$captchaCorrect = false;
|
||||||
|
} else {
|
||||||
|
$captchaCorrect = Captcha::isValidCaptcha($_REQUEST['captchaCode']);
|
||||||
|
if ($captchaCorrect === false) {
|
||||||
|
$_SESSION['authErrorMessage'] = 'Неверный код с картинки';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($captchaCorrect) {
|
||||||
|
if (User::securityAuthorize($_REQUEST['login'], $_REQUEST['password'], false)) {
|
||||||
|
unset($_SESSION['authErrorMessage']);
|
||||||
|
header('Location: /');
|
||||||
|
} else {
|
||||||
|
$_SESSION['authErrorMessage'] = 'Неверный логин или пароль';
|
||||||
|
header('Location: /login/failed');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
header('Location: /login/failed');
|
header('Location: /login/failed');
|
||||||
}
|
}
|
||||||
@@ -175,7 +199,7 @@
|
|||||||
|
|
||||||
public static function loginFailed()
|
public static function loginFailed()
|
||||||
{
|
{
|
||||||
self::render('login.twig', ['failed' => true]);
|
self::render('login.twig', ['failed' => true, 'errorMessage' => $_SESSION['authErrorMessage']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function userProfile(int $id)
|
public static function userProfile(int $id)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
namespace Core\DataBases;
|
namespace Core\DataBases;
|
||||||
|
|
||||||
use Core\CoreException;
|
use Core\CoreException;
|
||||||
|
use Core\Helpers\SystemFunctions;
|
||||||
|
use Core\SystemConfig;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@@ -112,22 +114,6 @@
|
|||||||
// TODO: на случай чего то стоящего...
|
// TODO: на случай чего то стоящего...
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Отправка уведомления о критическом событии
|
|
||||||
* // TODO: метод-заглушка для возможности оповещения о критических событиях
|
|
||||||
*
|
|
||||||
* @param string $text Текст
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @deprecated Вероятно, будет выпилено в дальнейшем
|
|
||||||
*/
|
|
||||||
public static function sendAlarm(string $text): void
|
|
||||||
{
|
|
||||||
if (function_exists('sendTelegram')) {
|
|
||||||
sendTelegram($text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить объект класса
|
* Получить объект класса
|
||||||
*
|
*
|
||||||
@@ -231,8 +217,14 @@
|
|||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
$set_string = '';
|
$set_string = '';
|
||||||
foreach ($set as $set_key => $set_item) {
|
foreach ($set as $setKey => $setValue) {
|
||||||
$set_string .= ' ' . $set_key . '=\'' . $set_item . '\',';
|
$set_string .= ' ' . $setKey . '=';
|
||||||
|
if (is_null($setValue)) {
|
||||||
|
$set_string .= ' ' . $setKey . '=null,';
|
||||||
|
} else {
|
||||||
|
$set_string .= '\'' . $setValue . '\',';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return substr($set_string, 0, -1);
|
return substr($set_string, 0, -1);
|
||||||
}
|
}
|
||||||
@@ -301,11 +293,14 @@
|
|||||||
try {
|
try {
|
||||||
$stmt = $this->db->query($sql);
|
$stmt = $this->db->query($sql);
|
||||||
} catch (\Throwable $t) {
|
} catch (\Throwable $t) {
|
||||||
self::sendAlarm(
|
SystemFunctions::sendAlarm('DataBase',
|
||||||
'<b><u>' . date('d.m.Y H:i:s') . '</u></b>' . PHP_EOL . '</b><b>SQL ERROR:</b> ' . PHP_EOL . $this->db->errorInfo()[2] . PHP_EOL
|
'<b><u>' . date('d.m.Y H:i:s') . '</u></b>' . PHP_EOL
|
||||||
. '<b>QUERY:</b> ' . PHP_EOL . $sql
|
. '</b><b>SQL ERROR:</b> ' . PHP_EOL
|
||||||
|
. $this->db->errorInfo()[2] . PHP_EOL
|
||||||
|
. '<b>QUERY:</b> ' . PHP_EOL
|
||||||
|
. $sql
|
||||||
);
|
);
|
||||||
if(DEBUG) {
|
if(SystemConfig::getValue('DEBUG')) {
|
||||||
throw new CoreException(
|
throw new CoreException(
|
||||||
'В SQL запросе произошла ошибка: ' . $this->db->errorInfo()[2]
|
'В SQL запросе произошла ошибка: ' . $this->db->errorInfo()[2]
|
||||||
. '. Запрос: ' . $sql, CoreException::ERROR_SQL_QUERY);
|
. '. Запрос: ' . $sql, CoreException::ERROR_SQL_QUERY);
|
||||||
|
|||||||
@@ -146,6 +146,7 @@
|
|||||||
* @param string $table Таблица
|
* @param string $table Таблица
|
||||||
*
|
*
|
||||||
* @return array|null Имена колонок
|
* @return array|null Имена колонок
|
||||||
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
private static function getColumnsInfo(string $table): array
|
private static function getColumnsInfo(string $table): array
|
||||||
{
|
{
|
||||||
@@ -166,16 +167,16 @@
|
|||||||
private function setData(array $data): void
|
private function setData(array $data): void
|
||||||
{
|
{
|
||||||
$this->sourceData = $data;
|
$this->sourceData = $data;
|
||||||
|
$columnsInfo = self::getColumnsInfo(static::TABLE);
|
||||||
foreach ($data as $prop => $value) {
|
foreach ($data as $prop => $value) {
|
||||||
$key = $prop;
|
$key = $prop;
|
||||||
if (empty($this->renameProps[$prop]) === false) {
|
if (!empty($this->renameProps[$prop])) {
|
||||||
$key = $this->renameProps[$prop];
|
$key = $this->renameProps[$prop];
|
||||||
}
|
}
|
||||||
if (property_exists($this, $key)) {
|
if (property_exists($this, $key)) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
$columnsInfo = self::getColumnsInfo(static::TABLE);
|
if (!empty($columnsInfo[$key])) {
|
||||||
if (empty($columnsInfo[$key]) === false) {
|
|
||||||
switch ($columnsInfo[$key]['type']) {
|
switch ($columnsInfo[$key]['type']) {
|
||||||
case self::COLUMN_TYPE_BOOL:
|
case self::COLUMN_TYPE_BOOL:
|
||||||
$this->$key = (bool)$this->$key;
|
$this->$key = (bool)$this->$key;
|
||||||
@@ -188,23 +189,27 @@
|
|||||||
/**
|
/**
|
||||||
* Сохранить элемент
|
* Сохранить элемент
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
* @throws CoreException
|
* @throws DataObjectsException
|
||||||
*/
|
*/
|
||||||
public function save(): self
|
public function save(): self
|
||||||
{
|
{
|
||||||
/** @var DB $db */
|
/** @var DB $db */
|
||||||
$db = DB::getInstance();
|
$db = DB::getInstance();
|
||||||
$id = static::ID_NAME;
|
$id = static::ID_NAME;
|
||||||
if (empty($this->$id) === false) {
|
try {
|
||||||
$diff = $this->getDataDifference();
|
if (!empty($this->$id)) {
|
||||||
if (empty($diff) === false) {
|
$diff = $this->getDataDifference();
|
||||||
$db->update(static::TABLE, [$id => $this->$id], $this->sanitizeFields($diff));
|
if (!empty($diff)) {
|
||||||
|
$db->update(static::TABLE, [$id => $this->$id], $this->sanitizeFields($diff));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->$id = $db->addItem(static::TABLE, $this->sanitizeFields($this->getDataDifference(true)));
|
||||||
}
|
}
|
||||||
} else {
|
$this->setData($db->getItem(static::TABLE, [$id => $this->$id]));
|
||||||
$this->$id = $db->addItem(static::TABLE, $this->sanitizeFields($this->getDataDifference(true)));
|
} catch (Throwable $e) {
|
||||||
|
throw new DataObjectsException('Произошла ошибка при сохранении данных: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
$this->setData($db->getItem(static::TABLE, [$id => $this->$id]));
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +275,7 @@
|
|||||||
$renameList = array_flip($this->renameProps);
|
$renameList = array_flip($this->renameProps);
|
||||||
}
|
}
|
||||||
$columnList = self::getColumnsInfo(static::TABLE);
|
$columnList = self::getColumnsInfo(static::TABLE);
|
||||||
foreach (self::getColumnsInfo(static::TABLE) as $prop => $info) {
|
foreach ($columnList as $prop => $info) {
|
||||||
if (!$includeWriteProtected && in_array($prop, static::WRITE_PROTECTION, true)) {
|
if (!$includeWriteProtected && in_array($prop, static::WRITE_PROTECTION, true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -315,7 +320,7 @@
|
|||||||
public static function select(array $filter): ModelCollection
|
public static function select(array $filter): ModelCollection
|
||||||
{
|
{
|
||||||
/** @var DB $db */
|
/** @var DB $db */
|
||||||
$db = DB::getInstance();
|
$db = DB::getInstance();
|
||||||
$result = $db->getItems(static::TABLE, $filter);
|
$result = $db->getItems(static::TABLE, $filter);
|
||||||
$collectionClass = static::COLLECTION;
|
$collectionClass = static::COLLECTION;
|
||||||
$collection = new $collectionClass();
|
$collection = new $collectionClass();
|
||||||
@@ -362,7 +367,7 @@
|
|||||||
* @param array $array Входные данные
|
* @param array $array Входные данные
|
||||||
*
|
*
|
||||||
* @return array Результат
|
* @return array Результат
|
||||||
* @throws CoreException
|
* @throws DataObjectsException
|
||||||
*/
|
*/
|
||||||
private function sanitizeFields(array $array): array
|
private function sanitizeFields(array $array): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
namespace Core\Helpers;
|
namespace Core\Helpers;
|
||||||
|
|
||||||
|
use mysql_xdevapi\Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс для работы с Captcha
|
* Класс для работы с Captcha
|
||||||
*/
|
*/
|
||||||
@@ -36,9 +38,15 @@
|
|||||||
{
|
{
|
||||||
if ($code === null) {
|
if ($code === null) {
|
||||||
$code = SystemFunctions::generateCode(8, 8);
|
$code = SystemFunctions::generateCode(8, 8);
|
||||||
$_SESSION['captchaCode'] = $code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_SESSION['captcha'] = [
|
||||||
|
'captchaCode' => $code,
|
||||||
|
'verified' => false,
|
||||||
|
'generatedTime' => time(),
|
||||||
|
'generatedDate' => date(DATETIME_FORMAT),
|
||||||
|
];
|
||||||
|
|
||||||
$width = 80;
|
$width = 80;
|
||||||
$height = 30;
|
$height = 30;
|
||||||
$img = imagecreate($width, $height);
|
$img = imagecreate($width, $height);
|
||||||
@@ -103,6 +111,21 @@
|
|||||||
*/
|
*/
|
||||||
public static function isValidCaptcha(string $code): bool
|
public static function isValidCaptcha(string $code): bool
|
||||||
{
|
{
|
||||||
return (string)$_SESSION['captchaCode'] === $code;
|
$result = (string)$_SESSION['captcha']['captchaCode'] === $code;
|
||||||
|
$_SESSION['captcha']['verified'] = $result;
|
||||||
|
$_SESSION['captcha']['verifiedTime'] = time();
|
||||||
|
$_SESSION['captcha']['verifiedDate'] = date(DATETIME_FORMAT);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Очистка данных каптчи
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function clearSession(): void
|
||||||
|
{
|
||||||
|
unset($_SESSION['captcha']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
use Core\CoreException;
|
use Core\CoreException;
|
||||||
use Core\DataBases\DB;
|
use Core\DataBases\DB;
|
||||||
use Core\Models\User;
|
use Core\Models\User;
|
||||||
|
use Core\SystemConfig;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +87,7 @@
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->setFrom(SERVER_EMAIL, SERVER_EMAIL_NAME)
|
$this->setFrom(SERVER_EMAIL, SERVER_EMAIL_NAME)
|
||||||
->setTo($user->getEmail(), $user->getName())
|
->setTo($user->getEmail(), $user->getName())
|
||||||
->setTemplate(MAIL_TEMPLATE_DEFAULT);
|
->setTemplate(SystemConfig::getValue('MAIL_TEMPLATE_DEFAULT'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,14 +96,15 @@
|
|||||||
*
|
*
|
||||||
* @param string $templateName Имя шаблона
|
* @param string $templateName Имя шаблона
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setTemplate(string $templateName): self
|
public function setTemplate(string $templateName): self
|
||||||
{
|
{
|
||||||
if(!file_exists(MAIL_TEMPLATES_PATH . '/' . $templateName . '.html')) {
|
|
||||||
throw new CoreException('Шаблон "' . $templateName . '" не найден');
|
|
||||||
}
|
|
||||||
$this->templateName = $templateName;
|
$this->templateName = $templateName;
|
||||||
|
if (!file_exists(MAIL_TEMPLATES_PATH . '/' . $templateName . '.html')) {
|
||||||
|
$this->templateName = 'default';
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +113,7 @@
|
|||||||
*
|
*
|
||||||
* @param array $templateVars Массив переменных шаблона
|
* @param array $templateVars Массив переменных шаблона
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setTemplateVars(array $templateVars): self
|
public function setTemplateVars(array $templateVars): self
|
||||||
{
|
{
|
||||||
@@ -136,7 +138,7 @@
|
|||||||
/**
|
/**
|
||||||
* От кого
|
* От кого
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setFrom($email, $name = null): self
|
public function setFrom($email, $name = null): self
|
||||||
{
|
{
|
||||||
@@ -148,7 +150,7 @@
|
|||||||
/**
|
/**
|
||||||
* Кому
|
* Кому
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setTo($email, $name = null): self
|
public function setTo($email, $name = null): self
|
||||||
{
|
{
|
||||||
@@ -160,7 +162,7 @@
|
|||||||
/**
|
/**
|
||||||
* Тема
|
* Тема
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSubject($subject = null): self
|
public function setSubject($subject = null): self
|
||||||
{
|
{
|
||||||
@@ -171,7 +173,7 @@
|
|||||||
/**
|
/**
|
||||||
* Тело письма
|
* Тело письма
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBody($body = null): self
|
public function setBody($body = null): self
|
||||||
{
|
{
|
||||||
@@ -182,7 +184,7 @@
|
|||||||
/**
|
/**
|
||||||
* Добавление файла к письму
|
* Добавление файла к письму
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function addFile($filename): self
|
public function addFile($filename): self
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
|
|
||||||
use Core\CoreException;
|
use Core\CoreException;
|
||||||
use Core\DTO\System\Memory;
|
use Core\DTO\System\Memory;
|
||||||
|
use Core\Models\Roles;
|
||||||
|
use Core\Models\User;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс вспомогательных методов
|
* Класс вспомогательных методов
|
||||||
@@ -480,7 +483,9 @@
|
|||||||
*/
|
*/
|
||||||
public static function sendTelegram(string $message): void
|
public static function sendTelegram(string $message): void
|
||||||
{
|
{
|
||||||
(new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendMessage($message);
|
(new \Core\ExternalServices\TelegramSender(SystemConfig::getValue('TELEGRAM_BOT_TOKEN')))
|
||||||
|
->setChat(SystemConfig::getValue('TELEGRAM_NOTIFICATION_CHANNEL'))
|
||||||
|
->sendMessage($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -489,6 +494,7 @@
|
|||||||
* @param array|string|null $var Массив
|
* @param array|string|null $var Массив
|
||||||
* @param string $title Заголовок
|
* @param string $title Заголовок
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function arrayToTable($var, string $title = ''): ?string
|
public static function arrayToTable($var, string $title = ''): ?string
|
||||||
@@ -917,4 +923,61 @@
|
|||||||
|
|
||||||
return $memoryObject;
|
return $memoryObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Отправка уведомления о критическом событии
|
||||||
|
*
|
||||||
|
* @param string $text Текст алярма
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function sendAlarm(string $title, string $text): void
|
||||||
|
{
|
||||||
|
$userList = User::getListByRole(Roles::ALARM_ROLE_ID);
|
||||||
|
|
||||||
|
foreach($userList as $userObject) {
|
||||||
|
(new Mail())->setFrom(SERVER_EMAIL, SERVER_EMAIL_NAME)
|
||||||
|
->setTemplate(MAIL_TEMPLATE_DEFAULT)
|
||||||
|
->setTo($userObject->getEmail(), $userObject->getName())
|
||||||
|
->setSubject('Alarm: ' . $title)
|
||||||
|
->setBody($text)
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
if (function_exists('sendTelegram')) {
|
||||||
|
sendTelegram('<b>' . $title . '</b>' . PHP_EOL. $text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверка авторизации через Telegram
|
||||||
|
*
|
||||||
|
* @param array $authData Данные для проверки
|
||||||
|
*
|
||||||
|
* @return bool Результат проверки
|
||||||
|
*/
|
||||||
|
public static function checkTelegramAuthorization(array $authData): bool
|
||||||
|
{
|
||||||
|
if (empty($authData['hash']) || empty($authData['auth_date'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$checkHash = $authData['hash'];
|
||||||
|
unset($authData['hash']);
|
||||||
|
$dataCheckArr = [];
|
||||||
|
foreach ($authData as $key => $value) {
|
||||||
|
$dataCheckArr[] = $key . '=' . $value;
|
||||||
|
}
|
||||||
|
sort($dataCheckArr);
|
||||||
|
$dataCheckString = implode("\n", $dataCheckArr);
|
||||||
|
$secretKey = hash('sha256', SystemConfig::getValue('TELEGRAM_BOT_TOKEN'), true);
|
||||||
|
$hash = hash_hmac('sha256', $dataCheckString, $secretKey);
|
||||||
|
if (strcmp($hash, $checkHash) !== 0) {
|
||||||
|
//Data is NOT from Telegram
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((time() - (int)$authData['auth_date']) > 86400) {
|
||||||
|
//Data is outdated
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,39 +25,56 @@
|
|||||||
|
|
||||||
class Thumbs
|
class Thumbs
|
||||||
{
|
{
|
||||||
|
/** @var string $filename */
|
||||||
|
private string $filename;
|
||||||
|
|
||||||
|
/** @var int $width */
|
||||||
|
private $width;
|
||||||
|
|
||||||
|
/** @var int $height */
|
||||||
|
private $height;
|
||||||
|
|
||||||
|
/** @var int $type */
|
||||||
|
private $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var false|\GdImage|resource
|
||||||
|
*/
|
||||||
|
private $img;
|
||||||
|
|
||||||
public function __construct(string $filename)
|
public function __construct(string $filename)
|
||||||
{
|
{
|
||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
if (empty($this->filename)) {
|
if (empty($this->filename)) {
|
||||||
throw new CoreException('Файл не найден');
|
throw new CoreException('Файл не найден');
|
||||||
} else {
|
}
|
||||||
$info = getimagesize($this->filename);
|
|
||||||
if (empty($info)) {
|
$info = getimagesize($this->filename);
|
||||||
throw new CoreException('Файл не найден');
|
if (empty($info)) {
|
||||||
} else {
|
throw new CoreException('Файл не найден');
|
||||||
$this->width = $info[0];
|
}
|
||||||
$this->height = $info[1];
|
|
||||||
$this->type = $info[2];
|
$this->width = $info[0];
|
||||||
switch ($this->type) {
|
$this->height = $info[1];
|
||||||
case 1:
|
$this->type = $info[2];
|
||||||
$this->img = imageCreateFromGif($this->filename);
|
switch ($this->type) {
|
||||||
break;
|
case IMAGETYPE_GIF:
|
||||||
case 2:
|
$this->img = imagecreatefromgif($this->filename);
|
||||||
$this->img = imageCreateFromJpeg($this->filename);
|
break;
|
||||||
break;
|
case IMAGETYPE_JPEG:
|
||||||
case 3:
|
$this->img = imagecreatefromjpeg($this->filename);
|
||||||
$this->img = imageCreateFromPng($this->filename);
|
break;
|
||||||
imageAlphaBlending($this->img, true);
|
case IMAGETYPE_PNG:
|
||||||
imageSaveAlpha($this->img, true);
|
$this->img = imagecreatefrompng($this->filename);
|
||||||
break;
|
imagealphablending($this->img, true);
|
||||||
case 18:
|
imagesavealpha($this->img, true);
|
||||||
$this->img = imageCreatefromWebp($this->filename);
|
break;
|
||||||
break;
|
case IMAGETYPE_WEBP:
|
||||||
default:
|
$this->img = imagecreatefromwebp($this->filename);
|
||||||
throw new CoreException('Формат файла не подерживается');
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
throw new CoreException('Формат файла не поддерживается');
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +110,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tmp = imageCreateTrueColor($width, $height);
|
$tmp = imageCreateTrueColor($width, $height);
|
||||||
if ($this->type == 1 || $this->type == 3) {
|
if ($this->type === IMAGETYPE_GIF || $this->type === IMAGETYPE_PNG) {
|
||||||
imagealphablending($tmp, true);
|
imagealphablending($tmp, true);
|
||||||
imageSaveAlpha($tmp, true);
|
imageSaveAlpha($tmp, true);
|
||||||
$transparent = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
|
$transparent = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
|
||||||
@@ -230,7 +247,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tmp = imageCreateTrueColor($width, $height);
|
$tmp = imageCreateTrueColor($width, $height);
|
||||||
if ($this->type == 1 || $this->type == 3) {
|
if ($this->type === IMAGETYPE_GIF || $this->type === IMAGETYPE_PNG) {
|
||||||
imagealphablending($tmp, true);
|
imagealphablending($tmp, true);
|
||||||
imageSaveAlpha($tmp, true);
|
imageSaveAlpha($tmp, true);
|
||||||
$transparent = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
|
$transparent = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
|
||||||
@@ -263,9 +280,9 @@
|
|||||||
$tw = ceil($height / ($this->height / $this->width));
|
$tw = ceil($height / ($this->height / $this->width));
|
||||||
$th = ceil($width / ($this->width / $this->height));
|
$th = ceil($width / ($this->width / $this->height));
|
||||||
|
|
||||||
if ($this->width == $this->height) {
|
if ($this->width === $this->height) {
|
||||||
// Источник - квадратная фотка
|
// Источник - квадратная фотка
|
||||||
if ($width == $height) {
|
if ($width === $height) {
|
||||||
// Превью - квадратная.
|
// Превью - квадратная.
|
||||||
$this->resize($width, $height);
|
$this->resize($width, $height);
|
||||||
} elseif ($width > $height) {
|
} elseif ($width > $height) {
|
||||||
@@ -341,9 +358,9 @@
|
|||||||
$tw = ceil($height / ($this->height / $this->width));
|
$tw = ceil($height / ($this->height / $this->width));
|
||||||
$th = ceil($width / ($this->width / $this->height));
|
$th = ceil($width / ($this->width / $this->height));
|
||||||
|
|
||||||
if ($this->width != $width && $this->height != $height) {
|
if ($this->width !== $width && $this->height !== $height) {
|
||||||
$tmp = imageCreateTrueColor($width, $height);
|
$tmp = imageCreateTrueColor($width, $height);
|
||||||
if ($this->type == 1 || $this->type == 3) {
|
if ($this->type === IMAGETYPE_GIF || $this->type === IMAGETYPE_PNG) {
|
||||||
imagealphablending($tmp, true);
|
imagealphablending($tmp, true);
|
||||||
imageSaveAlpha($tmp, true);
|
imageSaveAlpha($tmp, true);
|
||||||
$transparent = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
|
$transparent = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
|
||||||
@@ -563,9 +580,9 @@
|
|||||||
unset($tmp);
|
unset($tmp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return $this->cut($width, $height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->cut($width, $height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,80 +643,80 @@
|
|||||||
{
|
{
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
throw new CoreException('Файл маски не найден');
|
throw new CoreException('Файл маски не найден');
|
||||||
} else {
|
|
||||||
$info = getimagesize($file);
|
|
||||||
if (empty($info)) {
|
|
||||||
throw new CoreException('Файл маски не найден');
|
|
||||||
} else {
|
|
||||||
switch ($info[2]) {
|
|
||||||
case 1:
|
|
||||||
$dest = imageCreateFromGif($file);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$dest = imageCreateFromJpeg($file);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$dest = imageCreateFromPng($file);
|
|
||||||
$transparent = imagecolorallocatealpha($dest, 0, 0, 0, 127);
|
|
||||||
imagefill($dest, 0, 0, $transparent);
|
|
||||||
imagecolortransparent($dest, $transparent);
|
|
||||||
|
|
||||||
imageAlphaBlending($dest, true);
|
|
||||||
imageSaveAlpha($dest, true);
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 18:
|
|
||||||
$dest = imageCreatefromWebp($file);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new CoreException('Формат файла маски не подерживается');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($position) {
|
|
||||||
case 'top':
|
|
||||||
$x = ceil(($this->width - $info[0]) / 2);
|
|
||||||
$y = 0;
|
|
||||||
break;
|
|
||||||
case 'top-left':
|
|
||||||
$x = 0;
|
|
||||||
$y = 0;
|
|
||||||
break;
|
|
||||||
case 'top-right':
|
|
||||||
$x = ceil($this->width - $info[0]);
|
|
||||||
$y = 0;
|
|
||||||
break;
|
|
||||||
case 'left':
|
|
||||||
$x = 0;
|
|
||||||
$y = ceil(($this->height - $info[1]) / 2);
|
|
||||||
break;
|
|
||||||
case 'right':
|
|
||||||
$x = ceil($this->width - $info[0]);
|
|
||||||
$y = ceil(($this->height - $info[1]) / 2);
|
|
||||||
break;
|
|
||||||
case 'bottom':
|
|
||||||
$x = ceil(($this->width - $info[0]) / 2);
|
|
||||||
$y = ceil($this->height - $info[1]);
|
|
||||||
break;
|
|
||||||
case 'bottom-left':
|
|
||||||
$x = 0;
|
|
||||||
$y = ceil($this->height - $info[1]);
|
|
||||||
break;
|
|
||||||
case 'bottom-right':
|
|
||||||
$x = ceil($this->width - $info[0]);
|
|
||||||
$y = ceil($this->height - $info[1]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$x = ceil(($this->width - $info[0]) / 2);
|
|
||||||
$y = ceil(($this->height - $info[1]) / 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$dest = $this->opacity($dest, $transparency);
|
|
||||||
imagecopy($this->img, $dest, $x, $y, 0, 0, $info[0], $info[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$info = getimagesize($file);
|
||||||
|
if (empty($info)) {
|
||||||
|
throw new CoreException('Файл маски не найден');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($info[2]) {
|
||||||
|
case IMAGETYPE_GIF:
|
||||||
|
$dest = imageCreateFromGif($file);
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_JPEG:
|
||||||
|
$dest = imageCreateFromJpeg($file);
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_PNG:
|
||||||
|
$dest = imageCreateFromPng($file);
|
||||||
|
$transparent = imagecolorallocatealpha($dest, 0, 0, 0, 127);
|
||||||
|
imagefill($dest, 0, 0, $transparent);
|
||||||
|
imagecolortransparent($dest, $transparent);
|
||||||
|
|
||||||
|
imageAlphaBlending($dest, true);
|
||||||
|
imageSaveAlpha($dest, true);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_WEBP:
|
||||||
|
$dest = imageCreatefromWebp($file);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new CoreException('Формат файла маски не подерживается');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($position) {
|
||||||
|
case 'top':
|
||||||
|
$x = ceil(($this->width - $info[0]) / 2);
|
||||||
|
$y = 0;
|
||||||
|
break;
|
||||||
|
case 'top-left':
|
||||||
|
$x = 0;
|
||||||
|
$y = 0;
|
||||||
|
break;
|
||||||
|
case 'top-right':
|
||||||
|
$x = ceil($this->width - $info[0]);
|
||||||
|
$y = 0;
|
||||||
|
break;
|
||||||
|
case 'left':
|
||||||
|
$x = 0;
|
||||||
|
$y = ceil(($this->height - $info[1]) / 2);
|
||||||
|
break;
|
||||||
|
case 'right':
|
||||||
|
$x = ceil($this->width - $info[0]);
|
||||||
|
$y = ceil(($this->height - $info[1]) / 2);
|
||||||
|
break;
|
||||||
|
case 'bottom':
|
||||||
|
$x = ceil(($this->width - $info[0]) / 2);
|
||||||
|
$y = ceil($this->height - $info[1]);
|
||||||
|
break;
|
||||||
|
case 'bottom-left':
|
||||||
|
$x = 0;
|
||||||
|
$y = ceil($this->height - $info[1]);
|
||||||
|
break;
|
||||||
|
case 'bottom-right':
|
||||||
|
$x = ceil($this->width - $info[0]);
|
||||||
|
$y = ceil($this->height - $info[1]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$x = ceil(($this->width - $info[0]) / 2);
|
||||||
|
$y = ceil(($this->height - $info[1]) / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dest = $this->opacity($dest, $transparency);
|
||||||
|
imagecopy($this->img, $dest, $x, $y, 0, 0, $info[0], $info[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -736,13 +753,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case 1:
|
case IMAGETYPE_GIF:
|
||||||
return $this->saveGif($filename);
|
return $this->saveGif($filename);
|
||||||
case 2:
|
case IMAGETYPE_JPEG:
|
||||||
return $this->saveJpg($filename, $quality);
|
return $this->saveJpg($filename, $quality);
|
||||||
case 3:
|
case IMAGETYPE_PNG:
|
||||||
return $this->savePng($filename);
|
return $this->savePng($filename);
|
||||||
case 18:
|
case IMAGETYPE_WEBP:
|
||||||
return $this->saveWebp($filename);
|
return $this->saveWebp($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,19 +770,19 @@
|
|||||||
public function output($quality = 100): void
|
public function output($quality = 100): void
|
||||||
{
|
{
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case 1:
|
case IMAGETYPE_GIF:
|
||||||
header('Content-Type: image/gif');
|
header('Content-Type: image/gif');
|
||||||
imageGif($this->img);
|
imageGif($this->img);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case IMAGETYPE_JPEG:
|
||||||
header('Content-Type: image/jpeg');
|
header('Content-Type: image/jpeg');
|
||||||
imageJpeg($this->img, null, $quality);
|
imageJpeg($this->img, null, $quality);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case IMAGETYPE_PNG:
|
||||||
header('Content-Type: image/x-png');
|
header('Content-Type: image/x-png');
|
||||||
imagePng($this->img);
|
imagePng($this->img);
|
||||||
break;
|
break;
|
||||||
case 18:
|
case IMAGETYPE_WEBP:
|
||||||
header('Content-Type: image/webp');
|
header('Content-Type: image/webp');
|
||||||
imageWebp($this->img, $quality);
|
imageWebp($this->img, $quality);
|
||||||
break;
|
break;
|
||||||
@@ -782,15 +799,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case 1:
|
case IMAGETYPE_GIF:
|
||||||
header('Content-Type: image/gif');
|
header('Content-Type: image/gif');
|
||||||
imageGif($this->img, $filename);
|
imageGif($this->img, $filename);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case IMAGETYPE_JPEG:
|
||||||
header('Content-Type: image/jpeg');
|
header('Content-Type: image/jpeg');
|
||||||
imageJpeg($this->img, $filename, $quality);
|
imageJpeg($this->img, $filename, $quality);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case IMAGETYPE_PNG:
|
||||||
header('Content-Type: image/x-png');
|
header('Content-Type: image/x-png');
|
||||||
imagePng($this->img, $filename);
|
imagePng($this->img, $filename);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
|
|||||||
if (date('H') > 21 || date('H') < 9) {
|
if (date('H') > 21 || date('H') < 9) {
|
||||||
return 'Нерабочее время :(';
|
return 'Нерабочее время :(';
|
||||||
}
|
}
|
||||||
$telegram = new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN);
|
$telegram = new \Core\ExternalServices\TelegramSender(SystemConfig::getValue('TELEGRAM_BOT_TOKEN'));
|
||||||
$telegram->setChat(' -1001610334197');
|
$telegram->setChat(' -1001610334197');
|
||||||
|
|
||||||
/** @var DB $DB */
|
/** @var DB $DB */
|
||||||
@@ -338,7 +338,7 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
|
|||||||
$post .= PHP_EOL . '<a href="' . $link . '">Подробнее</a>';
|
$post .= PHP_EOL . '<a href="' . $link . '">Подробнее</a>';
|
||||||
|
|
||||||
|
|
||||||
$telegram = new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN);
|
$telegram = new \Core\ExternalServices\TelegramSender(SystemConfig::getValue('TELEGRAM_BOT_TOKEN'));
|
||||||
$telegram->setChat('-1001789206618');
|
$telegram->setChat('-1001789206618');
|
||||||
$res = $telegram->sendPhoto($tmpFile, $post);
|
$res = $telegram->sendPhoto($tmpFile, $post);
|
||||||
sendTelegram($post);
|
sendTelegram($post);
|
||||||
|
|||||||
@@ -62,6 +62,11 @@
|
|||||||
*/
|
*/
|
||||||
const USER_ROLE_ID = 5;
|
const USER_ROLE_ID = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Роль "уведомления о событиях"
|
||||||
|
*/
|
||||||
|
const ALARM_ROLE_ID = 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var User $user
|
* @var User $user
|
||||||
*/
|
*/
|
||||||
@@ -125,7 +130,7 @@
|
|||||||
* @return int|null
|
* @return int|null
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public function deleteRole(int $roleId): ?int
|
public function delete(int $roleId): ?int
|
||||||
{
|
{
|
||||||
$cacheId = md5(__CLASS__ . '::' . __FUNCTION__);
|
$cacheId = md5(__CLASS__ . '::' . __FUNCTION__);
|
||||||
Cache::delete($cacheId);
|
Cache::delete($cacheId);
|
||||||
@@ -135,21 +140,6 @@
|
|||||||
return $DB->query('DELETE FROM ' . self::USER_ROLES_TABLE . ' WHERE user_id=' . $this->user->getId() . ' AND role_id=' . $roleId);
|
return $DB->query('DELETE FROM ' . self::USER_ROLES_TABLE . ' WHERE user_id=' . $this->user->getId() . ' AND role_id=' . $roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Получение полной информации о ролях пользователя
|
|
||||||
*
|
|
||||||
* @deprecated Реализован новый метод для получения этих данных
|
|
||||||
* @return array|null
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
public function getFullRolesOld(): ?array
|
|
||||||
{
|
|
||||||
return array_map(function ($element) {
|
|
||||||
return static::getAllRoles()[$element];
|
|
||||||
},
|
|
||||||
$this->getRoles());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получение полной информации о ролях пользователя V2
|
* Получение полной информации о ролях пользователя V2
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
use Core\CoreException;
|
use Core\CoreException;
|
||||||
use Core\Helpers\{Cache, Log, Mail, Sanitize, SystemFunctions};
|
use Core\Helpers\{Cache, Log, Mail, Sanitize, SystemFunctions};
|
||||||
use Core\DataBases\DB;
|
use Core\DataBases\DB;
|
||||||
|
use Core\DTO\User\FilterUser;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class User
|
class User
|
||||||
@@ -720,12 +721,12 @@
|
|||||||
*/
|
*/
|
||||||
public static function logout(): void
|
public static function logout(): void
|
||||||
{
|
{
|
||||||
$_SESSION['id'] = '';
|
unset($_SESSION['id']);
|
||||||
$_SESSION['authorize'] = '';
|
unset($_SESSION['authorize']);
|
||||||
$_SESSION['login'] = '';
|
unset($_SESSION['login']);
|
||||||
$_SESSION['password'] = '';
|
unset($_SESSION['password']);
|
||||||
$_SESSION['token'] = '';
|
unset($_SESSION['token']);
|
||||||
$_SESSION['user'] = '';
|
unset($_SESSION['user']);
|
||||||
|
|
||||||
setcookie('userId', '', time() - 3600);
|
setcookie('userId', '', time() - 3600);
|
||||||
setcookie('userLogin', '', time() - 3600);
|
setcookie('userLogin', '', time() - 3600);
|
||||||
@@ -801,6 +802,26 @@
|
|||||||
return SystemFunctions::arrayToXml($res, self::TABLE);
|
return SystemFunctions::arrayToXml($res, self::TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Выборка пользователей по роли
|
||||||
|
*
|
||||||
|
* @param int $roleId Идентификатор роли
|
||||||
|
*
|
||||||
|
* @return self[]
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public static function getListByRole(int $roleId): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
/** @var $DB DB Объект базы данных */
|
||||||
|
$DB = DB::getInstance();
|
||||||
|
$res = $DB->getItems(Roles::USER_ROLES_TABLE, ['id' => $roleId]);
|
||||||
|
foreach ($res as $element) {
|
||||||
|
$result[] = new self((int)$element['user_id']);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Проверка электронной почты на подтвержденность
|
* Проверка электронной почты на подтвержденность
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Core\Models;
|
namespace Core\Models;
|
||||||
|
|
||||||
|
use Core\CoreException;
|
||||||
use Core\DataBases\DB;
|
use Core\DataBases\DB;
|
||||||
use Core\Helpers\Cache;
|
use Core\Helpers\Cache;
|
||||||
|
|
||||||
@@ -123,4 +124,18 @@
|
|||||||
$DB = DB::getInstance();
|
$DB = DB::getInstance();
|
||||||
$DB->query('DELETE FROM ' . self::TABLE . ' WHERE user_id=' . $this->user->getId() . ' AND id="' . $id . '"');
|
$DB->query('DELETE FROM ' . self::TABLE . ' WHERE user_id=' . $this->user->getId() . ' AND id="' . $id . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить список мета данных по фильтру
|
||||||
|
*
|
||||||
|
* @param array $params Параметры
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public static function getListByParams(array $params = []): ?array {
|
||||||
|
/** @var $DB DB */
|
||||||
|
$DB = DB::getInstance();
|
||||||
|
return $DB->getItems(self::TABLE, $params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс для работы с пользователями
|
* Модель пользователя
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Core\Models;
|
namespace Core\Models;
|
||||||
@@ -36,6 +36,15 @@
|
|||||||
/** @var string Имя */
|
/** @var string Имя */
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
|
/** @var string $login Логин */
|
||||||
|
protected $login;
|
||||||
|
|
||||||
|
/** @var int $image_id Идентификатор картинки */
|
||||||
|
protected $image_id;
|
||||||
|
|
||||||
|
/** @var string $token Токен */
|
||||||
|
protected $token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить имя
|
* Получить имя
|
||||||
*
|
*
|
||||||
@@ -59,4 +68,28 @@
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить идентификатор изображения
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getImageId(): ?int
|
||||||
|
{
|
||||||
|
return $this->image_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Установить идентификатор изображения
|
||||||
|
*
|
||||||
|
* @param int $id Идентификатор изображения
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setImageId(int $id): self
|
||||||
|
{
|
||||||
|
$this->image_id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2023 Roman Grinko <rsgrinko@gmail.com>
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Класс системных параметров
|
||||||
|
*/
|
||||||
|
class SystemConfig {
|
||||||
|
public static function getValue(string $param)
|
||||||
|
{
|
||||||
|
// TODO в текущей реализации берем просто заданную константу, в дальнейшем переделать
|
||||||
|
return constant($param);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,11 @@
|
|||||||
|
|
||||||
use Core\Models\MQ;
|
use Core\Models\MQ;
|
||||||
$fromPostId = $argv[1];
|
$fromPostId = $argv[1];
|
||||||
//sleep(5);
|
|
||||||
|
|
||||||
(new MQ())->setPriority(9)->setAttempts(3)->createTask('Core\MQTasks', 'getStory', [$fromPostId]);
|
(new MQ())->setPriority(9)
|
||||||
|
->setAttempts(2)
|
||||||
|
->createTask(
|
||||||
|
'Core\MQTasks',
|
||||||
|
'getStory',
|
||||||
|
[$fromPostId]
|
||||||
|
);
|
||||||
@@ -41,6 +41,12 @@ final class Roles extends AbstractMigration
|
|||||||
'date_created' => date('Y-m-d H:i:s'),
|
'date_created' => date('Y-m-d H:i:s'),
|
||||||
'date_updated' => null,
|
'date_updated' => null,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Уведомления о событиях',
|
||||||
|
'description' => 'Роль для рассылок уведомлений о сбоях в работе проекта',
|
||||||
|
'date_created' => date('Y-m-d H:i:s'),
|
||||||
|
'date_updated' => null,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
use Core\CoreException;
|
use Core\CoreException;
|
||||||
use Core\ExternalServices\Telegram2;
|
use Core\ExternalServices\Telegram2;
|
||||||
use Core\ExternalServices\ChatGPT;
|
use Core\ExternalServices\ChatGPT;
|
||||||
|
use Core\SystemConfig;
|
||||||
|
|
||||||
require_once __DIR__ . '/core/bootstrap.php';
|
require_once __DIR__ . '/core/bootstrap.php';
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
|
|
||||||
|
|
||||||
$tg = new Telegram2(TELEGRAM_BOT_TOKEN);
|
$tg = new Telegram2(SystemConfig::getValue('TELEGRAM_BOT_TOKEN'));
|
||||||
$tg->setRemoteRequest($data);
|
$tg->setRemoteRequest($data);
|
||||||
|
|
||||||
$gptObject = new ChatGPT();
|
$gptObject = new ChatGPT();
|
||||||
|
|||||||
+20
-1
@@ -3,12 +3,31 @@
|
|||||||
{% block main %}
|
{% block main %}
|
||||||
<h1>Авторизация</h1>
|
<h1>Авторизация</h1>
|
||||||
{% if failed %}
|
{% if failed %}
|
||||||
<div class="alert alert-error">Ошибка авторизации</div>
|
<div class="alert alert-error">{{ errorMessage }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>
|
<p>
|
||||||
<form action="/login/authorize" method="POST">
|
<form action="/login/authorize" method="POST">
|
||||||
<input class="input" type="text" name="login" placeholder="Введите логин">
|
<input class="input" type="text" name="login" placeholder="Введите логин">
|
||||||
<input class="input" type="password" name="password" placeholder="Введите пароль">
|
<input class="input" type="password" name="password" placeholder="Введите пароль">
|
||||||
|
|
||||||
|
{% if USE_CAPTCHA %}
|
||||||
|
<div class="input captchaInput">
|
||||||
|
<img id="captchaCode" src="{{ SITE_URL }}/core/captcha.php">
|
||||||
|
<span id="updateCaptcha" class="button" style="vertical-align: super;">Обновить код</span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="input" name="captchaCode" placeholder="Код с картинки">
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
let $captchaImage = $('#captchaCode'),
|
||||||
|
$captchaSrc = $captchaImage.attr('src'),
|
||||||
|
$updateBtn = $('#updateCaptcha');
|
||||||
|
$updateBtn.click(function () {
|
||||||
|
$captchaImage.attr('src', $captchaSrc + `?v=${new Date().getTime()}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<button class="button w100" type="submit">Войти</button>
|
<button class="button w100" type="submit">Войти</button>
|
||||||
</form>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in new issue
Block a user