<?php require_once 'database/DBConfig.php'; require_once 'database/Database.php'; ################################################################### # INSTALL AND UNINSTALL # ################################################################### $installationManager = new InstallationManager(); $installationMangerView = new InstallationManagerView(); // display menu echo $installationMangerView->doManagerBox(); // if cliced Install button: install if ($installationMangerView->doInstall()) { $installationManager->install(); } // if cliced Uninstall button: uninstall if ($installationMangerView->doUninstall()) { $installationManager->uninstall(); } ################################################################### /** * MANAGER */ class InstallationManager { // table names const TABLE_MEMBER = 'member'; const TABLE_RECORDING = 'recording'; private $m_db = null; public function __construct() {
protected function action_realinstall() { if (!Permissions::has('sys_installation_install')) { return $this->redirectForbidden(); } $lang = i18n::load('diamondmvc-backend'); if (!isset($_REQUEST['base']) or !isset($_REQUEST['ids'])) { $this->result = array('success' => false, 'msg' => $lang->get('ERROR_MISSING_ARGUMENTS')); return; } $base = $_REQUEST['base']; $ids = $_REQUEST['ids']; $result = array(); $success = true; $jail = realpath(DIAMONDMVC_ROOT . '/uploads'); $ctrl = (new ControllerFileBrowser($this->db))->jail($jail); foreach ($ids as $id) { $path = $ctrl->buildPath($base, $id); if ($path === $jail) { logMsg('DiamondMVC Installation: invalid file "' . $jail . DS . $base . DS . $file . '", skipping', 9, false); $success = false; $result[$id] = false; } else { try { InstallationManager::install($path); $result[$id] = true; } catch (Exception $ex) { logMsg('DiamondMVC Installation: installation failed with exception "' . $ex->getMessage() . '"', 9, false); $success = false; $result[$id] = false; } } } $this->result = array('success' => $success, 'details' => $result); }