Subversion Repositories php-qbpwcf

Rev

Rev 222 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
<?php
2
 
3
/*
4
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
239 liveuser 5
    Copyright (C) 2014~2026 MIN ZHI, CHEN
1 liveuser 6
 
7
    This file is part of QBPWCF.
8
 
9
    QBPWCF is free software: you can redistribute it and/or modify
10
    it under the terms of the GNU General Public License as published by
11
    the Free Software Foundation, either version 3 of the License, or
12
    (at your option) any later version.
13
 
14
    QBPWCF is distributed in the hope that it will be useful,
15
    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    GNU General Public License for more details.
18
 
19
    You should have received a copy of the GNU General Public License
20
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
222 liveuser 21
 
1 liveuser 22
*/
23
 
24
/*
25
 
26
抓取資料庫資料
27
 
28
*/
29
 
30
#使用命名空間qbpwcf
31
namespace qbpwcf;
32
 
33
#初始化輸出
34
$output=array();
35
 
36
#取得 lib path
106 liveuser 37
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
1 liveuser 38
 
39
#如果執行失敗
40
if($status!==0){
41
 
42
	#debug
43
	var_dump(__LINE__,$output);
44
 
45
	#結束執行,回傳shell 1.
46
	exit(1);
47
 
48
	}#if end
49
 
50
#儲存lib path
51
$folderOfUsrLib=$output[0];
52
 
53
#初始化輸出
54
$output=array();
55
 
56
#以該檔案的實際位置的 lib path 為 include path 首位
106 liveuser 57
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
1 liveuser 58
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
59
 
60
#匯入外部套件
61
include("allInOneForJson.php");
62
 
63
#建議的log位置
64
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
65
 
182 liveuser 66
#預設的範例資料參數
1 liveuser 67
$params=array();
182 liveuser 68
$params["dbSecret"]=$dbSecret;
69
$params["dbAddr"]=$dbAddress;
70
$params["dbPort"]=$dbPort;
71
$params["dbName"]=$dbName;
72
$params["dbUser"]=$dbAccount;
73
$params["dbPass"]=$dbPassword;
74
$params["dtName"]="namespace";
1 liveuser 75
$params["cols"]=array("*");
76
#$params["WhereColumnName"];
77
#$params["WhereColumnValue"];
78
#$params["WhereColumnOperator"];
79
#$params["orderItem"];
80
#$params["ascORdesc"];
81
#$params["numLimit"];
82
#$params["numberStart"];
83
 
182 liveuser 84
#加密參數
85
#函式說明:
86
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
87
#回傳結果:
222 liveuser 88
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
182 liveuser 89
#$result["function"],當前執行的函數名稱.
90
#$result["content"],加密後的結果.
91
#$result["error"],錯誤訊息陣列.
92
#$result["argu"],使用的參數.
93
#必填參數:
94
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
95
$conf["enCodeStr"]=$params;
96
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
97
$conf["enCodeType"]="qbpwcf";
98
#可省略參數:
99
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
100
#$conf["sha1Raw"]="false";
101
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
102
#$conf["p_hash"]="";
103
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
104
#$conf["keyForAes256"]="";
105
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
106
#$conf["aes256Encode"]="";
107
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
108
#$conf["qbpwcfDecode"]="false";
109
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
110
#$conf["gpgDecrypt"]="false";
111
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
112
#$conf["gpgId"]="";
113
#參考資料:
114
#sha1=>http://php.net/manual/en/function.sha1.php
115
#md5=>http://php.net/manual/en/function.md5.php
116
#password_hash=>http://php.net/manual/en/function.password-hash.php
117
#password_verify=>http://php.net/manual/en/function.password-verify.php
118
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
119
#備註:
120
#無.
121
$enCodeStr=authenticate::enCodeStr($conf);
122
unset($conf);
1 liveuser 123
 
182 liveuser 124
#debug
125
#var_dump(__LINE__,$enCodeStr);
1 liveuser 126
 
182 liveuser 127
#如果執行異常
128
if($enCodeStr["status"]==="false"){
1 liveuser 129
 
182 liveuser 130
	#函式說明:
131
	#撰寫log
132
	#回傳結果:
133
	#$result["status"],狀態,"true"或"false".
134
	#$result["error"],錯誤訊息陣列.
135
	#$result["function"],當前函式的名稱.
136
	#$result["argu"],使用的參數.
137
	#必填參數:
138
	#$conf["path"],log檔案的路徑與名稱.
139
	$conf["path"]=$logFile;
140
	#$conf["content"],字串,要寫的內容.
141
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
142
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
143
	$conf["fileArgu"]=__FILE__;
144
	#可省略參數:
145
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
146
	#$conf["rewrite"]="false";
147
	#參考資料:
148
	#無.
149
	#備註:
222 liveuser 150
	#無.
182 liveuser 151
	$record=logs::record($conf);
152
	unset($conf);
153
 
154
	#如果寫log 失敗
155
	if($record["status"]==="false"){
156
 
157
		#印出訊息
158
		echo json_encode($record);
222 liveuser 159
 
182 liveuser 160
		#異常結束執行
161
		exit(1);
162
 
163
		}#if end
222 liveuser 164
 
182 liveuser 165
	#異常結束執行
166
	exit(1);
167
 
168
	}#if end
