1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8$section = 'cms'; 9require_once('tiki-setup.php'); 10$artlib = TikiLib::lib('art'); 11 12$access->check_feature('feature_articles'); 13$access->check_permission('tiki_p_admin_cms'); 14 15if (! isset($_REQUEST["topicid"])) { 16 $smarty->assign('msg', tra("No topic id specified")); 17 $smarty->display("error.tpl"); 18 die; 19} 20 21$topic_info = $artlib->get_topic($_REQUEST["topicid"]); 22if ($topic_info == DB_ERROR) { 23 $smarty->assign('msg', tra("Invalid topic id specified")); 24 $smarty->display("error.tpl"); 25 die; 26} 27$smarty->assign_by_ref('topic_info', $topic_info); 28$errors = false; 29if (isset($_REQUEST["edittopic"])) { 30 if (isset($_FILES['userfile1'])&&is_uploaded_file($_FILES['userfile1']['tmp_name'])) { 31 $filegallib = TikiLib::lib('filegal'); 32 try { 33 $filegallib->assertUploadedFileIsSafe($_FILES['userfile1']['tmp_name'], $_FILES['userfile1']['name']); 34 } catch (Exception $e) { 35 $smarty->assign('errortype', 403); 36 $smarty->assign('msg', $e->getMessage()); 37 $smarty->display("error.tpl"); 38 die; 39 } 40 $fp = fopen($_FILES['userfile1']['tmp_name'], "rb"); 41 $data = fread($fp, filesize($_FILES['userfile1']['tmp_name'])); 42 fclose($fp); 43 $imgtype = $_FILES['userfile1']['type']; 44 $imgsize = $_FILES['userfile1']['size']; 45 $imgname = $_FILES['userfile1']['name']; 46 47 $artlib->replace_topic_image($_REQUEST["topicid"], $imgname, $imgtype, $imgsize, $data); 48 } 49 50 if (isset($_REQUEST["name"])) { 51 $artlib->replace_topic_name($_REQUEST["topicid"], $_REQUEST["name"]); 52 $topic_info['name'] = $_REQUEST['name']; 53 } 54 if (isset($_REQUEST['email']) && ! empty($_REQUEST['email'])) { 55 if (! validate_email($_REQUEST['email'])) { 56 Feedback::error(tra('Invalid email')); 57 $errors = true; 58 $smarty->assign('email', $_REQUEST['email']); 59 } else { 60 $tikilib->add_user_watch('admin', 'topic_article_created', $_REQUEST['topicid'], 'cms', $topic_info['name'], 'tiki-edit_topic.php?topicId=' . $_REQUEST['topicid'], $_REQUEST['email']); 61 $tikilib->add_user_watch('admin', 'topic_article_edited', $_REQUEST['topicid'], 'cms', $topic_info['name'], 'tiki-edit_topic.php?topicId=' . $_REQUEST['topicid'], $_REQUEST['email']); 62 $tikilib->add_user_watch('admin', 'topic_article_deleted', $_REQUEST['topicid'], 'cms', $topic_info['name'], 'tiki-edit_topic.php?topicId=' . $_REQUEST['topicid'], $_REQUEST['email']); 63 } 64 } 65 if (empty($errors)) { 66 header("Location: tiki-admin_topics.php"); 67 die; 68 } 69} 70include_once('tiki-section_options.php'); 71 72// disallow robots to index page: 73$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); 74 75$smarty->assign('mid', 'tiki-edit_topic.tpl'); 76$smarty->display("tiki.tpl"); 77