misc_manyou.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_manyou.php 33253 2013-05-10 01:29:32Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if($_GET['action'] == 'inviteCode') {
  12. $my_register_url = 'http://api.manyou.com/uchome.php';
  13. $response = dfsockopen($my_register_url, 0, 'action=inviteCode&app=search');
  14. showmessage($response, '', array(), array('msgtype' => 3, 'handle' => false));
  15. }elseif($_GET['action'] == 'menu') {
  16. $list = array();
  17. $menu = C::t('common_setting')->fetch('appmenu');
  18. $renew = false;
  19. if($menu) {
  20. $list = unserialize($menu);
  21. }
  22. $today = strtotime(dgmdate(TIMESTAMP, 'Y-m-d'));
  23. if(!isset($list['dateline']) || $list['dateline'] < $today) {
  24. $userApp = Cloud::loadClass('Service_Client_Manyou');
  25. $list = $userApp->getMenuApps();
  26. }
  27. $usedList = array();
  28. if(!empty($_G['cookie']['usedapp']) && $_G['uid']) {
  29. $usedInfo = explode('|', $_G['cookie']['usedapp']);
  30. if($usedInfo[0] == $_G['uid']) {
  31. $appids = explode(',', $usedInfo[1]);
  32. if($appids) {
  33. $usedList = C::t('home_userapp')->fetch_all_by_uid_appid($_G['uid'], $appids);
  34. $usedAppId = array();
  35. foreach($usedList as $key => $app) {
  36. if(isset($list[1][$app['appid']])) {
  37. unset($usedList[$key]);
  38. continue;
  39. }
  40. $usedAppId[$app['appid']] = $app['appid'];
  41. $app['pic'] = 'http://appicon.manyou.com/logos/'.$app['appid'];
  42. $app['url'] = 'userapp.php?mod=app&id='.$app['appid'];
  43. $app['name'] = $app['appname'];
  44. $usedList[$key] = $app;
  45. }
  46. $usedNum = count($usedAppId);
  47. if($usedNum < 6 && isset($list[2]) && $list[2]) {
  48. $addNum = 6 - $usedNum;
  49. foreach($list[2] as $app) {
  50. if(!$addNum) {
  51. break;
  52. }elseif(!isset($usedAppId[$app['appid']])) {
  53. $usedList[] = $app;
  54. $addNum--;
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. if(empty($usedList) && isset($list[2]) && $list[2]) {
  62. foreach($list[2] as $app) {
  63. if(count($usedList) >= 6) {
  64. break;
  65. }
  66. $usedList[] = $app;
  67. }
  68. }
  69. include template("userapp/userapp_misc");
  70. }