Skip to content

Commit

Permalink
Fix(Core/PHP) 修复 PHP 类型数据库连接在PHP7下函数废除引起的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Medicean committed Mar 31, 2021
1 parent 5cc6c69 commit 7bd4cad
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 69 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
> 有空会补补BUG、添添新功能。
> 同时也欢迎大家的参与!感谢各位朋友的支持! .TAT.
## 2021/03/27 `v(2.1.11.1)`

### 核心

* 修复 PHP 类型数据库连接在PHP7下函数废除引起的问题

## 2021/03/26 `v(2.1.11)`

### 后端模块
Expand Down
10 changes: 5 additions & 5 deletions source/core/php/template/database/mssql.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
@mssql_select_db($dbn,$T);
$q=@mssql_query($sql,$T);
if(is_bool($q)){
echo("Status\t|\tAffect Rows\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t".base64_encode(@mssql_rows_affected($T)." row(s)")."\t|\t\r\n");
echo("Status\\t|\\tAffect Rows\\t|\\t\\r\\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\\t|\\t".base64_encode(@mssql_rows_affected($T)." row(s)")."\\t|\\t\\r\\n");
}else{
$i=0;
while($rs=@mssql_fetch_field($q)){
echo($rs->name."\t|\t");
echo($rs->name."\\t|\\t");
$i++;
}
echo("\r\n");
echo("\\r\\n");
while($rs=@mssql_fetch_row($q)){
for($c=0;$c<$i;$c++){
echo(base64_encode(trim($rs[$c])));
echo("\t|\t");
echo("\\t|\\t");
}
echo("\r\n");
echo("\\r\\n");
}
@mssql_free_result($q);
}
Expand Down
65 changes: 61 additions & 4 deletions source/core/php/template/database/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,53 @@
module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库
show_databases: {
_: `$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}"];$T=@mysql_connect($hst,$usr,$pwd);$q=@mysql_query("SHOW DATABASES");while($rs=@mysql_fetch_row($q)){echo(trim($rs[0]).chr(9));}@mysql_close($T);`,
_: `$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}"];
$T=@mysql_connect($hst,$usr,$pwd);
$q=@mysql_query("SHOW DATABASES");
while($rs=@mysql_fetch_row($q)){
echo(trim($rs[0]).chr(9));
}
@mysql_close($T);`.replace(/\n\s+/g, ''),
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}'
},
// 显示数据库所有表
show_tables: {
_: `$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}"];$T=@mysql_connect($hst,$usr,$pwd);$q=@mysql_query("SHOW TABLES FROM \`{$dbn}\`");while($rs=@mysql_fetch_row($q)){echo(trim($rs[0]).chr(9));}@mysql_close($T);`,
_: `$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}"];
$T=@mysql_connect($hst,$usr,$pwd);
$q=@mysql_query("SHOW TABLES FROM \`{$dbn}\`");
while($rs=@mysql_fetch_row($q)){
echo(trim($rs[0]).chr(9));
}
@mysql_close($T);`.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}"];$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];$tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"];$T=@mysql_connect($hst,$usr,$pwd);@mysql_select_db( $dbn, $T);$q=@mysql_query("SHOW COLUMNS FROM \`{$tab}\`");while($rs=@mysql_fetch_row($q)){echo(trim($rs[0])." (".$rs[1].")".chr(9));}@mysql_close($T);`,
_: `$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}"];
$tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"];
$T=@mysql_connect($hst,$usr,$pwd);
@mysql_select_db( $dbn, $T);
$q=@mysql_query("SHOW COLUMNS FROM \`{$tab}\`");
while($rs=@mysql_fetch_row($q)){
echo(trim($rs[0])." (".$rs[1].")".chr(9));
}
@mysql_close($T);`.replace(/\n\s+/g, ''),
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand All @@ -30,7 +61,33 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 执行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}"]);$T=@mysql_connect($hst,$usr,$pwd);@mysql_query("SET NAMES $_POST[${arg6}]");@mysql_select_db($dbn, $T);$q=@mysql_query($sql);if(is_bool($q)){echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t\r\n");}else{$i=0;while($col=@mysql_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysql_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}}@mysql_close($T);`,
_: `$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}"]);
$T=@mysql_connect($hst,$usr,$pwd);
@mysql_query("SET NAMES $_POST[${arg6}]");
@mysql_select_db($dbn, $T);
$q=@mysql_query($sql);
if(is_bool($q)){echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\\t|\\t\\r\\n");
}else{
$i=0;
while($col=@mysql_fetch_field($q)){
echo($col->name."\\t|\\t");
$i++;
}
echo("\\r\\n");
while($rs=@mysql_fetch_row($q)){
for($c=0;$c<$i;$c++){
echo(base64_encode(trim($rs[$c])));
echo("\\t|\\t");
}
echo("\\r\\n");
}
}
@mysql_close($T);`.replace(/\n\s+/g, ''),
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand Down
10 changes: 5 additions & 5 deletions source/core/php/template/database/mysqli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
list($hst, $port) = split(":", $hst);
list($hst, $port) = explode(":", $hst);
$port == "" ? $port = "3306" : $port;
$T=@mysqli_connect($hst,$usr,$pwd,"",$port);
$q=@mysqli_query($T,"SHOW DATABASES");
Expand All @@ -29,7 +29,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
list($hst, $port) = split(":", $hst);
list($hst, $port) = explode(":", $hst);
$port == "" ? $port = "3306" : $port;
$T=@mysqli_connect($hst,$usr,$pwd,"",$port);
$q=@mysqli_query($T, "SHOW TABLES FROM \`{$dbn}\`");
Expand All @@ -50,7 +50,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"];
list($hst, $port) = split(":", $hst);
list($hst, $port) = explode(":", $hst);
$port == "" ? $port = "3306" : $port;
$T=@mysqli_connect($hst,$usr,$pwd,"",$port);
@mysqli_select_db($T, $dbn);
Expand All @@ -73,14 +73,14 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$sql=base64_decode($_POST["${arg5}"]);
list($hst, $port) = split(":", $hst);
list($hst, $port) = explode(":", $hst);
$port == "" ? $port = "3306" : $port;
$T=@mysqli_connect($hst,$usr,$pwd,"",$port);
@mysqli_query($T,"SET NAMES $_POST[${arg6}]");
@mysqli_select_db($T,$dbn);
$q=@mysqli_query($T,$sql);
if(is_bool($q)){
echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t\r\n");
echo("Status\\t|\\t\\r\\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\\t|\\t\\r\\n");
}else{
$i=0;
while($col=@mysqli_fetch_field($q)){echo($col->name."\t|\t");
Expand Down
4 changes: 2 additions & 2 deletions source/core/php/template/database/oracle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* 数据库管理模板::oracle
* i 数据分隔符号 => \t|\t
* i 数据分隔符号 => \\t|\\t
*/

module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
Expand Down Expand Up @@ -29,7 +29,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 执行SQL语句
query: {
_: `$m=get_magic_quotes_gpc();$sid=$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}"]);$H=@ora_plogon("{$usr}@{$sid}","{$pwd}");if(!$H){echo("ERROR:// Login Failed!");}else{$T=@ora_open($H);@ora_commitoff($H);$q=@ora_parse($T,"{$sql}");$R=ora_exec($T);if($R){$n=ora_numcols($T);for($i=0;$i<$n;$i++){echo(Ora_ColumnName($T,$i)."\t|\t");}echo("\r\n");while(ora_fetch($T)){for($i=0;$i<$n;$i++){echo(base64_encode(trim(ora_getcolumn($T,$i))));echo("\t|\t");}echo("\r\n");}}else{echo("ErrMsg\t|\t\r\n");}@ora_close($T);};`,
_: `$m=get_magic_quotes_gpc();$sid=$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}"]);$H=@ora_plogon("{$usr}@{$sid}","{$pwd}");if(!$H){echo("ERROR:// Login Failed!");}else{$T=@ora_open($H);@ora_commitoff($H);$q=@ora_parse($T,"{$sql}");$R=ora_exec($T);if($R){$n=ora_numcols($T);for($i=0;$i<$n;$i++){echo(Ora_ColumnName($T,$i)."\\t|\\t");}echo("\\r\\n");while(ora_fetch($T)){for($i=0;$i<$n;$i++){echo(base64_encode(trim(ora_getcolumn($T,$i))));echo("\\t|\\t");}echo("\\r\\n");}}else{echo("ErrMsg\\t|\\t\\r\\n");}@ora_close($T);};`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand Down
36 changes: 18 additions & 18 deletions source/core/php/template/database/oracle_oci8.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* 数据库管理模板::oracle oci8 驱动
* i 数据分隔符号 => \t|\t
* i 数据分隔符号 => \\t|\\t
*
* session_mode: OCI_DEFAULT 0 OCI_SYSOPER 4 OCI_SYSDBA 2
*
Expand All @@ -25,12 +25,12 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
echo(trim(@oci_result($q,1)).chr(9));
}
}else{
echo("Status\t|\t\r\n");
echo("Status\\t|\\t\\r\\n");
$e=@oci_error($q);
if($e){
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\t|\t\r\n");
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\\t|\\t\\r\\n");
}else{
echo("RmFsc2U="."\t|\t\r\n");
echo("RmFsc2U="."\\t|\\t\\r\\n");
}
}
@oci_close($H);
Expand Down Expand Up @@ -65,12 +65,12 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
}
}
}else{
echo("Status\t|\t\r\n");
echo("Status\\t|\\t\\r\\n");
$e=@oci_error($q);
if($e){
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\t|\t\r\n");
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\\t|\\t\\r\\n");
}else{
echo("RmFsc2U="."\t|\t\r\n");
echo("RmFsc2U="."\\t|\\t\\r\\n");
}
}
@oci_close($H);
Expand Down Expand Up @@ -107,12 +107,12 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
}
}
}else{
echo("Status\t|\t\r\n");
echo("Status\\t|\\t\\r\\n");
$e=@oci_error($q);
if($e){
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\t|\t\r\n");
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\\t|\\t\\r\\n");
}else{
echo("RmFsc2U="."\t|\t\r\n");
echo("RmFsc2U="."\\t|\\t\\r\\n");
}
}
@oci_close($H);
Expand Down Expand Up @@ -142,27 +142,27 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
if(@oci_execute($q)) {
$n=oci_num_fields($q);
if($n==0){
echo("Affect Rows\t|\t\r\n".base64_encode(@oci_num_rows($q))."\t|\t\r\n");
echo("Affect Rows\\t|\\t\\r\\n".base64_encode(@oci_num_rows($q))."\\t|\\t\\r\\n");
}else{
for($i=1;$i<=$n;$i++){
echo(oci_field_name($q,$i)."\t|\t");
echo(oci_field_name($q,$i)."\\t|\\t");
}
echo "\r\n";
echo "\\r\\n";
while ($row = @oci_fetch_array($q, OCI_ASSOC+OCI_RETURN_NULLS)) {
foreach ($row as $item) {
echo($item !== null ? base64_encode($item):"")."\t|\t";
echo($item !== null ? base64_encode($item):"")."\\t|\\t";
}
echo "\r\n";
echo "\\r\\n";
}
@oci_free_statement($q);
}
}else{
echo("Status\t|\t\r\n");
echo("Status\\t|\\t\\r\\n");
$e=@oci_error($q);
if($e){
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\t|\t\r\n");
echo(base64_encode("ERROR://{$e['message']} in [{$e['sqltext']}] col:{$e['offset']}")."\\t|\\t\\r\\n");
}else{
echo("RmFsc2U="."\t|\t\r\n");
echo("RmFsc2U="."\\t|\\t\\r\\n");
}
}
@oci_close($H);
Expand Down
24 changes: 12 additions & 12 deletions source/core/php/template/database/postgresql.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* 数据库管理模板::postgresql
* i 数据分隔符号 => \t|\t
* i 数据分隔符号 => \\t|\\t
*/

