diff options
Diffstat (limited to 'application/modules/ipxe/controllers/ResourceController.php')
| -rw-r--r-- | application/modules/ipxe/controllers/ResourceController.php | 190 |
1 files changed, 78 insertions, 112 deletions
diff --git a/application/modules/ipxe/controllers/ResourceController.php b/application/modules/ipxe/controllers/ResourceController.php index 00b5f29..44e45b2 100644 --- a/application/modules/ipxe/controllers/ResourceController.php +++ b/application/modules/ipxe/controllers/ResourceController.php @@ -13,7 +13,7 @@ class Ipxe_ResourceController extends Zend_Controller_Action { - private $thisSession; + private $session; public function init() { @@ -21,109 +21,69 @@ class Ipxe_ResourceController extends Zend_Controller_Action $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - $session = new Application_Model_Session(); - $sm = new Application_Model_SessionMapper(); + $this->session = new Application_Model_Session(); + $sessionMapper = new Application_Model_SessionMapper(); //TODO Error Messages if something failed $alphaID = $this->_request->getParam('alpha'); - - if($alphaID != ""){ + + if(isset($alphaID)){ $alphasessionID = $alphaID; - $result = $sm->findBy(array('alphasessionID' => $alphasessionID),true); + $result = $sessionMapper->findBy(array('alphasessionID' => $alphasessionID),true); # print_a($result); - $this->thisSession = $session->setOptions($result[0]); - $this->thisSession->setID($result[0]['sessionID']); + $this->session = $this->session->setOptions($result[0]); + $this->session->setID($result[0]['sessionID']); } $bootmenuntryID = $this->_request->getParam('bme'); - if(isset($bootmenuntryID)){ + if(isset($bootmenuntryID) && isset($this->session)){ + //TODO check if allowed $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); $bootmenuentry = new Application_Model_BootMenuEntries(); $bootmenuentriesMapper->find($bootmenuntryID,$bootmenuentry); - - $sessionMapper = new Application_Model_SessionMapper(); - - $this->thisSession->setBootmenuentryID($bootmenuntryID); - $this->thisSession->setBootosID($bootmenuentry->getBootosID()); - $sessionMapper->save($this->thisSession); + + $this->session->setBootmenuentryID($bootmenuntryID); + $this->session->setBootosID($bootmenuentry->getBootosID()); + $sessionMapper->save($this->session); } } - public function getvesamenuAction(){ - if(is_dir("../resources/ipxe/")){ - - header('Content-Type: application/octet-stream'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.c32"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - chdir("../resources/ipxe/"); - - header("Content-Length: ".filesize(getcwd()."/vesamenu.c32")); - - passthru( "cat vesamenu.c32"); - }else{ - header('HTTP/1.0 404 Not Found'); - } - - } - - public function getpxelinuxAction(){ - if(is_dir("../resources/ipxe/")){ - - header('Content-Type: application/octet-stream'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="pxelinux.0"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - chdir("../resources/ipxe/"); - - header("Content-Length: ".filesize(getcwd()."/pxelinux.0")); - - passthru( "cat pxelinux.0"); - }else{ - header('HTTP/1.0 404 Not Found'); - } - - } - public function getvesamenuconfigAction(){ - -// $membershipMapper = new Application_Model_MembershipMapper(); -// $memberships = $membershipMapper->findBy(array("personID" => $person->getID()),true); -// + header('Content-Type: text/html'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.conf"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + $vesamenuView = new Zend_View(); + $vesamenuView->addScriptPath(APPLICATION_PATH.'/modules/ipxe/views/scripts/resource/'); - - header('Content-Type: text/html'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.conf"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - $vesamenuView = new Zend_View(); - $vesamenuView->addScriptPath(APPLICATION_PATH.'/modules/ipxe/views/scripts/resource/'); + $vesamenuView->host = $_SERVER['HTTP_HOST']; + $vesamenuView->error = $this->_request->getParam('error'); - $vesamenuView->host = $_SERVER['HTTP_HOST']; - - $login = $this->_request->getParam('login') == 'true'; + if (isset($this->session)){ + $vesamenuView->alphaID = $this->session->getAlphasessionID(); - if($login){ - - $person = $this->_request->getParam('person'); - if (isset($person)) { - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->memberships = $this->membershipMapper->findBy(array("personID" => $person),true); - } - $this->memberships = null; + if ($this->session->getPersonID() != null){ + $personMapper = new Application_Model_PersonMapper(); + $person = $personMapper->find($this->session->getPersonID()); + $vesamenuView->name = $person->getName(); + $vesamenuView->firstname = $person->getFirstname(); + $vesamenuView->loggedin = true; + }else{ + $vesamenuView->loggedin = false; + } + + if ($this->session->getPersonID() != null && $this->session->getMembershipID() == null ){ $groupMapper = new Application_Model_GroupMapper(); $roleMapper = new Application_Model_RoleMapper(); - if(isset($this->memberships)) { - - foreach($this->memberships as $membership) { + $membershipMapper = new Application_Model_MembershipMapper(); + $memberships = $membershipMapper->findBy(array('personID' => $this->session->getPersonID()),true); + + if(isset($memberships)) { + foreach($memberships as $membership) { $group = $groupMapper->find($membership['groupID']); $role = $roleMapper->find($membership['roleID']); $membershipList[] = array( @@ -132,47 +92,53 @@ class Ipxe_ResourceController extends Zend_Controller_Action 'role' => $role->getTitle() ); } + $vesamenuView->memberships = $membershipList; + }else{ + $vesamenuView->memberships = null; } $vesamenuView->action = "selectmembership"; - $vesamenuView->memberships = $membershipList; + + } - }else{ - $vesamenuView->login = $login; - $_SESSION['alphasessionID'] = $this->thisSession->getAlphasessionID(); - // Request Bootmenu - $pbsFilter = new Pbs_Filter(); - $bootmenuID = $pbsFilter->evaluate(); - - if($bootmenuID != null){ - $vesamenuView->alphaID = $this->thisSession->getAlphasessionID(); + // Request Bootmenu + $_SESSION['alphasessionID'] = $this->session->getAlphasessionID(); + $pbsFilter = new Pbs_Filter(); + $bootmenuID = $pbsFilter->evaluate(); - $bootmenuMapper = new Application_Model_BootMenuMapper(); - $bm = $bootmenuMapper->find($bootmenuID); - $vesamenuView->title = $bm->getTitle(); - // $this->view->startcounter = $bm->getStartcounter(); - - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); - $vesamenuView->bmelist = $res; - - } - else{ + if($bootmenuID != null){ + $bootmenuMapper = new Application_Model_BootMenuMapper(); + $bm = $bootmenuMapper->find($bootmenuID); + $vesamenuView->title = $bm->getTitle(); + $vesamenuView->startcounter = $bm->getStartcounter(); - $vesamenuView->error = "You have no BootMenu."; - } + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); + $vesamenuView->bmelist = $res; + }else{ + $vesamenuView->bmelist = null; } - - $vesamenu = $vesamenuView->render('getvesamenu.phtml'); + }else{ + $vesamenuView->serialnumber = $this->_request->getParam('serialnumber'); + $vesamenuView->mac = $this->_request->getParam('mac'); + if($vesamenuView->error == "serial"){ + $vesamenuView->error = "serial"; + }else{ + $vesamenuView->error = "session"; + } + } + + $vesamenu = $vesamenuView->render('getvesamenu.phtml'); + + header("Content-Length: ".(strlen($vesamenu))); - header("Content-Length: ".(strlen($vesamenu))); - - echo $vesamenu; + echo $vesamenu; } public function getkernelAction(){ - $bootosID = $this->thisSession->getBootosID(); + //TODO session & bme error + $bootosID = $this->session->getBootosID(); if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){ @@ -197,7 +163,7 @@ class Ipxe_ResourceController extends Zend_Controller_Action public function getinitramfsAction() { - $bootosID = $this->thisSession->getBootosID(); + $bootosID = $this->session->getBootosID(); if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){ |
