@@ -8,7 +8,7 @@ | |||
* @license GNU GPL v2 (https://www.dedebiz.com/license) | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(dirname(__FILE__) . "/config.php"); | |||
require_once(dirname(__FILE__)."/config.php"); | |||
if (empty($f)) { | |||
$f = 'form1.enclosure'; | |||
} | |||
@@ -17,10 +17,10 @@ if (empty($comeback)) { | |||
} | |||
$addparm = ''; | |||
if (!empty($CKEditor)) { | |||
$addparm = '&CKEditor=' . $CKEditor; | |||
$addparm = '&CKEditor='.$CKEditor; | |||
} | |||
if (!empty($CKEditorFuncNum)) { | |||
$addparm .= '&CKEditorFuncNum=' . $CKEditorFuncNum; | |||
$addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum; | |||
} | |||
if (!empty($noeditor)) { | |||
$addparm .= '&noeditor=yes'; | |||
@@ -455,15 +455,14 @@ if ($action === 'is_need_check_code') { | |||
$params = $_GET; | |||
unset($params['action']); | |||
checkLogin(); | |||
$params['timestamp'] = time(); // 加入时间戳 | |||
$params['timestamp'] = time(); //加入时间戳 | |||
$cuserLogin = new userLogin(); | |||
$params['adminid'] = $cuserLogin->getUserID(); // 加入时间戳 | |||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; // 获取客户端IP | |||
ksort($params); // 按字典序排序 | |||
$queryString = http_build_query($params); // 生成查询字符串 | |||
$params['sign'] = md5($queryString . $cfg_ai_apikey); // 计算MD5签名 | |||
$url = $cfg_ai_server . '/ai?' . http_build_query($params); | |||
$params['adminid'] = $cuserLogin->getUserID(); //加入时间戳 | |||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; //获取客户端IP | |||
ksort($params); //按字典序排序 | |||
$queryString = http_build_query($params); //生成查询字符串 | |||
$params['sign'] = md5($queryString.$cfg_ai_apikey); //计算MD5签名 | |||
$url = $cfg_ai_server.'/ai?'.http_build_query($params); | |||
echo json_encode(array( | |||
"code" => 0, | |||
"data" => $url, | |||
@@ -472,14 +471,14 @@ if ($action === 'is_need_check_code') { | |||
$params = $_GET; | |||
unset($params['action']); | |||
checkLogin(); | |||
$params['timestamp'] = time(); // 加入时间戳 | |||
$params['timestamp'] = time(); //加入时间戳 | |||
$cuserLogin = new userLogin(); | |||
$params['adminid'] = $cuserLogin->getUserID(); // 加入时间戳 | |||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; // 获取客户端IP | |||
ksort($params); // 按字典序排序 | |||
$queryString = http_build_query($params); // 生成查询字符串 | |||
$params['sign'] = md5($queryString . $cfg_ai_apikey); // 计算MD5签名 | |||
$url = $cfg_ai_server . '/api/setbody?' . http_build_query($params); | |||
$params['adminid'] = $cuserLogin->getUserID(); //加入时间戳 | |||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; //获取客户端IP | |||
ksort($params); //按字典序排序 | |||
$queryString = http_build_query($params); //生成查询字符串 | |||
$params['sign'] = md5($queryString.$cfg_ai_apikey); //计算MD5签名 | |||
$url = $cfg_ai_server.'/api/setbody?'.http_build_query($params); | |||
echo json_encode(array( | |||
"code" => 0, | |||
"data" => $url, | |||
@@ -25,21 +25,21 @@ if ($dopost == "viewinfo") { | |||
if (empty($tablename)) { | |||
echo "没有指定表名"; | |||
} else { | |||
// 获取创建表的 SQL 语句 | |||
//获取创建表的SQL语句 | |||
$dsql->SetQuery("SELECT sql FROM sqlite_master WHERE type='table' AND name='$tablename'"); | |||
$dsql->Execute('me'); | |||
$row = $dsql->GetArray('me', SQLITE3_ASSOC); | |||
if ($row) { | |||
$createTableSql = $row['sql']; | |||
echo "创建表的 SQL 语句:\n"; | |||
echo trim($createTableSql) . "\n\n"; | |||
echo trim($createTableSql)."\n\n"; | |||
} | |||
// 获取表的列信息 | |||
//获取表的列信息 | |||
$dsql->SetQuery("PRAGMA table_info($tablename)"); | |||
$dsql->Execute('cols'); | |||
echo "表的列信息:\n"; | |||
while ($colRow = $dsql->GetArray('cols', SQLITE3_ASSOC)) { | |||
echo "列名: " . $colRow['name'] . ", 类型: " . $colRow['type'] . ", 是否为主键: " . ($colRow['pk'] ? '是' : '否') . "\n"; | |||
echo "列名: ".$colRow['name'].", 类型: ".$colRow['type'].", 是否为主键: ".($colRow['pk'] ? '是' : '否')."\n"; | |||
} | |||
} | |||
echo '</xmp>'; | |||
@@ -70,7 +70,7 @@ else if ($dopost == "opimize") { | |||
if ($rs) { | |||
echo "执行优化表 {$tablename} 完成<br>"; | |||
} else { | |||
echo "执行优化表 {$tablename} 失败,原因是:" . $dsql->GetError(); | |||
echo "执行优化表 {$tablename} 失败,原因是:".$dsql->GetError(); | |||
} | |||
} else { | |||
$rs = $dsql->ExecuteNoneQuery("OPTIMIZE TABLE `$tablename`"); | |||
@@ -171,16 +171,14 @@ exit; | |||
unset($params['dopost']); | |||
unset($params['apikey']); | |||
unset($params['server']); | |||
$params['timestamp'] = time(); // 加入时间戳 | |||
$params['timestamp'] = time(); //加入时间戳 | |||
$cuserLogin = new userLogin(); | |||
$params['adminid'] = $cuserLogin->getUserID(); // 加入时间戳 | |||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; // 获取客户端IP | |||
ksort($params); // 按字典序排序 | |||
$queryString = http_build_query($params); // 生成查询字符串 | |||
$params['sign'] = md5($queryString . $apikey); // 计算MD5签名 | |||
$url = $server . '/api/ping?' . http_build_query($params); | |||
$params['adminid'] = $cuserLogin->getUserID(); //加入时间戳 | |||
$params['ip'] = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; //获取客户端IP | |||
ksort($params); //按字典序排序 | |||
$queryString = http_build_query($params); //生成查询字符串 | |||
$params['sign'] = md5($queryString.$apikey); //计算MD5签名 | |||
$url = $server.'/api/ping?'.http_build_query($params); | |||
$dhd = new DedeHttpDown(); | |||
$dhd->OpenUrl($url); | |||
$data = $dhd->GetJSON(); | |||
@@ -190,7 +188,6 @@ exit; | |||
echo 'error'; | |||
} | |||
} | |||
exit(); | |||
} | |||
include DedeInclude('templets/sys_info.htm'); |
@@ -27,7 +27,7 @@ if ($dopost == "viewinfo") { | |||
$dsql->Execute('me'); | |||
$row = $dsql->GetArray('me', SQLITE3_ASSOC); | |||
if ($row) { | |||
$createTableSql = str_replace(" ", "\r\n", $row['sql']); | |||
$createTableSql = str_replace(" ", "\r\n", $row['sql']); | |||
echo trim($createTableSql)."\n\n"; | |||
} | |||
} | |||
@@ -224,7 +224,7 @@ else if ($dopost == "query") { | |||
<link rel="stylesheet" href="/static/web/css/bootstrap.min.css"> | |||
<link rel="stylesheet" href="/static/web/css/admin.css"> | |||
<title>DedeBIZ数据库文档</title> | |||
<style>.card{border:none;border-radius:0.5rem;box-shadow:0 4px 8px rgba(0,0,0,0.1);transition:transform 0.5s}.card:hover{transform:translateY(-0.25rem)}.card-header{background-color:#1eb867;color:white;border-top-left-radius:0.5rem!important;border-top-right-radius:0.5rem!important}.table thead th{background-color:#e9ecef;padding:0.5rem}.table tbody td{padding:0.5rem}</style> | |||
<style>.card{transition:transform 0.5s}.card:hover{transform:translateY(-0.25rem)}.card-header{border-top-left-radius:0.5rem!important;border-top-right-radius:0.5rem!important}.table thead th{padding:0.5rem;background:#e9ecef;border-bottom:none}.table tbody td{padding:0.5rem}</style> | |||
</head> | |||
<body> | |||
<div class="container-fluid"> | |||
@@ -235,10 +235,8 @@ else if ($dopost == "query") { | |||
</ol>'; | |||
while ($row = $dsql->GetArray('t', MYSQL_BOTH)) { | |||
$tableName = $row[0]; | |||
$output .= '<div class="card mb-3"> | |||
<div class="card-header"> | |||
<span>表名: '.$tableName.'</span> | |||
</div> | |||
$output .= '<div class="card shadow-sm mb-3"> | |||
<div class="card-header">表名: '.$tableName.'</div> | |||
<div class="card-body">'; | |||
//获取表的注释 | |||
$dsql->SetQuery("SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$tableName'"); | |||
@@ -251,7 +249,7 @@ else if ($dopost == "query") { | |||
//获取表的字段信息 | |||
$dsql->SetQuery("SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$tableName'"); | |||
$dsql->Execute('col'); | |||
$output .= '<table class="table table-striped table-bordered"> | |||
$output .= '<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>字段名</th> | |||
@@ -282,10 +280,8 @@ else if ($dopost == "query") { | |||
</div> | |||
</div>'; | |||
} | |||
$output .= '</div> | |||
<footer class="bg-light text-center py-3"> | |||
<p class="mb-0">版权所有 © '.date('Y').' <a href="https://www.dedebiz.com/?from=dbdocs" class="text-success">DedeBIZ</a> 保留所有权利。</p> | |||
</footer> | |||
$output .= '<p class="text-center">版权所有 © '.date('Y').' <a href="https://www.dedebiz.com/?from=dbdocs" class="text-success">DedeBIZ</a> 保留所有权利。</p> | |||
</div> | |||
</body> | |||
</html>'; | |||
//输出网页文档 | |||
@@ -692,7 +692,7 @@ function DedeSearchAPIURL($action, $parms=array()) | |||
$parms['q'] = isset($parms['id'])? $parms['id']:""; | |||
} | |||
//生成签名字符串 | |||
$signBaseString = "key=" . DEDEBIZSEARCHKEY . "&q=".$parms['q']. "&pageSize=".$parms['pageSize']. "&page=".$parms['page']. "×tamp=".$parms['timestamp']; | |||
$signBaseString = "key=".DEDEBIZSEARCHKEY."&q=".$parms['q']. "&pageSize=".$parms['pageSize']. "&page=".$parms['page']. "×tamp=".$parms['timestamp']; | |||
$parms['sign'] = md5($signBaseString); //使用MD5生成签名 | |||
if ($action == "delete" || $action == "add") { | |||
unset($parms['q']); | |||
@@ -701,7 +701,7 @@ function DedeSearchAPIURL($action, $parms=array()) | |||
} | |||
//拼接完整URL | |||
$finalQueryString = http_build_query($parms); | |||
$finalUrl = $baseUrl . '?' . $finalQueryString; | |||
$finalUrl = $baseUrl.'?'.$finalQueryString; | |||
return $finalUrl; | |||
} | |||
function ConvertMysqlToSqlite($mysqlQuery) { | |||
@@ -738,8 +738,8 @@ function ConvertMysqlToSqlite($mysqlQuery) { | |||
//处理PRIMARY KEY只能用于INTEGER | |||
if (preg_match('/PRIMARY KEY \(`(\w+)`\)/', $query, $matches)) { | |||
$primaryKeyColumn = $matches[1]; | |||
$query = preg_replace('/,?\s*PRIMARY KEY\s*\(`' . $primaryKeyColumn . '`\)/i', '', $query); | |||
$query = preg_replace('/(`' . $primaryKeyColumn . '`\s+INTEGER)/i', '$1 PRIMARY KEY', $query); | |||
$query = preg_replace('/,?\s*PRIMARY KEY\s*\(`'.$primaryKeyColumn.'`\)/i', '', $query); | |||
$query = preg_replace('/(`'.$primaryKeyColumn.'`\s+INTEGER)/i', '$1 PRIMARY KEY', $query); | |||
} | |||
//处理CONCAT替换为SQLite兼容形式 | |||
if (preg_match('/CONCAT\(([^)]*?)\)/i', $query, $matches)) { | |||
@@ -754,7 +754,7 @@ function ConvertMysqlToSqlite($mysqlQuery) { | |||
"/FIND_IN_SET\s*\(\s*'([^']+)'\s*,\s*([a-zA-Z0-9_`\.]+)\s*\)/i", | |||
function ($matches) { | |||
//返回SQLite兼容的LIKE语法 | |||
return "(',' || " . $matches[2] . " || ',' LIKE '%," . $matches[1] . ",%')"; | |||
return "(',' || ".$matches[2]." || ',' LIKE '%,".$matches[1].",%')"; | |||
}, | |||
$query | |||
); | |||
@@ -772,7 +772,7 @@ function ConvertMysqlToSqlite($mysqlQuery) { | |||
$cases[] = "WHEN $field = $value THEN $position"; | |||
$position++; | |||
} | |||
return "(CASE " . implode(' ', $cases) . " ELSE 0 END)"; | |||
return "(CASE ".implode(' ', $cases)." ELSE 0 END)"; | |||
}, | |||
$query | |||
); | |||
@@ -9,7 +9,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||
* @license GNU GPL v2 (https://www.dedebiz.com/license) | |||
* @link https://www.dedebiz.com | |||
*/ | |||
require_once(DEDEINC . "/libraries/jsonq/Jsonq.php"); | |||
require_once(DEDEINC."/libraries/jsonq/Jsonq.php"); | |||
helper('cache'); | |||
function lib_jsonq(&$ctag, &$refObj) | |||
{ | |||