admincp_pic.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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_pic.php 28299 2012-02-27 08:48:36Z svn_project_zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. $detail = $_GET['detail'];
  12. $albumid = $_GET['albumid'];
  13. $users = $_GET['users'];
  14. $picid = $_GET['picid'];
  15. $postip = $_GET['postip'];
  16. $hot1 = $_GET['hot1'];
  17. $hot2 = $_GET['hot2'];
  18. $starttime = $_GET['starttime'];
  19. $endtime = $_GET['endtime'];
  20. $searchsubmit = $_GET['searchsubmit'];
  21. $picids = $_GET['picids'];
  22. $title = $_GET['title'];
  23. $orderby = $_GET['orderby'];
  24. $ordersc = $_GET['ordersc'];
  25. $fromumanage = $_GET['fromumanage'] ? 1 : 0;
  26. $muticondition = '';
  27. $muticondition .= $albumid ? '&albumid='.$albumid : '';
  28. $muticondition .= $users ? '&users='.$users : '';
  29. $muticondition .= $picid ? '&picid='.$picid : '';
  30. $muticondition .= $postip ? '&postip='.$postip : '';
  31. $muticondition .= $hot1 ? '&hot1='.$hot1 : '';
  32. $muticondition .= $hot2 ? '&hot2='.$hot2 : '';
  33. $muticondition .= $starttime ? '&starttime='.$starttime : '';
  34. $muticondition .= $endtime ? '&endtime='.$endtime : '';
  35. $muticondition .= $title ? '&title='.$title : '';
  36. $muticondition .= $orderby ? '&orderby='.$orderby : '';
  37. $muticondition .= $ordersc ? '&ordersc='.$ordersc : '';
  38. $muticondition .= $fromumanage ? '&fromumanage='.$fromumanage : '';
  39. $muticondition .= $searchsubmit ? '&searchsubmit='.$searchsubmit : '';
  40. $muticondition .= $_GET['search'] ? '&search='.$_GET['search'] : '';
  41. $muticondition .= $detail ? '&detail='.$detail : '';
  42. cpheader();
  43. if(!submitcheck('picsubmit')) {
  44. if(empty($_GET['search'])) {
  45. $newlist = 1;
  46. $detail = 1;
  47. }
  48. if($fromumanage) {
  49. $starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
  50. $endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
  51. } else {
  52. $starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
  53. $endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
  54. }
  55. shownav('topic', 'nav_pic');
  56. showsubmenu('nav_pic', array(
  57. array('newlist', 'pic', !empty($newlist)),
  58. array('search', 'pic&search=true', empty($newlist)),
  59. ));
  60. empty($newlist) && showsubmenusteps('', array(
  61. array('pic_search', !$searchsubmit),
  62. array('nav_pic', $searchsubmit)
  63. ));
  64. if($muticondition) {
  65. showtips('pic_tips');
  66. }
  67. echo <<<EOT
  68. <script type="text/javascript" src="static/js/calendar.js"></script>
  69. <script type="text/JavaScript">
  70. function page(number) {
  71. $('picforum').page.value=number;
  72. $('picforum').searchsubmit.click();
  73. }
  74. </script>
  75. EOT;
  76. showtagheader('div', 'searchposts', !$searchsubmit && empty($newlist));
  77. showformheader("pic".(!empty($_GET['search']) ? '&search=true' : ''), '', 'picforum');
  78. showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
  79. showtableheader();
  80. showsetting('pic_search_detail', 'detail', $detail, 'radio');
  81. showsetting('pic_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>");
  82. showsetting('resultsort', '', $orderby, "<select name='orderby'><option value=''>$lang[defaultsort]</option><option value='dateline'>$lang[pic_search_createtime]</option><option value='size'>$lang[pic_size]</option><option value='hot'>$lang[pic_search_hot]</option></select> ");
  83. showsetting('', '', $ordersc, "<select name='ordersc'><option value='desc'>$lang[orderdesc]</option><option value='asc'>$lang[orderasc]</option></select>", '', 0, '', '', '', true);
  84. showsetting('pic_search_albumid', 'albumid', $albumid, 'text');
  85. showsetting('pic_search_user', 'users', $users, 'text');
  86. showsetting('pic_search_picid', 'picid', $picid, 'text');
  87. showsetting('pic_search_title', 'title', $title, 'text');
  88. showsetting('pic_search_ip', 'postip', $postip, 'text');
  89. showsetting('pic_search_hot', array('hot1', 'hot2'), array('', ''), 'range');
  90. showsetting('pic_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
  91. echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
  92. showsubmit('searchsubmit');
  93. showtablefooter();
  94. showformfooter();
  95. showtagfooter('div');
  96. } else {
  97. $picids = authcode($picids, 'DECODE');
  98. $picidsadd = $picids ? explode(',', $picids) : $_GET['delete'];
  99. include_once libfile('function/delete');
  100. $deletecount = count(deletepics($picidsadd));
  101. $cpmsg = cplang('pic_succeed', array('deletecount' => $deletecount));
  102. ?>
  103. <script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('picforum').searchsubmit.click();</script>
  104. <?php
  105. }
  106. if(submitcheck('searchsubmit', 1) || $newlist) {
  107. $picids = $piccount = '0';
  108. $sql = $error = '';
  109. $users = trim($users);
  110. if($starttime != '') {
  111. $starttime = strtotime($starttime);
  112. $sql .= ' AND p.'.DB::field('dateline', $starttime, '>');
  113. }
  114. if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
  115. if($endtime != '') {
  116. $endtime = strtotime($endtime);
  117. $sql .= ' AND p.'.DB::field('dateline', $endtime, '<');
  118. }
  119. } else {
  120. $endtime = TIMESTAMP;
  121. }
  122. if($picid !='') {
  123. $picids = '-1';
  124. $picidsarr = array('-1');
  125. $query = C::t('home_pic')->fetch_all(explode(',', str_replace(' ', '', $picid)));
  126. foreach($query as $arr) {
  127. $picids .=",$arr[picid]";
  128. $picidsarr[] = $arr['picid'];
  129. }
  130. $sql .= ' AND p.'.DB::field('picid', $picidsarr);
  131. }
  132. if($albumid !='') {
  133. $albumids = '-1';
  134. $albumidsarr = array('-1');
  135. $query = C::t('home_album')->fetch_all(explode(',', $albumid));
  136. foreach($query as $arr) {
  137. $albumids .=",$arr[albumid]";
  138. $albumidsarr[] = $arr['albumid'];
  139. }
  140. $sql .= ' AND p.'.DB::field('albumid', $albumidsarr);
  141. }
  142. if($users != '') {
  143. $uids = '-1';
  144. $uidsarr = array('-1');
  145. $query = C::t('home_album')->fetch_uid_by_username(explode(',', $users));
  146. foreach($query as $arr) {
  147. $uids .= ",$arr[uid]";
  148. $uidsarr[] = $arr['uid'];
  149. }
  150. $sql .= ' AND p.'.DB::field('uid', $uidsarr);
  151. }
  152. if($postip != '') {
  153. $sql .= ' AND p.'.DB::field('postip', str_replace('*', '%', $postip), 'like');
  154. }
  155. $sql .= $hot1 ? ' AND p.'.DB::field('hot', $hot1, '>=') : '';
  156. $sql .= $hot2 ? ' AND p.'.DB::field('hot', $hot2, '<=') : '';
  157. $sql .= $title ? ' AND p.'.DB::field('title', '%'.$title.'%', 'like') : '';
  158. $orderby = $orderby ? $orderby : 'dateline';
  159. $ordersc = $ordersc ? "$ordersc" : 'DESC';
  160. if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
  161. $error = 'pic_mod_range_illegal';
  162. }
  163. if(!$error) {
  164. if($detail) {
  165. $_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
  166. $perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
  167. $query = C::t('home_pic')->fetch_all_by_sql('1 '.$sql, 'p.'.DB::order($orderby, $ordersc), (($page - 1) * $perpage), $perpage);
  168. $pics = '';
  169. include_once libfile('function/home');
  170. foreach($query as $pic) {
  171. $pic['dateline'] = dgmdate($pic['dateline']);
  172. $pic['pic'] = pic_get($pic['filepath'], 'album', $pic['thumb'], $pic['remote']);
  173. $pic['albumname'] = empty($pic['albumname']) && empty($pic['albumid']) ? $lang['album_default'] : $pic['albumname'];
  174. $pic['albumid'] = empty($pic['albumid']) ? -1 : $pic['albumid'];
  175. $pics .= showtablerow('', '', array(
  176. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$pic[picid]\" />",
  177. "<a href='home.php?mod=space&uid=$pic[uid]&do=album&picid=$pic[picid]' target='_blank'><img src='$pic[pic]'/></a>",
  178. $pic['size'],
  179. "<a href='home.php?mod=space&uid=$pic[uid]&do=album&id=$pic[albumid]' target='_blank'>$pic[albumname]</a>",
  180. "<a href=\"home.php?mod=space&uid=$pic[uid]\" target=\"_blank\">".$pic['username']."</a>",
  181. $pic['dateline'], "<a href=\"".ADMINSCRIPT."?action=comment&detail=1&searchsubmit=1&idtype=picid&id=$pic[picid]\">".$lang['pic_comment']."</a>"
  182. ), TRUE);
  183. }
  184. $piccount = C::t('home_pic')->fetch_all_by_sql('1 '.$sql, '', 0, 0, 1);
  185. $multi = multi($piccount, $perpage, $page, ADMINSCRIPT."?action=pic$muticondition");
  186. } else {
  187. $piccount = 0;
  188. $query = C::t('home_pic')->fetch_all_by_sql('1 '.$sql, '', 0, 0, 0, 0);
  189. foreach($query as $pic) {
  190. $picids .= ','.$pic['picid'];
  191. $piccount++;
  192. }
  193. $multi = '';
  194. }
  195. if(!$piccount) {
  196. $error = 'pic_post_nonexistence';
  197. }
  198. }
  199. showtagheader('div', 'postlist', $searchsubmit || $newlist);
  200. showformheader('pic&frame=no', 'target="picframe"');
  201. showhiddenfields(array('picids' => authcode($picids, 'ENCODE')));
  202. if(!$muticondition) {
  203. showtableheader(cplang('pic_new_result').' '.$piccount, 'fixpadding');
  204. } else {
  205. showtableheader(cplang('pic_result').' '.$piccount.(empty($newlist) ? ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'picforum\').pp.value=\'\';$(\'picforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>' : ''), 'fixpadding');
  206. }
  207. if($error) {
  208. echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
  209. } else {
  210. if($detail) {
  211. showsubtitle(array('', 'albumpic', 'pic_size', 'albumname', 'author', 'time', 'pic_comment'));
  212. echo $pics;
  213. }
  214. }
  215. showsubmit('picsubmit', 'delete', $detail ? 'del' : '', '', $multi);
  216. showtablefooter();
  217. showformfooter();
  218. echo '<iframe name="picframe" style="display:none"></iframe>';
  219. showtagfooter('div');
  220. }
  221. ?>