Example #1
0
  $("#rb_public, #rb_private").change(showHideOwnerInfo);
  $( document ).ready(showHideOwnerInfo);
</script>
<?php 
    include "footer.php";
    exit;
}
// The rspec is in $_FILES["file"]["tmp_name"]
$actual_filename = $_FILES["file"]["tmp_name"];
$filename = $_FILES["file"]["name"];
$description = NULL;
$name = $_POST["name"];
$visibility = $_POST["group1"];
$description = $_POST["description"];
$rspec_id = $_POST['rspec_id'];
$parse_results = parseRequestRSpec($actual_filename);
if (is_null($parse_results)) {
    error_log("Failed to parse uploaded RSpec '{$actual_filename}'");
    $msg = "ERROR. RSpec '{$name}' from file '{$filename}' failed to parse.";
    $_SESSION['lasterror'] = $msg;
    relative_redirect('profile#rspecs');
    exit;
}
$contents = $parse_results[0];
$is_bound = $parse_results[1];
$is_stitch = $parse_results[2];
$am_urns = $parse_results[3];
if (rspec_name_exists($user, $visibility, $name, $rspec_id)) {
    /* This rspec name has already been taken. */
    $msg = "ERROR. A {$visibility} RSpec already exists with name \"{$name} \".";
    $_SESSION['lasterror'] = $msg;
 $errorcode = $_FILES['user_rspec_file']['error'];
 if ($errorcode != 0) {
     // An error occurred with the upload.
     if ($errorcode == UPLOAD_ERR_NO_FILE) {
         $results['message'] = "<b style='color:red;'>ERROR:</b> No file was uploaded.";
     } else {
         $results['message'] = "<b style='color:red;'>ERROR:</b> Unknown upload error (code = {$errorcode}).";
     }
 } else {
     // Upload was successful, do some basic checks on the contents.
     $rspec_filename = $_FILES["user_rspec_file"]["tmp_name"];
     if (!validateRSpec($rspec_filename, $msg)) {
         $results['message'] = "<b style='color:red;'>ERROR:</b> This RSpec is <b>invalid</b>: " . $msg;
     } else {
         // get bound status, stitching status, and AM URNs if possible
         $parse_results = parseRequestRSpec($rspec_filename);
         if (is_null($parse_results)) {
             $results['message'] = "<b style='color:red;'>ERROR:</b> This RSpec is <b>invalid</b>.";
         } else {
             // RSpec was valid
             $results['valid'] = true;
             $results['message'] = "This RSpec is <b>valid</b>";
             $results['rspec'] = $parse_results[0];
             $results['bound'] = $parse_results[1];
             $results['stitch'] = $parse_results[2];
             // FIXME: We can pass the AM URNs back if we need to for bound RSpecs
             $results['ams'] = $parse_results[3];
             $results['partially_bound'] = $parse_results[4];
             // Check for case wherein the rspec is bound to unknown aggregate
             $bound_aggregates = $results['ams'];
             $unknown_aggregates = checkForUnknownAggregates($bound_aggregates);