Added provisioning code for change requests
This commit is contained in:
parent
95db8533b5
commit
e2054c13c8
|
@ -36,10 +36,15 @@ require_once (APPLICATION_PATH."/logging/Logging.php");
|
||||||
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
||||||
|
|
||||||
// We need to manually route because we can't load Zend without the database being initialized first.
|
// We need to manually route because we can't load Zend without the database being initialized first.
|
||||||
|
// We should probably look for a better way to do this rather tan overloading this if statement
|
||||||
if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) {
|
if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) {
|
||||||
$provisioningHelper = new ProvisioningHelper($CC_CONFIG["apiKey"][0]);
|
$provisioningHelper = new ProvisioningHelper($CC_CONFIG["apiKey"][0]);
|
||||||
$provisioningHelper->createAction();
|
$provisioningHelper->createAction();
|
||||||
die();
|
die();
|
||||||
|
} else if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/change") !== false)) {
|
||||||
|
$provisioningHelper = new ProvisioningHelper($CC_CONFIG["apiKey"][0]);
|
||||||
|
$provisioningHelper->changeAction();
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::setAirtimeVersion();
|
Config::setAirtimeVersion();
|
||||||
|
|
|
@ -65,8 +65,33 @@ class ProvisioningHelper
|
||||||
$this->initializePrefs();
|
$this->initializePrefs();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
Logging::error($e->getMessage()
|
Logging::error($e->getMessage());
|
||||||
);
|
echo $e->getMessage() . PHP_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
http_response_code(201);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint to change Airtime preferences remotely.
|
||||||
|
* Mainly for use with the dashboard right now.
|
||||||
|
*/
|
||||||
|
public function changeAction() {
|
||||||
|
$apikey = $_SERVER['PHP_AUTH_USER'];
|
||||||
|
if (!isset($apikey) || $apikey != $this->apikey) {
|
||||||
|
Logging::info("Invalid API Key: $apikey");
|
||||||
|
http_response_code(403);
|
||||||
|
echo "ERROR: Incorrect API key";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->parsePostParams();
|
||||||
|
$this->initializePrefs();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
Logging::error($e->getMessage());
|
||||||
echo $e->getMessage() . PHP_EOL;
|
echo $e->getMessage() . PHP_EOL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue