/uchome/notifications.php

https://github.com/freefis/webim · PHP · 67 lines · 57 code · 7 blank · 3 comment · 12 complexity · 3546b9d5747004f927ef579908a7baed MD5 · raw file

  1. <?php
  2. include_once('common.php');
  3. include_once S_ROOT.'./uc_client/client.php';
  4. $page = max($page, 1);
  5. $action = !empty($action) ? $action : (isset($uid) || !empty($pmid) ? 'view' : '');
  6. $ppp=10;
  7. $pmstatus = uc_pm_checknew($_SGLOBAL['supe_uid'], 4);
  8. $systemnewpm = $pmstatus['newpm'] - $pmstatus['newprivatepm'];
  9. $filter = 'newpm';
  10. $ucdata = uc_pm_list($_SGLOBAL['supe_uid'], $page, $ppp, !isset($search) ? 'inbox' : 'searchbox', !isset($search) ? $filter : $srchtxt, 200);
  11. if(!empty($search) && $srchtxt !== '') {
  12. $filter = '';
  13. $srchtxtinput = htmlspecialchars(stripslashes($srchtxt));
  14. $srchtxtenc = rawurlencode($srchtxt);
  15. } else {
  16. $multipage = multi($ucdata['count'], $ppp, $page, 'pm.php?filter='.$filter);
  17. }
  18. $_COOKIE['checkpm'] && setcookie('checkpm', '', -86400 * 365);
  19. $pmlist = array();
  20. $today = $timestamp - ($timestamp + $timeoffset * 3600) % 86400;
  21. foreach($ucdata['data'] as $pm) {
  22. $pm['msgfromurl'] = $pm['fromappid'] && $ucapp[$pm['fromappid']]['viewprourl'] ? sprintf($ucapp[$pm['fromappid']]['viewprourl'], $pm['msgfromid']) : 'space.php?uid='.$pm['msgfromid'];
  23. $pm['daterange'] = 5;
  24. if($pm['dateline'] >= $today) {
  25. $pm['daterange'] = 1;
  26. } elseif($pm['dateline'] >= $today - 86400) {
  27. $pm['daterange'] = 2;
  28. } elseif($pm['dateline'] >= $today - 172800) {
  29. $pm['daterange'] = 3;
  30. }
  31. $pm['date'] = gmdate($dateformat, $pm['dateline'] + $timeoffset * 3600);
  32. $pm['time'] = gmdate($timeformat, $pm['dateline'] + $timeoffset * 3600);
  33. //////
  34. if ($pm['msgfromid'] > 0){
  35. $from=to_utf8($pm['msgfrom']);$text=to_utf8($pm['subject']);$link= 'space.php?do=pm&filter=newpm&uid='.$pm['touid'].'&filter=newpm&daterange='.$pm['daterange'];
  36. }else{
  37. $from='';$text=to_utf8($pm['subject']);$link= 'space.php?do=pm&filter=newpm?pmid='.$pm['pmid'].'&filter=systempm';
  38. }
  39. if($text)
  40. $pmlist[]= array('from'=>$from,'text'=>$text,'link'=>$link,'time'=>$pm['time']);
  41. /////
  42. }
  43. //get notice
  44. $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('myinvite')." WHERE touid='$_SGLOBAL[supe_uid]' $typesql ORDER BY dateline DESC");
  45. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  46. $key = md5($value['typename'].$value['type']);
  47. $list[$key][] = $value;
  48. $count++;
  49. $appidarr[] = $value['appid'];
  50. }
  51. if($list){
  52. foreach($list as $invite){
  53. $from='';$text='您有'.count($invite).'个 '.$invite[0]['typename'].($invite[0]['type']?'请求':'邀请');
  54. $link= 'space.php?do=notice&view=userapp';
  55. if($text)
  56. $pmlist[]= array('from'=>$from,'text'=>$text,'link'=>$link,'time'=>'');
  57. }
  58. }
  59. die(json_encode($pmlist));
  60. ?>