Example #1
0
 /**
  * The class constructor initializes variables.
  * @param string $user
  * @param string $pass
  * @param string $dbname
  * @param string $host
  * @param string $driver
  * @final
  */
 public final function __construct($user, $pass, $dbname = null, $host = 'localhost', $driver = 'mysql')
 {
     if (Server::PDO()) {
         $this->dbname = $dbname;
         try {
             $this->db = new \PDO("{$driver}:host={$host}" . (is_null($dbname) ? '' : ";dbname={$dbname}"), $user, $pass);
         } catch (PDOException $e) {
         }
     }
 }
Example #2
0
 /**
  * Creates an http request.
  * @param string $body
  * @return boolean
  * @static
  * @final
  */
 public static final function CreateRequest($body = '')
 {
     if (Server::Sockets() == false || isset($_SERVER['PHP_SELF']) === false || empty($body)) {
         return false;
     }
     $res = @fsockopen(self::getHost(), $_SERVER['SERVER_PORT'] ? $_SERVER['SERVER_PORT'] : 80, $errno, $errstr, 3);
     if ($res) {
         fputs($res, $body);
         $result = end(explode("\n", fread($res, 4096)));
         fclose($res);
         return $result == '1' ? true : false;
     } else {
         return false;
     }
 }
Example #3
0
 /**
  * The class constructor initializes variables.
  * @param string $ip
  * @final
  */
 public final function __construct($ip = '')
 {
     if (empty($ip) && Http::RealIP()) {
         $ip = Http::RealIP();
     }
     if (empty($ip) === false || Server::PerlRegex() != false || @preg_match(self::REGX, trim($ip)) != false || Server::Json() != false) {
         $geo = @json_decode(@file_get_contents("http://api.2ip.com.ua/geo.json?ip={$ip}"), true);
         if (empty($geo) == false) {
             $this->data = array_merge($this->data, $geo);
         }
         $provider = @json_decode(@file_get_contents("http://api.2ip.com.ua/provider.json?ip={$ip}"), true);
         if (empty($provider) == false) {
             $this->data = array_merge($this->data, $provider);
         }
     }
 }
Example #4
0
 /**
  * Checks ssl Version.
  * @return string|boolean
  * @static
  * @final
  */
 public static final function SSLLibVersion()
 {
     if (Server::Curl() === false) {
         return false;
     }
     $ver = curl_version();
     return isset($ver['ssl_version']) ? $ver['ssl_version'] : false;
 }
Example #5
0
 /**
  * Search data platform Magento.
  * @return boolean
  * @final
  */
 private final function Magento()
 {
     global $docroot;
     $root = $docroot && empty($docroot) === false ? $docroot : $_SERVER['DOCUMENT_ROOT'];
     if (file_exists("{$root}/app/Mage.php")) {
         $file = file_get_contents("{$root}/app/Mage.php");
         if (stripos($file, 'Magento') !== false) {
             $this->name = 'Magento';
             $file = str_replace("\n", "", $file);
             if (Server::PerlRegex() && preg_match("/.*getVersionInfo\\(\\)\\s+\\{(.*\\s+\\)\\;)\\s+\\}.*/", $file, $regx)) {
                 $v = @eval($regx[1]);
                 if ($v) {
                     $this->version = trim("{$v['major']}.{$v['minor']}.{$v['revision']}" . ($v['patch'] != '' ? ".{$v['patch']}" : "") . "-{$v['stability']}{$v['number']}", '.-');
                 }
             }
             if (file_exists("{$root}/app/etc/local.xml") && Server::SimpleXML()) {
                 $config = file_get_contents("{$root}/app/etc/local.xml");
                 $config = str_replace("<![CDATA[", "", $config);
                 $config = str_replace("]]>", "", $config);
                 $config = simplexml_load_string($config);
                 if (isset($config->global->resources->default_setup->connection)) {
                     $config = $config->global->resources->default_setup->connection;
                     $this->db['driver'] = 'mysql';
                 }
                 if (isset($config->host)) {
                     $this->db['host'] = (string) $config->host;
                 }
                 if (isset($config->username)) {
                     $this->db['user'] = (string) $config->username;
                 }
                 if (isset($config->password)) {
                     $this->db['password'] = (string) $config->password;
                 }
                 if (isset($config->dbname)) {
                     $this->db['dbname'] = (string) $config->dbname;
                 }
             }
             return true;
         }
     }
     return false;
 }
