2014-05-30 Miguel de Dios <miguel.dedios@artica.es>

* extensions/files_repo/files_repo_list.php: fixed PHP warnings.
	
	Incident: #847




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10056 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-05-30 17:18:59 +00:00
parent c3ad65f4b9
commit ba0af0e707
2 changed files with 26 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2014-05-30 Miguel de Dios <miguel.dedios@artica.es>
* extensions/files_repo/files_repo_list.php: fixed PHP warnings.
Incident: #847
2014-05-30 Sergio Martin <sergio.martin@artica.es> 2014-05-30 Sergio Martin <sergio.martin@artica.es>
* godmode/servers/recon_script.php: Improve layout of recon scripts * godmode/servers/recon_script.php: Improve layout of recon scripts

View File

@ -28,18 +28,23 @@ $filter['order'] = array('field' => 'id', 'order' => 'DESC');
$files = files_repo_get_files($filter); $files = files_repo_get_files($filter);
if (!empty($files)) { if (!empty($files)) {
echo "<br>"; echo "<br>";
if (!isset($manage)) {
$manage = false;
}
// Pagination // Pagination
if ($manage) { if ($manage) {
$url = ui_get_full_url("index.php?sec=gextensions&sec2=extensions/files_repo"); $url = ui_get_full_url("index.php?sec=gextensions&sec2=extensions/files_repo");
} else { }
else {
$url = ui_get_full_url("index.php?sec=extensions&sec2=extensions/files_repo"); $url = ui_get_full_url("index.php?sec=extensions&sec2=extensions/files_repo");
} }
$total_files = files_repo_get_files(false, true); $total_files = files_repo_get_files(false, true);
ui_pagination($total_files, $url, $offset); ui_pagination($total_files, $url, $offset);
$table = new stdClass(); $table = new stdClass();
$table->width = '98%'; $table->width = '98%';
$table->style = array(); $table->style = array();
@ -54,21 +59,21 @@ if (!empty($files)) {
$table->head[3] = __("Last modification"); $table->head[3] = __("Last modification");
$table->head[4] = ""; $table->head[4] = "";
$table->data = array(); $table->data = array();
foreach ($files as $file_id => $file) { foreach ($files as $file_id => $file) {
$data = array(); $data = array();
// Prepare the filename for the get_file.php script // Prepare the filename for the get_file.php script
$relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $file['location']); $relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $file['location']);
$file_path = base64_encode($relative_path); $file_path = base64_encode($relative_path);
$hash = md5($relative_path . $config['dbpass']); $hash = md5($relative_path . $config['dbpass']);
$url = ui_get_full_url("include/get_file.php?file=$file_path&hash=$hash"); $url = ui_get_full_url("include/get_file.php?file=$file_path&hash=$hash");
$data[0] = "<a href=\"$url\" target=\"_blank\">" . $file['name'] . "</a>"; // Name $data[0] = "<a href=\"$url\" target=\"_blank\">" . $file['name'] . "</a>"; // Name
$data[1] = ui_print_truncate_text($file['description'], 'description', true, true); // Description $data[1] = ui_print_truncate_text($file['description'], 'description', true, true); // Description
$data[2] = ui_format_filesize($file['size']); // Size $data[2] = ui_format_filesize($file['size']); // Size
$data[3] = date('F j, Y - H:m', $file['mtime']); // Last modification $data[3] = date('F j, Y - H:m', $file['mtime']); // Last modification
// Public URL // Public URL
$data[4] = ""; $data[4] = "";
if (!empty($file['hash'])) { if (!empty($file['hash'])) {
@ -79,18 +84,18 @@ if (!empty($files)) {
$data[4] .= html_print_image('images/world.png', true, array('title' => __('Public link'))); // Public link image $data[4] .= html_print_image('images/world.png', true, array('title' => __('Public link'))); // Public link image
$data[4] .= "</a> "; $data[4] .= "</a> ";
} }
$data[4] .= "<a href=\"$url\" target=\"_blank\">"; $data[4] .= "<a href=\"$url\" target=\"_blank\">";
$data[4] .= html_print_image('images/download.png', true, array('title' => __('Download'))); // Download image $data[4] .= html_print_image('images/download.png', true, array('title' => __('Download'))); // Download image
$data[4] .= "</a>"; $data[4] .= "</a>";
if ($manage) { if ($manage) {
$config_url = ui_get_full_url("index.php?sec=gextensions&sec2=extensions/files_repo&file_id=$file_id"); $config_url = ui_get_full_url("index.php?sec=gextensions&sec2=extensions/files_repo&file_id=$file_id");
$data[4] .= " <a href=\"$config_url\">"; $data[4] .= " <a href=\"$config_url\">";
$data[4] .= html_print_image('images/config.png', true, array('title' => __('Edit'))); // Edit image $data[4] .= html_print_image('images/config.png', true, array('title' => __('Edit'))); // Edit image
$data[4] .= "</a>"; $data[4] .= "</a>";
$delete_url = ui_get_full_url("index.php?sec=gextensions&sec2=extensions/files_repo&delete=1&file_id=$file_id"); $delete_url = ui_get_full_url("index.php?sec=gextensions&sec2=extensions/files_repo&delete=1&file_id=$file_id");
$data[4] .= " <a href=\"$delete_url\" onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\">"; $data[4] .= " <a href=\"$delete_url\" onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\">";
$data[4] .= html_print_image('images/cross.png', true, array('title' => __('Delete'))); // Delete image $data[4] .= html_print_image('images/cross.png', true, array('title' => __('Delete'))); // Delete image
@ -99,8 +104,9 @@ if (!empty($files)) {
$table->data[] = $data; $table->data[] = $data;
} }
html_print_table($table); html_print_table($table);
} else { }
else {
ui_print_info_message(__('No items')); ui_print_info_message(__('No items'));
} }