diff options
Diffstat (limited to 'application/modules/user')
5 files changed, 21 insertions, 183 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 { diff --git a/application/modules/user/forms/Bootos.php b/application/modules/user/forms/Bootos.php index 1dd0d07..d9cd24f 100644 --- a/application/modules/user/forms/Bootos.php +++ b/application/modules/user/forms/Bootos.php @@ -63,39 +63,6 @@ class user_Form_Bootos extends Zend_Form 'label' => 'Description:', )); - $this->addElement('text', 'path_init', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 250)), - ), - 'required' => false, - 'size' => 50, - 'readOnly' => $meta, - 'label' => 'Init-Path:', - )); - - $this->addElement('text', 'path_kernel', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 250)), - ), - 'required' => false, - 'size' => 50, - 'readOnly' => $meta, - 'label' => 'Kernel-Path:', - )); - - $this->addElement('text', 'path_config', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 250)), - ), - 'required' => false, - 'size' => 50, - 'readOnly' => $meta, - 'label' => 'Config-Path:', - )); - $this->addElement('textarea', 'defaultkcl', array( 'filters' => array('StringTrim'), 'validators' => array( diff --git a/application/modules/user/forms/Preboot.php b/application/modules/user/forms/Preboot.php index 634b2b7..54dc216 100644 --- a/application/modules/user/forms/Preboot.php +++ b/application/modules/user/forms/Preboot.php @@ -33,6 +33,12 @@ class user_Form_Preboot extends Zend_Form else $meta = null; + if($this->action == 'editpreboot') + $filereq = false; + else + $filereq = true; + + $this->addElement('text', 'title', array( 'filters' => array('StringTrim'), 'validators' => array( @@ -45,7 +51,7 @@ class user_Form_Preboot extends Zend_Form $this->addElement('textarea', 'description', array( 'filters' => array('StringTrim'), 'validators' => array( - array('StringLength', false, array(0, 50)), + array('StringLength', false, array(0, 140)), ), 'required' => false, 'rows' => 5, @@ -54,7 +60,8 @@ class user_Form_Preboot extends Zend_Form )); $this->addElement('file', 'preboot', array( - 'required' => true, + 'validators' => array(array('Extension', false, array('zip'))), + 'required' => $filereq, 'readOnly' => $meta, 'label' => 'Preboot:', )); diff --git a/application/modules/user/views/scripts/bootos/index.phtml b/application/modules/user/views/scripts/bootos/index.phtml index c0f201e..c39ac05 100644 --- a/application/modules/user/views/scripts/bootos/index.phtml +++ b/application/modules/user/views/scripts/bootos/index.phtml @@ -100,12 +100,6 @@ <?php if(Pbs_Acl::checkRight('boai')): ?> <label>BootosID</label> <div class='item'><?php echo $this->escape($bootos->getID()); ?> </div> - <label>initPath</label> - <div class='item'><?php echo $this->escape($bootos->getPath_init()); ?> </div> - <label>kernelPath</label> - <div class='item'><?php echo $this->escape($bootos->getPath_kernel()); ?> </div> - <label>configPath</label> - <div class='item'><?php echo $this->escape($bootos->getPath_config()); ?> </div> <label>Default KCL</label> <div class='item'><?php echo $this->escape($bootos->getDefaultkcl()); ?> </div> <label>Source</label> diff --git a/application/modules/user/views/scripts/preboot/index.phtml b/application/modules/user/views/scripts/preboot/index.phtml index b714b75..415db2e 100644 --- a/application/modules/user/views/scripts/preboot/index.phtml +++ b/application/modules/user/views/scripts/preboot/index.phtml @@ -52,6 +52,7 @@ <?php endif; ?> </div> <div class='title'><?php echo $this->escape($preboot->getTitle()); ?></div> + <div class='subtitle'><?php echo $this->escape($preboot->getDescription()); ?></div> <div class='details'> <label>PrebootID</label> <div class='item'><?php echo $this->escape($preboot->getID()); ?></div> |