Subversion Repositories ALCASAR

Rev

Rev 3100 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3100 Rev 3179
Line 304... Line 304...
304
                $result = trim($result);
304
                $result = trim($result);
305
                $ip = gethostbyname($result);
305
                $ip = gethostbyname($result);
306
                if ($ip != $result) {
306
                if ($ip != $result) {
307
                    $this->sys->setHostname(gethostbyaddr($ip));
307
                    $this->sys->setHostname(gethostbyaddr($ip));
308
                }
308
                }
309
            } elseif (CommonFunctions::executeProgram('hostname', '', $ret)) {
309
            } elseif (CommonFunctions::executeProgram('hostname', '', $ret, false)) {
-
 
310
                $this->sys->setHostname($ret);
-
 
311
            } elseif (CommonFunctions::executeProgram('uname', '-n', $ret, false)) {
310
                $this->sys->setHostname($ret);
312
                $this->sys->setHostname($ret);
311
            }
313
            }
-
 
314
 
312
        }
315
        }
313
    }
316
    }
314
 
317
 
315
    /**
318
    /**
316
     * Kernel Version
319
     * Kernel Version
Line 441... Line 444...
441
                                    $novm = false;
444
                                    $novm = false;
442
                                    break;
445
                                    break;
443
                                }
446
                                }
444
                            }
447
                            }
445
                        }
448
                        }
-
 
449
                        if (CommonFunctions::rfts('/proc/device-tree/compatible', $compatible, 1, 4096, false) && ($compatible === "qemu,pseries")) {
-
 
450
                            $this->sys->setVirtualizer('qemu'); // QEMU
-
 
451
                            $novm = false;
-
 
452
                        }
446
                    }
453
                    }
447
                }
454
                }
448
            }
455
            }
449
 
456
 
450
            if ($novm && CommonFunctions::rfts('/proc/sysinfo', $sysinfo, 0, 4096, false) && preg_match('//VM00 Control Program:\s*(\S+)/m', $sysinfo, $vcp)) {
457
            if ($novm && CommonFunctions::rfts('/proc/sysinfo', $sysinfo, 0, 4096, false) && preg_match('//VM00 Control Program:\s*(\S+)/m', $sysinfo, $vcp)) {
Line 690... Line 697...
690
            }
697
            }
691
 
698
 
692
            // IBM/S390
699
            // IBM/S390
693
            $bufr = preg_replace('/\ncpu number\s*:\s*(\d+)\r?\ncpu MHz dynamic\s*:\s*(\d+)/m', "\nprocessor:$1\nclock:$2", $bufr);
700
            $bufr = preg_replace('/\ncpu number\s*:\s*(\d+)\r?\ncpu MHz dynamic\s*:\s*(\d+)/m', "\nprocessor:$1\nclock:$2", $bufr);
694
 
701
 
-
 
702
            // machine
-
 
703
            $bufr = preg_replace('/(\nmachine\s*:\s*[^\r\n]+)/m', "$1\n", $bufr);
-
 
704
 
695
            $processors = preg_split('/\s?\n\s?\n/', trim($bufr));
705
            $processors = preg_split('/\s?\n\s?\n/', trim($bufr));
696
 
706
 
697
            //first stage
707
            //first stage
698
            $_arch = null;
708
            $_arch = null;
699
            $_impl = null;
709
            $_impl = null;
Line 722... Line 732...
722
                            $_part = $arrBuff1;
732
                            $_part = $arrBuff1;
723
                            break;
733
                            break;
724
                        case 'cpu variant':
734
                        case 'cpu variant':
725
                            $_vari = $arrBuff1;
735
                            $_vari = $arrBuff1;
726
                            break;
736
                            break;
-
 
737
                        case 'machine':
727
                        case 'hardware':
738
                        case 'hardware':
728
                            $_hard = $arrBuff1;
739
                            $_hard = $arrBuff1;
729
                            break;
740
                            break;
730
                        case 'revision':
741
                        case 'revision':
731
                            $_revi = $arrBuff1;
742
                            $_revi = $arrBuff1;
Line 1342... Line 1353...
1342
        if (is_array($i2cdevices) && (($total = count($i2cdevices)) > 0)) {
1353
        if (is_array($i2cdevices) && (($total = count($i2cdevices)) > 0)) {
1343
            $buf = "";
1354
            $buf = "";
1344
            for ($i = 0; $i < $total; $i++) {
1355
            for ($i = 0; $i < $total; $i++) {
1345
                if (CommonFunctions::rfts($i2cdevices[$i], $buf, 1, 4096, false) && (trim($buf) != "")) {
1356
                if (CommonFunctions::rfts($i2cdevices[$i], $buf, 1, 4096, false) && (trim($buf) != "")) {
1346
                    $dev = new HWDevice();
1357
                    $dev = new HWDevice();
1347
                    $dev->setName(trim($buf));
1358
                    $dev->setName(trim($buf, ": \n\r\t\v\x00"));
1348
                    $this->sys->setI2cDevices($dev);
1359
                    $this->sys->setI2cDevices($dev);
1349
                }
1360
                }
1350
            }
1361
            }
1351
        }
1362
        }
1352
    }
1363
    }
Line 1385... Line 1396...
1385
                    }
1396
                    }
1386
                    if ($begin) {
1397
                    if ($begin) {
1387
                        $nsize[$locid] = $i - $nlocate[$locid];
1398
                        $nsize[$locid] = $i - $nlocate[$locid];
1388
                    }
1399
                    }
1389
                } elseif ($count > 1) {
1400
                } elseif ($count > 1) {
1390
                    if (isset($nlocate[2]) && isset($nsize[2])) {
1401
                    if (isset($nlocate[2]) && isset($nsize[2]) && (($nvname=trim(substr($buf, $nlocate[2], $nsize[2]))) !== '')) {
1391
                        $dev = new HWDevice();
1402
                        $dev = new HWDevice();
1392
                        $dev->setName(trim(substr($buf, $nlocate[2], $nsize[2])));
1403
                        $dev->setName($nvname);
1393
                        if (defined('PSI_SHOW_DEVICES_INFOS') && (PSI_SHOW_DEVICES_INFOS)) {
1404
                        if (defined('PSI_SHOW_DEVICES_INFOS') && (PSI_SHOW_DEVICES_INFOS)) {
1394
                            if (isset($nlocate[4]) && isset($nsize[4])) {
1405
                            if (isset($nlocate[4]) && isset($nsize[4])) {
1395
                                if (preg_match('/\/\s*([0-9\.]+)\s*(B|KB|MB|GB|TB|PB)$/', str_replace(',', '.', trim(substr($buf, $nlocate[4], $nsize[4]))), $tmpbuf)) {
1406
                                if (preg_match('/\/\s*([0-9\.]+)\s*(B|KB|MB|GB|TB|PB)$/', str_replace(',', '.', trim(substr($buf, $nlocate[4], $nsize[4]))), $tmpbuf)) {
1396
                                    switch ($tmpbuf[2]) {
1407
                                    switch ($tmpbuf[2]) {
1397
                                    case 'B':
1408
                                    case 'B':
Line 1446... Line 1457...
1446
                    $dev->setName(trim($dev_name));
1457
                    $dev->setName(trim($dev_name));
1447
                    $dev->setRxBytes($stats[0]);
1458
                    $dev->setRxBytes($stats[0]);
1448
                    $dev->setTxBytes($stats[8]);
1459
                    $dev->setTxBytes($stats[8]);
1449
                    $dev->setErrors($stats[2] + $stats[10]);
1460
                    $dev->setErrors($stats[2] + $stats[10]);
1450
                    $dev->setDrops($stats[3] + $stats[11]);
1461
                    $dev->setDrops($stats[3] + $stats[11]);
-
 
1462
                    if (((defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) || (defined('PSI_SHOW_NETWORK_BRIDGE') && PSI_SHOW_NETWORK_BRIDGE))
-
 
1463
                       && CommonFunctions::executeProgram('ip', 'addr show '.trim($dev_name), $bufr2, PSI_DEBUG) && (trim($bufr2)!="")) {
-
 
1464
                        if (defined('PSI_SHOW_NETWORK_BRIDGE') && PSI_SHOW_NETWORK_BRIDGE && preg_match("/^\d+:\s+([^\s:@]+).+\s+master\s+(\S+)/", $bufr2, $brbufr)) {
-
 
1465
                            $dev->setBridge($brbufr[2]);
-
 
1466
                        }
-
 
1467
                    } else {
-
 
1468
                        $bufr2 = "";
-
 
1469
                    }
1451
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
1470
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
1452
                        $macaddr = "";
1471
                        $macaddr = "";
1453
                        if ((CommonFunctions::executeProgram('ip', 'addr show '.trim($dev_name), $bufr2, PSI_DEBUG) && ($bufr2!=""))
-
 
1454
                           || CommonFunctions::executeProgram('ifconfig', trim($dev_name).' 2>/dev/null', $bufr2, PSI_DEBUG)) {
1472
                        if (($bufr2!="") || CommonFunctions::executeProgram('ifconfig', trim($dev_name).' 2>/dev/null', $bufr2, PSI_DEBUG)) {
1455
                            $bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
1473
                            $bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
1456
                            foreach ($bufe2 as $buf2) {
1474
                            foreach ($bufe2 as $buf2) {
1457
//                                if (preg_match('/^'.trim($dev_name).'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
1475
//                                if (preg_match('/^'.trim($dev_name).'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
1458
                                if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
1476
                                if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
1459
                                   || preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $buf2, $ar_buf2)
1477
                                   || preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $buf2, $ar_buf2)
Line 1466... Line 1484...
1466
                                            $macaddr = "";
1484
                                            $macaddr = "";
1467
                                        }
1485
                                        }
1468
                                    }
1486
                                    }
1469
                                } elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $buf2, $ar_buf2)
1487
                                } elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $buf2, $ar_buf2)
1470
                                       || preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $buf2, $ar_buf2)
1488
                                       || preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $buf2, $ar_buf2)
1471
                                       || preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2)) {
1489
                                       || preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2)
-
 
1490
                                       /*|| preg_match('/^\s+link\/sit\s+([^\/\s]+).*peer\s+([^\/\s]+)/i', $buf2, $ar_buf2)*/) {
1472
                                    if ($ar_buf2[1] != $ar_buf2[2]) {
1491
                                    if ($ar_buf2[1] != $ar_buf2[2]) {
1473
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
1492
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
1474
                                    } else {
1493
                                    } else {
1475
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
1494
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
1476
                                    }
1495
                                    }
Line 1512... Line 1531...
1512
            $was = false;
1531
            $was = false;
1513
            $macaddr = "";
1532
            $macaddr = "";
1514
            $speedinfo = "";
1533
            $speedinfo = "";
1515
            $dev = null;
1534
            $dev = null;
1516
            foreach ($lines as $line) {
1535
            foreach ($lines as $line) {
1517
                if (preg_match("/^\d+:\s+([^\s:]+)/", $line, $ar_buf)) {
1536
                if (preg_match("/^\d+:\s+([^\s:@]+)(.*)/", $line, $ar_buf)) {
1518
                    if ($was) {
1537
                    if ($was) {
1519
                        if ($macaddr != "") {
1538
                        if ($macaddr != "") {
1520
                            $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
1539
                            $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
1521
                        }
1540
                        }
1522
                        if ($speedinfo != "") {
1541
                        if ($speedinfo != "") {
Line 1526... Line 1545...
1526
                    }
1545
                    }
1527
                    $speedinfo = "";
1546
                    $speedinfo = "";
1528
                    $macaddr = "";
1547
                    $macaddr = "";
1529
                    $dev = new NetDevice();
1548
                    $dev = new NetDevice();
1530
                    $dev->setName($ar_buf[1]);
1549
                    $dev->setName($ar_buf[1]);
-
 
1550
                    if (defined('PSI_SHOW_NETWORK_BRIDGE') && PSI_SHOW_NETWORK_BRIDGE
-
 
1551
                       && isset($ar_buf[2]) && (($ar_buf[2] = trim($ar_buf[2])) !=="") && preg_match("/\s+master\s+(\S+)/", $ar_buf[2], $bufr2)) {
-
 
1552
                        $dev->setBridge($bufr2[1]);
-
 
1553
                    }
1531
                    if (CommonFunctions::executeProgram('ip', '-s link show '.$ar_buf[1], $bufr2, PSI_DEBUG) && ($bufr2!="")
1554
                    if (CommonFunctions::executeProgram('ip', '-s link show '.$ar_buf[1], $bufr2, false) && ($bufr2!="")
1532
                       && preg_match("/\n\s+RX:\s[^\n]+\n\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)[^\n]+\n\s+TX:\s[^\n]+\n\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)/m", $bufr2, $ar_buf2)) {
1555
                       && preg_match("/\n\s+RX:\s[^\n]+\n\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)[^\n]+\n\s+TX:\s[^\n]+\n\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)/m", $bufr2, $ar_buf2)) {
1533
                        $dev->setRxBytes($ar_buf2[1]);
1556
                        $dev->setRxBytes($ar_buf2[1]);
1534
                        $dev->setTxBytes($ar_buf2[4]);
1557
                        $dev->setTxBytes($ar_buf2[4]);
1535
                        $dev->setErrors($ar_buf2[2]+$ar_buf2[5]);
1558
                        $dev->setErrors($ar_buf2[2]+$ar_buf2[5]);
1536
                        $dev->setDrops($ar_buf2[3]+$ar_buf2[6]);
1559
                        $dev->setDrops($ar_buf2[3]+$ar_buf2[6]);
-
 
1560
                    } elseif (CommonFunctions::executeProgram('ifconfig', $ar_buf[1], $bufr2, false) && ($bufr2!="")) {
-
 
1561
                        if (preg_match('/\sRX bytes:(\d+)\s/im', $bufr2, $ar_buf2)) {
-
 
1562
                            $dev->setRxBytes($ar_buf2[1]);
-
 
1563
                        }
-
 
1564
                        if (preg_match('/\sTX bytes:(\d+)\s/im', $bufr2, $ar_buf2)) {
-
 
1565
                            $dev->setTxBytes($ar_buf2[1]);
-
 
1566
                        }
-
 
1567
                        $errors = 0;
-
 
1568
                        $drops = 0;
-
 
1569
                        if (preg_match('/\sRX packets:\d+\serrors:(\d+)\sdropped:(\d+)/im', $bufr2, $ar_buf2)) {
-
 
1570
                            $errors +=$ar_buf2[1];
-
 
1571
                            $drops +=$ar_buf2[2];
-
 
1572
                        }
-
 
1573
                        if (preg_match('/\sTX packets:\d+\serrors:(\d+)\sdropped:(\d+)/im', $bufr2, $ar_buf2)) {
-
 
1574
                            $errors +=$ar_buf2[1];
-
 
1575
                            $drops +=$ar_buf2[2];
-
 
1576
                        }
-
 
1577
                        $dev->setErrors($errors);
-
 
1578
                        $dev->setDrops($drops);
1537
                    }
1579
                    }
1538
                    $was = true;
1580
                    $was = true;
1539
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
1581
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
1540
                        if ((!CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) &&
1582
                        if ((!CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/operstate', $buf, 1, 4096, false) || (($down=strtolower(trim($buf)))=="") || ($down!=="down")) &&
1541
                           (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) {
1583
                           (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535))) {
Line 1561... Line 1603...
1561
                                    $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
1603
                                    $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
1562
                                    if (($macaddr === '00-00-00-00-00-00') || ($macaddr === '00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00') || ($macaddr === '--') || ($macaddr === '0.0.0.0')) { // empty
1604
                                    if (($macaddr === '00-00-00-00-00-00') || ($macaddr === '00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00') || ($macaddr === '--') || ($macaddr === '0.0.0.0')) { // empty
1563
                                        $macaddr = "";
1605
                                        $macaddr = "";
1564
                                    }
1606
                                    }
1565
                                }
1607
                                }
1566
                            } elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)) {
1608
                            } elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)
-
 
1609
                                     /*|| preg_match('/^\s+link\/sit\s+([^\/\s]+).*peer\s+([^\/\s]+)/i', $line, $ar_buf2)*/) {
1567
                                if ($ar_buf2[1] != $ar_buf2[2]) {
1610
                                if ($ar_buf2[1] != $ar_buf2[2]) {
1568
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
1611
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
1569
                                } else {
1612
                                } else {
1570
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
1613
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
1571
                                }
1614
                                }
Line 1795... Line 1838...
1795
        $this->sys->setDistribution("Linux");
1838
        $this->sys->setDistribution("Linux");
1796
        $list = @parse_ini_file(PSI_APP_ROOT."/data/distros.ini", true);
1839
        $list = @parse_ini_file(PSI_APP_ROOT."/data/distros.ini", true);
1797
        if (!$list) {
1840
        if (!$list) {
1798
            return;
1841
            return;
1799
        }
1842
        }
-
 
1843
        $_ignore_lsb_release = false;
-
 
1844
        $_Distrib = "";
-
 
1845
        $_DistribIcon = "";
1800
        // We have the '2>/dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown
1846
        // We have the '2>/dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown
1801
        if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && strlen($distro_info) > 0) {
1847
        if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && strlen($distro_info) > 0) {
1802
            $distro_tmp = preg_split("/\r?\n/", $distro_info, -1, PREG_SPLIT_NO_EMPTY);
1848
            $distro_tmp = preg_split("/\r?\n/", $distro_info, -1, PREG_SPLIT_NO_EMPTY);
1803
            foreach ($distro_tmp as $info) {
1849
            foreach ($distro_tmp as $info) {
1804
                $info_tmp = preg_split('/:/', $info, 2);
1850
                $info_tmp = preg_split('/:/', $info, 2);
1805
                if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
1851
                if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
1806
                     isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
1852
                     isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
1807
                    $distro[trim($info_tmp[0])] = trim($info_tmp[1]);
1853
                    $distro[trim($info_tmp[0])] = trim($info_tmp[1]);
1808
                }
1854
                }
1809
            }
1855
            }
-
 
1856
 
1810
            if (!isset($distro['Distributor ID']) && !isset($distro['Description'])) { // Systems like StartOS
1857
            if (!isset($distro['Distributor ID']) && !isset($distro['Description'])) { // Systems like StartOS
1811
                if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "")) {
1858
                if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "")) {
1812
                    $this->sys->setDistribution(trim($distro_tmp[0]));
1859
                    $_Distrib = trim($distro_tmp[0]);
1813
                    if (preg_match('/^(\S+)\s*/', $distro_tmp[0], $id_buf)
1860
                    if (preg_match('/^(\S+)\s*/', $distro_tmp[0], $id_buf)
1814
                        && isset($list[trim($id_buf[1])]['Image'])) {
1861
                        && isset($list[strtolower(trim($id_buf[1]))]['Image'])) {
1815
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
1862
                            $_DistribIcon = $list[strtolower(trim($id_buf[1]))]['Image'];
-
 
1863
                            // set ignore lsb_release for some distributions
-
 
1864
                            if (isset($list[strtolower(trim($id_buf[1]))]['Test']) && ($list[strtolower(trim($id_buf[1]))]['Test'] === "nolsbfirst")) $_ignore_lsb_release = true;
1816
                    }
1865
                    }
1817
                }
1866
                }
