Et bien la partie Labo est pour le moment en développement. Celle-ci vous permettra de suivre et profiter de mes divers réalisations persos. Qui sait le labo y sera peut-être
Pour vous faire patienter, voici un petit échantillon (je sais
Y en a qui ont de drôle d’occupation pour un samedi soir) Allez, vos remarques et suggestions sont les bienvenues.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
| <?php
/*
* Class Name : dirToXml
* Version : 1.0
* Release Date : 05/04/2008
*
* Requires : PHP5
*
* Usage : $example = new dirToXml(pathOfRootDirecory);
*
* Copyright : © 2008 Simon Pottier
* Site : www.guistalk.com
*/
class dirToXml
{
private $rootdir; // ROOT PATH DIRECTORY
private $xml; // XML RETURN
public function __construct($rootdir)
{
$this->rootdir = $rootdir;
$this->listdir($_SERVER["DOCUMENT_ROOT"].$this->rootdir);
}
public function __destruct()
{
echo "<?xml version='1.0' encoding='UTF-8' ?>\n<root>".$this->xml."\n</root>";
}
/*******************************************
******* DIRECTORY TO XML ********
*******************************************/
private function listdir($currentdir)
{
$content = scandir($currentdir);
natcasesort($content);
foreach($content as $file)
{
if (count($content) > 2) // 2 IS FOR . AND ..
{
$filepath = $this->filepath($currentdir, $file);
if (file_exists($filepath) && $file != '.' && $file != '..' && !is_dir($filepath)) // ITS FILE
{
$date = $this->date($filepath);
$filetype = $this->ext($file);
$filesize = $this->size($filepath);
$filewebpath = $this->webpath($file);
$this->xml .= "\n<file label='$file' date='$date' size='$filesize' type='$filetype' path='$filewebpath' />";
}
else if (file_exists($filepath) && $file != '.' && $file != '..' && is_dir($filepath)) // ITS DIRECTORY
{
$filetype = $this->ext($file);
$this->xml .= "\n<folder label='$file' date='' type='$filetype'>";
$this->listdir($filepath);
$this->xml .= "\n</folder>";
}
}
}
}
/*******************************************
******** RETURN SERVER FILE PATH ********
*******************************************/
private function filepath($currentdir, $currentfile) // RETURN PATH OF FILE
{
return $currentdir."/".$currentfile;
}
/*******************************************
******** RETURN WEB FILE PATH ********
*******************************************/
private function webpath($currentfile)
{
return $this->rootdir.$currentfile;
}
/*******************************************
******** RETURN TYPE OF FILE ********
*******************************************/
private function ext($currentfile)
{
if (strpos($currentfile, ".") === false)
{
return "folder";
}
else
{
$array = explode(".", $currentfile);
$ext = strtolower($array[count($array)-1]);
return $ext;
}
}
/*******************************************
******** RETURN DATE OF FILE ********
*******************************************/
private function date($currentfile)
{
return date("d/m/y H:i", filemtime($currentfile));
}
/*******************************************
******** RETURN SIZE OF FILE ********
*******************************************/
private function size($currentfile)
{
$octets = filesize($currentfile);
$multiples = array('octets', 'ko', 'Mo', 'Go', 'To');
for ($i=0; $octets > 1024; $i++) $octets /= 1024;
if(strpos($octets, ".") != 0) $octets = number_format($octets, 2, ",", " ");
return $octets." ".$multiples[$i];
}
}
?> |
PHP 5
Le site, PHP |