Exemplo n.º 1
0
 /**
  * Checks work sessions via http.
  * @return boolean
  * @static
  * @final
  */
 public static final function Sessions()
 {
     if (Server::PHPInterface() == 'cli' || Server::Sockets() === false || FileSystem::FileDeletion() === false) {
         return false;
     }
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_session.php")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_session.php");
     }
     @session_start();
     $_SESSION['test_session'] = true;
     @session_write_close();
     $file = @fopen("{$_SERVER['DOCUMENT_ROOT']}/test_session.php", 'wb');
     @fputs($file, "<?php\n" . "@session_start();\n" . "if (\$_SESSION['test_session'] === true) {\n" . "    unset(\$_SESSION['test_session']);\n" . "    echo true;\n" . "} else {\n" . "    echo false;" . "}\n" . '?>');
     @fclose($file);
     $body = 'GET ' . dirname($_SERVER['PHP_SELF']) . "/test_session.php HTTP/1.1\r\n" . 'Host: ' . Tools::getHost() . "\r\n" . 'Cookie: ' . session_name() . '=' . session_id() . "\r\n\r\n";
     $result = file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_session.php") ? Tools::CreateRequest($body) : false;
     if (file_exists("{$_SERVER['DOCUMENT_ROOT']}/test_session.php")) {
         @unlink("{$_SERVER['DOCUMENT_ROOT']}/test_session.php");
     }
     return $result;
 }
Exemplo n.º 2
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;
 }