1818
            } else {
1867
            } else {
1819
                if (isset($distro['Description']) && ($distro['Description'] != "n/a") && isset($distro['Distributor ID']) && $distro['Distributor ID']=="Neon") { // Neon systems
1868
                if (isset($distro['Description'])) {
1820
                    $distro_tmp = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
1869
                   if (preg_match('/^NAME=\s*"?([^"\r\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
1821
                    $distro['Distributor ID'] = $distro_tmp[0];
1870
                       $distro['Description'] = trim($name_tmp[1]);
1822
                }
-
 
1823
                if (isset($distro['Description'])
1871
                   } elseif (($distro['Description']==="Rolling Release") && isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a")) {
1824
                   && preg_match('/^NAME=\s*"?([^"\r\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
1872
                       $distro['Description'] = $distro['Distributor ID']." ".$distro['Description'];
1825
                   $distro['Description'] = trim($name_tmp[1]);
1873
                   }
1826
                }
1874
                }
1827
                if (isset($distro['Description'])
1875
                if (isset($distro['Description'])
1828
                   && ($distro['Description'] != "n/a")
1876
                   && ($distro['Description'] != "n/a")
1829
                   && (!isset($distro['Distributor ID'])
1877
                   && (!isset($distro['Distributor ID'])
1830
                   || (($distro['Distributor ID'] != "n/a")
1878
                   || (($distro['Distributor ID'] != "n/a")
1831
                   && ($distro['Description'] != $distro['Distributor ID'])))) {
1879
                   && ($distro['Description'] != $distro['Distributor ID'])))) {
1832
                    $this->sys->setDistribution($distro['Description']);
1880
                    $_Distrib = $distro['Description'];
1833
                    if (isset($distro['Release']) && ($distro['Release'] != "n/a")
1881
                    if (isset($distro['Release']) && ($distro['Release'] != "n/a")
1834
                       && ($distro['Release'] != $distro['Description']) && strstr($distro['Release'], ".")){
1882
                       && ($distro['Release'] != $distro['Description']) && strstr($distro['Release'], ".")){
1835
                        if (preg_match("/^(\d+)\.[0]+$/", $distro['Release'], $match_buf)) {
1883
                        if (preg_match("/^(\d+)\.[0]+$/", $distro['Release'], $match_buf)) {
1836
                            $tofind = $match_buf[1];
1884
                            $tofind = $match_buf[1];
1837
                        } else {
1885
                        } else {
1838
                            $tofind = $distro['Release'];
1886
                            $tofind = $distro['Release'];
1839
                        }
1887
                        }
1840
                        if (!preg_match("/^".$tofind."[\s\.]|[\(\[]".$tofind."[\.\)\]]|\s".$tofind."$|\s".$tofind."[\s\.]/", $distro['Description'])) {
1888
                        if (!preg_match("/^".$tofind."[\s\.]|[\(\[]".$tofind."[\.\)\]]|\s".$tofind."$|\s".$tofind."[\s\.]/", $distro['Description'])) {
1841
                            $this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
1889
                            $_Distrib .= " ".$distro['Release'];
1842
                        }
1890
                        }
1843
                    }
1891
                    }
1844
                } elseif (isset($distro['Distributor ID'])) {
1892
                } elseif (isset($distro['Distributor ID'])) {
1845
                    if ($distro['Distributor ID'] != "n/a") {
1893
                    if ($distro['Distributor ID'] != "n/a") {
1846
                        $this->sys->setDistribution($distro['Distributor ID']);
1894
                        $_Distrib = $distro['Distributor ID'];
1847
                        if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
1895
                        if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
1848
                            $this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
1896
                            $_Distrib .= " ".$distro['Release'];
1849
                        }
1897
                        }
1850
                        if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
1898
                        if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
1851
                            $this->sys->setDistribution($this->sys->getDistribution()." (".$distro['Codename'].")");
1899
                            $_Distrib .= " (".$distro['Codename'].")";
1852
                        }
1900
                        }
1853
                    } elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
1901
                    } elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
1854
                        $this->sys->setDistribution($distro['Description']);
1902
                        $_Distrib = $distro['Description'];
1855
                    }
