Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2775 rexy 1
<?php
2
echo "<!DOCTYPE html>";
3
echo "<head>";
4
echo "<meta charset=\"UTF-8\">";
5
echo "<title> </title>";
6
echo "</head>";
7
echo "<body>";
8
 
9
define('PSI_APP_ROOT', dirname(__FILE__).'/..');
10
require_once PSI_APP_ROOT.'/includes/interface/class.PSI_Interface_OS.inc.php';
11
require_once PSI_APP_ROOT.'/includes/os/class.OS.inc.php';
12
require_once PSI_APP_ROOT.'/includes/to/class.System.inc.php';
13
require_once PSI_APP_ROOT.'/includes/os/class.Linux.inc.php';
14
define('PSI_USE_VHOST', false);
15
define('PSI_DEBUG', false);
16
define('PSI_LOAD_BAR', false);
17
 
18
$log_file = "";
19
$lsb = true; //enable detection lsb_release -a
20
$lsbfile = true; //enable detection /etc/lsb-release
21
 
22
class PSI_Error
23
{
24
    public static function singleton()
25
    {
26
    }
27
}
28
 
29
class Parser
30
{
31
    public static function lspci()
32
    {
33
        return array();
34
    }
35
    public static function df()
36
    {
37
        return array();
38
    }
39
}
40
 
41
class CommonFunctions
42
{
43
    private static function _parse_log_file($string)
44
    {
45
        global $log_file;
46
        if (file_exists($log_file)) {
47
            $contents = @file_get_contents($log_file);
48
            $contents = preg_replace("/\r\n/", "\n", $contents);
49
            if ($contents && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($string, '/')."\-\-\-\-\-\-\-\-\-\-\n/m", $contents, $matches, PREG_OFFSET_CAPTURE)) {
50
                $findIndex = $matches[0][1];
51
                if (preg_match("/\n/m", $contents, $matches, PREG_OFFSET_CAPTURE, $findIndex)) {
52
                    $startIndex = $matches[0][1]+1;
53
                    if (preg_match("/^\-\-\-\-\-\-\-\-\-\-/m", $contents, $matches, PREG_OFFSET_CAPTURE, $startIndex)) {
54
                        $stopIndex = $matches[0][1];
55
 
56
                        return substr($contents, $startIndex, $stopIndex-$startIndex);
57
                    } else {
58
                        return substr($contents, $startIndex);
59
                    }
60
                }
61
            }
62
        }
63
 
64
        return false;
65
    }
66
 
67
    public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
68
    {
69
        global $lsb;
70
        global $lsbfile;
71
        if ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release")) {
72
            $strRet=self::_parse_log_file($strFileName);
73
            if ($strRet && ($intLines == 1) && (strpos($strRet, "\n") !== false)) {
74
                $strRet=trim(substr($strRet, 0, strpos($strRet, "\n")));
75
            }
76
 
77
            return $strRet;
78
        } else {
79
            return false;
80
        }
81
    }
82
 
83
    public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true, $timeout = 30)
84
    {
85
        global $lsb;
86
        $strBuffer = '';
87
        if ($strProgramname=='lsb_release') {
88
            return $lsb && ($strBuffer = self::_parse_log_file('lsb_release -a'));
89
        } else {
90
            return $strBuffer = self::_parse_log_file($strProgramname);
91
        }
92
    }
93
 
94
    public static function fileexists($strFileName)
95
    {
96
        global $log_file;
97
        global $lsb;
98
        global $lsbfile;
99
        if (file_exists($log_file)
100
            && ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release"))
101
            && ($contents = @file_get_contents($log_file))
102
            && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($strFileName, '/')."\-\-\-\-\-\-\-\-\-\-\r?\n/m", $contents)) {
103
            return true;
104
        }
105
 
106
        return false;
107
    }
108
 
109
    public static function readenv($strElem, &$strBuffer)
110
    {
111
        return false;
112
    }
113
 
114
    public static function gdc()
115
    {
116
        return array();
117
    }
