コード例 #1
0
ファイル: vnc.php プロジェクト: cherry-wb/Qemu
    public function action_default()
    {
        $GLOBALS['just_content'] = true;
        if (isset($_SESSION['user'])) {
            $vmID = $_GET['vmID'];
            try {
                $vm = new QemuVm($vmID);
            } catch (Exception $e) {
                return $content . "<div class='notice error'>Unbekannte VM</div>";
            }
            if ($vm->isOwner()) {
                if ($vm->status == QemuMonitor::RUNNING) {
                    $content = ' <!--[if !IE]>-->
					<applet archive="tightvnc-jviewer.jar"
			code="com.glavsoft.viewer.Viewer"
			width="820" height="640">
					<param name="archive" value="tightvnc-jviewer.jar" />
					<param code="com.glavsoft.viewer.Viewer" />

					<param name="Host" value="10.11.12.1" />
					<param name="Port" value="' . $vm->vnc_port . '" />
					<param name="OpenNewWindow" value="no" />
					<param name="Password" value="' . $vm->password . '"> 
					<param name="ShowControls" value="yes" />
					<param name="AllowClipboardTransfer" value="yes" />
					<param name="JpegImageQuality" value="Lossless" />
					</applet>';
                } else {
                    $content = "<div class='notice warning'>Die VM scheint aus zu sein</div>";
                }
            } else {
                $content = "<div class='notice error'>Du hast keinen Zugriff auf diese VM</div>";
            }
        } else {
            $content = "<div class='notice warning'>Du musst eingeloggt sein</div>";
        }
        return $content;
    }
コード例 #2
0
ファイル: myvm.php プロジェクト: cherry-wb/Qemu
 public function action_stop()
 {
     Routing::getInstance()->appendRender($this, "action_default");
     $vm = new QemuVm($_GET['vmID']);
     if ($vm->isOwner()) {
         if ($vm->status == QemuMonitor::RUNNING) {
             try {
                 $vm->connect();
             } catch (Exception $e) {
                 $vm->setStatus(QemuMonitor::SHUTDOWN);
                 return "<div class='notice warning'>Die VM scheint bereits aus zu sein.</div>";
             }
             if (!isset($e)) {
                 $vm->shutdown();
                 return "<div class='notice success'>Die VM wird ausgeschaltet.</div>";
             }
         } else {
             return "<div class='notice warning'>Die VM scheint bereits aus zu sein.</div>";
         }
     } else {
         return "<div class='notice error'>Sie besitzen nicht die Rechte die VM zu stoppen</div>";
     }
 }
コード例 #3
0
ファイル: screenshot.php プロジェクト: cherry-wb/Qemu
<?php

include './config.php';
include './classes/Helper.class.php';
Helper::loadClasses();
if (isset($_SESSION['user'])) {
    $vmID = (int) $_GET['vmID'];
    $vm = new QemuVm($vmID);
    if ($vm->isOwner()) {
        if ($vm->status == QemuMonitor::RUNNING) {
            $vm->connect();
            $path = $GLOBALS['config']['screenshot_dir'] . '/vm_' . $vm->vmID . '_' . date("Y_m_d_h_i_s");
            $screen = $vm->createScreenshot($path);
            if ($screen) {
                header("Content-Type: image/png");
                echo file_get_contents($path . ".png");
            } else {
                echo "Fehler";
            }
        }
    }
}
コード例 #4
0
ファイル: cron.php プロジェクト: cherry-wb/Qemu
<?php

include './config.php';
include './classes/Helper.class.php';
Helper::loadClasses();
$query = $GLOBALS['pdo']->prepare("SELECT * FROM vm WHERE status=:status AND persistent=:persistent");
$query->bindValue(":status", QemuMonitor::RUNNING, PDO::PARAM_INT);
$query->bindValue(":persisent", 0, PDO::PARAM_INT);
$query->execute();
while ($ds = $query->fetch()) {
    $last_ping = strtotime($ds['last_ping']);
    if ($last_ping < time() - (int) $GLOBALS['config']['ping_timeout']) {
        $vm = new QemuVm($ds['vmID']);
        try {
            $vm->connect();
        } catch (Exception $e) {
            $vm->setStatus(QemuMonitor::SHUTDOWN);
        }
        if (!isset($e)) {
            $vm->shutdown();
        }
    }
}
$query = null;
コード例 #5
0
ファイル: setvnc.php プロジェクト: cherry-wb/Qemu
<?php

include '../config.php';
include '../classes/Helper.class.php';
Helper::loadClasses();
if (isset($_SESSION['user'])) {
    $vmID = (int) $_GET['vmID'];
    $password = $_GET['pass'];
    $vm = new QemuVm($vmID);
    if (Server::hasRessources($vm->ram)) {
        if ($vm->isOwner()) {
            if ($vm->status == QemuMonitor::RUNNING) {
                $vm->connect();
                $vm->setVncPassword($password);
                echo "OK";
                die;
            }
        }
    }
}
echo "ERROR";
コード例 #6
0
ファイル: vnc.php プロジェクト: cherry-wb/Qemu
<?php

include 'config.php';
include 'classes/Helper.class.php';
Helper::loadClasses();
if (isset($_SESSION['user'])) {
    $vmID = $_GET['vmID'];
    $vm = new QemuVm($_GET['vmID']);
    if ($vm->isOwner()) {
        if ($vm->status == QemuMonitor::RUNNING) {
            header("Cache-Control: public");
            header("Content-Description: File Transfer");
            header("Content-Disposition: attachment; filename=VM_" . str_replace(" ", "_", $vm->name) . ".vnc");
            header("Content-Type: application/zip");
            header("Content-Transfer-Encoding: binary");
            echo '[connection]
host=10.11.12.1
port=' . $vm->vnc_port . '
[options]
viewonly=0
fullscreen=0
shared=1
belldeiconify=0
disableclipboard=0
restricted=0
swapmouse=0
emulate3=1
fitwindow=0
cursorshape=1
noremotecursor=0
preferred_encoding=7