'.forumselect(FALSE, 0, 0, TRUE).'');
}
showsetting('attach_search_perpage', '', $_GET['perpage'], "");
showsetting('attach_sizerange', array('sizeless', 'sizemore'), array('', ''), 'range');
showsetting('attach_dlcountrange', array('dlcountless', 'dlcountmore'), array('', ''), 'range');
showsetting('attach_daysold', 'daysold', '', 'text');
showsetting('filename', 'filename', '', 'text');
showsetting('attach_keyword', 'keywords', '', 'text');
showsetting('attach_author', 'author', '', 'text');
showsubmit('searchsubmit', 'search');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
require_once libfile('function/attachment');
$operation == 'group' && $_GET['inforum'] = 'isgroup';
$inforum = $_GET['inforum'] != 'all' && $_GET['inforum'] != 'isgroup' ? intval($_GET['inforum']) : $_GET['inforum'];
$authorid = $_GET['author'] ? C::t('common_member')->fetch_uid_by_username($_GET['author']) : 0;
$authorid = $_GET['author'] && !$authorid ? C::t('common_member_archive')->fetch_uid_by_username($_GET['author']) : 0;
$attachments = '';
$attachuids = $attachusers = array();
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = ($_GET['pp'] ? $_GET['pp'] : $_GET['perpage']) / 10;
$attachmentcount = 0;
for($attachi = 0;$attachi < 10;$attachi++) {
$attachmentarray = array();
$attachmentcount += C::t('forum_attachment')->fetch_all_for_manage($attachi, $inforum, $authorid, $_GET['filename'], $_GET['keywords'], $_GET['sizeless'], $_GET['sizemore'], $_GET['dlcountless'], $_GET['dlcountmore'], $_GET['daysold'], 1);
$query = C::t('forum_attachment')->fetch_all_for_manage($attachi, $inforum, $authorid, $_GET['filename'], $_GET['keywords'], $_GET['sizeless'], $_GET['sizemore'], $_GET['dlcountless'], $_GET['dlcountmore'], $_GET['daysold'], 0, (($page - 1) * $perpage), $perpage);
foreach($query as $attachment) {
$attachuids[$attachment['uid']] = $attachment['uid'];
$attachmentarray[] = $attachment;
}
$attachusers += C::t('common_member')->fetch_all($attachuids);
foreach($attachmentarray as $attachment) {
if(!$attachment['remote']) {
$matched = file_exists($_G['setting']['attachdir'].'/forum/'.$attachment['attachment']) ? '' : cplang('attach_lost');
$attachment['url'] = $_G['setting']['attachurl'].'forum/';
} else {
@set_time_limit(0);
if(@fclose(@fopen($_G['setting']['ftp']['attachurl'].'forum/'.$attachment['attachment'], 'r'))) {
$matched = '';
} else {
$matched = cplang('attach_lost');
}
$attachment['url'] = $_G['setting']['ftp']['attachurl'].'forum/';
}
$attachsize = sizecount($attachment['filesize']);
if(!$_GET['nomatched'] || ($_GET['nomatched'] && $matched)) {
$attachment['url'] = trim($attachment['url'], '/');
$attachments .= showtablerow('', array('class="td25"', 'title="'.$attachment['description'].'" class="td21"'), array(
"",
$attachment['remote'] ? "$attachment[filename]" : $attachment['filename'],
$attachusers[$attachment['uid']]['username'],
"".cutstr($attachment['subject'], 20)."",
$attachsize,
$attachment['downloads'],
$matched ? "$matched" : "$lang[download]"
), TRUE);
}
}
}
$multipage = ''.
($page > 1 ? '
‹‹' : '').
'
››'.
'
';
echo <<
function page(number) {
$('attachmentforum').page.value=number;
$('attachmentforum').searchsubmit.click();
}
EOT;
showtagheader('div', 'admin', $searchsubmit);
showformheader('attach'.($operation ? '&operation='.$operation : ''), '', 'attachmentforum');
showhiddenfields(array(
'page' => $page,
'nomatched' => $_GET['nomatched'],
'inforum' => $_GET['inforum'],
'sizeless' => $_GET['sizeless'],
'sizemore' => $_GET['sizemore'],
'dlcountless' => $_GET['dlcountless'],
'dlcountmore' => $_GET['dlcountmore'],
'daysold' => $_GET['daysold'],
'filename' => $_GET['filename'],
'keywords' => $_GET['keywords'],
'author' => $_GET['author'],
'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']
));
echo '';
showformfooter();
showformheader('attach&frame=no'.($operation ? '&operation='.$operation : ''), 'target="attachmentframe"');
showtableheader();
showsubtitle(array('', 'filename', 'author', 'attach_thread', 'size', 'attach_downloadnums', ''));
echo $attachments;
showsubmit('deletesubmit', 'submit', 'del', ''.cplang('research').'', $multipage);
showtablefooter();
showformfooter();
echo '';
showtagfooter('div');
}
} else {
if($_GET['delete']) {
$tids = $pids = array();
for($attachi = 0;$attachi < 10;$attachi++) {
foreach(C::t('forum_attachment_n')->fetch_all($attachi, $_GET['delete']) as $attach) {
dunlink($attach);
$tids[$attach['tid']] = $attach['tid'];
$pids[$attach['pid']] = $attach['pid'];
}
C::t('forum_attachment_n')->delete($attachi, $_GET['delete']);
$attachtids = array();
foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachi, 'tid', $tids) as $attach) {
unset($tids[$attach['tid']]);
}
if($tids) {
C::t('forum_thread')->update($tids, array('attachment' => 0));
}
$attachpids = array();
foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachi, 'pid', $pids) as $attach) {
$attachpids[$attach['pid']] = $attach['pid'];
}
}
if($attachpids) {
$pids = array_diff($pids, $attachpids);
}
loadcache('posttableids');
$posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
foreach($posttableids as $id) {
C::t('forum_post')->update($id, $pids, array('attachment' => '0'));
}
$cpmsg = cplang('attach_edit_succeed');
} else {
$cpmsg = cplang('attach_edit_invalid');
}
echo "";
}
?>