Subversion Repositories php-qbpwcf

Rev

Rev 324 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2026 MIN ZHI, 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/>.

*/

/*

本程式說明:

接收email認證的link,驗證session,放行表單(可送出了).

*/

#使用命名空間qbpwcf
namespace qbpwcf;

#初始化輸出
$output=array();

#取得 lib path
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);

#如果執行失敗
if($status!==0){

        #debug
        var_dump(__LINE__,$output);

        #結束執行,回傳shell 1.
        exit(1);

        }#if end

#儲存lib path
$folderOfUsrLib=$output[0];

#初始化輸出
$output=array();

#以該檔案的實際位置的 lib path 為 include path 首位
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
set_include_path($output[0].PATH_SEPARATOR.get_include_path());

#匯入套件
require_once("allInOne.php");

#建議的log位置
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";

#從 GET 取得加密後的 session 數值
#函式說明:
#抓取命令列的參數.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["argu"],使用的參數陣列.
#$result["content"],要回傳的參數陣列.
#$result["count"],參數的數量.
#$result["_GET"],收到的 HTTP GET 參數陣列.
#$result["_POST"],收到的 HTTP POST 參數陣列.
#必填參數:
#無
#可省略參數:
#$conf["echo"],字串,"true"代表要將抓到的參數一個個印出來,"false"代表用回傳的方式,預設為"false".
#$conf["echo"]="false";
#$conf["httpGetToArgu"],字串,"true"代表要將 http get 參數變成參數來取得,像是 $_GET["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
$conf["httpGetToArgu"]="true";
#$conf["httpPostToArgu"],字串,"true"代表要將 http post 參數變成參數來取得,像是 $_POST["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
#$conf["httpPostToArgu"]="false";
#$conf["arguEqual2http"],字串,預設為"false",代表命令列環境的參數依序為程式名稱本身、第n個參數,反之為"true",代表命令列的第一個參數為第n個參數,亦即沒有程式本身名稱的參數.
$conf["arguEqual2http"]="true";
#參考資料:
#無.
#備註:
#pipe要用''包住,才會被解析,例如'|'、'>'、'>>'.
$getArgu=cmd::getArgu($conf);
unset($conf);

#debug
#var_dump(__LINE__,$getArgu);exit;

