Beispiel #1
0
    result('software', 'PHP GD library', 'W', 'The PHP GD library is not available. Test case images cannot be uploaded.');
} else {
    result('software', 'PHP GD library', 'O', 'The PHP GD library is available to handle test case images.');
}
if (extension_loaded('suhosin')) {
    result('software', 'suhosin', 'E', 'PHP suhosin extension loaded. This may result in dropping POST arguments, e.g. output_run.');
} else {
    result('software', 'suhosin', 'O', 'PHP suhosin extension disabled.');
}
$max_file_check = max(100, dbconfig_get('sourcefiles_limit', 100));
result('software', 'PHP max_file_uploads', (int) ini_get('max_file_uploads') < $max_file_check ? 'W' : 'O', 'PHP max_file_uploads is set to ' . (int) ini_get('max_file_uploads') . '. This should be set higher ' . 'than the maximum number of test cases per problem and the ' . 'configuration setting \'sourcefiles_limit\'.');
$sizes = array();
$postmaxvars = array('post_max_size', 'memory_limit', 'upload_max_filesize');
foreach ($postmaxvars as $var) {
    /* skip 0 or empty values, and -1 which means 'unlimited' */
    if ($size = phpini_to_bytes(ini_get($var))) {
        if ($size != '-1') {
            $sizes[$var] = $size;
        }
    }
}
$resulttext = 'PHP POST/upload filesize is limited to ' . printsize(min($sizes)) . "\n\nThis limit needs to be larger than the testcases you want to upload and than the amount of program output you expect the judgedaemons to post back to DOMjudge. We recommend at least 50 MB.\n\nNote that you need to ensure that all of the following php.ini parameters are at minimum the desired size:\n";
foreach ($postmaxvars as $var) {
    $resulttext .= "{$var} (now set to " . (isset($sizes[$var]) ? printsize($sizes[$var]) : "unlimited") . ")\n";
}
result('software', 'PHP POST/upload filesize', min($sizes) < 52428800 ? 'W' : 'O', '', $resulttext);
if (class_exists("ZipArchive")) {
    result('software', 'Problem up/download via zip bundles', 'O', 'PHP ZipArchive class available for importing and exporting problem data.');
} else {
    result('software', 'Problem up/download via zip bundles', 'W', 'Optionally, enable the PHP zip extension ' . 'to be able to import or export problem data via zip bundles.');
}
Beispiel #2
0
 /**
  * Call an API function
  */
 public function callFunction($name, $arguments)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         list($name, $primary_key) = explode('/', $name);
         $arguments['__primary_key'] = $primary_key;
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $postmax = phpini_to_bytes(trim(ini_get('post_max_size')));
             if ($postmax != -1 && $postmax < $_SERVER['CONTENT_LENGTH']) {
                 $this->createError("Size of post data too large (" . $_SERVER['CONTENT_LENGTH'] . "), increase post_max_size (" . $postmax . ") in your PHP config.");
             }
         }
     }
     $name = $name . '#' . $_SERVER['REQUEST_METHOD'];
     if (!array_key_exists($name, $this->apiFunctions)) {
         $this->createError("Function '" . $name . "' does not exist.", BAD_REQUEST);
     }
     $func = $this->apiFunctions[$name];
     // Permissions
     // no roles = anyone may access; admin may also access all
     if (!empty($func['roles']) && !checkrole('admin')) {
         $hasrole = false;
         foreach ($func['roles'] as $role) {
             if (checkrole($role)) {
                 $hasrole = TRUE;
                 break;
             }
         }
         if (!$hasrole) {
             $this->createError("Permission denied " . "' for function '" . $name . "'.", FORBIDDEN);
         }
     }
     // Arguments
     $args = array();
     foreach ($arguments as $key => $value) {
         if (!array_key_exists($key, $func['optArgs']) && $key != '__primary_key') {
             $this->createError("Invalid argument '" . $key . "' for function '" . $name . "'.", BAD_REQUEST);
         }
         $args[$key] = $value;
     }
     // Special case for public:
     if (array_key_exists('public', $func['optArgs'])) {
         if (checkrole('jury') && !isset($args['public'])) {
             // Default for jury is non-public
             $args['public'] = 0;
         } elseif (!checkrole('jury')) {
             // Only allowed for non-jury is public
             $args['public'] = 1;
         }
     }
     $this->createResponse(call_user_func($func['callback'], $args));
 }