summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon2011-03-29 12:11:07 +0200
committerSimon2011-03-29 12:11:07 +0200
commit045bb9611f572ecb0b251eb116a221ff9b8a96d4 (patch)
treea31117e6b8965152ebf6e9b42c49c88a226ea366
parentShortcuts zu rechten hinzugefügt (diff)
parentsql fixed (diff)
downloadpbs2-045bb9611f572ecb0b251eb116a221ff9b8a96d4.tar.gz
pbs2-045bb9611f572ecb0b251eb116a221ff9b8a96d4.tar.xz
pbs2-045bb9611f572ecb0b251eb116a221ff9b8a96d4.zip
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
-rw-r--r--application/controllers/ResourceController.php174
-rw-r--r--application/modules/user/controllers/PrebootController.php3
-rw-r--r--pbs.sql4
3 files changed, 177 insertions, 4 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
new file mode 100644
index 0000000..8ab1828
--- /dev/null
+++ b/application/controllers/ResourceController.php
@@ -0,0 +1,174 @@
+<?php
+
+class ResourceController extends Zend_Controller_Action
+{
+
+ private $thisSession;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ //TODO Error Messages if something failed
+
+ $alphasessionID = $this->_request->getParam('alpha');
+ $session = new Application_Model_Session();
+ $sm = new Application_Model_SessionMapper();
+ $result = $sm->findBy('alphasessionID',$alphasessionID);
+ # print_a($result);
+ $this->thisSession = $session->setOptions($result[0]);
+ $this->thisSession->setID($result[0]['sessionID']);
+ }
+
+ public function indexAction()
+ {
+
+
+ }
+
+ public function getinitramfsAction()
+ {
+
+ $bootosID = $this->thisSession->getBootosID();
+
+ 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})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="initramfs"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create file.
+ chdir("../resources/bootos/$bootosID/initramfs/");
+ $initname = array_pop(scandir("./"));
+
+ passthru( "cat ".$initname);
+ }
+ }
+
+ public function getconfigAction()
+ {
+ $bootmenuentryID = $this->thisSession->getBootmenuentryID();
+
+ $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})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="config.tgz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/config/$configID/config/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getkernelAction()
+ {
+ $bootosID = $this->thisSession->getBootosID();
+
+ 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})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kernel"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/kernel/");
+ $kernelname = array_pop(scandir("./"));
+
+ passthru( "cat ". $kernelname);
+ }
+ }
+
+ public function getkclAction()
+ {
+ $bmeID = $this->thisSession->getBootmenuentryID();
+
+ if(is_numeric($bmeID)){
+
+ $bmemapper = new Application_Model_BootMenuEntriesMapper();
+ $bme = new Application_Model_BootMenuEntries();
+ $bmemapper->find($bmeID,$bme);
+
+ 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="kcl.txt"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ if($bme->getKcl() != null)
+ $result = $bme->getKcl() . " " . $bme->getKclappend();
+ else
+ $result = $bme->getKclappend();
+
+ echo $result;
+
+
+ }
+
+ }
+
+ 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
+ $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
+ $bootosID = $this->_request->getParam('bootosID');
+
+ $this->thisSession->setBootosID($bootosID)->setBootmenuentryID($bootmenuentryID);
+ $sessionMapper = new Application_Model_SessionMapper();
+ $sessionMapper->save($this->thisSession);
+
+ if($this->thisSession->getBootmenuentryID() != null){
+ header('Content-Type: application/json');
+ $return_val =
+ array(
+ 'info' => 'This function is for debugging purpose only',
+ 'kernel' => $this->generateURL('getkernel', 'alpha', $_SESSION['alphasessionID'], "kernel"),
+ 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $_SESSION['alphasessionID'], "initramfs"),
+ 'kcl' => $this->generateURL('getkcl', 'alpha', $_SESSION['alphasessionID'], "kcl.txt"),
+ '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')
+ );
+ }
+ }
+
+ private function generateURL($action, $varname, $varvalue, $filename){
+ $path = '/dev/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ;
+ $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
+ return $path;
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php
index e1e67a5..1491ae9 100644
--- a/application/modules/user/controllers/PrebootController.php
+++ b/application/modules/user/controllers/PrebootController.php
@@ -12,8 +12,7 @@ class User_PrebootController extends Zend_Controller_Action
if (Zend_Auth::getInstance()->hasIdentity()) {
$userIDsNamespace = Zend_Session::namespaceGet('userIDs');
if($userIDsNamespace['membershipID'] ==''){
- $pbsNotifier = new Pbs_Notifier();
- echo $pbsNotifier->notify('No membershipID set','forbidden');
+ $this->_redirect('/user/index');
}
$this->prebootMapper = new Application_Model_PreBootMapper();
diff --git a/pbs.sql b/pbs.sql
index 6c2af35..d45b47e 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -147,7 +147,7 @@ CREATE TABLE IF NOT EXISTS `pbs_bootos` (
PRIMARY KEY (`bootosID`),
KEY `configID` (`configID`),
KEY `groupID` (`groupID`),
- KEY `membershipID` (`membershipID`),
+ KEY `membershipID` (`membershipID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
ALTER TABLE `pbs_bootos`
@@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `pbs_bootmenuentries` (
ALTER TABLE `pbs_bootmenuentries`
ADD CONSTRAINT `pbs_bootmenuentries_ibfk_1` FOREIGN KEY (`bootmenuID`) REFERENCES `pbs_bootmenu` (`bootmenuID`) ON DELETE CASCADE,
ADD CONSTRAINT `pbs_bootmenuentries_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE,
- ADD CONSTRAINT `pbs_bootmenuentries_ibfk_3` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE SET NULL,
+ ADD CONSTRAINT `pbs_bootmenuentries_ibfk_3` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE SET NULL;
CREATE TABLE IF NOT EXISTS `pbs_preboot` (
`prebootID` int(11) NOT NULL AUTO_INCREMENT,