1 Star 3 Fork 2

mojie126/HDCN-PT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
delattachments.php 5.65 KB
一键复制 编辑 原始数据 按行查看 历史
mojie126@foxmail.com 提交于 2014-11-12 16:16 . HDCN-PT初始化
<?php
/*
此段代码只适用于MTPT或包含有jQuery库的NexusPHP站点
*/
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
require_once(get_langfile_path());
if (get_user_class() < UC_SYSOP)
permissiondenied();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['sure']) {
set_time_limit(0);
sql_query("UPDATE attachments SET inuse = 0") or sqlerr(__FILE__, __LINE__); //全部标记未使用
$res = sql_query("SELECT descr FROM torrents WHERE `descr` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__); //对种子文章进行处理
$atts = array();
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT body FROM posts WHERE `body` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT descr FROM offers WHERE `descr` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT text FROM comments WHERE `text` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT body FROM fun WHERE `body` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT msg FROM messages WHERE `msg` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT msg FROM staffmessages WHERE `msg` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
$res = sql_query("SELECT signature FROM users WHERE `signature` LIKE '%attach%'") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
$attstemp = array();
preg_match_all('/\[attach\](.*?)\[\/attach\]/', $row[0], $attstemp);
$atts = array_merge($atts, $attstemp[1]);
}
sql_query("UPDATE attachments SET inuse = 1 WHERE dlkey = '" . join("' OR dlkey = '", $atts) . "'") or sqlerr(__FILE__, __LINE__);
$res = sql_query("SELECT COUNT(*), SUM(filesize) AS filesizes FROM attachments WHERE inuse = 0") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_array($res);
$deletecount = $row[0];
$filesizes = mksize($row[1]);
echo "共有" . $deletecount . "个无用附件,总共大小:" . $filesizes;
die;
} elseif ($_POST['suredel']) {
//删除无用图片
$filepath = dirname(__FILE__) . "/attachments/";
$res = sql_query("SELECT location FROM attachments WHERE inuse = 0") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($res)) {
if (file_exists($filepath . $row['location'])) {
@unlink($filepath . $row['location']);
}
if (file_exists($filepath . $row['location'] . ".thumb.jpg")) {
@unlink($filepath . $row['location'] . ".thumb.jpg");
}
}
sql_query("DELETE FROM attachments WHERE inuse = 0") or sqlerr(__FILE__, __LINE__);
//删除无用字幕
$filepath = dirname(__FILE__) . "/subs/";
$res = sql_query("SELECT torrent_id FROM subs WHERE torrent_id NOT IN (SELECT id FROM torrents)");
while ($row = mysql_fetch_array($res)) {
if (file_exists($filepath . $row['torrent_id'])) {
removeDir($filepath . $row['torrent_id']);
}
}
sql_query("DELETE FROM subs WHERE torrent_id NOT IN (SELECT id FROM torrents)");
}
}
$res = sql_query("SELECT COUNT(*),SUM(filesize) AS filesizes FROM attachments") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_array($res);
$deletecount = $row[0];
$filesizes = mksize($row[1]);
stdhead($lang_deletedisabled['head_delete_diasabled']);
begin_main_frame();
?>
<h1 align="center"><?php echo $lang_deletedisabled['text_delete_diasabled'] ?></h1>
<script type="text/javascript">
$(document).ready(function () {
$("#check").click(function () {
$("#check").val("检测中..");
$.post("delattachments.php", {sure: 1}, function (result) {
$("#check").val("检测完成");
$("#delatt").removeAttr("disabled");
$("#comp").html(result);
});
});
});
</script>
<div style="text-align: center;"><?php echo $lang_deletedisabled['text_delete_check_note'] ?></div>
<div style="text-align: center; margin-top: 10px;">
<input id="check" type="submit" value="<?php echo $lang_deletedisabled['submit_delete_check'] ?>" />
</div>
<p></p>
<div style="text-align: center;"><?php echo $lang_deletedisabled['text_delete_disabled_note'] ?></div>
<div style="text-align: center; margin-top: 10px;">
<form method="post" action="">
<input type="hidden" name="suredel" value="1" />
<input id="delatt" type="submit" disabled="disabled" value="<?php echo $lang_deletedisabled['submit_delete_all_disabled_users'] ?>" />
<?php echo "<br /><span id=\"comp\">共有" . $deletecount . "个附件,总共大小:" . $filesizes . "</span>" ?>
</form>
</div>
<?php
end_main_frame();
stdfoot();
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/mojie126/HDCN-PT.git
git@gitee.com:mojie126/HDCN-PT.git
mojie126
HDCN-PT
HDCN-PT
master

搜索帮助