diff options
3 files changed, 144 insertions, 67 deletions
diff --git a/application/modules/ipxe/controllers/AuthController.php b/application/modules/ipxe/controllers/AuthController.php index 5434a59..5a406b0 100644 --- a/application/modules/ipxe/controllers/AuthController.php +++ b/application/modules/ipxe/controllers/AuthController.php @@ -18,6 +18,7 @@ class Ipxe_AuthController extends Zend_Controller_Action { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); + $this->db = Zend_Db_Table::getDefaultAdapter(); } @@ -29,7 +30,7 @@ class Ipxe_AuthController extends Zend_Controller_Action echo $pbsNotifier->notify('serial',$result); } } - + public function serialAction() { $serialnumber = $this->_request->getParam('serialnumber'); @@ -72,10 +73,11 @@ class Ipxe_AuthController extends Zend_Controller_Action $result .= "imgfree\n"; if($login){ $result .= "login\n"; - $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 http://\${username:uristring}:\${password:uristring}@".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$session->getAlphasessionID()."/login/true\n"; + $result .= "chain http://\${username:uristring}:\${password:uristring}@".$_SERVER['HTTP_HOST']."/ipxe/auth/login/alpha/".$session->getAlphasessionID()."/login/true\n"; }else{ $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$session->getAlphasessionID()."/login/false\n"; } + header("Content-Length: ".(strlen($result))); @@ -89,4 +91,41 @@ class Ipxe_AuthController extends Zend_Controller_Action } + public function loginAction() + { + $alpha = $this->_request->getParam('alpha'); + + if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){ + header('WWW-Authenticate: Basic realm=""'); + header('HTTP/1.0 401 Unauthorized'); + exit; + } + + $email = $_SERVER['PHP_AUTH_USER']; + $password = $_SERVER['PHP_AUTH_PW']; + + $auth = Zend_Auth::getInstance(); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); + $adapter->setIdentity($email); + $adapter->setCredential($password); + + $result = $auth->authenticate($adapter); + + if ($result->isValid()) { + $personmapper = new Application_Model_PersonMapper(); + $result = $personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + $personmapper->save($person); + + $this->_redirect("/ipxe/resource/getvesamenuconfig/alpha/".$alpha."/person/".$person->getID()."/login/true"); + return; + } else { + echo "Wrong Email or Password."; + } + } + + } diff --git a/application/modules/ipxe/controllers/ResourceController.php b/application/modules/ipxe/controllers/ResourceController.php index feb85d2..840505d 100644 --- a/application/modules/ipxe/controllers/ResourceController.php +++ b/application/modules/ipxe/controllers/ResourceController.php @@ -17,6 +17,16 @@ class Ipxe_ResourceController extends Zend_Controller_Action public function init() { + + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $this->person = new Application_Model_Person($result[0]); + $this->person->setID($result[0]['personID']); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->memberships = $this->membershipMapper->findBy(array("personID" => $this->person->getID()),true); + } + $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); @@ -91,15 +101,12 @@ class Ipxe_ResourceController extends Zend_Controller_Action public function getvesamenuconfigAction(){ - $login = $this->_request->getParam('login') == 'true'; - if($login){ - if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){ - header('WWW-Authenticate: Basic realm=""'); - header('HTTP/1.0 401 Unauthorized'); - exit; - } - } +// $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"'); @@ -108,34 +115,54 @@ class Ipxe_ResourceController extends Zend_Controller_Action $vesamenuView = new Zend_View(); $vesamenuView->addScriptPath(APPLICATION_PATH.'/modules/ipxe/views/scripts/resource/'); - if($login == 'true'){ - $vesamenuView->username = $_SERVER['PHP_AUTH_USER']; - $vesamenuView->password = $_SERVER['PHP_AUTH_PW']; - } - $vesamenuView->login = $login; + $vesamenuView->host = $_SERVER['HTTP_HOST']; - $_SESSION['alphasessionID'] = $this->thisSession->getAlphasessionID(); - // Request Bootmenu - $pbsFilter = new Pbs_Filter(); - $bootmenuID = $pbsFilter->evaluate(); - - if($bootmenuID != null){ - $vesamenuView->alphaID = $this->thisSession->getAlphasessionID(); - - $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; + $login = $this->_request->getParam('login') == 'true'; + + if($login){ + $groupMapper = new Application_Model_GroupMapper(); + $roleMapper = new Application_Model_RoleMapper(); + if(isset($this->memberships)) { - } - else{ - - $vesamenuView->error = "You have no BootMenu."; + foreach($this->memberships as $membership) { + $group = $groupMapper->find($membership['groupID']); + $role = $roleMapper->find($membership['roleID']); + $membershipList[] = array( + 'membershipID' => $membership['membershipID'], + 'group' => $group->getTitle(), + 'role' => $role->getTitle() + ); + } + } + + $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(); + + $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{ + + $vesamenuView->error = "You have no BootMenu."; + } } $vesamenu = $vesamenuView->render('getvesamenu.phtml'); diff --git a/application/modules/ipxe/views/scripts/resource/getvesamenu.phtml b/application/modules/ipxe/views/scripts/resource/getvesamenu.phtml index c63ad8c..7ad44ba 100644 --- a/application/modules/ipxe/views/scripts/resource/getvesamenu.phtml +++ b/application/modules/ipxe/views/scripts/resource/getvesamenu.phtml @@ -95,41 +95,52 @@ menu color sel 7;37;40 #ff1c2a33 #667799bb all MENU MSGCOLOR #ff1c2a33 #00000000 none <? - if(!isset($this->error)){ - title ( $this->title ); - }else{ - title($this->error); - } +// if(!isset($this->error)){ +// title ( $this->title ); +// }else{ +// title($this->error); +// } - if ($this->login && !authenticated($this->username, $this->password)) { - retry(); - } else { - - $bootosmapper = new Application_Model_BootOsMapper(); - - if(isset($this->bmelist)){ - foreach($this->bmelist as $bme){ - - $kcl = $bootosmapper->find($bme->getBootosID())->getDefaultkcl(); - - if($bme->getKcl() && $kcl != null){ - uriboot ( $bme->getTitle(), - "http://$this->host/ipxe/resource/getkernel/alpha/$this->alphaID/bme/".$bme->getID()."/file/kernel", "initrd=http://$this->host/ipxe/resource/getinitramfs/alpha/$this->alphaID/bme/".$bme->getID()."/file/initramfs $kcl alpha=$this->alphaID file=http://$this->host/c/$this->alphaID/default.tgz ".$bme->getKclappend()); - }else{ - uriboot ( $bme->getTitle(), - "http://$this->host/ipxe/resource/getkernel/alpha/$this->alphaID/bme/".$bme->getID()."/file/kernel", "initrd=http://$this->host/ipxe/resource/getinitramfs/alpha/$this->alphaID/bme/".$bme->getID()."/file/initramfs alpha=$this->alphaID file=http://$this->host/c/$this->alphaID/default.tgz ".$bme->getKclappend()); - } + if($this->action == "selectmembership"){ + title ( "Select Membership:" ); + if(isset($this->memberships)){ + foreach($this->memberships as $membership){ + uriboot ($membership['group'], 'test', 'test'); } - if($this->login) - uriboot ( "Return to Group Bootmenu", "/ipxe/auth/serial/serialnumber/55-44-33-22-11/mac/123/login/false", "" ); + } - - if(!$this->login){ - uriboot ( "Login", "/ipxe/auth/serial/serialnumber/55-44-33-22-11/mac/123/login/true", "" ); - texthelp("Login to get your own Bootmenu."); - } - - localboot(); } + + +// if (!$this->login) { +// retry(); +// } else { +// +// $bootosmapper = new Application_Model_BootOsMapper(); +// +// if(isset($this->bmelist)){ +// foreach($this->bmelist as $bme){ +// +// $kcl = $bootosmapper->find($bme->getBootosID())->getDefaultkcl(); +// +// if($bme->getKcl() && $kcl != null){ +// uriboot ( $bme->getTitle(), +// "http://$this->host/ipxe/resource/getkernel/alpha/$this->alphaID/bme/".$bme->getID()."/file/kernel", "initrd=http://$this->host/ipxe/resource/getinitramfs/alpha/$this->alphaID/bme/".$bme->getID()."/file/initramfs $kcl alpha=$this->alphaID file=http://$this->host/c/$this->alphaID/default.tgz ".$bme->getKclappend()); +// }else{ +// uriboot ( $bme->getTitle(), +// "http://$this->host/ipxe/resource/getkernel/alpha/$this->alphaID/bme/".$bme->getID()."/file/kernel", "initrd=http://$this->host/ipxe/resource/getinitramfs/alpha/$this->alphaID/bme/".$bme->getID()."/file/initramfs alpha=$this->alphaID file=http://$this->host/c/$this->alphaID/default.tgz ".$bme->getKclappend()); +// } +// } +// if($this->login) +// uriboot ( "Return to Group Bootmenu", "/ipxe/auth/serial/serialnumber/55-44-33-22-11/mac/123/login/false", "" ); +// } +// +// if(!$this->login){ +// uriboot ( "Login", "/ipxe/auth/serial/serialnumber/55-44-33-22-11/mac/123/login/true", "" ); +// texthelp("Login to get your own Bootmenu."); +// } +// +// localboot(); +// } ?>
\ No newline at end of file |