1903
                    }
1856
                }
1904
                }
1857
                if (isset($distro['Distributor ID'])) {
1905
                if (isset($distro['Distributor ID'])) {
1858
                    $distrib = $distro['Distributor ID'];
1906
                    $distrib = $distro['Distributor ID'];
-
 
1907
                    $distrib2 = $distrib;
-
 
1908
                    $distrib3 = $distrib;
1859
                    if (isset($distro['Description'])) {
1909
                    if (isset($distro['Description'])) {
1860
                        $distarr = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
1910
                        $distarr = preg_split("/\s/", $distro['Description'], -1, PREG_SPLIT_NO_EMPTY);
1861
                        if (isset($distarr[0])) {
1911
                        if (isset($distarr[0])) {
1862
                            if ($distrib != "n/a") {
1912
                            if ($distrib != "n/a") {
1863
                                $distrib .= ' '.$distarr[0];
1913
                                $distrib2 .= ' '.$distarr[0];
1864
                            } else {
1914
                            } else {
1865
                                $distrib = $distarr[0];
1915
                                $distrib2 = $distarr[0];
-
 
1916
                            }
-
 
1917
                        }
-
 
1918
                        if (isset($distarr[1])) {
-
 
1919
                            if ($distrib != "n/a") {
-
 
1920
                                $distrib3 .= ' '.$distarr[0].' '.$distarr[1];
-
 
1921
                            } else {
-
 
1922
                                $distrib3 = $distarr[0].' '.$distarr[1];
1866
                            }
1923
                            }
1867
                        }
1924
                        }
1868
                    }
1925
                    }
-
 
1926
                    if (($distrib!==$distrib3) && isset($list[strtolower($distrib3)]['Image'])) {
1869
                    if (isset($list[$distrib]['Image'])) {
1927
                        $_DistribIcon = $list[strtolower($distrib3)]['Image'];
-
 
1928
                        // set ignore lsb_release for some distributions
-
 
1929
                        if (isset($list[strtolower($distrib3)]['Test']) && ($list[strtolower($distrib3)]['Test'] === "nolsbfirst")) $_ignore_lsb_release = true;
-
 
1930
                    } elseif (($distrib!==$distrib2) && isset($list[strtolower($distrib2)]['Image'])) {
1870
                        $this->sys->setDistributionIcon($list[$distrib]['Image']);
1931
                        $_DistribIcon = $list[strtolower($distrib2)]['Image'];
-
 
1932
                        // set ignore lsb_release for some distributions
-
 
1933
                        if (isset($list[strtolower($distrib2)]['Test']) && ($list[strtolower($distrib2)]['Test'] === "nolsbfirst")) $_ignore_lsb_release = true;
1871
                    } elseif (($distro['Distributor ID'] != "n/a") && isset($list[$distro['Distributor ID']]['Image'])) {
1934
                    } elseif (($distrib!=="n/a") && isset($list[strtolower($distrib)]['Image'])) {
1872
                        $this->sys->setDistributionIcon($list[$distro['Distributor ID']]['Image']);
1935
                        $_DistribIcon = $list[strtolower($distrib)]['Image'];
-
 
1936
                        // set ignore lsb_release for some distributions
-
 
1937
                        if (isset($list[strtolower($distrib)]['Test']) && ($list[strtolower($distrib)]['Test'] === "nolsbfirst")) $_ignore_lsb_release = true;
1873
                    }
1938
                    }
1874
                }
1939
                }
