1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11$section = 'cms'; 12require_once('tiki-setup.php'); 13$artlib = TikiLib::lib('art'); 14$access->check_feature('feature_articles'); 15// PERMISSIONS: NEEDS p_admin or tiki_p_articles_admin_topics 16$access->check_permission(['tiki_p_articles_admin_topics']); 17 18if (isset($_REQUEST["addtopic"])) { 19 check_ticket('admin-topics'); 20 if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) { 21 $filegallib = TikiLib::lib('filegal'); 22 try { 23 $filegallib->assertUploadedFileIsSafe($_FILES['userfile1']['tmp_name'], $_FILES['userfile1']['name']); 24 } catch (Exception $e) { 25 $smarty->assign('errortype', 403); 26 $smarty->assign('msg', $e->getMessage()); 27 $smarty->display("error.tpl"); 28 die; 29 } 30 $fp = fopen($_FILES['userfile1']['tmp_name'], "rb"); 31 $data = fread($fp, filesize($_FILES['userfile1']['tmp_name'])); 32 fclose($fp); 33 $imgtype = $_FILES['userfile1']['type']; 34 $imgsize = $_FILES['userfile1']['size']; 35 $imgname = $_FILES['userfile1']['name']; 36 } else { 37 $data = ''; 38 $imgtype = ''; 39 $imgsize = ''; 40 $imgname = ''; 41 } 42 // Store the image 43 $artlib->add_topic($_REQUEST["name"], $imgname, $imgtype, $imgsize, $data); 44} 45if (isset($_REQUEST["remove"])) { 46 $access->check_authenticity(tra('Are you sure you want to remove this topic?')); 47 $artlib->remove_topic($_REQUEST["remove"]); 48} 49if (isset($_REQUEST["removeall"])) { 50 $access->check_authenticity(tra('Are you sure you want to remove this topic AND all the articles related?')); 51 $artlib->remove_topic($_REQUEST["removeall"], 1); 52} 53if (isset($_REQUEST["activate"])) { 54 check_ticket('admin-topics'); 55 $artlib->activate_topic($_REQUEST["activate"]); 56} 57if (isset($_REQUEST["deactivate"])) { 58 check_ticket('admin-topics'); 59 $artlib->deactivate_topic($_REQUEST["deactivate"]); 60} 61$topics = $artlib->list_topics(); 62/* To renumber array keys from 0 since smarty 3 doesn't seem to like arrays 63 * that start with other keys in a section loop, which this variable is used in 64 */ 65$topics = array_values($topics); 66$smarty->assign('topics', $topics); 67ask_ticket('admin-topics'); 68include_once('tiki-section_options.php'); 69// disallow robots to index page: 70$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); 71$smarty->assign('mid', 'tiki-admin_topics.tpl'); 72$smarty->display("tiki.tpl"); 73