public function testMysql() { Tests_DBLoader4Test::getUp(); $servCheck = ServerCheck::getInstance(); $mysql_params = $servCheck->getMysqlParams(); $this->assertInstanceOf('ServerCheck_mysqlParams', $mysql_params); }
public function testMysql() { $this->markTestIncomplete('To be fixed.'); Tests_DBLoader4Test::getUp(); $servCheck = ServerCheck::getInstance(); $mysql_params = $servCheck->getMysqlParams(); $this->assertInstanceOf('ServerCheck_mysqlParams', $mysql_params); }
public function post() { if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { return $this->delete(); } $upload = isset($_FILES[$this->options['param_name']]) ? $_FILES[$this->options['param_name']] : null; $info = array(); if ($upload && is_array($upload['tmp_name'])) { // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index => $value) { $info[] = $this->handle_file_upload($upload['tmp_name'][$index], isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], $upload['error'][$index], $index); } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: $info[] = $this->handle_file_upload(isset($upload['tmp_name']) ? $upload['tmp_name'] : null, isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), isset($upload['error']) ? $upload['error'] : null); } //check for server misconfiguration $uploadParams = ServerCheck::getInstance()->getUploadParams(); if ($_SERVER['CONTENT_LENGTH'] >= $uploadParams->getPostMaxSize()) { $fp = fopen("php://input", "r"); list($trash, $boundary) = explode('boundary=', $_SERVER['CONTENT_TYPE']); $regexp = '/' . $boundary . '.*?filename="(.*)".*?Content-Type:(.*)\\x{0D}\\x{0A}\\x{0D}\\x{0A}/sm'; $readBuff = fread($fp, 1024); while (!preg_match($regexp, $readBuff, $matches)) { $readBuff .= fread($fp, 1024); } fclose($fp); $file = new stdClass(); $file->name = $this->trim_file_name($matches[1], trim($matches[2]), null); $file->size = null; $file->type = trim($matches[2]); $file->error = "The file is too large. " . "Please Contact support@matecat.com and report these details: " . "\"The server configuration does not conform with Matecat configuration. " . "Check for max header post size value in the virtualhost configuration or php.ini.\""; $info = array($file); } elseif ($_SERVER['CONTENT_LENGTH'] >= $uploadParams->getUploadMaxFilesize()) { $info[0]->error = "The file is too large. " . "Please Contact support@matecat.com and report these details: " . "\"The server configuration does not conform with Matecat configuration. " . "Check for max file upload value in the virtualhost configuration or php.ini.\""; } //check for server misconfiguration header('Vary: Accept'); $json = json_encode($info); $redirect = isset($_REQUEST['redirect']) ? stripslashes($_REQUEST['redirect']) : null; if ($redirect) { header('Location: ' . sprintf($redirect, rawurlencode($json))); return; } if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) { header('Content-type: application/json'); } else { header('Content-type: text/plain'); } echo $json; }