/** * Returns an output of dependencies * * @param int $ret * @return string|array */ public static function check($ret = Version::PLAIN) { // Get include path and define some variables. $includePath = explode(PATH_SEPARATOR, get_include_path()); $isWindows = DIRECTORY_SEPARATOR == '\\' ? true : false; $php = array('Required PHP' => '5.3.0', 'Installed PHP' => PHP_VERSION); $versionCompare = version_compare($php['Installed PHP'], $php['Required PHP']); $check = array(); // APC $check['Apc'] = !function_exists('apc_add') ? 'No' : 'Yes'; // Archive $check['Archive Tar'] = 'No'; foreach ($includePath as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . 'Archive' . DIRECTORY_SEPARATOR . 'Tar.php')) { $check['Archive Tar'] = 'Yes'; } } $check['Archive Phar'] = !class_exists('Phar', false) ? 'No' : 'Yes'; $check['Archive Rar'] = !class_exists('RarArchive', false) ? 'No' : 'Yes'; $check['Archive Zip'] = !class_exists('ZipArchive', false) ? 'No' : 'Yes'; // Compress $check['Compress Bzip2'] = function_exists('bzcompress') ? 'Yes' : 'No'; $check['Compress Lzf'] = function_exists('lzf_compress') ? 'Yes' : 'No'; $check['Compress Zlib'] = function_exists('gzcompress') ? 'Yes' : 'No'; // cURL $check['cURL'] = function_exists('curl_init') ? 'Yes' : 'No'; // DB $check['Db MySql'] = function_exists('mysql_connect') ? 'Yes' : 'No'; $check['Db MySqli'] = class_exists('mysqli') ? 'Yes' : 'No'; $check['Db Oracle'] = function_exists('oci_connect') ? 'Yes' : 'No'; $check['Db Pdo'] = class_exists('Pdo', false) ? 'Yes' : 'No'; $pdoDrivers = class_exists('Pdo', false) ? \PDO::getAvailableDrivers() : array(); $check['Db Pdo MySQL'] = in_array('mysql', $pdoDrivers) ? 'Yes' : 'No'; $check['Db Pdo SQLSrv'] = in_array('sqlsrv', $pdoDrivers) ? 'Yes' : 'No'; $check['Db Pdo PgSQL'] = in_array('pgsql', $pdoDrivers) ? 'Yes' : 'No'; $check['Db Pdo SQLite'] = in_array('sqlite', $pdoDrivers) ? 'Yes' : 'No'; $check['Db PgSql'] = function_exists('pg_connect') ? 'Yes' : 'No'; $check['Db Sqlite'] = class_exists('Sqlite3', false) ? 'Yes' : 'No'; $check['Db SQLSrv'] = function_exists('sqlsrv_connect') ? 'Yes' : 'No'; // DOM/XML $check['Dom DOMDocument'] = class_exists('DOMDocument', false) ? 'Yes' : 'No'; $check['Dom SimpleXml'] = class_exists('SimpleXMLElement', false) ? 'Yes' : 'No'; // FTP $check['FTP'] = function_exists('ftp_connect') ? 'Yes' : 'No'; // GeoIP $check['GeoIP'] = 'No'; if (function_exists('geoip_db_get_all_info')) { $yes = 'Yes'; $databases = geoip_db_get_all_info(); $count = 0; foreach ($databases as $db) { if ($db['available']) { $count++; } } $check['GeoIP'] = $yes . ' (' . $count . '/' . count($databases) . ' GeoIP DBs Available)'; } // Image $check['Image Gd'] = function_exists('getimagesize') ? 'Yes' : 'No'; $check['Image Freetype'] = function_exists('imagettftext') ? 'Yes' : 'No'; $check['Image Imagick'] = class_exists('Imagick', false) ? 'Yes' : 'No'; // Mcrypt $check['Mcrypt'] = function_exists('mcrypt_encrypt') ? 'Yes' : 'No'; // Memcache $check['Memcache'] = class_exists('Memcache', false) ? 'Yes' : 'No'; // SOAP $check['Soap'] = class_exists('SoapClient', false) ? 'Yes' : 'No'; // Total $count = array_count_values($check); $total = count($check) - $count['No'] . ' of ' . count($check); // Format and return the results $results = null; switch ($ret) { // Build plain text results case self::PLAIN: // Define colors for a bash terminal $green = !$isWindows ? "[1;32m" : null; $yellow = !$isWindows ? "[1;33m" : null; $red = !$isWindows ? "[1;31m" : null; $blue = !$isWindows ? "[1;34m" : null; $endColor = !$isWindows ? "[0m" : null; foreach ($php as $key => $value) { if ($key == 'Required PHP') { $value = $yellow . $value . $endColor; } else { $value = $versionCompare < 0 ? $red . $value . $endColor : $green . $value . $endColor; } $results .= $key . ': ' . $value . PHP_EOL; } $results .= '------------------' . PHP_EOL; foreach ($check as $key => $value) { $value = stripos($value, 'Yes') !== false ? $green . $value . $endColor : $red . $value . $endColor; $results .= $key . ': ' . $value . PHP_EOL; } $results .= '------------------' . PHP_EOL; $results .= 'Total: ' . $blue . $total . $endColor . PHP_EOL; break; // Build HTML results // Build HTML results case self::HTML: foreach ($php as $key => $value) { if ($key == 'Required PHP') { $color = 'orange'; } else { $color = $versionCompare < 0 ? 'red' : 'green'; } $results .= $key . ': <strong style="color: ' . $color . ';">' . $value . '</strong><br />' . PHP_EOL; } $results .= '<hr />' . PHP_EOL; foreach ($check as $key => $value) { $color = $value == 'No' ? 'red' : 'green'; $results .= $key . ': <strong style="color: ' . $color . ';">' . $value . '</strong><br />' . PHP_EOL; } $results .= '<hr />' . PHP_EOL; $results .= 'Total: <strong style="color: blue;">' . $total . '</strong>' . PHP_EOL; break; // Build the results as PHP data // Build the results as PHP data case self::DATA: $data = array(); foreach ($php as $key => $value) { $k = str_replace(' ', '', $key); $k = strtolower(substr($k, 0, 1)) . substr($k, 1); $data[$k] = $value; } foreach ($check as $key => $value) { if (strpos($key, ' ') !== false) { $k = str_replace(' ', '', $key); $k = strtolower(substr($k, 0, 1)) . substr($k, 1); } else { $k = strtolower($key); } $data[$k] = $value; } $results = new \ArrayObject($data, \ArrayObject::ARRAY_AS_PROPS); break; } return $results; }
/** * Get available databases * * @return void */ protected function getAvailableDatabases() { if (function_exists('geoip_db_get_all_info')) { $databases = geoip_db_get_all_info(); foreach ($databases as $db) { if (stripos($db['description'], 'ASNum') !== false && $db['available']) { $this->databases['asnum'] = true; } if (stripos($db['description'], 'City') !== false && $db['available']) { $this->databases['city'] = true; } if (stripos($db['description'], 'Country') !== false && $db['available']) { $this->databases['country'] = true; } if (stripos($db['description'], 'Country V6') !== false && $db['available']) { $this->databases['countryv6'] = true; } if (stripos($db['description'], 'Domain Name') !== false && $db['available']) { $this->databases['domainname'] = true; } if (stripos($db['description'], 'ISP') !== false && $db['available']) { $this->databases['isp'] = true; } if (stripos($db['description'], 'Netspeed') !== false && $db['available']) { $this->databases['netspeed'] = true; } if (stripos($db['description'], 'Organization') !== false && $db['available']) { $this->databases['org'] = true; } if (stripos($db['description'], 'Proxy') !== false && $db['available']) { $this->databases['proxy'] = true; } if (stripos($db['description'], 'Region') !== false && $db['available']) { $this->databases['region'] = true; } } } }
<? # return print_r(geoip_db_get_all_info());