Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
vault_diskimage.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_diskimage.php,v 1.2 2008/11/24 16:10:23 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  $dbaccess = $action->GetParam("FREEDOM_DB");
28 
29  $q = new QueryDb($dbaccess, "VaultDiskFsStorage");
30  $q->AddQuery("id_fs=" . intval($idfs));
31  $l = $q->Query(0, 0, "TABLE");
32 
33  $fs = $l[0];
34 
35  $nf = $q->Query(0, 0, "TABLE", "select count(id_file),sum(size) from vaultdiskstorage where id_fs='" . pg_escape_string($idfs) . "'");
36  $sqlfs = "id_fs=" . intval($idfs) . " and ";
37  $used_size = $nf[0]["sum"];
38  $q = new QueryDb($dbaccess, "VaultDiskFsStorage");
39 
40  $no = $q->Query(0, 0, "TABLE", "SELECT count(id_file), sum(size) from vaultdiskstorage where $sqlfs id_file not in (select vaultid from docvaultindex where docid>0)"); //Orphean
41  $nt = $q->Query(0, 0, "TABLE", "SELECT count(id_file), sum(size) from vaultdiskstorage where $sqlfs id_file in (select vaultid from docvaultindex where docid in (select id from docread where doctype='Z'))"); //trash files
42  $free = doubleval($fs["free_size"]);
43  $max = doubleval($fs["max_size"]);
44  $free = $max - $used_size;
45  $pci_used = (($max - $free) / $max * 100);
46  $effused = ($max - $free - $no[0]["sum"] - $nt[0]["sum"]);
47  $realused = ($max - $free);
48  $pci_realused = ($realused / $max * 100);
49  $pci_effused = ($effused / $max * 100);
50  $pci_free = (100 - $pci_used);
51  $pci_trash = (($nt[0]["sum"] / $max) * 100);
52  creatediskimage($pci_free, $pci_effused, $pci_trash, 10);
53 }
54 
55 function creatediskimage($pcfree, $pcused, $pctrash, $pcorphan)
56 {
57  // create image
58  $w = 200;
59  $w2 = $w / 2;
60  $x3 = $w / 2;
61  $y3 = $w / 3;
62 
63  if ($pcfree < 0) $pcfree = 0;
64  if ($pcused > 100) $pcused = 100;
65 
66  $afree = 360 - ($pcfree * 3.6);
67  $aused = $afree - ($pcused * 3.6);
68  $atrash = $aused - ($pctrash * 3.6);
69 
70  $image = imagecreatetruecolor($w, $w / 1.5);
71  imagecolortransparent($image, 0);
72  // allocate some solors
73  $orange = imagecolorallocate($image, 0xb5, 0x94, 0x12); #b59412
74  $darkorange = imagecolorallocate($image, 0xb5, 0x74, 0x12);
75  $brown = imagecolorallocate($image, 0xb5, 0x4f, 0x12); #b54f12
76  $darkbrown = imagecolorallocate($image, 0xa5, 0x2f, 0x02);
77  $red = imagecolorallocate($image, 0xFF, 0x00, 0x00);
78  $darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);
79  $green = imagecolorallocate($image, 0x00, 0x90, 0x00);
80  $darkgreen = imagecolorallocate($image, 0x00, 0x50, 0x00);
81  // make the 3D effect
82  for ($i = $y3 + 10; $i > $y3; $i--) {
83  imagefilledarc($image, $x3, $i, $w, $w2, 0, $atrash, $darkorange, IMG_ARC_PIE);
84  imagefilledarc($image, $x3, $i, $w, $w2, $atrash, $aused, $darkbrown, IMG_ARC_PIE);
85  imagefilledarc($image, $x3, $i, $w, $w2, $aused, $afree, $darkred, IMG_ARC_PIE);
86  imagefilledarc($image, $x3, $i, $w, $w2, $afree, 360, $darkgreen, IMG_ARC_PIE);
87  }
88 
89  imagefilledarc($image, $x3, $y3, $w, $w2, 0, $atrash, $orange, IMG_ARC_PIE);
90  imagefilledarc($image, $x3, $y3, $w, $w2, $atrash, $aused, $brown, IMG_ARC_PIE);
91  imagefilledarc($image, $x3, $y3, $w, $w2, $aused, $afree, $red, IMG_ARC_PIE);
92  imagefilledarc($image, $x3, $y3, $w, $w2, $afree, 360, $green, IMG_ARC_PIE);
93  // flush image
94  header('Content-type: image/png');
95  imagepng($image);
96  imagedestroy($image);
97  exit;
98 }
← centre documentaire © anakeen - published under CC License - Dynacase