Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
freedom_bgimport.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Importation in batch mode
8  *
9  * @author Anakeen
10  * @version $Id: freedom_bgimport.php,v 1.11 2008/11/12 13:24:01 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Dir.php");
18 include_once ("FDL/sendmail.php");
19 // -----------------------------------
21 {
22  // -----------------------------------
23  global $_FILES;
24  // Get all the params
25  $dirid = GetHttpVars("dirid");
26  $policy = GetHttpVars("policy", "keep");
27  $analyze = (GetHttpVars("analyze", "N") == "Y");
28  $double = GetHttpVars("double"); // with double title document
29  $to = GetHttpVars("to");
30 
31  if (isset($_FILES["file"])) {
32  // importation
33  $file = $_FILES["file"]["tmp_name"];
34  $filename = $_FILES["file"]["name"];
35  } else {
36  error_log(sprintf("No file has been uploaded!"));
37  return;
38  }
39 
40  $wsh = getWshCmd(true);
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));
45  return;
46  }
47 
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));
50  // $cmd[]="/bin/rm -f $file.?";
51  bgexec($cmd, $result, $err);
52 
53  if ($err == 0) $action->lay->set("text", sprintf(_("Import %s is in progress. When update will be finished an email to &lt;%s&gt; will be sended with result rapport") , $filename, $to));
54  else $action->lay->set("text", sprintf(_("update of %s catalogue has failed,") , $filename));
55 }
freedom_bgimport(Action &$action)
global $action
$filename
$file
$to
foreach($argv as $arg) $cmd
getWshCmd($nice=false, $userid=0, $sudo=false)
Definition: Lib.Common.php:594
bgexec($tcmd, &$result, &$err)
Definition: Lib.Common.php:621
if($file) if($subject==""&&$file) if($subject=="") $err
$analyze
← centre documentaire © anakeen