Commit 6d0c3621 authored by Antonio.Suerte's avatar Antonio.Suerte

System Debug Settings

parent 6a160d60
......@@ -61,15 +61,4 @@ class DevComponents extends System {
date("Y-m-d H:i:s")
], false);
}
/**
*
* @param string $string
* @return boolean
*/
public function isJSON($string){
return is_string($string)
&& is_array(json_decode($string, true))
&& (json_last_error() == JSON_ERROR_NONE) ? true : false;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -110,6 +110,21 @@ class CommonBase {
}
}
/*-------------------------------------------------------------------------
* @function_name: デバッグコンフィグレーション
* @parameter : なし
* @return : bool|string
-------------------------------------------------------------------------*/
public function getDebuggerConf(){
$debugContainer = LIBRARIES."debug-container.txt";
if(@file_exists($debugContainer)){
return file_get_contents($debugContainer);
}
return false;
}
/*-------------------------------------------------------------------------
* @function_name: 提示文言多语言设置
* @parameter :
......
<?php
use Defuse\Crypto\Crypto;
class DBAccess extends Cnnector {
/*-------------------------------------------------------------------------
......@@ -6,6 +8,10 @@ class DBAccess extends Cnnector {
-------------------------------------------------------------------------*/
public $sqlXml; // SQLファイルの配列
private $debugConf;
private $cryptConf;
private $containerContent;
/*-------------------------------------------------------------------------
* @function_name: DBアクセスクラスコンストラクタ
* @detail : スーパークラスのコンストラクタを呼び出す
......@@ -31,6 +37,7 @@ class DBAccess extends Cnnector {
throw new Exception($this -> getMessage(ERROR, E_CAN_NOT_OPEN_SQL_FILE, array()), -1);
}
$this -> cryptConf = $this -> getDebuggerConf();
} catch(Exception $e) {
die($e -> getMessage() . '<br>');
}
......@@ -51,7 +58,6 @@ class DBAccess extends Cnnector {
$result; // 結果セット
try {
// SQL発行
$result = $this -> publishSQL($sqlId, $elementArr);
......@@ -103,7 +109,6 @@ class DBAccess extends Cnnector {
$result; // 結果セット
try {
// SQL発行
$result = $this -> publishSQL($sqlId, $elementArr);
......@@ -128,7 +133,7 @@ class DBAccess extends Cnnector {
$result; // 結果セット
try {
$this -> debugQuery($sqlId, $elementArr);
// パラメータを設定する
$sqlString = $this -> setElementParam($sqlId, $elementArr);
......@@ -147,6 +152,58 @@ class DBAccess extends Cnnector {
return($result);
}
/*-------------------------------------------------------------------------
* @function_name: デバッグクエリー
* @parameter : SQLID,パラメータ配列
* @return : bool
-------------------------------------------------------------------------*/
private function debugQuery($sqlId, $elementArr){
if(!$this -> cryptConf)
return false;
if(!isset($this -> debugConf)){
$sqlString = $this -> setElementParam("SELECT_DEV_SETTING", ["sys_debug_conf"]);
$result = $this -> getRowData($this -> rawSQL($sqlString));
if($this -> checkJSONString($result["dev_setting_value"]))
$this -> debugConf = json_decode($result["dev_setting_value"]);
}
$ipAddress = $_SERVER["REMOTE_ADDR"];
if(!isset($this -> containerContent)){
$this -> containerContent = Crypto::decryptWithPassword($this -> cryptConf, $this -> debugConf -> debugger_passphrase);
$this -> containerContent = json_decode($this -> containerContent);
}
if(!$this -> containerContent -> enabled)
return false;
if(in_array($ipAddress, $this -> containerContent -> ip_address)){
$queryMap = array_map(function($element){
return $element -> query_name;
}, $this -> containerContent -> my_commands);
if(in_array($sqlId, $queryMap)){
foreach($this -> containerContent -> my_commands as $query){
if($query -> query_name == $sqlId){
$displayFunc = $query -> display_func;
$dispAsPreTag = $query -> dp_pre_tag;
$queryString = $this -> setElementParam($sqlId, $elementArr);
$display = ($dispAsPreTag) ? "<pre>{$queryString}</pre>" : $queryString;
$displayFunc == "die"
? die($display) : print($display);
break;
}
}
}
}
return true;
}
public function rawSQL($sqlString){
$result = NO_STRING;
......
......@@ -124,7 +124,7 @@ class DeveloperModelClass extends ModelClassEx {
switch($this -> getType()){
case TYPE_DEV_CREDENTIAL_EDIT:
case TYPE_DEV_CREDENTIAL_MODIFY_PASSCODE:
case TYPE_DEV_CREDENTIAL_UPDATE_PASSCODE:
case TYPE_DEV_CREDENTIAL_PASSCODE_UPDATE:
case TYPE_DEV_CREDENTIAL_UPDATE:
if(!$this -> checkAdminUserAccess('DEVF', array('','1'))){
$this -> popUpSessionMessage(ERROR, 'E_ERROR_NO_PAGE_ACCESS', array());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment