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