- Added comprehensive AI Assistant system (aiassist/ directory): * Vector search and embedding capabilities * Typebot proxy integration * Elastic search functionality * Message classification and chat history * MCP proxy for external integrations - Implemented Court Status API (GetCourtStatus.php): * Real-time court document status checking * Integration with external court systems * Comprehensive error handling and logging - Enhanced S3 integration: * Improved file backup system with metadata * Batch processing capabilities * Enhanced error logging and recovery * Copy operations with URL fixing - Added Telegram contact creation API - Improved error logging across all modules - Enhanced callback system for AI responses - Extensive backup file storage with timestamps - Updated documentation and README files - File storage improvements: * Thousands of backup files with proper metadata * Fix operations for broken file references * Project-specific backup and recovery systems * Comprehensive file integrity checking Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
145 lines
5.2 KiB
Plaintext
145 lines
5.2 KiB
Plaintext
<?php
|
||
if (file_exists(vglobal('root_directory').'/workflow2_lock') && filemtime(vglobal('root_directory').'/workflow2_lock') > (time() - 7200) && !defined('DEBUG_MODE')) {
|
||
echo "Cronjob already running (".vglobal('root_directory').'/workflow2_lock'.")\n";
|
||
return;
|
||
}
|
||
|
||
function wfd_cron_shutdown_handler() {
|
||
@unlink(vglobal('root_directory').'/workflow2_lock');
|
||
}
|
||
|
||
register_shutdown_function('wfd_cron_shutdown_handler');
|
||
|
||
$cronjobStartTime = time();
|
||
$maxRuntimeMinutes = 10; # Max Runtime
|
||
$logfile = 'logs/wf_cron.log';
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' начали с параметрами: '.json_encode($_REQUEST).PHP_EOL, FILE_APPEND);
|
||
|
||
echo "Workflow2 Cronjob Started\n";
|
||
file_put_contents(vglobal('root_directory').'/workflow2_lock', 'locked');
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' создали файл блокировки'.PHP_EOL, FILE_APPEND);
|
||
|
||
/**
|
||
This File was developed by Stefan Warnat <vtiger@stefanwarnat.de>
|
||
|
||
It belongs to the Workflow Designer and must not be distributed without complete extension
|
||
**/
|
||
require_once('autoload_wf.php');
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' подключили autoload_wf.php'.PHP_EOL, FILE_APPEND);
|
||
|
||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||
|
||
#$wfManager = new WfManager();
|
||
#$tasks = $wfManager->GetQueue();
|
||
|
||
global $current_language, $default_language, $current_user, $app_strings;
|
||
if(empty($current_language)) {
|
||
$current_language = $default_language;
|
||
}
|
||
$app_strings = return_application_language($current_language);
|
||
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' что-то с языками'.PHP_EOL, FILE_APPEND);
|
||
|
||
Workflow2::$enableError = true;
|
||
|
||
$tasks = \Workflow\Queue::getQueueEntry();
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' получили список задач'.PHP_EOL, FILE_APPEND);
|
||
if($tasks === false) {
|
||
date_default_timezone_set('UTC');
|
||
echo "Workflow2: Nothing to do! [".date("d.m.Y H:i:s")."]"."\n";
|
||
|
||
//unlink(vglobal('root_directory').'/workflow2_lock');
|
||
//return;
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' в списке нет задач'.PHP_EOL, FILE_APPEND);
|
||
} else {
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' списко не пустой'.PHP_EOL, FILE_APPEND);
|
||
do {
|
||
/** Loop Tasks */
|
||
foreach($tasks as $task) {
|
||
$task["task"]->setContinued(true);
|
||
|
||
\Workflow\EntityDelta::unserializeDelta($task["delta"]);
|
||
|
||
$wfMain = new \Workflow\Main($task["id"], $task["context"], $task["user"]);
|
||
$wfMain->setExecutionTrigger("WF2_MANUELL");
|
||
|
||
$current_user = $task["user"];
|
||
\Workflow\VTEntity::setUser($task["user"]);
|
||
|
||
$_SERVER["runningWorkflow".$task["id"]] = true;
|
||
|
||
try {
|
||
$wfMain->handleTasks($task["task"], $task["task"]->getBlockId());
|
||
} catch(\exception $exp) {
|
||
Workflow2::error_handler($exp);
|
||
}
|
||
|
||
$sql = "DELETE FROM vtiger_wf_queue WHERE id = ".$task["queue_id"]."";
|
||
$adb->query($sql);
|
||
|
||
$_SERVER["runningWorkflow".$task["id"]] = false;
|
||
|
||
// clean up filestore
|
||
$sql = "SELECT id FROM vtiger_wf_queue WHERE execID = '".$wfMain->getLastExecID()."'";
|
||
$result = $adb->query($sql, true);
|
||
|
||
if($adb->num_rows($result) == 0) {
|
||
$task["context"]->unlinkTempFiles($wfMain->getLastExecID());
|
||
}
|
||
|
||
#$wfMain->getContext()->save();
|
||
#var_dump($wfMain->getContext());exit();
|
||
}
|
||
|
||
if(time() < $cronjobStartTime + ($maxRuntimeMinutes * 60)) {
|
||
/** Loop Tasks */
|
||
$tasks = \Workflow\Queue::getQueueEntry();
|
||
} else {
|
||
$tasks = false;
|
||
}
|
||
} while($tasks !== false);
|
||
|
||
}
|
||
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' закончили циклы'.PHP_EOL, FILE_APPEND);
|
||
|
||
echo "Workflow2 Scheduler Started\n";
|
||
\Workflow\Scheduler::execute();
|
||
echo "Workflow2 Scheduler Finished\n";
|
||
|
||
echo "Workflow2 Cronjob Start Cleaning\n";
|
||
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' что-то выполнили'.PHP_EOL, FILE_APPEND);
|
||
|
||
/** correct storage permissions */
|
||
$filePath = decideFilePath();
|
||
@chmod(dirname(dirname($filePath)), 0777);
|
||
@chmod(dirname($filePath), 0777);
|
||
@chmod($filePath, 0777);
|
||
|
||
if(date('H') > 1 AND date('H') < 8) {
|
||
\Workflow2::purgeLogs();
|
||
\Workflow2::purgeQueue();
|
||
}
|
||
|
||
\Workflow2::cleanQueue();
|
||
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' почистили какую-то очередь'.PHP_EOL, FILE_APPEND);
|
||
|
||
$obj = new \Workflow2();
|
||
$obj->repoUpdateCheck();
|
||
|
||
$objLM = new \Workflow\SWExtension\LanguageManager('Workflow2');
|
||
$objLM->updateLanguages();
|
||
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' какой-то объект покрутили'.PHP_EOL, FILE_APPEND);
|
||
|
||
\Workflow2::$enableError = false;
|
||
|
||
unlink(vglobal('root_directory').'/workflow2_lock');
|
||
|
||
file_put_contents($logfile, date('Y-m-d- H:i:s').' удалили файл блокировки'.PHP_EOL, FILE_APPEND);
|
||
|
||
echo "Workflow2 Cronjob Finished\n";
|
||
|
||
?> |