Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 1 | Rev 17 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2015~2022 Min-Jhin,Chen

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/

#參考資料網址
#http://reference.sitepoint.com/html/extended-event-attributes/ondragstart

#宣告指派命名空間
namespace qbpwcf;

#建立一個跟網頁安全性有關的類別
class security{

        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        */
        public function __call($method,$arguments){
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #設置執行不正常
                $result["status"]="false";
                
                #設置執行錯誤
                $result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
                
                #設置所丟入的參數
                $result["error"][]=$arguments;
                
                #回傳結果
                return $result;
                
                }#function __call end
                
        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        */
        public static function __callStatic($method,$arguments){
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #設置執行不正常
                $result["status"]="false";
                
                #設置執行錯誤
                $result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
                
                #設置所丟入的參數
                $result["error"][]=$arguments;
                
                #回傳結果
                return $result;
                
                }#function __callStatic end
        
        /*
        #涵式說明:                
        #禁止特定的angent訪問我們的網站,例如google與百度的搜尋引擎。
        #回傳的結果
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息.
        #$result["function"],當前執行的函數名稱.
        #必填的參數:
        #$conf["disableAngentName"],字串,要禁止拜訪的用戶端資訊,代表要禁止哪些瀏覽器/搜尋引擎瀏覽,格式爲 /(含有哪些關鍵字,若有多個請用「|」隔開。)/i.
        $conf["disableAngentName"]="/(Chrome|Mozilla|Internet)/i";
        #可省略的參數:
        ##$conf["transferLocation"],字串,如果是要禁止搜尋引擎,要轉址到那個地方?,若沒設定,則預設爲資安素養網的臉書(https://zh-tw.facebook.com/isafemoe).
        #$conf["transferLocation"]="";
        #參考資料來源:
        #http://php.net/manual/en/function.preg-match.php
        */
        public static function preventSerchEngine(&$conf){

                #初始化要回傳的內容
                $result=array();
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end

                #debug,檢查 $_SERVER["HTTP_USER_AGENT"] 的內容
                #var_dump($_SERVER['HTTP_USER_AGENT']);
                
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("disableAngentName");
                #$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
                #$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["canBeEmptyString"]="false";
                #$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("transferLocation");
                #$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("https://zh-tw.facebook.com/isafemoe");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
                                
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;
                        
                        }#if end        
                        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;
                        
                        }#if end        
                                        
                #如果使用者的瀏覽器出現變數 $conf["disableAngentName"] 裡面的關鍵字
                if(preg_match($conf["disableAngentName"],$_SERVER["HTTP_USER_AGENT"])){

                        #則轉址特定頁面
                        #函式說明:
                        #設定session變數後,立即轉址.
                        #回傳的結果:
                        #$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
                        #$result["function"],當前執行的函數名稱.
                        #$result["error"],錯誤訊息陣列.
                        #必填的參數:
                        #$conf["header::redirectionNow"]["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
                        $conf["header::redirectionNow"]["headerLocation"]=$conf["transferLocation"];
                        #可省略的參數:
                        #$conf["sessionName"],字串陣列,可以指派session變數的名稱.
                        #$conf["sessionName"]=array("");
                        #$conf["sessionValue"]字串陣列,可以指派session變數的內容.
                        #$conf["sessionValue"]=array("");
                        #參靠資料來源:
                        #http://php.net/manual/en/reserved.variables.server.php
                        $redirectionNow=header::redirectionNow($conf["header::redirectionNow"]);
                        unset($conf["header::redirectionNow"]);                 
        
                        #如果轉址失敗
                        if($redirectionNow["status"]=="false"){
                                
                                #設置執行失敗
                                $result["status"]="false";
                                
                                #設置執行錯誤訊息
                                $result["error"]=$redirectionNow;

                                #回傳結果
                                return $result;
                                
                                }#if end
        
                        }#if end                
                        
                #執行到這邊代表是可以拜訪的網頁瀏覽器
                $result["status"]="true";
                
                #回傳結果
                return $result;

                }#function preventSerchEngine end

        #涵式說明:
        #禁止做任違反版權的事情,禁止在網頁按下滑鼠右鍵,禁止複製圖片,禁止開新分頁(失敗), 版權所有、Power by訊息.
        #回傳的內容:
        #保護版權的語法
        #必填參數:
        #無
        #可省略參數:
        #$conf["name"],字串,公司、組織、單位的名稱,預設不指定.
        #$conf["name"]="";
        #$conf["powerBy"],字串,由誰提供,預設爲QBPWCF.
        #$conf["powerBy"]="";
        #$conf["powerByLink"],字串,power by字串的連結目標,預設爲"https://www.qbpwcf.org".
        #$conf["powerByLink"]="";
        #$conf["bgColor"],字串,背景顏色,預設爲淡藍色.
        #$conf["bgColor"]="";
        #參考資料:
        #http://www.w3schools.com/jsref/dom_obj_event.asp
        public static function copyRight(&$conf=array()){
        
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if(is_null($conf)){

                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";

                                }#if end

                        #回傳結果
                        return $result;

                        }#if end
                        
                #初始化 content
                $result["content"]="";  
                
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["argu"],設置給予的參數.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                #$conf["mustBeFilledVariableName"]=array();
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                #$conf["mustBeFilledVariableType"]=array();
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                #$conf["canBeEmptyString"]="false";
                #$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
                #$conf["canNotBeEmpty"]=array();
                #$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
                #$conf["canBeEmpty"]=array();
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
                $conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("powerBy","powerByLink","bgColor");
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("name","powerBy","powerByLink","bgColor");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("","QBPWCF","https://mobile.qbpwcf.org","#DDDDFF");
                #$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
                #$conf["disallowAllSkipableVarIsEmpty"]="";
                #$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
                #$conf["disallowAllSkipableVarIsEmptyArray"]="";
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
                
                #如果檢查失敗
                if($checkArguments["status"]=="false"){

                        #設置錯誤狀態
                        $result["status"]="false";

                        #設置錯誤提示
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;

                        }#if end

                #如果檢查不通過
                if($checkArguments["passed"]=="false"){

                        #設置錯誤狀態
                        $result["status"]="false";

                        #設置錯誤提示
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;

                        }#if end
                                
                #涵式說明:
                #將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填的參數:
                #$conf["script"],字串,要執行的javaScript語法.
                $conf["javaScript::toScript"]["script"]="
                var copyRightDiv=document.createElement('div');
                var copyRightSpan=document.createElement('span');
                var copyRightText=document.createTextNode('".$conf["name"]."');
                copyRightSpan.appendChild(copyRightText);
                var powerBySpan=document.createElement('span');
                var powerByA=document.createElement('a');
                powerByA.href='".$conf["powerByLink"]."';
                powerByA.target='_blank';
                var powerByText=document.createTextNode('Powered by '+'".$conf["powerBy"]."');
                powerByA.appendChild(powerByText);
                powerBySpan.appendChild(powerByA);
                copyRightDiv.appendChild(copyRightSpan);
                copyRightDiv.appendChild(powerBySpan);
                copyRightDiv.style.backgroundColor='".$conf["bgColor"]."';
                copyRightDiv.style.textAlign='center';
                document.body.appendChild(copyRightDiv);
                ";
                #可省略參數:
                #$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
                #$conf["onReady"]="true";
                #$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
                #$conf["globalJs"]=array();
                #$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
                #$conf["jsFunciton"]=array();
                #參考資料:
                #http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
                $toScript=javaScript::toScript($conf["javaScript::toScript"]);
                unset($conf["javaScript::toScript"]);
                        
                #如果建立 javascript 語法失敗
                if($toScript["status"]==="false"){      
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$toScript;

                        #回傳結果
                        return $result; 
                        
                        }#if end
                
                #傳接 content 
                $result["content"]=$result["content"].$toScript["content"];
                        
                #保護版權的語法
                #oncontextmenu,按下滑鼠右鍵
                #onContextMenu,按下滑鼠右鍵
                #ondragstart,開始拖曳
                #onselsect,選取區塊時
                #onselectstart,開始選取區塊
                #onkeydown='if(event.tKey && event.ctrlKey),按下ctrl+t開分頁時
                $result["content"]=$result["content"]."
                        <html
                        oncontextmenu=\"return false\" 
                        onContextMenu=\"window.event.returnValue=false\"
                        onselect=\"return false\"
                        onselectstart=\"return false\" 
                        ondragstart=\"return false\" 
                        oncopy=\"return false\"
                        onbeforeprint=\"return false\"
                        >\r\n";
                
                #設置執行正常
                $result["status"]="true";
                
                #回傳語法
                return $result;
                
                }#函式結束

        /*
        #涵式說明: 
        #放置用空白圖片擋住要呈現的圖片
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息.
        #$result["function"],當前執行的函數名稱.
        #$result["content"],語法.
        #必填的參數:
        $conf["imgAddress"],字串,要放的圖片位置和名稱.
        $conf["imgAddress"]="";
        $conf["imgWidth"],字串,爲圖片的寬.
        $conf["imgWidth"]="";
        $conf["imgHeight"],字串,爲圖片的高.
        $conf["imgHeight"]="";
        $conf["imgLeft"]=,字串,爲圖片放置的位置距離網頁左邊多少.
        $conf["imgLeft"]="";
        $conf["imgTop"]=,字串,爲圖片放置的位置距離網頁頂端多少.
        $conf["imgTop"]="";
        #可省略參數:
        #$conf["useBase64"],字串,是否要用base64的方式呈現圖片,預設為"true"代表要用base64的方式呈現,反之可用"false".
        #$conf["useBase64"]="true";
        */      
        public static function imgProtect($conf){

                #初始化要回傳的內容
                $result=array();
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end

                #初始化程式碼
                $result["content"]="";
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("imgAddress","imgWidth","imgHeight","imgLeft","imgTop");
                #$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string");
                #$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["canBeEmptyString"]="false";
                #$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("useBase64");
                #$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
                                
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;
                        
                        }#if end        
                        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;
                        
                        }#if end

                #建立要放置的圖片樣式
                #涵式說明: 
                #創建 css 樣式
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["css"],css設定內容
                #$result["function"],當前執行的函數
                #$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤 
                $conf["css"]["createCssStyle"]["cssStyleName"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
                $conf["css"]["createCssStyle"]["attributes"]=array("width","height","position","top","left");
                $conf["css"]["createCssStyle"]["content"]=array($conf["imgWidth"],$conf["imgHeight"],"absolute",$conf["imgTop"],$conf["imgLeft"]);
                $css=css::createCssStyle($conf["css"]["createCssStyle"]);
                unset($conf["css"]["createCssStyle"]);#清空變數避免出錯
                
                #如果建立css樣式失敗
                if($css["status"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$css;

                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #串接css語法
                $result["content"]=$result["content"].$css["css"];

                #如果要用base64顯示圖片
                if($conf["useBase64"]=="true"){
                        
                        #將圖片用base64加密呈現
                        #函數說明:
                        #用data:mimeType;base64,imgVar的形式來提供圖片的連結,亦即圖片儲存在變數裡面,本函式包含顯示圖片的語法.
                        #回傳結果:
                        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                        #$result["error"],錯誤訊息
                        #$result["content"],圖片的連結資訊
                        #$result["function"],當前執行的函數名稱 
                        #必填參數:
                        #$conf["img::data"]["imgPosition"],要轉存成2元碼的圖片檔案位置與名稱
                        $conf["img::data"]["imgPosition"]=$conf["imgAddress"];
                        #可省略參數:
                        #$conf["img::data"]["alt"],若沒有圖片要用什麼文字顯示。
                        $conf["img::data"]["alt"]="not found";
                        #$conf["img::data"]["class"],圖片要套用的css樣式名稱.
                        $conf["img::data"]["class"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
                        #$conf["mimeType"],2元碼的內容是什麼,預設為"image/*".
                        #$conf["mimeType"]="image/*";
                        #$conf["compressType"],2元碼壓縮的方式,預設為"base64".
                        #$conf["compressType"]="base64";
                        #$conf["delImg"],讀取完圖片檔案後,要移除圖片嗎?"true"代表要移除,"false"代表不要移除,預設為"false".
                        #$conf["delImg"]="false";
                        #參考資料:
                        #將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php
                        #壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
                        $data=img::data($conf["img::data"]);
                        unset($conf["img::data"]);

                        #將圖片用base64加密呈現失敗
                        if($data["status"]=="false"){
                                                        
                                #設置執行失敗
                                $result["status"]="false";
                                
                                #設置執行錯誤訊息
                                $result["error"]=$data;

                                #回傳結果
                                return $result;
                                
                                }#if end
                        
                        #取得用base64放置圖片的語法
                        $result["content"]=$result["content"].$data["content"];
                        
                        }#if end

                #反之為一般放置圖片的方式
                else{
                        
                        #放置要放的圖片
                        #涵式說明:
                        #放置可以套用css樣式的圖片
                        #回傳的結果:
                        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                        #$result["error"],錯誤訊息陣列
                        #$result["function"],當前函數執行的名稱
                        #$result["content"],印出圖片的語法。            
                        $conf["img"]["show"]["position"]=$conf["imgAddress"];
                        $conf["img"]["show"]["alt"]="not found";
                        $conf["img"]["show"]["class"]="imgStyle-".$conf["imgLeft"].$conf["imgTop"];
                        $show=img::show($conf["img"]["show"]);
                        unset($conf["img"]["show"]);#清空變數避免出錯

                        #如果放置圖片的語法建立失敗
                        if($show["status"]=="false"){
                                
                                #設置執行失敗
                                $result["status"]="false";
                                
                                #設置執行錯誤訊息
                                $result["error"]=$show;

                                #回傳結果
                                return $result;
                                
                                }#if end
                        
                        #串接顯示圖片的語法
                        $result["content"]=$result["content"].$show["content"];
                        
                        }#else end

                #建立圖片隔離層樣式
                $conf["css"]["createCssStyle"]["cssStyleName"]="imgIsolationLayerStyle".$conf["imgLeft"].$conf["imgTop"];
                $conf["css"]["createCssStyle"]["attributes"]=array("width","height","opacity","position","top","left");
                $conf["css"]["createCssStyle"]["content"]=array($conf["imgWidth"],$conf["imgHeight"],".0","absolute",$conf["imgTop"],$conf["imgLeft"]);
                $css=css::createCssStyle($conf["css"]["createCssStyle"]);
                unset($conf["css"]["createCssStyle"]);#清空變數避免出錯
        
                #如果建立css樣式失敗
                if($css["status"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$css;

                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #取得圖片隔離層樣式程式碼
                $result["content"]=$result["content"].$css["css"];

                #放置隔離層
                #涵式說明:
                #放置可以套用css樣式的圖片
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前函數執行的名稱
                #$result["content"],印出圖片的語法。            
                #必填的參數:
                $conf["img"]["show"]["position"]="copyRight.png";#圖片位置
                #可省略的參數:
                #$conf["img"]["show"]["alt"]="not found";#若沒有圖片要用什麼文字顯示。
                $conf["img"]["show"]["class"]="imgIsolationLayerStyle".$conf["imgLeft"].$conf["imgTop"];#要套用的css樣式類別名稱。
                $show=img::show($conf["img"]["show"]);
                unset($conf["img"]["show"]);
                
                #如果放置圖片的語法建立失敗
                if($show["status"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$show;

                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #串接顯示隔離層圖片的語法
                $result["content"]=$result["content"].$show["content"];

                #執行到這邊代表執行成功
                $result["status"]="true";
                
                #回傳語法
                return $result;

                }#function imgProtect end

        }#class security end

?>