spacecp_space.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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: spacecp_space.php 25510 2011-11-14 02:22:26Z yexinhao $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(submitcheck('delappsubmit')) {
  12. $setarr = array();
  13. if($_POST['type'] == 'profilelink') {
  14. $setarr = array('allowprofilelink' => 0);
  15. } else {
  16. $setarr = array('privacy' => 5);
  17. }
  18. $appid = intval($_POST['appid']);
  19. C::t('home_userapp')->update_by_uid_appid($_G['uid'], $appid, $setarr);
  20. my_userapp_update($_G['uid'], $appid, $setarr['privacy'], $setarr['allowprofilelink']);
  21. showmessage('do_success', dreferer());
  22. }
  23. if($_GET['op'] == 'delete') {
  24. $delid = $_GET['type'] == 'profilelink'? 'profilelink_'.$_GET['appid'] : $_GET['appid'];
  25. }
  26. $actives = array($ac => ' class="active"');
  27. include_once template("home/spacecp_space");
  28. function my_userapp_update($uId, $appId, $privacy = null, $allowProfileLink = null) {
  29. global $my_register_url, $_G;
  30. $mySiteId = $_G['setting']['my_siteid'];
  31. $mySiteKey = $_G['setting']['my_sitekey'];
  32. if (!$_G['setting']['my_app_status']) {
  33. $res = array('errCode' => 121,
  34. 'errMessage' => 'Manyou Service Disabled',
  35. 'result' => ''
  36. );
  37. return $res;
  38. }
  39. $data = array();
  40. if ($privacy !== null) {
  41. switch($privacy) {
  42. case 1:
  43. $data['privacy'] = 'friends';
  44. break;
  45. case 3:
  46. $data['privacy'] = 'me';
  47. break;
  48. case 5:
  49. $data['privacy'] = 'none';
  50. break;
  51. case 0:
  52. default:
  53. $data['privacy'] = 'public';
  54. }
  55. }
  56. if ($allowProfileLink !== null) {
  57. $data['allowProfileLink'] = $allowProfileLink ? true : false;
  58. }
  59. if (!$data) {
  60. return array('errCode' => 5, 'errMessage' => 'Post Data Cann\'t Be Empty!');
  61. }
  62. $data = serialize($data);
  63. $key = "$mySiteId|$mySiteKey|$uId|$appId|$data";
  64. $key = md5($key);
  65. $data = urlencode($data);
  66. $postString = sprintf('action=%s&key=%s&mySiteId=%d&uId=%d&appId=%d&data=%s', 'userappUpdate', $key, $mySiteId, $uId, $appId, $data);
  67. loaducenter();
  68. $url = 'http://api.manyou.com/uchome.php';
  69. $response = uc_fopen2($url, 0, $postString, '', false, $_G['setting']['my_ip']);
  70. $res = unserialize($response);
  71. if (!$response) {
  72. $res['errCode'] = 111;
  73. $res['errMessage'] = 'Empty Response';
  74. $res['result'] = $response;
  75. } elseif(!$res) {
  76. $res['errCode'] = 110;
  77. $res['errMessage'] = 'Error Response';
  78. $res['result'] = $response;
  79. }
  80. return $res;
  81. }
  82. ?>