summaryrefslogtreecommitdiffstats
path: root/application/modules/dev/controllers/ResourceController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/dev/controllers/ResourceController.php')
-rw-r--r--application/modules/dev/controllers/ResourceController.php192
1 files changed, 192 insertions, 0 deletions
diff --git a/application/modules/dev/controllers/ResourceController.php b/application/modules/dev/controllers/ResourceController.php
new file mode 100644
index 0000000..aef8649
--- /dev/null
+++ b/application/modules/dev/controllers/ResourceController.php
@@ -0,0 +1,192 @@
+<?php
+
+class ResourceController extends Zend_Controller_Action
+{
+
+
+ public function init()
+ {
+
+ }
+
+ public function indexAction()
+ {
+
+
+ }
+
+ public function getinitramfsAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $alphasessionID = $this->_request->getParam('alpha');
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+ $result = $sm->findBy('alphasessionID',$alphasessionID);
+ # print_a($result);
+ $thisSession = $result[0];
+ $bootosID = $thisSession['bootosID'];
+
+ if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="initramfs.tar.gz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/initramfs/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getconfigAction()
+ {
+
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $alphasessionID = $this->_request->getParam('alpha');
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+ $result = $sm->findBy('alphasessionID',$alphasessionID);
+ # print_a($result);
+ $thisSession = $result[0];
+ $bootmenuentryID = $thisSession['bootmenuentryID'];
+ $bootmenuentry = new Application_Model_BootMenuEntries();
+ $bmm = new Application_Model_BootMenuEntriesMapper();
+ $bmm->find($bootmenuentryID,$bootmenuentry);
+ # print_a($bootmenuentry);
+ $configID = $bootmenuentry->getConfigID();
+
+ if(is_dir("../resources/config/$configID/config/") && is_numeric($configID)){
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="config.tar.gz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/config/$configID/config/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getkernelAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $alphasessionID = $this->_request->getParam('alpha');
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+ $result = $sm->findBy('alphasessionID',$alphasessionID);
+ # print_a($result);
+ $thisSession = $result[0];
+ $bootosID = $thisSession['bootosID'];
+
+
+ if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kernel.tar.gz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/kernel/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getkclAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $alphasessionID = $this->_request->getParam('alpha');
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+ $result = $sm->findBy('alphasessionID',$alphasessionID);
+ # print_a($result);
+ $thisSession = $result[0];
+ $bmeID = $thisSession['bootmenuentryID'];
+
+ if(is_numeric($bmeID)){
+ $bmemapper = new Application_Model_BootMenuEntriesMapper();
+ $bme = new Application_Model_BootMenuEntries();
+ $bmemapper->find($bmeID,$bme);
+
+ if($bme->getKcl() != null){
+ header('Content-Type: text/html');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+ echo $bme->getKcl();
+ }
+
+ }
+
+ }
+
+ public function getbootmenuentryAction()
+ {
+ // obsolete function (now only for debugging)
+ // after selecting the BootOS it will be saved in session
+ // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction
+ // can be called with session-identifier
+
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $bmeID = $this->_request->getParam('bootmenuentryID');
+ $bmeID = 4;
+
+ if(isset($_SESSION['alphasessionID'])){
+ $sessionmapper = new Application_Model_SessionMapper();
+ $session = $sessionmapper->findBy('alphasessionID',$_SESSION['alphasessionID']);
+ $session = $session[0];
+ if($session['bootmenuentryID'] != null){
+ $return_val =
+ array(
+ 'info' => 'This function is for debugging purpose only',
+ 'kernel' => $this->generateURL('getkernel', 'alpha', $_SESSION['alphasessionID']),
+ 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $_SESSION['alphasessionID']),
+ 'kcl' => $this->generateURL('getkcl', 'alpha', $_SESSION['alphasessionID']),
+ 'config' => $_SESSION['alphasessionID']
+ );
+ echo json_encode($return_val);
+ }
+ else{
+ echo json_encode(
+ array( 'info' => 'This function is for debugging purpose only',
+ 'error'=>'your session is out of date')
+ );
+ }
+ }
+
+ }
+
+ function generateURL($action, $varname, $varvalue){
+ $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue;
+ $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
+ return $path;
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+