169
 
170
#加密參數
171
#函式說明:
172
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
173
#回傳結果:
222 liveuser 174
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
182 liveuser 175
#$result["function"],當前執行的函數名稱.
176
#$result["content"],加密後的結果.
177
#$result["error"],錯誤訊息陣列.
178
#$result["argu"],使用的參數.
179
#必填參數:
180
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
181
$conf["enCodeStr"]=$enCodeStr["content"];
182
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
183
$conf["enCodeType"]="gpg";
184
#可省略參數:
185
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
186
#$conf["sha1Raw"]="false";
187
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
188
#$conf["p_hash"]="";
189
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
190
#$conf["keyForAes256"]="";
191
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
192
#$conf["aes256Encode"]="";
193
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
194
#$conf["qbpwcfDecode"]="false";
195
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
196
$conf["gpgDecrypt"]="false";
197
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
198
#$conf["gpgId"]="";
199
#參考資料:
200
#sha1=>http://php.net/manual/en/function.sha1.php
201
#md5=>http://php.net/manual/en/function.md5.php
202
#password_hash=>http://php.net/manual/en/function.password-hash.php
203
#password_verify=>http://php.net/manual/en/function.password-verify.php
204
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
205
#備註:
206
#無.
207
$enCodeStr=authenticate::enCodeStr($conf);
208
unset($conf);
209
 
210
#debug
211
#var_dump(__LINE__,$enCodeStr);
212
 
213
#如果執行異常
214
if($enCodeStr["status"]==="false"){
215
 
216
	#函式說明:
217
	#撰寫log
218
	#回傳結果:
219
	#$result["status"],狀態,"true"或"false".
220
	#$result["error"],錯誤訊息陣列.
221
	#$result["function"],當前函式的名稱.
222
	#$result["argu"],使用的參數.
223
	#必填參數:
224
	#$conf["path"],log檔案的路徑與名稱.
225
	$conf["path"]=$logFile;
226
	#$conf["content"],字串,要寫的內容.
227
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
228
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
229
	$conf["fileArgu"]=__FILE__;
230
	#可省略參數:
231
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
232
	#$conf["rewrite"]="false";
233
	#參考資料:
234
	#無.
235
	#備註:
222 liveuser 236
	#無.
182 liveuser 237
	$record=logs::record($conf);
238
	unset($conf);
239
 
240
	#如果寫log 失敗
241
	if($record["status"]==="false"){
242
 
243
		#印出訊息
244
		echo json_encode($record);
222 liveuser 245
 
182 liveuser 246
		#異常結束執行
247
		exit(1);
248
 
249
		}#if end
222 liveuser 250
 
182 liveuser 251
	#異常結束執行
252
	exit(1);
253
 
254
	}#if end
255
 
256
#編碼參數
257
#函式說明:
258
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
259
#回傳結果:
222 liveuser 260
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
182 liveuser 261
#$result["function"],當前執行的函數名稱.
262
#$result["content"],加密後的結果.
263
#$result["error"],錯誤訊息陣列.
264
#$result["argu"],使用的參數.
265
#必填參數:
266
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
267
$conf["enCodeStr"]=$enCodeStr["content"];
268
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
269
$conf["enCodeType"]="bin2hex";
270
#可省略參數:
271
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
272
#$conf["sha1Raw"]="false";
273
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
274
#$conf["p_hash"]="";
275
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
276
#$conf["keyForAes256"]="";
277
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
278
#$conf["aes256Encode"]="";
279
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
280
#$conf["qbpwcfDecode"]="false";
281
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
282
#$conf["gpgDecrypt"]="false";
283
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
284
#$conf["gpgId"]="";
285
#參考資料:
286
#sha1=>http://php.net/manual/en/function.sha1.php
287
#md5=>http://php.net/manual/en/function.md5.php
288
#password_hash=>http://php.net/manual/en/function.password-hash.php
289
#password_verify=>http://php.net/manual/en/function.password-verify.php
290
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
291
#備註:
292
#無.
293
$enCodeStr=authenticate::enCodeStr($conf);
294
unset($conf);
295
 
296
#debug
297
#var_dump(__LINE__,$enCodeStr);
298
 