1875
            }
1940
            }
1876
        } else {
1941
        }
-
 
1942
 
-
 
1943
        if (!$_ignore_lsb_release) {  // don't ignore lsb_release
-
 
1944
            if ($_Distrib !== "") $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", $_Distrib));
-
 
1945
            if ($_DistribIcon !== "") $this->sys->setDistributionIcon($_DistribIcon);
-
 
1946
        }
-
 
1947
 
-
 
1948
        // if the distribution is still unknown
-
 
1949
        if ($this->sys->getDistribution() == "Linux") {
1877
            /* default error handler */
1950
            /* default error handler */
1878
            if (function_exists('errorHandlerPsi')) {
1951
            if (function_exists('errorHandlerPsi')) {
1879
                restore_error_handler();
1952
                restore_error_handler();
1880
            }
1953
            }
1881
            /* fatal errors only */
1954
            /* fatal errors only */
Line 1883... Line 1956...
1883
            error_reporting(E_ERROR);
1956
            error_reporting(E_ERROR);
1884
 
1957
 
1885
            // Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
1958
            // Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
1886
            if (CommonFunctions::fileexists($filename="/etc/lsb-release")
1959
            if (CommonFunctions::fileexists($filename="/etc/lsb-release")
1887
               && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
1960
               && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
1888
               && preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf)) {
1961
               && (preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf) || preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $id_buf))) {
1889
                if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
1962
                if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
1890
                   && (trim($desc_buf[1])!=trim($id_buf[1]))) {
1963
                   && (trim($desc_buf[1])!=trim($id_buf[1]))) {
-
 
1964
                    if ($desc_buf[1]==="Rolling Release") {
1891
                    $this->sys->setDistribution(trim($desc_buf[1]));
1965
                        $desc_buf[1] = $id_buf[1]." ".$desc_buf[1];
-
 
1966
                    }
-
 
1967
                    $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", trim($desc_buf[1])));
1892
                    if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)
