summaryrefslogtreecommitdiffstats
path: root/application/controllers/ResourceController.php
diff options
context:
space:
mode:
authormichael pereira2011-04-18 16:33:13 +0200
committermichael pereira2011-04-18 16:33:13 +0200
commitbe3bf392777efb6c953064e095b5fe510bff1ca8 (patch)
treed05ed80b1d25ce33b4bdf8d2c21a105e99b133b7 /application/controllers/ResourceController.php
parentPublic Level -1 (nicht freigeschaltet) bei Bootiso und Bootos (diff)
downloadpbs2-be3bf392777efb6c953064e095b5fe510bff1ca8.tar.gz
pbs2-be3bf392777efb6c953064e095b5fe510bff1ca8.tar.xz
pbs2-be3bf392777efb6c953064e095b5fe510bff1ca8.zip
API-Key bei Membership & BootOS über API fertig
Diffstat (limited to 'application/controllers/ResourceController.php')
-rw-r--r--application/controllers/ResourceController.php85
1 files changed, 77 insertions, 8 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index f6b63e2..86d3f5b 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -5,6 +5,7 @@ class ResourceController extends Zend_Controller_Action
private $thisSession;
private $page;
+ private $membership;
public function init()
{
@@ -16,14 +17,25 @@ class ResourceController extends Zend_Controller_Action
//TODO Error Messages if something failed
$alpha = $this->_request->getParam('alpha');
- if($alpha != "0"){
- $alphasessionID = $alpha;
- $result = $sm->findBy(array('alphasessionID' => $alphasessionID),true);
- # print_a($result);
- $this->thisSession = $session->setOptions($result[0]);
- $this->thisSession->setID($result[0]['sessionID']);
+ $apikey = $this->_request->getParam('apikey');
+
+ if($apikey != ""){
+ $membershipMapper = new Application_Model_MembershipMapper();
+ $this->membership = new Application_Model_Membership();
+ $rightrolesMapper = new Application_Model_RightRolesMapper();
+ $rightroles = new Application_Model_RightRoles();
+ @list($this->membership) = $membershipMapper->findBy(array('apikey' => $apikey));
+ if($this->membership == null){
+ header('HTTP/1.0 401 Member not found');
+ die();
+ }
+ @list($rightroles) = $rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to Create Bootos');
+ die();
+ }
}
- else{
+ elseif($alpha == "0"){
$bootmenuentryID = $this->_request->getParam('bootmenuentryID');
$this->page = $this->_request->getParam('page');
@@ -45,13 +57,70 @@ class ResourceController extends Zend_Controller_Action
$this->thisSession = $session;
}
+ elseif($alpha != ""){
+ $alphasessionID = $alpha;
+ $result = $sm->findBy(array('alphasessionID' => $alphasessionID),true);
+ # print_a($result);
+ $this->thisSession = $session->setOptions($result[0]);
+ $this->thisSession->setID($result[0]['sessionID']);
+ }
}
public function indexAction()
{
+
-
+ }
+
+ public function addbootosAction()
+ {
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == ""){
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ if(!isset($params['title'])){
+ header('HTTP/1.0 400 Title must be set');
+ die();
+ }
+
+ $bootos = new Application_Model_BootOs();
+ $bootosMapper = new Application_Model_BootOsMapper();
+
+ $bootos->setOptions($params);
+ $bootos->setGroupID($this->membership->getGroupID());
+ $bootos->setSource($_SERVER['REMOTE_ADDR']);
+ $bootos->setPath_config($_FILES['config']['name']);
+ $bootos->setPath_init($_FILES['init']['name']);
+ $bootos->setPath_kernel($_FILES['kernel']['name']);
+ $bootos->setCreated(time());
+ $bootos->setPublic('-1');
+ $bootosID = $bootosMapper->save($bootos);
+
+ print_a($bootos);
+ $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);
+
+ if(isset($_FILES['config'])){
+ move_uploaded_file($_FILES['config']['tmp_name'], $configpath."config.tgz");
+ }
+ if(isset($_FILES['kernel'])){
+ move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
+ }
+ if(isset($_FILES['init'])){
+ move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
+ }
+
+ header('HTTP/1.0 201 Bootos created');
+
}
public function getinitramfsAction()