299
#如果執行異常
300
if($enCodeStr["status"]==="false"){
301
 
302
	#函式說明:
303
	#撰寫log
304
	#回傳結果:
305
	#$result["status"],狀態,"true"或"false".
306
	#$result["error"],錯誤訊息陣列.
307
	#$result["function"],當前函式的名稱.
308
	#$result["argu"],使用的參數.
309
	#必填參數:
310
	#$conf["path"],log檔案的路徑與名稱.
311
	$conf["path"]=$logFile;
312
	#$conf["content"],字串,要寫的內容.
313
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
314
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
315
	$conf["fileArgu"]=__FILE__;
316
	#可省略參數:
317
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
318
	#$conf["rewrite"]="false";
319
	#參考資料:
320
	#無.
321
	#備註:
222 liveuser 322
	#無.
182 liveuser 323
	$record=logs::record($conf);
324
	unset($conf);
325
 
326
	#如果寫log 失敗
327
	if($record["status"]==="false"){
328
 
329
		#印出訊息
330
		echo json_encode($record);
222 liveuser 331
 
182 liveuser 332
		#異常結束執行
333
		exit(1);
334
 
335
		}#if end
222 liveuser 336
 
182 liveuser 337
	#異常結束執行
338
	exit(1);
339
 
340
	}#if end
341
 
342
#更新POST的預設參數
343
$_POST["params"]=$enCodeStr["content"];
344
 
1 liveuser 345
#涵式說明:
346
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
347
#回傳的結果:
348
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
349
#$result["error"],錯誤訊息陣列.
350
#$resutl["function"],當前執行的涵式名稱.
351
#$result["warning"],警告訊息陣列.
352
#$result["passed"],是否有皆收到全部該接收到的變數,若有設定$conf["checkedVarName"]的話,執行正常後會回傳該結果。
353
#$result["lostVarName"],沒有皆收到的變數名稱陣列
354
#$result["inputDataContent"],所接收的參數陣列.
355
#$result["inputDataContent"]["變數名稱"],所接收變數的內容.
356
#$result["inputDataCount"],從表單總共接收到幾個元素.
357
#$result["HTTP_REFERER"],前一頁的網址,null代表不存在.
358
#必填的參數:
359
#$conf["method"],字串,傳送過來的資料是用"post/POST"還是"get/GET"?
360
$conf["method"]="POST";
361
#可省略的參數:
362
#$conf["allowGet"],字串,是否要允許 get 傳值,"true",代表允許;"false" ,代表不允許,預設爲不允許.
363
#$conf["allowGet"]="true";
364
#$conf["limitPrePage"],字串陣列,是否要限定前一頁的網址為哪些,才能接收內容,不符合則轉址.
365
#$conf["limitPrePage"]=array("");
366
#$conf["transferLocation"],字串,遇到get傳值,或前一個頁面不符合要求時要轉址到的頁面,預設爲資安素養網"https://isafe.moe.edu.tw/"
367
#$conf["transferLocation"]="";
368
#$conf["ignore"]=字串陣列,如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面.
369
#$conf["ignore"]=array();
370
#$conf["correctCharacter"]=,字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理.
371
#$conf["correctCharacter"]="false";
372
#$conf["checkedVarName"],字串陣列,為檢查是否有接收到哪些變數.
373
$conf["checkedVarName"]=array("params");
374
#$conf["canBeEmptyString"],字串,用$conf["checkedVarName"]指定接收的變數名稱陣列,若接收到的內容為空字串是否算有接收到內容,預設為"false","true"代表接收到的內容可以為空字串,"false"代表接收到的內容不可以為空字串.
375
#$conf["canBeEmptyString"]="false";
376
#$conf["sessionNameArray"],陣列,若存在則代表若沒有從表單取得變數,則從session變數中取得內容,每個元素代表每個表單變數對應的session名稱,若不是要改用session方式取得變數內容的變數,請輸入null,數量請跟$conf["checkedVarName"]參數一致.
377
#$conf["sessionNameArray"]=array();
378
#$conf["unsetSessionArray"],陣列,與$conf["sessionNameArray"]對應的元素,是否要接收到變數後就卸除,"true"代表要卸除,"false"代表不要卸除.
379
#$conf["unsetSessionArray"]=array();
380
#$conf["recaptcha_url"],字串,有內容代表要檢查有無透過recaptcha於特定頁面網址認證過.
381
#$conf["recaptcha_url"]="";
382
#參考資料來源:
383
#foreach 的用法 -> http://php.net/manual/en/control-structures.foreach.php
384
#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
385
#備註:
386
#表單變數的名稱若含有「.」,則會變成「-」。
387
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf);
388
unset($conf);
389
 
182 liveuser 390
#如果執行異常
391
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
392
 
393
	#函式說明:
394
	#撰寫log
395
	#回傳結果:
396
	#$result["status"],狀態,"true"或"false".
397
	#$result["error"],錯誤訊息陣列.
398
	#$result["function"],當前函式的名稱.
399
	#$result["argu"],使用的參數.
400
	#必填參數:
401
	#$conf["path"],log檔案的路徑與名稱.
402
	$conf["path"]=$logFile;
403
	#$conf["content"],字串,要寫的內容.
404
	$conf["content"]="Form data error, please see json:".json_encode($responseMultiInputDataSecurityEnhance).PHP_EOL;
405
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
406
	$conf["fileArgu"]=__FILE__;
407
	#可省略參數:
408
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
409
	#$conf["rewrite"]="false";
410
	#參考資料:
411
	#無.
412
	#備註:
222 liveuser 413
	#無.
182 liveuser 414
	$record=logs::record($conf);
