PageRenderTime 24ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website tin tức PHP/discuznews/source/include/space/space_index.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 153 lines | 131 code | 16 blank | 6 comment | 41 complexity | 22a0394dc4bdcfac41ab1c5febb17512 MD5 | raw file
  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: space_index.php 25870 2011-11-24 07:05:44Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(($_G['adminid'] == 1 && $_G['setting']['allowquickviewprofile'] && $_GET['view'] != 'admin' && $_GET['diy'] != 'yes') || defined('IN_MOBILE')) {
  12. dheader("Location:home.php?mod=space&uid=$space[uid]&do=profile");
  13. }
  14. require_once libfile('function/space');
  15. space_merge($space, 'field_home');
  16. $userdiy = getuserdiydata($space);
  17. if ($_GET['op'] == 'getmusiclist') {
  18. if(empty($space['uid'])) {
  19. exit();
  20. }
  21. $reauthcode = substr(md5($_G['authkey'].$space['uid']), 6, 16);
  22. if($reauthcode == $_GET['hash']) {
  23. space_merge($space,'field_home');
  24. $userdiy = getuserdiydata($space);
  25. $musicmsgs = $userdiy['parameters']['music'];
  26. $outxml = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
  27. $outxml .= '<playlist version="1">'."\n";
  28. $outxml .= '<mp3config>'."\n";
  29. $showmod = 'big' == $musicmsgs['config']['showmod'] ? 'true' : 'false';
  30. $outxml .= '<showdisplay>'.$showmod.'</showdisplay>'."\n";
  31. $outxml .= '<autostart>'.$musicmsgs['config']['autorun'].'</autostart>'."\n";
  32. $outxml .= '<showplaylist>true</showplaylist>'."\n";
  33. $outxml .= '<shuffle>'.$musicmsgs['config']['shuffle'].'</shuffle>'."\n";
  34. $outxml .= '<repeat>all</repeat>'."\n";
  35. $outxml .= '<volume>100</volume>';
  36. $outxml .= '<linktarget>_top</linktarget> '."\n";
  37. $outxml .= '<backcolor>0x'.substr($musicmsgs['config']['crontabcolor'], -6).'</backcolor> '."\n";
  38. $outxml .= '<frontcolor>0x'.substr($musicmsgs['config']['buttoncolor'], -6).'</frontcolor>'."\n";
  39. $outxml .= '<lightcolor>0x'.substr($musicmsgs['config']['fontcolor'], -6).'</lightcolor>'."\n";
  40. $outxml .= '<jpgfile>'.$musicmsgs['config']['crontabbj'].'</jpgfile>'."\n";
  41. $outxml .= '<callback></callback> '."\n";
  42. $outxml .= '</mp3config>'."\n";
  43. $outxml .= '<trackList>'."\n";
  44. foreach ($musicmsgs['mp3list'] as $value){
  45. $outxml .= '<track><annotation>'.$value['mp3name'].'</annotation><location>'.$value['mp3url'].'</location><image>'.$value['cdbj'].'</image></track>'."\n";
  46. }
  47. $outxml .= '</trackList></playlist>';
  48. $outxml = diconv($outxml, CHARSET, 'UTF-8');
  49. obclean();
  50. @header("Expires: -1");
  51. @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  52. @header("Pragma: no-cache");
  53. @header("Content-type: application/xml; charset=utf-8");
  54. echo $outxml;
  55. }
  56. exit();
  57. }else{
  58. if(!$_G['setting']['preventrefresh'] || $_G['uid'] && !$space['self'] && $_G['cookie']['viewid'] != 'uid_'.$space['uid']) {
  59. member_count_update($space['uid'], array('views' => 1));
  60. $viewuids[$space['uid']] = $space['uid'];
  61. dsetcookie('viewid', 'uid_'.$space['uid']);
  62. }
  63. if(!$space['self'] && $_G['uid']) {
  64. $visitor = C::t('home_visitor')->fetch_by_uid_vuid($space['uid'], $_G['uid']);
  65. $is_anonymous = empty($_G['cookie']['anonymous_visit_'.$_G['uid'].'_'.$space['uid']]) ? 0 : 1;
  66. if(empty($visitor['dateline'])) {
  67. $setarr = array(
  68. 'uid' => $space['uid'],
  69. 'vuid' => $_G['uid'],
  70. 'vusername' => $is_anonymous ? '' : $_G['username'],
  71. 'dateline' => $_G['timestamp']
  72. );
  73. C::t('home_visitor')->insert($setarr, false, true);
  74. show_credit();
  75. } else {
  76. if($_G['timestamp'] - $visitor['dateline'] >= 300) {
  77. C::t('home_visitor')->update_by_uid_vuid($space['uid'], $_G['uid'], array('dateline'=>$_G['timestamp'], 'vusername'=>$is_anonymous ? '' : $_G['username']));
  78. }
  79. if($_G['timestamp'] - $visitor['dateline'] >= 3600) {
  80. show_credit();
  81. }
  82. }
  83. updatecreditbyaction('visit', 0, array(), $space['uid']);
  84. }
  85. if($do != 'profile' && !ckprivacy($do, 'view')) {
  86. $_G['privacy'] = 1;
  87. require_once libfile('space/profile', 'include');
  88. include template('home/space_privacy');
  89. exit();
  90. }
  91. $widths = getlayout($userdiy['currentlayout']);
  92. $leftlist = formatdata($userdiy, 'left', $space);
  93. $centerlist = formatdata($userdiy, 'center', $space);
  94. $rightlist = formatdata($userdiy, 'right', $space);
  95. dsetcookie('home_diymode', 1);
  96. }
  97. $navtitle = !empty($space['spacename']) ? $space['spacename'] : lang('space', 'sb_space', array('who' => $space['username']));
  98. $metakeywords = lang('space', 'sb_space', array('who' => $space['username']));
  99. $metadescription = lang('space', 'sb_space', array('who' => $space['username']));
  100. $space['medals'] = getuserprofile('medals');
  101. if($space['medals']) {
  102. loadcache('medals');
  103. foreach($space['medals'] = explode("\t", $space['medals']) as $key => $medalid) {
  104. list($medalid, $medalexpiration) = explode("|", $medalid);
  105. if(isset($_G['cache']['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > TIMESTAMP)) {
  106. $space['medals'][$key] = $_G['cache']['medals'][$medalid];
  107. } else {
  108. unset($space['medals'][$key]);
  109. }
  110. }
  111. }
  112. include_once(template('home/space_index'));
  113. function formatdata($data, $position, $space) {
  114. $list = array();
  115. foreach ((array)$data['block']['frame`frame1']['column`frame1_'.$position] as $blockname => $blockdata) {
  116. if (strpos($blockname, 'block`') === false || empty($blockdata) || !isset($blockdata['attr']['name'])) continue;
  117. $name = $blockdata['attr']['name'];
  118. if(check_ban_block($name, $space)) {
  119. $list[$name] = getblockhtml($name, $data['parameters'][$name]);
  120. }
  121. }
  122. return $list;
  123. }
  124. function show_credit() {
  125. global $_G, $space;
  126. $showinfo = C::t('home_show')->fetch($space['uid']);
  127. if($showinfo['credit'] > 0) {
  128. $showinfo['unitprice'] = intval($showinfo['unitprice']);
  129. if($showinfo['credit'] <= $showinfo['unitprice']) {
  130. notification_add($space['uid'], 'show', 'show_out');
  131. C::t('home_show')->delete($space['uid']);
  132. } else {
  133. C::t('home_show')->update_credit_by_uid($space['uid'], -$showinfo['unitprice']);
  134. }
  135. }
  136. }
  137. ?>