예제 #1
0
 /**
  * Restore Kanso to factory
  *
  * @return bool
  */
 private function restorKansoDefaults()
 {
     # Grab the user's row from the session
     $user = \Kanso\Kanso::getInstance()->Session->get('KANSO_ADMIN_DATA');
     # Validate the user is an admin
     if ($user['role'] !== 'administrator') {
         return false;
     }
     # Reinstall from defaults
     $installer = new \Kanso\Install\Installer();
     if ($installer->installKanso(true)) {
         # Return
         return 'valid';
     }
     return false;
 }
예제 #2
0
파일: Kanso.php 프로젝트: kanso-cms/cms
 /**
  * Run the install script
  *
  * This method intializes the install script
  * and is called from $Kanso->run() when the application
  * is not installed
  */
 private function runInstall()
 {
     # Default is to do nothing
     $validRequest = false;
     # Get the installation directory
     $installDir = rtrim(dirname(__FILE__), '/');
     # Get the request URL
     $requestUrl = rtrim($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '/');
     # Convert the requested url to a directory
     $dirRequest = str_replace($_SERVER['HTTP_HOST'], $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'Kanso', $requestUrl);
     # Validate the request is for the location
     # of the installation
     if ($dirRequest === $installDir) {
         # Validate the install file exists
         if (!file_exists(__DIR__ . '/Install.php')) {
             throw new \Exception("Could not install Kanso. Install.php was not found on the server. Ensure you have renamed \"Install.sample.php\" to \"Install.php\".");
         }
         # Install the application if needed
         $installer = new \Kanso\Install\Installer();
         $installed = $installer->installKanso();
         # Show the welcome page
         include "Install/InstallSplash.php";
     }
     # Return the aplication was not installed
 }