2013-05-03 10:10:28 +00:00
|
|
|
<?php
|
|
|
|
// SeedDMS. Document Management System
|
|
|
|
// Copyright (C) 2013 Uwe Steinmann
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
include("../inc/inc.Settings.php");
|
2014-12-08 13:47:32 +00:00
|
|
|
include("../inc/inc.Language.php");
|
|
|
|
include("../inc/inc.Init.php");
|
2013-05-03 10:10:28 +00:00
|
|
|
include("../inc/inc.LogInit.php");
|
|
|
|
include("../inc/inc.DBInit.php");
|
2018-03-12 17:33:30 +00:00
|
|
|
include("../inc/inc.Extension.php");
|
2013-05-03 10:10:28 +00:00
|
|
|
include("../inc/inc.ClassUI.php");
|
2018-03-12 17:33:30 +00:00
|
|
|
include("../inc/inc.ClassController.php");
|
2013-05-03 10:10:28 +00:00
|
|
|
include("../inc/inc.Authentication.php");
|
|
|
|
|
2018-03-12 17:33:30 +00:00
|
|
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
|
|
|
$controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
|
2013-05-03 10:10:28 +00:00
|
|
|
if (!$user->isAdmin()) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the form data comes for a trusted request */
|
|
|
|
if(!checkFormKey('extensionmgr')) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
|
|
|
|
}
|
|
|
|
|
2018-03-12 17:33:30 +00:00
|
|
|
if (isset($_POST["action"])) $action=$_POST["action"];
|
|
|
|
else $action=NULL;
|
|
|
|
|
2018-03-14 17:56:28 +00:00
|
|
|
if (isset($_POST["currenttab"])) $currenttab=$_POST["currenttab"];
|
|
|
|
else $currenttab=NULL;
|
|
|
|
|
2018-03-12 17:33:30 +00:00
|
|
|
// add new attribute definition ---------------------------------------------
|
|
|
|
if ($action == "download") {
|
|
|
|
if (!isset($_POST["extname"])) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
|
|
|
|
}
|
|
|
|
$extname = trim($_POST["extname"]);
|
|
|
|
if (!file_exists($settings->_rootDir.'/ext/'.$extname) ) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("missing_extension"));
|
|
|
|
}
|
2018-03-13 17:38:30 +00:00
|
|
|
// $extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir);
|
2018-03-12 17:33:30 +00:00
|
|
|
$controller->setParam('extmgr', $extMgr);
|
|
|
|
$controller->setParam('extname', $extname);
|
|
|
|
if (!$controller($_POST)) {
|
2019-12-20 16:20:15 +00:00
|
|
|
echo json_encode(array('success'=>false, 'msg'=>'Could not download extension'));
|
2018-03-12 17:33:30 +00:00
|
|
|
}
|
|
|
|
add_log_line();
|
|
|
|
} /* }}} */
|
2018-03-13 13:38:49 +00:00
|
|
|
elseif ($action == "refresh") { /* {{{ */
|
2018-03-13 17:38:30 +00:00
|
|
|
// $extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir);
|
2018-03-12 17:33:30 +00:00
|
|
|
$extMgr->createExtensionConf();
|
|
|
|
$controller->setParam('extmgr', $extMgr);
|
|
|
|
if (!$controller($_POST)) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
|
|
|
|
}
|
2018-03-13 13:38:49 +00:00
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_extension_refresh')));
|
2018-03-12 17:33:30 +00:00
|
|
|
add_log_line();
|
2018-03-14 17:56:28 +00:00
|
|
|
header("Location:../out/out.ExtensionMgr.php?currenttab=".$currenttab);
|
2018-03-13 13:38:49 +00:00
|
|
|
} /* }}} */
|
|
|
|
elseif ($action == "upload") { /* {{{ */
|
2018-04-19 17:47:20 +00:00
|
|
|
if(!$extMgr->isWritableExtDir()) {
|
2018-03-14 10:47:06 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("extension_mgr_no_upload"));
|
|
|
|
}
|
2018-03-12 17:33:30 +00:00
|
|
|
if($_FILES['userfile']['error']) {
|
2020-08-27 10:15:21 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("extension_mgr_error_upload"));
|
2018-03-12 17:33:30 +00:00
|
|
|
}
|
2020-02-26 20:07:48 +00:00
|
|
|
if(!in_array($_FILES['userfile']['type'], array('application/zip', 'application/x-zip-compressed'))) {
|
2020-08-27 10:15:21 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("extension_mgr_no_zipfile"));
|
2018-03-12 17:33:30 +00:00
|
|
|
}
|
2018-03-13 17:38:30 +00:00
|
|
|
// $extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir);
|
2018-03-12 17:33:30 +00:00
|
|
|
$controller->setParam('extmgr', $extMgr);
|
|
|
|
$controller->setParam('file', $_FILES['userfile']['tmp_name']);
|
|
|
|
if (!$controller($_POST)) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
|
|
|
|
}
|
2018-03-13 13:38:49 +00:00
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_extension_import')));
|
2018-03-12 17:33:30 +00:00
|
|
|
add_log_line();
|
2018-03-14 17:56:28 +00:00
|
|
|
header("Location:../out/out.ExtensionMgr.php?currenttab=".$currenttab);
|
2018-03-13 13:38:49 +00:00
|
|
|
} /* }}} */
|
|
|
|
elseif ($action == "import") { /* {{{ */
|
|
|
|
if(!$_POST['url']) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
|
|
|
|
}
|
2020-03-02 08:18:16 +00:00
|
|
|
$file = $extMgr->getExtensionFromRepository($_POST['url']);
|
|
|
|
/*
|
2018-03-21 14:24:45 +00:00
|
|
|
$reposurl = $settings->_repositoryUrl;
|
2018-03-13 13:38:49 +00:00
|
|
|
$content = file_get_contents($reposurl."/".$_POST['url']);
|
|
|
|
$file = tempnam(sys_get_temp_dir(), '');
|
|
|
|
file_put_contents($file, $content);
|
2020-03-02 08:18:16 +00:00
|
|
|
*/
|
2018-03-13 13:38:49 +00:00
|
|
|
|
2018-03-13 17:38:30 +00:00
|
|
|
// $extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir);
|
2018-03-13 13:38:49 +00:00
|
|
|
$controller->setParam('extmgr', $extMgr);
|
|
|
|
$controller->setParam('file', $file);
|
|
|
|
$_POST['action'] = 'upload';
|
|
|
|
if (!$controller($_POST)) {
|
|
|
|
unlink($file);
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
|
|
|
|
}
|
|
|
|
unlink($file);
|
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_extension_upload')));
|
|
|
|
add_log_line();
|
2018-03-14 17:56:28 +00:00
|
|
|
header("Location:../out/out.ExtensionMgr.php?currenttab=".$currenttab);
|
2018-03-13 13:38:49 +00:00
|
|
|
} /* }}} */
|
2018-03-21 12:39:38 +00:00
|
|
|
elseif ($action == "getlist") { /* {{{ */
|
|
|
|
$v = new SeedDMS_Version();
|
|
|
|
$controller->setParam('extmgr', $extMgr);
|
|
|
|
$controller->setParam('forceupdate', (isset($_POST['forceupdate']) && $_POST['forceupdate']) ? true : false);
|
|
|
|
$controller->setParam('version', $v->version());
|
|
|
|
if (!$controller($_POST)) {
|
2018-03-27 12:05:04 +00:00
|
|
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_extension_getlist').": ".$controller->getErrorMsg(), 'timeout'=>5000));
|
2018-03-21 12:39:38 +00:00
|
|
|
} else {
|
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_extension_getlist')));
|
|
|
|
}
|
|
|
|
add_log_line();
|
|
|
|
header("Location:../out/out.ExtensionMgr.php?currenttab=".$currenttab);
|
2019-12-20 16:20:15 +00:00
|
|
|
} elseif ($action == "toggle") { /* {{{ */
|
|
|
|
if (!isset($_POST["extname"])) {
|
|
|
|
echo json_encode(array('success'=>false, 'msg'=>'Could not toggle extension'));
|
|
|
|
}
|
|
|
|
$extname = trim($_POST["extname"]);
|
|
|
|
if (!file_exists($settings->_rootDir.'/ext/'.$extname) ) {
|
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("missing_extension"));
|
|
|
|
}
|
|
|
|
$controller->setParam('extmgr', $extMgr);
|
|
|
|
$controller->setParam('extname', $extname);
|
|
|
|
if (!$controller($_POST)) {
|
|
|
|
echo json_encode(array('success'=>false, 'msg'=>'Could not toggle extension'));
|
|
|
|
} else {
|
|
|
|
echo json_encode(array('success'=>true, 'msg'=>'Operation succeded'));
|
|
|
|
}
|
|
|
|
add_log_line();
|
2018-03-21 12:39:38 +00:00
|
|
|
} /* }}} */
|
2018-03-12 17:33:30 +00:00
|
|
|
|
2013-05-03 10:10:28 +00:00
|
|
|
|