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 8if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) { 9 die('This script may only be included.'); 10} 11require_once('tiki-setup.php'); 12 13global $tikidomain; 14$path = $tikidomain ? "storage/$tikidomain/dump_wiki.tar" : 'storage/dump_wiki.tar'; 15 16//*** begin state-changing actions 17if (! empty($_POST['w_use_dir']) && $access->checkCsrf()) { 18 if (substr($_POST['w_use_dir'], -1) != '\\' && substr($_POST['w_use_dir'], -1) != '/') { 19 //TODO don't change $_POST values directly 20 $_POST['w_use_dir'] .= '/'; 21 } 22 simple_set_value('w_use_dir'); 23} 24 25if (! empty($_POST['moveWikiUp']) && $access->checkCsrf()) { 26 $filegallib = TikiLib::lib('filegal'); 27 $errorsWikiUp = []; 28 $info = $filegallib->get_file_gallery_info($prefs['home_file_gallery']); 29 if (empty($info)) { 30 Feedback::error(tr('You must set a home file gallery')); 31 } else { 32 $filegallib->moveAllWikiUpToFgal($prefs['home_file_gallery']); 33 } 34} 35 36// Included for the forum dropdown 37if (isset($_POST['createtag']) && $access->checkCsrf()) { 38 // Check existence 39 if ($adminlib->tag_exists($_POST['newtagname'])) { 40 Feedback::error(tra('Tag already exists')); 41 } 42 $adminlib->create_tag($_POST['newtagname']); 43 Feedback::success(tr('Tag %0 created.', '<em>' . $_POST['newtagname'] . '</em>')); 44} 45 46if (isset($_POST['restoretag'])&& $access->checkCsrf()) { 47 // Check existance 48 if (! $adminlib->tag_exists($_POST['tagname'])) { 49 Feedback::error(tr('Tag %0 not found', '<em>' . $_POST['tagname'] . '</em>')); 50 } 51 $result = $adminlib->restore_tag($_POST['tagname']); 52 if ($result) { 53 Feedback::success(tr('Tag %0 restored.', '<em>' . $_POST['tagname'] . '</em>')); 54 } else { 55 Feedback::error(tr('Tag %0 not restored.', '<em>' . $_POST['tagname'] . '</em>')); 56 } 57} 58 59if (isset($_POST['removetag']) && $access->checkCsrf()) { 60 $result = $adminlib->remove_tag($_POST['tagname']); 61 if ($result) { 62 Feedback::success(tr('Tag %0 removed.', '<em>' . $_POST['tagname'] . '</em>')); 63 } else { 64 Feedback::error(tr('Tag %0 not removed.', '<em>' . $_POST['tagname'] . '</em>')); 65 } 66} 67 68if (isset($_POST['rmvunusedpic']) && $access->checkCsrf()) { 69 $adminlib->remove_unused_pictures(); 70 Feedback::success(tr('Process to remove pictures has completed.')); 71} 72//*** end state-changing actions 73 74if (isset($_REQUEST['createdump'])) { 75 include('lib/tar.class.php'); 76 error_reporting(E_ERROR | E_WARNING); 77 $adminlib->dump(); 78 if (is_file($path)) { 79 Feedback::success(tr('Dump created at %0', '<em>' . $path . '</em>')); 80 } else { 81 Feedback::error(tra('Dump was not created. Please check permissions for the storage/ directory.')); 82 } 83} 84 85if (isset($_REQUEST['removedump'])) { 86 @unlink($path); 87 if (! is_file($path)) { 88 Feedback::success(tr('Dump file %0 removed.', '<em>' . $path . '</em>')); 89 } else { 90 Feedback::error(tr('Dump file %0 was not removed.', '<em>' . $path . '</em>')); 91 } 92} 93 94if (isset($_REQUEST['downloaddump'])) { 95 global $tikidomain; 96 // Check existence 97 if ($tikidomain) { 98 $file = "storage/$tikidomain/dump_wiki.tar"; 99 } else { 100 $file = "storage/dump_wiki.tar"; 101 } 102 103 if (is_file($file)) { 104 header('Content-Description: File Transfer'); 105 header('Content-Type: application/octet-stream'); 106 header('Content-Disposition: attachment; filename="' . basename($file) . '"'); 107 header('Expires: 0'); 108 header('Cache-Control: must-revalidate'); 109 header('Pragma: public'); 110 header('Content-Length: ' . filesize($file)); 111 readfile($file); 112 exit; 113 } 114} 115 116$smarty->assign('isDump', is_file($path)); 117$smarty->assign('dumpPath', $path); 118$tags = $adminlib->get_tags(); 119$smarty->assign_by_ref('tags', $tags); 120