summaryrefslogtreecommitdiffstats
path: root/application/modules/ipxe/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/ipxe/controllers')
-rw-r--r--application/modules/ipxe/controllers/AuthController.php124
-rw-r--r--application/modules/ipxe/controllers/ResourceController.php124
2 files changed, 184 insertions, 64 deletions
diff --git a/application/modules/ipxe/controllers/AuthController.php b/application/modules/ipxe/controllers/AuthController.php
index c553566..d3c5ca0 100644
--- a/application/modules/ipxe/controllers/AuthController.php
+++ b/application/modules/ipxe/controllers/AuthController.php
@@ -12,80 +12,76 @@
class Ipxe_AuthController extends Zend_Controller_Action
{
+ protected $membership;
public function init()
{
- $this->db = Zend_Db_Table::getDefaultAdapter();
- $this->personmapper = new Application_Model_PersonMapper();
- }
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
- public function indexAction()
- {
- $this->_helper-> viewRenderer-> setNoRender();
- $this->_helper->redirector('login', 'auth');
}
- public function loginAction()
+ public function errorAction()
{
- if (Zend_Auth::getInstance()->hasIdentity()) {
- $this->_redirect('/fbgui/');
- } else {
- if (!isset($_POST["login"])){
- $loginForm = new fbgui_Form_Login();
- } else {
- $loginForm = new fbgui_Form_Login($_POST);
-
- if ($loginForm->isValid($_POST)) {
-
- $auth = Zend_Auth::getInstance();
-
- $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))');
-
-
- $adapter->setIdentity($loginForm->getValue('email'));
- $adapter->setCredential($loginForm->getValue('password'));
-
- $result = $auth->authenticate($adapter);
-
- // TODO: erweiterte fehlerbeschreibung des Users
-
- if ($result->isValid()) {
- $this->personmapper = new Application_Model_PersonMapper();
- $result = $this->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());
- $this->personmapper->save($person);
- $this->_helper->redirector('selectmembership', 'person');
- return;
- } else {
- echo "Wrong Email or Password.";
- }
- }
- }
- $this->view->loginForm = $loginForm;
+ $result = $this->_request->getParam('serialresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('serial',$result);
}
}
- public function logoutAction()
+ public function serialAction()
{
- $this->_helper-> viewRenderer-> setNoRender();
- $auth = Zend_Auth::getInstance();
- $auth->clearIdentity();
- Zend_Session::namespaceUnset('userIDs');
- Zend_Session::forgetMe();
- $this->_redirect('/fbgui/index');
-# $this->_helper->redirector('fbgui', 'index');
- return;
+ $serialnumber = $this->_request->getParam('serialnumber');
+ $mac = $this->_request->getParam('mac');
+
+ if(isset($serialnumber)){
+ // Create a session
+
+ $n = new Pbs_Session();
+
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $bootiso = new Application_Model_BootIso();
+
+ $results = $bootisomapper->findBy(array('serialnumber' => $serialnumber),true);
+ if(count($results) == 0){
+ $this->_redirect('/ipxe/auth/error/serialresult/noserial');
+ }
+ $bootiso->setOptions($results[0]);
+ $bootiso->setID($results[0]['bootisoID']);
+ $groupID = $bootiso->getGroupID();
+
+ $client = new Application_Model_Client();
+ $client->setGroupID($groupID);
+ $client->setMacadress($mac);
+ $client->setCreated(time());
+ $client = $n->createClient($client);
+ $clientID = $client->getID();
+
+ if(!isset($_SESSION['alphasessionID'])){
+ $session = new Application_Model_Session();
+ $session->setBootisoID($bootiso->getID());
+ $session->setClientID($clientID);
+ $session->setTime(time());
+ $session->setIp($_SERVER['REMOTE_ADDR']);
+ $session = $n->createSession($session);
+ $_SESSION['alphasessionID'] = $session->getAlphasessionID();
+ }
+ else{
+ $session = new Application_Model_Session();
+ $sessionMapper = new Application_Model_SessionMapper();
+ $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID']));
+ $session = $sessions[0];
+ }
+
+ $this->_redirect('/ipxe/resource/ipxe/alpha/'.$session->getAlphasessionID());
+
+ }
+ else{
+
+ $this->_redirect('/ipxe/auth/error/serialresult/noserial');
+ }
+
}
+
}
-
-
-
-
-
-
-
-
-
diff --git a/application/modules/ipxe/controllers/ResourceController.php b/application/modules/ipxe/controllers/ResourceController.php
new file mode 100644
index 0000000..0d1428a
--- /dev/null
+++ b/application/modules/ipxe/controllers/ResourceController.php
@@ -0,0 +1,124 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Ipxe_ResourceController extends Zend_Controller_Action
+{
+
+ private $thisSession;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+
+ //TODO Error Messages if something failed
+ $alphaID = $this->_request->getParam('alpha');
+
+ if($alphaID != ""){
+ $alphasessionID = $alphaID;
+ $result = $sm->findBy(array('alphasessionID' => $alphasessionID),true);
+ # print_a($result);
+ $this->thisSession = $session->setOptions($result[0]);
+ $this->thisSession->setID($result[0]['sessionID']);
+ }
+
+ }
+
+ 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 getvesamenuconfigAction(){
+
+ 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'];
+
+ // 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');
+
+ header("Content-Length: ".(strlen($vesamenu)));
+
+ echo $vesamenu;
+ }
+
+ public function ipxeAction(){
+
+ header('Content-Type: text/plain');
+
+ $result = "#!ipxe\n";
+ $result .= "imgfree\n";
+
+ $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenu/alpha/".$this->thisSession->getAlphasessionID()." http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->thisSession->getAlphasessionID();
+
+ header("Content-Length: ".(strlen($result)));
+
+ echo $result;
+
+ }
+
+
+
+}
+
+
+
+
+
+
+