9 require_once(
"../class/config.php");
12 "action" => array (
"request",
"string",
''),
13 "script" => array (
"request",
"boolean", 0),
17 if (in_array($action, array(
'start',
'stop',
'monit'))) {
18 $res =
$hooks->invoke($action, array(),
'lxc');
28 if ($lxc->error && !$script) {
35 header(
"Content-Type: text/plain");
37 echo
"ACTION:".$action.
"\n";
38 echo
"RETURN:".intval(
$res[
'lxc']).
"\n";
41 echo
"VM_STATUS:OK\n";
42 echo
"VM_START:".$infos[
'starttime'].
"\n";
43 echo
"VM_HOSTNAME:".$infos[
'hostname'].
"\n";
44 foreach(
$infos[
'ssh-keys'] as $k)
46 echo
"VM_SSHKEY:".trim($k).
"\n";
48 echo
"VM_STATUS:NONE\n";
53 # Show the header after the "if script" ;)
54 include_once(
"head.php");
58 <h3><?php
__(
'Console access'); ?></h3>
63 echo
$msg->msg_html_all();
69 <p
class=
"alert alert-info"><?php
__(
"You can start a virtual machine."); ?></p>
70 <form method=
"post" action=
"vm.php">
72 <input type=
"hidden" name=
"action" value=
"start" />
73 <input type=
"submit" class=
"inb ok" name=
"go" value=
"<?php __("Click here to start a
virtual machine.
"); ?>" />
77 echo
"<table class='tedit'>";
78 echo
"<tr><th>"._(
"Hostname").
"</th><td>".
$infos[
'hostname'].
"</td></tr>";
79 echo
"<tr><th>"._(
"Start time").
"</th><td>".date(
'Y-m-d H:i:s',
$infos[
'starttime']).
"</td></tr>";
80 echo
"<tr><th>"._(
"SSH Fingerprint").
"</th><td style=\"font-family: Courier, fixed;\">".implode(
'<br />',
$infos[
'ssh-keys']).
"</td></tr>";
81 echo
"<tr><th>"._(
"Useful command").
"</th><td><pre>";
82 echo
"ssh ".$mem->user[
'login'].
"@".
$infos[
'hostname'].
"\n";
83 echo
"rsync ".$mem->user[
'login'].
"@".
$infos[
'hostname'].
"\n";
84 echo
"</pre></td></tr>";
87 <p
class=
"alert alert-info"><?php
__(
"You can stop your virtual machine."); ?></p>
88 <form method=
"post" action=
"vm.php">
90 <input type=
"hidden" name=
"action" value=
"stop" />
91 <input type=
"submit" class=
"inb cancel" name=
"go" value=
"<?php __("Click here to stop your running
virtual machine.
"); ?>" />
101 <h3><?php
__(
"Tips"); ?></h3>
103 <div
id=
"tabs-tips-vm">
106 <li
class=
"help"><a href=
"#tabs-tips-soft"><?php
__(
"Available softwares"); ?></a></li>
107 <li
class=
"help"><a href=
"#tabs-tips-script"><?php
__(
"Remotely start/stop a VM"); ?></a></li>
111 <div
id=
'tabs-tips-script'>
112 <?php
__(
"You can script the launch the console access in command line by using this url:"); ?>
114 <?php
__(
"You can halt the vm by using:"); ?>
116 <?php
__(
"And you can see existing vm information (if the vm is running) by using:"); ?>
118 <i><?php
__(
"Warning: if you do not use HTTPS, your password will be transfered without any protection"); ?></i>
121 <div
id=
'tabs-tips-soft'>
122 <?php
__(
"To access a remote console with SSH, you can use Putty.");?>
124 <?php
__(
"To transfer files, you can use Filezilla in SFTP mode."); ?>
127 </div><!-- tabs-tips-
vm -->
129 <script type=
"text/javascript">
130 $(
function() {$(
"#tabs-tips-vm" ).tabs();});
134 include_once(
"foot.php");
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
$fields
LXC vm management code.
if(in_array($action, array('start', 'stop', 'monit'))) switch($action) if($lxc->error &&! $script) $infos