415
	unset($conf);
416
 
417
	#如果寫log 失敗
418
	if($record["status"]==="false"){
419
 
420
		#印出訊息
421
		echo json_encode($record);
222 liveuser 422
 
182 liveuser 423
		#異常結束執行
424
		exit(1);
425
 
426
		}#if end
222 liveuser 427
 
182 liveuser 428
	#異常結束執行
429
	exit(1);
222 liveuser 430
 
182 liveuser 431
	}#if end
432
 
1 liveuser 433
#函式說明:
434
#撰寫log
435
#回傳結果:
436
#$result["status"],狀態,"true"或"false".
437
#$result["error"],錯誤訊息陣列.
438
#$result["function"],當前函式的名稱.
439
#$result["argu"],使用的參數.
440
#必填參數:
441
#$conf["path"],log檔案的路徑與名稱.
442
$conf["path"]=$logFile;
443
#$conf["content"],字串,要寫的內容.
444
$conf["content"]=json_encode($responseMultiInputDataSecurityEnhance).PHP_EOL;
445
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
446
$conf["fileArgu"]=__FILE__;
447
#可省略參數:
448
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
449
#$conf["rewrite"]="false";
450
#參考資料:
451
#無.
452
#備註:
222 liveuser 453
#無.
1 liveuser 454
$record=logs::record($conf);
455
unset($conf);
456
 
457
#如果寫log 失敗
458
if($record["status"]==="false"){
459
 
460
	#印出訊息
461
	echo json_encode($record);
222 liveuser 462
 
182 liveuser 463
	#異常結束執行
464
	exit(1);
1 liveuser 465
 
466
	}#if end
467
 
182 liveuser 468
#取得參數
469
$params=$responseMultiInputDataSecurityEnhance["inputDataContent"]["params"];
1 liveuser 470
 
182 liveuser 471
#解碼參數
472
#函式說明:
473
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
474
#回傳結果:
222 liveuser 475
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
182 liveuser 476
#$result["function"],當前執行的函數名稱.
477
#$result["content"],加密後的結果.
478
#$result["error"],錯誤訊息陣列.
479
#$result["argu"],使用的參數.
480
#必填參數:
481
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
482
$conf["enCodeStr"]=$params;
483
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
484
$conf["enCodeType"]="hex2bin";
485
#可省略參數:
486
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
487
#$conf["sha1Raw"]="false";
488
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
489
#$conf["p_hash"]="";
490
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
491
#$conf["keyForAes256"]="";
492
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
493
#$conf["aes256Encode"]="";
494
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
495
#$conf["qbpwcfDecode"]="false";
496
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
497
#$conf["gpgDecrypt"]="false";
498
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
499
#$conf["gpgId"]="";
500
#參考資料:
501
#sha1=>http://php.net/manual/en/function.sha1.php
502
#md5=>http://php.net/manual/en/function.md5.php
503
#password_hash=>http://php.net/manual/en/function.password-hash.php
504
#password_verify=>http://php.net/manual/en/function.password-verify.php
505
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
506
#備註:
507
#無.
508
$enCodeStr=authenticate::enCodeStr($conf);
509
unset($conf);
1 liveuser 510
 
182 liveuser 511
#debug
512
#var_dump(__LINE__,$enCodeStr);
1 liveuser 513
 
182 liveuser 514
#如果執行異常
515
if($enCodeStr["status"]==="false"){
516
 
517
	#函式說明:
518
	#撰寫log
519
	#回傳結果:
520
	#$result["status"],狀態,"true"或"false".
521
	#$result["error"],錯誤訊息陣列.
522
	#$result["function"],當前函式的名稱.
523
	#$result["argu"],使用的參數.
524
	#必填參數:
525
	#$conf["path"],log檔案的路徑與名稱.
526
	$conf["path"]=$logFile;
527
	#$conf["content"],字串,要寫的內容.
528
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
529
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
530
	$conf["fileArgu"]=__FILE__;
531
	#可省略參數:
532
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
533
	#$conf["rewrite"]="false";
534
	#參考資料:
535
	#無.
536
	#備註:
222 liveuser 537
	#無.
182 liveuser 538
	$record=logs::record($conf);
539
	unset($conf);
540
 
541
	#如果寫log 失敗
542
	if($record["status"]==="false"){
543
 
544
		#印出訊息
545
		echo json_encode($record);
222 liveuser 546
 
182 liveuser 547
		#異常結束執行
548
		exit(1);
549
 
550
		}#if end
222 liveuser 551
 
182 liveuser 552
	#異常結束執行
553
	exit(1);
222 liveuser 554
 
1 liveuser 555
	}#if end
556
 
