summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/EventController.php38
1 files changed, 35 insertions, 3 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index abde79d..a0c342b 100644
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -43,14 +43,47 @@ class EventController extends Zend_Controller_Action
return;
}
} else if($actionName == "report" || $actionName == "run") {
+ $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
if(isset($this->userIDsNamespace['apikey'])) {
$apikey = $this->userIDsNamespace['apikey'];
} else {
$apikey = $this->_request->getParam('apikey');
}
if($apikey == ""){
- header('HTTP/1.0 400 No API-Key');
- die();
+ $email = $this->_request->getParam('email');
+ $password = $this->_request->getParam('password');
+ if(!isset($email)) {
+ header('HTTP/1.0 401 No email is set');
+ die();
+ }
+ if(!isset($password)) {
+ header('HTTP/1.0 401 No password is set');
+ die();
+ }
+ $loginquery = "email=" . $email . "&password=" . $password;
+ $loginApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['login'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', $loginquery);
+ $loginXMLString = $loginApiResult['http-body'];
+ if(strlen($loginXMLString) > 0) {
+ $loginXML = new SimpleXMLElement($loginXMLString);
+ $login = $loginXML->login;
+ $success = sprintf("%s", $login->success);
+ if ($success === "true") {
+ $bootstrap = $this->getInvokeArg('bootstrap');
+ $this->config = $bootstrap->getOptions();
+ $this->pbs2host = $this->config['pbs2']['host'];
+ $this->gearmanServerHost = $this->config['gearman']['server']['host'];
+ $this->gearmanServerPort = $this->config['gearman']['server']['port'];
+ $this->gearmanWorkerWaitTime = $this->config['gearman']['worker']['waitTime'];
+ $this->gearmanWorkerUpdateRate = $this->config['gearman']['worker']['updateRate'];
+ $this->gearmanClient = new GearmanClient();
+ $this->gearmanClient->addServer($this->gearmanServerHost);
+ $this->eventMapper = new Application_Model_EventMapper();
+ $this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
+ } else {
+ header('HTTP/1.0 401 Wrong email or password');
+ die();
+ }
+ }
} else {
$bootstrap = $this->getInvokeArg('bootstrap');
$this->config = $bootstrap->getOptions();
@@ -61,7 +94,6 @@ class EventController extends Zend_Controller_Action
$this->gearmanWorkerUpdateRate = $this->config['gearman']['worker']['updateRate'];
$this->gearmanClient = new GearmanClient();
$this->gearmanClient->addServer($this->gearmanServerHost);
- $this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$this->eventMapper = new Application_Model_EventMapper();
$this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
}