Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
cleanFileName.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  * Clean file name
9  * delete \ characters
10  *
11  * @author Anakeen 2010
12  * @version $Id: $
13  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
14  * @package FDL
15  * @subpackage
16  */
17 /**
18  */
19 ini_set("max_execution_time", "36000");
20 
21 include_once ('FDL/Class.Doc.php');
22 include_once ('FDL/Class.DocFam.php');
23 include_once ('FDL/Class.DocVaultIndex.php');
24 include_once ('VAULT/Class.VaultFile.php');
25 
26 $dbaccess = GetParam("FREEDOM_DB");
27 if ($dbaccess == "") {
28  print "Database not found : param FREEDOM_DB";
29  exit;
30 }
31 
32 $limitFamily = $action->getArgument("family");
33 
35 
36 $qf = new QueryDb($dbaccess, "DocFam");
37 if ($limitFamily) $qf->AddQuery(sprintf("id ='%d' or name='%s'", $limitFamily, pg_escape_string($limitFamily)));
38 $rf = $qf->query(0, 0, "TABLE");
39 
40 if ($qf->nb == 0) {
41  $action->exitError("no family found");
42 }
43 
44 foreach ($rf as $k => $vf) {
45  printf("Family %s ", $vf["name"]);
46  $q = new QueryDb($dbaccess, "DocAttr");
47  $q->AddQuery("type = 'file' or type='image'");
48  $q->AddQuery("usefor != 'Q'");
49  $q->AddQuery("id !~ '^:'");
50  $q->AddQuery(sprintf("docid = %d", $vf["id"]));
51  //$q->AddQuery("frameid not in (select id from docattr where type~'array')");
52  $la = $q->Query(0, 0, "TABLE");
53  if ($q->nb > 0) {
54  print "reset filenames\n";
55  $s = sprintf("update doc%d set ", $vf["id"]);
56  $w = '';
57  foreach ($la as $ka => $va) {
58  $w.= sprintf("%s= replace(%s, E'\\\\', ''),", $va["id"], $va["id"]);
59  }
60  $s.= substr($w, 0, -1);
61  $s.= " where values ~ E'\\\\\\\\';";
62  $o->exec_query($s);
63  } else {
64  print "no filenames\n";
65  }
66 }
67 
68 print "reset vault...";
69 $o->exec_query("UPDATE vaultdiskstorage set name = replace(name, E'\\\\', '') where name ~ E'\\\\\\\\';");
70 print "DONE\n";
71 ?>
← centre documentaire © anakeen - published under CC License - Dynacase