1968
                    if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)
1893
                       && (trim($vers_buf[1])!=trim($desc_buf[1])) && strstr($vers_buf[1], ".")){
1969
                       && (trim($vers_buf[1])!=trim($desc_buf[1])) && strstr($vers_buf[1], ".")){
1894
                        if (preg_match("/^(\d+)\.[0]+$/", trim($vers_buf[1]), $match_buf)) {
1970
                        if (preg_match("/^(\d+)\.[0]+$/", trim($vers_buf[1]), $match_buf)) {
1895
                            $tofind = $match_buf[1];
1971
                            $tofind = $match_buf[1];
1896
                        } else {
1972
                        } else {
Line 1898... Line 1974...
1898
                        }
1974
                        }
1899
                        if (!preg_match("/^".$tofind."[\s\.]|[\(\[]".$tofind."[\.\)\]]|\s".$tofind."$|\s".$tofind."[\s\.]/", trim($desc_buf[1]))) {
1975
                        if (!preg_match("/^".$tofind."[\s\.]|[\(\[]".$tofind."[\.\)\]]|\s".$tofind."$|\s".$tofind."[\s\.]/", trim($desc_buf[1]))) {
1900
                            $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
1976
                            $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
1901
                        }
1977
                        }
1902
                    }
1978
                    }
-
 
1979
                    $distrib = trim($id_buf[1]);
-
 
1980
                    $distrib2 = $distrib;
-
 
1981
                    $distrib3 = $distrib;
-
 
1982
                    $distarr = preg_split("/\s/", trim($desc_buf[1]), -1, PREG_SPLIT_NO_EMPTY);
-
 
1983
                    if (isset($distarr[0])) {
-
 
1984
                        $distrib2 .= ' '.$distarr[0];
-
 
1985
                    }
-
 
1986
                    if (isset($distarr[1])) {
-
 
1987
                        $distrib3 .= ' '.$distarr[0].' '.$distarr[1];
-
 
1988
                    }
-
 
1989
                    if (($distrib!==$distrib3) && isset($list[strtolower($distrib3)]['Image'])) {
-
 
1990
                        $this->sys->setDistributionIcon($list[strtolower($distrib3)]['Image']);
-
 
1991
                    } elseif (($distrib!==$distrib2) && isset($list[strtolower($distrib2)]['Image'])) {
-
 
1992
                        $this->sys->setDistributionIcon($list[strtolower($distrib2)]['Image']);
-
 
1993
                    } elseif (($distrib!=="n/a") && isset($list[strtolower($distrib)]['Image'])) {
-
 
1994
                        $this->sys->setDistributionIcon($list[strtolower($distrib)]['Image']);
-
 
1995
                    }
1903
                } else {
1996
                } else {
1904
                    if (isset($list[trim($id_buf[1])]['Name'])) {
1997
                    if (isset($list[strtolower(trim($id_buf[1]))]['Name'])) {
1905
                        $this->sys->setDistribution(trim($list[trim($id_buf[1])]['Name']));
1998
                        $this->sys->setDistribution(trim($list[strtolower(trim($id_buf[1]))]['Name']));
1906
                    } else {
1999
                    } else {
1907
                        $this->sys->setDistribution(trim($id_buf[1]));
2000
                        $this->sys->setDistribution(trim($id_buf[1]));
1908
                    }
2001
                    }
1909
                    if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
2002
                    if (preg_match('/^DISTRIB_RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
1910
                        $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
2003
                        $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
1911
                    }
2004
                    }
1912
                    if (preg_match('/^DISTRIB_CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
2005
                    if (preg_match('/^DISTRIB_CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
1913
                        $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
2006
                        $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
1914
                    }
2007
                    }
1915
                }
-
 
1916
                if (isset($list[trim($id_buf[1])]['Image'])) {
2008
                    if (isset($list[strtolower(trim($id_buf[1]))]['Image'])) {
1917
                    $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
2009
                        $this->sys->setDistributionIcon($list[strtolower(trim($id_buf[1]))]['Image']);
-
 
2010
                    }
1918
                }
2011
                }
1919
            } else { // otherwise find files specific for distribution
2012
            } else { // otherwise find files specific for distribution
1920
                foreach ($list as $section=>$distribution) {
2013
                foreach ($list as $section=>$distribution) {
1921
                    if (!isset($distribution['Files'])) {
2014
                    if (!isset($distribution['Files'])) {
1922
                        continue;
2015
                        continue;
Line 1931... Line 2024...
1931
                                        $buf = "";
2024
                                        $buf = "";
1932
                                    }
2025
                                    }
1933
                                } else {
2026
                                } else {
1934
                                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2027
                                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
1935
                                        $buf = "";
2028
                                        $buf = "";
-
 
2029
                                        if (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="analyse")) {
-
 
2030
                                            break;
-
 
2031
                                        }
1936
                                    } elseif (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="analyse")) {
2032
                                    } elseif (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="analyse")) {
1937
                                        if (preg_match('/^(\S+)\s*/', preg_replace('/^Red\s+/', 'Red', $buf), $id_buf)
2033
                                        if (preg_match('/^(\S+)\s*/', preg_replace('/^red\s+/', 'red', strtolower($buf)), $id_buf)
1938
                                           && isset($list[trim($id_buf[1])]['Image'])) {
2034
                                           && isset($list[trim($id_buf[1])]['Image'])) {
1939
                                            $distro = $list[trim($id_buf[1])];
2035
                                            $distro = $list[trim($id_buf[1])];
1940
                                        }
2036
                                        }
1941
                                    }
2037
                                    }
1942
                                }
2038
                                }
-
 
2039
                                if (($buf !== null) && (trim($buf) !== "")) {
-
 
2040
                                    $buf = preg_replace("/ - Version:| Build:| Release| version| build/i", "", $buf);
-
 
2041
                                }
1943
                                if (isset($distro['Image'])) {
2042
                                if (isset($distro['Image'])) {
1944
                                    $this->sys->setDistributionIcon($distro['Image']);
2043
                                    $this->sys->setDistributionIcon($distro['Image']);
1945
                                }
2044
                                }
1946
                                if (isset($distribution['Name'])) {
2045
                                if (isset($distribution['Name'])) {
1947
                                    if (($buf === null) || (trim($buf) == "")) {
2046
                                    if (($buf === null) || (trim($buf) == "")) {
Line 1949... Line 2048...
1949
                                    } else {
2048
                                    } else {
1950
                                        $this->sys->setDistribution($distribution['Name']." ".trim($buf));
2049
                                        $this->sys->setDistribution($distribution['Name']." ".trim($buf));
1951
                                    }
2050
                                    }
1952
                                } else {
2051
                                } else {
1953
                                    if (($buf === null) || (trim($buf) == "")) {
2052
                                    if (($buf === null) || (trim($buf) == "")) {
1954
                                        $this->sys->setDistribution($section);
2053
                                        $this->sys->setDistribution(preg_replace('/linux/', 'Linux', ucwords($section)));
1955
                                    } else {
2054
                                    } else {
1956
                                        $this->sys->setDistribution(trim($buf));
2055
                                        $this->sys->setDistribution(trim($buf));
1957
                                    }
2056
                                    }
1958
                                }
2057
                                }
