/svs/user API support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
FROM nginx
|
||||
COPY . /opt/mainsite/wrenchboard/www-api/
|
||||
COPY index.php /opt/mainsite/wrenchboard/www-api/index.php
|
||||
COPY backend.php /opt/mainsite/wrenchboard/www-api/backend.php
|
||||
COPY application /opt/mainsite/wrenchboard/www-api/application
|
||||
COPY system /opt/mainsite/wrenchboard/www-api/system
|
||||
COPY composer.json /opt/mainsite/wrenchboard/www-api/composer.json
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?
|
||||
if (!array_key_exists('wrenchboard', $GLOBALS)) {
|
||||
class WrenchBoardAPIWrapper {
|
||||
const DEBUG_API_CALLS = true;
|
||||
public $wrenchboard;
|
||||
public $USER = 'root';
|
||||
public function __construct()
|
||||
{
|
||||
$USER = $_SERVER['SCRIPT_FILENAME'];
|
||||
$USER = str_replace('/home', '', $USER);
|
||||
$USER = strtok($USER, '/');
|
||||
if ($USER=='opt') $USER = 'root';
|
||||
// Load API class
|
||||
$USER = 'root';
|
||||
$this->USER = $USER;
|
||||
}
|
||||
|
||||
public function wrenchboard_api($in, $out = array()) {
|
||||
if (!is_array($in)) {
|
||||
$in = array();
|
||||
}
|
||||
if (!is_array($out)) {
|
||||
$out = array();
|
||||
}
|
||||
if (self::DEBUG_API_CALLS) {
|
||||
$stack = debug_backtrace();
|
||||
$log = json_encode($stack);
|
||||
error_log($log);
|
||||
error_log(json_encode($in));
|
||||
}
|
||||
$this->wrenchboard_load();
|
||||
return $this->wrenchboard->wrenchboard_api($in, $out);
|
||||
}
|
||||
|
||||
public function logMessage($in) {
|
||||
if ($in == null || trim($in) == "") {
|
||||
return null;
|
||||
}
|
||||
if (self::DEBUG_API_CALLS) {
|
||||
$stack = debug_backtrace();
|
||||
$log = json_encode($stack);
|
||||
error_log($log);
|
||||
error_log($in);
|
||||
}
|
||||
$this->wrenchboard_load();
|
||||
return $this->wrenchboard->logMessage($in);
|
||||
}
|
||||
|
||||
public function cfgReadChar($in) {
|
||||
if ($in == null || trim($in) == "") {
|
||||
return null;
|
||||
}
|
||||
if (self::DEBUG_API_CALLS) {
|
||||
$stack = debug_backtrace();
|
||||
$log = json_encode($stack);
|
||||
error_log($log);
|
||||
error_log($in);
|
||||
}
|
||||
$this->wrenchboard_load();
|
||||
return $this->wrenchboard->cfgReadChar($in);
|
||||
}
|
||||
|
||||
public function cfgReadLong($in) {
|
||||
if ($in == null || trim($in) == "") {
|
||||
return 0;
|
||||
}
|
||||
if (self::DEBUG_API_CALLS) {
|
||||
$stack = debug_backtrace();
|
||||
$log = json_encode($stack);
|
||||
error_log($log);
|
||||
error_log($in);
|
||||
}
|
||||
$this->wrenchboard_load();
|
||||
return $this->wrenchboard->cfgReadLong($in);
|
||||
}
|
||||
|
||||
private function wrenchboard_load() {
|
||||
// global $wrenchboard;
|
||||
// $this->$USER = $_SERVER['SCRIPT_FILENAME'];
|
||||
$wrenchboard_class = 'wrenchboard_api_' . $this->USER . '\\WrenchBoard';
|
||||
if (!is_object($this->wrenchboard)) {
|
||||
$this->wrenchboard = new $wrenchboard_class();
|
||||
}
|
||||
/* if (is_object($wrenchboard) && is_object($wrenchboard->wrenchboard)) {
|
||||
$this->wrenchboard = $wrenchboard->wrenchboard;
|
||||
} else if (is_object($wrenchboard)) {
|
||||
$this->wrenchboard = $wrenchboard;
|
||||
} else if (!is_object($this->wrenchboard)) {
|
||||
$this->wrenchboard = new $wrenchboard_class();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
global $wrenchboard;
|
||||
$wrenchboard = new WrenchBoardAPIWrapper();
|
||||
}
|
||||
?>
|
||||
@@ -15,6 +15,8 @@ fastcgi_param REMOTE_PORT $remote_port;
|
||||
fastcgi_param SERVER_ADDR $server_addr;
|
||||
fastcgi_param SERVER_PORT $server_port;
|
||||
fastcgi_param SERVER_NAME $server_name;
|
||||
fastcgi_param X-FORWARDED-FOR $remote_addr;
|
||||
fastcgi_param X-REAL-IP $remote_addr;
|
||||
|
||||
fastcgi_index index.php;
|
||||
|
||||
|
||||
@@ -46,6 +46,29 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
location /svs/user/ {
|
||||
try_files $uri $uri/ /svs/user/userve.php?$args;
|
||||
proxy_intercept_errors off;
|
||||
error_page 404 /svs/user/userve.php;
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
#if (!-f $document_root$fastcgi_script_name) {
|
||||
# return 404;
|
||||
#}
|
||||
fastcgi_pass host.docker.internal:9999;
|
||||
fastcgi_param SCRIPT_FILENAME /opt/mainsite/wrenchboard/www-api$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
error_page 404 /svs/user/userve.php;
|
||||
}
|
||||
|
||||
location = /svs/user/userve.php {
|
||||
fastcgi_pass host.docker.internal:9999;
|
||||
fastcgi_param SCRIPT_FILENAME /opt/mainsite/wrenchboard/www-api$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
return 444;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user