<?php
-/**
- * Bacula® - The Network Backup Solution
- * Baculum - Bacula web interface
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
*
- * Copyright (C) 2013-2014 Marcin Haba
+ * Copyright (C) 2013-2015 Marcin Haba
*
* The main author of Baculum is Marcin Haba.
- * The main author of Bacula is Kern Sibbald, with contributions from many
- * others, a complete list can be found in the file AUTHORS.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
*
* You may use this file and others of this release according to the
* license defined in the LICENSE file, which includes the Affero General
* Public License, v3.0 ("AGPLv3") and some additional permissions and
* terms pursuant to its AGPLv3 Section 7.
*
- * Bacula® is a registered trademark of Kern Sibbald.
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
*/
Prado::using('System.Exceptions.TException');
protected $director;
+ protected $user;
+
/**
* Actions methods.
*/
public function onInit($params) {
parent::onInit($params);
+ /*
+ * Workaround to bug in PHP 5.6 by FastCGI that caused general protection error.
+ * TODO: Check on newer PHP if it is already fixed.
+ */
+ $db = new ActiveRecord();
+ $db->getDbConnection();
$this->director = isset($this->Request['director']) ? $this->Request['director'] : null;
+
+ $user = isset($_SERVER['HTTP_X_BACULUM_USER']) ? $_SERVER['HTTP_X_BACULUM_USER']: null;
+ $pwd = isset($_SERVER['HTTP_X_BACULUM_PWD']) ? $_SERVER['HTTP_X_BACULUM_PWD']: null;
+ if(!is_null($user) && !is_null($pwd)) {
+ $logged = $this->Application->getModule('users')->loginUser($user, $pwd);
+ if ($logged === true) {
+ $this->user = ($this->User->getIsAdmin() === false) ? $user : null;
+ } else {
+ $this->output = AuthorizationError::MSG_ERROR_AUTHORIZATION_TO_WEBGUI_PROBLEM;
+ $this->error = AuthorizationError::ERROR_AUTHORIZATION_TO_WEBGUI_PROBLEM;
+ return;
+ }
+ } else {
+ $this->output = AuthorizationError::MSG_ERROR_AUTHORIZATION_TO_WEBGUI_PROBLEM;
+ $this->error = AuthorizationError::ERROR_AUTHORIZATION_TO_WEBGUI_PROBLEM;
+ return;
+ }
+
switch($_SERVER['REQUEST_METHOD']) {
case self::PUT_METHOD: {
try {
$params = (object)$this->Request['update'];
$this->set($id, $params);
} else {
- parse_str(file_get_contents("php://input"),$responseData);
+ $inputstr = file_get_contents("php://input");
+ $chunks = explode('&', $inputstr);
+ $responseData = array();
+ for($i = 0; $i<count($chunks); $i++) {
+ parse_str($chunks[$i], $responseEl);
+ if(is_array($responseEl) && array_key_exists('update', $responseEl) && is_array($responseEl['update'])) {
+ $key = key($responseEl['update']);
+ $responseData['update'][$key] = $responseEl['update'][$key];
+ }
+ }
if(is_array($responseData) && array_key_exists('update', $responseData)) {
$params = (object)$responseData['update'];
$this->set($id, $params);
return $this->Application->getModule($name);
}
}
-?>
\ No newline at end of file
+?>