| Line 118... |
Line 118... |
| 118 |
$debug=false;
|
118 |
$debug=false;
|
| 119 |
|
119 |
|
| 120 |
#預設暫存的白名單ip有效時間為1小時
|
120 |
#預設暫存的白名單ip有效時間為1小時
|
| 121 |
$tmp_white_ip_valid_time=1;
|
121 |
$tmp_white_ip_valid_time=1;
|
| 122 |
|
122 |
|
| - |
|
123 |
#初始化儲存拜訪的用戶名單
|
| - |
|
124 |
$clientBothers=array();
|
| - |
|
125 |
|
| 123 |
#說明函式
|
126 |
#說明函式
|
| 124 |
function help(){
|
127 |
function help(){
|
| 125 |
|
128 |
|
| 126 |
#印出指令說明
|
129 |
#印出指令說明
|
| 127 |
echo "Usage of ".basename(__FILE__).":".PHP_EOL;
|
130 |
echo "Usage of ".basename(__FILE__).":".PHP_EOL;
|
| Line 129... |
Line 132... |
| 129 |
echo "--exclude [white list ip] 代表白名單IP,一次只能放一個IP.".PHP_EOL;
|
132 |
echo "--exclude [white list ip] 代表白名單IP,一次只能放一個IP.".PHP_EOL;
|
| 130 |
echo "--tmp-white-ip-valid-time [white ip value time] 指定暫時白名單的有效小時".PHP_EOL;
|
133 |
echo "--tmp-white-ip-valid-time [white ip value time] 指定暫時白名單的有效小時".PHP_EOL;
|
| 131 |
echo "--client [true/false] 代表是否為 client 端,而非 server 端".PHP_EOL;
|
134 |
echo "--client [true/false] 代表是否為 client 端,而非 server 端".PHP_EOL;
|
| 132 |
echo "--client-add-tmp-white-ip [while ip for while] client端指令,代表要增加的暫時白名單IP".PHP_EOL;
|
135 |
echo "--client-add-tmp-white-ip [while ip for while] client端指令,代表要增加的暫時白名單IP".PHP_EOL;
|
| 133 |
echo "--client-update-tmp-white-ip-valid-time [white ip value time] client端指令,代表要更新暫時白名單的有效時間,單位為小時".PHP_EOL;
|
136 |
echo "--client-update-tmp-white-ip-valid-time [white ip value time] client端指令,代表要更新暫時白名單的有效時間,單位為小時".PHP_EOL;
|
| - |
|
137 |
echo "--client-bother-query [base64 encode json string] client端指令,代表要記錄與查詢該用戶資訊是否太過頻繁拜訪. ".PHP_EOL;
|
| 134 |
|
138 |
|
| 135 |
#結束執行
|
139 |
#結束執行
|
| 136 |
exit;
|
140 |
exit;
|
| 137 |
|
141 |
|
| 138 |
}#function help end
|
142 |
}#function help end
|
| Line 208... |
Line 212... |
| 208 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
212 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
| 209 |
#$conf["canNotBeEmpty"]=array();
|
213 |
#$conf["canNotBeEmpty"]=array();
|
| 210 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
214 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
| 211 |
#$conf["canBeEmpty"]=array();
|
215 |
#$conf["canBeEmpty"]=array();
|
| 212 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
216 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
| 213 |
$conf["skipableVariableCanNotBeEmpty"]=array("debug","exclude","tmp-white-ip-valid-time","client","tmp-white-ip-valid-time","client-add-tmp-white-ip","client-update-tmp-white-ip-valid-time");
|
217 |
$conf["skipableVariableCanNotBeEmpty"]=array("debug","exclude","tmp-white-ip-valid-time","client","tmp-white-ip-valid-time","client-add-tmp-white-ip","client-update-tmp-white-ip-valid-time","client-bother-query");
|
| 214 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
218 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
| 215 |
$conf["skipableVariableName"]=array("debug","exclude","tmp-white-ip-valid-time","client","tmp-white-ip-valid-time","client-add-tmp-white-ip","client-update-tmp-white-ip-valid-time");
|
219 |
$conf["skipableVariableName"]=array("debug","exclude","tmp-white-ip-valid-time","client","tmp-white-ip-valid-time","client-add-tmp-white-ip","client-update-tmp-white-ip-valid-time","client-bother-query");
|
| 216 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
220 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 217 |
$conf["skipableVariableType"]=array("array","array","array","array","array","array","array");
|
221 |
$conf["skipableVariableType"]=array("array","array","array","array","array","array","array","array");
|
| 218 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
222 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
| 219 |
$conf["skipableVarDefaultValue"]=array(array("false"),null,array("1"),null,null,null,null);
|
223 |
$conf["skipableVarDefaultValue"]=array(array("false"),null,array("1"),null,null,null,null.null);
|
| 220 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
224 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
| 221 |
$conf["disallowAllSkipableVarIsEmpty"]="false";
|
225 |
$conf["disallowAllSkipableVarIsEmpty"]="false";
|
| 222 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
226 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
| 223 |
$conf["disallowAllSkipableVarIsEmptyArray"]="false";
|
227 |
$conf["disallowAllSkipableVarIsEmptyArray"]="false";
|
| 224 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
228 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
| Line 508... |
Line 512... |
| 508 |
$res=(array)json_decode(trim($res));
|
512 |
$res=(array)json_decode(trim($res));
|
| 509 |
|
513 |
|
| 510 |
#要求 server 端更新暫時白名單的期限 - end
|
514 |
#要求 server 端更新暫時白名單的期限 - end
|
| 511 |
|
515 |
|
| 512 |
}#if end
|
516 |
}#if end
|
| - |
|
517 |
|
| - |
|
518 |
#如果有 client-bother-query 參數
|
| - |
|
519 |
if(isset($parseArgu["content"]["client-bother-query"])){
|
| - |
|
520 |
|
| - |
|
521 |
#針對每個要查詢的用戶資訊
|
| - |
|
522 |
foreach($parseArgu["content"]["client-bother-query"] as $client2query){
|
| - |
|
523 |
|
| - |
|
524 |
#取得json字串
|
| - |
|
525 |
$jsonStr=base64_decode($client2query);
|
| - |
|
526 |
|
| - |
|
527 |
#如果不是 json 字串
|
| - |
|
528 |
if(json_validate($jsonStr)===false){
|
| - |
|
529 |
|
| - |
|
530 |
#跳過
|
| - |
|
531 |
continue;
|
| - |
|
532 |
|
| - |
|
533 |
}#if end
|
| - |
|
534 |
|
| - |
|
535 |
#to object
|
| - |
|
536 |
$jsonObj=json_decode($jsonStr);
|
| - |
|
537 |
|
| - |
|
538 |
#如果必備的查詢條件有缺
|
| - |
|
539 |
if( !isset($jsonObj->clientIp) || !isset($jsonObj->clientAgent) || !isset($jsonObj->clientHeader) ){
|
| - |
|
540 |
|
| - |
|
541 |
#跳過
|
| - |
|
542 |
continue;
|
| - |
|
543 |
|
| - |
|
544 |
}#if end
|
| - |
|
545 |
|
| - |
|
546 |
#未實作,跳過
|
| - |
|
547 |
continue;
|
| - |
|
548 |
|
| - |
|
549 |
}#foreach end
|
| - |
|
550 |
|
| - |
|
551 |
}#if end
|
| 513 |
|
552 |
|
| 514 |
#client端程式結束,結束執行
|
553 |
#client端程式結束,結束執行
|
| 515 |
exit;
|
554 |
exit;
|
| 516 |
|
555 |
|
| 517 |
}#if end
|
556 |
}#if end
|