mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
code formating
This commit is contained in:
@@ -730,11 +730,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
$options->set_bases($params['bases'], $user->ACL());
|
$options->set_bases($params['bases'], $user->ACL());
|
||||||
|
|
||||||
if ( ! is_array($params['fields']))
|
if ( ! is_array($params['fields'])) {
|
||||||
$params['fields'] = array();
|
$params['fields'] = array();
|
||||||
|
}
|
||||||
$options->set_fields($params['fields']);
|
$options->set_fields($params['fields']);
|
||||||
if ( ! is_array($params['status']))
|
if ( ! is_array($params['status'])) {
|
||||||
$params['status'] = array();
|
$params['status'] = array();
|
||||||
|
}
|
||||||
$options->set_status($params['status']);
|
$options->set_status($params['status']);
|
||||||
$options->set_search_type($params['search_type']);
|
$options->set_search_type($params['search_type']);
|
||||||
$options->set_record_type($params['recordtype']);
|
$options->set_record_type($params['recordtype']);
|
||||||
@@ -938,15 +940,19 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
$datas = strrev($record->get_status());
|
$datas = strrev($record->get_status());
|
||||||
|
|
||||||
if ( ! is_array($status))
|
if ( ! is_array($status)) {
|
||||||
throw new API_V1_exception_badrequest();
|
throw new API_V1_exception_badrequest();
|
||||||
|
}
|
||||||
foreach ($status as $n => $value) {
|
foreach ($status as $n => $value) {
|
||||||
if ($n > 63 || $n < 4)
|
if ($n > 63 || $n < 4) {
|
||||||
throw new API_V1_exception_badrequest();
|
throw new API_V1_exception_badrequest();
|
||||||
if ( ! in_array($value, array('0', '1')))
|
}
|
||||||
|
if ( ! in_array($value, array('0', '1'))) {
|
||||||
throw new API_V1_exception_badrequest();
|
throw new API_V1_exception_badrequest();
|
||||||
if ( ! isset($status_bits[$n]))
|
}
|
||||||
|
if ( ! isset($status_bits[$n])) {
|
||||||
throw new API_V1_exception_badrequest ();
|
throw new API_V1_exception_badrequest ();
|
||||||
|
}
|
||||||
|
|
||||||
$datas = substr($datas, 0, ($n - 1)) . $value . substr($datas, ($n + 1));
|
$datas = substr($datas, 0, ($n - 1)) . $value . substr($datas, ($n + 1));
|
||||||
}
|
}
|
||||||
@@ -1076,8 +1082,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
$name = $request->get('name');
|
$name = $request->get('name');
|
||||||
|
|
||||||
if (trim(strip_tags($name)) === '')
|
if (trim(strip_tags($name)) === '') {
|
||||||
throw new API_V1_exception_badrequest ();
|
throw new API_V1_exception_badrequest ();
|
||||||
|
}
|
||||||
|
|
||||||
$user = $this->core->getAuthenticatedUser();
|
$user = $this->core->getAuthenticatedUser();
|
||||||
|
|
||||||
@@ -1472,10 +1479,11 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
*/
|
*/
|
||||||
protected function list_embedable_media(media_subdef &$media, registryInterface &$registry)
|
protected function list_embedable_media(media_subdef &$media, registryInterface &$registry)
|
||||||
{
|
{
|
||||||
if ($media->get_permalink() instanceof media_Permalink_Adapter)
|
if ($media->get_permalink() instanceof media_Permalink_Adapter) {
|
||||||
$permalink = $this->list_permalink($media->get_permalink(), $registry);
|
$permalink = $this->list_permalink($media->get_permalink(), $registry);
|
||||||
else
|
} else {
|
||||||
$permalink = null;
|
$permalink = null;
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'permalink' => $permalink,
|
'permalink' => $permalink,
|
||||||
@@ -1600,8 +1608,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
$expires_on_atom = $basket->getValidation()->getExpires();
|
$expires_on_atom = $basket->getValidation()->getExpires();
|
||||||
|
|
||||||
if ($expires_on_atom instanceof DateTime)
|
if ($expires_on_atom instanceof DateTime) {
|
||||||
$expires_on_atom = $expires_on_atom->format(DATE_ATOM);
|
$expires_on_atom = $expires_on_atom->format(DATE_ATOM);
|
||||||
|
}
|
||||||
|
|
||||||
$user = \User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox);
|
$user = \User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox);
|
||||||
|
|
||||||
|
@@ -59,8 +59,9 @@ class module_console_taskrun extends Command
|
|||||||
{
|
{
|
||||||
if ($this->task) {
|
if ($this->task) {
|
||||||
$this->task->log(sprintf("signal %s received", $signo));
|
$this->task->log(sprintf("signal %s received", $signo));
|
||||||
if ($signo == SIGTERM)
|
if ($signo == SIGTERM) {
|
||||||
$this->task->setRunning(false);
|
$this->task->setRunning(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +73,9 @@ class module_console_taskrun extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$task_id = (int) $input->getArgument('task_id');
|
$task_id = (int) $input->getArgument('task_id');
|
||||||
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
|
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id'))) {
|
||||||
throw new \RuntimeException('Argument must be an Id.');
|
throw new \RuntimeException('Argument must be an Id.');
|
||||||
|
}
|
||||||
|
|
||||||
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
@@ -82,21 +84,23 @@ class module_console_taskrun extends Command
|
|||||||
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
|
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
|
||||||
$schedStatus = $task_manager->getSchedulerState();
|
$schedStatus = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
|
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid']) {
|
||||||
$this->shedulerPID = $schedStatus['pid'];
|
$this->shedulerPID = $schedStatus['pid'];
|
||||||
|
}
|
||||||
$runner = task_abstract::RUNNER_MANUAL;
|
$runner = task_abstract::RUNNER_MANUAL;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$runner = task_abstract::RUNNER_SCHEDULER;
|
$runner = task_abstract::RUNNER_SCHEDULER;
|
||||||
$schedStatus = $task_manager->getSchedulerState();
|
$schedStatus = $task_manager->getSchedulerState();
|
||||||
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
|
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid']) {
|
||||||
$this->shedulerPID = $schedStatus['pid'];
|
$this->shedulerPID = $schedStatus['pid'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
register_tick_function(array($this, 'tick_handler'), true);
|
register_tick_function(array($this, 'tick_handler'), true);
|
||||||
declare(ticks = 1);
|
declare(ticks = 1);
|
||||||
if (function_exists('pcntl_signal'))
|
if (function_exists('pcntl_signal')) {
|
||||||
pcntl_signal(SIGTERM, array($this, 'sig_handler'));
|
pcntl_signal(SIGTERM, array($this, 'sig_handler'));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->task->run($runner, $input, $output);
|
$this->task->run($runner, $input, $output);
|
||||||
@@ -121,13 +125,13 @@ class module_console_taskrun extends Command
|
|||||||
if (time() - $start > 0) {
|
if (time() - $start > 0) {
|
||||||
if ($this->shedulerPID) {
|
if ($this->shedulerPID) {
|
||||||
if ( ! posix_kill($this->shedulerPID, 0)) {
|
if ( ! posix_kill($this->shedulerPID, 0)) {
|
||||||
if (method_exists($this->task, 'signal'))
|
if (method_exists($this->task, 'signal')) {
|
||||||
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
||||||
else
|
} else {
|
||||||
$this->task->setState(task_abstract::STATE_TOSTOP);
|
$this->task->setState(task_abstract::STATE_TOSTOP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$start = time();
|
$start = time();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,8 @@ class task_Scheduler
|
|||||||
$lockdir = $registry->get('GV_RootPath') . 'tmp/locks/';
|
$lockdir = $registry->get('GV_RootPath') . 'tmp/locks/';
|
||||||
|
|
||||||
for ($try = 1; true; $try ++ ) {
|
for ($try = 1; true; $try ++ ) {
|
||||||
if (($schedlock = fopen(($lockfile = ($lockdir . 'scheduler.lock')), 'a+'))) {
|
$lockfile = ($lockdir . 'scheduler.lock');
|
||||||
|
if (($schedlock = fopen($lockfile, 'a+')) != FALSE) {
|
||||||
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
|
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
|
||||||
$this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try));
|
$this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try));
|
||||||
if ($try == 4) {
|
if ($try == 4) {
|
||||||
@@ -107,8 +108,9 @@ class task_Scheduler
|
|||||||
|
|
||||||
$this->log(sprintf("running scheduler with method %s", $this->method));
|
$this->log(sprintf("running scheduler with method %s", $this->method));
|
||||||
|
|
||||||
if ($this->method == self::METHOD_FORK)
|
if ($this->method == self::METHOD_FORK) {
|
||||||
pcntl_signal(SIGCHLD, SIG_IGN);
|
pcntl_signal(SIGCHLD, SIG_IGN);
|
||||||
|
}
|
||||||
|
|
||||||
$logdir = $registry->get('GV_RootPath') . 'logs/';
|
$logdir = $registry->get('GV_RootPath') . 'logs/';
|
||||||
|
|
||||||
@@ -136,16 +138,11 @@ class task_Scheduler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tlist = array();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$schedstatus = 'started';
|
$schedstatus = 'started';
|
||||||
$runningtask = 0;
|
$runningtask = 0;
|
||||||
$connwaslost = false;
|
$connwaslost = false;
|
||||||
|
|
||||||
$last_log_check = array();
|
|
||||||
|
|
||||||
while ($schedstatus == 'started' || $runningtask > 0) {
|
while ($schedstatus == 'started' || $runningtask > 0) {
|
||||||
while (1) {
|
while (1) {
|
||||||
try {
|
try {
|
||||||
@@ -154,15 +151,17 @@ class task_Scheduler
|
|||||||
} catch (ErrorException $e) {
|
} catch (ErrorException $e) {
|
||||||
$ping = false;
|
$ping = false;
|
||||||
}
|
}
|
||||||
if ($ping)
|
if ($ping) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
unset($conn);
|
unset($conn);
|
||||||
if ( ! $connwaslost) {
|
if ( ! $connwaslost) {
|
||||||
$this->log(sprintf("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(sprintf("Warning : abox connection lost, restarting in 10 min."));
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < 60 * 10; $i ++ )
|
for ($i = 0; $i < 60 * 10; $i ++ ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
|
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||||
} catch (ErrorException $e) {
|
} catch (ErrorException $e) {
|
||||||
@@ -181,7 +180,7 @@ class task_Scheduler
|
|||||||
|
|
||||||
$connwaslost = false;
|
$connwaslost = false;
|
||||||
}
|
}
|
||||||
// printf("%d \n", __LINE__);
|
|
||||||
$schedstatus = '';
|
$schedstatus = '';
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
try {
|
try {
|
||||||
@@ -216,10 +215,10 @@ class task_Scheduler
|
|||||||
logs::rotate($logdir . "scheduler_o.log");
|
logs::rotate($logdir . "scheduler_o.log");
|
||||||
logs::rotate($logdir . "scheduler_e.log");
|
logs::rotate($logdir . "scheduler_e.log");
|
||||||
|
|
||||||
// printf("%d \n", __LINE__);
|
|
||||||
// initialy, all tasks are supposed to be removed from the poll
|
// initialy, all tasks are supposed to be removed from the poll
|
||||||
foreach ($taskPoll as $tkey => $task)
|
foreach ($taskPoll as $tkey => $task) {
|
||||||
$taskPoll[$tkey]["todel"] = true;
|
$taskPoll[$tkey]["todel"] = true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($task_manager->getTasks(true) as $task) {
|
foreach ($task_manager->getTasks(true) as $task) {
|
||||||
$tkey = "t_" . $task->getID();
|
$tkey = "t_" . $task->getID();
|
||||||
@@ -236,16 +235,18 @@ class task_Scheduler
|
|||||||
case "WINDOWS":
|
case "WINDOWS":
|
||||||
$cmd = $phpcli;
|
$cmd = $phpcli;
|
||||||
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler');
|
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler');
|
||||||
if ($this->input && ($this->input->getOption('notasklog')))
|
if ($this->input && ($this->input->getOption('notasklog'))) {
|
||||||
$args[] = 'notasklog';
|
$args[] = 'notasklog';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case "DARWIN":
|
case "DARWIN":
|
||||||
case "LINUX":
|
case "LINUX":
|
||||||
$cmd = $phpcli;
|
$cmd = $phpcli;
|
||||||
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler');
|
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler');
|
||||||
if ($this->input && ($this->input->getOption('notasklog')))
|
if ($this->input && ($this->input->getOption('notasklog'))) {
|
||||||
$args[] = 'notasklog';
|
$args[] = 'notasklog';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,8 +331,9 @@ class task_Scheduler
|
|||||||
|
|
||||||
case task_abstract::STATE_TOSTART:
|
case task_abstract::STATE_TOSTART:
|
||||||
// if scheduler is 'tostop', don't launch a new task !
|
// if scheduler is 'tostop', don't launch a new task !
|
||||||
if ($schedstatus != 'started')
|
if ($schedstatus != 'started') {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$taskPoll[$tkey]["killat"] = NULL;
|
$taskPoll[$tkey]["killat"] = NULL;
|
||||||
|
|
||||||
@@ -380,28 +382,24 @@ class task_Scheduler
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5) {
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
else
|
} else {
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($this->method == self::METHOD_FORK) {
|
||||||
elseif ($this->method == self::METHOD_FORK) {
|
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid == -1) {
|
if ($pid == -1) {
|
||||||
die("failed to fork");
|
die("failed to fork");
|
||||||
} elseif ($pid == 0) {
|
} elseif ($pid == 0) {
|
||||||
umask(0);
|
umask(0);
|
||||||
if (posix_setsid() < 0)
|
if (posix_setsid() < 0) {
|
||||||
die("Forked process could not detach from terminal\n");
|
die("Forked process could not detach from terminal\n");
|
||||||
|
}
|
||||||
|
|
||||||
fclose(STDIN);
|
// todo (if possible) : redirecting stdin, stdout to log files ?
|
||||||
fclose(STDOUT);
|
|
||||||
fclose(STDERR);
|
|
||||||
$fdIN = fopen($nullfile, 'r');
|
|
||||||
$fdOUT = fopen($logdir . "task_o_" . $taskPoll[$tkey]["task"]->getID() . ".log", 'a+');
|
|
||||||
$fdERR = fopen($logdir . "task_e_" . $taskPoll[$tkey]["task"]->getID() . ".log", 'a+');
|
|
||||||
|
|
||||||
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
||||||
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
||||||
@@ -419,12 +417,12 @@ class task_Scheduler
|
|||||||
|
|
||||||
if (is_resource($taskPoll[$tkey]["process"])) {
|
if (is_resource($taskPoll[$tkey]["process"])) {
|
||||||
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
|
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
|
||||||
if ($proc_status['running'])
|
if ($proc_status['running']) {
|
||||||
$runningtask ++;
|
$runningtask ++;
|
||||||
else
|
} else {
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,17 +453,19 @@ class task_Scheduler
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5) {
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
else
|
} else {
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATE_TOSTOP:
|
case task_abstract::STATE_TOSTOP:
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["killat"] === NULL)
|
if ($taskPoll[$tkey]["killat"] === NULL) {
|
||||||
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
||||||
|
}
|
||||||
|
|
||||||
$pid = $taskPoll[$tkey]['task']->getPID();
|
$pid = $taskPoll[$tkey]['task']->getPID();
|
||||||
if ($pid) {
|
if ($pid) {
|
||||||
@@ -545,8 +545,9 @@ class task_Scheduler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $sleeptime; $i ++ )
|
for ($i = 0; $i < $sleeptime; $i ++ ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'";
|
$sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'";
|
||||||
|
@@ -101,8 +101,9 @@ abstract class task_abstract
|
|||||||
$stmt->execute(array(':taskid' => $this->taskid));
|
$stmt->execute(array(':taskid' => $this->taskid));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ( ! $row)
|
if ( ! $row) {
|
||||||
throw new Exception('Unknown task id');
|
throw new Exception('Unknown task id');
|
||||||
|
}
|
||||||
|
|
||||||
return $row['status'];
|
return $row['status'];
|
||||||
}
|
}
|
||||||
@@ -281,8 +282,9 @@ abstract class task_abstract
|
|||||||
$stmt->execute(array(':taskid' => $this->getID()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ( ! $row)
|
if ( ! $row) {
|
||||||
throw new Exception('Unknown task id');
|
throw new Exception('Unknown task id');
|
||||||
|
}
|
||||||
$this->title = $row['name'];
|
$this->title = $row['name'];
|
||||||
$this->crash_counter = (int) $row['crashed'];
|
$this->crash_counter = (int) $row['crashed'];
|
||||||
$this->active = ! ! $row['active'];
|
$this->active = ! ! $row['active'];
|
||||||
@@ -367,7 +369,7 @@ abstract class task_abstract
|
|||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
system_file::mkdir($lockdir = $registry->get('GV_RootPath') . 'tmp/locks/');
|
system_file::mkdir($lockdir = $registry->get('GV_RootPath') . 'tmp/locks/');
|
||||||
|
|
||||||
if (($fd = fopen(($lockfile = ($lockdir . 'task_' . $taskid . '.lock')), 'a+'))) {
|
if (($fd = fopen(($lockfile = ($lockdir . 'task_' . $taskid . '.lock')), 'a+')) != FALSE) {
|
||||||
if (flock($fd, LOCK_EX | LOCK_NB) === FALSE) {
|
if (flock($fd, LOCK_EX | LOCK_NB) === FALSE) {
|
||||||
// already locked ? : task running
|
// already locked ? : task running
|
||||||
$pid = fgets($fd);
|
$pid = fgets($fd);
|
||||||
@@ -389,7 +391,7 @@ abstract class task_abstract
|
|||||||
protected function pause($when_started = 0)
|
protected function pause($when_started = 0)
|
||||||
{
|
{
|
||||||
$this->log($this->records_done . ' records done');
|
$this->log($this->records_done . ' records done');
|
||||||
if ($this->running) {// && $this->records_done == 0)
|
if ($this->running) { // && $this->records_done == 0)
|
||||||
$when_started = time() - $when_started;
|
$when_started = time() - $when_started;
|
||||||
if ($when_started < $this->period) {
|
if ($when_started < $this->period) {
|
||||||
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
@@ -411,12 +413,12 @@ abstract class task_abstract
|
|||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
|
|
||||||
$taskid = $this->getID();
|
$taskid = $this->getID();
|
||||||
$conn = connection::getPDOConnection();
|
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
system_file::mkdir($lockdir = $registry->get('GV_RootPath') . 'tmp/locks/');
|
system_file::mkdir($lockdir = $registry->get('GV_RootPath') . 'tmp/locks/');
|
||||||
$locker = true;
|
$locker = true;
|
||||||
$tasklock = fopen(($lockfile = ($lockdir . 'task_' . $taskid . '.lock')), 'a+');
|
$lockfile = ($lockdir . 'task_' . $taskid . '.lock');
|
||||||
|
$tasklock = fopen($lockfile, 'a+');
|
||||||
|
|
||||||
if (flock($tasklock, LOCK_EX | LOCK_NB, $locker) === FALSE) {
|
if (flock($tasklock, LOCK_EX | LOCK_NB, $locker) === FALSE) {
|
||||||
$this->log("runtask::ERROR : task already running.");
|
$this->log("runtask::ERROR : task already running.");
|
||||||
@@ -463,8 +465,9 @@ abstract class task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if something went wrong, report
|
// if something went wrong, report
|
||||||
if ($exception)
|
if ($exception) {
|
||||||
throw($exception);
|
throw($exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function run2();
|
abstract protected function run2();
|
||||||
@@ -472,18 +475,22 @@ abstract class task_abstract
|
|||||||
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->period = (int) $sx_task_settings->period;
|
$this->period = (int) $sx_task_settings->period;
|
||||||
if ($this->period <= 0 || $this->period >= 60 * 60)
|
if ($this->period <= 0 || $this->period >= 60 * 60) {
|
||||||
$this->period = 60;
|
$this->period = 60;
|
||||||
|
}
|
||||||
|
|
||||||
$this->maxrecs = (int) $sx_task_settings->maxrecs;
|
$this->maxrecs = (int) $sx_task_settings->maxrecs;
|
||||||
if ($sx_task_settings->maxrecs < 10 || $sx_task_settings->maxrecs > 1000)
|
if ($sx_task_settings->maxrecs < 10 || $sx_task_settings->maxrecs > 1000) {
|
||||||
$this->maxrecs = 100;
|
$this->maxrecs = 100;
|
||||||
|
}
|
||||||
$this->maxmegs = (int) $sx_task_settings->maxmegs;
|
$this->maxmegs = (int) $sx_task_settings->maxmegs;
|
||||||
if ($sx_task_settings->maxmegs < 16 || $sx_task_settings->maxmegs > 512)
|
if ($sx_task_settings->maxmegs < 16 || $sx_task_settings->maxmegs > 512) {
|
||||||
$this->maxmegs = 24;
|
$this->maxmegs = 24;
|
||||||
|
}
|
||||||
$this->record_buffer_size = (int) $sx_task_settings->flush;
|
$this->record_buffer_size = (int) $sx_task_settings->flush;
|
||||||
if ($sx_task_settings->flush < 1 || $sx_task_settings->flush > 100)
|
if ($sx_task_settings->flush < 1 || $sx_task_settings->flush > 100) {
|
||||||
$this->record_buffer_size = 10;
|
$this->record_buffer_size = 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function incrementLoops()
|
protected function incrementLoops()
|
||||||
@@ -500,8 +507,9 @@ abstract class task_abstract
|
|||||||
{
|
{
|
||||||
static $lastt = null;
|
static $lastt = null;
|
||||||
$t = explode(' ', ($ut = microtime()));
|
$t = explode(' ', ($ut = microtime()));
|
||||||
if ($lastt === null)
|
if ($lastt === null) {
|
||||||
$lastt = $t;
|
$lastt = $t;
|
||||||
|
}
|
||||||
$dt = ($t[0] - $lastt[0]) + ($t[1] - $lastt[1]);
|
$dt = ($t[0] - $lastt[0]) + ($t[1] - $lastt[1]);
|
||||||
|
|
||||||
$m = memory_get_usage() >> 10;
|
$m = memory_get_usage() >> 10;
|
||||||
@@ -547,8 +555,9 @@ abstract class task_abstract
|
|||||||
*/
|
*/
|
||||||
public static function create(appbox $appbox, $class_name, $settings = null)
|
public static function create(appbox $appbox, $class_name, $settings = null)
|
||||||
{
|
{
|
||||||
if ( ! class_exists($class_name))
|
if ( ! class_exists($class_name)) {
|
||||||
throw new Exception('Unknown task class');
|
throw new Exception('Unknown task class');
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'INSERT INTO task2
|
$sql = 'INSERT INTO task2
|
||||||
(task_id, usr_id_owner, status, crashed, active,
|
(task_id, usr_id_owner, status, crashed, active,
|
||||||
@@ -558,10 +567,11 @@ abstract class task_abstract
|
|||||||
:name, "0000/00/00 00:00:00", :class, :settings)';
|
:name, "0000/00/00 00:00:00", :class, :settings)';
|
||||||
|
|
||||||
|
|
||||||
if ($settings && ! DOMDocument::loadXML($settings))
|
if ($settings && ! DOMDocument::loadXML($settings)) {
|
||||||
throw new Exception('settings invalide');
|
throw new Exception('settings invalide');
|
||||||
elseif ( ! $settings)
|
} elseif ( ! $settings) {
|
||||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n</tasksettings>";
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n</tasksettings>";
|
||||||
|
}
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':active' => 1
|
':active' => 1
|
||||||
@@ -582,8 +592,9 @@ abstract class task_abstract
|
|||||||
{
|
{
|
||||||
global $argc, $argv;
|
global $argc, $argv;
|
||||||
$t = "usage: " . $argv[0] . " [options]\noptions:\n";
|
$t = "usage: " . $argv[0] . " [options]\noptions:\n";
|
||||||
foreach ($this->argt as $n => $v)
|
foreach ($this->argt as $n => $v) {
|
||||||
$t .= "\t" . $n . $v["usage"] . "\n";
|
$t .= "\t" . $n . $v["usage"] . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return($t);
|
return($t);
|
||||||
}
|
}
|
||||||
|
@@ -67,8 +67,9 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
if ( ! $this->running)
|
if ( ! $this->running) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
try {
|
try {
|
||||||
@@ -119,8 +120,6 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
{
|
{
|
||||||
$ret = self::STATE_OK;
|
$ret = self::STATE_OK;
|
||||||
|
|
||||||
$conn = $appbox->get_connection();
|
|
||||||
$tsub = array();
|
|
||||||
try {
|
try {
|
||||||
// get the records to process
|
// get the records to process
|
||||||
$rs = $this->retrieveContent($appbox);
|
$rs = $this->retrieveContent($appbox);
|
||||||
@@ -132,8 +131,9 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$rowstodo = count($rs);
|
$rowstodo = count($rs);
|
||||||
$rowsdone = 0;
|
$rowsdone = 0;
|
||||||
|
|
||||||
if ($rowstodo > 0)
|
if ($rowstodo > 0) {
|
||||||
$this->setProgress(0, $rowstodo);
|
$this->setProgress(0, $rowstodo);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
try {
|
try {
|
||||||
@@ -174,8 +174,9 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->running)
|
if ( ! $this->running) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// if nothing was done, at least check the status
|
// if nothing was done, at least check the status
|
||||||
@@ -205,8 +206,9 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rowstodo > 0)
|
if ($rowstodo > 0) {
|
||||||
$this->setProgress(0, 0);
|
$this->setProgress(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@@ -79,8 +79,9 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($rs as $row) { // every sbas
|
foreach ($rs as $row) { // every sbas
|
||||||
if ( ! $this->running)
|
if ( ! $this->running) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$this->sbas_id = (int) $row['sbas_id'];
|
$this->sbas_id = (int) $row['sbas_id'];
|
||||||
$this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id));
|
$this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id));
|
||||||
@@ -140,7 +141,6 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
{
|
{
|
||||||
$ret = self::STATE_OK;
|
$ret = self::STATE_OK;
|
||||||
|
|
||||||
$tsub = array();
|
|
||||||
$connbas = false;
|
$connbas = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -156,8 +156,9 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$rowstodo = count($rs);
|
$rowstodo = count($rs);
|
||||||
$rowsdone = 0;
|
$rowsdone = 0;
|
||||||
|
|
||||||
if ($rowstodo > 0)
|
if ($rowstodo > 0) {
|
||||||
$this->setProgress(0, $rowstodo);
|
$this->setProgress(0, $rowstodo);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
try {
|
try {
|
||||||
@@ -196,8 +197,9 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->running)
|
if ( ! $this->running) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// if nothing was done, at least check the status
|
// if nothing was done, at least check the status
|
||||||
@@ -233,8 +235,9 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
unset($connbas);
|
unset($connbas);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rowstodo > 0)
|
if ($rowstodo > 0) {
|
||||||
$this->setProgress(0, 0);
|
$this->setProgress(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@@ -33,8 +33,9 @@ class task_manager
|
|||||||
|
|
||||||
public function getTasks($refresh = false)
|
public function getTasks($refresh = false)
|
||||||
{
|
{
|
||||||
if ($this->tasks && ! $refresh)
|
if ($this->tasks && ! $refresh) {
|
||||||
return $this->tasks;
|
return $this->tasks;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
||||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||||
@@ -51,8 +52,9 @@ class task_manager
|
|||||||
$row['pid'] = NULL;
|
$row['pid'] = NULL;
|
||||||
|
|
||||||
$classname = $row['class'];
|
$classname = $row['class'];
|
||||||
if ( ! class_exists($classname))
|
if ( ! class_exists($classname)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// if( ($lock = fopen( $lockdir . 'task.'.$row['task_id'].'.lock', 'a+')) )
|
// if( ($lock = fopen( $lockdir . 'task.'.$row['task_id'].'.lock', 'a+')) )
|
||||||
// {
|
// {
|
||||||
@@ -129,7 +131,7 @@ class task_manager
|
|||||||
$pid = NULL;
|
$pid = NULL;
|
||||||
|
|
||||||
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
|
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
|
||||||
if (($schedlock = fopen($lockdir . 'scheduler.lock', 'a+'))) {
|
if (($schedlock = fopen($lockdir . 'scheduler.lock', 'a+')) != FALSE) {
|
||||||
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
|
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
|
||||||
// already locked : running !
|
// already locked : running !
|
||||||
$pid = trim(fgets($schedlock, 512));
|
$pid = trim(fgets($schedlock, 512));
|
||||||
@@ -159,12 +161,12 @@ class task_manager
|
|||||||
|
|
||||||
$tasks = array();
|
$tasks = array();
|
||||||
foreach ($taskdir as $path) {
|
foreach ($taskdir as $path) {
|
||||||
if (($hdir = @opendir($path))) {
|
if (($hdir = @opendir($path)) != FALSE) {
|
||||||
$tskin = array();
|
|
||||||
$max = 9999;
|
$max = 9999;
|
||||||
while (($max -- > 0) && (($file = readdir($hdir)) !== false)) {
|
while (($max -- > 0) && (($file = readdir($hdir)) !== false)) {
|
||||||
if ( ! is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php")
|
if ( ! is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php") {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$classname = 'task_period_' . substr($file, 0, strlen($file) - 10);
|
$classname = 'task_period_' . substr($file, 0, strlen($file) - 10);
|
||||||
|
|
||||||
|
@@ -77,10 +77,11 @@ class task_period_apibridge extends task_appboxAbstract
|
|||||||
|
|
||||||
$this->log("process " . $element->get_id() . " with status " . $element->get_status());
|
$this->log("process " . $element->get_id() . " with status " . $element->get_status());
|
||||||
|
|
||||||
if ($element->get_status() == Bridge_Element::STATUS_PENDING)
|
if ($element->get_status() == Bridge_Element::STATUS_PENDING) {
|
||||||
$this->upload_element($element);
|
$this->upload_element($element);
|
||||||
else
|
} else {
|
||||||
$this->update_element($element);
|
$this->update_element($element);
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$sql = 'UPDATE bridge_elements SET status = :status WHERE id = :id';
|
$sql = 'UPDATE bridge_elements SET status = :status WHERE id = :id';
|
||||||
|
|
||||||
|
@@ -101,10 +101,11 @@ class task_period_archive extends task_abstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
||||||
@@ -134,16 +135,18 @@ class task_period_archive extends task_abstract
|
|||||||
*/
|
*/
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
// ... but we could check for safe values (ex. 0 < period < 3600)
|
// ... but we could check for safe values (ex. 0 < period < 3600)
|
||||||
if ((int) ($sxml->period) < 10)
|
if ((int) ($sxml->period) < 10) {
|
||||||
$sxml->period = 10;
|
$sxml->period = 10;
|
||||||
elseif ((int) ($sxml->period) > 300)
|
} elseif ((int) ($sxml->period) > 300) {
|
||||||
$sxml->period = 300;
|
$sxml->period = 300;
|
||||||
if ((int) ($sxml->cold) < 5)
|
}
|
||||||
|
if ((int) ($sxml->cold) < 5) {
|
||||||
$sxml->cold = 5;
|
$sxml->cold = 5;
|
||||||
elseif ((int) ($sxml->cold) > 3600)
|
} elseif ((int) ($sxml->cold) > 3600) {
|
||||||
$sxml->cold = 3600;
|
$sxml->cold = 3600;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var i;
|
var i;
|
||||||
@@ -165,8 +168,7 @@ class task_period_archive extends task_abstract
|
|||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
} else { // ... so we NEVER come here
|
||||||
else { // ... so we NEVER come here
|
|
||||||
// bad xml
|
// bad xml
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
@@ -295,8 +297,9 @@ class task_period_archive extends task_abstract
|
|||||||
$collection = null;
|
$collection = null;
|
||||||
foreach ($databox->get_collections() as $coll) {
|
foreach ($databox->get_collections() as $coll) {
|
||||||
$this->TColls['c' . $coll->get_coll_id()] = $coll->get_coll_id();
|
$this->TColls['c' . $coll->get_coll_id()] = $coll->get_coll_id();
|
||||||
if ($base_id == $coll->get_base_id())
|
if ($base_id == $coll->get_base_id()) {
|
||||||
$collection = $coll;
|
$collection = $coll;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$server_coll_id = $collection->get_coll_id();
|
$server_coll_id = $collection->get_coll_id();
|
||||||
|
|
||||||
@@ -307,18 +310,20 @@ class task_period_archive extends task_abstract
|
|||||||
$this->cold = 60;
|
$this->cold = 60;
|
||||||
|
|
||||||
|
|
||||||
if (($this->sxBasePrefs = simplexml_load_string($collection->get_prefs()))) {
|
if (($this->sxBasePrefs = simplexml_load_string($collection->get_prefs())) != FALSE) {
|
||||||
$this->sxBasePrefs["id"] = $base_id;
|
$this->sxBasePrefs["id"] = $base_id;
|
||||||
|
|
||||||
$do_it = true;
|
$do_it = true;
|
||||||
|
|
||||||
$this->period = (int) ($this->sxTaskSettings->period);
|
$this->period = (int) ($this->sxTaskSettings->period);
|
||||||
if ($this->period <= 0 || $this->period >= 60 * 60)
|
if ($this->period <= 0 || $this->period >= 60 * 60) {
|
||||||
$this->period = 60;
|
$this->period = 60;
|
||||||
|
}
|
||||||
|
|
||||||
$this->cold = (int) ($this->sxTaskSettings->cold);
|
$this->cold = (int) ($this->sxTaskSettings->cold);
|
||||||
if ($this->cold <= 0 || $this->cold >= 60 * 60)
|
if ($this->cold <= 0 || $this->cold >= 60 * 60) {
|
||||||
$this->cold = 60;
|
$this->cold = 60;
|
||||||
|
}
|
||||||
|
|
||||||
// check the data-repository exists
|
// check the data-repository exists
|
||||||
$pathhd = (string) ($this->sxBasePrefs->path);
|
$pathhd = (string) ($this->sxBasePrefs->path);
|
||||||
@@ -333,21 +338,23 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
// load masks
|
// load masks
|
||||||
if ($this->sxTaskSettings->files && $this->sxTaskSettings->files->file) {
|
if ($this->sxTaskSettings->files && $this->sxTaskSettings->files->file) {
|
||||||
foreach ($this->sxTaskSettings->files->file as $ft)
|
foreach ($this->sxTaskSettings->files->file as $ft) {
|
||||||
$this->tmask[] = array(
|
$this->tmask[] = array(
|
||||||
"mask" => (string) $ft["mask"]
|
"mask" => (string) $ft["mask"]
|
||||||
, "caption" => (string) $ft["caption"]
|
, "caption" => (string) $ft["caption"]
|
||||||
, "accept" => (string) $ft["accept"]
|
, "accept" => (string) $ft["accept"]
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($this->sxTaskSettings->files && $this->sxTaskSettings->files->grouping) {
|
if ($this->sxTaskSettings->files && $this->sxTaskSettings->files->grouping) {
|
||||||
foreach ($this->sxTaskSettings->files->grouping as $ft)
|
foreach ($this->sxTaskSettings->files->grouping as $ft) {
|
||||||
$this->tmaskgrp[] = array(
|
$this->tmaskgrp[] = array(
|
||||||
"mask" => (string) $ft["mask"]
|
"mask" => (string) $ft["mask"]
|
||||||
, "caption" => (string) $ft["caption"]
|
, "caption" => (string) $ft["caption"]
|
||||||
, "representation" => (string) $ft["representation"]
|
, "representation" => (string) $ft["representation"]
|
||||||
, "accept" => (string) $ft["accept"]
|
, "accept" => (string) $ft["accept"]
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (count($this->tmask) == 0) {
|
if (count($this->tmask) == 0) {
|
||||||
// no mask defined : accept all kind of files
|
// no mask defined : accept all kind of files
|
||||||
@@ -410,13 +417,14 @@ class task_period_archive extends task_abstract
|
|||||||
$this->move_error = p4field::isyes($this->sxTaskSettings->move_error);
|
$this->move_error = p4field::isyes($this->sxTaskSettings->move_error);
|
||||||
|
|
||||||
$period = (int) ($this->sxTaskSettings->period);
|
$period = (int) ($this->sxTaskSettings->period);
|
||||||
if ($period <= 0 || $period >= 60 * 60)
|
if ($period <= 0 || $period >= 60 * 60) {
|
||||||
$period = 60;
|
$period = 60;
|
||||||
|
}
|
||||||
$cold = (int) ($this->sxTaskSettings->cold);
|
$cold = (int) ($this->sxTaskSettings->cold);
|
||||||
if ($cold <= 0 || $cold >= 60 * 60)
|
if ($cold <= 0 || $cold >= 60 * 60) {
|
||||||
$cold = 60;
|
$cold = 60;
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
|
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -443,8 +451,9 @@ class task_period_archive extends task_abstract
|
|||||||
$duration = time();
|
$duration = time();
|
||||||
$r = $this->archiveHotFolder($server_coll_id);
|
$r = $this->archiveHotFolder($server_coll_id);
|
||||||
|
|
||||||
if ($loop > 10)
|
if ($loop > 10) {
|
||||||
$r = 'MAXLOOP';
|
$r = 'MAXLOOP';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($r) {
|
switch ($r) {
|
||||||
case 'TOSTOP':
|
case 'TOSTOP':
|
||||||
@@ -550,13 +559,15 @@ class task_period_archive extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$cold = (int) ($this->sxTaskSettings->cold);
|
$cold = (int) ($this->sxTaskSettings->cold);
|
||||||
if ($cold <= 0 || $cold >= 60 * 60)
|
if ($cold <= 0 || $cold >= 60 * 60) {
|
||||||
$cold = 60;
|
$cold = 60;
|
||||||
|
}
|
||||||
|
|
||||||
while ($cold > 0) {
|
while ($cold > 0) {
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATE_TOSTOP)
|
if ($s == self::STATE_TOSTOP) {
|
||||||
return('TOSTOP');
|
return('TOSTOP');
|
||||||
|
}
|
||||||
sleep(2);
|
sleep(2);
|
||||||
$cold -= 2;
|
$cold -= 2;
|
||||||
}
|
}
|
||||||
@@ -682,14 +693,15 @@ class task_period_archive extends task_abstract
|
|||||||
try {
|
try {
|
||||||
$listFolder = new CListFolder($path);
|
$listFolder = new CListFolder($path);
|
||||||
|
|
||||||
if (($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml'))) {
|
if (($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')) != FALSE) {
|
||||||
// on gere le magicfile
|
// on gere le magicfile
|
||||||
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
||||||
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
|
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
|
||||||
if ($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
|
if ($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile)) {
|
||||||
return;
|
return;
|
||||||
elseif ($magicmethod == 'UNLOCK' && ! file_exists($path . '/' . $magicfile))
|
} elseif ($magicmethod == 'UNLOCK' && ! file_exists($path . '/' . $magicfile)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on gere le changement de collection
|
// on gere le changement de collection
|
||||||
@@ -716,11 +728,13 @@ class task_period_archive extends task_abstract
|
|||||||
$time0 = time();
|
$time0 = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($iloop ++ % 100) == 0)
|
if (($iloop ++ % 100) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isIgnoredFile($file))
|
if ($this->isIgnoredFile($file)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_dir($path . '/' . $file)) {
|
if (is_dir($path . '/' . $file)) {
|
||||||
$n = $node->appendChild($dom->createElement('file'));
|
$n = $node->appendChild($dom->createElement('file'));
|
||||||
@@ -738,8 +752,9 @@ class task_period_archive extends task_abstract
|
|||||||
$n = $node->appendChild($dom->createElement('file'));
|
$n = $node->appendChild($dom->createElement('file'));
|
||||||
$n->setAttribute('name', $file);
|
$n->setAttribute('name', $file);
|
||||||
$stat = stat($path . '/' . $file);
|
$stat = stat($path . '/' . $file);
|
||||||
foreach (array("size", "ctime", "mtime") as $k)
|
foreach (array("size", "ctime", "mtime") as $k) {
|
||||||
$n->setAttribute($k, $stat[$k]);
|
$n->setAttribute($k, $stat[$k]);
|
||||||
|
}
|
||||||
$nnew ++;
|
$nnew ++;
|
||||||
}
|
}
|
||||||
$n->setAttribute('cid', $server_coll_id);
|
$n->setAttribute('cid', $server_coll_id);
|
||||||
@@ -767,8 +782,9 @@ class task_period_archive extends task_abstract
|
|||||||
function listFilesPhase2($dom, $node, $path, $depth = 0)
|
function listFilesPhase2($dom, $node, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$nnew = 0;
|
$nnew = 0;
|
||||||
|
|
||||||
@@ -777,32 +793,36 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
$xp = new DOMXPath($dom);
|
$xp = new DOMXPath($dom);
|
||||||
|
|
||||||
if (($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml'))) {
|
if (($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')) != FALSE) {
|
||||||
// on gere le magicfile
|
// on gere le magicfile
|
||||||
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
||||||
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
|
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
|
||||||
if ($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
|
if ($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile)) {
|
||||||
return;
|
return;
|
||||||
elseif ($magicmethod == 'UNLOCK' && ! file_exists($path . '/' . $magicfile))
|
} elseif ($magicmethod == 'UNLOCK' && ! file_exists($path . '/' . $magicfile)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on gere le magicfile
|
// on gere le magicfile
|
||||||
if (($magicfile = trim((string) @($sxDotPhrasea->magicfile))) != '') {
|
if (($magicfile = trim((string) @($sxDotPhrasea->magicfile))) != '') {
|
||||||
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
|
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
|
||||||
if ($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
|
if ($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile)) {
|
||||||
return;
|
return;
|
||||||
elseif ($magicmethod == 'UNLOCK' && ! file_exists($path . '/' . $magicfile))
|
} elseif ($magicmethod == 'UNLOCK' && ! file_exists($path . '/' . $magicfile)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (($file = $listFolder->read()) !== NULL) {
|
while (($file = $listFolder->read()) !== NULL) {
|
||||||
if ($this->isIgnoredFile($file))
|
if ($this->isIgnoredFile($file)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (($iloop ++ % 100) == 0)
|
if (($iloop ++ % 100) == 0) {
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
$dnl = @$xp->query('./file[@name="' . $file . '"]', $node);
|
$dnl = @$xp->query('./file[@name="' . $file . '"]', $node);
|
||||||
if ($dnl && $dnl->length == 0) {
|
if ($dnl && $dnl->length == 0) {
|
||||||
@@ -865,24 +885,29 @@ class task_period_archive extends task_abstract
|
|||||||
function makePairs($dom, $node, $path, $path_archived, $path_error, $inGrp = false, $depth = 0)
|
function makePairs($dom, $node, $path, $path_archived, $path_error, $inGrp = false, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($depth == 0 && ($node->getAttribute('temperature') == 'hot' || $node->getAttribute('cid') == '-1'))
|
if ($depth == 0 && ($node->getAttribute('temperature') == 'hot' || $node->getAttribute('cid') == '-1')) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$xpath = new DOMXPath($dom); // useful
|
$xpath = new DOMXPath($dom); // useful
|
||||||
|
|
||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
if (($iloop ++ % 100) == 0)
|
if (($iloop ++ % 100) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
// make xml lighter (free ram)
|
// make xml lighter (free ram)
|
||||||
foreach (array("size", "ctime", "mtime") as $k)
|
foreach (array("size", "ctime", "mtime") as $k) {
|
||||||
$n->removeAttribute($k);
|
$n->removeAttribute($k);
|
||||||
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('temperature') == 'hot' || $n->getAttribute('cid') == '-1')
|
if ($n->getAttribute('temperature') == 'hot' || $n->getAttribute('cid') == '-1') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$name = $n->getAttribute('name');
|
$name = $n->getAttribute('name');
|
||||||
if ($n->getAttribute('isdir') == '1') {
|
if ($n->getAttribute('isdir') == '1') {
|
||||||
@@ -940,8 +965,9 @@ class task_period_archive extends task_abstract
|
|||||||
$this->setAllChildren($dom, $n, array('error' => '1'));
|
$this->setAllChildren($dom, $n, array('error' => '1'));
|
||||||
|
|
||||||
// bubble to the top
|
// bubble to the top
|
||||||
for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode)
|
for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode) {
|
||||||
$nn->setAttribute('error', '1');
|
$nn->setAttribute('error', '1');
|
||||||
|
}
|
||||||
|
|
||||||
// ... as the existing linked file(s) ...
|
// ... as the existing linked file(s) ...
|
||||||
foreach ($flink as $linkName => $v) {
|
foreach ($flink as $linkName => $v) {
|
||||||
@@ -961,10 +987,11 @@ class task_period_archive extends task_abstract
|
|||||||
} else {
|
} else {
|
||||||
// this is a file
|
// this is a file
|
||||||
if ( ! $n->getAttribute('match')) { // because match can be set before
|
if ( ! $n->getAttribute('match')) { // because match can be set before
|
||||||
if ($name == '.phrasea.xml')
|
if ($name == '.phrasea.xml') {
|
||||||
$n->setAttribute('match', '*'); // special file(s) always ok
|
$n->setAttribute('match', '*'); // special file(s) always ok
|
||||||
else
|
} else {
|
||||||
$this->checkMatch($dom, $n);
|
$this->checkMatch($dom, $n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -973,8 +1000,9 @@ class task_period_archive extends task_abstract
|
|||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
if ( ! $n->getAttribute('isdir') == '1' && ! $n->getAttribute('match')) {
|
if ( ! $n->getAttribute('isdir') == '1' && ! $n->getAttribute('match')) {
|
||||||
// still no match, now it's an error (bubble to the top)
|
// still no match, now it's an error (bubble to the top)
|
||||||
for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode)
|
for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode) {
|
||||||
$nn->setAttribute('error', '1');
|
$nn->setAttribute('error', '1');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,8 +1025,9 @@ class task_period_archive extends task_abstract
|
|||||||
function removeBadGroups($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
function removeBadGroups($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
|
|
||||||
@@ -1007,11 +1036,13 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
$nodesToDel = array();
|
$nodesToDel = array();
|
||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
if (($iloop ++ % 20) == 0)
|
if (($iloop ++ % 20) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('temperature') == 'hot') // do not move hotfiles
|
if ($n->getAttribute('temperature') == 'hot') {
|
||||||
continue;
|
continue; // do not move hotfiles
|
||||||
|
}
|
||||||
|
|
||||||
$name = $n->getAttribute('name');
|
$name = $n->getAttribute('name');
|
||||||
|
|
||||||
@@ -1045,8 +1076,9 @@ class task_period_archive extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($nodesToDel as $n)
|
foreach ($nodesToDel as $n) {
|
||||||
$n->parentNode->removeChild($n);
|
$n->parentNode->removeChild($n);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1068,19 +1100,23 @@ class task_period_archive extends task_abstract
|
|||||||
function archive($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
function archive($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($node->getAttribute('temperature') == 'hot')
|
if ($node->getAttribute('temperature') == 'hot') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$nodesToDel = array();
|
$nodesToDel = array();
|
||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
if (($iloop ++ % 20) == 0)
|
if (($iloop ++ % 20) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('temperature') == 'hot')
|
if ($n->getAttribute('temperature') == 'hot') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('cid') == '-1') {
|
if ($n->getAttribute('cid') == '-1') {
|
||||||
$n->setAttribute('error', '1');
|
$n->setAttribute('error', '1');
|
||||||
@@ -1104,16 +1140,18 @@ class task_period_archive extends task_abstract
|
|||||||
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, 0); // 0 = no grp
|
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, 0); // 0 = no grp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($nodesToDel as $n)
|
foreach ($nodesToDel as $n) {
|
||||||
$n->parentNode->removeChild($n);
|
$n->parentNode->removeChild($n);
|
||||||
|
}
|
||||||
|
|
||||||
// at the end of recursion, restore the magic file (create or delete it)
|
// at the end of recursion, restore the magic file (create or delete it)
|
||||||
if (($magicfile = $node->getAttribute('magicfile')) != '') {
|
if (($magicfile = $node->getAttribute('magicfile')) != '') {
|
||||||
$magicmethod = $node->getAttribute('magicmethod');
|
$magicmethod = $node->getAttribute('magicmethod');
|
||||||
if ($magicmethod == 'LOCK')
|
if ($magicmethod == 'LOCK') {
|
||||||
file_put_contents($path . '/' . $magicfile, '');
|
file_put_contents($path . '/' . $magicfile, '');
|
||||||
elseif ($magicmethod == 'UNLOCK')
|
} elseif ($magicmethod == 'UNLOCK') {
|
||||||
unlink($path . '/' . $magicfile);
|
unlink($path . '/' . $magicfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -1134,22 +1172,26 @@ class task_period_archive extends task_abstract
|
|||||||
function bubbleResults($dom, $node, $path, $depth = 0)
|
function bubbleResults($dom, $node, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($node->getAttribute('temperature') == 'hot')
|
if ($node->getAttribute('temperature') == 'hot') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
if (($iloop ++ % 20) == 0)
|
if (($iloop ++ % 20) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('name') == '.phrasea.xml' || $n->getAttribute('name') == '.grouping.xml') {
|
if ($n->getAttribute('name') == '.phrasea.xml' || $n->getAttribute('name') == '.grouping.xml') {
|
||||||
// special files stay in place AND are copied into 'archived'
|
// special files stay in place AND are copied into 'archived'
|
||||||
$n->setAttribute('keep', '1');
|
$n->setAttribute('keep', '1');
|
||||||
if (p4field::isyes($this->sxTaskSettings->copy_spe))
|
if (p4field::isyes($this->sxTaskSettings->copy_spe)) {
|
||||||
$n->setAttribute('archived', '1');
|
$n->setAttribute('archived', '1');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
@@ -1158,21 +1200,28 @@ class task_period_archive extends task_abstract
|
|||||||
// $n->setAttribute('error', '1');
|
// $n->setAttribute('error', '1');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if ($n->getAttribute('keep') == '1')
|
if ($n->getAttribute('keep') == '1') {
|
||||||
$ret |= 1;
|
$ret |= 1;
|
||||||
if ($n->getAttribute('archived') == '1')
|
}
|
||||||
|
if ($n->getAttribute('archived') == '1') {
|
||||||
$ret |= 2;
|
$ret |= 2;
|
||||||
if ($n->getAttribute('error') == '1')
|
}
|
||||||
|
if ($n->getAttribute('error') == '1') {
|
||||||
$ret |= 4;
|
$ret |= 4;
|
||||||
if ($n->getAttribute('isdir') == '1')
|
}
|
||||||
|
if ($n->getAttribute('isdir') == '1') {
|
||||||
$ret |= $this->bubbleResults($dom, $n, $path . '/' . $n->getAttribute('name'), $depth + 1);
|
$ret |= $this->bubbleResults($dom, $n, $path . '/' . $n->getAttribute('name'), $depth + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($ret & 1)
|
if ($ret & 1) {
|
||||||
$node->setAttribute('keep', '1');
|
$node->setAttribute('keep', '1');
|
||||||
if ($ret & 2)
|
}
|
||||||
|
if ($ret & 2) {
|
||||||
$node->setAttribute('archived', '1');
|
$node->setAttribute('archived', '1');
|
||||||
if ($ret & 4)
|
}
|
||||||
|
if ($ret & 4) {
|
||||||
$node->setAttribute('error', '1');
|
$node->setAttribute('error', '1');
|
||||||
|
}
|
||||||
|
|
||||||
return($ret);
|
return($ret);
|
||||||
}
|
}
|
||||||
@@ -1193,71 +1242,43 @@ class task_period_archive extends task_abstract
|
|||||||
function moveFiles($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
function moveFiles($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
|
|
||||||
if ($depth == 0 && $node->getAttribute('temperature') == 'hot') // if root of hotfolder if hot, die...
|
if ($depth == 0 && $node->getAttribute('temperature') == 'hot') { // if root of hotfolder if hot, die...
|
||||||
return($ret);
|
return($ret);
|
||||||
|
}
|
||||||
|
|
||||||
//printf("%s : \n", __LINE__);
|
//printf("%s : \n", __LINE__);
|
||||||
$nodesToDel = array();
|
$nodesToDel = array();
|
||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
if (($iloop ++ % 20) == 0)
|
if (($iloop ++ % 20) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('temperature') == 'hot') // do not move hotfiles
|
if ($n->getAttribute('temperature') == 'hot') { // do not move hotfiles
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//printf("%s : \n", __LINE__);
|
|
||||||
$name = $n->getAttribute('name');
|
$name = $n->getAttribute('name');
|
||||||
//printf("----------------\n file %s : \n ", $path.'/'.$name);
|
|
||||||
//$fp = fopen('php://stdin', 'r');
|
|
||||||
//fgets($fp);
|
|
||||||
//fclose($fp);
|
|
||||||
|
|
||||||
if ($n->getAttribute('isdir')) {
|
if ($n->getAttribute('isdir')) {
|
||||||
// printf("%s : ('%s', '%s')\n", __LINE__, $path_archived, $path_error);
|
|
||||||
// $new_path_archived = $new_path_error = null;
|
|
||||||
// if($n->getAttribute('archived') && $this->move_archived)
|
|
||||||
// {
|
|
||||||
// @mkdir($new_path_archived = ($path_archived . '/' . $name));
|
|
||||||
// if(!is_dir($new_path_archived))
|
|
||||||
// {
|
|
||||||
// $rootpath = p4string::delEndSlash(trim((string)($this->sxTaskSettings->hotfolder)));
|
|
||||||
// $subpath = substr($new_path_archived, strlen($rootpath));
|
|
||||||
//
|
|
||||||
// $this->log("error subfolder '".$subpath."' does not exits");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if($n->getAttribute('error') && $this->move_error)
|
|
||||||
// {
|
|
||||||
// @mkdir($new_path_error = ($path_error . '/' . $name));
|
|
||||||
// if(!is_dir($new_path_error))
|
|
||||||
// {
|
|
||||||
// $rootpath = p4string::delEndSlash(trim((string)($this->sxTaskSettings->hotfolder)));
|
|
||||||
// $subpath = substr($new_path_error, strlen($rootpath));
|
|
||||||
//
|
|
||||||
// $this->log("error subfolder '".$subpath."' does not exists");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
$ret |= $this->moveFiles($dom, $n, $path . '/' . $name
|
$ret |= $this->moveFiles($dom, $n, $path . '/' . $name
|
||||||
, $path_archived . '/' . $name
|
, $path_archived . '/' . $name
|
||||||
, $path_error . '/' . $name
|
, $path_error . '/' . $name
|
||||||
, $depth + 1);
|
, $depth + 1);
|
||||||
|
|
||||||
if ( ! $n->firstChild)
|
if ( ! $n->firstChild) {
|
||||||
$nodesToDel[] = $n;
|
$nodesToDel[] = $n;
|
||||||
|
}
|
||||||
// ----- JY 20100318 : DO NOT DELETE EMPTY FOLDERS ANYMORE, AS THEY MAY DISAPEAR TOO SOON -----
|
// ----- JY 20100318 : DO NOT DELETE EMPTY FOLDERS ANYMORE, AS THEY MAY DISAPEAR TOO SOON -----
|
||||||
// if(!$n->getAttribute('keep'))
|
// if(!$n->getAttribute('keep'))
|
||||||
// @rmdir($path.'/'.$name);
|
// @rmdir($path.'/'.$name);
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//printf("%s : \n", __LINE__);
|
|
||||||
$rootpath = p4string::delEndSlash(trim((string) ($this->sxTaskSettings->hotfolder)));
|
$rootpath = p4string::delEndSlash(trim((string) ($this->sxTaskSettings->hotfolder)));
|
||||||
$subpath = substr($path, strlen($rootpath));
|
$subpath = substr($path, strlen($rootpath));
|
||||||
|
|
||||||
@@ -1273,7 +1294,6 @@ class task_period_archive extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($n->getAttribute('error') && $this->move_error) {
|
if ($n->getAttribute('error') && $this->move_error) {
|
||||||
// printf("%s : \n", __LINE__);
|
|
||||||
$this->log(sprintf(('copy \'%s\' to \'error\''), $subpath . '/' . $name));
|
$this->log(sprintf(('copy \'%s\' to \'error\''), $subpath . '/' . $name));
|
||||||
|
|
||||||
@mkdir($path_error, 0755, true);
|
@mkdir($path_error, 0755, true);
|
||||||
@@ -1282,11 +1302,9 @@ class task_period_archive extends task_abstract
|
|||||||
$nodesToDel[] = $n;
|
$nodesToDel[] = $n;
|
||||||
$ret = true;
|
$ret = true;
|
||||||
}
|
}
|
||||||
//printf("-> copy to %s \n", $path_error.'/'.$name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $n->getAttribute('keep')) {
|
if ( ! $n->getAttribute('keep')) {
|
||||||
//printf("-> unlink %s \n", $path.'/'.$name);
|
|
||||||
$this->log(sprintf(('delete \'%s\''), $subpath . '/' . $name));
|
$this->log(sprintf(('delete \'%s\''), $subpath . '/' . $name));
|
||||||
if (@unlink($path . '/' . $name)) {
|
if (@unlink($path . '/' . $name)) {
|
||||||
// $n->parentNode->removeChild($n);
|
// $n->parentNode->removeChild($n);
|
||||||
@@ -1298,8 +1316,9 @@ class task_period_archive extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($nodesToDel as $n)
|
foreach ($nodesToDel as $n) {
|
||||||
$n->parentNode->removeChild($n);
|
$n->parentNode->removeChild($n);
|
||||||
|
}
|
||||||
|
|
||||||
return($ret);
|
return($ret);
|
||||||
}
|
}
|
||||||
@@ -1315,8 +1334,9 @@ class task_period_archive extends task_abstract
|
|||||||
for ($n = $node; $n; $n = $n->parentNode) {
|
for ($n = $node; $n; $n = $n->parentNode) {
|
||||||
if ($n->nodeType == XML_ELEMENT_NODE) {
|
if ($n->nodeType == XML_ELEMENT_NODE) {
|
||||||
$n->setAttribute('temperature', 'hot');
|
$n->setAttribute('temperature', 'hot');
|
||||||
if ($n->hasAttribute('pxml'))
|
if ($n->hasAttribute('pxml')) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1374,7 +1394,7 @@ class task_period_archive extends task_abstract
|
|||||||
$this->log(sprintf(('representation from \'%s\''), $representationFileName));
|
$this->log(sprintf(('representation from \'%s\''), $representationFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($cap = $node->getAttribute('grp_caption'))) {
|
if (($cap = $node->getAttribute('grp_caption')) != '') {
|
||||||
$dnl = $xpath->query('./file[@name="' . $cap . '"]', $node->parentNode);
|
$dnl = $xpath->query('./file[@name="' . $cap . '"]', $node->parentNode);
|
||||||
$captionFileNode = $dnl->item(0);
|
$captionFileNode = $dnl->item(0);
|
||||||
$captionFileName = $cap;
|
$captionFileName = $cap;
|
||||||
@@ -1399,15 +1419,19 @@ class task_period_archive extends task_abstract
|
|||||||
$meta = $system_file->extract_metadatas($databox->get_meta_structure(), $caption_file);
|
$meta = $system_file->extract_metadatas($databox->get_meta_structure(), $caption_file);
|
||||||
|
|
||||||
$stat0 = $stat1 = "0";
|
$stat0 = $stat1 = "0";
|
||||||
if ($this->sxBasePrefs->status)
|
if ($this->sxBasePrefs->status) {
|
||||||
$stat0 = (string) ($this->sxBasePrefs->status);
|
$stat0 = (string) ($this->sxBasePrefs->status);
|
||||||
if ($this->sxTaskSettings->status)
|
}
|
||||||
|
if ($this->sxTaskSettings->status) {
|
||||||
$stat1 = (string) ($this->sxTaskSettings->status);
|
$stat1 = (string) ($this->sxTaskSettings->status);
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $stat0)
|
if ( ! $stat0) {
|
||||||
$stat0 = '0';
|
$stat0 = '0';
|
||||||
if ( ! $stat1)
|
}
|
||||||
|
if ( ! $stat1) {
|
||||||
$stat1 = '0';
|
$stat1 = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1427,8 +1451,9 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($genericdoc)
|
if ($genericdoc) {
|
||||||
unlink($genericdoc);
|
unlink($genericdoc);
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents($groupingFile, '<?xml version="1.0" encoding="ISO-8859-1" ?><record grouping="' . $rid . '" />');
|
file_put_contents($groupingFile, '<?xml version="1.0" encoding="ISO-8859-1" ?><record grouping="' . $rid . '" />');
|
||||||
$n = $node->appendChild($dom->createElement('file'));
|
$n = $node->appendChild($dom->createElement('file'));
|
||||||
@@ -1449,8 +1474,9 @@ class task_period_archive extends task_abstract
|
|||||||
if ($this->move_archived) {
|
if ($this->move_archived) {
|
||||||
$this->log(sprintf(('copy \'%s\' to \'archived\''), $subpath . '/' . $captionFileName));
|
$this->log(sprintf(('copy \'%s\' to \'archived\''), $subpath . '/' . $captionFileName));
|
||||||
|
|
||||||
if ( ! is_dir($path_archived))
|
if ( ! is_dir($path_archived)) {
|
||||||
@mkdir($path_archived, 0755, true);
|
@mkdir($path_archived, 0755, true);
|
||||||
|
}
|
||||||
@copy($path . '/' . $captionFileName, $path_archived . '/' . $captionFileName);
|
@copy($path . '/' . $captionFileName, $path_archived . '/' . $captionFileName);
|
||||||
}
|
}
|
||||||
@unlink($path . '/' . $captionFileName);
|
@unlink($path . '/' . $captionFileName);
|
||||||
@@ -1463,8 +1489,9 @@ class task_period_archive extends task_abstract
|
|||||||
if ($this->move_archived) {
|
if ($this->move_archived) {
|
||||||
$this->log(sprintf(('copy \'%s\' to \'archived\''), $subpath . '/' . $representationFileName));
|
$this->log(sprintf(('copy \'%s\' to \'archived\''), $subpath . '/' . $representationFileName));
|
||||||
|
|
||||||
if ( ! is_dir($path_archived))
|
if ( ! is_dir($path_archived)) {
|
||||||
@mkdir($path_archived, 0755, true);
|
@mkdir($path_archived, 0755, true);
|
||||||
|
}
|
||||||
@copy($path . '/' . $representationFileName, $path_archived . '/' . $representationFileName);
|
@copy($path . '/' . $representationFileName, $path_archived . '/' . $representationFileName);
|
||||||
}
|
}
|
||||||
@unlink($path . '/' . $representationFileName);
|
@unlink($path . '/' . $representationFileName);
|
||||||
@@ -1527,8 +1554,9 @@ class task_period_archive extends task_abstract
|
|||||||
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, $grp_rid);
|
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, $grp_rid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($nodesToDel as $n)
|
foreach ($nodesToDel as $n) {
|
||||||
$n->parentNode->removeChild($n);
|
$n->parentNode->removeChild($n);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1548,8 +1576,9 @@ class task_period_archive extends task_abstract
|
|||||||
function archiveFile($dom, $node, $path, $path_archived, $path_error, &$nodesToDel, $grp_rid = 0)
|
function archiveFile($dom, $node, $path, $path_archived, $path_error, &$nodesToDel, $grp_rid = 0)
|
||||||
{
|
{
|
||||||
$match = $node->getAttribute('match');
|
$match = $node->getAttribute('match');
|
||||||
if ($match == '*')
|
if ($match == '*') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$file = $node->getAttribute('name');
|
$file = $node->getAttribute('name');
|
||||||
$cid = $node->getAttribute('cid');
|
$cid = $node->getAttribute('cid');
|
||||||
@@ -1571,7 +1600,7 @@ class task_period_archive extends task_abstract
|
|||||||
$node->setAttribute('error', '1');
|
$node->setAttribute('error', '1');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} elseif (($match != '.')) { // match='.' : the file does not have a separate caption
|
} elseif ($match != '.') { // match='.' : the file does not have a separate caption
|
||||||
$xpath = new DOMXPath($dom);
|
$xpath = new DOMXPath($dom);
|
||||||
$dnl = $xpath->query('./file[@name="' . $match . '"]', $node->parentNode);
|
$dnl = $xpath->query('./file[@name="' . $match . '"]', $node->parentNode);
|
||||||
// in fact, xquery has been done in checkMatch, setting match='?' if caption does not exists...
|
// in fact, xquery has been done in checkMatch, setting match='?' if caption does not exists...
|
||||||
@@ -1612,20 +1641,26 @@ class task_period_archive extends task_abstract
|
|||||||
$subpath = substr($path, strlen($rootpath));
|
$subpath = substr($path, strlen($rootpath));
|
||||||
|
|
||||||
$this->log(sprintf(("Archiving file '%s'"), $subpath . '/' . $file));
|
$this->log(sprintf(("Archiving file '%s'"), $subpath . '/' . $file));
|
||||||
if ($captionFileName !== NULL)
|
if ($captionFileName !== NULL) {
|
||||||
$this->log(sprintf(' ' . (" (caption in '%s')"), $captionFileName));
|
$this->log(sprintf(' ' . (" (caption in '%s')"), $captionFileName));
|
||||||
if ($grp_rid !== 0)
|
}
|
||||||
|
if ($grp_rid !== 0) {
|
||||||
$this->log(sprintf(' ' . (" into GRP rid=%s"), $grp_rid));
|
$this->log(sprintf(' ' . (" into GRP rid=%s"), $grp_rid));
|
||||||
|
}
|
||||||
|
|
||||||
$stat0 = $stat1 = "0";
|
$stat0 = $stat1 = "0";
|
||||||
if ($this->sxBasePrefs->status)
|
if ($this->sxBasePrefs->status) {
|
||||||
$stat0 = (string) ($this->sxBasePrefs->status);
|
$stat0 = (string) ($this->sxBasePrefs->status);
|
||||||
if ($this->sxTaskSettings->status)
|
}
|
||||||
|
if ($this->sxTaskSettings->status) {
|
||||||
$stat1 = (string) ($this->sxTaskSettings->status);
|
$stat1 = (string) ($this->sxTaskSettings->status);
|
||||||
if ( ! $stat0)
|
}
|
||||||
|
if ( ! $stat0) {
|
||||||
$stat0 = '0';
|
$stat0 = '0';
|
||||||
if ( ! $stat1)
|
}
|
||||||
|
if ( ! $stat1) {
|
||||||
$stat1 = '0';
|
$stat1 = '0';
|
||||||
|
}
|
||||||
|
|
||||||
$system_file = new system_file($path . '/' . $file);
|
$system_file = new system_file($path . '/' . $file);
|
||||||
|
|
||||||
@@ -1649,8 +1684,9 @@ class task_period_archive extends task_abstract
|
|||||||
$hexstat = '';
|
$hexstat = '';
|
||||||
if ($meta['status'] !== NULL) {
|
if ($meta['status'] !== NULL) {
|
||||||
$s = strrev($meta['status']) . str_repeat('0', 64);
|
$s = strrev($meta['status']) . str_repeat('0', 64);
|
||||||
for ($a = 0; $a < 4; $a ++ )
|
for ($a = 0; $a < 4; $a ++ ) {
|
||||||
$hexstat = substr('0000' . base_convert(strrev(substr($s, $a << 4, 16)), 2, 16), -4) . $hexstat;
|
$hexstat = substr('0000' . base_convert(strrev(substr($s, $a << 4, 16)), 2, 16), -4) . $hexstat;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$hexstat = '0';
|
$hexstat = '0';
|
||||||
}
|
}
|
||||||
@@ -1675,8 +1711,9 @@ class task_period_archive extends task_abstract
|
|||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($row && uuid::is_valid($row['uuid']))
|
if ($row && uuid::is_valid($row['uuid'])) {
|
||||||
$uuid = $row['uuid'];
|
$uuid = $row['uuid'];
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1687,8 +1724,9 @@ class task_period_archive extends task_abstract
|
|||||||
$error_file = p4file::check_file_error($system_file->getPathname(), $sbas_id, $file);
|
$error_file = p4file::check_file_error($system_file->getPathname(), $sbas_id, $file);
|
||||||
$status = databox_status::operation_or($stat0, $stat1);
|
$status = databox_status::operation_or($stat0, $stat1);
|
||||||
|
|
||||||
if ($meta['status'])
|
if ($meta['status']) {
|
||||||
$status = databox_status::operation_or($status, $meta['status']);
|
$status = databox_status::operation_or($status, $meta['status']);
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $system_file->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
|
if ( ! $system_file->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
|
||||||
$this->log(sprintf(("Trying to move to lazaret")));
|
$this->log(sprintf(("Trying to move to lazaret")));
|
||||||
@@ -1737,13 +1775,15 @@ class task_period_archive extends task_abstract
|
|||||||
$this->archivedFiles ++;
|
$this->archivedFiles ++;
|
||||||
|
|
||||||
$node->setAttribute('archived', '1');
|
$node->setAttribute('archived', '1');
|
||||||
if ($captionFileNode)
|
if ($captionFileNode) {
|
||||||
$captionFileNode->setAttribute('archived', '1');
|
$captionFileNode->setAttribute('archived', '1');
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log(("Error : can't insert record : " . $e->getMessage()));
|
$this->log(("Error : can't insert record : " . $e->getMessage()));
|
||||||
$node->setAttribute('error', '1');
|
$node->setAttribute('error', '1');
|
||||||
if ($captionFileNode)
|
if ($captionFileNode) {
|
||||||
$captionFileNode->setAttribute('error', '1');
|
$captionFileNode->setAttribute('error', '1');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1804,17 +1844,21 @@ class task_period_archive extends task_abstract
|
|||||||
function setAllChildren($dom, $node, $attributes, $depth = 0)
|
function setAllChildren($dom, $node, $attributes, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0) {
|
||||||
$iloop = 0;
|
$iloop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($attributes as $a => $v)
|
foreach ($attributes as $a => $v) {
|
||||||
$node->setAttribute($a, $v);
|
$node->setAttribute($a, $v);
|
||||||
|
}
|
||||||
|
|
||||||
if (($iloop ++ % 100) == 0)
|
if (($iloop ++ % 100) == 0) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
for ($n = $node->firstChild; $n; $n = $n->nextSibling)
|
for ($n = $node->firstChild; $n; $n = $n->nextSibling) {
|
||||||
$this->setAllChildren($dom, $n, $attributes, $depth + 1);
|
$this->setAllChildren($dom, $n, $attributes, $depth + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1834,8 +1878,9 @@ class task_period_archive extends task_abstract
|
|||||||
if (preg_match($preg_maskgrp, $file)) {
|
if (preg_match($preg_maskgrp, $file)) {
|
||||||
$matched = $maskgrp;
|
$matched = $maskgrp;
|
||||||
}
|
}
|
||||||
if ($matched)
|
if ($matched) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return($matched);
|
return($matched);
|
||||||
@@ -1859,11 +1904,13 @@ class CListFolder
|
|||||||
{
|
{
|
||||||
$this->list = array();
|
$this->list = array();
|
||||||
if ($hdir = opendir($path)) {
|
if ($hdir = opendir($path)) {
|
||||||
while (false !== ($file = readdir($hdir)))
|
while (false !== ($file = readdir($hdir))) {
|
||||||
$this->list[] = $file;
|
$this->list[] = $file;
|
||||||
|
}
|
||||||
closedir($hdir);
|
closedir($hdir);
|
||||||
if ($sorted)
|
if ($sorted) {
|
||||||
natcasesort($this->list);
|
natcasesort($this->list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,8 +70,9 @@ class task_period_batchupload extends task_appboxAbstract
|
|||||||
try {
|
try {
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = databox::get_instance($sbas_id);
|
||||||
$path = $registry->get('GV_RootPath') . 'tmp/batches/' . $batch_id . '/';
|
$path = $registry->get('GV_RootPath') . 'tmp/batches/' . $batch_id . '/';
|
||||||
if ( ! is_dir($path))
|
if ( ! is_dir($path)) {
|
||||||
throw new Exception(sprintf(('Batch directory \'%s\' does not exist'), $path));
|
throw new Exception(sprintf(('Batch directory \'%s\' does not exist'), $path));
|
||||||
|
}
|
||||||
|
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = User_Adapter::getInstance($usr_id, $appbox);
|
||||||
$auth = new Session_Authentication_None($user);
|
$auth = new Session_Authentication_None($user);
|
||||||
|
@@ -135,10 +135,11 @@ class task_period_cindexer extends task_abstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cr<63>e
|
// le champ n'existait pas dans le xml, on le cr<63>e
|
||||||
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
||||||
@@ -167,7 +168,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
*/
|
*/
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<?php echo $form ?>.binpath.value = "<?php echo p4string::MakeString($sxml->binpath, "js", '"') ?>";
|
<?php echo $form ?>.binpath.value = "<?php echo p4string::MakeString($sxml->binpath, "js", '"') ?>";
|
||||||
@@ -200,8 +201,9 @@ class task_period_cindexer extends task_abstract
|
|||||||
public function printInterfaceJS()
|
public function printInterfaceJS()
|
||||||
{
|
{
|
||||||
$appname = 'phraseanet_indexer';
|
$appname = 'phraseanet_indexer';
|
||||||
if ($this->system == 'WINDOWS')
|
if ($this->system == 'WINDOWS') {
|
||||||
$appname .= '.exe';
|
$appname .= '.exe';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function calccmd()
|
function calccmd()
|
||||||
@@ -273,13 +275,14 @@ class task_period_cindexer extends task_abstract
|
|||||||
public function printInterfaceHTML()
|
public function printInterfaceHTML()
|
||||||
{
|
{
|
||||||
$appname = 'phraseanet_indexer';
|
$appname = 'phraseanet_indexer';
|
||||||
if ($this->system == 'WINDOWS')
|
if ($this->system == 'WINDOWS') {
|
||||||
$appname .= '.exe';
|
$appname .= '.exe';
|
||||||
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:executable') ?> :
|
<?php echo _('task::cindexer:executable') ?> :
|
||||||
<input type="text" name="binpath" style="width:300px;" onchange="chgxmltxt(this, 'binpath');" value=""> / <?php echo $appname ?>
|
<input type="text" name="binpath" style="width:300px;" onchange="chgxmltxt(this, 'binpath');" value=""> / <?php echo $appname ?>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:host') ?> : <input type="text" name="host" style="width:100px;" onchange="chgxmltxt(this, 'host');" value="">
|
<?php echo _('task::cindexer:host') ?> : <input type="text" name="host" style="width:100px;" onchange="chgxmltxt(this, 'host');" value="">
|
||||||
@@ -290,13 +293,13 @@ class task_period_cindexer extends task_abstract
|
|||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:user') ?> : <input type="text" name="user" style="width:200px;" onchange="chgxmltxt(this, 'user');" value="">
|
<?php echo _('task::cindexer:user') ?> : <input type="text" name="user" style="width:200px;" onchange="chgxmltxt(this, 'user');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:password') ?> : <input type="password" name="password" style="width:200px;" onchange="chgxmltxt(this, 'password');" value="">
|
<?php echo _('task::cindexer:password') ?> : <input type="password" name="password" style="width:200px;" onchange="chgxmltxt(this, 'password');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo _('task::cindexer:control socket') ?> : <input type="text" name="socket" style="width:50px;" onchange="chgxmltxt(this, 'socket');" value="">
|
<?php echo _('task::cindexer:control socket') ?> : <input type="text" name="socket" style="width:50px;" onchange="chgxmltxt(this, 'socket');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:Debug mask') ?> : <input type="text" name="debugmask" style="width:50px;" onchange="chgxmltxt(this, 'debugmask');" value="">
|
<?php echo _('task::cindexer:Debug mask') ?> : <input type="text" name="debugmask" style="width:50px;" onchange="chgxmltxt(this, 'debugmask');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@@ -305,20 +308,20 @@ class task_period_cindexer extends task_abstract
|
|||||||
<br/>
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php echo _('task::cindexer:MySQL charset') ?> : <input type="text" name="charset" style="width:100px;" onchange="chgxmltxt(this, 'charset');" value="">
|
<?php echo _('task::cindexer:MySQL charset') ?> : <input type="text" name="charset" style="width:100px;" onchange="chgxmltxt(this, 'charset');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<input type="checkbox" name="nolog" onclick="chgxmlck(this, 'nolog');"> <?php echo _('task::cindexer:do not (sys)log, but out to console)') ?>
|
<input type="checkbox" name="nolog" onclick="chgxmlck(this, 'nolog');"> <?php echo _('task::cindexer:do not (sys)log, but out to console)') ?>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo _('task::cindexer:default language for new candidates') ?> : <input type="text" name="clng" style="width:50px;" onchange="chgxmltxt(this, 'clng');" value="">
|
<?php echo _('task::cindexer:default language for new candidates') ?> : <input type="text" name="clng" style="width:50px;" onchange="chgxmltxt(this, 'clng');" value="">
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::cindexer:windows specific') ?> :<br/>
|
<?php echo _('task::cindexer:windows specific') ?> :<br/>
|
||||||
<input type="checkbox" name="winsvc_run" onclick="chgxmlck(this, 'run');"> <?php echo _('task::cindexer:run as application, not as service') ?>
|
<input type="checkbox" name="winsvc_run" onclick="chgxmlck(this, 'run');"> <?php echo _('task::cindexer:run as application, not as service') ?>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@@ -388,28 +391,39 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$args = array();
|
$args = array();
|
||||||
if ($this->host)
|
if ($this->host) {
|
||||||
$args[] = '-h=' . $this->host;
|
$args[] = '-h=' . $this->host;
|
||||||
if ($this->port)
|
}
|
||||||
|
if ($this->port) {
|
||||||
$args[] = '-P=' . $this->port;
|
$args[] = '-P=' . $this->port;
|
||||||
if ($this->base)
|
}
|
||||||
|
if ($this->base) {
|
||||||
$args[] = '-b=' . $this->base;
|
$args[] = '-b=' . $this->base;
|
||||||
if ($this->user)
|
}
|
||||||
|
if ($this->user) {
|
||||||
$args[] = '-u=' . $this->user;
|
$args[] = '-u=' . $this->user;
|
||||||
if ($this->password)
|
}
|
||||||
|
if ($this->password) {
|
||||||
$args[] = '-p=' . $this->password;
|
$args[] = '-p=' . $this->password;
|
||||||
if ($this->socket)
|
}
|
||||||
|
if ($this->socket) {
|
||||||
$args[] = '--socket=' . $this->socket;
|
$args[] = '--socket=' . $this->socket;
|
||||||
if ($this->use_sbas)
|
}
|
||||||
|
if ($this->use_sbas) {
|
||||||
$args[] = '-o';
|
$args[] = '-o';
|
||||||
if ($this->charset)
|
}
|
||||||
|
if ($this->charset) {
|
||||||
$args[] = '--default-character-set=' . $this->charset;
|
$args[] = '--default-character-set=' . $this->charset;
|
||||||
if ($this->debugmask > 0)
|
}
|
||||||
|
if ($this->debugmask > 0) {
|
||||||
$args[] = '-d=' . $this->debugmask;
|
$args[] = '-d=' . $this->debugmask;
|
||||||
if ($this->nolog)
|
}
|
||||||
|
if ($this->nolog) {
|
||||||
$args[] = '-n';
|
$args[] = '-n';
|
||||||
if ($this->winsvc_run)
|
}
|
||||||
|
if ($this->winsvc_run) {
|
||||||
$args[] = '--run';
|
$args[] = '--run';
|
||||||
|
}
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
|
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
|
||||||
@@ -430,11 +444,13 @@ class task_period_cindexer extends task_abstract
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->new_status !== NULL)
|
if ($this->new_status !== NULL) {
|
||||||
$this->setState($this->new_status);
|
$this->setState($this->new_status);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->exception)
|
if ($this->exception) {
|
||||||
throw $this->exception;
|
throw $this->exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function run_with_proc_open($cmd, $args)
|
private function run_with_proc_open($cmd, $args)
|
||||||
@@ -453,8 +469,9 @@ class task_period_cindexer extends task_abstract
|
|||||||
$pid = NULL;
|
$pid = NULL;
|
||||||
if (is_resource($process)) {
|
if (is_resource($process)) {
|
||||||
$proc_status = proc_get_status($process);
|
$proc_status = proc_get_status($process);
|
||||||
if ($proc_status['running'])
|
if ($proc_status['running']) {
|
||||||
$pid = $proc_status['pid'];
|
$pid = $proc_status['pid'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$qsent = '';
|
$qsent = '';
|
||||||
$timetokill = NULL;
|
$timetokill = NULL;
|
||||||
@@ -469,8 +486,9 @@ class task_period_cindexer extends task_abstract
|
|||||||
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
||||||
socket_write($sock, 'Q', 1);
|
socket_write($sock, 'Q', 1);
|
||||||
socket_write($sock, "\r\n", strlen("\r\n"));
|
socket_write($sock, "\r\n", strlen("\r\n"));
|
||||||
for ($i = 0; $this->running && $i < 5; $i ++ )
|
for ($i = 0; $this->running && $i < 5; $i ++ ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
$qsent = 'Q';
|
$qsent = 'Q';
|
||||||
$timetokill = time() + 10;
|
$timetokill = time() + 10;
|
||||||
} else {
|
} else {
|
||||||
@@ -506,8 +524,9 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ($i = 0; $this->running && $i < 5; $i ++ )
|
for ($i = 0; $this->running && $i < 5; $i ++ ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sock) {
|
if ($sock) {
|
||||||
@@ -516,8 +535,9 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_keys($pipes) as $offset) {
|
foreach (array_keys($pipes) as $offset) {
|
||||||
if (is_resource($pipes[$offset]))
|
if (is_resource($pipes[$offset])) {
|
||||||
fclose($pipes[$offset]);
|
fclose($pipes[$offset]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_terminate($process); // sigint
|
proc_terminate($process); // sigint
|
||||||
@@ -526,8 +546,6 @@ class task_period_cindexer extends task_abstract
|
|||||||
|
|
||||||
private function run_with_fork($cmd, $args)
|
private function run_with_fork($cmd, $args)
|
||||||
{
|
{
|
||||||
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
|
||||||
|
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid == -1) {
|
if ($pid == -1) {
|
||||||
$this->exception = new Exception('cindexer can\'t fork', self::ERR_CANT_FORK);
|
$this->exception = new Exception('cindexer can\'t fork', self::ERR_CANT_FORK);
|
||||||
@@ -561,6 +579,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
|
|
||||||
if ($this->getState() == self::STATE_TOSTOP) {
|
if ($this->getState() == self::STATE_TOSTOP) {
|
||||||
posix_kill($pid, ($sigsent = SIGINT));
|
posix_kill($pid, ($sigsent = SIGINT));
|
||||||
|
$timetokill = time() + 10;
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +602,6 @@ class task_period_cindexer extends task_abstract
|
|||||||
if ($sigsent == SIGINT && time() > $timetokill) {
|
if ($sigsent == SIGINT && time() > $timetokill) {
|
||||||
// must kill cindexer
|
// must kill cindexer
|
||||||
$this->log(_('task::cindexer:killing the cindexer'));
|
$this->log(_('task::cindexer:killing the cindexer'));
|
||||||
$qsent = 'K';
|
|
||||||
posix_kill($pid, ($sigsent = SIGKILL));
|
posix_kill($pid, ($sigsent = SIGKILL));
|
||||||
}
|
}
|
||||||
sleep(2);
|
sleep(2);
|
||||||
@@ -594,7 +612,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
|
|
||||||
private function run_with_exec($cmd, $args)
|
private function run_with_exec($cmd, $args)
|
||||||
{
|
{
|
||||||
$x = pcntl_exec($cmd, $args);
|
pcntl_exec($cmd, $args);
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,16 +51,17 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
, "proxyport"
|
, "proxyport"
|
||||||
, "period"
|
, "period"
|
||||||
);
|
);
|
||||||
if (($dom = @DOMDocument::loadXML($oldxml))) {
|
if (($dom = @DOMDocument::loadXML($oldxml)) != FALSE) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("str:proxy", "str:proxyport", "str:period") as $pname) {
|
foreach (array("str:proxy", "str:proxyport", "str:period") as $pname) {
|
||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
@@ -91,7 +92,7 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
*/
|
*/
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
// ... but we could check for safe values (ex. 0 < period < 3600)
|
// ... but we could check for safe values (ex. 0 < period < 3600)
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -178,14 +179,15 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
|
|
||||||
if ($parm["xml"] === null) {
|
if ($parm["xml"] === null) {
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if (($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"]))) {
|
if (($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"])) != FALSE) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period") as $f) {
|
foreach (array("proxy", "proxyport", "period") as $f) {
|
||||||
if ($parm[$f] !== NULL) {
|
if ($parm[$f] !== NULL) {
|
||||||
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0))) {
|
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
|
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
|
||||||
@@ -197,8 +199,9 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$xmlchanged = true;
|
$xmlchanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($xmlchanged)
|
if ($xmlchanged) {
|
||||||
$parm["xml"] = $domTaskSettings->saveXML();
|
$parm["xml"] = $domTaskSettings->saveXML();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,8 +302,9 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs as $rowtask) {
|
foreach ($rs as $rowtask) {
|
||||||
if (isset($ftp_exports[$rowtask["ftp_export_id"]]))
|
if (isset($ftp_exports[$rowtask["ftp_export_id"]])) {
|
||||||
$ftp_exports[$rowtask["ftp_export_id"]]["files"][] = $rowtask;
|
$ftp_exports[$rowtask["ftp_export_id"]]["files"][] = $rowtask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ftp_exports;
|
return $ftp_exports;
|
||||||
@@ -324,16 +328,18 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$ftpLog = $ftp_user_name . "@" . p4string::addEndSlash($ftp_server) . $ftp_export["destfolder"];
|
$ftpLog = $ftp_user_name . "@" . p4string::addEndSlash($ftp_server) . $ftp_export["destfolder"];
|
||||||
|
|
||||||
if ($ftp_export["crash"] == 0) {
|
if ($ftp_export["crash"] == 0) {
|
||||||
$state .= $line = sprintf(
|
$line = sprintf(
|
||||||
_('task::ftp:Etat d\'envoi FTP vers le serveur' .
|
_('task::ftp:Etat d\'envoi FTP vers le serveur' .
|
||||||
' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL
|
' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL
|
||||||
, $ftp_server
|
, $ftp_server
|
||||||
, $ftp_user_name
|
, $ftp_user_name
|
||||||
, $ftp_export["destfolder"]
|
, $ftp_export["destfolder"]
|
||||||
);
|
);
|
||||||
|
$state .= $line;
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo $line;
|
echo $line;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$state .= $line = sprintf(
|
$state .= $line = sprintf(
|
||||||
@@ -342,8 +348,9 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
, " (" . date('r') . ")"
|
, " (" . date('r') . ")"
|
||||||
) . PHP_EOL;
|
) . PHP_EOL;
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo $line;
|
echo $line;
|
||||||
|
}
|
||||||
|
|
||||||
if (($ses_id = phrasea_create_session($usr_id)) == null) {
|
if (($ses_id = phrasea_create_session($usr_id)) == null) {
|
||||||
echo "Unable to create session\n";
|
echo "Unable to create session\n";
|
||||||
@@ -398,13 +405,15 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$obj = array();
|
$obj = array();
|
||||||
|
|
||||||
$basefolder = '';
|
$basefolder = '';
|
||||||
if ( ! in_array(trim($ftp_export["destfolder"]), array('.', './', '')))
|
if ( ! in_array(trim($ftp_export["destfolder"]), array('.', './', ''))) {
|
||||||
$basefolder = p4string::addEndSlash($ftp_export["destfolder"]);
|
$basefolder = p4string::addEndSlash($ftp_export["destfolder"]);
|
||||||
|
}
|
||||||
|
|
||||||
$basefolder .= $ftp_export["foldertocreate"];
|
$basefolder .= $ftp_export["foldertocreate"];
|
||||||
|
|
||||||
if (in_array(trim($basefolder), array('.', './', '')))
|
if (in_array(trim($basefolder), array('.', './', ''))) {
|
||||||
$basefolder = '/';
|
$basefolder = '/';
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($ftp_export['files'] as $fileid => $file) {
|
foreach ($ftp_export['files'] as $fileid => $file) {
|
||||||
$base_id = $file["base_id"];
|
$base_id = $file["base_id"];
|
||||||
@@ -480,8 +489,9 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
, basename($localfile), $record_id
|
, basename($localfile), $record_id
|
||||||
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>";
|
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>";
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo $line;
|
echo $line;
|
||||||
|
}
|
||||||
|
|
||||||
$done = $file['error'];
|
$done = $file['error'];
|
||||||
|
|
||||||
@@ -494,8 +504,9 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ftp_export['logfile']) {
|
if ($ftp_export['logfile']) {
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo "\nlogfile \n";
|
echo "\nlogfile \n";
|
||||||
|
}
|
||||||
|
|
||||||
$date = new DateTime();
|
$date = new DateTime();
|
||||||
$remote_file = $date->format('U');
|
$remote_file = $date->format('U');
|
||||||
@@ -539,8 +550,9 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$state .= $line = $e . "\n";
|
$state .= $line = $e . "\n";
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo $line;
|
echo $line;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()"
|
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()"
|
||||||
. " WHERE id = :export_id";
|
. " WHERE id = :export_id";
|
||||||
@@ -653,10 +665,11 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
if ($row['crash'] >= $row['nbretry'])
|
if ($row['crash'] >= $row['nbretry']) {
|
||||||
$connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant');
|
$connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant');
|
||||||
else
|
} else {
|
||||||
$connection_status = _('La connection vers le serveur distant est OK');
|
$connection_status = _('La connection vers le serveur distant est OK');
|
||||||
|
}
|
||||||
|
|
||||||
$text_mail_sender = $row['text_mail_sender'];
|
$text_mail_sender = $row['text_mail_sender'];
|
||||||
$text_mail_receiver = $row['text_mail_receiver'];
|
$text_mail_receiver = $row['text_mail_receiver'];
|
||||||
|
@@ -80,7 +80,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
// ... but we could check for safe values (ex. 0 < period < 3600)
|
// ... but we could check for safe values (ex. 0 < period < 3600)
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -194,11 +194,11 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
if ($parm["xml"] === null) {
|
if ($parm["xml"] === null) {
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if (($domTaskSettings = DOMDocument::loadXML($taskrow["settings"]))) {
|
if (($domTaskSettings = DOMDocument::loadXML($taskrow["settings"])) != FALSE) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
||||||
if ($parm[$f] !== NULL) {
|
if ($parm[$f] !== NULL) {
|
||||||
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0))) {
|
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
@@ -74,10 +74,11 @@ class task_period_outofdate extends task_abstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
@@ -105,15 +106,17 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ====================================================================
|
// ====================================================================
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
// ... but we could check for safe values
|
// ... but we could check for safe values
|
||||||
if ((int) ($sxml->period) < 10)
|
if ((int) ($sxml->period) < 10) {
|
||||||
$sxml->period = 10;
|
$sxml->period = 10;
|
||||||
elseif ((int) ($sxml->period) > 1440) // 1 jour
|
} elseif ((int) ($sxml->period) > 1440) { // 1 jour
|
||||||
$sxml->period = 1440;
|
$sxml->period = 1440;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->delay) == '')
|
if ((string) ($sxml->delay) == '') {
|
||||||
$sxml->delay = 0;
|
$sxml->delay = 0;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var i;
|
var i;
|
||||||
@@ -155,8 +158,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
} else { // ... so we NEVER come here
|
||||||
else { // ... so we NEVER come here
|
|
||||||
// bad xml
|
// bad xml
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
@@ -199,7 +201,6 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ====================================================================
|
// ====================================================================
|
||||||
public function printInterfaceJS()
|
public function printInterfaceJS()
|
||||||
{
|
{
|
||||||
global $parm;
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
@@ -324,8 +325,6 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ====================================================================
|
// ====================================================================
|
||||||
public function printInterfaceHTML()
|
public function printInterfaceHTML()
|
||||||
{
|
{
|
||||||
global $usr_id;
|
|
||||||
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
@@ -469,13 +468,13 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
|
|
||||||
// ici la tache tourne tant qu'elle est active
|
// ici la tache tourne tant qu'elle est active
|
||||||
$last_exec = 0;
|
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
if ( ! $conn->ping()) {
|
if ( ! $conn->ping()) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
for ($i = 0; $i < 60 * 10; $i ++ )
|
for ($i = 0; $i < 60 * 10; $i ++ ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
|
|
||||||
return(self::STATUS_TORESTART);
|
return(self::STATUS_TORESTART);
|
||||||
@@ -483,12 +482,14 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$connbas = connection::getPDOConnection($this->sbas_id);
|
$connbas = connection::getPDOConnection($this->sbas_id);
|
||||||
if ( ! $connbas->ping())
|
if ( ! $connbas->ping()) {
|
||||||
throw new Exception('Mysql has gone away');
|
throw new Exception('Mysql has gone away');
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log(("dbox connection lost, restarting in 10 min."));
|
$this->log(("dbox connection lost, restarting in 10 min."));
|
||||||
for ($i = 0; $i < 60 * 10; $i ++ )
|
for ($i = 0; $i < 60 * 10; $i ++ ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
|
|
||||||
return(self::STATUS_TORESTART);
|
return(self::STATUS_TORESTART);
|
||||||
@@ -496,8 +497,6 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
$this->setLastExecTime();
|
$this->setLastExecTime();
|
||||||
|
|
||||||
$databox = databox::get_instance($this->sbas_id);
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
|
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':task_id' => $this->getID()));
|
$stmt->execute(array(':task_id' => $this->getID()));
|
||||||
@@ -509,12 +508,12 @@ class task_period_outofdate extends task_abstract
|
|||||||
$ret = self::STATUS_STOPPED;
|
$ret = self::STATUS_STOPPED;
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
} else {
|
} else {
|
||||||
if (($this->sxTaskSettings = simplexml_load_string($row['settings']))) {
|
if (($this->sxTaskSettings = simplexml_load_string($row['settings'])) != FALSE) {
|
||||||
$period = (int) ($this->sxTaskSettings->period);
|
$period = (int) ($this->sxTaskSettings->period);
|
||||||
if ($period <= 0 || $period >= 24 * 60)
|
if ($period <= 0 || $period >= 24 * 60) {
|
||||||
$period = 60;
|
$period = 60;
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
$period = 60;
|
$period = 60;
|
||||||
}
|
}
|
||||||
$this->connbas = connection::getPDOConnection($this->sbas_id);
|
$this->connbas = connection::getPDOConnection($this->sbas_id);
|
||||||
@@ -579,10 +578,10 @@ class task_period_outofdate extends task_abstract
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$nchanged += $n;
|
$nchanged += $n;
|
||||||
if ($n > 0)
|
if ($n > 0) {
|
||||||
$this->log(sprintf("SQL='%s' ; parms=%s - %s changes", $xsql['sql'], var_export($xsql['params']), $n));
|
$this->log(sprintf("SQL='%s' ; parms=%s - %s changes", $xsql['sql'], var_export($xsql['params']), $n));
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
$this->log(sprintf("ERROR SQL='%s' ; parms=%s", $xsql['sql'], var_export($xsql['params'], true)));
|
$this->log(sprintf("ERROR SQL='%s' ; parms=%s", $xsql['sql'], var_export($xsql['params'], true)));
|
||||||
}
|
}
|
||||||
} catch (ErrorException $e) {
|
} catch (ErrorException $e) {
|
||||||
@@ -608,10 +607,11 @@ class task_period_outofdate extends task_abstract
|
|||||||
if (($field1 = trim($this->sxTaskSettings->field1)) != '') {
|
if (($field1 = trim($this->sxTaskSettings->field1)) != '') {
|
||||||
$date1 = time();
|
$date1 = time();
|
||||||
if (($delta = (int) ($this->sxTaskSettings->fieldDv1)) > 0) {
|
if (($delta = (int) ($this->sxTaskSettings->fieldDv1)) > 0) {
|
||||||
if ($this->sxTaskSettings->fieldDs1 == '-')
|
if ($this->sxTaskSettings->fieldDs1 == '-') {
|
||||||
$date1 += 86400 * $delta;
|
$date1 += 86400 * $delta;
|
||||||
else
|
} else {
|
||||||
$date1 -= 86400 * $delta;
|
$date1 -= 86400 * $delta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$date1 = date("YmdHis", $date1);
|
$date1 = date("YmdHis", $date1);
|
||||||
}
|
}
|
||||||
@@ -619,16 +619,18 @@ class task_period_outofdate extends task_abstract
|
|||||||
if (($field2 = trim($this->sxTaskSettings->field2)) != '') {
|
if (($field2 = trim($this->sxTaskSettings->field2)) != '') {
|
||||||
$date2 = time();
|
$date2 = time();
|
||||||
if (($delta = (int) ($this->sxTaskSettings->fieldDv2)) > 0) {
|
if (($delta = (int) ($this->sxTaskSettings->fieldDv2)) > 0) {
|
||||||
if ($this->sxTaskSettings->fieldDs2 == '-')
|
if ($this->sxTaskSettings->fieldDs2 == '-') {
|
||||||
$date2 += 86400 * $delta;
|
$date2 += 86400 * $delta;
|
||||||
else
|
} else {
|
||||||
$date2 -= 86400 * $delta;
|
$date2 -= 86400 * $delta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$date2 = date("YmdHis", $date2);
|
$date2 = date("YmdHis", $date2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sqlset = $params = $tmp_params = array();
|
$sqlset = $params = $tmp_params = array();
|
||||||
|
$sqlwhere = array();
|
||||||
for ($i = 0; $i <= 2; $i ++ ) {
|
for ($i = 0; $i <= 2; $i ++ ) {
|
||||||
$sqlwhere[$i] = '';
|
$sqlwhere[$i] = '';
|
||||||
$sqlset[$i] = '';
|
$sqlset[$i] = '';
|
||||||
@@ -771,8 +773,9 @@ class task_period_outofdate extends task_abstract
|
|||||||
$meta_struct = $databox->get_meta_structure();
|
$meta_struct = $databox->get_meta_structure();
|
||||||
|
|
||||||
foreach ($meta_struct as $meta) {
|
foreach ($meta_struct as $meta) {
|
||||||
if (mb_strtolower($meta->get_type()) == 'date')
|
if (mb_strtolower($meta->get_type()) == 'date') {
|
||||||
$ret['date_fields'][] = $meta->get_name();
|
$ret['date_fields'][] = $meta->get_name();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $databox->get_statusbits();
|
$status = $databox->get_statusbits();
|
||||||
@@ -783,8 +786,9 @@ class task_period_outofdate extends task_abstract
|
|||||||
$ret['status_bits'][] = array('n' => $n, 'value' => 1, 'label' => $labelon);
|
$ret['status_bits'][] = array('n' => $n, 'value' => 1, 'label' => $labelon);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($databox->get_collections() as $collection)
|
foreach ($databox->get_collections() as $collection) {
|
||||||
$ret['collections'][] = array('id' => $collection->get_coll_id(), 'name' => $collection->get_name());
|
$ret['collections'][] = array('id' => $collection->get_coll_id(), 'name' => $collection->get_name());
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -77,9 +77,10 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
||||||
}
|
}
|
||||||
@@ -107,32 +108,38 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
*/
|
*/
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) {
|
if (($sxml = simplexml_load_string($xml)) != FALSE) {
|
||||||
if ((int) ($sxml->period) < 10)
|
if ((int) ($sxml->period) < 10) {
|
||||||
$sxml->period = 10;
|
$sxml->period = 10;
|
||||||
elseif ((int) ($sxml->period) > 300)
|
} elseif ((int) ($sxml->period) > 300) {
|
||||||
$sxml->period = 300;
|
$sxml->period = 300;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->flush) == '')
|
if ((string) ($sxml->flush) == '') {
|
||||||
$sxml->flush = 10;
|
$sxml->flush = 10;
|
||||||
elseif ((int) ($sxml->flush) < 1)
|
} elseif ((int) ($sxml->flush) < 1) {
|
||||||
$sxml->flush = 1;
|
$sxml->flush = 1;
|
||||||
elseif ((int) ($sxml->flush) > 100)
|
} elseif ((int) ($sxml->flush) > 100) {
|
||||||
$sxml->flush = 100;
|
$sxml->flush = 100;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->maxrecs) == '')
|
if ((string) ($sxml->maxrecs) == '') {
|
||||||
$sxml->maxrecs = 100;
|
$sxml->maxrecs = 100;
|
||||||
if ((int) ($sxml->maxrecs) < 10)
|
}
|
||||||
|
if ((int) ($sxml->maxrecs) < 10) {
|
||||||
$sxml->maxrecs = 10;
|
$sxml->maxrecs = 10;
|
||||||
elseif ((int) ($sxml->maxrecs) > 500)
|
} elseif ((int) ($sxml->maxrecs) > 500) {
|
||||||
$sxml->maxrecs = 500;
|
$sxml->maxrecs = 500;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->maxmegs) == '')
|
if ((string) ($sxml->maxmegs) == '') {
|
||||||
$sxml->maxmegs = 6;
|
$sxml->maxmegs = 6;
|
||||||
if ((int) ($sxml->maxmegs) < 3)
|
}
|
||||||
|
if ((int) ($sxml->maxmegs) < 3) {
|
||||||
$sxml->maxmegs = 3;
|
$sxml->maxmegs = 3;
|
||||||
elseif ((int) ($sxml->maxmegs) > 32)
|
} elseif ((int) ($sxml->maxmegs) > 32) {
|
||||||
$sxml->maxmegs = 32;
|
$sxml->maxmegs = 32;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
@@ -143,8 +150,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,12 +225,12 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
||||||
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo sprintf(_("task::_common_:passer tous les %s records a l'etape suivante"), '<input type="text" name="flush" style="width:40px;" onchange="chgxmltxt(this, \'flush\');" value="">'); ?>
|
<?php echo sprintf(_("task::_common_:passer tous les %s records a l'etape suivante"), '<input type="text" name="flush" style="width:40px;" onchange="chgxmltxt(this, \'flush\');" value="">'); ?>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:relancer la tache tous les') ?>
|
<?php echo _('task::_common_:relancer la tache tous les') ?>
|
||||||
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
|
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
|
||||||
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>
|
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>
|
||||||
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
|
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
|
||||||
Mo
|
Mo
|
||||||
<br/>
|
<br/>
|
||||||
|
@@ -112,8 +112,9 @@ class task_period_upgradetov32 extends task_abstract
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
if ($row)
|
if ($row) {
|
||||||
$total = $row['total'];
|
$total = $row['total'];
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(record_id) as total FROM record WHERE migrated = 1';
|
$sql = 'SELECT COUNT(record_id) as total FROM record WHERE migrated = 1';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
@@ -122,8 +123,9 @@ class task_period_upgradetov32 extends task_abstract
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$done = 0;
|
$done = 0;
|
||||||
if ($row)
|
if ($row) {
|
||||||
$done = $row['total'];
|
$done = $row['total'];
|
||||||
|
}
|
||||||
|
|
||||||
$this->setProgress($done, $total);
|
$this->setProgress($done, $total);
|
||||||
|
|
||||||
@@ -195,8 +197,9 @@ class task_period_upgradetov32 extends task_abstract
|
|||||||
$document = $record->get_subdef('document');
|
$document = $record->get_subdef('document');
|
||||||
|
|
||||||
foreach ($document->readTechnicalDatas() as $name => $value) {
|
foreach ($document->readTechnicalDatas() as $name => $value) {
|
||||||
if (is_null($value))
|
if (is_null($value)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':record_id' => $record->get_record_id()
|
':record_id' => $record->get_record_id()
|
||||||
@@ -239,7 +242,7 @@ class task_period_upgradetov32 extends task_abstract
|
|||||||
|
|
||||||
$metadatas = array();
|
$metadatas = array();
|
||||||
|
|
||||||
if ($sxe = simplexml_load_string($row['xml'])) {
|
if (($sxe = simplexml_load_string($row['xml'])) != FALSE) {
|
||||||
$z = $sxe->xpath('/record/description');
|
$z = $sxe->xpath('/record/description');
|
||||||
if ($z && is_array($z)) {
|
if ($z && is_array($z)) {
|
||||||
foreach ($z[0] as $ki => $vi) {
|
foreach ($z[0] as $ki => $vi) {
|
||||||
@@ -250,8 +253,9 @@ class task_period_upgradetov32 extends task_abstract
|
|||||||
|
|
||||||
$value = (string) $vi;
|
$value = (string) $vi;
|
||||||
|
|
||||||
if (trim($value) === '')
|
if (trim($value) === '') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($databox_field->is_multi()) {
|
if ($databox_field->is_multi()) {
|
||||||
$new_value = caption_field::get_multi_values($value, $databox_field->get_separator());
|
$new_value = caption_field::get_multi_values($value, $databox_field->get_separator());
|
||||||
|
@@ -50,10 +50,11 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
@@ -78,15 +79,17 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
// ... but we could check for safe values
|
// ... but we could check for safe values
|
||||||
if ((int) ($sxml->period) < 1)
|
if ((int) ($sxml->period) < 1) {
|
||||||
$sxml->period = 1;
|
$sxml->period = 1;
|
||||||
elseif ((int) ($sxml->period) > 1440) // 1 jour
|
} elseif ((int) ($sxml->period) > 1440) { // 1 jour
|
||||||
$sxml->period = 1440;
|
$sxml->period = 1440;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->delay) == '')
|
if ((string) ($sxml->delay) == '') {
|
||||||
$sxml->delay = 0;
|
$sxml->delay = 0;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var i;
|
var i;
|
||||||
@@ -119,8 +122,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
} else { // ... so we NEVER come here
|
||||||
else { // ... so we NEVER come here
|
|
||||||
// bad xml
|
// bad xml
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
@@ -365,8 +367,9 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
// in minutes
|
// in minutes
|
||||||
$this->period = (int) $sx_task_settings->period * 60;
|
$this->period = (int) $sx_task_settings->period * 60;
|
||||||
|
|
||||||
if ($this->period <= 0 || $this->period >= 24 * 60)
|
if ($this->period <= 0 || $this->period >= 24 * 60) {
|
||||||
$this->period = 60;
|
$this->period = 60;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieveSbasContent(databox $databox)
|
protected function retrieveSbasContent(databox $databox)
|
||||||
@@ -401,10 +404,11 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
throw new Exception('Error in settings for status destination');
|
throw new Exception('Error in settings for status destination');
|
||||||
}
|
}
|
||||||
$sql_s .= ($sql_s ? ', ' : '');
|
$sql_s .= ($sql_s ? ', ' : '');
|
||||||
if ((int) $x[1] === 0)
|
if ((int) $x[1] === 0) {
|
||||||
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
||||||
else
|
} else {
|
||||||
$sql_s .= 'status = status |(1 << :stat_dst)';
|
$sql_s .= 'status = status |(1 << :stat_dst)';
|
||||||
|
}
|
||||||
$sql_parms[':stat_dst'] = (int) $x[0];
|
$sql_parms[':stat_dst'] = (int) $x[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,8 +466,9 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
try {
|
try {
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = databox::get_instance($sbas_id);
|
||||||
foreach ($databox->get_meta_structure() as $meta) {
|
foreach ($databox->get_meta_structure() as $meta) {
|
||||||
if ($meta->get_type() !== 'date')
|
if ($meta->get_type() !== 'date') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
$retjs['date_fields'][] = $meta->get_name();
|
$retjs['date_fields'][] = $meta->get_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,7 +486,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$base_ids = $user->ACL()->get_granted_base(array(), array($sbas_id));
|
$base_ids = $user->ACL()->get_granted_base(array(), array($sbas_id));
|
||||||
foreach ($base_ids as $base_id => $collection) {
|
foreach ($base_ids as $collection) {
|
||||||
$retjs['collections'][] = array('id' => (string) ($collection->get_coll_id()), 'name' => $collection->get_name());
|
$retjs['collections'][] = array('id' => (string) ($collection->get_coll_id()), 'name' => $collection->get_name());
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@@ -59,10 +59,11 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild)) {
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
@@ -87,26 +88,31 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
|
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml)) != FALSE) { // in fact XML IS always valid here...
|
||||||
// ... but we could check for safe values (ex. 0 < period < 3600)
|
// ... but we could check for safe values (ex. 0 < period < 3600)
|
||||||
if ((int) ($sxml->period) < 10)
|
if ((int) ($sxml->period) < 10) {
|
||||||
$sxml->period = 10;
|
$sxml->period = 10;
|
||||||
elseif ((int) ($sxml->period) > 300)
|
} elseif ((int) ($sxml->period) > 300) {
|
||||||
$sxml->period = 300;
|
$sxml->period = 300;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->maxrecs) == '')
|
if ((string) ($sxml->maxrecs) == '') {
|
||||||
$sxml->maxrecs = 100;
|
$sxml->maxrecs = 100;
|
||||||
if ((int) ($sxml->maxrecs) < 10)
|
}
|
||||||
|
if ((int) ($sxml->maxrecs) < 10) {
|
||||||
$sxml->maxrecs = 10;
|
$sxml->maxrecs = 10;
|
||||||
elseif ((int) ($sxml->maxrecs) > 500)
|
} elseif ((int) ($sxml->maxrecs) > 500) {
|
||||||
$sxml->maxrecs = 500;
|
$sxml->maxrecs = 500;
|
||||||
|
}
|
||||||
|
|
||||||
if ((string) ($sxml->maxmegs) == '')
|
if ((string) ($sxml->maxmegs) == '') {
|
||||||
$sxml->maxmegs = 6;
|
$sxml->maxmegs = 6;
|
||||||
if ((int) ($sxml->maxmegs) < 3)
|
}
|
||||||
|
if ((int) ($sxml->maxmegs) < 3) {
|
||||||
$sxml->maxmegs = 3;
|
$sxml->maxmegs = 3;
|
||||||
elseif ((int) ($sxml->maxmegs) > 32)
|
} elseif ((int) ($sxml->maxmegs) > 32) {
|
||||||
$sxml->maxmegs = 32;
|
$sxml->maxmegs = 32;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
@@ -116,8 +122,7 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
} else { // ... so we NEVER come here
|
||||||
else { // ... so we NEVER come here
|
|
||||||
// bad xml
|
// bad xml
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
@@ -217,8 +222,9 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
foreach ($subdefgroups as $type => $subdefs) {
|
foreach ($subdefgroups as $type => $subdefs) {
|
||||||
foreach ($subdefs as $sub) {
|
foreach ($subdefs as $sub) {
|
||||||
$name = $sub->get_name();
|
$name = $sub->get_name();
|
||||||
if ($sub->meta_writeable())
|
if ($sub->meta_writeable()) {
|
||||||
$metasubdefs[$name . '_' . $type] = true;
|
$metasubdefs[$name . '_' . $type] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,10 +29,11 @@ switch ($parm['action']) {
|
|||||||
$output = module_admin::getTree($parm['position']);
|
$output = module_admin::getTree($parm['position']);
|
||||||
break;
|
break;
|
||||||
case 'APACHE':
|
case 'APACHE':
|
||||||
if ($parm['test'] == 'success')
|
if ($parm['test'] == 'success') {
|
||||||
$output = '1';
|
$output = '1';
|
||||||
else
|
} else {
|
||||||
$output = '0';
|
$output = '0';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'SCHEDULERKEY':
|
case 'SCHEDULERKEY':
|
||||||
$output = $registry->get('GV_ServerName') . 'admin/runscheduler.php?key=' . urlencode(phrasea::scheduler_key( ! ! $parm['renew']));
|
$output = $registry->get('GV_ServerName') . 'admin/runscheduler.php?key=' . urlencode(phrasea::scheduler_key( ! ! $parm['renew']));
|
||||||
@@ -114,8 +115,9 @@ switch ($parm['action']) {
|
|||||||
$pid = (int) ($task->getPID());
|
$pid = (int) ($task->getPID());
|
||||||
$task->setState($parm["status"]);
|
$task->setState($parm["status"]);
|
||||||
$signal = (int) ($parm['signal']);
|
$signal = (int) ($parm['signal']);
|
||||||
if ($signal > 0 && $pid)
|
if ($signal > 0 && $pid) {
|
||||||
posix_kill($pid, $signal);
|
posix_kill($pid, $signal);
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -167,8 +169,9 @@ switch ($parm['action']) {
|
|||||||
* @todo checker, cette methode n'est pas implementee partout
|
* @todo checker, cette methode n'est pas implementee partout
|
||||||
*/
|
*/
|
||||||
$root->setAttribute("crashed", $task->getCrashCounter());
|
$root->setAttribute("crashed", $task->getCrashCounter());
|
||||||
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
if ($task->saveChanges($conn, $parm["task_id"], $row)) {
|
||||||
$root->setAttribute("saved", "1");
|
$root->setAttribute("saved", "1");
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -206,8 +209,9 @@ switch ($parm['action']) {
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$ret['db_processlist'] = array();
|
$ret['db_processlist'] = array();
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
if ($row['Info'] != $sql)
|
if ($row['Info'] != $sql) {
|
||||||
$ret['db_processlist'][] = $row;
|
$ret['db_processlist'][] = $row;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,8 +256,9 @@ switch ($parm['action']) {
|
|||||||
$ret['xml_indexed'] = $datas['xml_indexed'];
|
$ret['xml_indexed'] = $datas['xml_indexed'];
|
||||||
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
|
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
|
||||||
|
|
||||||
if (file_exists($registry->get('GV_RootPath') . 'config/minilogos/logopdf_' . $parm['sbas_id'] . '.jpg'))
|
if (file_exists($registry->get('GV_RootPath') . 'config/minilogos/logopdf_' . $parm['sbas_id'] . '.jpg')) {
|
||||||
$ret['printLogoURL'] = '/print/' . $parm['sbas_id'];
|
$ret['printLogoURL'] = '/print/' . $parm['sbas_id'];
|
||||||
|
}
|
||||||
$output = p4string::jsonencode($ret);
|
$output = p4string::jsonencode($ret);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -29,35 +29,38 @@ $appbox = appbox::get_instance(\bootstrap::getCore());
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
define("DEFAULT_MIMETYPE", "application/octet-stream");
|
define("DEFAULT_MIMETYPE", "application/octet-stream");
|
||||||
|
|
||||||
if ($request->comes_from_flash())
|
if ($request->comes_from_flash()) {
|
||||||
define("UPLOADER", "FLASH");
|
define("UPLOADER", "FLASH");
|
||||||
else
|
} else {
|
||||||
define("UPLOADER", "HTML");
|
define("UPLOADER", "HTML");
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset($_FILES['Filedata'])) {
|
if ( ! isset($_FILES['Filedata'])) {
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH') {
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
} else {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Internal Server Error") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Internal Server Error") . '")</script>';
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_FILES['Filedata']['error'] > 0) {
|
if ($_FILES['Filedata']['error'] > 0) {
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH') {
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
} else {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Internal Server Error") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Internal Server Error") . '")</script>';
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! move_uploaded_file($_FILES['Filedata']['tmp_name'], $_FILES['Filedata']['tmp_name'] . '_muf')) {
|
if ( ! move_uploaded_file($_FILES['Filedata']['tmp_name'], $_FILES['Filedata']['tmp_name'] . '_muf')) {
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH') {
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
} else {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Internal Server Error") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Internal Server Error") . '")</script>';
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$_FILES['Filedata']['tmp_name'].='_muf';
|
$_FILES['Filedata']['tmp_name'].='_muf';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,10 +90,11 @@ if ($sbas_id !== false && is_array($parm['status'])) {
|
|||||||
|
|
||||||
foreach ($parm['status'] as $k => $v) {
|
foreach ($parm['status'] as $k => $v) {
|
||||||
if ((int) $k <= 63 && (int) $k >= 4) {
|
if ((int) $k <= 63 && (int) $k >= 4) {
|
||||||
if ($v == '0')
|
if ($v == '0') {
|
||||||
$mask_non[63 - (int) $k] = $v;
|
$mask_non[63 - (int) $k] = $v;
|
||||||
elseif ($v == '1')
|
} elseif ($v == '1') {
|
||||||
$mask_oui[63 - (int) $k] = $v;
|
$mask_oui[63 - (int) $k] = $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,10 +108,12 @@ try {
|
|||||||
try {
|
try {
|
||||||
$tmp_record = record_adapter::get_record_by_sha($sbas_id, $sha256);
|
$tmp_record = record_adapter::get_record_by_sha($sbas_id, $sha256);
|
||||||
|
|
||||||
if ( ! $tmp_record)
|
if ( ! $tmp_record) {
|
||||||
throw new Exception('bad luck');
|
throw new Exception('bad luck');
|
||||||
if (is_array($tmp_record))
|
}
|
||||||
|
if (is_array($tmp_record)) {
|
||||||
$tmp_record = array_shift($tmp_record);
|
$tmp_record = array_shift($tmp_record);
|
||||||
|
}
|
||||||
|
|
||||||
$tmp_uuid = $tmp_record->get_uuid();
|
$tmp_uuid = $tmp_record->get_uuid();
|
||||||
|
|
||||||
@@ -126,34 +132,35 @@ try {
|
|||||||
// file already exists in base
|
// file already exists in base
|
||||||
if ( ! lazaretFile::move_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
|
if ( ! lazaretFile::move_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
|
||||||
// move in lazaret failed
|
// move in lazaret failed
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH') {
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
} else {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
// move in lazaret succeed
|
// move in lazaret succeed
|
||||||
if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML') {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML') {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
|
||||||
|
}
|
||||||
|
|
||||||
unset($filename);
|
unset($filename);
|
||||||
unlink($_FILES['Filedata']['tmp_name']);
|
unlink($_FILES['Filedata']['tmp_name']);
|
||||||
exit;
|
exit;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// file does not exists in base, we can archive
|
// file does not exists in base, we can archive
|
||||||
if (($record_id = p4file::archiveFile($filename, $base_id, true, $_FILES['Filedata']["name"])) === false) {
|
if (($record_id = p4file::archiveFile($filename, $base_id, true, $_FILES['Filedata']["name"])) === false) {
|
||||||
// archive failed
|
// archive failed
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH') {
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
} else {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
// archive succeed
|
// archive succeed
|
||||||
if ($chStatus === true && $sbas_id !== false && is_array($parm['status'])) {
|
if ($chStatus === true && $sbas_id !== false && is_array($parm['status'])) {
|
||||||
try {
|
try {
|
||||||
@@ -164,10 +171,12 @@ try {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML') {
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade !") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade !") . '")</script>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user