118
}
119
 
120
class _Linux extends Linux
121
{
122
    public function build()
123
    {
124
        parent::_distro();
125
    }
126
}
127
 
128
$system = new _Linux();
129
if ($handle = opendir(PSI_APP_ROOT.'/sample/distrotest')) {
130
    echo "<table cellpadding=\"2\" border=\"1\"  CELLSPACING=\"0\">";
131
    echo "<tr>";
132
    echo "<td>Distrotest sample</td>";
133
    echo "<td>Distro Name</td>";
134
    echo "<td>Distro Icon</td>";
135
    echo "<td>Distro Name (no lsb_release)</td>";
136
    echo "<td>Distro Icon (no lsb_release)</td>";
137
    echo "<td>Distro Name (no lsb_release and no /etc/lsb-release)</td>";
138
    echo "<td>Distro Icon (no lsb_release and no /etc/lsb-release)</td>";
139
    echo "</tr>";
140
    while (false !== ($entry = readdir($handle))) {
141
        if (($entry!=".")&&($entry!="..")) {
142
            if ($shandle = opendir(PSI_APP_ROOT."/sample/distrotest/$entry")) {
143
                while (false !== ($sentry = readdir($shandle))) {
144
                    if (($sentry!=".")&&($sentry!="..")) {
145
                        $log_file=PSI_APP_ROOT.'/sample/distrotest/'.$entry.'/'.$sentry;
146
                        echo "<tr>";
147
                        echo "<td>".$entry.'/'.$sentry."</td>";
148
 
149
                        $lsb = true;
150
                        $lsbfile = true;
151
                        $sys=$system->getSys();
152
                        $distro=$sys->getDistribution();
153
                        $icon=$sys->getDistributionIcon();
154
                        if ($icon == '') $icon="unknown.png";
155
                        if ($icon != $entry.'.png')
156
                            echo "<td style='color:red'>";
157
                        else
158
                            echo "<td>";
159
                        echo $distro."</td>";
160
                        if ($icon != $entry.'.png')
161
                            echo "<td style='color:red'>";
162
                        else
163
                            echo "<td>";
164
                        echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\"/>";
165
                        echo $icon."</td>";
166
                        $sys->setDistribution("");
167
                        $sys->setDistributionIcon("");
168
 
169
                        $lsb = false;
170
                        $lsbfile = true;
171
                        $sys=$system->getSys();
172
                        $distro=$sys->getDistribution();
173
                        $icon=$sys->getDistributionIcon();
174
                        if ($icon == '') $icon="unknown.png";
175
                        if ($icon != $entry.'.png')
176
                            echo "<td style='color:red'>";
177
                        else
178
                            echo "<td>";
179
                        echo $distro."</td>";
180
                        if ($icon != $entry.'.png')
181
                            echo "<td style='color:red'>";
182
                        else
183
                            echo "<td>";
184
                        echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\"/>";
185
                        echo $icon."</td>";
186
                        $sys->setDistribution("");
187
                        $sys->setDistributionIcon("");
188
 
189
                        $lsb = false;
190
                        $lsbfile = false;
191
                        $sys=$system->getSys();
192
                        $distro=$sys->getDistribution();
193
                        $icon=$sys->getDistributionIcon();
194
                        if ($icon == '') $icon="unknown.png";
195
                        if ($icon != $entry.'.png')
196
                            echo "<td style='color:red'>";
197
                        else
198
                            echo "<td>";
199
                        echo $distro."</td>";
200
                        if ($icon != $entry.'.png')
201
                            echo "<td style='color:red'>";
202
                        else
203
                            echo "<td>";
204
                        echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\"/>";
205
                        echo $icon."</td>";
206
                        $sys->setDistribution("");
207
                        $sys->setDistributionIcon("");
208
 
209
                        echo "</tr>";
210
                    }
211
                }
212
                closedir($shandle);
213
            }
214
        }
215
    }
216
    echo "</table>";
217
    closedir($handle);
218
}
219
echo "</body>";