Quockunplus
(Thành Viên)
[Off] 14-03-2016 |
Đôi lúc file bị xóa mất, lỗi hay muốn cập nhật file mới mà không biết làm thế nào thì mod này giúp bạn xoá file đã đính kèm. Rất tiện lợi nhé!
Tạo 1 file với tên [blue]xoafile.php[/blue] trong [red]forum/include[/red] với nội dung:
<?php
// code xoa file
defined('_IN_JOHNCMS') or die('Error: restricted access');
$error = false;
if ($rights >= 6) {
if ($id) {
//---Get info file---//
$req = mysql_query("SELECT * FROM `cms_forum_files` WHERE `id` = '$id'");
if (mysql_num_rows($req)) {
$res = mysql_fetch_array($req);
mysql_query("DELETE FROM `cms_forum_files` WHERE `id` = '$id'");
if (file_exists('../files/forum/attach/' . $res['filename'])) {
unlink('../files/forum/attach/' . $res['filename']);
}
require('../incfiles/head.php');
echo'<div class="rmenu">Đã xóa thành công</div>';
require('../incfiles/end.php');
} else {
$error = true;
}
if ($error) {
require('../incfiles/head.php');
echo '<div class="rmenu">Không thể xóa</div>';
require('../incfiles/end.php');
exit;
}
} else {
require('../incfiles/head.php');
echo functions::display_error($lng['error_wrong_data']);
require('../incfiles/end.php');
exit;
}
} else {
echo functions::display_error($lng['access_forbidden']);
}
?>
// code xoa file
defined('_IN_JOHNCMS') or die('Error: restricted access');
$error = false;
if ($rights >= 6) {
if ($id) {
//---Get info file---//
$req = mysql_query("SELECT * FROM `cms_forum_files` WHERE `id` = '$id'");
if (mysql_num_rows($req)) {
$res = mysql_fetch_array($req);
mysql_query("DELETE FROM `cms_forum_files` WHERE `id` = '$id'");
if (file_exists('../files/forum/attach/' . $res['filename'])) {
unlink('../files/forum/attach/' . $res['filename']);
}
require('../incfiles/head.php');
echo'<div class="rmenu">Đã xóa thành công</div>';
require('../incfiles/end.php');
} else {
$error = true;
}
if ($error) {
require('../incfiles/head.php');
echo '<div class="rmenu">Không thể xóa</div>';
require('../incfiles/end.php');
exit;
}
} else {
require('../incfiles/head.php');
echo functions::display_error($lng['error_wrong_data']);
require('../incfiles/end.php');
exit;
}
} else {
echo functions::display_error($lng['access_forbidden']);
}
?>
Lưu lại.
Tiếp theo mở file [blue]index.php[/blue] trong forum ra và tìm:
<?php
'vip',
'vote',
?>
'vip',
'vote',
?>
Chèn vào bên dưới:
<?php
'xoafile',
?>
'xoafile',
?>
Tìm tiếp:
<?php
$file_id = $fres['id'];
?>
$file_id = $fres['id'];
?>
Thêm bên dưới:
<?php
if ($rights >= 6)
echo' <a href="index.php?act=xoafile&id=' . $fres['id'] . '">Xóa</a>';
if ($fls == 0) {
echo'
File đã bị xóa';
}
?>
if ($rights >= 6)
echo' <a href="index.php?act=xoafile&id=' . $fres['id'] . '">Xóa</a>';
if ($fls == 0) {
echo'
File đã bị xóa';
}
?>
Xong rồi đó,lưu lại.
Chúc thành công!