182 liveuser 557
#解密參數
558
#函式說明:
559
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
560
#回傳結果:
222 liveuser 561
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
182 liveuser 562
#$result["function"],當前執行的函數名稱.
563
#$result["content"],加密後的結果.
564
#$result["error"],錯誤訊息陣列.
565
#$result["argu"],使用的參數.
566
#必填參數:
567
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
568
$conf["enCodeStr"]=$enCodeStr["content"];
569
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
570
$conf["enCodeType"]="gpg";
571
#可省略參數:
572
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
573
#$conf["sha1Raw"]="false";
574
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
575
#$conf["p_hash"]="";
576
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
577
#$conf["keyForAes256"]="";
578
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
579
#$conf["aes256Encode"]="";
580
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
581
#$conf["qbpwcfDecode"]="true";
582
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
583
$conf["gpgDecrypt"]="true";
584
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
585
#$conf["gpgId"]="";
586
#參考資料:
587
#sha1=>http://php.net/manual/en/function.sha1.php
588
#md5=>http://php.net/manual/en/function.md5.php
589
#password_hash=>http://php.net/manual/en/function.password-hash.php
590
#password_verify=>http://php.net/manual/en/function.password-verify.php
591
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
592
#備註:
593
#無.
594
$enCodeStr=authenticate::enCodeStr($conf);
595
unset($conf);
1 liveuser 596
 
182 liveuser 597
#debug
598
#var_dump(__LINE__,$enCodeStr);exit;
1 liveuser 599
 
182 liveuser 600
#如果執行異常
601
if($enCodeStr["status"]==="false"){
1 liveuser 602
 
182 liveuser 603
	#函式說明:
604
	#撰寫log
605
	#回傳結果:
606
	#$result["status"],狀態,"true"或"false".
607
	#$result["error"],錯誤訊息陣列.
608
	#$result["function"],當前函式的名稱.
609
	#$result["argu"],使用的參數.
610
	#必填參數:
611
	#$conf["path"],log檔案的路徑與名稱.
612
	$conf["path"]=$logFile;
613
	#$conf["content"],字串,要寫的內容.
614
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
615
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
616
	$conf["fileArgu"]=__FILE__;
617
	#可省略參數:
618
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
619
	#$conf["rewrite"]="false";
620
	#參考資料:
621
	#無.
622
	#備註:
222 liveuser 623
	#無.
182 liveuser 624
	$record=logs::record($conf);
625
	unset($conf);
626
 
627
	#如果寫log 失敗
628
	if($record["status"]==="false"){
629
 
630
		#印出訊息
631
		echo json_encode($record);
222 liveuser 632
 
182 liveuser 633
		#異常結束執行
634
		exit(1);
635
 
636
		}#if end
222 liveuser 637
 
182 liveuser 638
	#異常結束執行
639
	exit(1);
222 liveuser 640
 
1 liveuser 641
	}#if end
642
 
182 liveuser 643
#解密參數
644
#函式說明:
645
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
646
#回傳結果:
222 liveuser 647
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
182 liveuser 648
#$result["function"],當前執行的函數名稱.
649
#$result["content"],加密後的結果.
650
#$result["error"],錯誤訊息陣列.
651
#$result["argu"],使用的參數.
652
#必填參數:
653
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
654
$conf["enCodeStr"]=$enCodeStr["content"];
655
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
656
$conf["enCodeType"]="qbpwcf";
657
#可省略參數:
658
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
659
#$conf["sha1Raw"]="false";
660
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
661
#$conf["p_hash"]="";
662
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
663
#$conf["keyForAes256"]="";
664
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
665
#$conf["aes256Encode"]="";
666
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
667
$conf["qbpwcfDecode"]="true";
668
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
669
#$conf["gpgDecrypt"]="true";
670
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
671
#$conf["gpgId"]="";
672
#參考資料:
673
#sha1=>http://php.net/manual/en/function.sha1.php
674
#md5=>http://php.net/manual/en/function.md5.php
675
#password_hash=>http://php.net/manual/en/function.password-hash.php
676
#password_verify=>http://php.net/manual/en/function.password-verify.php
677
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
678
#備註:
679
#無.
680
$enCodeStr=authenticate::enCodeStr($conf);
681
unset($conf);
1 liveuser 682
 
182 liveuser 683
#debug
684
#var_dump(__LINE__,$enCodeStr);exit;
1 liveuser 685
 
182 liveuser 686
#如果執行異常
687
if($enCodeStr["status"]==="false"){
688
 
689
	#函式說明:
690
	#撰寫log
691
	#回傳結果:
692
	#$result["status"],狀態,"true"或"false".
693
	#$result["error"],錯誤訊息陣列.
694
	#$result["function"],當前函式的名稱.
695
	#$result["argu"],使用的參數.
696
	#必填參數:
697
	#$conf["path"],log檔案的路徑與名稱.
698
	$conf["path"]=$logFile;
699
	#$conf["content"],字串,要寫的內容.
700
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
701
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
702
	$conf["fileArgu"]=__FILE__;
703
	#可省略參數:
704
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
705
	#$conf["rewrite"]="false";
706
	#參考資料:
707
	#無.
708
	#備註:
222 liveuser 709
	#無.
182 liveuser 710
	$record=logs::record($conf);
711
	unset($conf);
712
 
713
	#如果寫log 失敗
714
	if($record["status"]==="false"){
715
 
716
		#印出訊息
717
		echo json_encode($record);
222 liveuser 718
 
182 liveuser 719
		#異常結束執行
720
		exit(1);
721
 
722
		}#if end
222 liveuser 723
 
182 liveuser 724
	#異常結束執行
725
	exit(1);
222 liveuser 726
 
182 liveuser 727
	}#if end
