<?php
### Brainy Control Panel
### Decoded IonCube by pimnik98
### Декодировал Пиминов Никита
### vk.com/piminov_remont
### Скрипт скачан с портала X-Scripts.Ru
error_reporting(0);
require_once "/etc/brainy/conf/globals.php";
require_once "/etc/brainy/classes/server.php";
require_once "/etc/brainy/classes/hostacc.php";
$server = new server();
$next_exec_file = "/etc/brainy/data/crontab/next_exec";
$file_out_array = explode(PHP_EOL, trim(file_get_contents("/etc/brainy/conf/cron_exec_config")));
$file_out_array_next = explode(PHP_EOL, trim(file_get_contents($next_exec_file)));
foreach ($file_out_array_next as $val_array_next) {
list($comand_exec, $time_now) = explode("|", trim($val_array_next));
$array_exec[$comand_exec] = $time_now;
}
$timestamp = time();
$date = date("Y-m-d H:i", $timestamp);
foreach ($file_out_array as $val_array) {
list($comand, $time_exec) = explode("|", trim($val_array));
list($minutes, $hour, $mount, $year) = explode(",", $time_exec);
$val_next = get_next_exec($minutes, $hour, $mount, $year);
$hour_exec = preg_replace("/\\/|\\*/iu", "", $hour);
$minutes_exec = preg_replace("/\\/|\\*/iu", "", $minutes);
if ($hour_exec < 10) {
$hour_exec = "0" . $hour_exec;
}
if ($minutes_exec < 10) {
$minutes_exec = "0" . $minutes_exec;
}
if (preg_match("/\\*\\//iu", $hour) && !preg_match("/\\//iu", $minutes)) {
if ($minutes_exec == "*") {
$minutes_exec = "0";
}
$hour_exec = preg_replace("/\\/|\\*/iu", "", $hour);
if (!$array_exec[$comand]) {
$array_exec[$comand] = date("Y-m-d H:i", $timestamp + $hour_exec * 60 * 60 + $minutes_exec * 60);
}
if ($array_exec[$comand] == date("Y-m-d ") . (string) $hour_exec . ":" . $minutes_exec || strtotime($array_exec[$comand]) < $timestamp + 10 && $array_exec[$comand]) {
$out = $server->ssh("nohup " . $comand . " &");
$array_exec[$comand] = date("Y-m-d H:i", $timestamp + $hour_exec * 60 * 60 + $minutes_exec * 60);
}
} else {
if (!preg_match("/\\*/iu", $hour) && !preg_match("/\\*/iu", $minutes)) {
if (!$array_exec[$comand]) {
$array_exec[$comand] = date("Y-m-d ") . (string) $hour_exec . ":" . $minutes_exec;
}
if ($array_exec[$comand] == $date || strtotime($array_exec[$comand]) < $timestamp + 10 && $array_exec[$comand]) {
$out = $server->ssh("nohup " . $comand . " &");
$array_exec[$comand] = date("Y-m-d H:i", $timestamp + 86400);
}
} else {
if (!$array_exec[$comand]) {
$array_exec[$comand] = date("Y-m-d H:i", $timestamp + $val_next);
} else {
if ($array_exec[$comand] == $date || strtotime($array_exec[$comand]) < $timestamp + 10 && $array_exec[$comand]) {
$out = $server->ssh("nohup " . $comand . " &");
$array_exec[$comand] = date("Y-m-d H:i", $timestamp + $val_next);
}
}
}
}
}
$txt_next = "";
foreach ($array_exec as $key_exec => $val_exec) {
if ($val_exec && $key_exec) {
$txt_next .= (string) $key_exec . "|" . $val_exec . PHP_EOL;
}
}
file_put_contents($next_exec_file, $txt_next);
function get_next_exec($minutes, $hour, $mount = "*", $year = "*")
{
$hour_exec = preg_replace("/\\/|\\*/iu", "", $hour);
$minutes_exec = preg_replace("/\\/|\\*/iu", "", $minutes);
$time_exec = 1;
if ($hour_exec) {
if (preg_match("/\\//iu")) {
$time_exec = $hour_exec * 24 * 60;
} else {
$time_exec = $hour_exec * 60;
}
}
if ($minutes_exec) {
$time_exec = $time_exec + $minutes_exec * 60;
}
return $time_exec;
}
?>