добавлена лицензия в PHP файлы

This commit is contained in:
rsgrinko committed 2022-07-15 00:29:53 +03:00
1 parent 4f1275727b
commit f99506e117
52 files changed
+1166 -139

No files matched your search

+21 -1
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\MQ; use Core\Models\MQ;
@@ -166,7 +185,8 @@
ob_start(); ob_start();
?> ?>
<div class="progress"> <div class="progress">
<div style="width: <?=round(($MQ->getCountWorkers() / MQ::WORKERS_LIMIT)*100, 2);?>%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="40" role="progressbar" class="progress-bar progress-bar-warning"> <div style="width: <?= round(($MQ->getCountWorkers() / MQ::WORKERS_LIMIT) * 100, 2); ?>%" aria-valuemax="100" aria-valuemin="0"
aria-valuenow="40" role="progressbar" class="progress-bar progress-bar-warning">
<span class="sr-only">40% Complete (success)</span> <span class="sr-only">40% Complete (success)</span>
</div> </div>
</div> </div>
+31 -4
View File
@@ -1,5 +1,26 @@
<?php <?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.
*/
use Core\Helpers\{Cache, SystemFunctions}; use Core\Helpers\{Cache, SystemFunctions};
require_once __DIR__ . '/inc/header.php'; require_once __DIR__ . '/inc/header.php';
?> ?>
<div class="pageheader"> <div class="pageheader">
@@ -38,11 +59,17 @@
$arCacheInfo = Cache::getCacheInfo(); $arCacheInfo = Cache::getCacheInfo();
?> ?>
<tr> <tr>
<td><?=$arCacheInfo['countAll'] . ' ' . SystemFunctions::numWord($arCacheInfo['countAll'], ['раз', 'раза', 'раз']);?></td> <td><?= $arCacheInfo['countAll'] . ' ' . SystemFunctions::numWord($arCacheInfo['countAll'], ['раз', 'раза', 'раз']
<td><?=$arCacheInfo['countWrite'] . ' ' . SystemFunctions::numWord($arCacheInfo['countWrite'], ['раз', 'раза', 'раз']);?></td> ); ?></td>
<td><?=$arCacheInfo['countRead'] . ' ' . SystemFunctions::numWord($arCacheInfo['countRead'], ['раз', 'раза', 'раз']);?></td> <td><?= $arCacheInfo['countWrite'] . ' ' . SystemFunctions::numWord($arCacheInfo['countWrite'], ['раз', 'раза', 'раз']
); ?></td>
<td><?= $arCacheInfo['countRead'] . ' ' . SystemFunctions::numWord($arCacheInfo['countRead'], ['раз', 'раза', 'раз']
); ?></td>
<td><?= $arCacheInfo['cacheDir']; ?></td> <td><?= $arCacheInfo['cacheDir']; ?></td>
<td><?=$arCacheInfo['cachedCount'] . ' ' . SystemFunctions::numWord($arCacheInfo['cachedCount'], ['элемент', 'элемента', 'элементов']);?></td> <td><?= $arCacheInfo['cachedCount'] . ' ' . SystemFunctions::numWord(
$arCacheInfo['cachedCount'],
['элемент', 'элемента', 'элементов']
); ?></td>
<td><?= SystemFunctions::convertBytes($arCacheInfo['size']); ?></td> <td><?= SystemFunctions::convertBytes($arCacheInfo['size']); ?></td>
</tr> </tr>
</tbody> </tbody>
+21
View File
@@ -1,5 +1,26 @@
<?php <?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.
*/
use Core\Models\{User, Roles}; use Core\Models\{User, Roles};
require_once __DIR__ . '/inc/header.php'; require_once __DIR__ . '/inc/header.php';
?> ?>
<div class="pageheader"> <div class="pageheader">
+20
View File
@@ -1,4 +1,24 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
require_once __DIR__ . '/../../core/bootstrap.php'; require_once __DIR__ . '/../../core/bootstrap.php';
+21
View File
@@ -1,4 +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.
*/
?>
</div> </div>
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
+25 -2
View File
@@ -1,4 +1,26 @@
<?php require_once __DIR__ . '/inc/header.php'; ?> <?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 __DIR__ . '/inc/header.php';
?>
<div class="pageheader"> <div class="pageheader">
<div class="media"> <div class="media">
<div class="pageicon pull-left"> <div class="pageicon pull-left">
@@ -19,4 +41,5 @@
типа статистика или хз типа статистика или хз
</div><!-- contentpanel --> </div><!-- contentpanel -->
<?php require_once __DIR__ . '/inc/footer.php'; ?> <?php
require_once __DIR__ . '/inc/footer.php';
+19 -1
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
@@ -9,7 +28,6 @@
} else { } else {
$auth = false; $auth = false;
if (!empty($_REQUEST['login'] && !empty($_REQUEST['pass']))) { if (!empty($_REQUEST['login'] && !empty($_REQUEST['pass']))) {
if (User::securityAuthorize( if (User::securityAuthorize(
$_REQUEST['login'], $_REQUEST['login'],
$_REQUEST['pass'], $_REQUEST['pass'],
+21
View File
@@ -1,5 +1,26 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
require_once __DIR__ . '/inc/bootstrap.php'; require_once __DIR__ . '/inc/bootstrap.php';
User::logout(); User::logout();
header('Location: index.php'); header('Location: index.php');
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\{User, Roles}; use Core\Models\{User, Roles};
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\{User, MQ}; use Core\Models\{User, MQ};
+19 -2
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
@@ -8,7 +27,6 @@ if (User::isAuthorized()) {
} else { } else {
$arErrors = []; $arErrors = [];
if (!empty($_REQUEST['send']) && $_REQUEST['send'] === 'Y') { if (!empty($_REQUEST['send']) && $_REQUEST['send'] === 'Y') {
if (empty($_REQUEST['login'])) { if (empty($_REQUEST['login'])) {
$arErrors[] = 'Логин не задан'; $arErrors[] = 'Логин не задан';
} }
@@ -31,7 +49,6 @@ if (User::isAuthorized()) {
User::authorize($userId); User::authorize($userId);
header('Location: index.php'); header('Location: index.php');
} }
} }
+23 -3
View File
@@ -1,4 +1,24 @@
<?php <?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.
*/
use Core\Models\{User, MQ}; use Core\Models\{User, MQ};
require_once __DIR__ . '/inc/header.php'; require_once __DIR__ . '/inc/header.php';
@@ -51,7 +71,6 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@@ -109,8 +128,8 @@
</div><!-- contentpanel --> </div><!-- contentpanel -->
<script> <script>
var isPaused = false; var isPaused = false;
function update()
{ function update() {
isPaused = true; isPaused = true;
$.ajax({ $.ajax({
url: 'ajax/threads.php', url: 'ajax/threads.php',
@@ -127,6 +146,7 @@
} }
}); });
} }
$(document).ready(function () { $(document).ready(function () {
update(); update();
setInterval(function () { setInterval(function () {
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
+21 -7
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\Models\User; use Core\Models\User;
use Core\Helpers\Cache; use Core\Helpers\Cache;
@@ -107,16 +126,11 @@
// 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)) (new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendMessage($message);
->setChat(TELEGRAM_NOTIFICATION_CHANNEL)
->sendMessage($message);
if (!empty($file)) { if (!empty($file)) {
(new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN)) (new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendDocument($file);
->setChat(TELEGRAM_NOTIFICATION_CHANNEL)
->sendDocument($file);
} }
} }
//end debug //end debug
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
/** /**
* Версия сервиса * Версия сервиса
+22 -4
View File
@@ -1,6 +1,27 @@
<?php <?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); @ignore_user_abort(true);
set_time_limit(0); set_time_limit(0);
use Core\Helpers\Cache; use Core\Helpers\Cache;
use Core\Models\MQ; use Core\Models\MQ;
@@ -27,8 +48,5 @@
} }
if ($runMyslo === true) { if ($runMyslo === true) {
$result = (new MQ())->setAttempts(3) $result = (new MQ())->setAttempts(3)->setPriority(3)->setCheckDuplicates(true)->createTask('Core\MQTasks', 'getMySLO');
->setPriority(3)
->setCheckDuplicates(true)
->createTask('Core\MQTasks', 'getMySLO');
} }
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core; namespace Core;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core; namespace Core;
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\ExternalServices; namespace Core\ExternalServices;
@@ -1,4 +1,24 @@
<?php <?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.
*/
/** /**
* Класс для работы с API телеграмм * Класс для работы с API телеграмм
* Поддерживает: * Поддерживает:
@@ -1,7 +1,26 @@
<?php <?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.
*/
/** /**
* Класс-обработчик команд Telegram * Класс-обработчик команд Telegram
*
* Поддерживает: * Поддерживает:
* - работа с простыми командами * - работа с простыми командами
* - выделение аргументов команды * - выделение аргументов команды
@@ -93,7 +112,8 @@ class TelegramActions
} elseif (!empty($data[self::$messageType]['contact'])) { } elseif (!empty($data[self::$messageType]['contact'])) {
self::$eventType = 'contact'; self::$eventType = 'contact';
self::$event['phone_number'] = $data[self::$messageType]['contact']['phone_number']; self::$event['phone_number'] = $data[self::$messageType]['contact']['phone_number'];
self::$event['name'] = $data[self::$messageType]['contact']['first_name'] . ' ' . $data['message']['contact']['last_name']; self::$event['name'] = $data[self::$messageType]['contact']['first_name'] . ' '
. $data['message']['contact']['last_name'];
} elseif (!empty($data[self::$messageType]['location'])) { } elseif (!empty($data[self::$messageType]['location'])) {
self::$eventType = 'location'; self::$eventType = 'location';
self::$event['latitude'] = $data[self::$messageType]['location']['latitude']; self::$event['latitude'] = $data[self::$messageType]['location']['latitude'];
@@ -131,7 +151,6 @@ class TelegramActions
if (!empty($arParams)) { if (!empty($arParams)) {
self::$params = implode(' ', $arParams); self::$params = implode(' ', $arParams);
} }
} elseif (!empty($data) && isset($data['callback_query']['from']['id']) and $data['callback_query']['from']['id'] !== '') { } elseif (!empty($data) && isset($data['callback_query']['from']['id']) and $data['callback_query']['from']['id'] !== '') {
self::$eventType = 'callback'; self::$eventType = 'callback';
self::$event['callback_id'] = self::$chatId = (int)$data['callback_query']['id']; // идентификатор callback self::$event['callback_id'] = self::$chatId = (int)$data['callback_query']['id']; // идентификатор callback
@@ -141,7 +160,10 @@ class TelegramActions
self::$event['first_name'] = $data['callback_query']['from']['first_name']; // имя собеседника self::$event['first_name'] = $data['callback_query']['from']['first_name']; // имя собеседника
self::$event['last_name'] = $data['callback_query']['from']['last_name']; // фамилию собеседника self::$event['last_name'] = $data['callback_query']['from']['last_name']; // фамилию собеседника
self::$event['chat_time'] = $data['callback_query']['message']['date']; // дата сообщения self::$event['chat_time'] = $data['callback_query']['message']['date']; // дата сообщения
self::$event['data'] = json_decode($data['callback_query']['data'], true); // Содержимое callback запроса self::$event['data'] = json_decode(
$data['callback_query']['data'],
true
); // Содержимое callback запроса
self::$cmd = self::$event['data']['method']; self::$cmd = self::$event['data']['method'];
} else { } else {
self::$eventType = null; self::$eventType = null;
@@ -204,6 +226,7 @@ class TelegramActions
* *
* @param string $name Имя метода * @param string $name Имя метода
* @param ?array $arguments Массив аргументов метода * @param ?array $arguments Массив аргументов метода
*
* @return void * @return void
*/ */
public static function __callStatic(string $name, ?array $arguments): void public static function __callStatic(string $name, ?array $arguments): void
@@ -269,7 +292,7 @@ class TelegramActions
['/online', '/yastat'], ['/online', '/yastat'],
['/fail2ban', '/stat'], ['/fail2ban', '/stat'],
['/getcam', '/clearcache'], ['/getcam', '/clearcache'],
['/deploy'] ['/deploy'],
]; ];
} }
@@ -359,7 +382,13 @@ class TelegramActions
public static function commandTest(): void public static function commandTest(): void
{ {
Telegram::sendChatAction(self::getChatId()); // печатает... Telegram::sendChatAction(self::getChatId()); // печатает...
Telegram::execute(self::getChatId(), 'Запущена команда test, переданы аргумент: ' . self::getParams(), '', self::getInlineKeyboard(), self::getKeyboard()); Telegram::execute(
self::getChatId(),
'Запущена команда test, переданы аргумент: ' . self::getParams(),
'',
self::getInlineKeyboard(),
self::getKeyboard()
);
} }
/** /**
@@ -374,21 +403,17 @@ class TelegramActions
$message = '<b>Посетители онлайн (' . count($result) . ')</b>' . PHP_EOL; $message = '<b>Посетители онлайн (' . count($result) . ')</b>' . PHP_EOL;
foreach ($result as $key => $item) { foreach ($result as $key => $item) {
$message .= '✔ <b>Пользователь #' . ($key + 1) . '</b> ' $message .= '✔ <b>Пользователь #' . ($key + 1) . '</b> ' . PHP_EOL . '<b>IP:</b> ' . $item['ip'] . PHP_EOL . '<b>Страница:</b> <code>'
. PHP_EOL . $item['page'] . '</code>' . PHP_EOL . '<b>Referer:</b> <code>' . (!empty(
. '<b>IP:</b> ' . $item['ip'] trim(
. PHP_EOL $item['referer']
. '<b>Страница:</b> <code>' . $item['page'] . '</code>' )
. PHP_EOL ) ? SystemFunctions::getBaseUrl($item['referer']) : 'нет') . '</code>' . PHP_EOL . '<b>Бот:</b> ' . (SystemFunctions::isSearchBot(
. '<b>Referer:</b> <code>' . (!empty(trim($item['referer'])) ? SystemFunctions::getBaseUrl($item['referer']) : 'нет') . '</code>' $item['useragent']
. PHP_EOL ) ?? 'нет') . PHP_EOL . '<b>Последняя активность:</b> ' . SystemFunctions::secToString(time() - (int)$item['last_active'])
. '<b>Бот:</b> ' . (SystemFunctions::isSearchBot($item['useragent']) ?? 'нет') . PHP_EOL . '<b>Геозона:</b> ' . SystemFunctions::gluingLocationToString(
. PHP_EOL ['country' => $item['country'], 'region' => $item['region'], 'city' => $item['city']]
. '<b>Последняя активность:</b> ' . SystemFunctions::secToString(time() - (int)$item['last_active']) ) . PHP_EOL . PHP_EOL;
. PHP_EOL
. '<b>Геозона:</b> ' . SystemFunctions::gluingLocationToString(['country' => $item['country'], 'region' => $item['region'], 'city' => $item['city']])
. PHP_EOL
. PHP_EOL;
} }
Telegram::sendChatAction(self::getChatId()); // печатает... Telegram::sendChatAction(self::getChatId()); // печатает...
Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard()); Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard());
@@ -405,15 +430,11 @@ class TelegramActions
$message = '<b>Список заблокированных IP (' . Fail2ban::getBlockedIpCount() . ' из ' . Fail2ban::getAllIpCount() . ')</b>' . PHP_EOL; $message = '<b>Список заблокированных IP (' . Fail2ban::getBlockedIpCount() . ' из ' . Fail2ban::getAllIpCount() . ')</b>' . PHP_EOL;
foreach ($result as $key => $item) { foreach ($result as $key => $item) {
$message .= '🚩 <b> ' . $item['ip'] . '</b> ' $message .= '🚩 <b> ' . $item['ip'] . '</b> ' . PHP_EOL . '<b>Попыток:</b> ' . $item['attempts'] . PHP_EOL . '<b>Активность:</b> '
. PHP_EOL . SystemFunctions::secToString(time() - $item['last_active']) . PHP_EOL . '<b>Геозона:</b> '
. '<b>Попыток:</b> ' . $item['attempts'] . SystemFunctions::gluingLocationToString(
. PHP_EOL ['country' => $item['country'], 'region' => $item['region'], 'city' => $item['city']]
. '<b>Активность:</b> ' . SystemFunctions::secToString(time() - $item['last_active']) ) . PHP_EOL . PHP_EOL;
. PHP_EOL
. '<b>Геозона:</b> ' . SystemFunctions::gluingLocationToString(['country' => $item['country'], 'region' => $item['region'], 'city' => $item['city']])
. PHP_EOL
. PHP_EOL;
} }
Telegram::sendChatAction(self::getChatId()); // печатает... Telegram::sendChatAction(self::getChatId()); // печатает...
Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard()); Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard());
@@ -443,9 +464,10 @@ class TelegramActions
[ [
[ [
['text' => 'Очистка кэша', 'callback_data' => self::getPreparedCallbackData('clearcache')], ['text' => 'Очистка кэша', 'callback_data' => self::getPreparedCallbackData('clearcache')],
['text' => 'Сброс Opcache', 'callback_data' => self::getPreparedCallbackData('clearopcache')] ['text' => 'Сброс Opcache', 'callback_data' => self::getPreparedCallbackData('clearopcache')],
],
] ]
]); );
$countCacheElements = \FCCache::getCountElements(); $countCacheElements = \FCCache::getCountElements();
$cacheSize = \FCCache::getCacheSize(); $cacheSize = \FCCache::getCacheSize();
@@ -454,25 +476,23 @@ class TelegramActions
$countAllIp = Fail2ban::getAllIpCount(); $countAllIp = Fail2ban::getAllIpCount();
$arOpcache = opcache_get_status(); $arOpcache = opcache_get_status();
$message = '📱 <b>Статистика по проекту</b>' $message = '📱 <b>Статистика по проекту</b>' . PHP_EOL . '<b>В кэше:</b> ' . $countCacheElements . ' ' . SystemFunctions::numWord(
. PHP_EOL $countCacheElements,
. '<b>В кэше:</b> ' . $countCacheElements . ' ' . SystemFunctions::numWord($countCacheElements, ['элемент', 'элемента', 'элементов']) ['элемент', 'элемента', 'элементов']
. PHP_EOL ) . PHP_EOL . '<b>Размер кэша:</b> ' . SystemFunctions::convertBytes($cacheSize) . PHP_EOL . '<b>В Opcache:</b> '
. '<b>Размер кэша:</b> ' . SystemFunctions::convertBytes($cacheSize) . $arOpcache['opcache_statistics']['num_cached_scripts'] . ' ' . SystemFunctions::numWord(
. PHP_EOL $arOpcache['opcache_statistics']['num_cached_scripts'],
. '<b>В Opcache:</b> ' . $arOpcache['opcache_statistics']['num_cached_scripts'] . ' ' . SystemFunctions::numWord($arOpcache['opcache_statistics']['num_cached_scripts'], ['элемент', 'элемента', 'элементов']) ['элемент', 'элемента', 'элементов']
. PHP_EOL ) . PHP_EOL . '<b>Opcache (используется):</b> ' . SystemFunctions::convertBytes($arOpcache['memory_usage']['used_memory']) . PHP_EOL
. '<b>Opcache (используется):</b> ' . SystemFunctions::convertBytes($arOpcache['memory_usage']['used_memory']) . '<b>Opcache (свободно):</b> ' . SystemFunctions::convertBytes($arOpcache['memory_usage']['free_memory']) . PHP_EOL
. PHP_EOL . '<b>Opcache (битая):</b> ' . SystemFunctions::convertBytes($arOpcache['memory_usage']['wasted_memory']) . PHP_EOL
. '<b>Opcache (свободно):</b> ' . SystemFunctions::convertBytes($arOpcache['memory_usage']['free_memory']) . '<b>Opcache (всего):</b> 512Mb' . PHP_EOL . '<b>Онлайн на сайте:</b> ' . $usersOnline . ' ' . SystemFunctions::numWord(
. PHP_EOL $usersOnline,
. '<b>Opcache (битая):</b> ' . SystemFunctions::convertBytes($arOpcache['memory_usage']['wasted_memory']) ['посетитель', 'посетителя', 'посетителей']
. PHP_EOL ) . PHP_EOL . '<b>Заблокировано:</b> ' . $countBlockedIp . ' ' . SystemFunctions::numWord(
. '<b>Opcache (всего):</b> 512Mb' $countBlockedIp,
. PHP_EOL ['адрес', 'адреса', 'адресов']
. '<b>Онлайн на сайте:</b> ' . $usersOnline . ' ' . SystemFunctions::numWord($usersOnline, ['посетитель', 'посетителя', 'посетителей']) ) . ' из ' . $countAllIp;
. PHP_EOL
. '<b>Заблокировано:</b> ' . $countBlockedIp . ' ' . SystemFunctions::numWord($countBlockedIp, ['адрес', 'адреса', 'адресов']) . ' из ' . $countAllIp;
Telegram::sendChatAction(self::getChatId()); // печатает... Telegram::sendChatAction(self::getChatId()); // печатает...
Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard()); Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard());
} }
@@ -484,11 +504,8 @@ class TelegramActions
*/ */
public static function commandYaStat(): void public static function commandYaStat(): void
{ {
$objectYandex = new Yandex( $objectYandex = new Yandex(
YANDEX_APP_ID, YANDEX_APP_ID, YANDEX_APP_SECRET, YANDEX_REDIRECT_URL
YANDEX_APP_SECRET,
YANDEX_REDIRECT_URL
); );
$objectYandex->loadConfig()->refreshToken(); $objectYandex->loadConfig()->refreshToken();
$objectYandex->save(); $objectYandex->save();
@@ -501,14 +518,15 @@ class TelegramActions
'entity_field' => 'page_level', 'entity_field' => 'page_level',
'field' => 'partner_wo_nds', 'field' => 'partner_wo_nds',
'lang' => 'ru', 'lang' => 'ru',
'pretty' => '0' 'pretty' => '0',
]; ];
$result = $objectYandex->request( $result = $objectYandex->request(
'partner2.yandex.ru', 'partner2.yandex.ru',
'api/statistics2/get.json', 'api/statistics2/get.json',
$query); $query
);
$day_price = []; $day_price = [];
@@ -530,10 +548,8 @@ class TelegramActions
$day_price['today'] = $day_price['today'] ?? '0'; $day_price['today'] = $day_price['today'] ?? '0';
$day_price['yesterday'] = $day_price['yesterday'] ?? '0'; $day_price['yesterday'] = $day_price['yesterday'] ?? '0';
$message = '<b>Статистика РСЯ</b>' . PHP_EOL $message = '<b>Статистика РСЯ</b>' . PHP_EOL . 'Доход за сегодня: ' . $day_price['today'] . ' р.' . PHP_EOL . 'Доход за вчера: '
. 'Доход за сегодня: ' . $day_price['today'] . ' р.' . PHP_EOL . $day_price['yesterday'] . ' р.' . PHP_EOL . 'Курс доллара: ' . SystemFunctions::getExchangeRates('USD', 2) . ' р.';
. 'Доход за вчера: ' . $day_price['yesterday'] . ' р.' . PHP_EOL
. 'Курс доллара: ' . SystemFunctions::getExchangeRates('USD', 2) . ' р.';
Telegram::sendChatAction(self::getChatId()); // печатает... Telegram::sendChatAction(self::getChatId()); // печатает...
Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard()); Telegram::execute(self::getChatId(), $message, '', self::getInlineKeyboard(), self::getKeyboard());
} }
@@ -547,7 +563,13 @@ class TelegramActions
{ {
$image = SystemFunctions::getCamScreen(); $image = SystemFunctions::getCamScreen();
Telegram::sendChatAction(self::getChatId()); // печатает... Telegram::sendChatAction(self::getChatId()); // печатает...
Telegram::execute(self::getChatId(), 'Снимок сделан ' . date('d.m.Y H:i:s', strtotime('+3 hours')), $image, self::getInlineKeyboard(), self::getKeyboard()); Telegram::execute(
self::getChatId(),
'Снимок сделан ' . date('d.m.Y H:i:s', strtotime('+3 hours')),
$image,
self::getInlineKeyboard(),
self::getKeyboard()
);
} }
/** /**
@@ -1,4 +1,24 @@
<?php <?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.
*/
/** /**
* Класс для работы с API телеграмм (не-статический) * Класс для работы с API телеграмм (не-статический)
* *
+22 -2
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
@@ -178,7 +197,7 @@
* *
* @return bool Флаг успеха * @return bool Флаг успеха
*/ */
public static function del(string $name): bool public static function delete(string $name): bool
{ {
if (self::check($name)) { if (self::check($name)) {
if (!unlink(self::$cacheDir . md5($name) . '.tmp')) { if (!unlink(self::$cacheDir . md5($name) . '.tmp')) {
@@ -214,8 +233,9 @@
{ {
$return_size = 0; $return_size = 0;
foreach (scandir(self::$cacheDir) as $file) { foreach (scandir(self::$cacheDir) as $file) {
if ($file == '.' or $file == '..') if ($file == '.' or $file == '..') {
continue; continue;
}
$return_size = $return_size + filesize(self::$cacheDir . $file); $return_size = $return_size + filesize(self::$cacheDir . $file);
} }
return $return_size; return $return_size;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
/** /**
* Работа с файлами и директориями. * Работа с файлами и директориями.
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
+29 -4
View File
@@ -1,11 +1,34 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
class Pagination class Pagination
{ {
private static $page; private static $page;
private static $total; private static $total;
private static $total_pages; private static $total_pages;
private static $limit; private static $limit;
/** /**
@@ -40,7 +63,6 @@ class Pagination
$limit = $start . ', ' . self::$limit; $limit = $start . ', ' . self::$limit;
return $limit; return $limit;
} }
/** /**
@@ -57,15 +79,18 @@ class Pagination
} }
if (self::$page != 1) { if (self::$page != 1) {
$prevPage = '<li class="page-item active"><a class="page-link" href="' . $url . $paginator_name . '=' . (self::$page - 1) . '">‹</a></li>'; $prevPage = '<li class="page-item active"><a class="page-link" href="' . $url . $paginator_name . '=' . (self::$page - 1)
. '">‹</a></li>';
} else { } else {
$prevPage = '<li class="page-item"><span class="page-link">‹</span></li>'; $prevPage = '<li class="page-item"><span class="page-link">‹</span></li>';
} }
if (self::$page != self::$total_pages) { if (self::$page != self::$total_pages) {
$nextPage = '<li class="page-item active"><a class="page-link" href="' . $url . $paginator_name . '=' . (self::$page + 1) . '">›</a></li>'; $nextPage = '<li class="page-item active"><a class="page-link" href="' . $url . $paginator_name . '=' . (self::$page + 1)
. '">›</a></li>';
} else { } else {
$nextPage = '<li class="page-item"><span class="page-link">›</span></li>'; $nextPage = '<li class="page-item"><span class="page-link">›</span></li>';
} }
echo '<ul class="pagination">'.$prevPage.'<li class="page-item"><a class="page-link" href="#">' . self::$page . ' из ' . self::$total_pages . '</a></li>'.$nextPage.'</ul>'; echo '<ul class="pagination">' . $prevPage . '<li class="page-item"><a class="page-link" href="#">' . self::$page . ' из '
. self::$total_pages . '</a></li>' . $nextPage . '</ul>';
} }
} }
+20
View File
@@ -1,4 +1,24 @@
<?php <?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.
*/
/** /**
* Класс реестра * Класс реестра
*/ */
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
@@ -640,7 +659,10 @@
$rootData = ' object="' . $objectName . '"'; $rootData = ' object="' . $objectName . '"';
} }
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><DeltaCore version="' . CORE_VERSION . '"' . $rootData . ' date="' . date('d.m.Y H:i:s') . '"/>'); $xml = new \SimpleXMLElement(
'<?xml version="1.0" encoding="UTF-8"?><DeltaCore version="' . CORE_VERSION . '"' . $rootData . ' date="' . date('d.m.Y H:i:s')
. '"/>'
);
static::arrayToXmlHelper($arData, $xml); static::arrayToXmlHelper($arData, $xml);
$dom = dom_import_simplexml($xml)->ownerDocument; $dom = dom_import_simplexml($xml)->ownerDocument;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Helpers; namespace Core\Helpers;
+20 -4
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core; namespace Core;
@@ -138,9 +157,7 @@
if ($res) { if ($res) {
$j++; $j++;
$DB->update( $DB->update(
'bashorg', 'bashorg', ['hash' => $hash], ['ext_id' => (int)$element['id'], 'date' => $element['date'], 'rating' => $element['rating']]
['hash' => $hash],
['ext_id' => (int)$element['id'], 'date' => $element['date'], 'rating' => $element['rating']]
); );
} }
} }
@@ -257,7 +274,6 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
$link = 'https://myslo.ru' . trim($link[1][0]); $link = 'https://myslo.ru' . trim($link[1][0]);
if ($oldLink !== $link) { if ($oldLink !== $link) {
sendTelegram('OLD (' . strlen($oldLink) . '): ' . $oldLink . PHP_EOL . 'NEW (' . strlen($link) . '): ' . $link); sendTelegram('OLD (' . strlen($oldLink) . '): ' . $oldLink . PHP_EOL . 'NEW (' . strlen($link) . '): ' . $link);
sendTelegram('Обнаружен новый пост'); sendTelegram('Обнаружен новый пост');
+19 -1
View File
@@ -1,8 +1,26 @@
<?php <?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.
*/
namespace Core\Models; namespace Core\Models;
use Core\CoreException; use Core\CoreException;
/** /**
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Models; namespace Core\Models;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Models; namespace Core\Models;
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Models; namespace Core\Models;
+21 -2
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
namespace Core\Models; namespace Core\Models;
@@ -73,7 +92,7 @@
public function addRole(int $roleId): ?int public function addRole(int $roleId): ?int
{ {
$cacheId = md5('Roles_' . $this->user->getId() . '_getRoles'); $cacheId = md5('Roles_' . $this->user->getId() . '_getRoles');
Cache::del($cacheId); Cache::delete($cacheId);
/** @var $DB DB */ /** @var $DB DB */
$DB = DB::getInstance(); $DB = DB::getInstance();
@@ -90,7 +109,7 @@
public function removeRole(int $roleId): ?int public function removeRole(int $roleId): ?int
{ {
$cacheId = md5('Roles_' . $this->user->getId() . '_getRoles'); $cacheId = md5('Roles_' . $this->user->getId() . '_getRoles');
Cache::del($cacheId); Cache::delete($cacheId);
/** @var $DB DB */ /** @var $DB DB */
$DB = DB::getInstance(); $DB = DB::getInstance();
+19 -1
View File
@@ -1,8 +1,26 @@
<?php <?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.
*/
namespace Core\Models; namespace Core\Models;
class Router class Router
{ {
+31 -5
View File
@@ -1,8 +1,26 @@
<?php <?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.
*/
/** /**
* Класс для работы с пользователями * Класс для работы с пользователями
*
* @author Roman Grinko <rsgrinko@gmail.com>
*/ */
namespace Core\Models; namespace Core\Models;
@@ -190,7 +208,7 @@
{ {
$newToken = self::generateGUID(); $newToken = self::generateGUID();
(DB::getInstance())->update(self::TABLE, ['id' => $this->id], ['token' => $newToken]); (DB::getInstance())->update(self::TABLE, ['id' => $this->id], ['token' => $newToken]);
Log::logToFile('Создан токен ' . $newToken, 'User.log'); Log::logToFile('Создан токен ' . $newToken, 'User.log', ['userId' => $this->id]);
return $newToken; return $newToken;
} }
@@ -297,14 +315,15 @@
* *
* @param string $login Логин * @param string $login Логин
* @param string $password Пароль * @param string $password Пароль
* @param string $email E-Mail
* @param string $name Имя * @param string $name Имя
* @param string $image Аватар
* *
* @return int
* @throws CoreException * @throws CoreException
*/ */
public static function create(string $login, string $password, string $email, string $name = ''): int public static function create(string $login, string $password, string $email, string $name = ''): int
{ {
Log::logToFile(__METHOD__, 'User.log', func_get_args()); Log::logToFile('Создание нового пользователя', 'User.log', func_get_args());
/** @var $DB DB */ /** @var $DB DB */
$DB = DB::getInstance(); $DB = DB::getInstance();
@@ -330,8 +349,15 @@
public function update(array $fields): bool public function update(array $fields): bool
{ {
$cacheId = md5('User_getAllUserData_' . $this->id);
/** @var $DB DB */ /** @var $DB DB */
$DB = DB::getInstance(); $DB = DB::getInstance();
Log::logToFile(
'Изменение данных пользователя c ID ' . $this->id,
'User.log',
['before' => $this->getAllUserData(), 'after' => func_get_args()]
);
Cache::delete($cacheId);
return $DB->update(self::TABLE, ['id' => $this->id], $fields); return $DB->update(self::TABLE, ['id' => $this->id], $fields);
} }
+20 -1
View File
@@ -1,6 +1,26 @@
<?php <?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.
*/
namespace Core; namespace Core;
use Core\Helpers\SystemFunctions; use Core\Helpers\SystemFunctions;
class Template class Template
@@ -20,7 +40,6 @@
public static function render($buffer): ?string public static function render($buffer): ?string
{ {
$buffer = str_replace(array_keys(self::$arTemplateVariables), array_values(self::$arTemplateVariables), $buffer); $buffer = str_replace(array_keys(self::$arTemplateVariables), array_values(self::$arTemplateVariables), $buffer);
return $buffer; return $buffer;
} }
+17 -1
View File
@@ -1,6 +1,22 @@
<?php <?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.
*/ */
namespace Core; namespace Core;
+20
View File
@@ -0,0 +1,20 @@
<?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.
*/
+31 -8
View File
@@ -1,4 +1,24 @@
<?php <?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.
*/
if (count($argv) < 2) { if (count($argv) < 2) {
die('Не выбрано действие. Для справки наберите php -f partizan.php -?' . PHP_EOL); die('Не выбрано действие. Для справки наберите php -f partizan.php -?' . PHP_EOL);
} }
@@ -10,21 +30,24 @@
define('DB_NAME', 'rsgrinko_delta'); define('DB_NAME', 'rsgrinko_delta');
define('DB_TABLE_VERSIONS', 'versions'); define('DB_TABLE_VERSIONS', 'versions');
function connectDB() { function connectDB()
{
$errorMessage = 'Невозможно подключиться к серверу базы данных'; $errorMessage = 'Невозможно подключиться к серверу базы данных';
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$conn) if (!$conn) {
throw new Exception($errorMessage); throw new Exception($errorMessage);
else { } else {
$query = $conn->query('set names utf8'); $query = $conn->query('set names utf8');
if (!$query) if (!$query) {
throw new Exception($errorMessage); throw new Exception($errorMessage);
else } else {
return $conn; return $conn;
} }
} }
}
function getMigrationFiles($conn) { function getMigrationFiles($conn)
{
$sqlFolder = 'migrations/'; $sqlFolder = 'migrations/';
$allFiles = glob($sqlFolder . '*.sql'); $allFiles = glob($sqlFolder . '*.sql');
@@ -46,7 +69,8 @@
} }
function migrate($conn, $file) { function migrate($conn, $file)
{
$command = sprintf('mysql -u%s -p%s -h %s -D %s < %s', DB_USER, DB_PASSWORD, DB_HOST, DB_NAME, $file); $command = sprintf('mysql -u%s -p%s -h %s -D %s < %s', DB_USER, DB_PASSWORD, DB_HOST, DB_NAME, $file);
shell_exec($command); shell_exec($command);
$baseName = basename($file); $baseName = basename($file);
@@ -72,7 +96,6 @@
} }
break; break;
default: default:
echo 'Неизвестная команда' . PHP_EOL; echo 'Неизвестная команда' . PHP_EOL;
+21 -2
View File
@@ -1,6 +1,27 @@
<?php <?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.
*/
use Core\Models\Router; use Core\Models\Router;
Router::route('/', '\Core\App::index'); Router::route('/', '\Core\App::index');
Router::route('/404', function () { Router::route('/404', function () {
@@ -13,8 +34,6 @@
}); });
Router::route('/test', '\Core\App::test'); Router::route('/test', '\Core\App::test');
Router::route('/test/(\d+)', '\Core\App::test'); Router::route('/test/(\d+)', '\Core\App::test');
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
/** /**
* Инициализация runtime * Инициализация runtime
+19
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
/** /**
* Воркер диспетчера очереди * Воркер диспетчера очереди
+35 -17
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\CoreException; use Core\CoreException;
use Core\ExternalServices\Telegram; use Core\ExternalServices\Telegram;
@@ -22,7 +41,8 @@
<nav class="navbar navbar-expand-md navbar-dark bg-dark" aria-label="Fourth navbar example"> <nav class="navbar navbar-expand-md navbar-dark bg-dark" aria-label="Fourth navbar example">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#">Delta Framework</a> <a class="navbar-brand" href="#">Delta Framework</a>
<button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbarsExample04" aria-controls="navbarsExample04" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbarsExample04"
aria-controls="navbarsExample04" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@@ -50,8 +70,6 @@
</nav> </nav>
<div class="container"> <div class="container">
<div class="row justify-content-md-center"> <div class="row justify-content-md-center">
<div class="col-md"> <div class="col-md">
@@ -59,7 +77,11 @@
echo $_REQUEST['route'] . '<br>'; echo $_REQUEST['route'] . '<br>';
if (User::isAuthorized()) { if (User::isAuthorized()) {
global $USER; global $USER;
echo str_replace('<table style="', '<table style="width:100%;', SystemFunctions::arrayToTable($USER->getAllUserData(), 'Информация о пользователе')); echo str_replace(
'<table style="',
'<table style="width:100%;',
SystemFunctions::arrayToTable($USER->getAllUserData(), 'Информация о пользователе')
);
} }
//echo str_replace('<table style="', '<table style="width:100%;', SystemFunctions::arrayToTable(Cache::getCacheInfo(), 'Информация о кэше')); //echo str_replace('<table style="', '<table style="width:100%;', SystemFunctions::arrayToTable(Cache::getCacheInfo(), 'Информация о кэше'));
@@ -82,7 +104,9 @@ $arData = (DB::getInstance())->query('select * from users order by id desc limit
'image' => $element['image'], 'image' => $element['image'],
'token' => $element['token'], 'token' => $element['token'],
'last_active' => $element['last_active'], 'last_active' => $element['last_active'],
'groups' => array_map(function($element){ return Roles::getAllRoles()[$element]; }, (new User($element['id']))->getRolesObject()->getRoles()), 'groups' => array_map(function ($element) {
return Roles::getAllRoles()[$element];
}, (new User($element['id']))->getRolesObject()->getRoles()),
//'groups_human' => User::getAllGroups(), //'groups_human' => User::getAllGroups(),
]; ];
@@ -112,21 +136,15 @@ echo str_replace('<table style="', '<table style="width:100%;', SystemFunctions:
$delta = 0.001; $delta = 0.001;
} }
$cacheSize = Cache::getCacheSize(); $cacheSize = Cache::getCacheSize();
echo '<p class="text-center text-muted">Использовано ОЗУ: ' echo '<p class="text-center text-muted">Использовано ОЗУ: ' . round(memory_get_usage() / 1024 / 1024, 2) . ' МБ / БД: ' . round(
. round(memory_get_usage() / 1024 / 1024, 2) DB::$workingTime,
. ' МБ / БД: ' 3
. round(DB::$workingTime, 3) ) . ' сек (' . DB::$quantity . ' шт.) / Кэш: ' . Files::convertBytes($cacheSize) . ' / Генерация: ' . $delta . ' сек</p>';
. ' сек ('
. DB::$quantity
. ' шт.) / Кэш: '
. Files::convertBytes($cacheSize)
. ' / Генерация: '
. $delta
. ' сек</p>';
?> ?>
<p class="text-center text-muted">© <?= date('Y'); ?> Delta Project</p> <p class="text-center text-muted">© <?= date('Y'); ?> Delta Project</p>
</footer> </footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body> </body>
</html> </html>
+29 -4
View File
@@ -1,4 +1,23 @@
<?php <?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.
*/
use Core\CoreException; use Core\CoreException;
use Core\ExternalServices\Telegram; use Core\ExternalServices\Telegram;
@@ -77,11 +96,17 @@
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Log;');">Log</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Log;');">Log</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Files;');">Files</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Files;');">Files</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Mail;');">Mail</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Mail;');">Mail</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Pagination;');">Pagination</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Pagination;');">
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Registry;');">Registry</button> Pagination
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\SystemFunctions;');">SystemFunctions</button> </button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Registry;');">Registry
</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\SystemFunctions;');">
SystemFunctions
</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Zip;');">Zip</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Helpers\\Zip;');">Zip</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\CoreException;');">CoreException</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\CoreException;');">CoreException
</button>
<button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Template;');">Template</button> <button class="btn btn-primary" type="button" onClick="addUseSection(this, 'use Core\\Template;');">Template</button>
</div> </div>
+21
View File
@@ -1,6 +1,27 @@
<?php <?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.
*/
$_SERVER['DOCUMENT_ROOT'] = '/home/rsgrinko/sites/dev.it-stories.ru'; $_SERVER['DOCUMENT_ROOT'] = '/home/rsgrinko/sites/dev.it-stories.ru';
require_once $_SERVER['DOCUMENT_ROOT'] . '/core/bootstrap.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/core/bootstrap.php';
use Core\MQTasks; use Core\MQTasks;
echo MQTasks::sendJokeToTelegram(); echo MQTasks::sendJokeToTelegram();