Platform  3.1
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  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Importation in batch mode
9  *
10  * @author Anakeen 2000
11  * @version $Id: freedom_bgimport.php,v 1.11 2008/11/12 13:24:01 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Dir.php");
20 include_once ("FDL/sendmail.php");
21 // -----------------------------------
23 {
24  // -----------------------------------
25  global $_FILES;
26  // Get all the params
27  $dirid = GetHttpVars("dirid");
28  $dbaccess = $action->GetParam("FREEDOM_DB");
29  $policy = GetHttpVars("policy", "keep");
30  $analyze = (GetHttpVars("analyze", "N") == "Y");
31  $double = GetHttpVars("double"); // with double title document
32  $to = GetHttpVars("to");
33 
34  if (isset($_FILES["file"])) {
35  // importation
36  $file = $_FILES["file"]["tmp_name"];
37  $filename = $_FILES["file"]["name"];
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[] = "$wsh --userid={$action->user->id} --api=freedom_import --htmlmode=Y --dirid=$dirid --double=$double --policy=$policy --to=$to --file=$destfile";
49  $cmd[] = "/bin/rm $destfile ";
50  // $cmd[]="/bin/rm -f $file.?";
51 
52  bgexec($cmd, $result, $err);
53 
54  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));
55  else $action->lay->set("text", sprintf(_("update of %s catalogue has failed,") , $filename));
56 }
57 ?>
← centre documentaire © anakeen - published under CC License - Dynacase