Example #6
0
 /**
  * Checking upload big files to the server.
  * @param integer $size
  * @return boolean
  * @static
  * @final
  */
 public static final function UploadsBigFile($size = 1024)
 {
     global $count, $js;
     if (Server::PHPInterface() == 'cli' || Server::PHPFileUploads() === false || FileSystem::FileDeletion() === false) {
         return false;
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_big.dat")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_big.dat");
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_big_upload.php")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_big_upload.php");
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_big_uploader.php")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_big_uploader.php");
     }
     $file = @fopen("{$_SERVER['DOCUMENT_ROOT']}/test_big_upload.php", 'wb');
     @fputs($file, "<?php\n" . "if (isset(\$_FILES['filename']) && is_uploaded_file(\$_FILES['filename']['tmp_name'])) {\n" . "    @move_uploaded_file(\$_FILES['filename']['tmp_name'], \$_REQUEST['root'] . '/test_big.dat');\n" . "    echo file_exists(\$_REQUEST['root'] . '/test_big.dat');\n" . "}\n" . "@unlink(__FILE__);\n" . '?>');
     @fclose($file);
     $file = @fopen("{$_SERVER['DOCUMENT_ROOT']}/test_big_uploader.php", 'wb');
     @fputs($file, "<?php\n" . "ini_set('display_errors', false);\n" . "@error_reporting(-1);\n\n" . "\$text = str_repeat(str_repeat('*', 1023) . \"\\n\", {$size});\n" . "\$boundary = sha1(1);\n" . "\$file = \"--\$boundary\\r\\n\" .\n" . "         \"Content-Disposition: form-data; name=\\\"filename\\\"; filename=\\\"test_big.dat\\\"\\r\\n\" .\n" . "         \"Content-Type: text/plain; charset=us-ascii\\r\\n\" .\n" . "         \"Content-Length: \" . (1024 * {$size}) . \"\\r\\n\" .\n" . "         \"Content-Type: application/octet-stream\\r\\n\\r\\n\" .\n" . "         \"\$text\\r\\n\" .\n" . "         \"--\$boundary--\";\n\n" . "\$body = \"POST " . dirname($_SERVER['PHP_SELF']) . "/test_big_upload.php?root={$_SERVER['DOCUMENT_ROOT']} HTTP/1.1\\r\\n\" .\n" . "         \"Host: " . Tools::getHost() . "\\r\\n\" .\n" . "         \"Content-Type: multipart/form-data; boundary=\$boundary\\r\\n\" .\n" . "         'Content-Length: ' . strlen(\$file) . \"\\r\\n\" .\n" . "         \"Connection: Close\\r\\n\\r\\n\" .\n" . "         \$file;\n\n" . "if (file_exists(\"{$_SERVER['DOCUMENT_ROOT']}/test_big_upload.php\")) { \n" . "    \$res = @fsockopen('" . Tools::getHost() . "', " . ($_SERVER['SERVER_PORT'] ? $_SERVER['SERVER_PORT'] : 80) . ", \$errno, \$errstr, 3);\n" . "     if (\$res) {\n" . "          \$time = explode(' ', microtime());\n" . "          \$time = (float) \$time[0] + (float) \$time[1];\n" . "          fputs(\$res, \$body);\n" . "          \$result = end(explode(\"\\n\", fread(\$res, 4096)));\n" . "          fclose(\$res);\n" . "          \$finishtime = explode(' ', microtime());\n" . "          \$finishtime = (float) \$finishtime[0] + (float) \$finishtime[1];\n" . "          \$time = round(\$finishtime - \$time, 2);\n" . "          echo \$result == '1' ? \"Yes \$time s\" : 'No';\n" . "     } else {\n" . "         echo 'No';\n" . "     }\n" . "} else {\n" . "    echo 'No';\n" . "}\n" . "@unlink('{$_SERVER['DOCUMENT_ROOT']}/test_big_upload.php');\n" . "@unlink('{$_SERVER['DOCUMENT_ROOT']}/test_big.dat');\n" . "@unlink(__FILE__);\n" . '?>');
     @fclose($file);
     $cnt = $count + 1;
     $js .= "\$('#value-{$cnt}').parent('tr').removeClass().addClass('active');\n" . "\$('#value-{$cnt}').siblings('.loader').html('<img src=\"https://www.crazydogtshirts.com/skin/frontend/mtcolias/default/images/loader.gif\"/>');\n" . "\$.get( \"" . dirname($_SERVER['PHP_SELF']) . "/test_big_uploader.php\", function(data) {\n" . "    \$('#value-{$cnt}').siblings('.loader').children().remove();\n" . "    \$('#value-{$cnt}').parent('tr').removeClass();\n" . "    if (data == 'No' || data == '') {\n" . "        \$('#value-{$cnt}').html(data);\n" . "        \$('#value-{$cnt}').parent('tr').addClass('danger');\n\n" . "    } else {\n" . "        \$('#value-{$cnt}').html(data);\n" . "        \$('#value-{$cnt}').parent('tr').addClass('success');\n\n" . "    }\n" . "})\n" . ".fail(function() {\n" . "    \$('#value-{$cnt}').siblings('.loader').children().remove();\n" . "    \$('#value-{$cnt}').html('No');\n" . "    \$('#value-{$cnt}').parent('tr').addClass('danger');\n" . "})\n";
     return 'Wait';
 }
