Exemplo n.º 1
0
 /**
  * Bootstrap PHPPE environament on remote server by running diagnostics
  */
 function bootstrap($item = "")
 {
     //! check rights
     if (!Core::$user->has("install")) {
         Core::log('A', "Suspicious behavior " . $url . " " . $this->getSiteUrl(), "extensions");
         return "PHPPE-E: " . L("Access denied");
     }
     //! get live image
     $data = file_get_contents("public/index.php");
     if (empty($data)) {
         return "PHPPE-E: " . L("No PHPPE Core?");
     }
     //! we cannot install localy, that would use webserver's user, forbidden to write.
     //! So we must use remote user identity even when host is localhost.
     try {
         //! save PHPPE Core
         //! call diagnostics mode, with and without root privileges
         $r = explode("\n", Tools::ssh("mkdir -p " . escapeshellarg(Core::$user->data['remote']['path'] . "/public") . " \\&\\& \\( cat \\>" . escapeshellarg(Core::$user->data['remote']['path'] . "/public/index.php") . " \\) \\&\\& \\( " . "php " . escapeshellarg(Core::$user->data['remote']['path'] . "/public/index.php") . " --diag \\; sudo php " . escapeshellarg(Core::$user->data['remote']['path'] . "/public/index.php") . " --diag \\)", $data));
     } catch (\Exception $e) {
         return "PHPPE-E: " . $e->getMessage();
     }
     //! check the result
     if (Extensions::isErr($r[0])) {
         Core::log('E', "Failed to bootstrap PHPPE to " . $this->getSiteUrl(), "extensions");
         return "PHPPE-E: " . sprintf(L("Failed to install %s"), "Core") . "\nPHPPE-E: " . $this->getSiteUrl() . "\n\n" . implode("\n", $r);
     }
     Core::log('A', "Installed PHPPE to " . $this->getSiteUrl(), "extensions");
     return "PHPPE-I: " . sprintf(L("Installed %d files from %s"), 1, "public/index.php") . "\nPHPPE-I: " . $this->getSiteUrl() . "\n\n" . implode("\n", $r);
 }