spacecp_blog.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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_blog.php 28297 2012-02-27 08:35:59Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $blogid = empty($_GET['blogid'])?0:intval($_GET['blogid']);
  12. $op = empty($_GET['op'])?'':$_GET['op'];
  13. $blog = array();
  14. if($blogid) {
  15. $blog = array_merge(
  16. C::t('home_blog')->fetch($blogid),
  17. C::t('home_blogfield')->fetch($blogid)
  18. );
  19. if($blog['tag']) {
  20. $tagarray_all = $array_temp = $blogtag_array = array();
  21. $tagarray_all = explode("\t", $blog['tag']);
  22. if($tagarray_all) {
  23. foreach($tagarray_all as $var) {
  24. if($var) {
  25. $array_temp = explode(',', $var);
  26. $blogtag_array[] = $array_temp['1'];
  27. }
  28. }
  29. }
  30. $blog['tag'] = implode(',', $blogtag_array);
  31. }
  32. }
  33. if(empty($blog)) {
  34. if(!helper_access::check_module('blog') || !checkperm('allowblog')) {
  35. showmessage('no_authority_to_add_log', '', array(), array('return' => true));
  36. }
  37. cknewuser();
  38. $waittime = interval_check('post');
  39. if($waittime > 0) {
  40. showmessage('operating_too_fast', '', array('waittime' => $waittime), array('return' => true));
  41. }
  42. $blog['subject'] = empty($_GET['subject'])?'':getstr($_GET['subject'], 80);
  43. $blog['message'] = empty($_GET['message'])?'':getstr($_GET['message'], 5000);
  44. } else {
  45. if($_G['uid'] != $blog['uid'] && !checkperm('manageblog') && $_GET['modblogkey'] != modauthkey($blog['blogid'])) {
  46. showmessage('no_authority_operation_of_the_log');
  47. }
  48. }
  49. if(submitcheck('blogsubmit', 0, $seccodecheck, $secqaacheck) && helper_access::check_module('blog')) {
  50. if(empty($blog['blogid'])) {
  51. $blog = array();
  52. } else {
  53. if(!checkperm('allowblog')) {
  54. showmessage('no_privilege_blog');
  55. }
  56. }
  57. if($_G['setting']['blogcategorystat'] && $_G['setting']['blogcategoryrequired'] && !$_POST['catid']) {
  58. showmessage('blog_choose_system_category');
  59. }
  60. require_once libfile('function/blog');
  61. if($newblog = blog_post($_POST, $blog)) {
  62. if(empty($blog) && $newblog['topicid']) {
  63. $url = 'home.php?mod=space&uid='.$_G['uid'].'&do=topic&topicid='.$newblog['topicid'].'&view=blog&quickforward=1';
  64. } else {
  65. $url = 'home.php?mod=space&uid='.$newblog['uid'].'&do=blog&quickforward=1&id='.$newblog['blogid'];
  66. }
  67. if($_GET['modblogkey']) {
  68. $url .= "&modblogkey=$_GET[modblogkey]";
  69. }
  70. dsetcookie('clearUserdata', 'home');
  71. showmessage('do_success', $url);
  72. } else {
  73. showmessage('that_should_at_least_write_things', NULL, array(), array('return'=>1));
  74. }
  75. }
  76. if($_GET['op'] == 'delete') {
  77. if(submitcheck('deletesubmit')) {
  78. require_once libfile('function/delete');
  79. if(deleteblogs(array($blogid))) {
  80. showmessage('do_success', "home.php?mod=space&uid=$blog[uid]&do=blog&view=me");
  81. } else {
  82. showmessage('failed_to_delete_operation');
  83. }
  84. }
  85. } elseif($_GET['op'] == 'stick') {
  86. space_merge($space, 'field_home');
  87. $stickflag = $_GET['stickflag'] ? 1 : 0;
  88. if(submitcheck('sticksubmit')) {
  89. if($space['uid'] === $blog['uid'] && empty($blog['status'])) {
  90. $stickblogs = explode(',', $space['stickblogs']);
  91. $pos = array_search($blogid, $stickblogs);
  92. if($pos !== false) {
  93. unset($stickblogs[$pos]);
  94. }
  95. $blogs = implode(',', $stickblogs);
  96. $blogs = empty($_POST['stickflag']) ? $blogs : $blogid.','.$blogs;
  97. $stickblogs = explode(',', $blogs);
  98. $stickblogs = array_filter($stickblogs);
  99. $space['stickblogs'] = implode(',', $stickblogs);
  100. C::t('common_member_field_home')->update($space['uid'], array('stickblogs' => $space['stickblogs']));
  101. showmessage('do_success', dreferer("home.php?mod=space&uid=$blog[uid]&do=blog&view=me"));
  102. } else {
  103. showmessage('failed_to_stick_operation');
  104. }
  105. }
  106. } elseif($_GET['op'] == 'edithot') {
  107. if(!checkperm('manageblog')) {
  108. showmessage('no_privilege_edithot_blog');
  109. }
  110. if(submitcheck('hotsubmit')) {
  111. $_POST['hot'] = intval($_POST['hot']);
  112. C::t('home_blog')->update($blog['blogid'], array('hot'=>$_POST['hot']));
  113. if($_POST['hot']>0) {
  114. require_once libfile('function/feed');
  115. feed_publish($blog['blogid'], 'blogid');
  116. } else {
  117. C::t('home_feed')->update($blog['blogid'], array('hot'=>$_POST['hot']), 'blogid');
  118. }
  119. showmessage('do_success', "home.php?mod=space&uid=$blog[uid]&do=blog&id=$blog[blogid]");
  120. }
  121. } else {
  122. $classarr = $blog['uid']?getclassarr($blog['uid']):getclassarr($_G['uid']);
  123. $albums = getalbums($_G['uid']);
  124. $friendarr = array($blog['friend'] => ' selected');
  125. $passwordstyle = $selectgroupstyle = 'display:none';
  126. if($blog['friend'] == 4) {
  127. $passwordstyle = '';
  128. } elseif($blog['friend'] == 2) {
  129. $selectgroupstyle = '';
  130. if($blog['target_ids']) {
  131. $names = array();
  132. foreach(C::t('common_member')->fetch_all($blog['target_ids']) as $uid => $value) {
  133. $names[$uid] = $value['username'];
  134. }
  135. $blog['target_names'] = implode(' ', $names);
  136. }
  137. }
  138. $blog['message'] = dhtmlspecialchars($blog['message']);
  139. $allowhtml = checkperm('allowhtml');
  140. require_once libfile('function/friend');
  141. $groups = friend_group_list();
  142. if($_G['setting']['blogcategorystat']) {
  143. loadcache('blogcategory');
  144. $category = $_G['cache']['blogcategory'];
  145. $categoryselect = '';
  146. if($category) {
  147. include_once libfile('function/portalcp');
  148. $categoryselect = category_showselect('blog', 'catid', !$_G['setting']['blogcategoryrequired'] ? true : false, $blog['catid']);
  149. }
  150. }
  151. $menuactives = array('space'=>' class="active"');
  152. }
  153. require_once libfile('function/upload');
  154. $swfconfig = getuploadconfig($_G['uid'], 0, false);
  155. include_once template("home/spacecp_blog");
  156. ?>