Example #7
0
 /**
  * Checking upload files to the server.
  * @return boolean
  * @static
  * @final
  */
 public static final function FileUploads()
 {
     if (Server::PHPInterface() == 'cli' || Server::PHPFileUploads() === false || self::FileDeletion() === false) {
         return false;
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test.dat")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test.dat");
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_upload.php")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_upload.php");
     }
     $file = @fopen("{$_SERVER['DOCUMENT_ROOT']}/test_upload.php", 'wb');
     @fputs($file, "<?php\n" . "if (isset(\$_FILES['filename']) && is_uploaded_file(\$_FILES['filename']['tmp_name'])) {\n" . "    @move_uploaded_file(\$_FILES['filename']['tmp_name'], \$_REQUEST['root'] . '/test.dat');\n" . "    echo file_exists(\$_REQUEST['root'] . '/test.dat');\n" . "}\n" . '?>');
     @fclose($file);
     $text = 'Test upload';
     $boundary = sha1(1);
     $file = "--{$boundary}\r\n" . "Content-Disposition: form-data; name=\"filename\"; filename=\"test.dat\"\r\n" . "Content-Type: text/plain; charset=us-ascii\r\n" . "Content-Length: 11\r\n" . "Content-Type: application/octet-stream\r\n\r\n" . "{$text}\r\n" . "--{$boundary}--";
     $body = 'POST ' . dirname($_SERVER['PHP_SELF']) . "/test_upload.php?root={$_SERVER['DOCUMENT_ROOT']} HTTP/1.1\r\n" . 'Host: ' . Tools::getHost() . "\r\n" . "Content-Type: multipart/form-data; boundary={$boundary}\r\n" . 'Content-Length: ' . strlen($file) . "\r\n" . "Connection: Close\r\n\r\n" . $file;
     $result = file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_upload.php") ? Tools::CreateRequest($body) : false;
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test.dat")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test.dat");
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_upload.php")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_upload.php");
     }
     return $result;
 }
