API debugging wrappers
This commit is contained in:
@@ -5,6 +5,7 @@ class Backend_model extends CI_Model {
|
||||
var $thisUser = 'oameye';
|
||||
var $USER = '';
|
||||
var $wrenchboard;
|
||||
const DEBUG_API_CALLS = true;
|
||||
|
||||
function __construct() {
|
||||
|
||||
@@ -19,7 +20,19 @@ class Backend_model extends CI_Model {
|
||||
|
||||
public function wrenchboard_api($in, $out = array()) {
|
||||
$this->wrenchboard_load();
|
||||
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
||||
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);
|
||||
|
||||
// var_dump($ret);
|
||||
// echo "-----";
|
||||
@@ -34,17 +47,60 @@ class Backend_model extends CI_Model {
|
||||
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(json_encode($in));
|
||||
}
|
||||
$ret = $this->wrenchboard->logMessage($str);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function cfgReadChar($str) {
|
||||
$this->wrenchboard_load();
|
||||
$ret = $this->wrenchboard->cfgReadChar($str);
|
||||
if ($str == NULL || trim($str) == '') {
|
||||
return NULL;
|
||||
}
|
||||
if (self::DEBUG_API_CALLS) {
|
||||
$stack = debug_backtrace();
|
||||
$log = json_encode($stack);
|
||||
error_log($log);
|
||||
error_log(json_encode($in));
|
||||
}
|
||||
$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(json_encode($in));
|
||||
}
|
||||
$ret = $this->wrenchboard->cfgReadLong($str);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function wrenchboard_load() {
|
||||
global $wrenchboard;
|
||||
// $this->$USER = $_SERVER['SCRIPT_FILENAME'];
|
||||
$wrenchboard_class = 'wrenchboard_api_' . $this->USER . '\\WrenchBoard';
|
||||
if (!is_object($this->wrenchboard)) {
|
||||
$wrenchboard_class = 'wrenchboard_api_' . $this->USER . '\\WrenchBoard';
|
||||
/* 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();
|
||||
}
|
||||
}
|
||||
|
||||
+94
-8
@@ -1,12 +1,98 @@
|
||||
<?
|
||||
var_dump($GLOBALS);
|
||||
if (!array_key_exists('wrenchboard', $GLOBALS)) {
|
||||
$USER = $_SERVER['SCRIPT_FILENAME'];
|
||||
$USER = str_replace('/home', '', $USER);
|
||||
$USER = strtok($USER, '/');
|
||||
if ($USER=='opt') $USER = 'root';
|
||||
// Load API class
|
||||
$USER = 'oameye';
|
||||
$wrenchboard_class = 'wrenchboard_api_' . $USER . '\\WrenchBoard';
|
||||
$wrenchboard = new $wrenchboard_class();
|
||||
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();
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -22,20 +22,51 @@ class backend {
|
||||
|
||||
public function wrenchboard_api($in, $out = array()) {
|
||||
$this->wrenchboard_load();
|
||||
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
||||
if (!is_array($in)) {
|
||||
$in = array();
|
||||
}
|
||||
if (!is_array($out)) {
|
||||
$out = array();
|
||||
}
|
||||
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function logMessage($str) {
|
||||
$this->wrenchboard_load();
|
||||
if ($str == NULL || trim($str) == '') {
|
||||
return NULL;
|
||||
}
|
||||
$ret = $this->wrenchboard->logMessage($str);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function cfgReadChar($str) {
|
||||
$this->wrenchboard_load();
|
||||
$this->wrenchboard_load();
|
||||
if ($str == NULL || trim($str) == '') {
|
||||
return NULL;
|
||||
}
|
||||
$ret = $this->wrenchboard->cfgReadChar($str);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function cfgReadLong($str) {
|
||||
$this->wrenchboard_load();
|
||||
if ($str == NULL || trim($str) == '') {
|
||||
return 0;
|
||||
}
|
||||
$ret = $this->wrenchboard->cfgReadLong($str);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function wrenchboard_load() {
|
||||
// $this->$USER = $_SERVER['SCRIPT_FILENAME'];
|
||||
$wrenchboard_class = 'wrenchboard_api_' . $this->USER . '\\WrenchBoard';
|
||||
if (!is_object($this->wrenchboard)) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user