summaryrefslogtreecommitdiffstats
path: root/application/modules/dev
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/dev')
-rw-r--r--application/modules/dev/controllers/BootisoController.php15
-rw-r--r--application/modules/dev/controllers/BootosController.php74
-rw-r--r--application/modules/dev/controllers/ResourceController.php16
-rw-r--r--application/modules/dev/forms/BootisoCreate.php4
-rw-r--r--application/modules/dev/views/scripts/bootiso/index.phtml4
-rw-r--r--application/modules/dev/views/scripts/bootos/index.phtml18
6 files changed, 112 insertions, 19 deletions
diff --git a/application/modules/dev/controllers/BootisoController.php b/application/modules/dev/controllers/BootisoController.php
index 2b0e624..86454cd 100644
--- a/application/modules/dev/controllers/BootisoController.php
+++ b/application/modules/dev/controllers/BootisoController.php
@@ -42,7 +42,22 @@ class dev_BootisoController extends Zend_Controller_Action
$bootiso->setCreated(time());
try {
+
+ exec("wget --spider ".$bootiso->getPath_fbgui()." 2>&1 | grep 'Remote file exists.'", $exists_fbgui);
+
+ if(!array_pop($exists_fbgui)){
+ $this->view->createbootisoForm = $createbootisoForm;
+ return;
+ }
+
$bootisomapper->save($bootiso);
+
+ $path_fbgui = "../resources/bootmedium/fbgui/";
+
+ exec("wget -P ".$path_fbgui." -N ".$bootiso->getPath_fbgui());
+
+
+
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "<br/>";
diff --git a/application/modules/dev/controllers/BootosController.php b/application/modules/dev/controllers/BootosController.php
index 36c1cf5..5f8aaf0 100644
--- a/application/modules/dev/controllers/BootosController.php
+++ b/application/modules/dev/controllers/BootosController.php
@@ -19,8 +19,11 @@ class dev_BootosController extends Zend_Controller_Action
$configmapper = new Application_Model_ConfigMapper();
$this->view->bootoslist = $bootosmapper->fetchAll();
+ $this->view->update = array();
+
if(count($this->view->bootoslist)>0){
foreach ($this->view->bootoslist as $bootos){
+ $this->view->update[$bootos->getID()] = $this->checkupdateAction($bootos);
$bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupmapper->find($bootos->getGroupID())->getTitle());
$bootos->setMembershipID("[".$bootos->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootos->getMembershipID())->getPersonID())->getFirstname());
$bootos->setConfigID("[".$bootos->getConfigID()."] ".$configmapper->find($bootos->getConfigID())->getTitle());
@@ -36,12 +39,12 @@ class dev_BootosController extends Zend_Controller_Action
$configmapper = new Application_Model_ConfigMapper();
if (!isset($_POST["createbootos"])){
- try{
+ try{
$createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()));
- }catch(Zend_Exception $e){
- print_a($e);
- }
- } else {
+ }catch(Zend_Exception $e){
+ print_a($e);
+ }
+ } else {
$createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST);
@@ -55,13 +58,23 @@ class dev_BootosController extends Zend_Controller_Action
$bootos->setCreated(time());
try {
+ exec("wget --spider ".$bootos->getPath_kernel()." 2>&1 | grep 'Remote file exists.'", $exists_kernel);
+ exec("wget --spider ".$bootos->getPath_init()." 2>&1 | grep 'Remote file exists.'" , $exists_init);
+
+ if(!array_pop($exists_init) || !array_pop($exists_kernel)){
+ $this->view->createbootosForm = $createbootosForm;
+ return;
+ }
+
$bootosID = $bootosmapper->save($bootos);
$initpath = "../resources/bootos/".$bootosID."/initramfs/";
$kernelpath = "../resources/bootos/".$bootosID."/kernel/";
-
+
exec("wget -P ".$kernelpath." ".$bootos->getPath_kernel());
- exec("wget -P ".$initpath." ".$bootos->getPath_init());
+ exec("wget -P ".$initpath." ".$bootos->getPath_init());
+
+
}catch(Zend_Exception $e)
{
@@ -76,6 +89,52 @@ class dev_BootosController extends Zend_Controller_Action
$this->view->createbootosForm = $createbootosForm;
}
+
+ public function checkupdateAction($bootos)
+ {
+ 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);
+
+ $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate))));
+ $kernelname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/kernel/"));
+
+ if($kernelname != "." && $kernelname != "..")
+ $kernelolddate = filemtime("../resources/bootos/".$bootos->getID()."/kernel/".$kernelname);
+ else
+ $kernelolddate = false;
+
+ $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate))));
+ $initname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/initramfs/"));
+
+ if($initname != "." && $initname != "..")
+ $initolddate = filemtime("../resources/bootos/".$bootos->getID()."/initramfs/".$initname);
+ else
+ $initolddate = false;
+
+ //print_a($kernelname,$kerneldate,$kernelolddate,$initname,$initdate,$initolddate);
+
+
+ if($kerneldate > $kernelolddate || $initdate > $initolddate)
+ return true;
+ else
+ return false;
+
+ }
+
+ public function updatebootosAction()
+ {
+ $bootosID = $this->_request->getParam('bootosID');
+ $bootosmapper = new Application_Model_BootOsMapper();
+ $bootos = $bootosmapper->find($bootosID);
+
+ $initpath = "../resources/bootos/".$bootosID."/initramfs/";
+ $kernelpath = "../resources/bootos/".$bootosID."/kernel/";
+
+ exec("wget -P ".$kernelpath." -N ".$bootos->getPath_kernel());
+ exec("wget -P ".$initpath." -N ".$bootos->getPath_init());
+
+ $this->_redirect('/dev/bootos');
+ }
public function editbootosAction()
{
@@ -100,6 +159,7 @@ class dev_BootosController extends Zend_Controller_Action
if ($editbootosForm->isValid($_POST)) {
+ //TODO: Check for new URL and download new files.
$bootos = new Application_Model_BootOs($_POST);
$bootos->setMembershipID('1');
if($bootos->getConfigID() == '')
diff --git a/application/modules/dev/controllers/ResourceController.php b/application/modules/dev/controllers/ResourceController.php
index 653b70d..cbca8d0 100644
--- a/application/modules/dev/controllers/ResourceController.php
+++ b/application/modules/dev/controllers/ResourceController.php
@@ -33,14 +33,16 @@ class dev_ResourceController extends Zend_Controller_Action
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})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $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/");
- passthru( "cat initramfs");
+ $initname = array_pop(scandir("./"));
+
+ passthru( "cat ".$initname);
}
}
@@ -58,7 +60,7 @@ class dev_ResourceController extends Zend_Controller_Action
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})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="config.tar.gz"');
header('Pragma: no-cache');
header('Expires: 0');
@@ -76,14 +78,16 @@ class dev_ResourceController extends Zend_Controller_Action
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})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $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/");
- passthru( "cat kernel");
+ $kernelname = array_pop(scandir("./"));
+
+ passthru( "cat ". $kernelname);
}
}
@@ -98,7 +102,7 @@ class dev_ResourceController extends Zend_Controller_Action
$bmemapper->find($bmeID,$bme);
header('Content-Type: text/html');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $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');
diff --git a/application/modules/dev/forms/BootisoCreate.php b/application/modules/dev/forms/BootisoCreate.php
index 1615f6e..2ecc2d2 100644
--- a/application/modules/dev/forms/BootisoCreate.php
+++ b/application/modules/dev/forms/BootisoCreate.php
@@ -35,14 +35,14 @@ class dev_Form_BootisoCreate extends Zend_Form
$groupfield->setRegisterInArrayValidator(false);
$this->addElement($groupfield);
- $this->addElement('text', 'path', array(
+ $this->addElement('text', 'path_fbgui', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 50)),
),
'required' => true,
'size' => 50,
- 'label' => 'Path:',
+ 'label' => 'Path to FbGui:',
));
$this->addElement('text', 'serialnumber', array(
diff --git a/application/modules/dev/views/scripts/bootiso/index.phtml b/application/modules/dev/views/scripts/bootiso/index.phtml
index b119aff..453f316 100644
--- a/application/modules/dev/views/scripts/bootiso/index.phtml
+++ b/application/modules/dev/views/scripts/bootiso/index.phtml
@@ -8,7 +8,7 @@
<th>Title</th>
<th>GroupID</th>
<th>MembershipID</th>
- <th>Path</th>
+ <th>FbGui Path</th>
<th>Serialnumber</th>
<th>Created</th>
<th>Expires</th>
@@ -23,7 +23,7 @@
<td><?php echo $this->escape($bootiso->getTitle()); ?></td>
<td><?php echo $this->escape($bootiso->getGroupID()); ?></td>
<td><?php echo $this->escape($bootiso->getMembershipID()); ?></td>
- <td><?php echo $this->escape($bootiso->getPath()); ?></td>
+ <td><?php echo $this->escape($bootiso->getPath_fbgui()); ?></td>
<td><?php echo $this->escape($bootiso->getSerialnumber()); ?></td>
<td><?php echo $this->escape(date('Y-m-d H:i:s', $bootiso->getCreated())); ?></td>
<td><?php echo $this->escape($bootiso->getExpires()); ?></td>
diff --git a/application/modules/dev/views/scripts/bootos/index.phtml b/application/modules/dev/views/scripts/bootos/index.phtml
index c5970b6..f76938d 100644
--- a/application/modules/dev/views/scripts/bootos/index.phtml
+++ b/application/modules/dev/views/scripts/bootos/index.phtml
@@ -17,7 +17,7 @@
<th>Changed</th>
<th>Expires</th>
<th>Public</th>
- <th colspan=2>Actions</th>
+ <th colspan=3>Actions</th>
</tr>
<?php if(count($this->bootoslist)==0)
echo "</table> There are no BootOs's to display." ?>
@@ -35,6 +35,20 @@
<td><?php echo $this->escape(date('Y-m-d H:i:s', $bootos->getCreated())); ?></td>
<td><?php echo $this->escape($bootos->getExpires()); ?></td>
<td><?php echo $this->escape($bootos->getPublic()); ?></td>
+ <?php if($this->update[$bootos->getID()]==true): ?>
+ <td class='action'><a
+ href="<?php echo $this->url(
+ array(
+ 'module' => 'dev',
+ 'controller' => 'bootos',
+ 'action' => 'updatebootos',
+ 'bootosID' => $bootos->getID()
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/update.png' alt='Updates available' /></a></td>
+ <?php else: ?>
+ <td class='action'><img src='/media/img/update_grey.png' alt='No updates available' /></td>
+ <?php endif; ?>
<td class='action'><a
href="<?php echo $this->url(
array(
@@ -54,7 +68,7 @@
'bootosID' => $bootos->getID()
),
'default',
- true) ?>"><img src='/media/img/delete.png' alt='Delete BootOS' /></a></td>
+ true) ?>"><img src='/media/img/delete.png' alt='Delete BootOS' /></a></td>
</tr>
<?php endforeach; ?>
</table>