mirror of
https://github.com/kleeja-official/kleeja.git
synced 2025-12-16 04:59:42 +01:00
delete files by extension feature
This commit is contained in:
@@ -1,83 +1,153 @@
|
||||
|
||||
<!-- Breadcrumbs -->
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="./">{lang.R_CPINDEX}</a></li>
|
||||
<li class="breadcrumb-item active">{lang.R_FILES} (<span>{current_page}/{total_pages}</span>)</li>
|
||||
<li class="breadcrumb-item active">
|
||||
<IF NAME="current_smt == "> {lang.R_FILES} (<span>{current_page}/{total_pages}</span>)<ELSE>{lang.DEL_BY_EXT}
|
||||
</IF>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<IF NAME="is_search">
|
||||
<div class="card">
|
||||
<span>{lang.FIND_IP_FILES} ( {nums_rows} ) {lang.FILE} <IF NAME="nums_rows"> | <a href="{deletelink}" onclick="javascript:get_kleeja_link(this.href, '#content', {confirm:true}); return false;">{lang.DELETEALLRES}</a></IF></span>
|
||||
</div>
|
||||
<div class="card">
|
||||
<span>{lang.FIND_IP_FILES} ( {nums_rows} ) {lang.FILE} <IF NAME="nums_rows"> | <a href="{deletelink}"
|
||||
onclick="javascript:get_kleeja_link(this.href, '#content', {confirm:true}); return false;">{lang.DELETEALLRES}</a>
|
||||
</IF></span>
|
||||
</div>
|
||||
</IF>
|
||||
|
||||
|
||||
<IF NAME="current_smt == ">
|
||||
<form method="post" name="filesform" action="{action}" id="files_form">
|
||||
|
||||
<form method="post" name="filesform" action="{action}" id="files_form">
|
||||
|
||||
<IF NAME="no_results">
|
||||
<div class="alert alert-info">
|
||||
{lang.NO_RESULT_USE_SYNC}
|
||||
</div>
|
||||
<IF NAME="no_results">
|
||||
<div class="alert alert-info">
|
||||
{lang.NO_RESULT_USE_SYNC}
|
||||
</div>
|
||||
<ELSE>
|
||||
|
||||
|
||||
<!-- start data table -->
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-striped table-sm" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a href="javascript:void(0);" onclick="checkAll(document.filesform, '_del', 'su');"
|
||||
title="{lang.DELETE}">#</a></th>
|
||||
<th style="width:20px;"></th>
|
||||
<th style="white-space:nowrap;">
|
||||
<a title="{lang.ALPHABETICAL_ORDER_FILES}"
|
||||
href="{ord_action}&order_by=real_filename">{lang.FILENAME}</a>
|
||||
<a href="{page2_action}&order_way=1"><i class="fa fa-sort-asc"
|
||||
title="↑"></i></a>
|
||||
<a href="{page2_action}&order_way=2"><i class="fa fa-sort-desc"
|
||||
title="↓"></i></a>
|
||||
</th>
|
||||
<th><a title="{lang.ORDER_SIZE}" href="{ord_action}&order_by=size">{lang.SIZE}</a>
|
||||
</th>
|
||||
<th><a href="{ord_action}&order_by=folder">{lang.FILDER}</a></th>
|
||||
<th><a href="{ord_action}&order_by=user">{lang.BY}</a></th>
|
||||
<th><a href="{ord_action}&order_by=user_ip">{lang.IP}</a></th>
|
||||
<th><a title="{lang.ORDER_TOTAL_DOWNLOADS}" href="{ord_action}&order_by=uploads"><i
|
||||
class="fa fa-download" title="{lang.FILEUPS}" data-toggle="tooltip"></i></a>
|
||||
</th>
|
||||
<th><a href="{ord_action}&order_by=report"><i class="fa fa-flag"
|
||||
title="{lang.NUMPER_REPORT}" data-toggle="tooltip"></i></a></th>
|
||||
<th><a href="{ord_action}&order_by=time">{lang.FILEDATE}</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<LOOP NAME="arr">
|
||||
<tr id="su[{{id}}]" class="osilver">
|
||||
<td><input type="checkbox" name="del_{{id}}" value="{{id}}"
|
||||
onclick="change_color(this,'su[{{id}}]');" rel="_del" /></td>
|
||||
<td style="width:20px;"><img src="{{typeicon}}" alt="{{type}}" title="{{type}}"
|
||||
data-toggle="tooltip" /></td>
|
||||
<td title="{{fullname}}" data-toggle="tooltip">{{name}}</td>
|
||||
<td>{{size}}</td>
|
||||
<td>{{folder}}</td>
|
||||
<td>{{user}}</td>
|
||||
<td>{{ip}} <a title="{lang.SHOWFILESBYIP}" href="{{showfilesbyip}}"><i
|
||||
class="fa fa-search"></i></a></td>
|
||||
<td>
|
||||
<IF LOOP="direct"><i class="fa fa-bell-slash-o" title="{lang.DIRECT_FILE_NOTE}"
|
||||
data-toggle="tooltip"></i>
|
||||
<ELSE>{{ups}}
|
||||
</IF>
|
||||
</td>
|
||||
<td>{{report}}</td>
|
||||
<td title="{{time}}" data-toggle="tooltip">{{time_human}}</td>
|
||||
<!-- admin files data td2 extra -->
|
||||
</tr>
|
||||
</LOOP>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end data table -->
|
||||
|
||||
<div class="form-group">
|
||||
<!--<div class="col">[ <a href="javascript:void(0);" onclick="checkAll(document.filesform, '_del', 'su');">{lang.CHECK_ALL}</a> ]</div>-->
|
||||
|
||||
<input type="submit" class="btn btn-outline-primary" name="submit" value="{lang.DEL_SELECTED}">
|
||||
</div>
|
||||
|
||||
|
||||
<!-- pagination -->
|
||||
{page_nums}
|
||||
|
||||
</IF>
|
||||
|
||||
{H_FORM_KEYS}
|
||||
</form>
|
||||
<ELSE>
|
||||
|
||||
|
||||
<!-- start data table -->
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-striped table-sm" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a href="javascript:void(0);" onclick="checkAll(document.filesform, '_del', 'su');" title="{lang.DELETE}">#</a></th>
|
||||
<th style="width:20px;"></th>
|
||||
<th style="white-space:nowrap;">
|
||||
<a title="{lang.ALPHABETICAL_ORDER_FILES}"
|
||||
href="{ord_action}&order_by=real_filename">{lang.FILENAME}</a>
|
||||
<a href="{page2_action}&order_way=1"><i class="fa fa-sort-asc" title="↑"></i></a>
|
||||
<a href="{page2_action}&order_way=2"><i class="fa fa-sort-desc"
|
||||
title="↓"></i></a>
|
||||
</th>
|
||||
<th><a title="{lang.ORDER_SIZE}" href="{ord_action}&order_by=size">{lang.SIZE}</a></th>
|
||||
<th><a href="{ord_action}&order_by=folder">{lang.FILDER}</a></th>
|
||||
<th><a href="{ord_action}&order_by=user">{lang.BY}</a></th>
|
||||
<th><a href="{ord_action}&order_by=user_ip">{lang.IP}</a></th>
|
||||
<th><a title="{lang.ORDER_TOTAL_DOWNLOADS}" href="{ord_action}&order_by=uploads"><i class="fa fa-download" title="{lang.FILEUPS}" data-toggle="tooltip"></i></a></th>
|
||||
<th><a href="{ord_action}&order_by=report"><i class="fa fa-flag" title="{lang.NUMPER_REPORT}" data-toggle="tooltip"></i></a></th>
|
||||
<th><a href="{ord_action}&order_by=time">{lang.FILEDATE}</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<LOOP NAME="arr">
|
||||
<tr id="su[{{id}}]" class="osilver">
|
||||
<td><input type="checkbox" name="del_{{id}}" value="{{id}}" onclick="change_color(this,'su[{{id}}]');" rel="_del" /></td>
|
||||
<td style="width:20px;"><img src="{{typeicon}}" alt="{{type}}" title="{{type}}" data-toggle="tooltip"/></td>
|
||||
<td title="{{fullname}}" data-toggle="tooltip">{{name}}</td>
|
||||
<td>{{size}}</td>
|
||||
<td>{{folder}}</td>
|
||||
<td>{{user}}</td>
|
||||
<td>{{ip}} <a title="{lang.SHOWFILESBYIP}" href="{{showfilesbyip}}"><i class="fa fa-search"></i></a></td>
|
||||
<td><IF LOOP="direct"><i class="fa fa-bell-slash-o" title="{lang.DIRECT_FILE_NOTE}" data-toggle="tooltip"></i><ELSE>{{ups}}</IF></td>
|
||||
<td>{{report}}</td>
|
||||
<td title="{{time}}" data-toggle="tooltip">{{time_human}}</td>
|
||||
<!-- admin files data td2 extra -->
|
||||
</tr>
|
||||
</LOOP>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="container">
|
||||
<IF NAME="no_results">
|
||||
<div class="alert alert-info">
|
||||
{lang.NO_RESULT_USE_SYNC}
|
||||
</div>
|
||||
<ELSE>
|
||||
<form action="{action}" style="text-align: center;" method="post">
|
||||
<div class="form-group">
|
||||
<label for="selected_extnsions">{lang.SELECT_EXT}</label>
|
||||
<select class="form-control" name="selected_extnsion" id="selected_extnsions">
|
||||
<option></option>
|
||||
<LOOP NAME="available_extensions">
|
||||
<option>{{type}}</option>
|
||||
</LOOP>
|
||||
</select>
|
||||
</div>
|
||||
<button id="delete_button" style="display: none;" name="delete_files" type="submit"
|
||||
class="btn btn-danger">{lang.DELETE}</button>
|
||||
</form>
|
||||
</IF>
|
||||
</div>
|
||||
<!-- end data table -->
|
||||
|
||||
<div class="form-group">
|
||||
<!--<div class="col">[ <a href="javascript:void(0);" onclick="checkAll(document.filesform, '_del', 'su');">{lang.CHECK_ALL}</a> ]</div>-->
|
||||
|
||||
<input type="submit" class="btn btn-outline-primary" name="submit" value="{lang.DEL_SELECTED}">
|
||||
</div>
|
||||
|
||||
|
||||
<!-- pagination -->
|
||||
{page_nums}
|
||||
|
||||
</IF>
|
||||
|
||||
{H_FORM_KEYS}
|
||||
</form>
|
||||
<script>
|
||||
let selected_extnsions = document.getElementById('selected_extnsions');
|
||||
let delete_button = document.getElementById('delete_button');
|
||||
if (selected_extnsions && delete_button) {
|
||||
selected_extnsions.onchange = () => {
|
||||
if (selected_extnsions.value.trim() != '') {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
if (this.responseText == '0') {
|
||||
alert('{lang.NO_FILE_WITH_EXT}')
|
||||
delete_button.style.display = 'none';
|
||||
}
|
||||
else {
|
||||
alert(("{lang.X_FILE_WITH_EXT}").replace('(x)', this.responseText))
|
||||
delete_button.style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
xhttp.open("GET", "{action}&fetch_ext_files=" + selected_extnsions.value, true);
|
||||
xhttp.send();
|
||||
}
|
||||
else {
|
||||
delete_button.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</IF>
|
||||
@@ -17,6 +17,7 @@ if (! defined('IN_ADMIN'))
|
||||
|
||||
//number of images per page
|
||||
$files_acp_perpage = defined('ACP_FILES_PER_PAGE') ? ACP_FILES_PER_PAGE : 20;
|
||||
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', ''));
|
||||
|
||||
|
||||
//display
|
||||
@@ -30,7 +31,7 @@ $url_pg = ig('page') ? '&page=' . g('page', 'int') : '';
|
||||
$page_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or . $url_sea . $url_lst;
|
||||
$ord_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_pg . $url_sea . $url_lst;
|
||||
$page2_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . $url_or2 . $url_sea . $url_lst;
|
||||
$action = $page_action . $url_pg;
|
||||
$action = $page_action . $url_pg . ($current_smt == 'delete_by_extension' ? '&smt=delete_by_extension' : '');
|
||||
$is_search = $affected = false;
|
||||
$H_FORM_KEYS = kleeja_add_form_key('adm_files');
|
||||
|
||||
@@ -133,11 +134,11 @@ if (ip('submit'))
|
||||
'<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . str_replace('&', '&', $action) . '\');", 2000);</script>' . "\n";
|
||||
$stylee = 'admin_info';
|
||||
}
|
||||
else
|
||||
elseif ($current_smt == '')
|
||||
{
|
||||
|
||||
//
|
||||
//Delete all user files [only one user]
|
||||
//Delete all user files [only one user]
|
||||
//
|
||||
if (ig('deletefiles'))
|
||||
{
|
||||
@@ -404,3 +405,90 @@ else
|
||||
$page_nums = $Pager->print_nums($page_action);
|
||||
$current_page = $Pager->getCurrentPage();
|
||||
}
|
||||
elseif ($current_smt == 'delete_by_extension')
|
||||
{
|
||||
if (ig('fetch_ext_files'))
|
||||
{
|
||||
$query = [
|
||||
'SELECT' => 'id',
|
||||
'FROM' => $dbprefix . 'files',
|
||||
'WHERE' => 'type = \'' . g('fetch_ext_files') . '\''
|
||||
];
|
||||
|
||||
$SQL->build($query);
|
||||
|
||||
echo $SQL->num_rows();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if (ip('delete_files'))
|
||||
{
|
||||
$ext = p('selected_extnsion');
|
||||
|
||||
$query = [
|
||||
'SELECT' => 'id, name, type, size',
|
||||
'FROM' => $dbprefix . 'files',
|
||||
'WHERE' => 'type = \'' . $ext . '\''
|
||||
];
|
||||
|
||||
$SQL->build($query);
|
||||
$deleted_files = [];
|
||||
$fileSizes = 0;
|
||||
|
||||
if ($SQL->num_rows())
|
||||
{
|
||||
while ($file = $SQL->fetch())
|
||||
{
|
||||
$fileLocation = PATH . 'uploads/' . $file['name'];
|
||||
$thumbFileLocation = PATH . 'uploads/thumbs/' . $file['name'];
|
||||
|
||||
if (is_file($fileLocation))
|
||||
{
|
||||
kleeja_unlink($fileLocation);
|
||||
}
|
||||
if (is_file($thumbFileLocation))
|
||||
{
|
||||
kleeja_unlink($thumbFileLocation);
|
||||
}
|
||||
$fileSizes += $file['size'];
|
||||
$deleted_files[] = $file['id'];
|
||||
}
|
||||
|
||||
if (($deletedFileCount = count($deleted_files)) <= 1)
|
||||
{
|
||||
$SQL->query("delete from {$dbprefix}files where id = '$deleted_files[0]'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$SQL->query("delete from {$dbprefix}files where id in (" . implode(',', $deleted_files) . ')');
|
||||
}
|
||||
|
||||
$update_stats = "update {$dbprefix}stats set " . (in_array($ext, ['png','gif','jpg','jpeg', 'bmp']) ? 'imgs = imgs-' . $deletedFileCount : 'files = files-' . $deletedFileCount)
|
||||
. ", sizes = sizes-{$fileSizes}";
|
||||
|
||||
|
||||
$SQL->query($update_stats);
|
||||
}
|
||||
|
||||
kleeja_admin_info($lang['ADMIN_DELETE_FILE_OK'], true, '', true, $action);
|
||||
}
|
||||
|
||||
$available_extensions = [];
|
||||
$query = [
|
||||
'SELECT' => 'DISTINCT type',
|
||||
'FROM' => $dbprefix . 'files'
|
||||
];
|
||||
|
||||
$SQL->build($query);
|
||||
|
||||
while ($ext = $SQL->fetch())
|
||||
{
|
||||
$available_extensions[] = $ext;
|
||||
}
|
||||
|
||||
$no_results = count($available_extensions) == 0;
|
||||
}
|
||||
$go_menu = [
|
||||
'delete_by_extension' => ['name'=> $lang['DEL_BY_EXT'], 'link'=> basename(ADMIN_PATH) . '?cp=c_files&smt=delete_by_extension', 'goto'=>'delete_by_extension', 'current'=> $current_smt == 'delete_by_extension'],
|
||||
];
|
||||
|
||||
@@ -38,6 +38,7 @@ class kleeja_style
|
||||
|
||||
$html = file_get_contents($template_path);
|
||||
$html = $this->_parse($html, $template_name);
|
||||
$html = "<!-- file generated by kleeja {kleeja.net} -->\n" . $html;
|
||||
|
||||
//use 'b' to force binary mode
|
||||
if ($filename = @fopen(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php', 'wb'))
|
||||
|
||||
@@ -280,4 +280,8 @@ return [
|
||||
'CANT_DEL_DEFAULT_STYLE' => 'لا يمكنك حذف الستايل الإفتراضي! قم بتعيين ستايل آخر لتستطيع حذفه.',
|
||||
'NOTIFICATIONS' => 'تنبيهات',
|
||||
'KJ_TWEETS' => 'تغريدات كليجا',
|
||||
'DEL_BY_EXT' => 'حذف الملفات حسب الامتداد',
|
||||
'SELECT_EXT' => 'حدد الامتداد',
|
||||
'NO_FILE_WITH_EXT' => 'لا يوجد ملفات موجودة بالملحق المحدد',
|
||||
'X_FILE_WITH_EXT' => 'يوجد (x) ملفات بالملحق المحدد',
|
||||
];
|
||||
|
||||
@@ -277,4 +277,8 @@ return [
|
||||
'CANT_DEL_DEFAULT_STYLE' => 'You can not delete the current default style! choose another style to be the default then try again.',
|
||||
'NOTIFICATIONS' => 'Notifications',
|
||||
'KJ_TWEETS' => 'Kleeja Tweets',
|
||||
'DEL_BY_EXT' => 'Delete Files By Extension',
|
||||
'SELECT_EXT' => 'Select an Extension',
|
||||
'NO_FILE_WITH_EXT' => 'there is no files exists with the selected extension',
|
||||
'X_FILE_WITH_EXT' => 'there is (x) files exists with the selected extension',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user