Subversion Repositories php-qbpwcf

Rev

Rev 226 | 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~2024 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/>.

*/
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,陣列,為呼叫方法時所用的參數.
        #可省略參數:
        #無.
        #參考資料:
        #__callStatic=>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){
        
                #初始化要回傳的結果
                $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://www.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

        /*
        #函式說明:
        #加密php檔案的內容將結果輸出.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #$result["content"],加密好的php內容字串.
        #必填參數:
        #$conf["phpFile"],字串,要加密的php檔案位置與名稱.
        $conf["phpFile"]="";
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #無.
        #參考資料:
        #無.
        #備註:
        #僅支援單行只出現<?php、?>、其他內容的PHP檔案格式內容.
        */
        public static function encodePHP(&$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

                #初始加密好的php程式內容
                $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("phpFile","fileArgu");
                #$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("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
                        
                #函式說明:
                #依據行號分隔抓取檔案的內容,結果會回傳一個陣列
                #回傳的變數說明:
                #$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
                #$result["error"],錯誤訊息提示.
                #$result["warning"],警告訊息.
                #$result["function"],當前執行的函數名稱.
                #$result["fileContent"],爲檔案的內容陣列.
                #$result["lineCount"],爲檔案內容總共的行數.
                #$result["fullContent"],為檔案的完整內容.
                #$result["base64data"],為檔案的base64內容.
                #$result["mimeType"],為檔案的mime type.
                #必填參數:
                #$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
                $conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["phpFile"];
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數:
                #$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".
                $conf["fileAccess::getFileContent"]["web"]="false";
                #參考資料:
                #file(),取得檔案內容的行數.
                #file=>http:#php.net/manual/en/function.file.php
                #rtrim(),剔除透過file()取得每行內容結尾的換行符號.
                #filesize=>http://php.net/manual/en/function.filesize.php
                $getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
                unset($conf["fileAccess::getFileContent"]);
        
                #如果讀取檔案內容失敗
                if($getFileContent["status"]==="false"){
                
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]=$getFileContent;

                        #回傳結果
                        return $result;
                
                        }#if end
                
                #加密過後的php內容
                $contentWithoutPhpTagArray=array();
                
                #識別是否開始php語法了.
                $isPHP=false;
                
                #識別是否讀取到php tag開頭
                $phpStart=false;
                
                #識別是否讀取到php tag結尾
                $phpEed=true;
                
                #針對每行內容
                foreach($getFileContent["fileContent"] as $index=>$line){
                
                        #debug
                        #echo "處理第".($index+1)."行".PHP_EOL;
                
                        #函式說明:
                        #將固定格式的字串分開,並回傳分開的結果。
                        #回傳結果:
                        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                        #$result["error"],錯誤訊息陣列
                        #$result["function"],當前執行的函數名稱.
                        #$result["argu"],使用的參數.
                        #$result["oriStr"],要分割的原始字串內容
                        #$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
                        #$result["dataCounts"],爲總共分成幾段
                        #$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
                        #必填的參數:
                        #$conf["stringIn"],字串,要處理的字串.
                        $conf["stringProcess::spiltString"]["stringIn"]=$line;
                        #$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
                        $conf["stringProcess::spiltString"]["spiltSymbol"]="<?php";
                        #可省略參數:
                        #$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
                        $conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
                        $spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
                        unset($conf["stringProcess::spiltString"]);

                        #如果執行失敗
                        if($spiltString["status"]==="false"){
                        
                                #設置執行失敗
                                $result["status"]="false";
                                
                                #設置執行錯誤訊息
                                $result["error"]=$spiltString;

                                #回傳結果
                                return $result;
                        
                                }#if end
                        
                        #初始化該行的資訊描述
                        $lineInfo=array();
                                                        
                        #如果沒有關鍵字
                        if($spiltString["found"]==="false" && $isPHP===false){
                        
                                #初始化暫存的資訊
                                $tempLineInfo=array();
                        
                                #預設該行不是php的內容
                                $tempLineInfo["isPHP"]=false;
                                
                                #放置內容
                                $tempLineInfo["content"]=$line;
                                
                                #儲存一行資訊描述
                                $lineInfo[]=$tempLineInfo;
                        
                                }#if end

                        #反之有關鍵字且 現在是屬於 php 的範圍
                        else if($spiltString["found"]==="false" && $isPHP===true){
                        
                                #確認該段目前沒有 "?".">" 結尾
                        
                                #函式說明:
                                #將固定格式的字串分開,並回傳分開的結果。
                                #回傳結果:
                                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                                #$result["error"],錯誤訊息陣列
                                #$result["function"],當前執行的函數名稱.
                                #$result["argu"],使用的參數.
                                #$result["oriStr"],要分割的原始字串內容
                                #$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
                                #$result["dataCounts"],爲總共分成幾段
                                #$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
                                #必填的參數:
                                #$conf["stringIn"],字串,要處理的字串.
                                $conf["stringProcess::spiltString"]["stringIn"]=$line;
                                #$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
                                $conf["stringProcess::spiltString"]["spiltSymbol"]="?>";
                                #可省略參數:
                                #$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
                                $conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
                                $spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
                                unset($conf["stringProcess::spiltString"]);

                                #如果執行失敗
                                if($spiltString["status"]==="false"){
                                
                                        #設置執行失敗
                                        $result["status"]="false";
                                        
                                        #設置執行錯誤訊息
                                        $result["error"]=$spiltString;

                                        #回傳結果
                                        return $result;
                                
                                        }#if end
                        
                                #反之有關鍵字且 現在是屬於 php 的範圍
                                if($spiltString["found"]==="false" && $isPHP===true){
                                
                                        #初始化暫存的資訊
                                        $tempLineInfo=array();
                                
                                        #預設該行不是php的內容
                                        $tempLineInfo["isPHP"]=true;
                                        
                                        #放置內容
                                        $tempLineInfo["content"]=$line;
                                        
                                        #儲存一行資訊描述
                                        $lineInfo[]=$tempLineInfo;
                                
                                        }#if end
                        
                                #反之有找到關鍵字,且現在屬於 php 的範圍
                                else if($spiltString["found"]==="true" && $isPHP===true){

                                        #如果分割成0段
                                        if($spiltString["dataCounts"]===0){
                                
                                                #識別是否開始php語法了.
                                                $isPHP=false;
                                                
                                                #識別是否讀取到php tag開頭
                                                $phpStart=false;
                                                
                                                #識別是否讀取到php tag結尾
                                                $phpEed=true;
                                
                                                }#if end
                                                
                                        #如果分割成其他段落
                                        else{
                                        
                                                #設置執行錯誤訊息
                                                $result["error"][]="not supported now";
                                        
                                                }#else end
                                
                                        }#if end
                        
                                }#if end

                        #反之有關鍵字
                        else if($spiltString["found"]==="true"){
                        
                                #識別是否開始php語法了.
                                $isPHP=true;
                                
                                #識別是否讀取到php tag開頭
                                $phpStart=true;
                                
                                #識別是否讀取到php tag結尾
                                $phpEed=false;
                        
                                #如果切成兩段
                                if($spiltString["dataCounts"]===2){
                                
                                        #儲存非 php 的字串
                                        $noPHPstr=$spiltString["dataArray"][0];
                                
                                        #初始化暫存的資訊
                                        $tempLineInfo=array();
                                        
                                        #預設該行不是php的內容
                                        $tempLineInfo["isPHP"]=false;
                                
                                        #放置內容
                                        $tempLineInfo["content"]=$noPHPstr;
                                
                                        #儲存屬於 php 的字串
                                        $phpStr=$spiltString["dataArray"][1];
                                                                                
                                        #初始化暫存的資訊
                                        $tempLineInfo=array();
                                        
                                        #預設該行不是php的內容
                                        $tempLineInfo["isPHP"]=true;
                                
                                        #放置內容
                                        $tempLineInfo["content"]=$noPHPstr;
                                
                                        }#if end
                                
                                #反之切成一段
                                else if($spiltString["dataCounts"]===1){
                                
                                        #設置執行失敗
                                        $result["status"]="false";
                                        
                                        #設置執行錯誤訊息
                                        $result["error"][]="not supported now";

                                        #回傳結果
                                        return $result;
                                
                                        }#else end
                                
                                #反之切成0段
                                else if($spiltString["dataCounts"]===0){
                                
                                        #do nothing
                                
                                        }#else end
                                
                                #反之
                                else{
                                        #設置執行失敗
                                        $result["status"]="false";
                                        
                                        #設置執行錯誤訊息
                                        $result["error"][]="not supported now";

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

                        #真對每個字串
                        foreach($lineInfo as $linfo){
                        
                                #記錄起來                   
                                $contentWithoutPhpTagArray[]=$linfo;
                        
                                }#foreach end
                                                
                        }#foreach end
                        
                #debug
                #var_dump($contentWithoutPhpTagArray);
                
                #儲存每行的檔案內容
                $res=array();
                
                #php段落
                $phpSection="";
                
                #針對每行程式
                foreach($contentWithoutPhpTagArray as $lineInfo){
                
                        #如果不是 php
                        if($lineInfo["isPHP"]===false){
                        
                                #如果有php段落
                                if(!empty($phpSection)){
                                
                                        #加密php程式                        
                                        $encodedPHP=base64_encode($phpSection);
                                
                                        #串接內容
                                        $res[]="<?php eval(base64_decode(\"".$encodedPHP."\")); ?>";
                                
                                        }#if end
                                        
                                #清空php段落
                                $phpSection="";
                                        
                                #串接內容
                                $res[]=$lineInfo["content"].PHP_EOL;
                        
                                }#if end
                                
                        #反之是 PHP 內容
                        else{
                                #有內容才處理
                                if(!empty($lineInfo["content"])){
                        
                                        #串接php語法
                                        $phpSection=$phpSection.$lineInfo["content"].PHP_EOL;
                                                
                                        }#if end
                        
                                }#else end
                
                        }#foreach end
                
                #如果有php段落
                if(!empty($phpSection)){
                
                        #加密php程式                        
                        $encodedPHP=base64_encode($phpSection);
                
                        #串接內容
                        $res[]="<?php eval(base64_decode(\"".$encodedPHP."\")); ?>";
                
                        }#if end
                        
                #var_dump($res);exit;
                
                #針對每個要寫入的行內容
                foreach($res as $line){
                
                        $result["content"]=$result["content"].$line;
                
                        }#foreach end
                
                #設置執行正常
                $result["status"]="true";
        
                #回傳結果
                return $result;
        
                }#function encodePHP end

        }#class security end

?>