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