728
 
729
#取得解碼後的結果
730
$params=$enCodeStr["content"];
731
 
1 liveuser 732
#轉換為陣列
733
$params=(array)$params;
734
 
735
#函式說明:
736
#撰寫log
737
#回傳結果:
738
#$result["status"],狀態,"true"或"false".
739
#$result["error"],錯誤訊息陣列.
740
#$result["function"],當前函式的名稱.
741
#$result["argu"],使用的參數.
742
#必填參數:
743
#$conf["path"],log檔案的路徑與名稱.
744
$conf["path"]=$logFile;
745
#$conf["content"],字串,要寫的內容.
746
$conf["content"]=json_encode($params).PHP_EOL;
747
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
748
$conf["fileArgu"]=__FILE__;
749
#可省略參數:
750
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
751
#$conf["rewrite"]="false";
752
#參考資料:
753
#無.
754
#備註:
222 liveuser 755
#無.
1 liveuser 756
$record=logs::record($conf);
757
unset($conf);
758
 
759
#如果寫log 失敗
760
if($record["status"]==="false"){
761
 
762
	#印出訊息
763
	echo json_encode($record);
222 liveuser 764
 
182 liveuser 765
	#異常結束執行
766
	exit(1);
1 liveuser 767
 
768
	}#if end
769
 
770
#如果少了使用資料庫系統的dbSecret
771
if(!isset($params["dbSecret"])){
772
 
773
	#結束執行
774
	exit;
775
 
776
	}#if end
222 liveuser 777
 
1 liveuser 778
#驗證密碼是否正確
779
else{
780
 
781
	#若dbSecret錯誤
782
	if($params["dbSecret"]!==dbSecret){
222 liveuser 783
 
182 liveuser 784
		#函式說明:
785
		#撰寫log
786
		#回傳結果:
787
		#$result["status"],狀態,"true"或"false".
788
		#$result["error"],錯誤訊息陣列.
789
		#$result["function"],當前函式的名稱.
790
		#$result["argu"],使用的參數.
791
		#必填參數:
792
		#$conf["path"],log檔案的路徑與名稱.
793
		$conf["path"]=$logFile;
794
		#$conf["content"],字串,要寫的內容.
795
		$conf["content"]="wrong dbSecret".PHP_EOL;
796
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
797
		$conf["fileArgu"]=__FILE__;
798
		#可省略參數:
799
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
800
		#$conf["rewrite"]="false";
801
		#參考資料:
802
		#無.
803
		#備註:
222 liveuser 804
		#無.
182 liveuser 805
		$record=logs::record($conf);
806
		unset($conf);
807
 
808
		#如果寫log 失敗
809
		if($record["status"]==="false"){
810
 
811
			#印出訊息
812
			echo json_encode($record);
222 liveuser 813
 
182 liveuser 814
			#異常結束執行
815
			exit(1);
816
 
817
			}#if end
222 liveuser 818
 
1 liveuser 819
		#結束執行
820
		exit;
222 liveuser 821
 
1 liveuser 822
		}#if end
222 liveuser 823
 
1 liveuser 824
	#移除傳遞的 dbSecret
825
	unset($params["dbSecret"]);
826
 
827
	}#else end
828
 
829
#檢查變數
830
#函式說明:
831
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
832
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
833
#$reuslt["error"],執行不正常結束的錯訊息陣列.
834
#$result["function"],當前執行的函式名稱.
835
#$result["argu"],設置給予的參數.
836
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
837
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
838
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
839
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
840
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
841
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
842
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
843
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
844
#必填寫的參數:
845
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
846
$conf["variableCheck::checkArguments"]["varInput"]=&$params;
847
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
848
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
849
#可以省略的參數:
850
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
851
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("dbAddr","dbName","dbUser","dbPass","dtName","cols");
852
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
853
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string","array");
854
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
855
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
856
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
857
#$conf["canNotBeEmpty"]=array();
858
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
859
#$conf["canBeEmpty"]=array();
860
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
861
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("dbPort","orderItem","ascORdesc","numLimit","WhereColumnName","WhereColumnValue","WhereColumnOperator","numberStart");
862
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
863
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("dbPort","orderItem","ascORdesc","numLimit","WhereColumnName","WhereColumnValue","WhereColumnOperator","numberStart");
864
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
865
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","array","array","array","string");
866
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
867
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("3306",null,null,null,null,null,null,"0");
868
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
869
#$conf["disallowAllSkipableVarIsEmpty"]="";
870
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
871
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
872
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
873
$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("cols","vals");
874
#參考資料來源:
875
#array_keys=>http://php.net/manual/en/function.array-keys.php
876
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
877
unset($conf["variableCheck::checkArguments"]);
878
 
