[Commits] r657 - in trunk/webinterface: core mods/super/vservers
new-commit at lists.openvcp.org
new-commit at lists.openvcp.org
Mon Feb 23 15:16:39 UTC 2009
Author: cryptronic
Date: 2009-02-23 15:16:39 +0000 (Mon, 23 Feb 2009)
New Revision: 657
Added:
trunk/webinterface/mods/super/vservers/backup.php
Modified:
trunk/webinterface/core/GUI.php
Log:
Frontend for userbackuproutine
Modified: trunk/webinterface/core/GUI.php
===================================================================
--- trunk/webinterface/core/GUI.php 2009-02-23 14:31:51 UTC (rev 656)
+++ trunk/webinterface/core/GUI.php 2009-02-23 15:16:39 UTC (rev 657)
@@ -696,12 +696,19 @@
* @param string $method
* @return int
*/
- public function form($element = 0, $name, $action, $method = "POST"){
+ public function form($element = 0, $name, $action, $method = "POST", $additions = null){
$id = $this->createElementId();
+ $addition = "";
+ if($additions != null) {
+ foreach($additions as $key => $value)
+ {
+ $addition .= " $key=\"$value\"";
+ }
+ }
if($element == 0)
- $this->contentData .= "<form name=\"" . $name . "\" action=\"" . $action . "\" method=\"" . $method . "\">{eId" . $id . "}</form>\n";
+ $this->contentData .= "<form name=\"" . $name . "\" action=\"" . $action . "\" method=\"" . $method . "\"$addition>{eId" . $id . "}</form>\n";
else
- $this->contentData = str_replace("{eId" . $element . "}","<form name=\"" . $name . "\" action=\"" . $action . "\" method=\"" . $method . "\">{eId" . $id . "}</form>{eId" . $element . "}\n", $this->contentData);
+ $this->contentData = str_replace("{eId" . $element . "}","<form name=\"" . $name . "\" action=\"" . $action . "\" method=\"" . $method . "\"$addition>{eId" . $id . "}</form>{eId" . $element . "}\n", $this->contentData);
return $id;
}
Added: trunk/webinterface/mods/super/vservers/backup.php
===================================================================
--- trunk/webinterface/mods/super/vservers/backup.php (rev 0)
+++ trunk/webinterface/mods/super/vservers/backup.php 2009-02-23 15:16:39 UTC (rev 657)
@@ -0,0 +1,249 @@
+<?php
+/**
+ * OpenVCP Webinterface
+ * Copyright (C) 2006 Gerrit Wyen <gerrit at t4a.net>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * @author Oliver Werner / OpenVCP Team
+ * @version 0.4.0.1
+ * @package OpenVCP-v0.4
+ */
+$AUTH =& OpenVCP::call('Auth', 'getReference');
+$GUI =& OpenVCP::call('GUI' , 'getReference');
+$XML =& OpenVCP::call('XML', 'getReference');
+$PARAMS =& OpenVCP::getParams();
+$USERINFO = $AUTH->user_information;
+
+require_once('AdminFactory.class.php');
+require_once('VserverFactory.class.php');
+require_once('NodeFactory.class.php');
+require_once("Customer.class.php");
+$ADMIN = AdminFactory::getInstance()->getUserByID($USERINFO['id']);
+
+$nodename = $PARAMS[0];
+$vservername = $PARAMS[1];
+$node = NodeFactory::getNodeFactory()->getNodeByName($nodename);
+
+
+$vserver = VserverFactory::getInstance()->getVserverByNameAndNode($vservername, $node->getId());
+
+$task = "backup";
+
+require_once "navi.php";
+
+if(@$PARAMS[2] == "add") {
+
+ if(@isset($_POST['submit']))
+ {
+ $state = $vserver->getState();
+ $offline = false;
+ if($state == "Online")
+ {
+ $GUI->flushContent();
+ $GUI->div(_("stopping vserver")." ".$vserver->getName()."...", "left");
+ $GUI->flushContent();
+ $GUI->flushContent();
+ $dmesg = $vserver->controlStop();
+ $state = $vserver->getState();
+ if($state == "Offline")
+ {
+ $GUI->div(_("ok"), "rightgreen");
+ $GUI->flushContent();
+ }
+ else
+ {
+ $GUI->div(_("failed"), "rightred");
+ $GUI->p(_("error stopping vserver")." ".$vserver->getName()."!");
+ $GUI->p(_("please contact support")."!");
+ $GUI->flushContent();
+ exit();
+ }
+ $f = $GUI->fieldset(_("output"), "dmesg");
+ foreach($dmesg as $msg)
+ foreach(explode('<br />', $msg) as $line) {
+ $GUI->addToElementID($f, $line."<br />");
+ }
+ $GUI->flushContent();
+ }
+
+ $GUI->div(_("create backup"), "left");
+ $GUI->flushContent();
+ $GUI->flushContent();
+ sleep(2);
+ $backupname = $vserver->createBackup();
+ if($backupname != "")
+ {
+ $GUI->div(_("ok"), "rightgreen");
+ $GUI->div(_("starting vserver")." ".$vserver->getName()."...", "left");
+ $GUI->flushContent();
+ $GUI->flushContent();
+ $dmesg = $vserver->controlStart();
+ $GUI->flushContent();
+ $GUI->flushContent();
+ $state = $vserver->getState();
+ if($state == "Online")
+ {
+ $GUI->div(_("ok"), "rightgreen");
+ $GUI->flushContent();
+ }
+ else
+ {
+ $GUI->div(_("failed"), "rightred");
+ $GUI->p(_("error starting vserver")." ".$vserver->getName()."!");
+ $GUI->p(_("please contact support")."!");
+ $GUI->flushContent();
+ }
+ $f = $GUI->fieldset(_("output"), "dmesg");
+ foreach($dmesg as $msg)
+ foreach(explode('<br />', $msg) as $line) {
+ $GUI->addToElementID($f, $line."<br />");
+ }
+ $GUI->p(_("new backup name is").": ".$backupname);
+ }
+ else
+ {
+ $GUI->div(_("failed"), "rightred");
+ $GUI->p(_("error backuping vserver")." ".$vserver->getName()."!");
+ $GUI->p(_("please contact support")."!");
+ $GUI->flushContent();
+ }
+ }
+ else
+ {
+ $f = $GUI->fieldset(_("backup vserver"));
+ $form = $GUI->form($f, "take_backup", "add/submit");
+ $GUI->p(_("do you want to create a backup of the vserver")."?",$form);
+ $GUI->p(_("attention: system will be stopped for backup process")."?",$form);
+ $GUI->formAddInputElement($form, "submit", "submit", _("take backup"));
+ }
+ exit(0);
+}
+else if(@$PARAMS[2] == "action") {
+ if(isset($_POST['delete'])) {
+ $backups = $vserver->getBackups();
+ $state = $vserver->deleteBackup($backups[$_POST['backups']]);
+ if($state == "Success") {
+ $GUI->p(_("image")." ".$backups[$_POST['backups']]." "._("successfully deleted"));
+ }
+ else {
+ $GUI->p(_("image")." ".$backups[$_POST['backups']]." "._("not deleted"));
+ }
+ }
+ if(isset($_POST['restore'])) {
+ $state = $vserver->getState();
+ $offline = false;
+ if($state == "Online")
+ {
+ $GUI->flushContent();
+ $GUI->div(_("stopping vserver")." ".$vserver->getName()."...", "left");
+ $GUI->flushContent();
+ $GUI->flushContent();
+ $dmesg = $vserver->controlStop();
+ $state = $vserver->getState();
+ if($state == "Offline")
+ {
+ $GUI->div(_("ok"), "rightgreen");
+ $GUI->flushContent();
+ }
+ else
+ {
+ $GUI->div(_("failed"), "rightred");
+ $GUI->p(_("error stopping vserver")." ".$vserver->getName()."!");
+ $GUI->p(_("please contact support")."!");
+ $GUI->flushContent();
+ exit();
+ }
+ $f = $GUI->fieldset(_("output"), "dmesg");
+ foreach($dmesg as $msg)
+ foreach(explode('<br />', $msg) as $line) {
+ $GUI->addToElementID($f, $line."<br />");
+ }
+ $GUI->flushContent();
+ }
+
+ $backups = $vserver->getBackups();
+ $GUI->div(_("restore backup")." ".$backups[$_POST['backups']], "left");
+ $GUI->flushContent();
+ $GUI->flushContent();
+ sleep(2);
+ $state = $vserver->restoreBackup($backups[$_POST['backups']]);
+
+ if($state == "Success")
+ {
+ $GUI->div(_("ok"), "rightgreen");
+ $GUI->div(_("starting vserver")." ".$vserver->getName()."...", "left");
+ $GUI->flushContent();
+ $GUI->flushContent();
+ $dmesg = $vserver->controlStart();
+ $GUI->flushContent();
+ $GUI->flushContent();
+ $state = $vserver->getState();
+ if($state == "Online")
+ {
+ $GUI->div(_("ok"), "rightgreen");
+ $GUI->p(_("system restored"));
+ $GUI->flushContent();
+ }
+ else
+ {
+ $GUI->div(_("failed"), "rightred");
+ $GUI->p(_("error starting vserver")." ".$vserver->getName()."!");
+ $GUI->p(_("please contact support")."!");
+ $GUI->p(_("system restored"));
+ $GUI->flushContent();
+ }
+ $f = $GUI->fieldset(_("output"), "dmesg");
+ foreach($dmesg as $msg)
+ foreach(explode('<br />', $msg) as $line) {
+ $GUI->addToElementID($f, $line."<br />");
+ }
+ }
+ else
+ {
+ $GUI->div(_("failed"), "rightred");
+ $GUI->p(_("error restoring vserver")." ".$vserver->getName()."!");
+ $GUI->p(_("please contact support")."!");
+ $GUI->flushContent();
+ }
+
+ }
+ exit(0);
+}
+
+$GUI->content("<script type=\"text/javascript\">function confirmSubmit(form){return confirm(\""._("are you sure?")."\");}</script>");
+
+$GUI->h("Please do not use heavy development", 1);
+
+$f = $GUI->fieldset(_("backup"));
+
+$backups = $vserver->getBackups();
+
+$form = $GUI->form($f, "backups_list", (@$PARAMS[2] != "action" ? $PARAMS[1] . "/action" : "action"), "POST", array('onsubmit' => 'return confirmSubmit(this)'));
+$table = $GUI->table($form);
+$row = $GUI->tableAddRow($table);
+$GUI->tableAddCol($row, _("name"));
+$GUI->tableAddCol($row, " ");
+$backupkeys=$backups;
+sort($backups);
+foreach($backups as $backup)
+{
+ $row = $GUI->tableAddRow($table);
+ $GUI->tableAddCol($row, $backup);
+ $GUI->formAddCheckelement($GUI->tableAddCol($row, ""), "radio", "backups", array_search($backup, $backupkeys));
+}
+$GUI->formAddInputElement($form, "submit", "delete", _("delete"));
+$GUI->formAddInputElement($form, "submit", "restore", _("restore"));
+?>
More information about the Commits
mailing list