Skip to content

Commit

Permalink
Merge pull request #49 from antoor/bf-mysql-mysqli
Browse files Browse the repository at this point in the history
php  mysql and mysqli
  • Loading branch information
antoor committed Apr 30, 2016
2 parents 42c94b9 + 4d2d88c commit 2d93df8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
1 change: 1 addition & 0 deletions source/core/php/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PHP extends Base {
[
'base', 'command', 'filemanager',
'database/mysql',
'database/mysqli',
'database/mssql',
'database/oracle',
'database/informix'
Expand Down
8 changes: 4 additions & 4 deletions source/core/php/template/database/mysql.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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=@mysqli_connect($hst,$usr,$pwd);$q=@mysqli_query($T,"SHOW DATABASES");while($rs=@mysqli_fetch_row($q)){echo(trim($rs[0]).chr(9));}@mysqli_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);`,
[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=@mysqli_connect($hst,$usr,$pwd);$q=@mysqli_query($T, "SHOW TABLES FROM \`{$dbn}\`");while($rs=@mysqli_fetch_row($q)){echo(trim($rs[0]).chr(9));}@mysqli_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);`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand All @@ -24,7 +24,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示表字段
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=@mysqli_connect($hst,$usr,$pwd);@mysqli_select_db($T, $dbn);$q=@mysqli_query($T, "SHOW COLUMNS FROM \`{$tab}\`");while($rs=@mysqli_fetch_row($q)){echo(trim($rs[0])." (".$rs[1].")".chr(9));}@mysqli_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);`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand All @@ -34,7 +34,7 @@ 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=@mysqli_connect($hst,$usr,$pwd);@mysqli_query($T,"SET NAMES ${arg6}");@mysqli_select_db($T,$dbn);$q=@mysqli_query($T,$sql);$i=0;while($col=@mysqli_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysqli_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}@mysqli_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 ${arg6}");@mysql_select_db($dbn, $T);$q=@mysql_query($sql);$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);`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand Down
45 changes: 45 additions & 0 deletions source/core/php/template/database/mysqli.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* 数据库管理模板::mysql
* 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}"];$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];$T=@mysqli_connect($hst,$usr,$pwd);$q=@mysqli_query($T,"SHOW DATABASES");while($rs=@mysqli_fetch_row($q)){echo(trim($rs[0]).chr(9));}@mysqli_close($T);`,
[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=@mysqli_connect($hst,$usr,$pwd);$q=@mysqli_query($T, "SHOW TABLES FROM \`{$dbn}\`");while($rs=@mysqli_fetch_row($q)){echo(trim($rs[0]).chr(9));}@mysqli_close($T);`,
[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=@mysqli_connect($hst,$usr,$pwd);@mysqli_select_db($T, $dbn);$q=@mysqli_query($T, "SHOW COLUMNS FROM \`{$tab}\`");while($rs=@mysqli_fetch_row($q)){echo(trim($rs[0])." (".$rs[1].")".chr(9));}@mysqli_close($T);`,
[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}"]);$T=@mysqli_connect($hst,$usr,$pwd);@mysqli_query($T,"SET NAMES ${arg6}");@mysqli_select_db($T,$dbn);$q=@mysqli_query($T,$sql);$i=0;while($col=@mysqli_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysqli_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}@mysqli_close($T);`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
[arg4]: '#{db}',
[arg5]: '#{base64::sql}',
[arg6]: '#{encode}'
}
})
17 changes: 17 additions & 0 deletions source/modules/database/php/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ class PHP {
return ret;
})() }

] },
{ text: 'MYSQLI', value: 'mysqli', list: [

{ type: 'settings', position: 'label-left', offsetLeft: 70, labelWidth: 90, inputWidth: 150 },
{ type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => {
let ret = [];
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({
text: _,
value: _
});
})
return ret;
})() }

] },
{ text: 'MSSQL', value: 'mssql' },
{ text: 'ORACLE', value: 'oracle' },
Expand All @@ -186,6 +202,7 @@ class PHP {
if (_ !== 'type') { return };
switch(id) {
case 'mysql':
case 'mysqli':
form.setFormData({
user: 'root',
passwd: ''
Expand Down

0 comments on commit 2d93df8

Please sign in to comment.