module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
Expand All @@ -10,7 +10,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
list($host,$port,$dbn) = split(":", $hst);
list($host,$port,$dbn) = explode(":", $hst);
$port == "" ? $port = "5432" : $port;
$dbn == "" ? $dbn = "postgres" : $dbn;
Expand Down Expand Up @@ -55,7 +55,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
list($host, $port) = split(":", $hst);
list($host, $port) = explode(":", $hst);
$port == "" ? $port = "5432" : $port;
$arr=array(
'host'=>$host,
Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"];
list($host, $port) = split(":", $hst);
list($host, $port) = explode(":", $hst);
$port == "" ? $port = "5432" : $port;
$arr=array(
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$sql=base64_decode($_POST["${arg5}"]);
$encode=$m?stripslashes($_POST["${arg6}"]):$_POST["${arg6}"];
list($host, $port) = split(":", $hst);
list($host, $port) = explode(":", $hst);
$port == "" ? $port = "5432" : $port;
$arr=array(
'host'=>$host,
Expand All @@ -173,20 +173,20 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
}else{
$n=@pg_num_fields($q);
if($n===NULL){
echo("Status\t|\t\r\n");
echo(base64_encode("ERROR://".@pg_last_error())."\t|\t\r\n");
echo("Status\\t|\\t\\r\\n");
echo(base64_encode("ERROR://".@pg_last_error())."\\t|\\t\\r\\n");
}elseif($n===0){
echo("Affect Rows\t|\t\r\n".base64_encode(@pg_affected_rows($q))."\t|\t\r\n");
echo("Affect Rows\\t|\\t\\r\\n".base64_encode(@pg_affected_rows($q))."\\t|\\t\\r\\n");
}else{
for($i=0;$i<$n;$i++){
echo(@pg_field_name($q,$i)."\t|\t");
echo(@pg_field_name($q,$i)."\\t|\\t");
}
echo "\r\n";
echo "\\r\\n";
while($row=@pg_fetch_row($q)){
for($i=0;$i<$n;$i++){
echo(base64_encode($row[$i]!==NULL?$row[$i]:"NULL")."\t|\t");
echo(base64_encode($row[$i]!==NULL?$row[$i]:"NULL")."\\t|\\t");
}
echo "\r\n";
echo "\\r\\n";
}
}
@pg_free_result($q);
Expand Down
Loading

0 comments on commit 7bd4cad

Please sign in to comment.