diff --git a/CHANGELOG.md b/CHANGELOG.md index f54365c1..eb8a5c60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,16 @@ ### 核心 * 修复 JSP Shell 无法执行 update/delete/insert 语句问题 +* JSP Template 升级至 [v1.6](https://github.com/AntSwordProject/AntSword-JSP-Template/releases/tag/1.6) + * equals支持数组传参方式,兼容各种容器 + * build.py中可以手动指定版本号编译,不再需要下载指定jdk + * 部分变量转为类属性,方便调试 + * 修正 insert/update/delete 语句无法执行问题 ## 数据管理 * 优化出错提示 * PHP 类型新增 SQLite_PDO 支持 +* PHP 类型新增 SQLite3 支持 ## 2021/03/27 `v(2.1.11.1)` diff --git a/source/core/php/index.js b/source/core/php/index.js index 8fe460b1..b01db31a 100644 --- a/source/core/php/index.js +++ b/source/core/php/index.js @@ -25,6 +25,7 @@ class PHP extends Base { 'database/oracle_oci8', 'database/postgresql', 'database/postgresql_pdo', + 'database/sqlite3', 'database/sqlite_pdo', 'database/informix' ].map((_) => { diff --git a/source/core/php/template/base.js b/source/core/php/template/base.js index f6de0680..fbadc26d 100644 --- a/source/core/php/template/base.js +++ b/source/core/php/template/base.js @@ -26,7 +26,11 @@ module.exports = () => ({ _: `$m=array('mysql_close','mysqli_close','mssql_close','sqlsrv_close','ora_close','oci_close','ifx_close','sqlite_close','pg_close','dba_close','dbmclose','filepro_fieldcount','sybase_close'); foreach ($m as $f) { echo($f."\\t".(function_exists($f)?'1':'0')."\\n"); - } + }; + $n=array('SQLite3'); + foreach ($n as $f) { + echo($f."\\t".(class_exists($f)?'1':'0')."\\n"); + }; if(function_exists('pdo_drivers')){ foreach(@pdo_drivers() as $f){ echo("pdo_".$f."\\t1\\n"); diff --git a/source/core/php/template/database/sqlite3.js b/source/core/php/template/database/sqlite3.js new file mode 100644 index 00000000..7b86a821 --- /dev/null +++ b/source/core/php/template/database/sqlite3.js @@ -0,0 +1,123 @@ +/** + * 数据库管理模板:: sqlite3 + * i 数据分隔符号 => \\t|\\t + */ + +module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({ + // 显示所有数据库 + show_databases: { + _: `$m=get_magic_quotes_gpc(); + $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; + $dbh=new SQLite3($hst); + if(!$dbh){ + echo("ERROR://CONNECT ERROR".SQLite3::lastErrorMsg()); + }else{ + echo("main".chr(9)); + $dbh->close(); + }`.replace(/\n\s+/g, ''), + [arg1]: '#{host}', + [arg2]: '#{user}', + [arg3]: '#{passwd}' + }, + // 显示数据库所有表 + show_tables: { + _: `$m=get_magic_quotes_gpc(); + $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; + $dbh=new SQLite3($hst); + if(!$dbh){ + echo("ERROR://CONNECT ERROR".SQLite3::lastErrorMsg()); + }else{ + $query="select tbl_name from sqlite_master where type='table' order by tbl_name;"; + $stmt=$dbh->prepare($query); + $result=$stmt->execute(); + while($res=$result->fetchArray(SQLITE3_ASSOC)){ + echo(trim($res['tbl_name']).chr(9)); + } + $dbh->close(); + }`.replace(/\n\s+/g, ''), + [arg1]: '#{host}', + [arg2]: '#{user}', + [arg3]: '#{passwd}', + [arg4]: '#{db}' + }, + // 显示表字段 + show_columns: { + _: `$m=get_magic_quotes_gpc(); + $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; + $dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"]; + $tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"]; + $dbh=new SQLite3($hst); + if(!$dbh){ + echo("ERROR://CONNECT ERROR".SQLite3::lastErrorMsg()); + }else{ + $query="pragma table_info('{$tab}');"; + $stmt=$dbh->prepare($query); + $result=$stmt->execute(); + while($res=$result->fetchArray(SQLITE3_ASSOC)){ + echo(trim($res['name'])." ({$res['type']})".chr(9)); + } + $dbh->close(); + }`.replace(/\n\s+/g, ''), + [arg1]: '#{host}', + [arg2]: '#{user}', + [arg3]: '#{passwd}', + [arg4]: '#{db}', + [arg5]: '#{table}' + }, + // 执行SQL语句 + query: { + _: `$m=get_magic_quotes_gpc(); + $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; + $usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"]; + $pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"]; + $dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"]; + $sql=base64_decode($_POST["${arg5}"]); + $encode=$m?stripslashes($_POST["${arg6}"]):$_POST["${arg6}"]; + $dbh=new SQLite3($hst); + if(!$dbh){ + echo("ERROR://CONNECT ERROR".SQLite3::lastErrorMsg()); + }else{ + $stmt=$dbh->prepare($sql); + if(!$stmt){ + echo("Status\\t|\\t\\r\\n"); + echo(base64_encode("ERROR://".$dbh->lastErrorMsg())."\\t|\\t\\r\\n"); + } else { + $result=$stmt->execute(); + if(!$result){ + echo("Status\\t|\\t\\r\\n"); + echo(base64_encode("ERROR://".$dbh->lastErrorMsg())."\\t|\\t\\r\\n"); + }else{ + $bool=True; + while($res=$result->fetchArray(SQLITE3_ASSOC)){ + if($bool){ + foreach($res as $key=>$value){ + echo($key."\\t|\\t"); + } + echo "\\r\\n"; + $bool=False; + } + foreach($res as $key=>$value){ + echo(base64_encode($value!==NULL?$value:"NULL")."\\t|\\t"); + } + echo "\\r\\n"; + } + if($bool){ + if(!$result->numColumns()){ + echo("Affect Rows\\t|\\t\\r\\n".base64_encode($dbh->changes())."\\t|\\t\\r\\n"); + }else{ + echo("Status\\t|\\t\\r\\n"); + echo(base64_encode("ERROR://Table is empty.")."\\t|\\t\\r\\n"); + } + } + } + } + $dbh->close(); + }`.replace(/\n\s+/g, ''), + [arg1]: '#{host}', + [arg2]: '#{user}', + [arg3]: '#{passwd}', + [arg4]: '#{db}', + [arg5]: '#{base64::sql}', + [arg6]: '#{encode}' + } +}) \ No newline at end of file diff --git a/source/modules/database/php/index.js b/source/modules/database/php/index.js index d7c62797..d028f85d 100644 --- a/source/modules/database/php/index.js +++ b/source/modules/database/php/index.js @@ -270,6 +270,7 @@ class PHP { 'oracle_oci8': ['UTF8','ZHS16GBK','ZHT16BIG5','ZHS16GBKFIXED','ZHT16BIG5FIXED'], 'postgresql': ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'], 'postgresql_pdo': ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'], + 'sqlite3': ['utf8'], 'sqlite_pdo': ['utf8'], 'informix': ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'], } @@ -350,6 +351,7 @@ class PHP { { text: 'ORACLE_OCI8', value: 'oracle_oci8' }, { text: 'PostgreSQL', value: 'postgresql' }, { text: 'PostgreSQL_PDO', value: 'postgresql_pdo' }, + { text: 'SQLite3', value: 'sqlite3' }, { text: 'SQLite_PDO', value: 'sqlite_pdo' }, { text: 'INFORMIX', value: 'informix' } ] }, @@ -427,6 +429,7 @@ class PHP { passwd: '', }); break; + case 'sqlite3': case 'sqlite_pdo': form.setFormData({ host: '/var/www/html/test.db',