header('Location: ' . url_rewrite('mods/_standard/file_storage/comments.php' . $owner_arg_prefix . 'id=' . $_POST['id'], AT_PRETTY_URL_IS_HEADER)); exit; } $_GET['id'] = $_POST['id']; } } } } } } if (isset($_GET['comment_id'])) { $onload = 'document.form.edit_comment.focus();'; } require AT_INCLUDE_PATH . 'header.inc.php'; $id = abs($_GET['id']); $files = fs_get_revisions($id, $owner_type, $owner_id); if (!$files) { $msg->printErrors('FILE_NOT_FOUND'); require AT_INCLUDE_PATH . 'footer.inc.php'; exit; } ?> <?php if ($_config['fs_versioning']) { ?> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <input type="hidden" name="ot" value="<?php
$owner_id = abs($_REQUEST['oid']); $owner_arg_prefix = '?ot=' . $owner_type . SEP . 'oid=' . $owner_id . SEP; if (!($owner_status = fs_authenticate($owner_type, $owner_id)) || !query_bit($owner_status, WORKSPACE_AUTH_WRITE)) { exit('NOT AUTHENTICATED'); } $id = abs($_REQUEST['id']); if (isset($_POST['submit_no'])) { $path = fs_get_revisions($id, $owner_type, $owner_id); reset($path); $first = current($path); $msg->addFeedback('CANCELLED'); header('Location: ' . url_rewrite('mods/_standard/file_storage/revisions.php' . $owner_arg_prefix . 'id=' . $first['file_id'], AT_PRETTY_URL_IS_HEADER)); exit; } else { if (isset($_POST['submit_yes'])) { $path = fs_get_revisions($id, $owner_type, $owner_id); // set the new parent // $sql = "SELECT parent_file_id, owner_type, owner_id, folder_id FROM " . TABLE_PREFIX . "files WHERE file_id={$id} AND owner_type={$owner_type} AND owner_id={$owner_id}"; $result = mysql_query($sql, $db); $row = mysql_fetch_assoc($result); $sql = "UPDATE " . TABLE_PREFIX . "files SET parent_file_id={$row['parent_file_id']}, date=date WHERE parent_file_id={$id} AND owner_type={$owner_type} AND owner_id={$owner_id}"; mysql_query($sql, $db); $sql = "UPDATE " . TABLE_PREFIX . "files SET num_revisions=num_revisions-1, date=date WHERE file_id>{$id} AND owner_type={$row['owner_type']} AND owner_id={$row['owner_id']} AND folder_id={$row['folder_id']}"; mysql_query($sql, $db); $sql = "DELETE FROM " . TABLE_PREFIX . "files WHERE file_id={$id} AND owner_type={$owner_type} AND owner_id={$owner_id}"; mysql_query($sql, $db); $sql = "DELETE FROM " . TABLE_PREFIX . "files_comments WHERE file_id={$id}"; mysql_query($sql, $db); $file = fs_get_file_path($id); if (file_exists($file . $id)) { @unlink($file . $id);
/** * delete a given file, its revisions, and comments. * * $file_id the ID of the file to delete. can be any ID within a revision sequence. */ function fs_delete_file($file_id, $owner_type, $owner_id) { $revisions = fs_get_revisions($file_id, $owner_type, $owner_id); foreach ($revisions as $file) { $sql = "DELETE FROM %sfiles WHERE file_id=%d AND owner_type=%d AND owner_id=%d"; $result = queryDB($sql, array(TABLE_PREFIX, $file['file_id'], $owner_type, $owner_id)); if ($result == 1) { $sql = "DELETE FROM %sfiles_comments WHERE file_id=%d"; queryDB($sql, array(TABLE_PREFIX, $file['file_id'])); $path = fs_get_file_path($file['file_id']); if (file_exists($path . $file['file_id'])) { @unlink($path . $file['file_id']); } } } }
/** * delete a given file, its revisions, and comments. * * $file_id the ID of the file to delete. can be any ID within a revision sequence. */ function fs_delete_file($file_id, $owner_type, $owner_id) { global $db; $revisions = fs_get_revisions($file_id, $owner_type, $owner_id); foreach ($revisions as $file) { $sql = "DELETE FROM ".TABLE_PREFIX."files WHERE file_id=$file[file_id] AND owner_type=$owner_type AND owner_id=$owner_id"; mysql_query($sql, $db); if (mysql_affected_rows($db) == 1) { $sql = "DELETE FROM ".TABLE_PREFIX."files_comments WHERE file_id=$file[file_id]"; mysql_query($sql, $db); $path = fs_get_file_path($file['file_id']); if (file_exists($path . $file['file_id'])) { @unlink($path . $file['file_id']); } } } }
$orders = array('asc' => 'desc', 'desc' => 'asc'); $cols = array('num_revisions' => 1, 'file_name' => 1, 'date' => 1, 'num_comments' => 1, 'file_size' => 1); if (isset($_GET['asc'])) { $order = 'asc'; $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'num_revisions'; } else if (isset($_GET['desc'])) { $order = 'desc'; $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'num_revisions'; } else { // no order set $order = 'desc'; $col = 'num_revisions'; } $files = fs_get_revisions($id, $owner_type, $owner_id, $col, $order); $current_file = current($files); usort($files, 'fs_revisions_sort_compare'); ?> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form"> <input type="hidden" name="folder" value="<?php echo $current_file['folder_id']; ?>" /> <input type="hidden" name="ot" value="<?php echo $owner_type; ?>" /> <input type="hidden" name="oid" value="<?php echo $owner_id; ?>" /> <table class="data"> <colgroup> <?php if ($col == 'num_revisions'): ?> <col />