Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
107 righe
3.3 KiB
107 righe
3.3 KiB
<? |
|
$continue = false; |
|
$mode = php_sapi_name(); |
|
if($mode == "cli") { |
|
$continue = true; |
|
ini_set('memory_limit', "512M"); |
|
} else { |
|
include(__DIR__."/backend/utenti/utente.class.php"); |
|
@session_start(); |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->gerarchia < 10) { |
|
$continue = true; |
|
} |
|
} |
|
if ($continue) { |
|
if (empty($config)) { |
|
$root = __DIR__; |
|
include_once($root."/../config.php"); |
|
$pdo = new myPDO($config["db_host"],$config["db_user"],$config["db_pass"],$config["db_name"], $config['socket']); |
|
} |
|
session_write_close(); |
|
|
|
$queuePath = $config["queue_log"] . "/" . date("Y-m-d") . ".json"; |
|
|
|
if (!file_exists($queuePath)) { |
|
touch($queuePath); |
|
} |
|
|
|
$queueLog = jsonToArray($queuePath); |
|
if (empty($queueLog)) { |
|
$queueLog = []; |
|
} |
|
|
|
function getQueueLog(string $tenant = "0", string $id = null) { |
|
global $queueLog; |
|
return $queueLog[$tenant][$id] ?? null; |
|
} |
|
|
|
function writeQueueLog(string $tenant = "0", string $id = null, $value = true) { |
|
global $queuePath, $queueLog; |
|
if (!empty($id)) { |
|
$queueLog[(string)$tenant][(string)$id] = $value; |
|
if (!file_put_contents($queuePath,json_encode($queueLog,JSON_PRETTY_PRINT),LOCK_EX)) { |
|
Throw new Exception("Errore scrittura file log queue"); |
|
} |
|
} else { |
|
Throw new Exception("ID null nel log queue"); |
|
} |
|
} |
|
|
|
$elabora_coda = true; |
|
|
|
|
|
if($mode == "cli") { |
|
exec("chown -R {$config["vh_user"]}:{$config["vh_group"]} {$realRoot}/logs"); |
|
} |
|
if(!function_exists("ec_create_ticket")) { |
|
function ec_create_ticket(string $oggetto, string $corpo = "", ?int $codice_ente=null) { |
|
return true; |
|
if(!empty($codice_ente)) { |
|
$oggetto = "[ENTE_{$codice_ente}] {$oggetto}"; |
|
} |
|
$mailer = new Communicator(); |
|
$mailer->oggetto = $oggetto; |
|
$mailer->corpo = empty($corpo) ? $oggetto : $corpo; |
|
|
|
$mailer->codice_pec = -2; |
|
$mailer->comunicazione = false; |
|
$mailer->coda = false; |
|
$mailer->intestazione = false; |
|
$mailer->destinatari = "assistenza@studioamica.it"; |
|
$esito = $mailer->send(); |
|
var_dump($esito); |
|
return $esito; |
|
} |
|
} |
|
|
|
$to_include = [ |
|
"{$root}/elabora_coda/clean_queueLog.php", |
|
"{$root}/elabora_coda/update_ausa.php", |
|
"{$root}/elabora_coda/update_centri_di_costo.php", |
|
"{$root}/elabora_coda/login_hash.php", |
|
"{$root}/elabora_coda/disabilita_utenti_inattivi.php", |
|
"{$root}/elabora_coda/check_coda.php", |
|
"{$root}/elabora_coda/smaltisci_coda.php", |
|
"{$root}/elabora_coda/alert_task.php", |
|
"{$root}/elabora_coda/clean_del.php", |
|
"{$root}/elabora_coda/update_spid.php", |
|
"{$root}/elabora_coda/create_db.php", |
|
"{$root}/elabora_coda/elaborazioniTenant.php", |
|
]; |
|
foreach ($to_include as $path) { |
|
try { |
|
alertManager::printCliInfo("- Caricamento di {$path}"); |
|
require $path; |
|
} catch (\Throwable $t) { |
|
$alert = <<<ERR |
|
[!] {$path} ha lanciato un eccezione: |
|
{$t->getMessage()} |
|
{$t->getTraceAsString()} |
|
ERR; |
|
alertManager::printCliAlert($alert); |
|
ec_create_ticket("Eccezione in {$path}", $alert); |
|
} |
|
} |
|
} |
|
|
|
?>
|
|
|