misc_ajax.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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: misc_ajax.php 26657 2011-12-19 04:13:43Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $op = empty($_GET['op'])?'':$_GET['op'];
  12. if($op == 'comment') {
  13. $cid = empty($_GET['cid'])?0:intval($_GET['cid']);
  14. if($cid) {
  15. $ajax_edit = 1;
  16. } else {
  17. $ajax_edit = 0;
  18. }
  19. $list = array();
  20. $value = C::t('home_comment')->fetch_latest_by_authorid($_G['uid'], $cid);
  21. $list[] = $value;
  22. } elseif($op == 'getfriendgroup') {
  23. $uid = intval($_GET['uid']);
  24. if($_G['uid'] && $uid) {
  25. $space = getuserbyuid($_G['uid']);
  26. $query = C::t('home_friend')->fetch_all_by_uid_fuid($_G['uid'], $uid);
  27. $value = $query[0];
  28. }
  29. require_once libfile('function/friend');
  30. $groups = friend_group_list();
  31. if(empty($value['gid'])) $value['gid'] = 0;
  32. $group =$groups[$value['gid']];
  33. } elseif($op == 'getfriendname') {
  34. $groupname = '';
  35. $group = intval($_GET['group']);
  36. if($_G['uid'] && $group) {
  37. require_once libfile('function/friend');
  38. $groups = friend_group_list();
  39. $groupname = $groups[$group];
  40. }
  41. } elseif($op == 'share') {
  42. require_once libfile('function/share');
  43. $list = array();
  44. foreach(C::t('home_share')->fetch_all_by_uid($_G['uid'], 0, 1) as $value) {
  45. $value = mkshare($value);
  46. $ajax_edit = 1;
  47. $list[] = $value;
  48. }
  49. } elseif($op == 'album') {
  50. $id = empty($_GET['id'])?0:intval($_GET['id']);
  51. $perpage = 10;
  52. $page = empty($_GET['page'])?1:intval($_GET['page']);
  53. $start = ($page-1)*$perpage;
  54. ckstart($start, $perpage);
  55. if(empty($_G['uid'])) {
  56. showmessage('to_login', null, array(), array('showmsg' => true, 'login' => 1));
  57. }
  58. $count = C::t('home_pic')->check_albumpic($id, NULL, $_G['uid']);
  59. $piclist = array();
  60. $multi = '';
  61. if($count) {
  62. $query = C::t('home_pic')->fetch_all_by_albumid($id, $start, $perpage, 0, 0, 1, $_G['uid']);
  63. foreach($query as $value) {
  64. $value['bigpic'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0);
  65. $value['pic'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']);
  66. $piclist[] = $value;
  67. }
  68. $multi = multi($count, $perpage, $page, "home.php?mod=misc&ac=ajax&op=album&id=$id");
  69. }
  70. } elseif($op == 'docomment') {
  71. $doid = intval($_GET['doid']);
  72. $clist = $do = array();
  73. $icon = $_GET['icon'] == 'plus' ? 'minus' : 'plus';
  74. if($doid) {
  75. if($value = C::t('home_doing')->fetch($doid)) {
  76. $value['icon'] = 'plus';
  77. if($value['replynum'] > 0 && ($value['replynum'] < 20 || $doid == $value['doid'])) {
  78. $doids[] = $value['doid'];
  79. $value['icon'] = 'minus';
  80. } elseif($value['replynum']<1) {
  81. $value['icon'] = 'minus';
  82. }
  83. $value['id'] = 0;
  84. $value['layer'] = 0;
  85. $clist[] = $value;
  86. }
  87. }
  88. if($_GET['icon'] == 'plus' && $value['replynum']) {
  89. $tree = new lib_tree();
  90. foreach(C::t('home_docomment')->fetch_all_by_doid($doid) as $value) {
  91. if(empty($value['upid'])) {
  92. $value['upid'] = "do";
  93. }
  94. $tree->setNode($value['id'], $value['upid'], $value);
  95. }
  96. $values = $tree->getChilds("do");
  97. foreach ($values as $key => $id) {
  98. $one = $tree->getValue($id);
  99. $one['layer'] = $tree->getLayer($id) * 2;
  100. $clist[] = $one;
  101. }
  102. }
  103. } elseif($op == 'deluserapp') {
  104. if(empty($_G['uid'])) {
  105. showmessage('no_privilege_guest');
  106. }
  107. $hash = trim($_GET['hash']);
  108. if(C::t('common_myinvite')->count_by_hash_touid($hash, $_G['uid'])) {
  109. C::t('common_myinvite')->delete_by_hash_touid($hash, $_G['uid']);
  110. showmessage('do_success');
  111. } else {
  112. showmessage('no_privilege_deluserapp');
  113. }
  114. } elseif($op == 'delnotice') {
  115. if(empty($_G['uid'])) {
  116. showmessage('no_privilege_guest');
  117. }
  118. $id = intval($_GET['id']);
  119. if($id) {
  120. C::t('home_notification')->delete_by_id_uid($id, $uid);
  121. }
  122. showmessage('do_success');
  123. } elseif($op == 'getreward') {
  124. $reward = '';
  125. if($_G['cookie']['reward_log']) {
  126. $log = explode(',', $_G['cookie']['reward_log']);
  127. if(count($log) == 2 && $log[1]) {
  128. loadcache('creditrule');
  129. $creditlog = C::t('common_credit_rule_log')->fetch($log[1]);
  130. $rule = $_G['cache']['creditrule'][$log[0]];
  131. $rule['cyclenum'] = $rule['rewardnum']? $rule['rewardnum'] - $creditlog['cyclenum'] : 0;
  132. }
  133. dsetcookie('reward_log', '');
  134. }
  135. } elseif($op == 'district') {
  136. $container = $_GET['container'];
  137. $showlevel = intval($_GET['level']);
  138. $showlevel = $showlevel >= 1 && $showlevel <= 4 ? $showlevel : 4;
  139. $values = array(intval($_GET['pid']), intval($_GET['cid']), intval($_GET['did']), intval($_GET['coid']));
  140. $containertype = in_array($_GET['containertype'], array('birth', 'reside'), true) ? $_GET['containertype'] : 'birth';
  141. $level = 1;
  142. if($values[0]) {
  143. $level++;
  144. } else if($_G['uid'] && !empty($_GET['showdefault'])) {
  145. space_merge($_G['member'], 'profile');
  146. $district = array();
  147. if($containertype == 'birth') {
  148. if(!empty($_G['member']['birthprovince'])) {
  149. $district[] = $_G['member']['birthprovince'];
  150. if(!empty($_G['member']['birthcity'])) {
  151. $district[] = $_G['member']['birthcity'];
  152. }
  153. if(!empty($_G['member']['birthdist'])) {
  154. $district[] = $_G['member']['birthdist'];
  155. }
  156. if(!empty($_G['member']['birthcommunity'])) {
  157. $district[] = $_G['member']['birthcommunity'];
  158. }
  159. }
  160. } else {
  161. if(!empty($_G['member']['resideprovince'])) {
  162. $district[] = $_G['member']['resideprovince'];
  163. if(!empty($_G['member']['residecity'])) {
  164. $district[] = $_G['member']['residecity'];
  165. }
  166. if(!empty($_G['member']['residedist'])) {
  167. $district[] = $_G['member']['residedist'];
  168. }
  169. if(!empty($_G['member']['residecommunity'])) {
  170. $district[] = $_G['member']['residecommunity'];
  171. }
  172. }
  173. }
  174. if(!empty($district)) {
  175. foreach(C::t('common_district')->fetch_all_by_name($district) as $value) {
  176. $key = $value['level'] - 1;
  177. $values[$key] = $value['id'];
  178. }
  179. $level++;
  180. }
  181. }
  182. if($values[1]) {
  183. $level++;
  184. }
  185. if($values[2]) {
  186. $level++;
  187. }
  188. if($values[3]) {
  189. $level++;
  190. }
  191. $showlevel = $level;
  192. $elems = array();
  193. if($_GET['province']) {
  194. $elems = array($_GET['province'], $_GET['city'], $_GET['district'], $_GET['community']);
  195. }
  196. include_once libfile('function/profile');
  197. $html = showdistrict($values, $elems, $container, $showlevel, $containertype);
  198. } elseif($_GET['op'] == 'createalbum') {
  199. $albumname = 'new:'.$_GET['name'];
  200. require_once libfile('function/spacecp');
  201. $albumid = album_creat_by_id($albumname, intval($_GET['catid']));
  202. }
  203. include template('home/misc_ajax');
  204. ?>