879
#函式說明:
880
#撰寫log
881
#回傳結果:
882
#$result["status"],狀態,"true"或"false".
883
#$result["error"],錯誤訊息陣列.
884
#$result["function"],當前函式的名稱.
885
#$result["argu"],使用的參數.
886
#必填參數:
887
#$conf["path"],log檔案的路徑與名稱.
888
$conf["path"]=$logFile;
889
#$conf["content"],字串,要寫的內容.
890
$conf["content"]=json_encode($checkArguments).PHP_EOL;
891
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
892
$conf["fileArgu"]=__FILE__;
893
#可省略參數:
894
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
895
#$conf["rewrite"]="false";
896
#參考資料:
897
#無.
898
#備註:
222 liveuser 899
#無.
1 liveuser 900
$record=logs::record($conf);
901
unset($conf);
902
 
903
#如果寫log 失敗
904
if($record["status"]==="false"){
905
 
906
	#印出訊息
907
	echo json_encode($record);
222 liveuser 908
 
182 liveuser 909
	#異常結束執行
910
	exit(1);
1 liveuser 911
 
912
	}#if end
913
 
914
#如果執行失敗
915
if($checkArguments["status"]==="false"){
916
 
917
	#印出訊息
918
	echo json_encode($checkArguments);
919
 
182 liveuser 920
	#異常結束執行
921
	exit(1);
1 liveuser 922
 
923
	}#if end
924
 
925
#如果邊數檢查不通過
926
if($checkArguments["passed"]==="false"){
927
 
928
	#印出訊息
929
	echo json_encode($checkArguments);
930
 
931
	#結束執行
932
	exit;
933
 
934
	}#if end
935
 
936
/*
937
#可能存在的參數
938
$params["dbAddr"];
939
$params["dbPort"];
940
$params["dbName"];
941
$params["dbUser"];
942
$params["dbPass"];
943
$params["dtName"];
944
$params["cols"];
945
$params["WhereColumnName"];
946
$params["WhereColumnValue"];
947
$params["WhereColumnOperator"];
948
$params["orderItem"];
949
$params["ascORdesc"];
950
$params["numLimit"];
951
*/
952
 
953
#涵式說明:
954
#一次取得資料庫、表的資料
955
#回傳的結果
956
#$result["status"],執行結果"true"為成功;"false"為執行失敗。
957
#$result["error"],錯誤訊息陣列。
958
#$result["function"],當前執行的漢書名稱.
959
#$result["argu"],使用的參數.
960
#$result["dataColumnName"],抓取的資料欄位名稱陣列.
961
	#$result["dataColumnName"][$i]代表第$i+1個欄位名稱
962
#$result["dataContent"],爲資料的內容。
963
#$result["dataContent"][$conf["WhereColumnName"][$i]][$dataSetNum]
964
	#$dataSetNum 爲第$dataSetNum+1筆資料
965
	#$conf["WhereColumnName"][$i] 爲第 $i+1 個欄位的名稱
966
#$result["dataCount"],爲取得的資料筆數。
967
#$result["sql"],執行的sql字串.
968
#必填的參數:
969
$conf["dbAddress"]=$params["dbAddr"];#爲dbServer的位置。
970
$conf["dbAccount"]=$params["dbUser"];#爲登入dbServer的帳號。
971
$conf["dbName"]=$params["dbName"];#爲要存取的資料庫名稱
972
$conf["tableName"]=$params["dtName"];#爲要存取的資料表名稱
973
$conf["columnYouWant"]=$params["cols"];#你想要的欄位!,若設為「array("*")」則代表全部欄位.
974
#可省略的參數:
975
$conf["dbPassword"]=$params["dbPass"];#爲要存取dbServer的密碼
976
 
977
#如果存在 $params["WhereColumnName"]
978
if(isset($params["WhereColumnName"])){
979
 
980
	$conf["WhereColumnName"]=$params["WhereColumnName"];#用於判斷語句的欄位項目陣列。
981
 
982
	}#if end
983
 
984
#如果存在 $params["WhereColumnName"]
985
if(isset($params["WhereColumnValue"])){
986
 
987
	$conf["WhereColumnValue"]=$params["WhereColumnValue"];#用於判斷語句的欄位數值陣列,若與LIKE搭配,則可以在關鍵自字串的左右名加上「%」符號,這樣就可以搜尋具有該字串的內容。
988
 
989
	}#if end
990
 
991
#$conf["WhereColumnCombine"]=array("");#用於判斷語句當中需要()起來的判斷式,須爲陣列值,"s"代表「(」,"e"代表「)」 ,若無則須設爲""。
992
 
993
#如果存在 $params["WhereColumnOperator"]
994
if(isset($params["WhereColumnOperator"])){
995
 
996
	$conf["WhereColumnOperator"]=$params["WhereColumnOperator"];#用於判斷語句的比較符號陣列,可以用的符號有「"="、"!="、">"、"<"、"LIKE"、"NOT LIKE"」,預設都爲「=」。
997
 
998
	}#if end
999
 
