PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/miles/GlobalMBA/mba/sns_00/upload/home/source/cp_click.php

#
PHP | 187 lines | 137 code | 33 blank | 17 comment | 20 complexity | 22f3fee10c5b2d8c6b41e0e62b8eaac5 MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /*
  3. [UCenter Home] (C) 2007-2008 Comsenz Inc.
  4. $Id: cp_blog.php 11934 2009-04-10 07:54:59Z liguode $
  5. */
  6. if(!defined('IN_UCHOME')) {
  7. exit('Access Denied');
  8. }
  9. $clickid = empty($_GET['clickid'])?0:intval($_GET['clickid']);
  10. $idtype = empty($_GET['idtype'])?'':trim($_GET['idtype']);
  11. $id = empty($_GET['id'])?0:intval($_GET['id']);
  12. //点击器
  13. include_once(S_ROOT.'./data/data_click.php');
  14. $clicks = empty($_SGLOBAL['click'][$idtype])?array():$_SGLOBAL['click'][$idtype];
  15. $click = $clicks[$clickid];
  16. if(empty($click)) {
  17. showmessage('click_error');
  18. }
  19. //信息
  20. switch ($idtype) {
  21. case 'picid':
  22. $sql = "SELECT p.*, s.username, a.friend, pf.hotuser FROM ".tname('pic')." p
  23. LEFT JOIN ".tname('picfield')." pf ON pf.picid=p.picid
  24. LEFT JOIN ".tname('album')." a ON a.albumid=p.albumid
  25. LEFT JOIN ".tname('space')." s ON s.uid=p.uid
  26. WHERE p.picid='$id'";
  27. $tablename = tname('pic');
  28. break;
  29. case 'tid':
  30. $sql = "SELECT t.*, p.hotuser FROM ".tname('thread')." t
  31. LEFT JOIN ".tname('post')." p ON p.tid='$id' AND p.isthread='1'
  32. WHERE t.tid='$id'";
  33. $tablename = tname('thread');
  34. break;
  35. default:
  36. $idtype = 'blogid';
  37. $sql = "SELECT b.*, bf.hotuser FROM ".tname('blog')." b
  38. LEFT JOIN ".tname('blogfield')." bf ON bf.blogid=b.blogid
  39. WHERE b.blogid='$id'";
  40. $tablename = tname('blog');
  41. break;
  42. }
  43. $query = $_SGLOBAL['db']->query($sql);
  44. if(!$item = $_SGLOBAL['db']->fetch_array($query)) {
  45. showmessage('click_item_error');
  46. }
  47. $hash = md5($item['uid']."\t".$item['dateline']);
  48. if($_GET['op'] == 'add') {
  49. if(!checkperm('allowclick') || $_GET['hash'] != $hash) {
  50. showmessage('no_privilege');
  51. }
  52. if($item['uid'] == $_SGLOBAL['supe_uid']) {
  53. showmessage('click_no_self');
  54. }
  55. //黑名单
  56. if(isblacklist($item['uid'])) {
  57. showmessage('is_blacklist');
  58. }
  59. //检查是否点击过了
  60. $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('clickuser')." WHERE uid='$space[uid]' AND id='$id' AND idtype='$idtype'");
  61. if($value = $_SGLOBAL['db']->fetch_array($query)) {
  62. showmessage('click_have');
  63. }
  64. //参与
  65. $setarr = array(
  66. 'uid' => $space['uid'],
  67. 'username' => $_SGLOBAL['supe_username'],
  68. 'id' => $id,
  69. 'idtype' => $idtype,
  70. 'clickid' => $clickid,
  71. 'dateline' => $_SGLOBAL['timestamp']
  72. );
  73. inserttable('clickuser', $setarr);
  74. //更新数量
  75. $_SGLOBAL['db']->query("UPDATE $tablename SET click_{$clickid}=click_{$clickid}+1 WHERE $idtype='$id'");
  76. //更新热度
  77. hot_update($idtype, $id, $item['hotuser']);
  78. //实名
  79. realname_set($item['uid'], $item['username']);
  80. realname_get();
  81. //动态
  82. $fs = array();
  83. switch ($idtype) {
  84. case 'blogid':
  85. $fs['title_template'] = cplang('feed_click_blog');
  86. $fs['title_data'] = array(
  87. 'touser' => "<a href=\"space.php?uid=$item[uid]\">{$_SN[$item['uid']]}</a>",
  88. 'subject' => "<a href=\"space.php?uid=$item[uid]&do=blog&id=$item[blogid]\">$item[subject]</a>",
  89. 'click' => $click['name']
  90. );
  91. $note_type = 'clickblog';
  92. $q_note = cplang('note_click_blog', array("space.php?uid=$item[uid]&do=blog&id=$item[blogid]", $item['subject']));
  93. break;
  94. case 'tid':
  95. $fs['title_template'] = cplang('feed_click_thread');
  96. $fs['title_data'] = array(
  97. 'touser' => "<a href=\"space.php?uid=$item[uid]\">{$_SN[$item['uid']]}</a>",
  98. 'subject' => "<a href=\"space.php?uid=$item[uid]&do=thread&id=$item[tid]\">$item[subject]</a>",
  99. 'click' => $click['name']
  100. );
  101. $note_type = 'clickthread';
  102. $q_note = cplang('note_click_thread', array("space.php?uid=$item[uid]&do=thread&id=$item[tid]", $item['subject']));
  103. break;
  104. case 'picid':
  105. $fs['title_template'] = cplang('feed_click_pic');
  106. $fs['title_data'] = array(
  107. 'touser' => "<a href=\"space.php?uid=$item[uid]\">{$_SN[$item['uid']]}</a>",
  108. 'click' => $click['name']
  109. );
  110. $fs['images'] = array(pic_get($item['filepath'], $item['thumb'], $item['remote']));
  111. $fs['image_links'] = array("space.php?uid=$item[uid]&do=album&picid=$item[picid]");
  112. $fs['body_general'] = $item['title'];
  113. $note_type = 'clickpic';
  114. $q_note = cplang('note_click_pic', array("space.php?uid=$item[uid]&do=album&picid=$item[picid]"));
  115. break;
  116. }
  117. //事件发布
  118. if(empty($item['friend']) && ckprivacy('click', 1)) {
  119. feed_add('click', $fs['title_template'], $fs['title_data'], '', array(), $fs['body_general'],$fs['images'], $fs['image_links']);
  120. }
  121. //奖励访客
  122. getreward('click', 1, 0, $idtype.$id);
  123. //统计
  124. updatestat('click');
  125. //通知
  126. notification_add($item['uid'], $note_type, $q_note);
  127. showmessage('click_success', $_SGLOBAL['refer']);
  128. } elseif ($_GET['op'] == 'show') {
  129. foreach ($clicks as $key => $value) {
  130. $value['clicknum'] = $item["click_$key"];
  131. $value['classid'] = mt_rand(1, 4);
  132. if($value['clicknum'] > $maxclicknum) $maxclicknum = $value['clicknum'];
  133. $clicks[$key] = $value;
  134. }
  135. $start = intval($_GET['start']);
  136. if($start < 0) $start = 0;
  137. $perpage = 18;
  138. $count = 0;
  139. $clickuserlist = array();
  140. $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('clickuser')."
  141. WHERE id='$id' AND idtype='$idtype'
  142. ORDER BY dateline DESC
  143. LIMIT $start,$perpage");
  144. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  145. realname_set($value['uid'], $value['username']);//实名
  146. $value['clickname'] = $clicks[$value['clickid']]['name'];
  147. $clickuserlist[] = $value;
  148. $count++;
  149. }
  150. realname_get();
  151. $click_multi = smulti($start, $perpage, $count, "cp.php?ac=click&op=show&clickid=$clickid&idtype=$idtype&id=$id", 'click_div');
  152. }
  153. include_once(template('cp_click'));
  154. ?>