1959
                                if (isset($distribution['Files2'])) {
2058
                                if (isset($distribution['Files2'])) {
Line 1970... Line 2069...
1970
                                                }
2069
                                                }
1971
                                                if (preg_match('/^builddate="?([^"\r\n]+)/m', $buf, $dat_buf)) {
2070
                                                if (preg_match('/^builddate="?([^"\r\n]+)/m', $buf, $dat_buf)) {
1972
                                                    $distr2.=' ('.$dat_buf[1].')';
2071
                                                    $distr2.=' ('.$dat_buf[1].')';
1973
                                                }
2072
                                                }
1974
                                                $this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
2073
                                                $this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
-
 
2074
                                            } elseif (preg_match('/^elive-codename:\s*([^\r\n]+)/m', $buf, $cod_buf)
-
 
2075
                                               && preg_match('/^elive-version:\s*([^\r\n]+)/m', $buf, $ver_buf)) {
-
 
2076
                                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($cod_buf[1])." ".trim($ver_buf[1]));
-
 
2077
                                            } elseif (preg_match('/^VERSION=["\']?([^"\'\r\n]+)/im', $buf, $vers_buf)
-
 
2078
                                               || preg_match('/^VERSION_ID=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
-
 
2079
                                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
2080
                                            } elseif (preg_match('/^DISTRIB_ID=[\'"]?([^\'"\r\n]+)/m', $buf, $id_buf)) {
-
 
2081
                                                if (preg_match('/^DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
-
 
2082
                                                   && (trim($desc_buf[1])!=trim($id_buf[1]))) {
-
 
2083
                                                    $this->sys->setDistribution(trim($desc_buf[1]));
-
 
2084
                                                } else {
-
 
2085
                                                    if (isset($list[strtolower(trim($id_buf[1]))]['Name'])) {
-
 
2086
                                                        $this->sys->setDistribution(trim($list[strtolower(trim($id_buf[1]))]['Name']));
-
 
2087
                                                    } else {
-
 
2088
                                                        $this->sys->setDistribution(trim($id_buf[1]));
-
 
2089
                                                    }
-
 
2090
                                                    if (preg_match('/^RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf) || preg_match('/^DISTRIB_RELEASE=[\'"]?([^\'"\r\n]+)/m', $buf, $vers_buf)) {
-
 
2091
                                                        $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
2092
                                                    }
-
 
2093
                                                    if (preg_match('/^CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
-
 
2094
                                                        $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
-
 
2095
                                                    }
-
 
2096
                                                }
1975
                                            } else {
2097
                                            } else {
1976
                                                $distr2=trim(substr($buf, 0, strpos($buf, "\n")));
2098
                                                $distr2=trim(substr($buf, 0, strpos($buf, "\n")));
1977
                                                if (($distr2 !== null) && ($distr2 != "")) {
2099
                                                if (($distr2 !== null) && ($distr2 != "")) {
1978
                                                    $this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
2100
                                                    $this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
1979
                                                }
2101
                                                }
Line 1988... Line 2110...
1988
                    }
2110
                    }
1989
                }
2111
                }
1990
            }
2112
            }
1991
            // if the distribution is still unknown
2113
            // if the distribution is still unknown
1992
            if ($this->sys->getDistribution() == "Linux") {
2114
            if ($this->sys->getDistribution() == "Linux") {
-
 
2115
                if ($_ignore_lsb_release) { // if lsb_release was ignored
-
 
2116
                    if ($_Distrib !== "") $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", $_Distrib));
-
 
2117
                    if ($_DistribIcon !== "") $this->sys->setDistributionIcon($_DistribIcon);
-
 
2118
                }
-
 
2119
            }
-
 
2120
            // if the distribution is still unknown
-
 
2121
            if ($this->sys->getDistribution() == "Linux") {
-
 
2122
                if (((defined('PSI_EMU_PORT') && CommonFunctions::executeProgram('cat', '/etc/os-release', $buf, false))
-
 
2123
                    || (!defined('PSI_EMU_PORT') && CommonFunctions::fileexists($filename="/etc/os-release") && CommonFunctions::rfts($filename, $buf, 0, 4096, false)))
-
 
2124
                    && (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf) || preg_match('/^NAME=["\']?([^"\'\r\n]+)/m', $buf, $id_buf) || preg_match('/^DISTRIB_ID=["\']?([^"\'\r\n]+)/m', $buf, $id_buf))) {
-
 
2125
                    if (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)) {
-
 
2126
                        if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\r\n]+)/m', $buf, $desc_buf)) {
-
 
2127
                            $this->sys->setDistribution(trim($desc_buf[1])." ".trim($tid_buf[1]));
-
 
2128
                        } else {
-
 
2129
                            if (isset($list['tails']['Name'])) {
-
 
2130
                                $this->sys->setDistribution(trim($list['tails']['Name'])." ".trim($tid_buf[1]));
-
 
2131
                            } else {
-
 
2132
                                $this->sys->setDistribution('Tails'." ".trim($tid_buf[1]));
-
 
2133
                            }
-
 
2134
                        }
-
 
2135
                        $this->sys->setDistributionIcon($list['tails']['Image']);
-
 
