diff options
| author | michael pereira | 2011-04-21 15:55:59 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-21 15:55:59 +0200 |
| commit | 4d141b993337331b61945cc02c43cb15d89714e9 (patch) | |
| tree | 38e42801af6fee086771eca48ff44d2b668f1986 /application/modules/user/controllers/PrebootController.php | |
| parent | config fix (diff) | |
| download | pbs2-4d141b993337331b61945cc02c43cb15d89714e9.tar.gz pbs2-4d141b993337331b61945cc02c43cb15d89714e9.tar.xz pbs2-4d141b993337331b61945cc02c43cb15d89714e9.zip | |
Preboot gefixt
Diffstat (limited to 'application/modules/user/controllers/PrebootController.php')
| -rw-r--r-- | application/modules/user/controllers/PrebootController.php | 153 |
1 files changed, 11 insertions, 142 deletions
diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index 730debb..a2bbc48 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -152,111 +152,17 @@ class User_PrebootController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - //$this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/error'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/error'); //TODO Delete folder + preboot in DB } - //$this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/ok'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/ok'); } } $this->view->prebootForm = $prebootForm; } - public function checkupdateAction($preboot) - { - - //ACL Is he allowed to update Preboots? - if(!Pbs_Acl::checkRight('pru')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - $prebootID = $preboot->getID(); - exec("wget --server-response --spider ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'Last-Modified:'", $prebootdate); - - //print_a($prebootdate); - - $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); - - if(is_file("../resources/bootmedium/$prebootID/preboot.zip")){ - $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.zip"); - }else{ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); - return true; - } - - //print_a($prebootname,$prebootdate,$prebootolddate); - - $pbsNotifier = new Pbs_Notifier(); - - if($prebootdate > $prebootolddate){ - $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); - return true; - } - else - return false; - - } - - public function updateprebootAction() - { - //ACL Is he allowed to update Preboots? - if(!Pbs_Acl::checkRight('pru')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - $prebootID = $this->_request->getParam('prebootID'); - if (!is_numeric($prebootID)) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - $preboot = new Application_Model_PreBoot(); - $this->prebootMapper->find($prebootID,$preboot); - - if($this->membership->getGroupID() != $preboot->getGroupID()) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - - $path_preboot = "../resources/bootmedium/$prebootID/"; - - exec("wget -O '".$path_preboot."preboot.zip' ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'saved'", $status); - - if(!array_pop($status)){ - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/404'); - } - - try{ - $filelist = array(); - $filelist = scandir($path_preboot); - - $bootisoMapper = new Application_Model_BootIsoMapper(); - - //TODO Lock preboot - - foreach($filelist as $file){ - if($file == preg_match('![0-9]+\.zip!')){ - $bootisoID = str_replace('.zip', '', $file); - $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); - - copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); - $zip->close(); - } - } - } - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); - //TODO Delete Folder + Preboot - } - - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); - } - public function editprebootAction() { //ACL Is he allowed to edit Preboots? @@ -268,7 +174,6 @@ class User_PrebootController extends Zend_Controller_Action if (!is_numeric($prebootID)) $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - $preboot = new Application_Model_PreBoot(); $this->prebootMapper->find($prebootID, $preboot); @@ -291,56 +196,20 @@ class User_PrebootController extends Zend_Controller_Action if ($prebootForm->isValid($_POST)) { $prebootold = $preboot; - + $source = $_SERVER['REMOTE_ADDR']; + $preboot = new Application_Model_PreBoot($_POST); $preboot->setGroupID($this->membership->getGroupID()); $preboot->setID($prebootID); + $preboot->setSource($source); + $preboot->setCreated(time()); - $path_preboot = "../resources/bootmedium/$prebootID/"; + $prebootpath = "../resources/bootmedium/$prebootID/"; - if($preboot->getPath_preboot() != $prebootold->getPath_preboot()){ - - //ACL Is he allowed to edit the Preboot Path? - if(!Pbs_Acl::checkRight('pre')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - - exec("wget -O '".$path_preboot."preboot.zip' ".escapeshellcmd($preboot->getPath_preboot()) ." 2>&1 | grep 'saved'" , $status); - if(!array_pop($status)){ - $this->view->prebootForm = $prebootForm; - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); - - return; - } - - try{ - $filelist = array(); - $filelist = scandir($path_preboot); - - $bootisoMapper = new Application_Model_BootIsoMapper(); - - //TODO Lock preboot - - foreach($filelist as $file){ - if(preg_match('![0-9]+\.zip!',$file)){ - $bootisoID = str_replace('.zip', '', $file); - $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); - - copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); - $zip->close(); - } - } - } - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); - } + mkdir($prebootpath ,0777, true); + + if(isset($_FILES['preboot'])){ + move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip"); } try { |
