Commit 99d70d49 authored by Medicean's avatar Medicean

(Enhance:Database) php sqlsrv 连接编码调整

parent 640caf91
...@@ -77,7 +77,8 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({ ...@@ -77,7 +77,8 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$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}"]);
$chs='utf-8'; $chs=strtolower($m?stripslashes($_POST["${arg6}"]):$_POST["${arg6}"]);
$chs=($chs=='utf-8'||$chs=='char')?$chs:'utf-8';
$T=@sqlsrv_connect($hst,array("UID"=> $usr,"PWD"=>$pwd,"Database"=>$dbn,"CharacterSet"=>$chs)); $T=@sqlsrv_connect($hst,array("UID"=> $usr,"PWD"=>$pwd,"Database"=>$dbn,"CharacterSet"=>$chs));
$q=@sqlsrv_query($T,$sql,null); $q=@sqlsrv_query($T,$sql,null);
if($q!==false){ if($q!==false){
...@@ -108,7 +109,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({ ...@@ -108,7 +109,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
echo(base64_encode($e['message'])."\t|\t\r\n"); echo(base64_encode($e['message'])."\t|\t\r\n");
} }
}else{ }else{
echo("RmFsc2U="); echo("RmFsc2U="."\t|\t\r\n");
} }
} }
@sqlsrv_close($T);`.replace(/\n\s+/g, ''), @sqlsrv_close($T);`.replace(/\n\s+/g, ''),
...@@ -117,6 +118,6 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({ ...@@ -117,6 +118,6 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
[arg3]: '#{passwd}', [arg3]: '#{passwd}',
[arg4]: '#{db}', [arg4]: '#{db}',
[arg5]: '#{base64::sql}', [arg5]: '#{base64::sql}',
// [arg6]: '#{encode}' [arg6]: '#{encode}'
} }
}) })
...@@ -378,9 +378,9 @@ class PHP { ...@@ -378,9 +378,9 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] }, { type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => { { type: 'combo', label: '', name: 'encode', options: (() => {
let ret = []; let ret = [];
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => { ['utf-8','char'].map((_) => {
ret.push({ ret.push({
text: _, text: _.toUpperCase(),
value: _, value: _,
}); });
}) })
...@@ -607,9 +607,9 @@ class PHP { ...@@ -607,9 +607,9 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] }, { type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => { { type: 'combo', label: '', name: 'encode', options: (() => {
let ret = []; let ret = [];
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => { ['utf-8', 'char'].map((_) => {
ret.push({ ret.push({
text: _, text: _.toUpperCase(),
value: _, value: _,
selected: conf['encode'] === _ selected: conf['encode'] === _
}); });
...@@ -1650,6 +1650,13 @@ class PHP { ...@@ -1650,6 +1650,13 @@ class PHP {
let encoding = Decodes.detectEncoding(buff, {defaultEncoding: "unknown"}); let encoding = Decodes.detectEncoding(buff, {defaultEncoding: "unknown"});
if(encoding == "unknown") { if(encoding == "unknown") {
switch(this.dbconf['type']){ switch(this.dbconf['type']){
case 'sqlsrv':
var sqlsrv_conncs_mapping = {
'UTF-8': 'utf8',
'CHAR': '',
}
encoding = sqlsrv_conncs_mapping[this.dbconf['encode']] || '';
break;
case 'oracle_oci8': case 'oracle_oci8':
var oci8_characterset_mapping = { var oci8_characterset_mapping = {
'UTF8': 'utf8', 'UTF8': 'utf8',
...@@ -1705,6 +1712,13 @@ class PHP { ...@@ -1705,6 +1712,13 @@ class PHP {
let encoding = Decodes.detectEncoding(buff, {defaultEncoding: "unknown"}); let encoding = Decodes.detectEncoding(buff, {defaultEncoding: "unknown"});
if(encoding == "unknown") { if(encoding == "unknown") {
switch(this.dbconf['type']){ switch(this.dbconf['type']){
case 'sqlsrv':
var sqlsrv_conncs_mapping = {
'utf-8': 'utf8',
'char': '',
}
encoding = sqlsrv_conncs_mapping[this.dbconf['encode']] || '';
break;
case 'oracle_oci8': case 'oracle_oci8':
var oci8_characterset_mapping = { var oci8_characterset_mapping = {
'UTF8': 'utf8', 'UTF8': 'utf8',
......
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