Example #8
0
$b->add('Zlib', Server::Zlib(), null, null, 'Checking zlib.');
$b->add('GDlib', Server::GDlib(), null, null, 'Checking gdlib.');
$b->add('Free Type', Server::FreeType(), null, null, 'Checking free type.');
$b->add('Mbstring', Server::Mbstring(), null, null, 'Checking mbstring.');
$b->add('PDO', Server::PDO(), null, null, 'Checking PDO');
$b->add('SimpleXML', Server::SimpleXML(), null, null, 'Checking SimpleXML');
$b->add('DOMDocument', Server::DOMDocument(), null, null, 'Checking DOMDocument');
$b->add('Curl', Server::Curl(), null, null, 'Checking Curl');
$b->add('Memory Limit', Server::MemoryLimit(), null, null, 'Checking Memory Limit');
$b->add('Max Execution Time', Server::MaxExecutionTime(), null, null, 'Checking Max Execution Time');
$b->add('Umask', Server::Umask(), null, null, 'Finds and returns the umask.');
$b->add('Post Max Size', Server::PostMaxSize(), null, null, 'Finds and returns the post max size.');
$b->add('Register Globals', Server::RegisterGlobals(), null, null, 'Checking Register Globals.');
$b->add('Display Errors', Server::DisplayErrors(), null, null, 'Checking Display Errors.');
$b->add('PHP File Uploads', Server::PHPFileUploads(), null, null, 'Checking PHPFileUploads.');
$b->add('Server Time', Server::ServerTime(), null, null, 'Returns the current server time.');
$b->addHeader('High Load.');
$b->add('Actual Memory Limit', HighLoad::ActualMemoryLimit(), 128, '>', 'Checks the actual memory limit.');
$b->add('Number Cpu Operations', HighLoad::NumberCpuOperations(), null, null, 'Number of operations of the CPU.');
$b->add('Number File Operations', HighLoad::NumberFileOperations(), null, null, 'Number of file operations.');
$b->add('Actual Execution Time', HighLoad::ActualExecutionTime(50), null, null, 'Checks real-time execution of the script.');
$b->add('Sending Big Emails', HighLoad::SendingBigEmails(), null, null, 'Checking the sending big emails.');
$b->add('Uploads Big File', HighLoad::UploadsBigFile(1000), null, null, 'Checking upload big files to the server.');
$b->addHeader('Http server.');
$b->add('Server', Http::Server(), null, null, 'Finds the current http server.');
$b->add('Protocol', Http::Protocol(), null, null, 'Gets the protocol HTTP.');
$b->add('Real IP', Http::RealIP(), null, null, 'Gets real ip address of the server.');
$b->add('Authorization', Http::Authorization(), null, null, 'Checks authorization via http.');
$b->add('Sessions', Http::Sessions(), null, null, 'Checks work sessions via http.');
$b->add('SSL', Http::SSL('www.google.com'), null, null, 'Checks operation ssl via http.');
$b->add('SSL Lib Version', Http::SSLLibVersion(), null, null, 'Checks ssl Version.');
Example #9
0
 /**
  * Searches for java scripts on the site
  * @param string $regxHtml
  * @param string $regxFind
  * @param string $regxVersion
  * @return array|boolean
  * @final
  */
 private static final function search($regxHtml, $regxFind, $regxVersion = null)
 {
     global $docroot;
     if (Server::PHPInterface() == 'cli' || Server::PerlRegex() == false) {
         return false;
     }
     $root = $docroot && empty($docroot) === false ? $docroot : $_SERVER['DOCUMENT_ROOT'];
     $content = false;
     $port = $_SERVER['SERVER_PORT'] ? $_SERVER['SERVER_PORT'] : 80;
     $html = file_get_contents(($port == 443 ? 'https://' : 'http://') . Tools::getHost());
     if (preg_match($regxHtml, $html, $regx)) {
         if (stripos($regx[1], 'http') === false) {
             if (stripos($regx[1], '//') === false) {
                 $regx[1] = ($port == 443 ? 'https://' : 'http://') . Tools::getHost() . "/";
             } else {
                 $regx[1] = "http:{$regx[1]}";
             }
         }
         $content = file_get_contents($regx[1]);
     }
     if ($content == false && function_exists('exec')) {
         exec("find {$root} -name \"*.js\" -exec grep \"{$regxFind}\" {} \\; | head -n 1", $out);
         $content = reset($out);
     }
     if (is_null($regxVersion) == false && preg_match($regxVersion, substr($content, 0, 2000), $regx)) {
         return array('value' => true, 'version' => empty($regx[1]) == false ? reset(explode(' ', $regx[1])) : '');
     } elseif ($content !== false) {
         return true;
     }
     return false;
 }
Example #10
0
 /**
  * Receives the clock frequency of the CPU.
  * @return array|boolean
  * @final
  */
 public static final function CPUClock()
 {
     if (function_exists('exec') == false || Server::PerlRegex() == false) {
         return false;
     }
     $result = false;
     exec('cat /proc/cpuinfo | grep -m 1 "model name"', $cpu);
     if (preg_match("/.*@\\s(.*)/", reset($cpu), $regx)) {
         $result = array('value' => preg_replace('/[^0-9\\.]/', '', $regx[1]), 'postfix' => preg_replace('/[^a-zA-Z]/', '', $regx[1]));
     }
     return $result;
 }