示例#1
0
$category = array_shift(array_keys($request->categories));
$identifier = array_shift($request->categories[$category]);
$path = SLAM_getArchivePath($config, $category, $identifier);
$access = 0;
/* get asset and set the accessibility appropriately */
if (count($result->assets[$category]) == 1) {
    $asset = array_shift($result->assets[$category]);
    $access = SLAM_getAssetAccess($user, $asset);
} else {
    $config->errors[] = 'Invalid identifier provided.';
    $access = 2;
}
/* is the current user qualified to make changes to the archive? */
if ($access > 0) {
    /* attempt to retrieve the asset's archive path*/
    if (($path = SLAM_getArchivePath($config, $category, $identifier)) !== false) {
        /* retrieve info on the files in the archive */
        if (($files = SLAM_getArchiveFiles($config, $path)) !== false) {
            echo "<div id='assetTitle'>{$identifier}</div>\n";
            echo "<div id='fileListScrollbox'>\n";
            echo "<form name='assetFileRemove' id='assetFileRemove' method='POST' action='delete.php'>\n";
            echo "<input type='hidden' name='i' value='{$identifier}' />\n";
            echo SLAM_makeArchiveFilesHTML($config, $db, $category, $identifier, $files, $access > 1);
            echo "</div>\n";
            if ($access > 1) {
                echo "<input type='button' id='deleteButton' value='Delete' onClick=\"delete_submit('assetFileRemove')\" />\n";
            }
            echo "</form>\n";
            echo "</div>\n";
        } else {
            echo "<div id='fileEmpty'>No files to show</div>\n";
示例#2
0
require '../lib/slam_files.inc.php';
$config = new SLAMconfig();
$db = new SLAMdb($config);
$user = new SLAMuser($config, $db);
$slam_file_errors['zip_errors'] = array('No error', 'No error', 'Unexpected end of zip file', 'A generic error in the zipfile format was detected.', 'zip was unable to allocate itself memory', 'A severe error in the zipfile format was detected', 'Entry too large to be split with zipsplit', 'Invalid comment format', 'zip -T failed or out of memory', 'The user aborted zip prematurely', 'zip encountered an error while using a temp file', 'Read or seek error', 'zip has nothing to do', 'Missing or empty zip file', 'Error writing to a file', 'zip was unable to create a file to write to', 'bad command line parameters', 'zip could not open a specified file to read');
//exit status descriptions from the zip man page
$slam_file_errors['unzip_errors'] = array('No error', 'One or more warning errors were encountered, but processing completed successfully anyway', 'A generic error in the zipfile format was detected', 'A severe error in the zipfile format was detected.', 'unzip was unable to allocate itself memory.', 'unzip was unable to allocate memory, or encountered an encryption error', 'unzip was unable to allocate memory during decompression to disk', 'unzip was unable allocate memory during in-memory decompression', 'unused', 'The specified zipfiles were not found', 'Bad command line parameters', 'No matching files were found', '50' => 'The disk is (or was) full during extraction', 51 => 'The end of the ZIP archive was encountered prematurely.', 80 => 'The user aborted unzip prematurely.', 81 => 'Testing or extraction of one or more files failed due to unsupported compression methods or unsupported decryption.', 82 => 'No files were found due to bad decryption password(s)');
if (!$user->authenticated) {
    echo "You are not logged in.\n";
    return;
}
$request = new SLAMrequest($config, $db, $user);
$result = new SLAMresult($config, $db, $user, $request);
$category = array_shift(array_keys($request->categories));
$identifier = array_shift($request->categories[$category]);
$path = SLAM_getArchivePath($config, $category, $identifier);
$access = 0;
/* get asset and set the accessibility appropriately */
if (count($result->assets[$category]) == 1) {
    $asset = array_shift($result->assets[$category]);
    $access = SLAM_getAssetAccess($user, $asset);
} else {
    // possibly a new asset
    $access = 2;
}
/* if we've encountered any errors at this point, bail */
if (count($config->errors) == 0 && $access > 1) {
    /* sanitize the path before going any further */
    $path = escapeshellarg($path);
    /* are there files ready to be uploaded? */
    if (isset($_FILES['asset_file'])) {
function SLAM_deleteAssetFiles(&$config, $category, $identifier)
{
    /*
    	deletes the file archive of an asset
    */
    if (($path = SLAM_getArchivePath(&$config, $category, $identifier)) !== false) {
        if (!unlink($path)) {
            $config->errors[] = 'File manager error: Could not delete asset archive.';
        }
    }
    return;
}