summaryrefslogtreecommitdiffstats
path: root/application/modules/backend
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/backend')
-rw-r--r--application/modules/backend/controllers/BootmediaController.php53
-rw-r--r--application/modules/backend/controllers/JsonController.php84
-rw-r--r--application/modules/backend/controllers/MenuController.php210
-rw-r--r--application/modules/backend/controllers/MkisoController.php283
-rw-r--r--application/modules/backend/controllers/SystemController.php273
-rw-r--r--application/modules/backend/controllers/UserController.php18
-rw-r--r--application/modules/backend/views/scripts/bootmedia/index.phtml1
-rw-r--r--application/modules/backend/views/scripts/bootmedia/list.phtml20
-rw-r--r--application/modules/backend/views/scripts/menu/index.phtml1
-rw-r--r--application/modules/backend/views/scripts/menu/list.phtml15
-rw-r--r--application/modules/backend/views/scripts/menu/listassignments.phtml18
-rw-r--r--application/modules/backend/views/scripts/menu/listentries.phtml19
-rw-r--r--application/modules/backend/views/scripts/mkiso/index.phtml1
-rw-r--r--application/modules/backend/views/scripts/system/add.phtml1
-rw-r--r--application/modules/backend/views/scripts/system/addkernel.phtml0
-rw-r--r--application/modules/backend/views/scripts/system/index.phtml1
-rw-r--r--application/modules/backend/views/scripts/system/sync.phtml0
-rw-r--r--application/modules/backend/views/scripts/system/updateinitramfs.phtml0
-rw-r--r--application/modules/backend/views/scripts/system/updatekernel.phtml0
-rw-r--r--application/modules/backend/views/scripts/user/index.phtml1
20 files changed, 999 insertions, 0 deletions
diff --git a/application/modules/backend/controllers/BootmediaController.php b/application/modules/backend/controllers/BootmediaController.php
new file mode 100644
index 0000000..1e0de8c
--- /dev/null
+++ b/application/modules/backend/controllers/BootmediaController.php
@@ -0,0 +1,53 @@
+<?php
+
+class Backend_BootmediaController extends Zend_Controller_Action
+{
+ private $_mbootmedia;
+ private $_logger;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ #$this->_helper->viewRenderer->setNoRender();
+
+ $this->_mbootmedia = new Model_Bootmedia();
+
+
+ $this->_logger = new Zend_Log();
+ $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');
+
+ $this->_logger->addWriter($w);
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+ public function delAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+
+ $id = $this->getRequest()->getParam("id");
+
+ $w = $this->_mbootmedia->getAdapter()->quoteInto('id = ?', $id);
+ $this->_mbootmedia->delete($w);
+ }
+
+ public function listAction()
+ {
+ $data = $this->_mbootmedia->fetchAll()->toArray();
+ $this->view->listdata = $data;
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/backend/controllers/JsonController.php b/application/modules/backend/controllers/JsonController.php
new file mode 100644
index 0000000..61da947
--- /dev/null
+++ b/application/modules/backend/controllers/JsonController.php
@@ -0,0 +1,84 @@
+<?php
+
+class Backend_JsonController extends Zend_Controller_Action
+{
+ private $_mkernel;
+ private $_msources;
+ private $_msystems;
+ private $_mbootmedia;
+ private $_mmenus;
+ private $_logger;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $this->_mkernels = new Model_Kernels();
+ $this->_mmenus = new Model_Menus();
+ $this->_msources = new Model_Sources();
+ $this->_msystems = new Model_Systems();
+ $this->_mbootmedia = new Model_Bootmedia();
+
+
+ $this->_logger = new Zend_Log();
+ $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');
+
+ $this->_logger->addWriter($w);
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+ public function kernelAction()
+ {
+ $kernels = $this->_mkernels->fetchAll()->toArray();
+ echo (json_encode($kernels));
+ }
+
+ public function menuAction()
+ {
+ $menus = $this->_mmenus->fetchAll()->toArray();
+ echo (json_encode($menus));
+ }
+
+ public function bootmediaAction()
+ {
+ $bootmedia= $this->_mbootmedia->fetchAll()->toArray();
+ echo (json_encode($bootmedia));
+ }
+
+ public function sourcesAction()
+ {
+ $sources = $this->_msources->fetchAll()->toArray();
+ echo (json_encode($sources));
+
+ }
+
+ public function systemsAction()
+ {
+ $ip = $this->getRequest()->getParam('ip');
+ if (!empty($ip)) {
+ $s = $this->_msystems->select();
+ $s->where('source = ?', $ip);
+ $systems = $this->_msystems->fetchAll($s)->toArray();
+ } else {
+ $systems = $this->_msystems->fetchAll()->toArray();
+ }
+ echo (json_encode($systems));
+ }
+
+
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/backend/controllers/MenuController.php b/application/modules/backend/controllers/MenuController.php
new file mode 100644
index 0000000..f8c6a7f
--- /dev/null
+++ b/application/modules/backend/controllers/MenuController.php
@@ -0,0 +1,210 @@
+<?php
+
+class Backend_MenuController extends Zend_Controller_Action
+{
+ private $_mmenus;
+ private $_mmenu_entries;
+ private $_mmenu_assignments;
+ private $_mmenu_assignment_iprules;
+ private $_mmenu_assignment_bmrules;
+
+ private $_logger;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ #$this->_helper->viewRenderer->setNoRender();
+
+ $this->_mmenus = new Model_Menus();
+ $this->_mmenu_entries = new Model_Menuentries();
+ $this->_mmenu_assignments = new Model_Menuassignments();
+ $this->_mmenu_assignment_iprules = new Model_Menuassignmentip();
+ $this->_mmenu_assignment_bmrules = new Model_Menuassignmentbm();
+
+
+ $this->_logger = new Zend_Log();
+ $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');
+
+ $this->_logger->addWriter($w);
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+ public function listentriesAction()
+ {
+ $mid = $this->getRequest()->getParam('id');
+ $s = $this->_mmenu_entries->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
+ $s->setIntegrityCheck(false)
+ ->where('menu_id = ?', $mid)
+ ->joinLeft(array('s' => 'systems'), 's.id = menu_entries.system_id',
+ array('s_name' => 'name',
+ 's_external_id' => 'external_id',
+ 's_source' => 'source'))
+ ->order('entry_order');
+ $data = $this->_mmenu_entries->fetchAll($s)->toArray();
+ $this->view->listdata = $data;
+ }
+
+ public function listAction()
+ {
+ $data = $this->_mmenus->fetchAll()->toArray();
+ $this->view->listdata = $data;
+ }
+
+ public function addAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+ $name = $this->getRequest()->getParam("name");
+ $description = $this->getRequest()->getParam("description");
+
+ #TODO: make themes selectable
+ $db_data = array(
+ "name" => $name,
+ "description" => $description,
+ "theme" => "openslx"
+ );
+
+ $this->_mmenus->insert($db_data);
+
+ }
+
+ public function delAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+
+ $id = $this->getRequest()->getParam("id");
+
+ $w = $this->_mmenus->getAdapter()->quoteInto('id = ?', $id);
+ $this->_mmenus->delete($w);
+
+ $w = $this->_mmenu_entries->getAdapter()->quoteInto('menu_id = ?', $id);
+ $this->_mmenu_entries->delete($w);
+
+ }
+
+ public function addentryAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+
+ $menu = $this->getRequest()->getParam("menu");
+ $system = $this->getRequest()->getParam("system");
+ $altCaptionSet = $this->getRequest()->getParam("altCaptionSet");
+ $altCaption = ($altCaptionSet) ? $this->getRequest()->getParam("altCaption") : null;
+ $altAppendSet = $this->getRequest()->getParam("altAppendSet");
+ $altAppend = ($altAppendSet) ? $this->getRequest()->getParam("altAppend") : null;
+
+ $db_data = array(
+ "menu_id" => $menu,
+ "system_id" => $system,
+ "overwrite_caption" => $altCaptionSet,
+ "overwrite_append" => $altAppendSet,
+ "alternative_caption" => $altCaption,
+ "alternative_append" => $altAppend
+ );
+
+ $this->_mmenu_entries->insert($db_data);
+
+ }
+
+ public function saveentryorderAction() {
+ $this->_helper->viewRenderer->setNoRender();
+ $data = $this->getRequest()->getParam("data");
+
+ $data = explode(';', $data);
+ foreach ($data as $d) {
+ if (!empty($d)) {
+ list($id, $order) = explode(':', $d);
+ $db_data = array(
+ 'entry_order' => $order
+ );
+ $w = $this->_mmenu_entries->getAdapter()->quoteInto('id = ?', $id);
+ $this->_mmenu_entries->update($db_data, $w);
+ }
+ }
+
+ }
+
+ public function delentryAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+
+ $id = $this->getRequest()->getParam("id");
+
+ $w = $this->_mmenu_entries->getAdapter()->quoteInto('id = ?', $id);
+ $this->_mmenu_entries->delete($w);
+ }
+
+ public function listassignmentsAction()
+ {
+ $l = $this->_logger;
+ $s = $this->_mmenu_assignments->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
+ $s->setIntegrityCheck(false)
+ ->joinLeft(array('m' => 'menus'), 'm.id = menu_assignments.menu_id',
+ array('m_name' => 'name'))
+ ->joinLeft(array('i' => 'menu_assignment_iprules'), 'i.menu_assignment_rule = menu_assignments.id',
+ array('i_ip' => 'ip',
+ 'i_netmask' => 'netmask'))
+ ->joinLeft(array('b' => 'menu_assignment_bmrules'), 'b.menu_assignment_rule = menu_assignments.id',
+ array('b_bootmedia_id' => 'bootmedia_id'))
+ ->joinLeft(array('bm' => 'bootmedia'), 'bm.id = b.bootmedia_id',
+ array('b_name' => 'name'))
+ ->order(array('menu_id', 'i_netmask', 'b_bootmedia'));
+ $l->info('[menucontroller] '. $s->assemble());
+ $data = $this->_mmenu_assignments->fetchAll($s)->toArray();
+ $this->view->listdata = $data;
+ }
+
+ public function addassignmentAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+
+ $name = $this->getRequest()->getParam("name");
+ $menu = $this->getRequest()->getParam("menu");
+ $bootmedia = $this->getRequest()->getParam("bootmedia");
+ $ip = $this->getRequest()->getParam("ip");
+
+ if (empty($ip) || !strpos($ip, "/")) {
+ $ip = ""; $netmask="";
+ } else {
+ list($ip, $netmask) = explode("/", $ip);
+ }
+
+ $db_data = array(
+ 'name' => $name,
+ 'menu_id' => $menu
+ );
+
+ $id = (int)$this->_mmenu_assignments->insert($db_data);
+
+ if ($bootmedia != "all") {
+ $db_data = array (
+ 'menu_assignment_rule' => $id,
+ 'bootmedia_id' => $bootmedia
+ );
+ $this->_mmenu_assignment_bmrules->insert($db_data);
+ }
+
+ if (!empty($ip)) {
+ $db_data = array (
+ 'menu_assignment_rule' => $id,
+ 'ip' => $ip,
+ 'netmask' => $netmask
+ );
+ $this->_mmenu_assignment_iprules->insert($db_data);
+ }
+
+ }
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/backend/controllers/MkisoController.php b/application/modules/backend/controllers/MkisoController.php
new file mode 100644
index 0000000..b0b4fd5
--- /dev/null
+++ b/application/modules/backend/controllers/MkisoController.php
@@ -0,0 +1,283 @@
+<?php
+
+class Backend_MkisoController extends Zend_Controller_Action
+{
+ private $_mkernel;
+ private $_msources;
+ private $_mbootmedia;
+ private $_logger;
+
+ private function smartCopy($source, $dest, $folderPermission=0755,$filePermission=0644){
+ $result=false;
+
+ if (is_file($source)) { # $source is file
+ if(is_dir($dest)) { # $dest is folder
+ if ($dest[strlen($dest)-1]!='/') # add '/' if necessary
+ $__dest=$dest."/";
+ $__dest .= basename($source);
+ }
+ else { # $dest is (new) filename
+ $__dest=$dest;
+ }
+ $result=copy($source, $__dest);
+ chmod($__dest,$filePermission);
+ }
+ elseif(is_dir($source)) { # $source is dir
+ if(!is_dir($dest)) { # dest-dir not there yet, create it
+ @mkdir($dest,$folderPermission);
+ chmod($dest,$folderPermission);
+ }
+ if ($source[strlen($source)-1]!='/') # add '/' if necessary
+ $source=$source."/";
+ if ($dest[strlen($dest)-1]!='/') # add '/' if necessary
+ $dest=$dest."/";
+
+ # find all elements in $source
+ $result = true; # in case this dir is empty it would otherwise return false
+ $dirHandle=opendir($source);
+ while($file=readdir($dirHandle)) { # note that $file can also be a folder
+ if($file!="." && $file!="..") { # filter starting elements and pass the rest to this function again
+ # echo "$source$file ||| $dest$file<br />\n";
+ $result=smartCopy($source.$file, $dest.$file, $folderPermission, $filePermission);
+ }
+ }
+ closedir($dirHandle);
+ }
+ else {
+ $result=false;
+ }
+ return $result;
+ }
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $this->_mkernels = new Model_Kernels();
+ $this->_msources = new Model_Sources();
+ $this->_mbootmedia = new Model_Bootmedia();
+
+
+ $this->_logger = new Zend_Log();
+ $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');
+
+ $this->_logger->addWriter($w);
+ }
+
+ private function delTree($dir) {
+ $files = glob( $dir . '*', GLOB_MARK );
+ foreach( $files as $file ){
+ if( substr( $file, -1 ) == '/' )
+ $this->delTree( $file );
+ else
+ unlink( $file );
+ }
+
+ if (is_dir($dir)) rmdir( $dir );
+
+ }
+
+ public function indexAction()
+ {
+
+ }
+
+ public function prepareAction() {
+ $l = $this->_logger;
+
+ $kernel = $this->getRequest()->getParam('kernel');
+ $name = $this->getRequest()->getParam('name');
+ $description = $this->getRequest()->getParam('description');
+ $identifier = dechex(mktime());
+
+ $tmppath = APPLICATION_PATH . "/../data/tmp";
+ $cdpath = $tmppath . "/cd";
+ $isoDir = "$cdpath/iso/isolinux";
+ $syslinuxpath = APPLICATION_PATH . "/../data/syslinux";
+
+
+ if (!is_dir($isoDir))
+ mkdir($isoDir, 0777, true);
+ $files = array('LICENSE', 'README.iso', 'vesamenu.c32', 'isolinux.bin');
+ foreach ($files as $f) copy ($syslinuxpath . "/$f", $isoDir . "/$f");
+ $l->info("copy syslinux files to tmp");
+
+ if ($kernel != "auto") {
+ $s = $this->_mkernels->select();
+ $s->where("kernel = ?", $kernel);
+ $r = $this->_mkernels->fetchAll($s)->toArray();
+ }
+
+ #TODO: fetch newest kernel or let user select kernel
+ if ($kernel == "auto" || empty($r)){
+ #TODO: build in some ordering to get the newest kernel..
+ #$s = $this->_mkernels->select();
+ $r = $this->_mkernels->fetchAll()->toArray();
+ }
+
+ $r = $r[0];
+
+ $kernel = $r['kernel'];
+ $kernelpath = APPLICATION_PATH . "/../data/kernels/$kernel";
+
+ $files = array('vmlinuz', 'initramfs');
+ foreach ($files as $f) copy ($kernelpath . "/$f", $isoDir . "/$f");
+ $l->info("copy kernel/initramfs to tmp");
+
+ $isolinuxConfig = "DEFAULT vesamenu.c32\n";
+ $isolinuxConfig .= "PROMPT 0\n";
+ $isolinuxConfig .= "TIMEOUT 100\n";
+ $isolinuxConfig .= file_get_contents($syslinuxpath . "/themes/openslx/theme.conf");
+
+ copy($syslinuxpath . "/themes/openslx/openslx.png", $isoDir . "/openslx.png");
+
+
+ $isolinuxConfig .= '
+MENU TITLE Welcome to OpenSLX PreBoot ISO/CD (Mini Linux/Kexec)
+LABEL SLXSTDBOOT
+ MENU LABEL OpenSLX PreBoot - Stateless Netboot Linux ...
+ MENU DEFAULT
+ KERNEL vmlinuz
+ APPEND initrd=initramfs vga=0x317 pbsId='.$identifier.'
+ TEXT HELP
+ Use this (default) entry if you have configured your client.
+ You have chance to edit the kernel commandline by hitting
+ the TAB key (e.g. for adding debug=3 to it for bug hunting).
+ ENDTEXT
+LABEL LOCALBOOT
+ MENU LABEL Boot locally (skip OpenSLX PreBoot) ...
+ LOCALBOOT -1
+ TEXT HELP
+ Gets you out of here by booting from next device in BIOS
+ boot order.
+ ENDTEXT';
+
+ file_put_contents($isoDir . "/isolinux.cfg", $isolinuxConfig);
+
+ $return = array(
+ "kernel" => $kernel,
+ "name" => $name,
+ "description" => $description,
+ "identifier" => $identifier,
+ "progress" => "30",
+ "progressmsg" => "creating iso",
+ "error" => false,
+ "errormsg" => ""
+ );
+
+ echo(json_encode($return));
+
+ }
+
+ public function createisoAction() {
+ $l = $this->_logger;
+
+ $kernel = $this->getRequest()->getParam('kernel');
+ $name = $this->getRequest()->getParam('name');
+ $description = $this->getRequest()->getParam('description');
+ $identifier = $this->getRequest()->getParam('identifier');
+
+ $tmppath = APPLICATION_PATH . "/../data/tmp";
+ $cdpath = $tmppath . "/cd";
+
+ $mkisofsCmd = 'mkisofs \
+ -o %s \
+ -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
+ -r -J -l -boot-info-table -joliet-long \
+ -publisher "OpenSLX Project - http://www.openslx.org" \
+ -p "OpenSLX Project - openslx-devel@openslx.org" \
+ -V "OpenSLX BootISO" \
+ -volset "OpenSLX Project - PreBoot ISO/CD for non PXE/TFTP start of a Linux Stateless Client" \
+ -c isolinux/boot.cat "%s/iso"';
+
+ $outDir = APPLICATION_PATH . "/../public/isos/$identifier";
+ if (!is_dir($outDir))
+ mkdir($outDir, 0777, true);
+
+ $iso = $outDir . "/openslx.iso";
+ $isolog = $outDir . "/openslx.iso.log";
+ $mkisofsCmd = sprintf ($mkisofsCmd, $iso, $cdpath);
+ $output = array();
+ $returnval = null;
+ exec($mkisofsCmd, $output, $returnval);
+
+ $l->info(print_r($output,true));
+
+ $return = array(
+ "kernel" => $kernel,
+ "name" => $name,
+ "description" => $description,
+ "identifier" => $identifier,
+ "progress" => "60",
+ "progressmsg" => "cleaning up",
+ "error" => false,
+ "errormsg" => ""
+ );
+
+ echo(json_encode($return));
+
+ }
+
+ public function cleanupAction() {
+ $l = $this->_logger;
+
+ $kernel = $this->getRequest()->getParam('kernel');
+ $name = $this->getRequest()->getParam('name');
+ $description = $this->getRequest()->getParam('description');
+ $identifier = $this->getRequest()->getParam('identifier');
+
+ $tmppath = APPLICATION_PATH . "/../data/tmp";
+ $cdpath = $tmppath . "/cd";
+
+ $this->delTree($cdpath);
+
+ $return = array(
+ "kernel" => $kernel,
+ "name" => $name,
+ "description" => $description,
+ "identifier" => $identifier,
+ "progress" => "80",
+ "progressmsg" => "update DB",
+ "error" => false,
+ "errormsg" => ""
+ );
+
+ echo(json_encode($return));
+ }
+
+ public function dbAction() {
+
+ $kernel = $this->getRequest()->getParam('kernel');
+ $name = $this->getRequest()->getParam('name');
+ $description = $this->getRequest()->getParam('description');
+ $identifier = $this->getRequest()->getParam('identifier');
+
+ $db_data = array(
+ kernel => $kernel,
+ name => $name,
+ identifier => $identifier,
+ description => $description,
+ theme => "openslx",
+ created => mktime(),
+ mediatype => "cd"
+ );
+
+ $this->_mbootmedia->insert($db_data);
+
+ $return = array(
+ "kernel" => $kernel,
+ "name" => $name,
+ "description" => $description,
+ "identifier" => $identifier,
+ "progress" => "80",
+ "progressmsg" => "update DB",
+ "error" => false,
+ "errormsg" => ""
+ );
+ echo(json_encode(array("progress" => "100", "progressmsg" => "FINISHED!")));
+ }
+
+
+
+}
diff --git a/application/modules/backend/controllers/SystemController.php b/application/modules/backend/controllers/SystemController.php
new file mode 100644
index 0000000..a13ed2a
--- /dev/null
+++ b/application/modules/backend/controllers/SystemController.php
@@ -0,0 +1,273 @@
+<?php
+
+class Backend_SystemController extends Zend_Controller_Action
+{
+
+ private $_msystems;
+ private $_mkernel;
+ private $_logger;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_msystems = new Model_Systems();
+ $this->_mkernels = new Model_Kernels();
+ $this->_msources = new Model_Sources();
+
+
+ $this->_logger = new Zend_Log();
+ $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');
+
+ $this->_logger->addWriter($w);
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+ public function updateinitramfsAction()
+ {
+ // we don't need any view for json output
+ $this->_helper->viewRenderer->setNoRender();
+
+ $l = $this->_logger;
+ $adapter = new Zend_File_Transfer_Adapter_Http();
+ $kernel = $this->getRequest()->getParam('kernel');
+
+ $s = $this->_mkernels->select();
+ $s->where('kernel=?', $data['kernel']);
+ $r = $this->_mkernels->fetchAll($s)->toArray();
+
+ $id = $r[0]['id'];
+
+ #TODO: bild in more checks
+ $targetpath = APPLICATION_PATH . "/../data/kernels/$kernel/";
+
+ if (!is_dir($targetpath))
+ mkdir($targetpath, 0777, true);
+
+ $adapter->setDestination($targetpath);
+
+ #todo add to db
+
+ if (!$adapter->receive()) {
+ $messages = $adapter->getMessages();
+ foreach ($messages as $m) {
+ $l->crit($m);
+ }
+ } else {
+ $db_data = array(
+ 'initramfs_md5' => $adapter->getHash('md5', 'initramfsFile')
+ );
+ $w = $this->_mkernels->getAdapter()->quoteInto('id = ?', $id);
+ $this->_mkernels->update($db_data, $w);
+ $l->info(sprintf(
+ "updated initramfs with following md5s:\n\tinitramfs:\t%s",
+ $adapter->getHash('md5', 'initramfsFile')
+ ));
+ }
+ }
+
+ public function updatekernelAction()
+ {
+ // we don't need any view for json output
+ $this->_helper->viewRenderer->setNoRender();
+
+ $l = $this->_logger;
+ $adapter = new Zend_File_Transfer_Adapter_Http();
+ $kernel = $this->getRequest()->getParam('kernel');
+
+ $s = $this->_mkernels->select();
+ $s->where('kernel=?', $data['kernel']);
+ $r = $this->_mkernels->fetchAll($s)->toArray();
+
+ $id = $r[0]['id'];
+
+ #TODO: bild in more checks
+ $targetpath = APPLICATION_PATH . "/../data/kernels/$kernel/";
+
+ if (!is_dir($targetpath))
+ mkdir($targetpath, 0777, true);
+
+ $adapter->setDestination($targetpath);
+
+ #todo add to db
+
+ if (!$adapter->receive()) {
+ $messages = $adapter->getMessages();
+ foreach ($messages as $m) {
+ $l->crit($m);
+ }
+ } else {
+ $db_data = array(
+ 'kernel_md5' => $adapter->getHash('md5', 'kernelFile')
+ );
+ $w = $this->_mkernels->getAdapter()->quoteInto('id = ?', $id);
+ $this->_mkernels->update($db_data, $w);
+ $l->info(sprintf(
+ "updated kernel with following md5s:\n\tkernel:\t%s",
+ $adapter->getHash('md5', 'kernelFile')
+ ));
+ }
+ }
+
+ public function addkernelAction()
+ {
+ // we don't need any view for json output
+ $this->_helper->viewRenderer->setNoRender();
+
+ $l = $this->_logger;
+ $adapter = new Zend_File_Transfer_Adapter_Http();
+ $kernel = $this->getRequest()->getParam('kernel');
+
+ #TODO: bild in more checks
+ $targetpath = APPLICATION_PATH . "/../data/kernels/$kernel/";
+
+ if (!is_dir($targetpath))
+ mkdir($targetpath, 0777, true);
+
+ $adapter->setDestination($targetpath);
+
+ #todo add to db
+
+ if (!$adapter->receive()) {
+ $messages = $adapter->getMessages();
+ foreach ($messages as $m) {
+ $l->crit($m);
+ }
+ } else {
+ $db_data = array(
+ 'kernel' => $kernel,
+ 'kernel_md5' => $adapter->getHash('md5', 'kernelFile'),
+ 'initramfs_md5' => $adapter->getHash('md5', 'initramfsFile')
+ );
+ $this->_mkernels->insert($db_data);
+ $l->info(sprintf(
+ "added kernel/initramfs with following md5s:\n\tkernel:\t\t%s\n\tinitramfs:\t%s",
+ $adapter->getHash('md5', 'kernelFile'),
+ $adapter->getHash('md5', 'initramfsFile')
+ ));
+ }
+ }
+
+ public function syncAction()
+ {
+ $l = $this->_logger;
+
+ // we don't need any view for json output
+ $this->_helper->viewRenderer->setNoRender();
+
+ // get data from slxconfig-demuxer
+ $data = $this->getRequest()->getParam('data');
+ $data = json_decode(stripslashes($data), true);
+
+ if (empty($data)) return;
+
+ $source = $this->getRequest()->getServer('REMOTE_ADDR');
+
+ // compare md5sums with old values from db
+ $s = $this->_mkernels->select();
+ $s->where('kernel=?', $data['kernel']);
+ $r = $this->_mkernels->fetchAll($s)->toArray();
+
+ $response = array();
+ if (empty($r)) {
+ $response['getKernel'] = "fresh";
+ $response['getInitramfs'] = "fresh";
+ $l->info("request new kernel/initramfs pair");
+ } else {
+ $r = $r[0];
+ if ($data['kernel_md5'] == $r['kernel_md5']) {
+ $response['getKernel'] = "no";
+ $l->info("kernel is still up to date");
+ } else {
+ $response['getKernel'] = "update";
+ $l->info("request updated kernel");
+ }
+ if ($data['initramfs_md5'] == $r['initramfs_md5']) {
+ $response['getInitramfs'] = "no";
+ $l->info("initramfs is still up to date");
+ } else {
+ $response['getInitramfs'] = "update";
+ $l->info("request updated initramfs");
+ }
+ }
+
+ echo(json_encode($response));
+
+ // add systems to db..
+ if (!empty($data['systems'])) {
+ $s = $this->_msystems->select();
+ $s->where('source=?', $source);
+ $r = $this->_msystems->fetchAll($s)->toArray();
+ $externalIDs = array();
+ if (!empty($r)) {
+ foreach ($r as $r_) {
+ $externalIDs[] = $r_['external_id'];
+ }
+ }
+
+ foreach ($data['systems'] as $d) {
+ if (in_array($d['external-id'],$externalIDs)) {
+ $db_data = array(
+ 'name' => $d["label"],
+ 'external_id' => $d["external-id"],
+ 'description' => $d["description"],
+ 'kernel' => $d['vendor-os']['name'] . "/" . basename($d["kernel-file"]),
+ 'initrd' => $d['vendor-os']['name'] . "/" .$d["initramfs-name"],
+ 'append' => $d["append"],
+ 'source' => $source
+ );
+ $w[] = $this->_msystems->getAdapter()
+ ->quoteInto('external_id = ?', $d["external-id"]);
+ $w[] = $this->_msystems->getAdapter()
+ ->quoteInto('source = ?', $source);
+
+ $this->_msystems->update($db_data, $w);
+ $l->info(sprintf("updated system: %s", $d["external-id"]));
+ } else {
+ $db_data = array(
+ 'name' => $d["label"],
+ 'external_id' => $d["external-id"],
+ 'description' => $d["description"],
+ 'kernel' => $d['vendor-os']['name'] . "/" . basename($d["kernel-file"]),
+ 'initrd' => $d['vendor-os']['name'] . "/" .$d["initramfs-name"],
+ 'append' => $d["append"],
+ 'source' => $source
+ );
+ $this->_msystems->insert($db_data);
+ $l->info(sprintf("added system: %s", $d["external-id"]));
+ }
+ }
+ }
+
+ // add / modify systems table
+ $s = $this->_msources->select();
+ $s->where('ip=?', $source);
+ $r = $this->_msources->fetchAll($s)->toArray();
+
+ if (!empty($r)) {
+ $db_data = array(
+ 'version' => $data['slxinfo'],
+ 'lastdemux' => mktime()
+ );
+ $w = $this->_msources->getAdapter()->quoteInto('ip = ?', $source);
+ $this->_msources->update($db_data, $w);
+ } else {
+ $db_data = array(
+ 'ip' => $source,
+ 'version' => $data['slxinfo'],
+ 'lastdemux' => mktime()
+ );
+ $this->_msources->insert($db_data);
+ }
+
+
+ }
+
+
+}
+
+
+
diff --git a/application/modules/backend/controllers/UserController.php b/application/modules/backend/controllers/UserController.php
new file mode 100644
index 0000000..a7a90c2
--- /dev/null
+++ b/application/modules/backend/controllers/UserController.php
@@ -0,0 +1,18 @@
+<?php
+
+class Backend_UserController extends Zend_Controller_Action
+{
+
+ public function init()
+ {
+ /* Initialize action controller here */
+ }
+
+ public function indexAction()
+ {
+ // action body
+ }
+
+
+}
+
diff --git a/application/modules/backend/views/scripts/bootmedia/index.phtml b/application/modules/backend/views/scripts/bootmedia/index.phtml
new file mode 100644
index 0000000..2bd3dd3
--- /dev/null
+++ b/application/modules/backend/views/scripts/bootmedia/index.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>bootmedia</b> and script/action name <b>index</b></center> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/bootmedia/list.phtml b/application/modules/backend/views/scripts/bootmedia/list.phtml
new file mode 100644
index 0000000..8d441c9
--- /dev/null
+++ b/application/modules/backend/views/scripts/bootmedia/list.phtml
@@ -0,0 +1,20 @@
+<? if (!empty($this->listdata)): ?>
+<? foreach ($this->listdata as $l): ?>
+<div id="bootmedia-item-<?= $l['id'] ?>" class="bootmedia-item ui-corner-all">
+<h3><?= $l['name'] ?></h3>
+<p class="shortinfo">
+kernel: <?= $l['kernel'] ?><br/>
+created: <?= date("r",$l['created']) ?><br/>
+</p>
+<p class="description">
+<b>Description: </b>
+<?= $l['description'] ?>
+</p>
+<p class="list-context-menu">
+<a href="javascript:bootmediaDelete(<?= $l['id'] ?>)" class="ui-corner-all">Delete</a>
+<a href="javascript:bootmediaEdit(<?= $l['id'] ?>)" class="ui-corner-all">Edit</a>
+<a href="/isos/<?= $l['identifier'] ?>/openslx.iso" class="ui-corner-all">Download</a>
+</p>
+</div>
+<? endforeach;?>
+<? endif;?> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/menu/index.phtml b/application/modules/backend/views/scripts/menu/index.phtml
new file mode 100644
index 0000000..2bd3dd3
--- /dev/null
+++ b/application/modules/backend/views/scripts/menu/index.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>bootmedia</b> and script/action name <b>index</b></center> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/menu/list.phtml b/application/modules/backend/views/scripts/menu/list.phtml
new file mode 100644
index 0000000..e28e54e
--- /dev/null
+++ b/application/modules/backend/views/scripts/menu/list.phtml
@@ -0,0 +1,15 @@
+<? if (!empty($this->listdata)): ?>
+<? foreach ($this->listdata as $l): ?>
+<div id="menu-item-<?= $l['id'] ?>" class="menu-item ui-corner-all">
+<h3><?= $l['name'] ?></h3>
+<p class="description">
+<?= $l['description'] ?>
+</p>
+<p class="list-context-menu">
+<a href="javascript:menuDelete(<?= $l['id'] ?>)" class="ui-corner-all">Delete</a>
+<a href="javascript:menuEdit(<?= $l['id'] ?>)" class="ui-corner-all">Edit Metadata</a>
+<a href="javascript:menuEditentries(<?= $l['id'] ?>)" class="ui-corner-all">Edit Entries</a>
+</p>
+</div>
+<? endforeach;?>
+<? endif;?> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/menu/listassignments.phtml b/application/modules/backend/views/scripts/menu/listassignments.phtml
new file mode 100644
index 0000000..2ca982b
--- /dev/null
+++ b/application/modules/backend/views/scripts/menu/listassignments.phtml
@@ -0,0 +1,18 @@
+<? if (!empty($this->listdata)): ?>
+<? foreach ($this->listdata as $l): ?>
+<li id="menuassignment-item-<?= $l['id'] ?>" class="menuassignment-item ui-corner-all">
+<p class="list-caption no-padding">
+<b><?= $l['name'] ?></b><br/>
+[Bootmedia: <?= empty($l['b_bootmedia_id'])? 'All':$l['b_name'] ?>]
+<? if ($l['i_ip']): ?>
+&nbsp; + &nbsp; [IP range: <?= $l['i_ip'] ?>/<?= $l['i_netmask'] ?>]
+<? endif;?>
+&nbsp; &rArr; &nbsp; <?= $l['m_name'] ?>
+</p>
+<p class="list-context-menu no-padding">
+<a href="javascript:menuAssignmentDelete(<?= $l['id'] ?>)" class="ui-corner-all">Delete</a>
+<a href="javascript:menuAssignmentEdit(<?= $l['id'] ?>)" class="ui-corner-all">Edit</a>
+</p>
+</li>
+<? endforeach;?>
+<? endif;?> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/menu/listentries.phtml b/application/modules/backend/views/scripts/menu/listentries.phtml
new file mode 100644
index 0000000..4d8431e
--- /dev/null
+++ b/application/modules/backend/views/scripts/menu/listentries.phtml
@@ -0,0 +1,19 @@
+<? if (!empty($this->listdata)): ?>
+<? foreach ($this->listdata as $l): ?>
+<li id="menuentries-item-<?= $l['id'] ?>" class="menuentries-item ui-corner-all">
+<span class="menuentries-item-id-value" style="display:none;"><?= $l['id'] ?></span>
+<div class="sortHandle ui-state-default ui-corner-all" ><span class="ui-icon ui-icon-arrow-4"></span></div>
+<p class="list-caption no-padding">
+<? if ($l['overwrite_caption']): ?>
+<b><?= $l['alternative_caption'] ?></b> (<?= $l['s_source'] ?>/<?= $l['s_external_id'] ?>)
+<? else: ?>
+<b><?= $l['s_name'] ?></b> (<?= $l['s_source'] ?>/<?= $l['s_external_id'] ?>)
+<? endif;?>
+</p>
+<p class="list-context-menu no-padding">
+<a href="javascript:menuEntryDelete(<?= $l['id'] ?>)" class="ui-corner-all">Delete</a>
+<a href="javascript:menuEntryEdit(<?= $l['id'] ?>)" class="ui-corner-all">Edit</a>
+</p>
+</li>
+<? endforeach;?>
+<? endif;?> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/mkiso/index.phtml b/application/modules/backend/views/scripts/mkiso/index.phtml
new file mode 100644
index 0000000..2bd3dd3
--- /dev/null
+++ b/application/modules/backend/views/scripts/mkiso/index.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>bootmedia</b> and script/action name <b>index</b></center> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/system/add.phtml b/application/modules/backend/views/scripts/system/add.phtml
new file mode 100644
index 0000000..f09beb8
--- /dev/null
+++ b/application/modules/backend/views/scripts/system/add.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>system</b> and script/action name <b>add</b></center> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/system/addkernel.phtml b/application/modules/backend/views/scripts/system/addkernel.phtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/application/modules/backend/views/scripts/system/addkernel.phtml
diff --git a/application/modules/backend/views/scripts/system/index.phtml b/application/modules/backend/views/scripts/system/index.phtml
new file mode 100644
index 0000000..690f955
--- /dev/null
+++ b/application/modules/backend/views/scripts/system/index.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>system</b> and script/action name <b>index</b></center> \ No newline at end of file
diff --git a/application/modules/backend/views/scripts/system/sync.phtml b/application/modules/backend/views/scripts/system/sync.phtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/application/modules/backend/views/scripts/system/sync.phtml
diff --git a/application/modules/backend/views/scripts/system/updateinitramfs.phtml b/application/modules/backend/views/scripts/system/updateinitramfs.phtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/application/modules/backend/views/scripts/system/updateinitramfs.phtml
diff --git a/application/modules/backend/views/scripts/system/updatekernel.phtml b/application/modules/backend/views/scripts/system/updatekernel.phtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/application/modules/backend/views/scripts/system/updatekernel.phtml
diff --git a/application/modules/backend/views/scripts/user/index.phtml b/application/modules/backend/views/scripts/user/index.phtml
new file mode 100644
index 0000000..c04cb93
--- /dev/null
+++ b/application/modules/backend/views/scripts/user/index.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>user</b> and script/action name <b>index</b></center> \ No newline at end of file