.$attach['attachmentid']."'");
}
$update=1;
unset($attachs[$key]);
}
}
if($update){
$attachs = $attachs ? addslashes(serialize($attachs)) : '';
$DB->unbuffered_query("UPDATE {$db_prefix}articles SET attachments='$attachs' WHERE articleid='".$aids['articleid']."'");
}
} else{
$count++;
$DB->unbuffered_query("UPDATE {$db_prefix}articles SET attachments='' WHERE articleid='".$aids['articleid']."'");
}
}
// 鏇存柊棣栭〉鏄剧ず鐨勯檮浠舵暟
$attachment_count = $DB->num_rows($DB->query("SELECT att.attachmentid, art.visible FROM {$db_prefix}attachments att LEFT JOIN {$db_prefix}articles art ON (art.articleid = att.articleid) WHERE art.visible='1'"));
$DB->unbuffered_query("UPDATE {$db_prefix}statistics SET attachment_count='$attachment_count'");
redirect('鎴愬姛淇'.$count.'涓檮浠惰褰?, 'admincp.php?go=attachment&action=list');
}
if ($action == 'doclear'){
if (!$start){
$start=0;
$deltotal=0;
}
$num = 0;
$delnum = 0;
!$percount && $percount = 500;
$attachdir = '../'.$base['attachments_dir'];
$dir1 = @opendir($attachdir);
while($file1 = @readdir($dir1)){
if ($file1 != '' && $file1 != '.' && $file1 != 'index.php' && $file1 != '..' && $file1 != 'index.htm'){
if (@is_dir($attachdir.'/'.$file1)){
$dir2 = @opendir($attachdir.'/'.$file1);
while($file2 = @readdir($dir2)){
if (@is_file($attachdir.'/'.$file1.'/'.$file2) && $file2 != '' && $file1 != 'index.php' && $file2 != '.' && $file2 != '..' && $file2 != 'index.htm'){
$num++;
if ($num > $start){
$r = $DB->fetch_one_array("SELECT attachmentid FROM {$db_prefix}attachments WHERE filepath='/$file1/$file2' OR thumb_filepath='/$file1/$file2'");
if(!$r){
$delnum++;
$deltotal++;
@unlink($attachdir.'/'.$file1.'/'.$file2);
}
if ($num-$start >= $percount){
$start = $num-$delnum;
$jumpurl="admincp.php?go=attachment&action=doclear&start=$start&percount=$percount&deltotal=$deltotal";
redirect('姝e湪娓呯悊鍐椾綑闄勪欢锛屽凡缁忓垹闄?'.$deltotal.' 涓檮浠?绋嬪簭灏嗚嚜鍔ㄥ畬鎴愭暣涓繃绋?椤甸潰璺宠浆涓?.',$jumpurl);
}
}
}
}
} elseif (is_file($attachdir.'/'.$file1)){
$num++;
if ($num > $start){
$rt = $DB->fetch_one_array("SELECT attachmentid FROM {$db_prefix}attachments WHERE filepath='/$file1' OR thumb_filepath='/$file1'");
if(!$rt){
$delnum++;
$deltotal++;
@unlink($attachdir.'/'.$file1);
}
if ($num-$start >= $percount){
$start = $num-$delnum;
$jumpurl = "admincp.php?go=attachment&action=doclear&start=$start&percount=$percount&deltotal=$deltotal";
redirect('姝e湪娓呯悊鍐椾綑闄勪欢锛屽凡缁忓垹闄?'.$deltotal.' 涓檮浠?绋嬪簭灏嗚嚜鍔ㄥ畬鎴愭暣涓繃绋?椤甸潰璺宠浆涓?.',$jumpurl);
}
}
}
}
}
redirect('闄勪欢娓呯悊缁撴潫,鍏卞垹闄や簡'.$deltotal.'涓啑浣欓檮浠?', 'admincp.php?go=attachment&action=list');
}
//鎿嶄綔缁撴潫
if (!$action) {
$action = 'list';
}
if ($action == 'list') {
if($page) {
$start_limit = ($page - 1) * 30;
} else {
$start_limit = 0;
$page = 1;
}
$sql = 'WHERE 1';
$subnav = '鍏ㄩ儴闄勪欢';
if ($view == 'image') {
$sql .= " AND (a.filetype LIKE '%image/%')";
$subnav = '鍥剧墖闄勪欢';
} elseif ($view == 'file') {
$
sql .= " AND !(a.filetype LIKE '%image/%')";
$subnav = '闈炲浘鐗囬檮浠?;
}
$articleid = intval($_GET['articleid']);
if ($articleid) {
$article = $DB->fetch_one_array("SELECT title FROM {$db_prefix}articles WHERE articleid='$articleid'");
$subnav = '銆?.$article['title'].'銆嬬殑闄勪欢';
$sql .= " AND a.articleid='$articleid'";
} else {
$warning = '';
$a_dir = '../'.$base['attachments_dir'];
$attachsize = dirsize($a_dir);
$dircount = dircount($a_dir);
$realattachsize = (is_numeric($attachsize)) ? sizecount($attachsize) : '涓嶈';
$stats = $DB->fetch_one_array("SELECT count(*) as count, sum(filesize) as sum FROM {$db_prefix}attachments");
$stats['count'] = ($stats['count'] != 0) ? $stats['count'] : 0;
$stats['sum'] = ($stats['count'] == 0) ? '0 KB' : sizecount($stats['sum']);
if (!@is_dir($a_dir)) {
$warning = ' <font color="#FF0000"><strong>(鏂囦欢澶规棤鏁?璇烽噸鏂拌瀹氫笂浼犳枃浠跺す!)</strong></font>';
}
}
$view = in_array($_GET['view'], array('image', 'file')) ? $_GET['view'] : '';
$tatol = $DB->num_rows($DB->query("SELECT attachmentid FROM {$db_prefix}attachments a ".$sql));
$Paginationpage = Paginat