Commit 47402e6b authored by Medicean's avatar Medicean

(Nothing)Remove Windows CRLF ending

parent 52783288
/** /**
* 数据库管理模板::postgresql_pdo * 数据库管理模板::postgresql_pdo
* i 数据分隔符号 => \t|\t * i 数据分隔符号 => \t|\t
*/ */
module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库 // 显示所有数据库
show_databases: { show_databases: {
_: _:
`$m=get_magic_quotes_gpc(); `$m=get_magic_quotes_gpc();
$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"]; $usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"]; $pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$host=split(':',$hst)[0]; $host=split(':',$hst)[0];
$port=split(':',$hst)[1]; $port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=postgres;",$usr,$pwd); $dbh=new PDO("pgsql:host=$host;port=$port;dbname=postgres;",$usr,$pwd);
if(!$dbh){ if(!$dbh){
echo("ERROR://CONNECT ERROR"); echo("ERROR://CONNECT ERROR");
}else{ }else{
$query="select datname FROM pg_database where datistemplate='f';"; $query="select datname FROM pg_database where datistemplate='f';";
$result=$dbh->prepare($query); $result=$dbh->prepare($query);
$result->execute(); $result->execute();
while($res=$result->fetch(PDO::FETCH_ASSOC)){ while($res=$result->fetch(PDO::FETCH_ASSOC)){
echo(trim($res['datname']).chr(9)); echo(trim($res['datname']).chr(9));
} }
$dbh=null; $dbh=null;
}`.replace(/\n\s+/g,''), }`.replace(/\n\s+/g,''),
[arg1]: '#{host}', [arg1]: '#{host}',
[arg2]: '#{user}', [arg2]: '#{user}',
[arg3]: '#{passwd}' [arg3]: '#{passwd}'
}, },
// 显示数据库所有表 // 显示数据库所有表
show_tables: { show_tables: {
_: _:
`$m=get_magic_quotes_gpc(); `$m=get_magic_quotes_gpc();
$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"]; $usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"]; $pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"]; $dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$host=split(':',$hst)[0]; $host=split(':',$hst)[0];
$port=split(':',$hst)[1]; $port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd); $dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd);
if(!$dbh){ if(!$dbh){
echo("ERROR://CONNECT ERROR"); echo("ERROR://CONNECT ERROR");
}else{ }else{
$query="SELECT table_name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema');"; $query="SELECT table_name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema');";
$result=$dbh->prepare($query); $result=$dbh->prepare($query);
$result->execute(); $result->execute();
while($res=$result->fetch(PDO::FETCH_ASSOC)){ while($res=$result->fetch(PDO::FETCH_ASSOC)){
echo(trim($res['table_name']).chr(9)); echo(trim($res['table_name']).chr(9));
} }
$dbh=null; $dbh=null;
}`.replace(/\n\s+/g,''), }`.replace(/\n\s+/g,''),
[arg1]: '#{host}', [arg1]: '#{host}',
[arg2]: '#{user}', [arg2]: '#{user}',
[arg3]: '#{passwd}', [arg3]: '#{passwd}',
[arg4]: '#{db}' [arg4]: '#{db}'
}, },
// 显示表字段 // 显示表字段
show_columns: { show_columns: {
_: _:
`$m=get_magic_quotes_gpc(); `$m=get_magic_quotes_gpc();
$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"]; $usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"]; $pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"]; $dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"]; $tab=$m?stripslashes($_POST["${arg5}"]):$_POST["${arg5}"];
$host=split(':',$hst)[0]; $host=split(':',$hst)[0];
$port=split(':',$hst)[1]; $port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd); $dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd);
if(!$dbh){ if(!$dbh){
echo("ERROR://CONNECT ERROR"); echo("ERROR://CONNECT ERROR");
}else{ }else{
$query="SELECT column_name,udt_name,character_maximum_length FROM information_schema.COLUMNS WHERE TABLE_NAME = '{$tab}';"; $query="SELECT column_name,udt_name,character_maximum_length FROM information_schema.COLUMNS WHERE TABLE_NAME = '{$tab}';";
$result=$dbh->prepare($query); $result=$dbh->prepare($query);
$result->execute(); $result->execute();
while($res=$result->fetch(PDO::FETCH_ASSOC)){ while($res=$result->fetch(PDO::FETCH_ASSOC)){
$len=$res['character_maximum_length'] ? $res['character_maximum_length']:"0"; $len=$res['character_maximum_length'] ? $res['character_maximum_length']:"0";
echo(trim($res['column_name'])." ({$res['udt_name']}({$len}))".chr(9)); echo(trim($res['column_name'])." ({$res['udt_name']}({$len}))".chr(9));
} }
$dbh = null; $dbh = null;
}`.replace(/\n\s+/g,''), }`.replace(/\n\s+/g,''),
[arg1]: '#{host}', [arg1]: '#{host}',
[arg2]: '#{user}', [arg2]: '#{user}',
[arg3]: '#{passwd}', [arg3]: '#{passwd}',
[arg4]: '#{db}', [arg4]: '#{db}',
[arg5]: '#{table}' [arg5]: '#{table}'
}, },
// 执行SQL语句 // 执行SQL语句
query: { query: {
_: _:
`$m=get_magic_quotes_gpc(); `$m=get_magic_quotes_gpc();
$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]; $hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];
$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"]; $usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];
$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"]; $pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];
$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"]; $dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];
$sql=base64_decode($_POST["${arg5}"]); $sql=base64_decode($_POST["${arg5}"]);
$encode=$m?stripslashes($_POST["${arg6}"]):$_POST["${arg6}"]; $encode=$m?stripslashes($_POST["${arg6}"]):$_POST["${arg6}"];
$host=split(':',$hst)[0]; $host=split(':',$hst)[0];
$port=split(':',$hst)[1]; $port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd); $dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd);
if(!$dbh){ if(!$dbh){
echo("ERROR://CONNECT ERROR"); echo("ERROR://CONNECT ERROR");
}else{ }else{
$result=$dbh->prepare($sql); $result=$dbh->prepare($sql);
if(!$result->execute()){ if(!$result->execute()){
echo("Status\t|\t\r\n"); echo("Status\t|\t\r\n");
echo(base64_encode("ERROR://EXECUTE ERROR")."\t|\t\r\n"); echo(base64_encode("ERROR://EXECUTE ERROR")."\t|\t\r\n");
}else{ }else{
$bool=True; $bool=True;
while($res=$result->fetch(PDO::FETCH_ASSOC)){ while($res=$result->fetch(PDO::FETCH_ASSOC)){
if($bool){ if($bool){
foreach($res as $key=>$value){ foreach($res as $key=>$value){
echo($key."\t|\t"); echo($key."\t|\t");
} }
echo "\r\n"; echo "\r\n";
$bool=False; $bool=False;
} }
foreach($res as $key=>$value){ foreach($res as $key=>$value){
echo(base64_encode($value!==NULL?$value:"NULL")."\t|\t"); echo(base64_encode($value!==NULL?$value:"NULL")."\t|\t");
} }
echo "\r\n"; echo "\r\n";
} }
if($bool){ if($bool){
if($result->rowCount()){ if($result->rowCount()){
echo("Affect Rows\t|\t\r\n".base64_encode($result->rowCount())."\t|\t\r\n"); echo("Affect Rows\t|\t\r\n".base64_encode($result->rowCount())."\t|\t\r\n");
}else{ }else{
echo("Status\t|\t\r\n"); echo("Status\t|\t\r\n");
} }
} }
} }
$dbh = null; $dbh = null;
}`.replace(/\n\s+/g, ''), }`.replace(/\n\s+/g, ''),
[arg1]: '#{host}', [arg1]: '#{host}',
[arg2]: '#{user}', [arg2]: '#{user}',
[arg3]: '#{passwd}', [arg3]: '#{passwd}',
[arg4]: '#{db}', [arg4]: '#{db}',
[arg5]: '#{base64::sql}', [arg5]: '#{base64::sql}',
[arg6]: '#{encode}' [arg6]: '#{encode}'
} }
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment