summaryrefslogtreecommitdiffstats
path: root/modules/minilinux.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-05-26 22:49:54 +0200
committerSimon Rettberg2014-05-26 22:49:54 +0200
commita4f4147b6fe5f2a003a61cf8a8f7508c94130b31 (patch)
treede34472a2b9bd83909469affb884619b4858efc1 /modules/minilinux.inc.php
parentWIP (diff)
downloadslx-admin-a4f4147b6fe5f2a003a61cf8a8f7508c94130b31.tar.gz
slx-admin-a4f4147b6fe5f2a003a61cf8a8f7508c94130b31.tar.xz
slx-admin-a4f4147b6fe5f2a003a61cf8a8f7508c94130b31.zip
WIP
Diffstat (limited to 'modules/minilinux.inc.php')
-rw-r--r--modules/minilinux.inc.php73
1 files changed, 64 insertions, 9 deletions
diff --git a/modules/minilinux.inc.php b/modules/minilinux.inc.php
index 6e68a34e..e2d85247 100644
--- a/modules/minilinux.inc.php
+++ b/modules/minilinux.inc.php
@@ -15,18 +15,73 @@ class Page_MiniLinux extends Page
protected function doRender()
{
- $files = array();
- mkdir(CONFIG_HTTP_DIR . "/default", 0755, true);
- $this->checkFile($files, 'kernel');
- $this->checkFile($files, 'initramfs-stage31');
- $this->checkFile($files, 'stage32.sqfs');
- $this->checkFile($files, 'vmware.sqfs');
- $this->checkFile($files, 'nvidia_libs.sqfs');
Render::addTemplate('page-minilinux', array(
- 'files' => $files,
- 'token' => Session::get('token')
+ 'listurl' => '?do=MiniLinux&async=true&action=list'
));
}
+
+ protected function doAjax()
+ {
+ $data = Property::getVersionCheckInformation();
+ if (!is_array($data) || !isset($data['systems'])) {
+ echo Render::parse('messagebox-error', array(
+ 'message' => 'Fehler beim Abrufen der Liste: ' . $data
+ ));
+ return;
+ }
+ $action = Request::any('action');
+ switch ($action) {
+ case 'list':
+ $count = 0;
+ foreach ($data['systems'] as &$system) {
+ foreach ($system['files'] as &$file) {
+ $file['uid'] = 'dlid' . $count++;
+ $local = CONFIG_HTTP_DIR . '/' . $system['id'] . '/' . $file['name'];
+ if (!file_exists($local) || md5_file($local) !== substr($file['md5'], 0, 32)) {
+ $file['changed'] = true;
+ }
+ }
+ }
+ echo Render::parse('minilinux/filelist', array(
+ 'systems' => $data['systems'],
+ 'token' => Session::get('token')
+ ));
+ return;
+ case 'download':
+ $id = Request::post('id');
+ $name = Request::post('name');
+ if (!$id || !$name || strpos("$id$name", '/') !== false) {
+ echo "Invalid download request";
+ return;
+ }
+ $found = false;
+ foreach ($data['systems'] as &$system) {
+ if ($system['id'] !== $id) continue;
+ foreach ($system['files'] as &$file) {
+ if ($file['name'] !== $name) continue;
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ echo "Nonexistent system/file: $id / $name";
+ return;
+ }
+ $task = Taskmanager::submit('DownloadFile', array(
+ 'url' => CONFIG_REMOTE_ML . '/' . $id . '/' . $name,
+ 'destination' => CONFIG_HTTP_DIR . '/' . $id . '/' . $name
+ ));
+ if (!isset($task['id'])) {
+ echo 'Error launching download task: ' . $task['statusCode'];
+ return;
+ }
+ echo Render::parse('minilinux/download', array(
+ 'name' => $name,
+ 'task' => $task['id']
+ ));
+ return;
+ }
+ }
private function checkFile(&$files, $name)
{