#如果執行失敗
if($getArgu["status"]==="false"){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$getArgu;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#如果沒有一個 GET 參數
if(count($getArgu["_GET"])!==1){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$getArgu;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#函式說明:
#將陣列的key資訊取出,以方便使用.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["argu"],使用的參數.
#$result["content"],結果陣列.
#$result["content"]["key"],陣列key數值的陣列.
#$result["content"]["val"],陣列value的陣列.
#必填參數:
#$conf["array"],陣列,要讀取的一維陣列.
$conf["array"]=$getArgu["_GET"];
#可省略參數:
#無.
#參考資料:
#無.
#備註:
#無.
$inspectKey=arrays::inspectKey($conf);
unset($conf);

#如果執行出錯
if($inspectKey["status"]==="false"){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$inspectKey;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#取得未解密的字串
$encodedSessionStr=$inspectKey["content"]["val"][0];

#debug
#var_dump(__LINE__,$encodedSessionStr,base64_decode($encodedSessionStr));exit;

#解密 json 數值 - start

#用gpg解密
#函式說明:
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#$result["argu"],使用的參數.
#必填參數:
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
$conf["enCodeStr"]=base64_decode($encodedSessionStr);
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密,"aes256"是對稱式加解密,"qbpwcf"是透過urlencode、json_encode、base64_encode的結果,"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin","gpg"是應用gpg進行加解密,需要先有ID對應的key.
$conf["enCodeType"]="gpg";
#可省略參數:
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
#$conf["sha1Raw"]="false";
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
#$conf["p_hash"]="";
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
#$conf["keyForAes256"]="";
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
#$conf["aes256Encode"]="";
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
#$conf["qbpwcfDecode"]="false";
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
$conf["gpgDecrypt"]="true";
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,該參數必填.
$conf["gpgId"]=gnupgId;
#參考資料:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
#password_hash=>http://php.net/manual/en/function.password-hash.php
#password_verify=>http://php.net/manual/en/function.password-verify.php
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
#備註:
#無.
$enCodeStr=authenticate::enCodeStr($conf);
unset($conf);

#debug
#var_dump(__LINE__,$enCodeStr);exit;

#如果執行出錯
if($enCodeStr["status"]==="false"){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$enCodeStr;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#儲存解密後的 json 
$json=$enCodeStr["content"];

#debug
#var_dump(__LINE__,$json);exit;

#解密 json 數值 - end

#取得用於識別資源的id
$wsClientId=base64_decode($json->id);

#取得 session 名稱 
$sessionNameOnly=base64_decode($json->sId);

#取得 session 檔案名稱
$sessionName="../.hta-session/sess_".$sessionNameOnly;

#取得認證過的信箱
$validatedEmail=base64_decode($json->email);

#debug
#var_dump(__LINE__,$sessionName,$validatedEmail);exit;

#檢查 session 的內容是否正確

#函式說明:
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
#回傳的變數說明:
#$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["filePositionAndName"]=$sessionName;
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#可省略參數:
#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
#$conf["web"]="true";
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
#$conf["createIfnotExist"]="false";
#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
#$conf["autoDeleteSpaceOnEachLineStart"]="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);
unset($conf);

#如果無內容
if(!isset($getFileContent["fileContent"][0])){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$getFileContent;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#debug
#var_dump(__LINE__,$getFileContent["fileContent"][0]);exit;

#解開 session 並使用之
$session_decode=session_decode($getFileContent["fileContent"][0]);

#如果沒有應該要有的內容
if(!isset($_SESSION["sendMailAgent"])){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$_SESSION;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#debug
#var_dump($_SESSION);exit;

#如果沒有應該要有的內容
if(!isset($_SESSION["sendMailAgent"]["status"])){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$_SESSION;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);

        #如果寫log失敗
        if($record["status"]==="false"){

                #印出json結果
                echo json_encode($record);

                }#if end

        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end

#如果尚未記錄成通過email認證
if($_SESSION["sendMailAgent"]["status"]==="wait"){

        #如果超過 5 分鐘了
        if(time()-$_SESSION["start"]>300){

                #移除session
                session_destroy();

                #因為儲存seesion檔案的路徑未修改,因此得手動移除session檔案
                unlink($sessionName);

                }#if end

        #更新 session 檔案的內容為已經通過 email 認證
        $_SESSION["sendMailAgent"]["status"]="pass";

        #記錄通過 email 認證的時間點
        $_SESSION["sendMailAgent"]["passTime"]=time();

        #debug
        #var_dump(__LINE__,"seesion 已經更新");

        #debug
        #var_dump(__LINE__,"web socket 可以告訴 client 可以填寫表單內容了");

        #產生亂數
        #函式說明:
        #建立以圖片(PNG格式)呈現的驗證碼.
        #回傳的解果:
        #$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
        #$result["error"],錯誤訊息.
        #$result["function"],檔前執行的函數名稱.
        #$result["randNumberWord"],傳驗證碼的內容.
        #$result["imgAddress"],包含src圖片的位置與名稱.
        #$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
        #必填參數:
        #$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
        $conf["imgAddressAndName"]="/tmp/notExsit.img";
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
        #$conf["num"]="8";
        #$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
        $conf["disableImg"]="true";
        #$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
        #$conf["imgToData"]="true";
        #$conf["class"],字串,圖片要套用的css樣式類別.
        #$conf["class"]="";
        #$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
        #$conf["content"]=array();
        #參考資料:
        #無.
        #備註:
        #無.
        $validationCode=authenticate::validationCode($conf);
        unset($conf);

        #如果執行失敗
        if($validationCode["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$validationCode;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end

        #隨機產生get變數名稱
        $getVarName=$validationCode["randNumberWord"];

        #儲存含有亂數get名稱的session名稱
        $sess_str=$getVarName."=".$sessionNameOnly;

        #加密 $sess_str
        #函式說明:
        #加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["function"],當前執行的函數名稱.
        #$result["content"],加密後的結果.
        #$result["error"],錯誤訊息陣列.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["enCodeStr"],any,要加密的字串,陣列,物件.
        $conf["enCodeStr"]=$sess_str;
        #$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
        $conf["enCodeType"]="gpg";
        #可省略參數:
        #$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
        #$conf["sha1Raw"]="false";
        #$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
        #$conf["p_hash"]="";
        #$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
        #$conf["keyForAes256"]="";
        #$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
        #$conf["aes256Encode"]="";
        #$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["qbpwcfDecode"]="false";
        #$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["gpgDecrypt"]="true";
        #$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
        #$conf["gpgId"]="";
        #參考資料:
        #sha1=>http://php.net/manual/en/function.sha1.php
        #md5=>http://php.net/manual/en/function.md5.php
        #password_hash=>http://php.net/manual/en/function.password-hash.php
        #password_verify=>http://php.net/manual/en/function.password-verify.php
        #json_decode=>https://www.php.net/manual/en/function.json-decode.php
        #備註:
        #無.
        $enCodeStr=authenticate::enCodeStr($conf);
        unset($conf);

        #如果執行失敗
        if($enCodeStr["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$enCodeStr;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end
                
        #取得訊息接收者的id
        $wsRevId=$enCodeStr["content"];
        
        #產生亂數
        #函式說明:
        #建立以圖片(PNG格式)呈現的驗證碼.
        #回傳的解果:
        #$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
        #$result["error"],錯誤訊息.
        #$result["function"],檔前執行的函數名稱.
        #$result["randNumberWord"],傳驗證碼的內容.
        #$result["imgAddress"],包含src圖片的位置與名稱.
        #$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
        #必填參數:
        #$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
        $conf["imgAddressAndName"]="/tmp/notExsit.img";
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
        #$conf["num"]="8";
        #$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
        $conf["disableImg"]="true";
        #$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
        #$conf["imgToData"]="true";
        #$conf["class"],字串,圖片要套用的css樣式類別.
        #$conf["class"]="";
        #$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
        #$conf["content"]=array();
        #參考資料:
        #無.
        #備註:
        #無.
        $validationCode=authenticate::validationCode($conf);
        unset($conf);

        #如果執行失敗
        if($validationCode["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$validationCode;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end

        #隨機產生get變數名稱
        $getVarName=$validationCode["randNumberWord"];

        #儲存含有亂數get名稱的validatedEmail名稱
        $validatedEmail=$getVarName."=".$validatedEmail;
        
        #函式說明:
        #加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["function"],當前執行的函數名稱.
        #$result["content"],加密後的結果.
        #$result["error"],錯誤訊息陣列.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["enCodeStr"],any,要加密的字串,陣列,物件.
        $conf["enCodeStr"]=$validatedEmail;
        #$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
        $conf["enCodeType"]="gpg";
        #可省略參數:
        #$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
        #$conf["sha1Raw"]="false";
        #$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
        #$conf["p_hash"]="";
        #$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
        #$conf["keyForAes256"]="";
        #$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
        #$conf["aes256Encode"]="";
        #$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["qbpwcfDecode"]="false";
        #$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["gpgDecrypt"]="true";
        #$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
        #$conf["gpgId"]="";
        #參考資料:
        #sha1=>http://php.net/manual/en/function.sha1.php
        #md5=>http://php.net/manual/en/function.md5.php
        #password_hash=>http://php.net/manual/en/function.password-hash.php
        #password_verify=>http://php.net/manual/en/function.password-verify.php
        #json_decode=>https://www.php.net/manual/en/function.json-decode.php
        #備註:
        #無.
        $enCodeStr=authenticate::enCodeStr($conf);
        unset($conf);

        #如果執行失敗
        if($enCodeStr["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$enCodeStr;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end
                
        #取得加密後的含email字串
        $validatedEmail=$enCodeStr["content"];
        
        #產生亂數
        #函式說明:
        #建立以圖片(PNG格式)呈現的驗證碼.
        #回傳的解果:
        #$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
        #$result["error"],錯誤訊息.
        #$result["function"],檔前執行的函數名稱.
        #$result["randNumberWord"],傳驗證碼的內容.
        #$result["imgAddress"],包含src圖片的位置與名稱.
        #$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
        #必填參數:
        #$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
        $conf["imgAddressAndName"]="/tmp/notExsit.img";
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
        #$conf["num"]="8";
        #$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
        $conf["disableImg"]="true";
        #$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
        #$conf["imgToData"]="true";
        #$conf["class"],字串,圖片要套用的css樣式類別.
        #$conf["class"]="";
        #$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
        #$conf["content"]=array();
        #參考資料:
        #無.
        #備註:
        #無.
        $validationCode=authenticate::validationCode($conf);
        unset($conf);

        #如果執行失敗
        if($validationCode["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$validationCode;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end

        #隨機產生get變數名稱
        $getVarName=$validationCode["randNumberWord"];

        #儲存含有亂數get名稱的msg內容
        $msg=$getVarName."=authenticated";
        
        #加密要傳遞的訊息內容
        #函式說明:
        #加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["function"],當前執行的函數名稱.
        #$result["content"],加密後的結果.
        #$result["error"],錯誤訊息陣列.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["enCodeStr"],any,要加密的字串,陣列,物件.
        $conf["enCodeStr"]=$msg;
        #$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
        $conf["enCodeType"]="gpg";
        #可省略參數:
        #$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
        #$conf["sha1Raw"]="false";
        #$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
        #$conf["p_hash"]="";
        #$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
        #$conf["keyForAes256"]="";
        #$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
        #$conf["aes256Encode"]="";
        #$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["qbpwcfDecode"]="false";
        #$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["gpgDecrypt"]="true";
        #$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
        #$conf["gpgId"]="";
        #參考資料:
        #sha1=>http://php.net/manual/en/function.sha1.php
        #md5=>http://php.net/manual/en/function.md5.php
        #password_hash=>http://php.net/manual/en/function.password-hash.php
        #password_verify=>http://php.net/manual/en/function.password-verify.php
        #json_decode=>https://www.php.net/manual/en/function.json-decode.php
        #備註:
        #無.
        $enCodeStr=authenticate::enCodeStr($conf);
        unset($conf);

        #如果執行失敗
        if($enCodeStr["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$enCodeStr;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end
                
        #取得加密後的msg
        $msg=$enCodeStr["content"];

        #產生亂數
        #函式說明:
        #建立以圖片(PNG格式)呈現的驗證碼.
        #回傳的解果:
        #$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
        #$result["error"],錯誤訊息.
        #$result["function"],檔前執行的函數名稱.
        #$result["randNumberWord"],傳驗證碼的內容.
        #$result["imgAddress"],包含src圖片的位置與名稱.
        #$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
        #必填參數:
        #$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
        $conf["imgAddressAndName"]="/tmp/notExsit.img";
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
        #$conf["num"]="8";
        #$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
        $conf["disableImg"]="true";
        #$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
        #$conf["imgToData"]="true";
        #$conf["class"],字串,圖片要套用的css樣式類別.
        #$conf["class"]="";
        #$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
        #$conf["content"]=array();
        #參考資料:
        #無.
        #備註:
        #無.
        $validationCode=authenticate::validationCode($conf);
        unset($conf);

        #如果執行失敗
        if($validationCode["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$validationCode;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end

        #隨機產生get變數名稱
        $getVarName=$validationCode["randNumberWord"];

        #儲存含有亂數get名稱的from數值
        $from=$getVarName."=server";
        
        #加密要傳遞的訊息內容
        #函式說明:
        #加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["function"],當前執行的函數名稱.
        #$result["content"],加密後的結果.
        #$result["error"],錯誤訊息陣列.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["enCodeStr"],any,要加密的字串,陣列,物件.
        $conf["enCodeStr"]=$from;
        #$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
        $conf["enCodeType"]="gpg";
        #可省略參數:
        #$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
        #$conf["sha1Raw"]="false";
        #$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
        #$conf["p_hash"]="";
        #$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
        #$conf["keyForAes256"]="";
        #$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
        #$conf["aes256Encode"]="";
        #$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["qbpwcfDecode"]="false";
        #$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
        #$conf["gpgDecrypt"]="true";
        #$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
        #$conf["gpgId"]="";
        #參考資料:
        #sha1=>http://php.net/manual/en/function.sha1.php
        #md5=>http://php.net/manual/en/function.md5.php
        #password_hash=>http://php.net/manual/en/function.password-hash.php
        #password_verify=>http://php.net/manual/en/function.password-verify.php
        #json_decode=>https://www.php.net/manual/en/function.json-decode.php
        #備註:
        #無.
        $enCodeStr=authenticate::enCodeStr($conf);
        unset($conf);

        #如果執行失敗
        if($enCodeStr["status"]==="false"){

                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$enCodeStr;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);

                }#if end
                
        #取得加密後的from
        $from=$enCodeStr["content"];

        #初始化要傳遞的json字串
        $json=array();
        
        #設置傳送訊息的來源
        $json["from"]=base64_encode($from);
        
        #設置接收訊息的id(加密過)
        $json["to"]=base64_encode($wsRevId);
        
        #設置要傳遞加密後訊息的內容
        $json["content"]=base64_encode($msg);

        #設置通過認證加密後的email
        $json["email"]=base64_encode($validatedEmail);
        
        #設置識別資訊的id
        $json["id"]=$wsClientId;
        
        #debug
        #var_dump(__LINE__,$json,json_encode($json));

        #web socket 告訴 client 可以填寫表單內容了.
        #函式說明:
        #webSocket的javaScript用戶端
        #回傳結果:
        #$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息陣列.
        #$resutl["function"],當前執行的涵式名稱.
        #$result["argu"],所使用的參數.
        #$result["content"],語法.
        #必填參數:
        #$conf["url"],字串要拜訪的web socket,請省略"ws://".
        $conf["url"]=system_sendMailAgent_ws_domain.system_sendMailAgent_path;
        #可省略參數:
        #$conf["entry"],字串,是否要用加密的wss,預設為"false",代表用ws,若為"true"則為wss.
        $conf["entry"]="true";
        #$conf["connVar"],字串,用來儲存webSocket連線的物件名稱,預設為"conn".
        #$conf["connVar"]="conn";
        #$conf["sendThenClose"],字串,是否要傳遞訊息後關閉連線,預設為"false",代表不要要;反之為"true".
        $conf["sendThenClose"]="true";
        #$conf["oneTimeMsg"],字串,要傳遞的一次訊息內容,預設不指定.
        $conf["oneTimeMsg"]=json_encode($json);
        #參考資料:
        #無.
        #備註:
        #無.
        $client=webSock::client($conf);
        unset($conf);
        
        #如果執行異常
        if($client["status"]==="false"){
        
                #函式說明:
                #撰寫log
                #回傳結果:
                #$result["status"],狀態,"true"或"false".
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前函式的名稱.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["path"],字串,log檔案的路徑與名稱.
                $conf["path"]=$logFile;
                #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
                $conf["content"]=$client;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileArgu"]=__FILE__;
                #可省略參數:
                #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
                #$conf["rewrite"]="false";
                #參考資料:
                #無.
                #備註:
                #無.
                $record=logs::record($conf);
                unset($conf);

                #如果寫log失敗
                if($record["status"]==="false"){

                        #印出json結果
                        echo json_encode($record);

                        }#if end

                #結束執行,回傳錯誤代碼1
                exit(1);
        
                }#if end
                
        #印出語法
        echo $client["content"];
        
        #移除session
        session_destroy();

        #因為儲存seesion檔案的路徑未修改,因此得手動移除session檔案
        unlink($sessionName);
        
        #結束執行
        exit;
        
        }#if end

#debug
#var_dump(__LINE__,$_SESSION);

#例外狀況
exit(1);