diff options
Diffstat (limited to 'application/modules/user/controllers/BootosController.php')
| -rw-r--r-- | application/modules/user/controllers/BootosController.php | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index 2fe8f41..4a173ae 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -70,6 +70,8 @@ class user_BootosController extends Zend_Controller_Action foreach ($bootos as $b) if($b->getPublic() - $k >= 0 ) $this->view->bootoslist[] = $b; + elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')) + $this->view->bootoslist[] = $b; } } @@ -77,9 +79,7 @@ class user_BootosController extends Zend_Controller_Action $this->view->update = array(); $update = $this->_request->getParam('checkupdate'); - $groupMapper = new Application_Model_GroupMapper(); - $configMapper = new Application_Model_ConfigMapper(); - + $groupMapper = new Application_Model_GroupMapper(); if(count($this->view->bootoslist)>0){ foreach ($this->view->bootoslist as $bootos){ @@ -87,7 +87,6 @@ class user_BootosController extends Zend_Controller_Action if($bootos->getDefaultkcl() == null) $bootos->setDefaultkcl("none (edit Bootos to set KCL)"); $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); - $bootos->setConfigID("[".$bootos->getConfigID()."] ".$configMapper->find($bootos->getConfigID())->getTitle()); $bootos->setCreated(date(Zend_Registry::get('dateformat'),$bootos->getCreated())); $bootos->setExpires(date(Zend_Registry::get('dateformat'),$bootos->getExpires())); } @@ -133,21 +132,16 @@ class user_BootosController extends Zend_Controller_Action $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); - $configMapper = new Application_Model_ConfigMapper(); - $configlist = $configMapper->findBy(array("groupID" => $groupID)); - if (!isset($_POST["createbootos"])){ $bootosForm = new user_Form_Bootos(array( 'action' => 'createbootos', 'groupdepth' => $childgroups, - 'configlist'=>$configlist, 'page' => $this->page)); } else { $bootosForm = new user_Form_Bootos(array( 'action' => 'createbootos', 'groupdepth' => $childgroups, - 'configlist'=>$configlist, 'page' => $this->page),$_POST); if ($bootosForm->isValid($_POST)) { @@ -165,8 +159,9 @@ class user_BootosController extends Zend_Controller_Action $hash = md5(microtime(1)); exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); - - if(!array_pop($status) || !array_pop($status2)){ + exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); + + if(!array_pop($status) || !array_pop($status2) || !array_pop($status3)){ $this->view->bootosForm = $bootosForm; $pbsNotifier = new Pbs_Notifier(); echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); @@ -178,12 +173,15 @@ class user_BootosController extends Zend_Controller_Action $initpath = "../resources/bootos/".$bootosID."/initramfs/"; $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + $configpath = "../resources/bootos/".$bootosID."/config/"; mkdir($initpath ,0777, true); mkdir($kernelpath ,0777, true); + mkdir($configpath ,0777, true); exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); + exec("mv ../resources/bootos/config$hash $configpath"."config.tgz"); }catch(Zend_Exception $e) { @@ -210,9 +208,10 @@ class user_BootosController extends Zend_Controller_Action $bootosID = $bootos->getID(); - if(is_file("../resources/bootos/$bootosID/kernel/kernel") && is_file("../resources/bootos/$bootosID/initramfs/initramfs")){ + if(is_file("../resources/bootos/$bootosID/kernel/kernel") && is_file("../resources/bootos/$bootosID/initramfs/initramfs") && is_file("../resources/bootos/$bootosID/config/config.tgz")){ $kernelolddate = filemtime("../resources/bootos/".$bootosID."/kernel/kernel"); $initolddate = filemtime("../resources/bootos/".$bootosID."/initramfs/initramfs"); + $configolddate = filemtime("../resources/bootos/".$bootosID."/config/config.tgz"); } else { @@ -223,13 +222,15 @@ class user_BootosController extends Zend_Controller_Action exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_kernel())."' 2>&1 | grep 'Last-Modified:'", $kerneldate); exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_init())."' 2>&1 | grep 'Last-Modified:'", $initdate); + exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_config())."' 2>&1 | grep 'Last-Modified:'", $configdate); $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate)))); $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate)))); + $configdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($configdate)))); //print_a($bootos->getPath_kernel(),$kerneldate,$kernelolddate,$initname,$initdate,$initolddate); - if($kerneldate > $kernelolddate || $initdate > $initolddate){ + if($kerneldate > $kernelolddate || $initdate > $initolddate || $configdate > $configolddate){ $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); return true; }else{ @@ -256,19 +257,22 @@ class user_BootosController extends Zend_Controller_Action $initpath = "../resources/bootos/".$bootosID."/initramfs/"; $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + $configpath = "../resources/bootos/".$bootosID."/config/"; $path_tmp = "../resources/bootos/"; $hash = md5(microtime(1)); exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); - - if(!array_pop($status) || !array_pop($status2)){ + exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); + + if(!array_pop($status) || !array_pop($status2) || !array_pop($status3)){ $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/404'); //TODO Delete Files in tmp } exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); + exec("mv ../resources/bootos/config$hash $initpath"."config.tgz"); $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/ok'); } @@ -288,9 +292,6 @@ class user_BootosController extends Zend_Controller_Action $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); - - $configMapper = new Application_Model_ConfigMapper(); - $configlist = $configMapper->findBy(array("groupID" => $groupID)); $bootos = new Application_Model_BootOs(); $bootos = $this->bootosMapper->find($bootosID); @@ -303,7 +304,6 @@ class user_BootosController extends Zend_Controller_Action $bootosForm = new user_Form_Bootos(array( 'action' => 'editbootos', 'groupdepth' => $childgroups, - 'configlist'=>$configlist, 'page' => $this->page)); $bootosForm->populate($bootos->toArray()); @@ -312,7 +312,6 @@ class user_BootosController extends Zend_Controller_Action $bootosForm = new user_Form_Bootos(array( 'action' => 'editbootos', 'groupdepth' => $childgroups, - 'configlist'=>$configlist, 'page' => $this->page),$_POST); if ($bootosForm->isValid($_POST)) { @@ -322,11 +321,13 @@ class user_BootosController extends Zend_Controller_Action $bootos = new Application_Model_BootOs($_POST); $bootos->setGroupID($this->membership->getGroupID()); $bootos->setCreated(time()); - if($bootos->getConfigID() == '') - $bootos->setConfigID(NULL); $bootos->setID($bootosID); - if( $bootos->getConfigID() != $bootosold->getConfigID() || + if( $bootos->getSource() != $bootosold->getSource() || + $bootos->getDistro() != $bootosold->getDistro() || + $bootos->getDistroversion() != $bootosold->getDistroversion() || + $bootos->getShare() != $bootosold->getShare() || + $bootos->getShortname() != $bootosold->getShortname() || $bootos->getDefaultkcl() != $bootosold->getDefaultkcl() || $bootos->getExpires() != $bootosold->getExpires() || $bootos->getPublic() != $bootosold->getPublic() ){ @@ -335,7 +336,7 @@ class user_BootosController extends Zend_Controller_Action $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); } - if($bootos->getPath_kernel() != $bootosold->getPath_kernel() || $bootos->getPath_init() != $bootosold->getPath_init()){ + if($bootos->getPath_config() != $bootosold->getPath_config() || $bootos->getPath_kernel() != $bootosold->getPath_kernel() || $bootos->getPath_init() != $bootosold->getPath_init()){ //ACL Is he allowed to edit the Kernel/Init Path? if(!Pbs_Acl::checkRight('boe')) $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); @@ -345,8 +346,9 @@ class user_BootosController extends Zend_Controller_Action $hash = md5(microtime(1)); exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); + exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); - if(!array_pop($status) || !array_pop($status2)){ + if(!array_pop($status) || !array_pop($status2) || !array_pop($status3)){ $this->view->bootosForm = $bootosForm; $pbsNotifier = new Pbs_Notifier(); echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); @@ -356,13 +358,15 @@ class user_BootosController extends Zend_Controller_Action $initpath = "../resources/bootos/".$bootosID."/initramfs/"; $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; - + $configpath = "../resources/bootos/".$bootosID."/config/"; + mkdir($initpath ,0777, true); mkdir($kernelpath ,0777, true); - + mkdir($configpath ,0777, true); + exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); - + exec("mv ../resources/bootos/config$hash $initpath"."config.tgz"); } try { |