2136
                    } else {
-
 
2137
                        $addversion = false;
-
 
2138
                        $distrib = trim($id_buf[1]);
-
 
2139
                        if (preg_match('/^PRETTY_NAME=["\']?([^"\'\r\n]+)/m', $buf, $desc_buf)
-
 
2140
                           && !preg_match('/\$/', $desc_buf[1]) // if is not defined by variable
-
 
2141
                           && ($distrib!==trim($desc_buf[1]))) {
-
 
2142
                            if (isset($list[strtolower($distrib)]['Name']) && !preg_match("/".$list[strtolower($distrib)]['Name']."/i", trim($desc_buf[1]))) {
-
 
2143
                                $this->sys->setDistribution($list[strtolower($distrib)]['Name'] ." ". preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", trim($desc_buf[1])));
-
 
2144
                            } else {
-
 
2145
                                $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", trim($desc_buf[1])));
-
 
2146
                            }
-
 
2147
                            $distrib2 = $distrib;
-
 
2148
                            $distrib3 = $distrib;
-
 
2149
                            $distarr = preg_split("/\s/", trim($desc_buf[1]), -1, PREG_SPLIT_NO_EMPTY);
-
 
2150
                            if (isset($distarr[0])) {
-
 
2151
                                $distrib2 .= ' '.$distarr[0];
-
 
2152
                            }
-
 
2153
                            if (isset($distarr[1])) {
-
 
2154
                                $distrib3 .= ' '.$distarr[0].' '.$distarr[1];
-
 
2155
                            }
-
 
2156
                            if (($distrib!==$distrib3) && isset($list[strtolower($distrib3)]['Image'])) {
-
 
2157
                                $this->sys->setDistributionIcon($list[strtolower($distrib3)]['Image']);
-
 
2158
                                if (count($distarr) == 2) {
-
 
2159
                                    $addversion = true;
-
 
2160
                                }
-
 
2161
                            } elseif (($distrib!==$distrib2) && isset($list[strtolower($distrib2)]['Image'])) {
-
 
2162
                                $this->sys->setDistributionIcon($list[strtolower($distrib2)]['Image']);
-
 
2163
                                if (count($distarr) == 1) {
-
 
2164
                                    $addversion = true;
-
 
2165
                                }
-
 
2166
                            } elseif (($distrib!=="n/a") && isset($list[strtolower($distrib)]['Image'])) {
-
 
2167
                                $this->sys->setDistributionIcon($list[strtolower($distrib)]['Image']);
-
 
2168
                            }
-
 
2169
                        } else {
-
 
2170
                            if (isset($list[strtolower($distrib)]['Name'])) {
-
 
2171
                                $this->sys->setDistribution(trim($list[strtolower($distrib)]['Name']));
-
 
2172
                            } else {
-
 
2173
                                $this->sys->setDistribution($distrib);
-
 
2174
                            }
-
 
2175
                            if (isset($list[strtolower($distrib)]['Image'])) {
-
 
2176
                                $this->sys->setDistributionIcon($list[strtolower($distrib)]['Image']);
-
 
2177
                            }
-
 
2178
                            $addversion = true;
-
 
2179
                        }
-
 
2180
                        if ($addversion) {
-
 
2181
                            if (preg_match('/^VERSION=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)
-
 
2182
                               || preg_match('/^VERSION_ID=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)
-
 
2183
                               || preg_match('/^DISTRIB_RELEASE=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)
-
 
2184
                               || preg_match('/^IMAGE_VERSION=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
-
 
2185
                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
2186
                            }
-
 
2187
                            if (!strstr($this->sys->getDistribution(), "(") && (preg_match('/^VERSION_CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)
-
 
2188
                               || preg_match('/^DISTRIB_CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf))) {
-
 
2189
                                $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
-
 
2190
                            }
-
 
2191
                        }
-
 
2192
                    }
1993
                if (CommonFunctions::fileexists($filename="/etc/DISTRO_SPECS")
2193
                } elseif (CommonFunctions::fileexists($filename="/etc/DISTRO_SPECS")
1994
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
2194
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
1995
                   && preg_match('/^DISTRO_NAME=\'(.+)\'/m', $buf, $id_buf)) {
2195
                   && preg_match('/^DISTRO_NAME=["\']([^"\']+)/m', $buf, $id_buf)) {
1996
                    if (isset($list[trim($id_buf[1])]['Name'])) {
2196
                    if (isset($list[strtolower(trim($id_buf[1]))]['Name'])) {
1997
                        $dist = trim($list[trim($id_buf[1])]['Name']);
2197
                        $dist = trim($list[strtolower(trim($id_buf[1]))]['Name']);
1998
                    } else {
2198
                    } else {
1999
                        $dist = trim($id_buf[1]);
2199
                        $dist = trim($id_buf[1]);
2000
                    }
2200
                    }
2001
                    if (preg_match('/^DISTRO_VERSION=([^#\n\r]+)/m', $buf, $vers_buf)) {
2201
                    if (preg_match('/^DISTRO_VERSION=([^$#\n\r]+)/m', $buf, $vers_buf)) {
2002
                        $this->sys->setDistribution(trim($dist." ".trim($vers_buf[1])));
2202
                        $this->sys->setDistribution(trim($dist." ".trim($vers_buf[1])));
2003
                    } else {
2203
                    } else {
2004
                        $this->sys->setDistribution($dist);
2204
                        $this->sys->setDistribution($dist);
2005
                    }
2205
                    }
2006
                    if (isset($list[trim($id_buf[1])]['Image'])) {
2206
                    if (isset($list[strtolower(trim($id_buf[1]))]['Image'])) {
2007
                        $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
2207
                        $this->sys->setDistributionIcon($list[strtolower(trim($id_buf[1]))]['Image']);
2008
                    } else {
2208
                    } else {
2009
                        if (isset($list['Puppy']['Image'])) {
2209
                        if (isset($list['puppy']['Image'])) {
2010
                            $this->sys->setDistributionIcon($list['Puppy']['Image']);
2210
                            $this->sys->setDistributionIcon($list['puppy']['Image']);
-
 
2211
                            if (!preg_match("/puppy/i", $dist = $this->sys->getDistribution())) {
-
 
2212
                                $this->sys->setDistribution("Puppy ".$dist);
-
 
2213
                            }
2011
                        }
2214
                        }
2012
                    }
2215
                    }
2013
                } elseif ((CommonFunctions::fileexists($filename="/etc/distro-release")
2216
                } elseif ((CommonFunctions::fileexists($filename="/etc/distro-release")
2014
                        && CommonFunctions::rfts($filename, $buf, 1, 4096, false)
2217
                        && CommonFunctions::rfts($filename, $buf, 1, 4096, false)
2015
                        && ($buf !== null) && (trim($buf) != ""))
2218
                        && ($buf !== null) && (trim($buf) != ""))
2016
                    || (CommonFunctions::fileexists($filename="/etc/system-release")
2219
                    || (CommonFunctions::fileexists($filename="/etc/system-release")
2017
                        && CommonFunctions::rfts($filename, $buf, 1, 4096, false)
2220
                        && CommonFunctions::rfts($filename, $buf, 1, 4096, false)
2018
                        && ($buf !== null) && (trim($buf) != ""))) {
2221
                        && ($buf !== null) && (trim($buf) != ""))) {
2019
                    $this->sys->setDistribution(trim($buf));
2222
                    $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", trim($buf)));
2020
                    if (preg_match('/^(\S+)\s*/', preg_replace('/^Red\s+/', 'Red', $buf), $id_buf)
2223
                    if (preg_match('/^(\S+)\s*/', preg_replace('/^red\s+/', 'red', strtolower($buf)), $id_buf)
2021
                        && isset($list[trim($id_buf[1])]['Image'])) {
2224
                        && isset($list[trim($id_buf[1])]['Image'])) {
2022
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
2225
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
2023
                    }
2226
                    }
2024
                } elseif (CommonFunctions::fileexists($filename="/etc/solydxk/info")
-
 
2025
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
2026
                   && preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf)) {
-
 
2027
                    if (preg_match('/^DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
-
 
2028
                       && (trim($desc_buf[1])!=trim($id_buf[1]))) {
-
 
2029
                        $this->sys->setDistribution(trim($desc_buf[1]));
-
 
2030
                    } else {
-
 
2031
                        if (isset($list[trim($id_buf[1])]['Name'])) {
-
 
2032
                            $this->sys->setDistribution(trim($list[trim($id_buf[1])]['Name']));
-
 
2033
                        } else {
-
 
2034
                            $this->sys->setDistribution(trim($id_buf[1]));
-
 
2035
                        }
-
 
2036
                        if (preg_match('/^RELEASE="?([^"\r\n]+)/m', $buf, $vers_buf)) {
-
 
2037
                            $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
2038
                        }
-
 
2039
                        if (preg_match('/^CODENAME="?([^"\r\n]+)/m', $buf, $vers_buf)) {
-
 
2040
                            $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
-
 
2041
                        }
-
 
2042
                    }
-
 
2043
                    if (isset($list[trim($id_buf[1])]['Image'])) {
-
 
2044
                        $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
-
 
2045
                    } else {
-
 
2046
                        $this->sys->setDistributionIcon($list['SolydXK']['Image']);
-
 
2047
                    }
-
 
2048
                } elseif (CommonFunctions::fileexists($filename="/etc/os-release")
-
 
2049
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
2050
                   && (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)
-
 
2051
                   || preg_match('/^NAME=["\']?([^"\'\r\n]+)/m', $buf, $id_buf))) {
-
 
2052
                    if (preg_match('/^TAILS_VERSION_ID="?([^"\r\n]+)/m', $buf, $tid_buf)) {
-
 
2053
                        if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\r\n]+)/m', $buf, $desc_buf)) {
-
 
2054
                            $this->sys->setDistribution(trim($desc_buf[1])." ".trim($tid_buf[1]));
-
 
2055
                        } else {
-
 
2056
                            if (isset($list['Tails']['Name'])) {
-
 
2057
                                $this->sys->setDistribution(trim($list['Tails']['Name'])." ".trim($tid_buf[1]));
-
 
2058
                            } else {
-
 
2059
                                $this->sys->setDistribution('Tails'." ".trim($tid_buf[1]));
-
 
2060
                            }
-
 
2061
                        }
-
 
2062
                        $this->sys->setDistributionIcon($list['Tails']['Image']);
-
 
2063
                    } else {
-
 
2064
                        if (preg_match('/^PRETTY_NAME=["\']?([^"\'\r\n]+)/m', $buf, $desc_buf)
-
 
2065
                           && !preg_match('/\$/', $desc_buf[1])) { // if is not defined by variable
-
 
2066
                            $this->sys->setDistribution(trim($desc_buf[1]));
-
 
2067
                        } else {
-
 
2068
                            if (isset($list[trim($id_buf[1])]['Name'])) {
-
 
2069
                                $this->sys->setDistribution(trim($list[trim($id_buf[1])]['Name']));
-
 
2070
                            } else {
-
 
2071
                                $this->sys->setDistribution(trim($id_buf[1]));
-
 
2072
                            }
-
 
2073
                            if (preg_match('/^VERSION=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
-
 
2074
                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
2075
                            } elseif (preg_match('/^VERSION_ID=["\']?([^"\'\r\n]+)/m', $buf, $vers_buf)) {
-
 
2076
                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
2077
                            }
-
 
2078
                        }
-
 
2079
                        if (isset($list[trim($id_buf[1])]['Image'])) {
-
 
2080
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
-
 
2081
                        }
-
 
2082
                    }
-
 
2083
                } elseif (CommonFunctions::fileexists($filename="/etc/debian_version")) {
2227
                } elseif (CommonFunctions::fileexists($filename="/etc/debian_version")) {
2084
                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2228
                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2085
                        $buf = "";
2229
                        $buf = "";
2086
                    }
2230
                    }
2087
                    if (isset($list['Debian']['Image'])) {
2231
                    if (isset($list['debian']['Image'])) {
2088
                        $this->sys->setDistributionIcon($list['Debian']['Image']);
2232
                        $this->sys->setDistributionIcon($list['debian']['Image']);
2089
                    }
2233
                    }
2090
                    if (isset($list['Debian']['Name'])) {
2234
                    if (isset($list['debian']['Name'])) {
2091
                        if (($buf === null) || (trim($buf) == "")) {
2235
                        if (($buf === null) || (trim($buf) == "")) {
2092
                            $this->sys->setDistribution($list['Debian']['Name']);
2236
                            $this->sys->setDistribution($list['debian']['Name']);
2093
                        } else {
2237
                        } else {
2094
                            $this->sys->setDistribution($list['Debian']['Name']." ".trim($buf));
2238
                            $this->sys->setDistribution($list['debian']['Name']." ".trim($buf));
2095
                        }
2239
                        }
2096
                    } else {
2240
                    } else {
2097
                        if (($buf === null) || (trim($buf) == "")) {
2241
                        if (($buf === null) || (trim($buf) == "")) {
2098
                            $this->sys->setDistribution('Debian');
2242
                            $this->sys->setDistribution('Debian');
2099
                        } else {
2243
                        } else {
Line 2102... Line 2246...
2102
                    }
2246
                    }
2103
                } elseif (CommonFunctions::fileexists($filename="/etc/slackware-version")) {
2247
                } elseif (CommonFunctions::fileexists($filename="/etc/slackware-version")) {
2104
                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2248
                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2105
                        $buf = "";
2249
                        $buf = "";
2106
                    }
2250
                    }
2107
                    if (isset($list['Slackware']['Image'])) {
2251
                    if (isset($list['slackware']['Image'])) {
2108
                        $this->sys->setDistributionIcon($list['Slackware']['Image']);
2252
                        $this->sys->setDistributionIcon($list['slackware']['Image']);
2109
                    }
2253
                    }
2110
                    if (isset($list['Slackware']['Name'])) {
2254
                    if (isset($list['slackware']['Name'])) {
2111
                        if (($buf === null) || (trim($buf) == "")) {
2255
                        if (($buf === null) || (trim($buf) == "")) {
2112
                            $this->sys->setDistribution($list['Slackware']['Name']);
2256
                            $this->sys->setDistribution($list['slackware']['Name']);
2113
                        } else {
2257
                        } else {
2114
                            $this->sys->setDistribution($list['Slackware']['Name']." ".trim($buf));
2258
                            $this->sys->setDistribution($list['slackware']['Name']." ".trim($buf));
2115
                        }
2259
                        }
2116
                    } else {
2260
                    } else {
2117
                        if (($buf === null) || (trim($buf) == "")) {
2261
                        if (($buf === null) || (trim($buf) == "")) {
2118
                            $this->sys->setDistribution('Slackware');
2262
                            $this->sys->setDistribution('Slackware');
2119
                        } else {
2263
                        } else {
Line 2123... Line 2267...
2123
                } elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf")
2267
                } elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf")
2124
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
2268
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
2125
                   && preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
2269
                   && preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
2126
                   && preg_match("/^Version\s*=\s*([\d\.]+)\r?\nBuild\sNumber\s*=\s*(\S+)/m", $buf, $ver_buf)) {
2270
                   && preg_match("/^Version\s*=\s*([\d\.]+)\r?\nBuild\sNumber\s*=\s*(\S+)/m", $buf, $ver_buf)) {
2127
                    $buf = $ver_buf[1]."-".$ver_buf[2];
2271
                    $buf = $ver_buf[1]."-".$ver_buf[2];
2128
                    if (isset($list['QTS']['Image'])) {
2272
                    if (isset($list['qts']['Image'])) {
2129
                        $this->sys->setDistributionIcon($list['QTS']['Image']);
2273
                        $this->sys->setDistributionIcon($list['qts']['Image']);
2130
                    }
2274
                    }
2131
                    if (isset($list['QTS']['Name'])) {
2275
                    if (isset($list['qts']['Name'])) {
2132
                        $this->sys->setDistribution($list['QTS']['Name']." ".trim($buf));
2276
                        $this->sys->setDistribution($list['qts']['Name']." ".trim($buf));
2133
                    } else {
2277
                    } else {
2134
                        $this->sys->setDistribution(trim($buf));
2278
                        $this->sys->setDistribution(trim($buf));
2135
                    }
2279
                    }
2136
                }
2280
                }
2137
            }
2281
            }