1000
#$conf["WhereColumnAndOr"]=array("");#用於判斷語句條件之間成立的條件是AND還是OR,須爲陣列值。其數量應爲要判斷的欄位數量減一。
1001
#$conf["whereIn"],二維字串陣列,為每個in語句的內容,特定欄位數值等於陣列元素之一。array(array("colName",array("a","b","c")));代表欄位colName的值為a,b,c三者之一.
1002
#$conf["whereIn"]=array(array("colName",array("a","b","c")));
1003
#$conf["whereNotIn"],二維字串陣列,為每個not in語句的內容,array(array("colName",array("a","b","c")));代表欄位colName的值不為a,b,c三者之一.
1004
#$conf["whereNotIn"]=array(array("colName",array("a","b","c")));
1005
 
1006
#如果有設置 $params["orderItem"]
1007
if(isset($params["orderItem"])){
1008
 
1009
	$conf["orderItem"]=$params["orderItem"];#爲排序的項目依據,若要用隨機抽樣,可以用"rand()",可省略。
1010
 
1011
	}#if end
1012
 
1013
#如果有設置 $params["ascORdesc"]
1014
if(isset($params["ascORdesc"])){
1015
 
1016
	$conf["ascORdesc"]=$params["ascORdesc"];#爲要低增還是遞減排序,asc爲遞增;desc爲遞減。
1017
 
1018
	}#if end
1019
 
1020
#如果有設置 $params["numLimit"]
1021
if(isset($params["numLimit"])){
1022
 
1023
	$conf["numLimit"]=$params["numLimit"];#為要取幾筆資料,可以省略,省略則表示不限制數目。
1024
 
1025
	}#if end
1026
 
1027
#如果有設置 $params["numberStart"]
1028
if(isset($params["numberStart"])){
1029
 
1030
	$conf["numberStart"]=$params["numberStart"];#為從第幾筆開始讀取,預設為0,代筆第一筆。
1031
 
1032
	}#if end
1033
 
1034
#$conf["groupBy"]=array("");#爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
1035
#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的3306 port.
1036
$conf["dbPort"]=$params["dbPort"];
1037
$fastGetDbData=db::fastGetDbData($conf);
1038
unset($conf);
1039
 
182 liveuser 1040
#如果執行異常
1041
if($fastGetDbData["status"]==="false"){
1042
 
1043
	#函式說明:
1044
	#撰寫log
1045
	#回傳結果:
1046
	#$result["status"],狀態,"true"或"false".
1047
	#$result["error"],錯誤訊息陣列.
1048
	#$result["function"],當前函式的名稱.
1049
	#$result["argu"],使用的參數.
1050
	#必填參數:
1051
	#$conf["path"],log檔案的路徑與名稱.
1052
	$conf["path"]=$logFile;
1053
	#$conf["content"],字串,要寫的內容.
1054
	$conf["content"]=json_encode($fastGetDbData).PHP_EOL;
1055
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1056
	$conf["fileArgu"]=__FILE__;
1057
	#可省略參數:
1058
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1059
	#$conf["rewrite"]="false";
1060
	#參考資料:
1061
	#無.
1062
	#備註:
222 liveuser 1063
	#無.
182 liveuser 1064
	$record=logs::record($conf);
1065
	unset($conf);
1066
 
1067
	#如果寫log 失敗
1068
	if($record["status"]==="false"){
1069
 
1070
		#印出訊息
1071
		echo json_encode($record);
222 liveuser 1072
 
182 liveuser 1073
		#異常結束執行
1074
		exit(1);
1075
 
1076
		}#if end
222 liveuser 1077
 
182 liveuser 1078
	#異常結束執行
1079
	exit(1);
222 liveuser 1080
 
182 liveuser 1081
	}#if end
1082
 
1 liveuser 1083
#函式說明:
1084
#撰寫log
1085
#回傳結果:
1086
#$result["status"],狀態,"true"或"false".
1087
#$result["error"],錯誤訊息陣列.
1088
#$result["function"],當前函式的名稱.
1089
#$result["argu"],使用的參數.
1090
#必填參數:
1091
#$conf["path"],log檔案的路徑與名稱.
1092
$conf["path"]=$logFile;
1093
#$conf["content"],字串,要寫的內容.
1094
$conf["content"]=json_encode($fastGetDbData).PHP_EOL;
1095
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1096
$conf["fileArgu"]=__FILE__;
1097
#可省略參數:
1098
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1099
#$conf["rewrite"]="false";
1100
#參考資料:
1101
#無.
1102
#備註:
222 liveuser 1103
#無.
1 liveuser 1104
$record=logs::record($conf);
1105
unset($conf);
1106
 
1107
#如果寫log 失敗
1108
if($record["status"]==="false"){
1109
 
1110
	#印出訊息
1111
	echo json_encode($record);
222 liveuser 1112
 
1 liveuser 1113
	#結束執行
1114
	exit;
1115
 
1116
	}#if end
1117
 
1118
#印出訊息
1119
echo json_encode($fastGetDbData);
1120
 
1121
?>