backend model
This commit is contained in:
@@ -296,7 +296,8 @@ class WrenchApi extends BaseController
|
|||||||
$in["pid"] = 100;
|
$in["pid"] = 100;
|
||||||
$out = array();
|
$out = array();
|
||||||
if ( $call_backend == true){
|
if ( $call_backend == true){
|
||||||
// $ret = $wrenchboard->wrenchboard_api($in, $out);
|
$wrenchboard = new \App\Models\BackendModel();
|
||||||
|
$ret = $wrenchboard->wrenchboard_api($in, $out);
|
||||||
$out['internal_return'] = 0; // $ret; // this is reserved array parameter - to be captured and received before you use the out array()
|
$out['internal_return'] = 0; // $ret; // this is reserved array parameter - to be captured and received before you use the out array()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
class BackendModel extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
var $thisUser = 'oameye';
|
||||||
|
var $USER = '';
|
||||||
|
var $wrenchboard;
|
||||||
|
const DEBUG_API_CALLS = true;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
|
||||||
|
$this->USER = $_SERVER['SCRIPT_FILENAME'];
|
||||||
|
$this->USER = str_replace('/home', '', $this->USER);
|
||||||
|
$this->USER = strtok($this->USER, '/');
|
||||||
|
if ($this->USER == 'opt') {
|
||||||
|
$this->USER = 'root';
|
||||||
|
}
|
||||||
|
$this->thisUser = $this->USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wrenchboard_api($in, $out = array()) {
|
||||||
|
$this->wrenchboard_load();
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wrenchboard_api2($in, $out) {
|
||||||
|
$this->wrenchboard_load();
|
||||||
|
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logMessage($str) {
|
||||||
|
$this->wrenchboard_load();
|
||||||
|
if ($str == NULL || trim($str) == '') {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (self::DEBUG_API_CALLS) {
|
||||||
|
$stack = debug_backtrace();
|
||||||
|
$log = json_encode($stack);
|
||||||
|
error_log($log);
|
||||||
|
error_log($str);
|
||||||
|
}
|
||||||
|
$ret = $this->wrenchboard->logMessage($str);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cfgReadChar($str) {
|
||||||
|
$this->wrenchboard_load();
|
||||||
|
if ($str == NULL || trim($str) == '') {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (self::DEBUG_API_CALLS) {
|
||||||
|
$stack = debug_backtrace();
|
||||||
|
$log = json_encode($stack);
|
||||||
|
error_log($log);
|
||||||
|
error_log($str);
|
||||||
|
}
|
||||||
|
$ret = $this->wrenchboard->cfgReadChar($str);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cfgReadLong($str) {
|
||||||
|
$this->wrenchboard_load();
|
||||||
|
if ($str == NULL || trim($str) == '') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (self::DEBUG_API_CALLS) {
|
||||||
|
$stack = debug_backtrace();
|
||||||
|
$log = json_encode($stack);
|
||||||
|
error_log($log);
|
||||||
|
error_log($str);
|
||||||
|
}
|
||||||
|
$ret = $this->wrenchboard->cfgReadLong($str);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function wrenchboard_load() {
|
||||||
|
$wrenchboard_class = 'wrenchboard_api_' . $this->USER . '\\WrenchBoard';
|
||||||
|
if (!is_object($this->wrenchboard)) {
|
||||||
|
$this->wrenchboard = new $wrenchboard_class();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user