Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
vault_increasefs.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  * Increase size of vault file system
9  *
10  * @author Anakeen 2006
11  * @version $Id: vault_increasefs.php,v 1.2 2006/12/06 12:39:15 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("VAULT/Class.VaultDiskStorage.php");
20 include_once ("VAULT/Class.VaultDiskFsStorage.php");
21 include_once ("FDL/Class.DocVaultIndex.php");
22 // -----------------------------------
24 {
25  // GetAllParameters
26  $idfs = GetHttpVars("idfs");
27  $unit = GetHttpVars("unitsize");
28  $size = intval(GetHttpVars("size"));
29  // Set the globals elements
30  $dbaccess = $action->GetParam("FREEDOM_DB");
31  $fs = new VaultDiskFsStorage($dbaccess, $idfs);
32 
33  switch ($unit) {
34  case "Kb":
35  $size_in_bytes = $size * 1024;
36  break;
37 
38  case "Mb":
39  $size_in_bytes = $size * 1024 * 1024;
40  break;
41 
42  case "Gb":
43  $size_in_bytes = $size * 1024 * 1024 * 1024;
44  break;
45 
46  case "Tb":
47  $size_in_bytes = $size * 1024 * 1024 * 1024 * 1024;
48  break;
49  }
50 
51  if ($fs->isAffected()) {
52 
53  if ($size_in_bytes < ($fs->max_size - $fs->free_size)) {
54  $action->AddWarningMsg(sprintf(_("the new size must be upper than %s") , humanreadsize($fs->max_size - $fs->free_size)));
55  } else {
56  $diff = $size_in_bytes - $fs->max_size;
57  $fs->max_size = $size_in_bytes;
58  $fs->free_size+= $diff;
59  $err = $fs->modify();
60  if ($err == "") $action->AddWarningMsg(sprintf(_("adding %s") , humanreadsize($diff)));
61  else $action->AddWarningMsg(sprintf(_("Cannot adding : [%s]") , $err));
62  }
63  }
64  redirect($action, "VAULT", "VAULT_VIEW", $action->GetParam("CORE_STANDURL"));
65 }
66 
67 function humanreadsize($bytes)
68 {
69  if (abs($bytes) < 1024) return sprintf(_("%d bytes") , $bytes);
70  if (abs($bytes) < 1048576) return sprintf(_("%d Kb") , $bytes / 1024);
71  if (abs($bytes) < 1048576 * 1024) return sprintf(_("%d Mb") , $bytes / 1048576);
72  return sprintf(_("%d Gb") , $bytes / 1048576 / 1024);
73 }
74 ?>
← centre documentaire © anakeen - published under CC License - Dynacase