admincp_attach.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: admincp_attach.php 31441 2012-08-28 07:46:04Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. $searchsubmit = $_GET['searchsubmit'];
  13. if(!submitcheck('deletesubmit')) {
  14. require_once libfile('function/forumlist');
  15. $anchor = isset($_GET['anchor']) ? $_GET['anchor'] : '';
  16. $anchor = in_array($anchor, array('search', 'admin')) ? $anchor : 'search';
  17. shownav('topic', 'nav_attaches'.($operation ? '_'.$operation : ''));
  18. showsubmenusteps('nav_attaches'.($operation ? '_'.$operation : ''), array(
  19. array('search', !$searchsubmit),
  20. array('admin', $searchsubmit),
  21. ));
  22. showtips('attach_tips', 'attach_tips', $searchsubmit);
  23. showtagheader('div', 'search', !$searchsubmit);
  24. showformheader('attach'.($operation ? '&operation='.$operation : ''));
  25. showtableheader();
  26. showsetting('attach_nomatched', 'nomatched', 0, 'radio');
  27. if($operation != 'group') {
  28. showsetting('attach_forum', '', '', '<select name="inforum"><option value="all">&nbsp;&nbsp;>'.cplang('all').'</option><option value="">&nbsp;</option>'.forumselect(FALSE, 0, 0, TRUE).'</select>');
  29. }
  30. showsetting('attach_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>$lang[perpage_20]</option><option value='50'>$lang[perpage_50]</option><option value='100'>$lang[perpage_100]</option></select>");
  31. showsetting('attach_sizerange', array('sizeless', 'sizemore'), array('', ''), 'range');
  32. showsetting('attach_dlcountrange', array('dlcountless', 'dlcountmore'), array('', ''), 'range');
  33. showsetting('attach_daysold', 'daysold', '', 'text');
  34. showsetting('filename', 'filename', '', 'text');
  35. showsetting('attach_keyword', 'keywords', '', 'text');
  36. showsetting('attach_author', 'author', '', 'text');
  37. showsubmit('searchsubmit', 'search');
  38. showtablefooter();
  39. showformfooter();
  40. showtagfooter('div');
  41. if(submitcheck('searchsubmit')) {
  42. require_once libfile('function/attachment');
  43. $operation == 'group' && $_GET['inforum'] = 'isgroup';
  44. $inforum = $_GET['inforum'] != 'all' && $_GET['inforum'] != 'isgroup' ? intval($_GET['inforum']) : $_GET['inforum'];
  45. $authorid = $_GET['author'] ? C::t('common_member')->fetch_uid_by_username($_GET['author']) : 0;
  46. $authorid = $_GET['author'] && !$authorid ? C::t('common_member_archive')->fetch_uid_by_username($_GET['author']) : 0;
  47. $attachments = '';
  48. $attachuids = $attachusers = array();
  49. $_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
  50. $perpage = ($_GET['pp'] ? $_GET['pp'] : $_GET['perpage']) / 10;
  51. $attachmentcount = 0;
  52. for($attachi = 0;$attachi < 10;$attachi++) {
  53. $attachmentarray = array();
  54. $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);
  55. $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);
  56. foreach($query as $attachment) {
  57. $attachuids[$attachment['uid']] = $attachment['uid'];
  58. $attachmentarray[] = $attachment;
  59. }
  60. $attachusers += C::t('common_member')->fetch_all($attachuids);
  61. foreach($attachmentarray as $attachment) {
  62. if(!$attachment['remote']) {
  63. $matched = file_exists($_G['setting']['attachdir'].'/forum/'.$attachment['attachment']) ? '' : cplang('attach_lost');
  64. $attachment['url'] = $_G['setting']['attachurl'].'forum/';
  65. } else {
  66. @set_time_limit(0);
  67. if(@fclose(@fopen($_G['setting']['ftp']['attachurl'].'forum/'.$attachment['attachment'], 'r'))) {
  68. $matched = '';
  69. } else {
  70. $matched = cplang('attach_lost');
  71. }
  72. $attachment['url'] = $_G['setting']['ftp']['attachurl'].'forum/';
  73. }
  74. $attachsize = sizecount($attachment['filesize']);
  75. if(!$_GET['nomatched'] || ($_GET['nomatched'] && $matched)) {
  76. $attachment['url'] = trim($attachment['url'], '/');
  77. $attachments .= showtablerow('', array('class="td25"', 'title="'.$attachment['description'].'" class="td21"'), array(
  78. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$attachment[aid]\" />",
  79. $attachment['remote'] ? "<span class=\"diffcolor3\">$attachment[filename]" : $attachment['filename'],
  80. $attachusers[$attachment['uid']]['username'],
  81. "<a href=\"forum.php?mod=viewthread&tid=$attachment[tid]\" target=\"_blank\">".cutstr($attachment['subject'], 20)."</a>",
  82. $attachsize,
  83. $attachment['downloads'],
  84. $matched ? "<em class=\"error\">$matched<em>" : "<a href=\"forum.php?mod=attachment&aid=".aidencode($attachment['aid'])."&noupdate=yes\" target=\"_blank\" class=\"act nomargin\">$lang[download]</a>"
  85. ), TRUE);
  86. }
  87. }
  88. }
  89. $multipage = '<div class="cuspages right"><div class="pg">'.
  90. ($page > 1 ? '<a href="javascript:page('.($page-1).')" class="nxt">&lsaquo;&lsaquo;</a>' : '').
  91. '<a href="javascript:page('.($page+1).')" class="nxt">&rsaquo;&rsaquo;</a>'.
  92. '</div></div>';
  93. echo <<<EOT
  94. <script type="text/JavaScript">
  95. function page(number) {
  96. $('attachmentforum').page.value=number;
  97. $('attachmentforum').searchsubmit.click();
  98. }
  99. </script>
  100. EOT;
  101. showtagheader('div', 'admin', $searchsubmit);
  102. showformheader('attach'.($operation ? '&operation='.$operation : ''), '', 'attachmentforum');
  103. showhiddenfields(array(
  104. 'page' => $page,
  105. 'nomatched' => $_GET['nomatched'],
  106. 'inforum' => $_GET['inforum'],
  107. 'sizeless' => $_GET['sizeless'],
  108. 'sizemore' => $_GET['sizemore'],
  109. 'dlcountless' => $_GET['dlcountless'],
  110. 'dlcountmore' => $_GET['dlcountmore'],
  111. 'daysold' => $_GET['daysold'],
  112. 'filename' => $_GET['filename'],
  113. 'keywords' => $_GET['keywords'],
  114. 'author' => $_GET['author'],
  115. 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']
  116. ));
  117. echo '<input type="submit" name="searchsubmit" value="'.cplang('submit').'" class="btn" style="display: none" />';
  118. showformfooter();
  119. showformheader('attach&frame=no'.($operation ? '&operation='.$operation : ''), 'target="attachmentframe"');
  120. showtableheader();
  121. showsubtitle(array('', 'filename', 'author', 'attach_thread', 'size', 'attach_downloadnums', ''));
  122. echo $attachments;
  123. showsubmit('deletesubmit', 'submit', 'del', '<a href="###" onclick="$(\'admin\').style.display=\'none\';$(\'search\').style.display=\'\';$(\'attachmentforum\').pp.value=\'\';$(\'attachmentforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', $multipage);
  124. showtablefooter();
  125. showformfooter();
  126. echo '<iframe name="attachmentframe" style="display:none"></iframe>';
  127. showtagfooter('div');
  128. }
  129. } else {
  130. if($_GET['delete']) {
  131. $tids = $pids = array();
  132. for($attachi = 0;$attachi < 10;$attachi++) {
  133. foreach(C::t('forum_attachment_n')->fetch_all($attachi, $_GET['delete']) as $attach) {
  134. dunlink($attach);
  135. $tids[$attach['tid']] = $attach['tid'];
  136. $pids[$attach['pid']] = $attach['pid'];
  137. }
  138. C::t('forum_attachment_n')->delete($attachi, $_GET['delete']);
  139. $attachtids = array();
  140. foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachi, 'tid', $tids) as $attach) {
  141. unset($tids[$attach['tid']]);
  142. }
  143. if($tids) {
  144. C::t('forum_thread')->update($tids, array('attachment' => 0));
  145. }
  146. $attachpids = array();
  147. foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachi, 'pid', $pids) as $attach) {
  148. $attachpids[$attach['pid']] = $attach['pid'];
  149. }
  150. }
  151. if($attachpids) {
  152. $pids = array_diff($pids, $attachpids);
  153. }
  154. loadcache('posttableids');
  155. $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
  156. foreach($posttableids as $id) {
  157. C::t('forum_post')->update($id, $pids, array('attachment' => '0'));
  158. }
  159. $cpmsg = cplang('attach_edit_succeed');
  160. } else {
  161. $cpmsg = cplang('attach_edit_invalid');
  162. }
  163. echo "<script type=\"text/JavaScript\">alert('$cpmsg');parent.\$('attachmentforum').searchsubmit.click();</script>";
  164. }
  165. ?>