17 include_once (
"FDL/Class.Dir.php");
18 include_once (
"FDL/sendmail.php");
25 $dirid = GetHttpVars(
"dirid");
26 $policy = GetHttpVars(
"policy",
"keep");
27 $analyze = (GetHttpVars(
"analyze",
"N") ==
"Y");
28 $double = GetHttpVars(
"double");
29 $to = GetHttpVars(
"to");
31 if (isset($_FILES[
"file"])) {
33 $file = $_FILES[
"file"][
"tmp_name"];
36 error_log(sprintf(
"No file has been uploaded!"));
41 $destfile = dirname(
$file) .
"/__" . uniqid() .
"__" . preg_replace(
'/[^a-zA-Z0-9_.-]/',
'_',
$filename);
42 if (!move_uploaded_file(
$file, $destfile)) {
43 error_log(sprintf(
"Error moving uploaded file '%s' to '%s'.",
$file, $destfile));
44 $action->lay->set(
"text", sprintf(_(
"update of %s catalogue has failed,") ,
$filename));
48 $cmd[] = sprintf(
"%s --userid=%s --api=importDocuments --htmlmode=yes --dir=%s --policy=%s --to=%s --file=%s",
$wsh, escapeshellarg($action->user->id) , escapeshellarg(
$dirid) , escapeshellarg(
$policy) , escapeshellarg(
$to) , escapeshellarg($destfile));
49 $cmd[] = sprintf(
"rm -- %s", escapeshellarg($destfile));
53 if (
$err == 0) $action->lay->set(
"text", sprintf(_(
"Import %s is in progress. When update will be finished an email to <%s> will be sended with result rapport") ,
$filename,
$to));
54 else $action->lay->set(
"text", sprintf(_(
"update of %s catalogue has failed,") ,
$filename));
freedom_bgimport(Action &$action)
foreach($argv as $arg) $cmd
getWshCmd($nice=false, $userid=0, $sudo=false)
bgexec($tcmd, &$result, &$err)
if($file) if($subject==""&&$file) if($subject=="") $err