| @@ -8,7 +8,7 @@ | |||||
| * @license GNU GPL v2 (https://www.dedebiz.com/license) | * @license GNU GPL v2 (https://www.dedebiz.com/license) | ||||
| * @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
| */ | */ | ||||
| require_once(dirname(__FILE__) . "/config.php"); | |||||
| require_once(dirname(__FILE__)."/config.php"); | |||||
| if (empty($f)) { | if (empty($f)) { | ||||
| $f = 'form1.enclosure'; | $f = 'form1.enclosure'; | ||||
| } | } | ||||
| @@ -17,10 +17,10 @@ if (empty($comeback)) { | |||||
| } | } | ||||
| $addparm = ''; | $addparm = ''; | ||||
| if (!empty($CKEditor)) { | if (!empty($CKEditor)) { | ||||
| $addparm = '&CKEditor=' . $CKEditor; | |||||
| $addparm = '&CKEditor='.$CKEditor; | |||||
| } | } | ||||
| if (!empty($CKEditorFuncNum)) { | if (!empty($CKEditorFuncNum)) { | ||||
| $addparm .= '&CKEditorFuncNum=' . $CKEditorFuncNum; | |||||
| $addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum; | |||||
| } | } | ||||
| if (!empty($noeditor)) { | if (!empty($noeditor)) { | ||||
| $addparm .= '&noeditor=yes'; | $addparm .= '&noeditor=yes'; | ||||
| @@ -455,15 +455,14 @@ if ($action === 'is_need_check_code') { | |||||
| $params = $_GET; | $params = $_GET; | ||||
| unset($params['action']); | unset($params['action']); | ||||
| checkLogin(); | checkLogin(); | ||||
| $params['timestamp'] = time(); // 加入时间戳 | |||||
| $params['timestamp'] = time(); //加入时间戳 | |||||
| $cuserLogin = new userLogin(); | $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( | echo json_encode(array( | ||||
| "code" => 0, | "code" => 0, | ||||
| "data" => $url, | "data" => $url, | ||||
| @@ -472,14 +471,14 @@ if ($action === 'is_need_check_code') { | |||||
| $params = $_GET; | $params = $_GET; | ||||
| unset($params['action']); | unset($params['action']); | ||||
| checkLogin(); | checkLogin(); | ||||
| $params['timestamp'] = time(); // 加入时间戳 | |||||
| $params['timestamp'] = time(); //加入时间戳 | |||||
| $cuserLogin = new userLogin(); | $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( | echo json_encode(array( | ||||
| "code" => 0, | "code" => 0, | ||||
| "data" => $url, | "data" => $url, | ||||
| @@ -25,21 +25,21 @@ if ($dopost == "viewinfo") { | |||||
| if (empty($tablename)) { | if (empty($tablename)) { | ||||
| echo "没有指定表名"; | echo "没有指定表名"; | ||||
| } else { | } else { | ||||
| // 获取创建表的 SQL 语句 | |||||
| //获取创建表的SQL语句 | |||||
| $dsql->SetQuery("SELECT sql FROM sqlite_master WHERE type='table' AND name='$tablename'"); | $dsql->SetQuery("SELECT sql FROM sqlite_master WHERE type='table' AND name='$tablename'"); | ||||
| $dsql->Execute('me'); | $dsql->Execute('me'); | ||||
| $row = $dsql->GetArray('me', SQLITE3_ASSOC); | $row = $dsql->GetArray('me', SQLITE3_ASSOC); | ||||
| if ($row) { | if ($row) { | ||||
| $createTableSql = $row['sql']; | $createTableSql = $row['sql']; | ||||
| echo "创建表的 SQL 语句:\n"; | echo "创建表的 SQL 语句:\n"; | ||||
| echo trim($createTableSql) . "\n\n"; | |||||
| echo trim($createTableSql)."\n\n"; | |||||
| } | } | ||||
| // 获取表的列信息 | |||||
| //获取表的列信息 | |||||
| $dsql->SetQuery("PRAGMA table_info($tablename)"); | $dsql->SetQuery("PRAGMA table_info($tablename)"); | ||||
| $dsql->Execute('cols'); | $dsql->Execute('cols'); | ||||
| echo "表的列信息:\n"; | echo "表的列信息:\n"; | ||||
| while ($colRow = $dsql->GetArray('cols', SQLITE3_ASSOC)) { | 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>'; | echo '</xmp>'; | ||||
| @@ -70,7 +70,7 @@ else if ($dopost == "opimize") { | |||||
| if ($rs) { | if ($rs) { | ||||
| echo "执行优化表 {$tablename} 完成<br>"; | echo "执行优化表 {$tablename} 完成<br>"; | ||||
| } else { | } else { | ||||
| echo "执行优化表 {$tablename} 失败,原因是:" . $dsql->GetError(); | |||||
| echo "执行优化表 {$tablename} 失败,原因是:".$dsql->GetError(); | |||||
| } | } | ||||
| } else { | } else { | ||||
| $rs = $dsql->ExecuteNoneQuery("OPTIMIZE TABLE `$tablename`"); | $rs = $dsql->ExecuteNoneQuery("OPTIMIZE TABLE `$tablename`"); | ||||
| @@ -171,16 +171,14 @@ exit; | |||||
| unset($params['dopost']); | unset($params['dopost']); | ||||
| unset($params['apikey']); | unset($params['apikey']); | ||||
| unset($params['server']); | unset($params['server']); | ||||
| $params['timestamp'] = time(); // 加入时间戳 | |||||
| $params['timestamp'] = time(); //加入时间戳 | |||||
| $cuserLogin = new userLogin(); | $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 = new DedeHttpDown(); | ||||
| $dhd->OpenUrl($url); | $dhd->OpenUrl($url); | ||||
| $data = $dhd->GetJSON(); | $data = $dhd->GetJSON(); | ||||
| @@ -190,7 +188,6 @@ exit; | |||||
| echo 'error'; | echo 'error'; | ||||
| } | } | ||||
| } | } | ||||
| exit(); | exit(); | ||||
| } | } | ||||
| include DedeInclude('templets/sys_info.htm'); | include DedeInclude('templets/sys_info.htm'); | ||||
| @@ -27,7 +27,7 @@ if ($dopost == "viewinfo") { | |||||
| $dsql->Execute('me'); | $dsql->Execute('me'); | ||||
| $row = $dsql->GetArray('me', SQLITE3_ASSOC); | $row = $dsql->GetArray('me', SQLITE3_ASSOC); | ||||
| if ($row) { | if ($row) { | ||||
| $createTableSql = str_replace(" ", "\r\n", $row['sql']); | |||||
| $createTableSql = str_replace(" ", "\r\n", $row['sql']); | |||||
| echo trim($createTableSql)."\n\n"; | 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/bootstrap.min.css"> | ||||
| <link rel="stylesheet" href="/static/web/css/admin.css"> | <link rel="stylesheet" href="/static/web/css/admin.css"> | ||||
| <title>DedeBIZ数据库文档</title> | <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> | </head> | ||||
| <body> | <body> | ||||
| <div class="container-fluid"> | <div class="container-fluid"> | ||||
| @@ -235,10 +235,8 @@ else if ($dopost == "query") { | |||||
| </ol>'; | </ol>'; | ||||
| while ($row = $dsql->GetArray('t', MYSQL_BOTH)) { | while ($row = $dsql->GetArray('t', MYSQL_BOTH)) { | ||||
| $tableName = $row[0]; | $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">'; | <div class="card-body">'; | ||||
| //获取表的注释 | //获取表的注释 | ||||
| $dsql->SetQuery("SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$tableName'"); | $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->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'); | $dsql->Execute('col'); | ||||
| $output .= '<table class="table table-striped table-bordered"> | |||||
| $output .= '<table class="table table-bordered"> | |||||
| <thead> | <thead> | ||||
| <tr> | <tr> | ||||
| <th>字段名</th> | <th>字段名</th> | ||||
| @@ -282,10 +280,8 @@ else if ($dopost == "query") { | |||||
| </div> | </div> | ||||
| </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> | </body> | ||||
| </html>'; | </html>'; | ||||
| //输出网页文档 | //输出网页文档 | ||||
| @@ -692,7 +692,7 @@ function DedeSearchAPIURL($action, $parms=array()) | |||||
| $parms['q'] = isset($parms['id'])? $parms['id']:""; | $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生成签名 | $parms['sign'] = md5($signBaseString); //使用MD5生成签名 | ||||
| if ($action == "delete" || $action == "add") { | if ($action == "delete" || $action == "add") { | ||||
| unset($parms['q']); | unset($parms['q']); | ||||
| @@ -701,7 +701,7 @@ function DedeSearchAPIURL($action, $parms=array()) | |||||
| } | } | ||||
| //拼接完整URL | //拼接完整URL | ||||
| $finalQueryString = http_build_query($parms); | $finalQueryString = http_build_query($parms); | ||||
| $finalUrl = $baseUrl . '?' . $finalQueryString; | |||||
| $finalUrl = $baseUrl.'?'.$finalQueryString; | |||||
| return $finalUrl; | return $finalUrl; | ||||
| } | } | ||||
| function ConvertMysqlToSqlite($mysqlQuery) { | function ConvertMysqlToSqlite($mysqlQuery) { | ||||
| @@ -738,8 +738,8 @@ function ConvertMysqlToSqlite($mysqlQuery) { | |||||
| //处理PRIMARY KEY只能用于INTEGER | //处理PRIMARY KEY只能用于INTEGER | ||||
| if (preg_match('/PRIMARY KEY \(`(\w+)`\)/', $query, $matches)) { | if (preg_match('/PRIMARY KEY \(`(\w+)`\)/', $query, $matches)) { | ||||
| $primaryKeyColumn = $matches[1]; | $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兼容形式 | //处理CONCAT替换为SQLite兼容形式 | ||||
| if (preg_match('/CONCAT\(([^)]*?)\)/i', $query, $matches)) { | 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", | "/FIND_IN_SET\s*\(\s*'([^']+)'\s*,\s*([a-zA-Z0-9_`\.]+)\s*\)/i", | ||||
| function ($matches) { | function ($matches) { | ||||
| //返回SQLite兼容的LIKE语法 | //返回SQLite兼容的LIKE语法 | ||||
| return "(',' || " . $matches[2] . " || ',' LIKE '%," . $matches[1] . ",%')"; | |||||
| return "(',' || ".$matches[2]." || ',' LIKE '%,".$matches[1].",%')"; | |||||
| }, | }, | ||||
| $query | $query | ||||
| ); | ); | ||||
| @@ -772,7 +772,7 @@ function ConvertMysqlToSqlite($mysqlQuery) { | |||||
| $cases[] = "WHEN $field = $value THEN $position"; | $cases[] = "WHEN $field = $value THEN $position"; | ||||
| $position++; | $position++; | ||||
| } | } | ||||
| return "(CASE " . implode(' ', $cases) . " ELSE 0 END)"; | |||||
| return "(CASE ".implode(' ', $cases)." ELSE 0 END)"; | |||||
| }, | }, | ||||
| $query | $query | ||||
| ); | ); | ||||
| @@ -9,7 +9,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); | |||||
| * @license GNU GPL v2 (https://www.dedebiz.com/license) | * @license GNU GPL v2 (https://www.dedebiz.com/license) | ||||
| * @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
| */ | */ | ||||
| require_once(DEDEINC . "/libraries/jsonq/Jsonq.php"); | |||||
| require_once(DEDEINC."/libraries/jsonq/Jsonq.php"); | |||||
| helper('cache'); | helper('cache'); | ||||
| function lib_jsonq(&$ctag, &$refObj) | function lib_jsonq(&$ctag, &$refObj) | ||||
| { | { | ||||