pm_client.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: pm_client.php 1166 2014-11-03 01:49:32Z hypowang $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class pm_clientcontrol extends base {
  9. function __construct() {
  10. $this->pm_clientcontrol();
  11. }
  12. function pm_clientcontrol() {
  13. parent::__construct();
  14. if (!$this->settings['pmcenter']) {
  15. exit('PMCenter closed');
  16. }
  17. $this->load('user');
  18. $this->load('pm', NULL, UC_SERVER_RELEASE);
  19. }
  20. function _auth() {
  21. $input = getgpc('input');
  22. if (!$this->user['uid'] || isset($input)) {
  23. $this->init_input();
  24. header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
  25. if ($this->input['uid']) {
  26. $this->setcookie('uc_auth', @$this->authcode($this->input['uid'] . "||" . md5($_SERVER['HTTP_USER_AGENT']), 'ENCODE', UC_KEY), 1800);
  27. @$this->user['uid'] = $this->input['uid'];
  28. } else {
  29. $this->setcookie('uc_auth', '');
  30. $this->message('please_login', '', 1);
  31. }
  32. }
  33. }
  34. function onls() {
  35. $folder = getgpc('folder');
  36. $page = getgpc('page');
  37. $filter = getgpc('filter');
  38. $a = getgpc('a');
  39. $this->_auth();
  40. $uid = $this->user['uid'];
  41. $_ENV['pm']->lang = &$this->lang;
  42. $page = $page ? $page : 1;
  43. $filter = $filter ? (in_array($filter, array('newpm', 'privatepm')) ? $filter : '') : 'privatepm';
  44. $pmnum_private = $_ENV['pm']->getpmnum($uid, 0, 0);
  45. $unreadpmnum = $_ENV['pm']->getpmnum($uid, 0, 1);
  46. $this->view->assign('user', $this->user);
  47. $this->view->assign('pmnum_private', $pmnum_private);
  48. $this->view->assign('pmnum_chatpm', $pmnum_chatpm);
  49. $this->view->assign('unreadpmnum', $unreadpmnum);
  50. if ($folder == 'blackls') {
  51. $blackls = dhtmlspecialchars($_ENV['pm']->get_blackls($uid));
  52. $this->view->assign('folder', $folder);
  53. $this->view->assign('blackls', $blackls);
  54. $this->view->display('pm_blackls');
  55. } else {
  56. $start = ($page - 1) * 10;
  57. $pmlist = $_ENV['pm']->getpmlist($uid, $filter, $start, 10);
  58. if ($pmlist) {
  59. foreach ($pmlist as $key => $value) {
  60. $pmlist[$key]['filter'] = 'privatepm';
  61. $pmlist[$key]['lastdateline'] = $this->date($value['lastdateline']);
  62. }
  63. }
  64. $extra = 'extra=' . rawurlencode('page=' . $page);
  65. $multipage = $this->page($pmnum, 10, $page, 'index.php?m=pm_client&a=ls&folder=' . $folder . '&filter=' . $filter);
  66. $this->view->assign('extra', $extra);
  67. $this->view->assign('filter', $filter);
  68. $this->view->assign('pmlist', $pmlist);
  69. $this->view->assign('multipage', $multipage);
  70. $this->view->display('pm_ls');
  71. }
  72. }
  73. function onblackls() {
  74. $blackls = getgpc('blackls', 'P');
  75. $this->_auth();
  76. $uid = $this->user['uid'];
  77. if ($this->submitcheck()) {
  78. $_ENV['pm']->set_blackls($uid, $blackls);
  79. }
  80. $this->message('blackls_updated', 'index.php?m=pm_client&a=ls&folder=blackls', 1);
  81. }
  82. function onsend() {
  83. $a = getgpc('a');
  84. $do = getgpc('do');
  85. $this->_auth();
  86. $uid = $this->user['uid'];
  87. $this->load('friend');
  88. $totalnum = $_ENV['friend']->get_totalnum_by_uid($this->user['uid'], 3);
  89. $friends = $totalnum ? $_ENV['friend']->get_list($this->user['uid'], 1, $totalnum, $totalnum, 3) : array();
  90. if (!$this->submitcheck()) {
  91. $extra = 'extra=' . rawurlencode($_GET['extra']);
  92. $type = !empty($_GET['type']) ? $_GET['type'] : '';
  93. $pmid = @is_numeric($_GET['pmid']) ? $_GET['pmid'] : 0;
  94. $daterange = $_GET['daterange'] ? intval($_GET['daterange']) : 1;
  95. $touid = intval($_GET['touid']);
  96. $plid = intval($_GET['plid']);
  97. $folder = getgpc('folder');
  98. $pmnum_private = $_ENV['pm']->getpmnum($uid, 0, 0);
  99. $unreadpmnum = $_ENV['pm']->getpmnum($uid, 0, 1);
  100. $touser = '';
  101. if ($pmid) {
  102. $tmp = $_ENV['pm']->getpmbypmid($uid, $pmid);
  103. $tmp = $tmp[0];
  104. } else {
  105. $tmp = array();
  106. }
  107. if (!empty($pmid)) {
  108. if ($do == 'forward') {
  109. $user = $_ENV['user']->get_user_by_uid($tmp['msgtoid']);
  110. $tmp['message'] = $this->lang['pm_from'] . ': ' . $tmp['author'] . "\n" .
  111. $this->lang['pm_to'] . ': ' . dhtmlspecialchars($user['username']) . "\n" .
  112. $this->lang['pm_date'] . ': ' . $this->date($tmp['dateline']) . "\n\n" .
  113. '[quote]' . trim(preg_replace("/(\[quote])(.*)(\[\/quote])/siU", '', $tmp['message'])) . '[/quote]' . "\n";
  114. }
  115. } else {
  116. !empty($_GET['msgto']) && $touser = dhtmlspecialchars($_GET['msgto']);
  117. !empty($_GET['subject']) && $tmp['subject'] = $_GET['subject'];
  118. !empty($_GET['message']) && $tmp['message'] = $_GET['message'];
  119. }
  120. if ($this->settings['sendpmseccode']) {
  121. $authkey = md5(UC_KEY . $_SERVER['HTTP_USER_AGENT'] . $this->onlineip);
  122. $rand = rand(100000, 999999);
  123. $seccodeinit = rawurlencode($this->authcode($rand, 'ENCODE', $authkey, 720));
  124. $this->view->assign('seccodeinit', $seccodeinit);
  125. }
  126. $this->view->assign('sendpmseccode', $this->settings['sendpmseccode']);
  127. $this->view->assign('touser', $touser);
  128. $this->view->assign('user', $this->user);
  129. $this->view->assign('pmnum_private', $pmnum_private);
  130. $this->view->assign('pmnum_chatpm', $pmnum_chatpm);
  131. $this->view->assign('unreadpmnum', $unreadpmnum);
  132. $this->view->assign('friends', $friends);
  133. $this->view->assign('extra', $extra);
  134. $this->view->assign('pmid', $pmid);
  135. $this->view->assign('daterange', $daterange);
  136. $this->view->assign('touid', $touid);
  137. $this->view->assign('plid', $plid);
  138. $this->view->assign('a', $a);
  139. $this->view->assign('do', $do);
  140. $this->view->assign('folder', $folder);
  141. $tmp['message'] = dhtmlspecialchars($tmp['message']);
  142. $this->view->assign('message', $tmp['message']);
  143. $this->view->assign('type', $type);
  144. $this->view->display('pm_send');
  145. } else {
  146. if ($this->settings['sendpmseccode']) {
  147. $authkey = md5(UC_KEY . $_SERVER['HTTP_USER_AGENT'] . $this->onlineip);
  148. $seccodehidden = urldecode(getgpc('seccodehidden', 'P'));
  149. $seccode = strtoupper(getgpc('seccode', 'P'));
  150. $seccodehidden = $this->authcode($seccodehidden, 'DECODE', $authkey);
  151. require UC_ROOT . './lib/seccode.class.php';
  152. if (!seccode::seccode_check($seccodehidden, $seccode)) {
  153. $this->message('pm_send_seccode_error', 'BACK', 1);
  154. }
  155. }
  156. $user = $_ENV['user']->get_user_by_uid($this->user['uid']);
  157. $this->user['username'] = daddslashes($user['username'], 1);
  158. $touid = intval(getgpc('touid'));
  159. $daterange = intval(getgpc('daterange'));
  160. $type = intval(getgpc('type'));
  161. $replypmid = @is_numeric($_GET['replypmid']) ? $_GET['replypmid'] : 0;
  162. $msgto = array();
  163. if ($replypmid) {
  164. $plid = $_ENV['pm']->getplidbypmid($replypmid);
  165. $msgto = $_ENV['pm']->getuidbyplid($plid);
  166. unset($msgto[$uid]);
  167. } else {
  168. if (!empty($_POST['msgto'])) {
  169. $msgto = explode(',', $_POST['msgto']);
  170. $msgto = $_ENV['user']->name2id($msgto);
  171. }
  172. }
  173. if (isset($_POST['friend'])) {
  174. $frienduids = array();
  175. foreach ($friends as $friend) {
  176. $frienduids[] = $friend['friendid'];
  177. }
  178. foreach ($_POST['friend'] as $friendid) {
  179. if (in_array($friendid, $frienduids)) {
  180. $msgto[] = $friendid;
  181. }
  182. }
  183. }
  184. if (!$msgto) {
  185. $this->message('receiver_no_exists', 'BACK', 1);
  186. }
  187. $msgto = array_unique($msgto);
  188. $countmsgto = count($msgto);
  189. if ($this->settings['pmsendregdays']) {
  190. if ($user['regdate'] > $this->time - $this->settings['pmsendregdays'] * 86400) {
  191. $this->message('pm_send_regdays_error', 'BACK', 1, array('$pmsendregdays' => $this->settings['pmsendregdays']));
  192. }
  193. }
  194. if ($this->settings['chatpmmemberlimit']) {
  195. if ($type == 1 && ($countmsgto > ($this->settings['chatpmmemberlimit'] - 1))) {
  196. $this->message('pm_send_chatpmmemberlimit_error', 'BACK', 1, array('$chatpmmemberlimit' => $this->settings['chatpmmemberlimit']));
  197. }
  198. }
  199. if ($this->settings['pmfloodctrl']) {
  200. if (!$_ENV['pm']->ispminterval($this->user['uid'], $this->settings['pmfloodctrl'])) {
  201. $this->message('pm_send_pmfloodctrl_error', 'BACK', 1, array('$pmfloodctrl' => $this->settings['pmfloodctrl']));
  202. }
  203. }
  204. if ($this->settings['privatepmthreadlimit']) {
  205. if (!$_ENV['pm']->isprivatepmthreadlimit($this->user['uid'], $this->settings['privatepmthreadlimit'])) {
  206. $this->message('pm_send_privatepmthreadlimit_error', 'BACK', 1, array('$privatepmthreadlimit' => $this->settings['privatepmthreadlimit']));
  207. }
  208. }
  209. if ($this->settings['chatpmthreadlimit']) {
  210. if (!$_ENV['pm']->ischatpmthreadlimit($this->user['uid'], $this->settings['chatpmthreadlimit'])) {
  211. $this->message('pm_send_chatpmthreadlimit_error', 'BACK', 1, array('$chatpmthreadlimit' => $this->settings['chatpmthreadlimit']));
  212. }
  213. }
  214. if ($replypmid) {
  215. $lastpmid = $_ENV['pm']->replypm($plid, $this->user['uid'], $this->user['username'], $_POST['message']);
  216. } else {
  217. $lastpmid = $_ENV['pm']->sendpm($this->user['uid'], $this->user['username'], $msgto, '', $_POST['message'], $type);
  218. }
  219. if ($lastpmid > 0) {
  220. if ($replypmid) {
  221. if ($touid) {
  222. $this->message('pm_send_succeed', "index.php?m=pm_client&a=view&touid=$touid&daterange=$daterange&filter=privatepm", 1);
  223. } else {
  224. $this->message('pm_send_succeed', "index.php?m=pm_client&a=view&plid=$plid&daterange=$daterange&filter=chatpm", 1);
  225. }
  226. } else {
  227. if (!$type) {
  228. $this->message('pm_send_succeed', 'index.php?m=pm_client&a=ls&filter=privatepm', 1);
  229. } else {
  230. $this->message('pm_send_succeed', 'index.php?m=pm_client&a=ls&filter=chatpm', 1);
  231. }
  232. }
  233. } else {
  234. $this->message('pm_send_ignore', 'BACK', 1);
  235. }
  236. }
  237. }
  238. function ondelete() {
  239. $this->_auth();
  240. $uid = $this->user['uid'];
  241. $deletetouids = getgpc('deleteuid');
  242. $deleteplids = getgpc('deleteplid');
  243. $quitplids = getgpc('deletequitplid');
  244. $filter = getgpc('filter');
  245. if ($deletetouids && $deleteplids && $quitplids) {
  246. $this->message('pm_delete_invalid', 'index.php?m=pm_client&a=ls&filter=' . $filter . '&' . $_GET['extra'], 1);
  247. }
  248. $flag = true;
  249. if ($deletetouids) {
  250. $return = $_ENV['pm']->deletepmbyplids($uid, $deletetouids, 1);
  251. if ($return <= 0) {
  252. $flag = false;
  253. }
  254. }
  255. if ($deleteplids) {
  256. $return = $_ENV['pm']->deletepmbyplids($uid, $deleteplids);
  257. if ($return <= 0) {
  258. $flag = false;
  259. }
  260. }
  261. if ($quitplids) {
  262. $return = $_ENV['pm']->quitchatpm($uid, $quitplids);
  263. if ($return <= 0) {
  264. $flag = false;
  265. }
  266. }
  267. if ($flag) {
  268. $this->message('pm_delete_succeed', 'index.php?m=pm_client&a=ls&filter=' . $filter . '&' . $_GET['extra'], 1);
  269. } else {
  270. $this->message('pm_delete_invalid', 'index.php?m=pm_client&a=ls&filter=' . $filter . '&' . $_GET['extra'], 1);
  271. }
  272. }
  273. function onview() {
  274. $touid = intval(getgpc('touid'));
  275. $plid = intval(getgpc('plid'));
  276. $scroll = getgpc('scroll');
  277. $daterange = getgpc('daterange');
  278. $filter = getgpc('filter');
  279. $extra = 'extra=' . rawurlencode(getgpc('extra'));
  280. $a = getgpc('a');
  281. $this->_auth();
  282. $uid = $this->user['uid'];
  283. $pmnum_private = $_ENV['pm']->getpmnum($uid, 0, 0);
  284. $unreadpmnum = $_ENV['pm']->getpmnum($uid, 0, 1);
  285. $daterange = empty($daterange) ? 1 : $daterange;
  286. $today = $this->time - ($this->time + $this->settings['timeoffset']) % 86400;
  287. if ($daterange == 1) {
  288. $starttime = $today;
  289. } elseif ($daterange == 2) {
  290. $starttime = $today - 86400;
  291. } elseif ($daterange == 3) {
  292. $starttime = $today - 172800;
  293. } elseif ($daterange == 4) {
  294. $starttime = $today - 604800;
  295. } elseif ($daterange == 5) {
  296. $starttime = 0;
  297. }
  298. $endtime = $this->time;
  299. if ($touid) {
  300. $touser = $_ENV['user']->get_user_by_uid($touid);
  301. $plid = $_ENV['pm']->getplidbytouid($uid, $touid);
  302. $pms = $_ENV['pm']->getpmbyplid($uid, $plid, $starttime, $endtime, 0, 0, 0);
  303. } elseif ($plid) {
  304. $pms = $_ENV['pm']->getpmbyplid($uid, $plid, $starttime, $endtime, 0, 0, 1);
  305. }
  306. if ($pms) {
  307. $founderuid = $pms[0]['founderuid'];
  308. $replypmid = $pms[0]['pmid'];
  309. $subject = $pms[0]['subject'];
  310. }
  311. require_once UC_ROOT . 'lib/uccode.class.php';
  312. $this->uccode = new uccode();
  313. foreach ($pms as $key => $pm) {
  314. $pms[$key]['message'] = $this->uccode->complie($pms[$key]['message']);
  315. $pms[$key]['dateline'] = $this->date($pms[$key]['dateline']);
  316. }
  317. if ($this->settings['sendpmseccode']) {
  318. $authkey = md5(UC_KEY . $_SERVER['HTTP_USER_AGENT'] . $this->onlineip);
  319. $rand = rand(100000, 999999);
  320. $seccodeinit = rawurlencode($this->authcode($rand, 'ENCODE', $authkey, 720));
  321. $this->view->assign('seccodeinit', $seccodeinit);
  322. }
  323. $this->view->assign('sendpmseccode', $this->settings['sendpmseccode']);
  324. $this->view->assign('scroll', $scroll);
  325. $this->view->assign('user', $this->user);
  326. $this->view->assign('touser', $touser);
  327. $this->view->assign('subject', $subject);
  328. $this->view->assign('pmnum_private', $pmnum_private);
  329. $this->view->assign('pmnum_chatpm', $pmnum_chatpm);
  330. $this->view->assign('unreadpmnum', $unreadpmnum);
  331. $this->view->assign('daterange', $daterange);
  332. $this->view->assign('replypmid', $replypmid);
  333. $this->view->assign('touid', $touid);
  334. $this->view->assign('plid', $plid);
  335. $this->view->assign('extra', $extra);
  336. $this->view->assign('founderuid', $founderuid);
  337. $this->view->assign('filter', $filter);
  338. $this->view->assign('pms', $pms);
  339. $this->view->display('pm_view');
  340. }
  341. function onmember() {
  342. $plid = intval(getgpc('plid'));
  343. $scroll = getgpc('scroll');
  344. $daterange = getgpc('daterange');
  345. $filter = getgpc('filter');
  346. $extra = 'extra=' . rawurlencode(getgpc('extra'));
  347. $a = getgpc('a');
  348. $do = getgpc('do');
  349. $this->_auth();
  350. $uid = $this->user['uid'];
  351. $pmnum_private = $_ENV['pm']->getpmnum($uid, 0, 0);
  352. $unreadpmnum = $_ENV['pm']->getpmnum($uid, 0, 1);
  353. if ($do == 'kickmember') {
  354. $memberuid = intval(getgpc('memberuid'));
  355. if ($memberuid) {
  356. $_ENV['pm']->kickchatpm($plid, $uid, $memberuid);
  357. }
  358. $this->message('pm_kickmember_succeed', "index.php?m=pm_client&a=member&plid=$plid&filter=" . $filter . '&' . $_GET['extra'], 1);
  359. }
  360. if ($this->submitcheck() && $do == 'appendmember') {
  361. $appendmember = $_ENV['user']->get_user_by_username(getgpc('appendmember'));
  362. if ($appendmember) {
  363. $return = $_ENV['pm']->appendchatpm($plid, $uid, $appendmember['uid']);
  364. if ($return > 0) {
  365. $this->message('pm_appendmember_succeed', "index.php?m=pm_client&a=member&plid=$plid&filter=" . $filter . '&' . $_GET['extra'], 1);
  366. }
  367. }
  368. $this->message('pm_appendmember_invalid', "index.php?m=pm_client&a=member&plid=$plid&filter=" . $filter . '&' . $_GET['extra'], 1);
  369. }
  370. $members = $_ENV['pm']->chatpmmemberlist($uid, $plid);
  371. $authorid = $members['author'];
  372. $members = $members['member'];
  373. $members = $_ENV['user']->id2name($members);
  374. $this->view->assign('scroll', $scroll);
  375. $this->view->assign('user', $this->user);
  376. $this->view->assign('pmnum_private', $pmnum_private);
  377. $this->view->assign('pmnum_chatpm', $pmnum_chatpm);
  378. $this->view->assign('unreadpmnum', $unreadpmnum);
  379. $this->view->assign('replypmid', $replypmid);
  380. $this->view->assign('subject', $subject);
  381. $this->view->assign('daterange', $daterange);
  382. $this->view->assign('plid', $plid);
  383. $this->view->assign('extra', $extra);
  384. $this->view->assign('filter', $filter);
  385. $this->view->assign('authorid', $authorid);
  386. $this->view->assign('members', $members);
  387. $this->view->display('pm_member');
  388. }
  389. }
  390. ?>