8 isset(
$user) or require
$_SERVER[
'DOCUMENT_ROOT'] .
'/page/404.php';
10 header(
"Content-type: application/json");
12 array_walk_recursive(
$_POST,
function (&$item) {
13 $item = trim(htmlspecialchars($item, ENT_QUOTES));
16 if (!($row = Wrong\Models\Crontabs::find(
$_POST[
'id']))) {
17 exit(json_encode([
'error' =>
'Ошибка']));
20 if (!
$user->access()->write($row)) {
21 exit(json_encode([
'error' =>
'Недостаточно прав!']));
25 $cron = Cron\CronExpression::factory(
$_POST[
'shedule']);
26 }
catch (\Throwable $th) {
27 exit(json_encode([
'error' => $th->getMessage()]));
31 for (
$i = 0;
$i < 25;
$i++) {
32 $shedules[] = $cron->getNextRunDate(
null,
$i)->format(
'Y-m-d H:i:s');
36 exit(json_encode([
'error' =>
'Расписание указано некорректно']));
41 $sth =
$dbh->prepare(
"UPDATE `crontabs` SET `shedule` = :shedule, `run_at` = :run_at WHERE `id` = :id");
42 $sth->bindValue(
':shedule',
$_POST[
'shedule']);
44 $sth->bindValue(
':id', $row->id);
47 if (
$sth->errorCode() ==
'00000') {
49 $mem->delete($row->id);
50 exit(json_encode([
'result' =>
'ok',
'message' =>
'Расписание успешно установлено']));
53 exit(json_encode([
'error' =>
'Ошибка']));
for($i=0; $i< 25; $i++) if(count($shedules) !=25) $_POST['run_at']
catch(\Throwable $th) $shedules
if(empty($_POST['name'])) if(empty($_POST['type'])||!in_array($_POST['type'], ['page', 'modal', 'incode', 'select', 'action'])) $i
Cache класс, отвечающий за кеширование
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit