edit-threads.php
См. документацию.
1 <?php
2 
3 /**
4  * @file
5  * @brief обработчик настройки потоков и нагрузки для cron задачи
6  */
7 
8 isset($user) or require $_SERVER['DOCUMENT_ROOT'] . '/page/404.php';
9 
10 header("Content-type: application/json");
11 
12 array_walk_recursive($_POST, function (&$item) {
13  $item = trim(htmlspecialchars($item, ENT_QUOTES));
14 });
15 
16 if (!($row = Wrong\Models\Crontabs::find($_POST['id']))) {
17  exit(json_encode(['error' => 'Ошибка']));
18 }
19 
20 if (!$user->access()->write($row)) {
21  exit(json_encode(['error' => 'Недостаточно прав!']));
22 }
23 
24 if ($_POST['min'] < 1 || $_POST['min'] > 100000 || $_POST['max'] < 1 || $_POST['max'] > 100000 || $_POST['load'] < 1 || $_POST['load'] > 1000) {
25  exit(json_encode(['error' => 'Ошибка']));
26 }
27 
28 $threads = array_map('intval', ['min' => $_POST['min'], 'max' => $_POST['max'], 'load' => $_POST['load'], 'fixed' => intval(isset($_POST['fixed']))]);
29 
30 $sth = $dbh->query("UPDATE `crontabs` SET `threads` = '" . json_encode($threads) . "' WHERE `id` = $row->id");
31 
32 if ($sth->errorCode() == '00000') {
33  $mem = new Wrong\Memory\Cache('cron');
34  $mem->delete($row->id);
35  exit(json_encode(['result' => 'ok', 'message' => 'Данные успешно установлены']));
36 }
37 
38 exit(json_encode(['error' => 'Ошибка']));
$_POST['groups']
Definition: add-action.php:16
if(!($row=Wrong\Models\Crontabs::find($_POST['id']))) if(! $user->access() ->write($row)) if($_POST['min']< 1|| $_POST['min'] > 100000|| $_POST['max']< 1|| $_POST['max'] > 100000|| $_POST['load']< 1|| $_POST['load'] > 1000) $threads
$sth
$mem
Definition: settings.php:129
Cache класс, отвечающий за кеширование
Definition: Cache.php:19
$user
Definition: from-user.php:38
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']
Definition: from-user.php:36
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
Definition: install.php:198
$dbh
Definition: session.php:19