portalcp_topic.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: portalcp_topic.php 27484 2012-02-02 05:08:02Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $allowmanage = $allowadd = 0;
  12. if($_G['group']['allowaddtopic'] || $_G['group']['allowmanagetopic']) {
  13. $allowadd = 1;
  14. }
  15. $op = in_array($_GET['op'], array('edit')) ? $_GET['op'] : 'add';
  16. $topicid = $_GET['topicid'] ? intval($_GET['topicid']) : 0;
  17. $topic = '';
  18. if($topicid) {
  19. $topic = C::t('portal_topic')->fetch($topicid);
  20. if(empty($topic)) {
  21. showmessage('topic_not_exist');
  22. }
  23. if($_G['group']['allowmanagetopic'] || ($_G['group']['allowaddtopic'] && $topic['uid'] == $_G['uid'])) {
  24. $allowmanage = 1;
  25. }
  26. $coverpath = $topic['picflag'] == '0' ? $topic['cover'] : '';
  27. if($topic['cover']) {
  28. if($topic['picflag'] == '1') {
  29. $topic['cover'] = $_G['setting']['attachurl'].$topic['cover'];
  30. } elseif ($topic['picflag'] == '2') {
  31. $topic['cover'] = $_G['setting']['ftp']['attachurl'].$topic['cover'];
  32. }
  33. }
  34. }
  35. if(($topicid && !$allowmanage) || (!$topicid && !$allowadd)) {
  36. showmessage('topic_edit_nopermission', dreferer());
  37. }
  38. $tpls = array();
  39. foreach($alltemplate = C::t('common_template')->range() as $template) {
  40. if(($dir = dir(DISCUZ_ROOT.$template['directory'].'/portal/'))) {
  41. while(false !== ($file = $dir->read())) {
  42. $file = strtolower($file);
  43. if (fileext($file) == 'htm' && substr($file, 0, 13) == 'portal_topic_') {
  44. $tpls[$template['directory'].':portal/'.str_replace('.htm','',$file)] = getprimaltplname($template['directory'].':portal/'.$file);
  45. }
  46. }
  47. }
  48. }
  49. if (empty($tpls)) showmessage('topic_has_on_template', dreferer());
  50. if(submitcheck('editsubmit')) {
  51. include_once libfile('function/portalcp');
  52. if(is_numeric($topicid = updatetopic($topic))){
  53. showmessage('do_success', 'portal.php?mod=topic&topicid='.$topicid);
  54. } else {
  55. showmessage($topicid, dreferer());
  56. }
  57. }
  58. include_once template("portal/portalcp_topic");
  59. ?>