mobile.class.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. /**
  3. * [超级活动(xj_event.{modulename})] (C)2012-2099 Powered by 逍遥工作室.
  4. * Version: 1.0
  5. * Date: 2012-9-15 10:27
  6. */
  7. if (!defined('IN_DISCUZ')) {
  8. exit('Access Denied');
  9. }
  10. class mobileplugin_xj_event {
  11. function global_header(){
  12. if($_GET['mod'] == 'post' && $_GET['specialextra'] == 'xj_event'){
  13. dheader('location: plugin.php?id=xj_event:wsqcenter&mod=event_pub');
  14. }
  15. }
  16. function viewthread_posttop_mobile(){
  17. global $_G;
  18. $return = array();
  19. $tid = intval($_G['tid']);
  20. $num = DB::result_first("SELECT COUNT(*) FROM ".DB::table('xj_eventthread')." WHERE tid=".$tid);
  21. if($num>0){
  22. $items = DB::fetch_first("SELECT A.eid,B.setting,C.tid,C.subject FROM ".DB::table('xj_eventthread')." A,".DB::table('xj_event')." B,".DB::table('forum_thread')." C WHERE A.tid=".$_G['tid']." and A.eid=B.eid and B.tid=C.tid");
  23. $nowtime = $_G["timestamp"];
  24. $setting = unserialize($items['setting']);
  25. $eid=$items['eid'];
  26. $tid=intval($_G['tid']);
  27. $return[0] = '<div style=" line-height:30px;">'.lang('plugin/xj_event', 'btlzyhd').':<img src="static/image/common/activitysmall.gif" align="absmiddle"> <a href="forum.php?mod=viewthread&tid='.$items['tid'].'" style=" font-weight:bold; color:#ff4200;">'.$items['subject'].'</a>';
  28. if($setting[vote][openvote]==1 && $nowtime>$setting['vote']['votestarttime'] && $nowtime<$setting['vote']['voteendtime']){
  29. $return[0] = $return[0].'<div style="margin:30px; text-align:center;"><a href="plugin.php?id=xj_event:event_vote&tid='.$tid.'&eid='.$eid.'&formhash='.$_G['formhash'].'" onclick="ajaxmenu(this, 3000, 0, 0, \'43\');return false;" style=" display:inline-block; width:186px; height:81px; background: url(source/plugin/xj_event/images/tp_btn.png); line-height:22px;"></a></div>';
  30. }
  31. $return[0] = $return[0].'</div>';
  32. }
  33. return $return;
  34. }
  35. function post_bottom_mobile(){
  36. global $_G;
  37. if($_GET['specialextra']!='xj_event'){
  38. if($_GET['action']!='albumphoto'){
  39. if($_GET['action']=='edit'){
  40. $eid = DB::result_first("SELECT eid FROM ".DB::table('xj_eventthread')." WHERE tid=".$_GET['tid']);
  41. }
  42. $i = 0;
  43. $uid = $_G['uid'];
  44. $nowtime = time();
  45. $return = '<div style="clear:both; line-height:30px; padding-left:10px; padding-bottom:10px;">'.lang('plugin/xj_event', 'xghd').': <select name="eid" id="select"><option value=\"'.$eid.'\">'.lang('plugin/xj_event', 'qxzhd').'</option>';
  46. $query = DB::query("SELECT A.eid,A.setting,C.subject FROM ".DB::table('xj_event')." A,".DB::table('xj_eventapply')." B,".DB::table('forum_thread')." C WHERE C.tid=A.tid and A.tid=B.tid and B.uid={$uid} and B.verify=1 and A.postclass=1 and (A.endtime+2592000)>$nowtime");
  47. $return = $return."<optgroup label='".lang('plugin/xj_event', 'xxhd')."'>";
  48. while($value = DB::fetch($query)){
  49. $setting = unserialize($value['setting']);
  50. if($setting['eventzy_enable']){
  51. if($setting['eventzy_fid']==$_G['fid'] || !$setting['eventzy_fid']){
  52. $return = $return."<option value=\"$value[eid]\" ".($value['eid']==$_GET['eid']?"selected":"").">$value[subject]</option>";
  53. $i++;
  54. }
  55. }
  56. }
  57. $query = DB::query("SELECT A.eid,A.setting,C.subject FROM ".DB::table('xj_event')." A,".DB::table('xj_eventapply')." B,".DB::table('forum_thread')." C WHERE C.tid=A.tid and A.tid=B.tid and B.uid={$uid} and B.verify=1 and A.postclass=2 and A.endtime>$nowtime");
  58. $return = $return."<optgroup label='".lang('plugin/xj_event', 'xshd')."'>";
  59. while($value = DB::fetch($query)){
  60. $setting = unserialize($value['setting']);
  61. if($setting['eventzy_enable']){
  62. if($setting['eventzy_fid']==$_G['fid'] || !$setting['eventzy_fid']){
  63. $return = $return."<option value=\"$value[eid]\" ".($value['eid']==$_GET['eid']?"selected":"").">$value[subject]</option>";
  64. $i++;
  65. }
  66. }
  67. }
  68. $return .= "</select> <span style='color:#D0D0D0;'>".lang('plugin/xj_event', 'xzncjdhdfbhdzy')."</span></div>";
  69. if($i==0){ //判断是否有加参正在进行中的活动,没有就不调用
  70. $return = '';
  71. }
  72. }
  73. }
  74. return $return;
  75. }
  76. }
  77. class mobileplugin_xj_event_forum extends mobileplugin_xj_event {
  78. function post_xj_event_reply_output($a) {
  79. global $_G,$postinfo;
  80. if($_GET['action']=='reply'){
  81. $postinfo['message'] = '';
  82. }
  83. }
  84. function post_xj_event_message($a) {
  85. global $_G;
  86. if($a['param']['0'] == 'post_newthread_succeed' || $a['param']['0'] == 'post_newthread_mod_succeed') {
  87. $tid = $a['param'][2]['tid'];
  88. if($_GET['eid']>0){
  89. $sort = intval($_GET['et_sort']);
  90. $eid = intval($_GET['eid']);
  91. $fid = intval($_G['fid']);
  92. $aid = DB::result_first("SELECT aid FROM ".DB::table('forum_attachment')." WHERE tid=$tid");
  93. //生成缩略图
  94. $imgtype = 1;
  95. $attach = array_keys($_G['gp_attachnew']);
  96. foreach($_G['gp_attachnew'] as $key => $value){
  97. if(count($value) == 1){
  98. $aid = $key;
  99. break;
  100. }
  101. }
  102. $basedir = !$_G['setting']['attachurl'] ? ('data/attachment/') : $_G['setting']['attachurl'];
  103. $coverdir = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/';
  104. if($aid){ //生成缩略图
  105. if(mbeventsetthreadcover($a['param'][2]['pid'],$a['param'][2]['tid'],$aid,0,'',$imgtype,$fid)){
  106. $coverurl = $basedir.'forum/'.$coverdir.$tid.'-event.jpg';
  107. }
  108. }else{
  109. preg_match("/\[img(.*)\](.+?)\[\/img\]/is",$_G['gp_message'],$match);
  110. if(mbeventsetthreadcover($a['param'][2]['pid'],$a['param'][2]['tid'],0,0,$match[2],$imgtype,$fid)){
  111. $coverurl = $basedir.'forum/'.$coverdir.$tid.'-event.jpg';
  112. }
  113. }
  114. DB::query("INSERT INTO ".DB::table('xj_eventthread')." (eid,tid,fid,coverurl,sort) VALUES ('$eid','$tid','$fid','$coverurl','$sort')");
  115. }
  116. }
  117. if($a['param']['0'] =='post_edit_succeed'){
  118. $tid = $a['param'][2]['tid'];
  119. if($_GET['eid']>0){
  120. //获取此贴是否已关联其它活动
  121. $num = DB::result_first("SELECT COUNT(*) FROM ".DB::table('xj_eventthread')." WHERE tid='$tid'");
  122. if($num>0){
  123. $eid = intval($_GET['eid']);
  124. DB::query("UPDATE ".DB::table('xj_eventthread')." SET eid='$eid' WHERE tid = '$tid'");
  125. }else{
  126. $sort = intval($_GET['et_sort']);
  127. $eid = intval($_GET['eid']);
  128. $fid = intval($_G['fid']);
  129. //生成缩略图
  130. $imgtype = 1;
  131. $attach = array_keys($_G['gp_attachnew']);
  132. foreach($_G['gp_attachnew'] as $key => $value){
  133. if(count($value) == 1){
  134. $aid = $key;
  135. break;
  136. }
  137. }
  138. $basedir = !$_G['setting']['attachurl'] ? ('data/attachment/') : $_G['setting']['attachurl'];
  139. $coverdir = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/';
  140. if($aid){ //生成缩略图
  141. if(mbeventsetthreadcover($a['param'][2]['pid'],$a['param'][2]['tid'],$aid,0,'',$imgtype,$fid)){
  142. $coverurl = $basedir.'forum/'.$coverdir.$tid.'-event.jpg';
  143. }
  144. }else{
  145. preg_match("/\[img(.*)\](.+?)\[\/img\]/is",$_G['gp_message'],$match);
  146. if(mbeventsetthreadcover($a['param'][2]['pid'],$a['param'][2]['tid'],0,0,$match[2],$imgtype,$fid)){
  147. $coverurl = $basedir.'forum/'.$coverdir.$tid.'-event.jpg';
  148. }
  149. }
  150. DB::query("INSERT INTO ".DB::table('xj_eventthread')." (eid,tid,fid,coverurl,sort) VALUES ('$eid','$tid','$fid','$coverurl','$sort')");
  151. }
  152. }
  153. }
  154. return;
  155. }
  156. }
  157. function mbeventsetthreadcover($pid, $tid = 0, $aid = 0, $countimg = 0, $imgurl = '',$imgtype = 1,$fid) {
  158. global $_G;
  159. $cover = 0;
  160. //图片大小
  161. $imgheight = 165;
  162. $imgwidth = 165;
  163. if(empty($_G['uid']) || !intval($imgheight) || !intval($imgwidth)) {
  164. return false;
  165. }
  166. if(($pid || $aid) && empty($countimg)) {
  167. if(empty($imgurl)) {
  168. if($aid) {
  169. $attachtable = 'aid:'.$aid;
  170. $attach = C::t('forum_attachment_n')->fetch('aid:'.$aid, $aid, array(1, -1));
  171. } else {
  172. $attachtable = 'pid:'.$pid;
  173. $attach = C::t('forum_attachment_n')->fetch_max_image('pid:'.$pid, 'pid', $pid);
  174. }
  175. if(!$attach) {
  176. return false;
  177. }
  178. if(empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
  179. return false;
  180. }
  181. $pid = empty($pid) ? $attach['pid'] : $pid;
  182. $tid = empty($tid) ? $attach['tid'] : $tid;
  183. $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
  184. } else {
  185. $attachtable = 'pid:'.$pid;
  186. $picsource = $imgurl;
  187. }
  188. $basedir = !$_G['setting']['attachdir'] ? (DISCUZ_ROOT.'./data/attachment/') : $_G['setting']['attachdir'];
  189. $coverdir = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/';
  190. dmkdir($basedir.'./forum/'.$coverdir);
  191. require_once libfile('class/image');
  192. $image = new image();
  193. if($image->Thumb($picsource, 'forum/'.$coverdir.$tid.'-event.jpg', $imgwidth, $imgheight, 2)) {
  194. return true;
  195. } else {
  196. return false;
  197. }
  198. }
  199. }
  200. ?>