function upload($input_file, $input_file_name, $input_file_type, $description)
 {
     if (!util_check_fileupload($input_file)) {
         $this->setError('ArtifactFile: Invalid filename');
         return false;
     }
     $size = @filesize($input_file);
     $input_data = fread(fopen($input_file, 'r'), $size);
     return $this->create($input_file_name, $input_file_type, $size, $input_data, $description);
 }
 /**
  * Upload a file to store in artifact_file
  *
  * @return boolean
  */
 function upload($input_file, $input_file_name, $input_file_type, $description, &$changes)
 {
     global $sys_max_size_attachment, $Language;
     if (!util_check_fileupload($input_file)) {
         $this->setError($Language->getText('tracker_include_artifactfile', 'invalid_name'));
         return false;
     }
     $size = @filesize($input_file);
     $input_data = @fread(@fopen($input_file, 'r'), $size);
     if (strlen($input_data) < 1 || strlen($input_data) > $sys_max_size_attachment) {
         $this->setError($Language->getText('tracker_include_artifactfile', 'not_attached', formatByteToMb($sys_max_size_attachment)));
         return false;
     }
     return $this->create($input_file_name, $input_file_type, $size, $input_data, $description, $changes);
 }
Esempio n. 3
0
         continue;
     }
     $file_name = $_FILES['input_file']['name'][$i];
     $tmp_name = $_FILES['input_file']['tmp_name'][$i];
     if (!is_uploaded_file($tmp_name)) {
         continue;
     }
     $size = $_FILES['input_file']['size'][$i];
     $type = $_FILES['input_file']['type'][$i];
     $afh = new ArtifactFileHtml($ah);
     if (!$afh || !is_object($afh)) {
         $feedback .= 'Could Not Create File Object';
         //			} elseif ($afh->isError()) {
         //				$feedback .= $afh->getErrorMessage();
     } else {
         if (!util_check_fileupload($tmp_name)) {
             form_release_key(getStringFromRequest('form_key'));
             exit_error("Error", "Invalid filename");
         }
         if (!$afh->upload($tmp_name, $file_name, $type, ' ')) {
             $feedback .= ' <br />' . _('File Upload: Error') . ':' . $afh->getErrorMessage();
             $was_error = true;
         } else {
             $feedback .= ' <br />' . _('File Upload: Successful');
         }
     }
 }
 //
 //	Delete list of files from this artifact
 //
 $delete_file = getStringFromRequest('delete_file');
Esempio n. 4
0
     $comment_format = $request->getValidated('comment_format', $vFormat, Artifact::FORMAT_TEXT);
     if (!$ah->addComment($comment, $email, $changes, $comment_format)) {
         exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'not_saved_comment'));
     }
 }
 //
 // Add CC
 //
 if ($add_cc = trim($request->get('add_cc'))) {
     $ah->addCC($add_cc, $sanitizer->sanitize($request->get('cc_comment')), $changes);
 }
 //
 //  Attach file to this Artifact.
 //
 if (isset($_FILES['input_file']['error']) && $_FILES['input_file']['error'] != UPLOAD_ERR_NO_FILE) {
     if (!util_check_fileupload($_FILES['input_file']['tmp_name'])) {
         exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'invalid_filename_attach'));
     }
     $afh = new ArtifactFileHtml($ah);
     if (!$afh || !is_object($afh)) {
         $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_index', 'not_create_file'));
     } elseif ($afh->isError()) {
         $GLOBALS['Response']->addFeedback('error', $afh->getErrorMessage());
     } else {
         if (!$afh->upload($_FILES['input_file']['tmp_name'], $_FILES['input_file']['name'], $_FILES['input_file']['type'], $sanitizer->sanitize($request->get('file_description')), $changes)) {
             $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_index', 'not_attach_file', $afh->getErrorMessage()));
         }
     }
 }
 // send an email to notify the user of the bug update
 $agnf = new ArtifactGlobalNotificationFactory();
Esempio n. 5
0
        $ath->clearError();
    } else {
        $feedback .= _('Tracker Updated');
    }
    //
    //	Delete a tracker
    //
} elseif (getStringFromRequest('delete')) {
    $sure = getStringFromRequest('sure');
    $really_sure = getStringFromRequest('really_sure');
    if (!$ath->delete($sure, $really_sure)) {
        $feedback .= _('Error updating') . ' : ' . $ath->getErrorMessage();
    } else {
        header("Location: /tracker/admin/?group_id={$group_id}&tracker_deleted=1");
        exit;
    }
    //
    //	Upload template
    //
} elseif (getStringFromRequest('uploadtemplate')) {
    $input_file = getUploadedFile('input_file');
    if (!util_check_fileupload($input_file)) {
        echo 'Invalid filename';
        exit;
    }
    $size = $input_file['size'];
    $input_data = addslashes(fread(fopen($input_file['tmp_name'], 'r'), $size));
    db_query("UPDATE artifact_group_list SET custom_renderer='{$input_data}' WHERE group_artifact_id='" . $ath->getID() . "'");
    echo db_error();
    $feedback .= 'Renderer Uploaded';
}