Subversion Repositories php-qbpwcf

Rev

Blame | Last modification | View Log | RSS feed

<?php

#指派命名空間爲 qbpwcf
namespace qbpwcf;

#匯入外部套件
include("../allInOne.php");

/*

#提示目前測試的項目
echo"<hr>authenticate::simpleAuthenticate - testCase 1<br>";

#建立驗證碼
$_SESSION["password"]="password";

#涵式說明:
#用來檢查 $_SESSION['password'] 是否存在以及其值是否正確
#回傳結果:
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
#$result["passed"],是否驗證通過,"true"為驗證通過,"false"為驗證不通過.
#$result["function"],當前執行的函數名稱.
#$result["error"],錯誤訊息陣列.
#必填的參數:
$conf["password"]="password";#是驗證碼的內容應該要等於什麼才是對的。
var_dump(authenticate::simpleAuthenticate($conf));
unset($password);

#註銷驗證碼
unset($_SESSION["password"]);

*/

/*

#提示目前測試的項目
echo"<hr>authenticate::sessionAuthenticate - testCase 1<br>";

#建立驗證碼
$_SESSION["password"]="password";

#涵式說明:
#用來檢查 $_SESSION['password'] 是否存在以及其值是否正確
#必填的參數:
$conf["failLocation"]="http://www.nttu.edu.tw";#是當驗證失敗時要轉址到的位置
$conf["password"]="password";#是驗證碼的內容應該要等於什麼才是對的。
var_dump(authenticate::sessionAuthenticate($conf));
unset($conf);

*/

/*

#提示目前測試的項目
echo"<hr>authenticate::sessionAuthenticate - testCase 2<br>";

unset($_SESSION['password']);

#涵式說明:
#用來檢查 $_SESSION['password'] 是否存在以及其值是否正確
#必填的參數:
$conf["failLocation"]="http://www.nttu.edu.tw";#是當驗證失敗時要轉址到的位置
$conf["password"]="password";#是驗證碼的內容應該要等於什麼才是對的。
var_dump(authenticate::sessionAuthenticate($conf));
unset($conf);

*/

/*

#提示目前測試的項目
echo"<hr>authenticate::sessionAuthenticate - testCase 3<br>";
 
$_SESSION['password']="123";

#涵式說明:
#用來檢查 $_SESSION['password'] 是否存在以及其值是否正確
#必填的參數:
$conf["failLocation"]="http://www.nttu.edu.tw";#是當驗證失敗時要轉址到的位置
$conf["password"]="password";#是驗證碼的內容應該要等於什麼才是對的。
var_dump(authenticate::sessionAuthenticate($conf));
unset($conf);

*/

/*

#提示目前測試的項目
echo"<hr>authenticate::checkUserGroupAuthorities - testCase 1<br>";

#宣告使用者名稱
$_SESSION["username"]="root";

#函式說明:
#檢查session裏面的使用者資訊是否在會員清單裏面,
#該會員所屬的羣組是否具有權限瀏覽該子功能頁面
#目標資料庫裏面必須有名爲member作爲儲存會員資料的資料表。
#目標資料庫裏面必須有名爲userGroupAuthorities作爲儲存羣組資料的資料表                           
#回傳的參數:
#無.
#必填寫的參數:
$conf["thisSubSystemName"]="phplib";#爲該子系統的名稱,若該羣組所能瀏覽的子系統裏面有該名稱,則通過驗證。
$conf["dbName"]="test";#爲指定的資料庫名稱,欲選擇的資料庫名稱
$conf["dbPassword"]="dolbyhometheater";#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
#可省略的參數:
#$conf["dbAddress"]="localhost";#爲mysql-Server的位置,預設爲 "localhost"
#$conf["dbAccount"]="root";#爲用於連入mysql-Server時要使用的帳號,預設爲 "root"
#$conf["selectedDataTableName"]["member"]="member";#儲存會員資料的資料表,預設爲 "member"
#$conf["selectedDataTableName"]["userGroup"]="userGroupAuthorties";#儲存羣組資料的資,預設爲 "userGroupAuthorities"
var_dump(authenticate::checkUserGroupAuthorities($conf));
unset($conf);

*/

/*

#提示目前測試的項目
echo"<hr>authenticate::checkUserGroupAuthorities - testCase 2<br>";

#宣告使用者名稱
$_SESSION["username"]="guest";

#函式說明:
#檢查session裏面的使用者資訊是否在會員清單裏面,
#該會員所屬的羣組是否具有權限瀏覽該子功能頁面
#目標資料庫裏面必須有名爲member作爲儲存會員資料的資料表。
#目標資料庫裏面必須有名爲userGroupAuthorities作爲儲存羣組資料的資料表                           
#回傳的參數:
#無.
#必填寫的參數:
$conf["thisSubSystemName"]="phplib";#爲該子系統的名稱,若該羣組所能瀏覽的子系統裏面有該名稱,則通過驗證。
$conf["dbName"]="test";#爲指定的資料庫名稱,欲選擇的資料庫名稱
$conf["dbPassword"]="dolbyhometheater";#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
#可省略的參數:
#$conf["dbAddress"]="localhost";#爲mysql-Server的位置,預設爲 "localhost"
#$conf["dbAccount"]="root";#爲用於連入mysql-Server時要使用的帳號,預設爲 "root"
#$conf["selectedDataTableName"]["member"]="member";#儲存會員資料的資料表,預設爲 "member"
#$conf["selectedDataTableName"]["userGroup"]="userGroupAuthorties";#儲存羣組資料的資,預設爲 "userGroupAuthorities"
var_dump(authenticate::checkUserGroupAuthorities($conf));
unset($conf);

*/

/*

#提示目前測試的項目
echo"<hr>authenticate::checkUserGroupAuthorities - testCase 3<br>";

#宣告使用者名稱
$_SESSION["username"]="unExist";

#函式說明:
#檢查session裏面的使用者資訊是否在會員清單裏面,
#該會員所屬的羣組是否具有權限瀏覽該子功能頁面
#目標資料庫裏面必須有名爲member作爲儲存會員資料的資料表。
#目標資料庫裏面必須有名爲userGroupAuthorities作爲儲存羣組資料的資料表                           
#回傳的參數:
#無.
#必填寫的參數:
$conf["thisSubSystemName"]="phplib";#爲該子系統的名稱,若該羣組所能瀏覽的子系統裏面有該名稱,則通過驗證。
$conf["dbName"]="test";#爲指定的資料庫名稱,欲選擇的資料庫名稱
$conf["dbPassword"]="dolbyhometheater";#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
#可省略的參數:
#$conf["dbAddress"]="localhost";#爲mysql-Server的位置,預設爲 "localhost"
#$conf["dbAccount"]="root";#爲用於連入mysql-Server時要使用的帳號,預設爲 "root"
#$conf["selectedDataTableName"]["member"]="member";#儲存會員資料的資料表,預設爲 "member"
#$conf["selectedDataTableName"]["userGroup"]="userGroupAuthorties";#儲存羣組資料的資,預設爲 "userGroupAuthorities"
var_dump(authenticate::checkUserGroupAuthorities($conf));
unset($conf);

*/

/*

#分隔線
echo"<hr>authenticate::validationCode - testCase 1<br>";

#涵式說明:
#建立以圖片(PNG格式)呈現的驗證碼
#回傳的解果:
#$result["status"],執行是否成功。"true"代表執行成功;"false"代表執行失敗
#$result["error"],錯誤訊息
#$result["randNumberWord"],傳驗證碼的內容
#$result["imgAddress"],圖片的位置與名稱
#必填的參數
$conf["imgAddressAndName"]="img/test";#爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生。
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#可省略的參數:
#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
$conf["num"]="5";
#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
#$conf["disableImg"]="true";
#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
$conf["imgToData"]="false";
var_dump(authenticate::validationCode($conf));
unset($conf);

#涵式說明:
#放置可以套用css樣式的圖片
#回傳的結果:
#$result,印出圖片的語法。               
#必填的參數:
$conf["position"]="img/test.png";#圖片位置
#可省略的參數:
#$conf["alt"]="";#若沒有圖片要用什麼文字顯示。
#$conf["class"]="";#要套用的css樣式類別名稱。
var_dump(img::show($conf));
unset($conf);

*/

/*

#分隔線
echo"<hr>authenticate::validationCode - testCase 2<br>";

#涵式說明:
#建立以圖片(PNG格式)呈現的驗證碼
#回傳的解果:
#$result["status"],執行是否成功。"true"代表執行成功;"false"代表執行失敗
#$result["error"],錯誤訊息
#$result["randNumberWord"],傳驗證碼的內容
#$result["imgAddress"],圖片的位置與名稱
#必填的參數
$conf["imgAddressAndName"]="img/test";#爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生。
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#可省略的參數:
#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
$conf["num"]="5";
#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
$conf["disableImg"]="true";
var_dump(authenticate::validationCode($conf));
unset($conf);   

*/

/*

#分隔線
echo"<hr>authenticate::validationCode - testCase 3<br>";

#涵式說明:
#建立以圖片(PNG格式)呈現的驗證碼
#回傳的解果:
#$result["status"],執行是否成功。"true"代表執行成功;"false"代表執行失敗
#$result["error"],錯誤訊息
#$result["randNumberWord"],傳驗證碼的內容
#$result["imgAddress"],圖片的位置與名稱
#必填的參數
$conf["imgAddressAndName"]="img/test";#爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生。
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#可省略的參數:
#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
$conf["num"]="5";
#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
#$conf["disableImg"]="true";
var_dump(authenticate::validationCode($conf));
unset($conf);   

*/

/*

#分隔線
echo"<hr>authenticate::validationCode - testCase 4<br>";

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

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::enCodeStr - testCase 1<br>";

#涵式說明:
#加密字串,可以用的方法有sha1,md5,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="str";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"兩種,前者較耗時但安全,後者較快但較不安全.
$conf["enCodeType"]="sha1";
#可省略參數:
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
$conf["sha1Raw"]="false";
#參考資料來源:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
var_dump(authenticate::enCodeStr($conf));
unset($conf);

#涵式說明:
#加密字串,可以用的方法有sha1,md5,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="str";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"兩種,前者較耗時但安全,後者較快但較不安全.
$conf["enCodeType"]="sha1";
#可省略參數:
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
$conf["sha1Raw"]="true";
#參考資料來源:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
var_dump(authenticate::enCodeStr($conf));
unset($conf);

#涵式說明:
#加密字串,可以用的方法有sha1,md5,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="str";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"兩種,前者較耗時但安全,後者較快但較不安全.
$conf["enCodeType"]="md5";
#可省略參數:
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
#$conf["sha1Raw"]="false";
#參考資料來源:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
var_dump(authenticate::enCodeStr($conf));
unset($conf);

#涵式說明:
#加密字串,可以用的方法有sha1,md5,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="str";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"兩種,前者較耗時但安全,後者較快但較不安全.
$conf["enCodeType"]="p_hash";
#可省略參數:
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
#$conf["sha1Raw"]="false";
#參考資料來源:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
$p_hashed_str=authenticate::enCodeStr($conf);
unset($conf);   
var_dump($p_hashed_str);

#涵式說明:
#加密字串,可以用的方法有sha1,md5,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="str";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"兩種,前者較耗時但安全,後者較快但較不安全.
$conf["enCodeType"]="p_hash";
#可省略參數:
#$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"]=$p_hashed_str["content"];
#參考資料來源:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
var_dump(authenticate::enCodeStr($conf));
unset($conf);

#涵式說明:
#加密字串,可以用的方法有sha1,md5,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="wrong_str";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"兩種,前者較耗時但安全,後者較快但較不安全.
$conf["enCodeType"]="p_hash";
#可省略參數:
#$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"]=$p_hashed_str["content"];
#參考資料來源:
#sha1=>http://php.net/manual/en/function.sha1.php
#md5=>http://php.net/manual/en/function.md5.php
var_dump(authenticate::enCodeStr($conf));
unset($conf);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::enCodeStr - testCase 2<br>";

#涵式說明:
#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#$result["argu"],使用的參數.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="fh829fh84fh2489fh8299813239";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"3種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密.
$conf["enCodeType"]="p_hash";
#可省略參數:
#$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"]="";
#參考資料來源:
#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
$enCodeStr=authenticate::enCodeStr($conf);
unset($conf);

var_dump($enCodeStr);

#涵式說明:
#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#$result["argu"],使用的參數.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]="fh829fh84fh2489fh8299813239";
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"3種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密.
$conf["enCodeType"]="p_hash";
#可省略參數:
#$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"]=$enCodeStr["content"];
#參考資料來源:
#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
$enCodeStr=authenticate::enCodeStr($conf);
unset($conf);

var_dump($enCodeStr);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::enCodeStr - testCase 3<br>";

$原文="密碼";

#印出原文
echo "原文:".$原文."<br>";

#取得 tls key
#函式說明:
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
#回傳的變數說明:
#$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"]="/etc/pki/tls/private/private.key";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".
$conf["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);
unset($conf);

#如果取得 tls 檔案失敗
if($getFileContent["status"]==="false")
{
        #初始化要印出的結果
        $result=array();

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

        #設置錯誤訊息
        $result["error"]=$getFileContent;

        #印出結果
        var_dump($result);

        #停止執行
        exit;
        
}#if end

#tls key
$tlsKey=$getFileContent["fullContent"];

#涵式說明:
#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#$result["argu"],使用的參數.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]=$原文;
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"與"aes256"4種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密,"aes256"是對稱式加解密.
$conf["enCodeType"]="aes256";
#可省略參數:
#$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"]=$tlsKey;
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
$conf["aes256Encode"]="true";
#參考資料來源:
#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
$enCodeStr=authenticate::enCodeStr($conf);
unset($conf);

#如果加密出錯
if($enCodeStr["status"]==="false")
{
        #初始化要印出的結果
        $result=array();

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

        #設置錯誤訊息
        $result["error"]=$enCodeStr;

        #印出結果
        var_dump($result);

        #停止執行
        exit;
        
}#if end

#取得加密後的內文
$密文=$enCodeStr["content"];

#印出加密後的密文
echo "密文:".$密文."<br>";

#涵式說明:
#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#$result["argu"],使用的參數.
#必填參數:
#$conf["enCodeStr"],"字串",要加密的字串.
$conf["enCodeStr"]=$密文;
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"與"aes256"4種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密,"aes256"是對稱式加解密.
$conf["enCodeType"]="aes256";
#可省略參數:
#$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"]=$tlsKey;
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
$conf["aes256Encode"]="false";
#參考資料來源:
#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
$enCodeStr=authenticate::enCodeStr($conf);
unset($conf);

#如果加密出錯
if($enCodeStr["status"]==="false")
{
        #初始化要印出的結果
        $result=array();

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

        #設置錯誤訊息
        $result["error"]=$$enCodeStr;

        #印出結果
        var_dump($result);

        #停止執行
        exit;
        
}#if end

#取得解密後的內文
$明文=$enCodeStr["content"];

#印出解密後的明文
echo "明文:".$明文."<br>";

#/*

#分隔線與函數名稱
echo"<hr>authenticate::hex2bin - testCase 1<br>";

#涵式說明:
#將字串變成2元碼或2元碼變成字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["input"],"字串",要hex或unhex的字串
$conf["input"]="Hello world";
#$conf["action"],"字串",要toBin或toStr.
$conf["action"]="toBin";        
#參考資料:
#hex2bin=>http://php.net/manual/en/function.hex2bin.php
#bin2hex=>http://php.net/manual/en/function.binhex.php
#pack=>http://php.net/manual/en/function.pack.php
#備註:
#參數的來源不易取得,建議改成輸入字串加密成2元碼,再hex,或逆向還原成原始字串.
$binStr=authenticate::str2bin($conf);
unset($conf);
var_dump($binStr);

#涵式說明:
#將字串變成2元碼或2元碼變成字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["content"],加密後的結果.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["input"],"字串",要hex或unhex的字串
$conf["input"]=$binStr["content"];
#$conf["action"],"字串",要toBin或toStr.
$conf["action"]="toStr";        
#參考資料:
#hex2bin=>http://php.net/manual/en/function.hex2bin.php
#bin2hex=>http://php.net/manual/en/function.binhex.php
#pack=>http://php.net/manual/en/function.pack.php
#備註:
#參數的來源不易取得,建議改成輸入字串加密成2元碼,再hex,或逆向還原成原始字串.
var_dump(authenticate::str2bin($conf));
unset($conf);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::validUser - testCase 1<br>";

#涵式說明:
#驗證Linux使用者的密碼是否正確.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["error"],錯誤訊息陣列.
#$result["valid"],是否為存在的使用者且密碼正確.
#必填參數:
#$conf["username"],字串,要驗證的使用者名稱.
$conf["username"]="notExistUser";
#$conf["password"],字串,用於驗證使用者的密碼.
$conf["password"]="wrongPasswd";
$validUser=authenticate::validUser($conf);
unset($conf);
var_dump($validUser);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::validUser - testCase 2<br>";

#涵式說明:
#驗證Linux使用者的密碼是否正確.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["error"],錯誤訊息陣列.
#$result["valid"],是否為存在的使用者且密碼正確.
#必填參數:
#$conf["username"],字串,要驗證的使用者名稱.
$conf["username"]="liveuser";
#$conf["password"],字串,用於驗證使用者的密碼.
$conf["password"]="wrongPasswd";
$validUser=authenticate::validUser($conf);
unset($conf);
var_dump($validUser);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::validUser - testCase 3<br>";

#請先手動增加使用者test,且密碼為test,測試完畢後記得移除該帳號.

#涵式說明:
#驗證Linux使用者的密碼是否正確.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
#$result["function"],當前執行的函數名稱.
#$result["error"],錯誤訊息陣列.
#$result["valid"],是否為存在的使用者且密碼正確.
#必填參數:
#$conf["username"],字串,要驗證的使用者名稱.
$conf["username"]="test";
#$conf["password"],字串,用於驗證使用者的密碼.
$conf["password"]="test";
$validUser=authenticate::validUser($conf);
unset($conf);
var_dump($validUser);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::validUser - testCase 4<br>";

#請先手動增加使用者test,且密碼為test,測試完畢後記得移除該帳號.

$rewrite="false";
while(true)
{
        #函數說明:
        #如果在設定檔取得不了對應的數值,則改用 readLine 取得設定值.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #$result["content"],設定值內容.
        #必填參數:
        #$conf["readVarName"],字串,要從設定檔取得的變數名稱.
        $conf["readVarName"]="password";
        #可省略參數:
        #$conf["conf"],字串,設定檔的名稱與路徑,預設為 ".qbpwcf_tmp/cmd/getFromConf/conf.xml"
        #$conf["conf"]=".qbpwcf_tmp/cmd/getFromConf/conf";
        #$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
        #$conf["fileArgu"]=__FILE__;
        #$conf["commentsArray"],字串,提示輸入內容的描述,一個元素代表一列內容,預設為 array("請輸入變數 $conf["readVarName"] 的內容").
        $conf["commentsArray"]=array("請輸入test帳戶的密碼");
        #$conf["forceRewrite"],字串,是否要強制覆寫設定值,"true"代表要;"false"代表不要.
        $conf["forceRewrite"]=$rewrite;
        $getFromConf=cmd::getFromConf($conf);
        unset($conf);
                
        #如果抓取設定值失敗
        if($getFromConf["status"]=="false")
        {
                #debug
                var_dump($getFromConf);
                
                #結束程式
                exit;
                
        }#if end        
                
        #涵式說明:
        #驗證Linux使用者的密碼是否正確.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
        #$result["function"],當前執行的函數名稱.
        #$result["error"],錯誤訊息陣列.
        #$result["valid"],是否為存在的使用者且密碼正確.
        #必填參數:
        #$conf["username"],字串,要驗證的使用者名稱.
        $conf["username"]="test";
        #$conf["password"],字串,用於驗證使用者的密碼.
        $conf["password"]=$getFromConf["content"];
        $validUser=authenticate::validUser($conf);
        unset($conf);
        
        #如果驗證使用者失敗
        if($validUser["status"]=="false")
        {
                #debug
                var_dump($validUser);
                
                #結束程式
                exit;
        }
        
        #如果驗證使用者成功
        if($validUser["valid"]=="true")
        {
                #設置通過                   
                $rewrite="false";
                
                #跳出while
                break;                  
        }
        
        #如果驗證用者不成功
        else if($validUser["valid"]=="false")
        {
                #設置要重新輸入密碼
                $rewrite="true";        
        }
}

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::encodePassword - testCase 1<br>";

#函式說明:
#用php的password_hash方法來單向加密密碼.  
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],呼叫完WebService所得回傳結果.
#必填參數:
#無
#可省略參數:
#$conf["password"],字串,要加密的密碼.
#$conf["password"]="qbpwcf";
$conf=array();
$encodePassword=authenticate::encodePassword($conf);
unset($conf);

#如果執行失敗
if($encodePassword["status"]==="false"){
        
        #印出結果
        var_dump($encodePassword);
        
        #結束執行
        exit;
        
        }#if end
        
#印出結果
var_dump($encodePassword);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::validPassword - testCase 1<br>";

#函式說明:
#用php的password_verify方法來驗證密碼是否正確.  
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],呼叫完WebService所得回傳結果.
#必填參數:
#$conf["input"],字串,要檢查是否正確的待驗證密碼.
$conf["input"]="qbpwcf";
#$conf["password"],字串,透過encodePassword加密後的密碼.
$conf["password"]="$2y$10$6bGfUY44f/AMB9Aldf6dp.iEtST8tTc2CitrVEqV4WzUF3Tie/8ua";
#可省略參數:
#無
$validPassword=authenticate::validPassword($conf);
unset($conf);

#如果執行失敗
if($validPassword["status"]==="false"){
        
        #印出結果
        var_dump($validPassword);
        
        #結束執行
        exit;
        
        }#if end
        
#印出結果
var_dump($validPassword["passed"]);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::validPassword - testCase 2<br>";

#函式說明:
#用php的password_verify方法來驗證密碼是否正確.  
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],呼叫完WebService所得回傳結果.
#必填參數:
#$conf["input"],字串,要檢查是否正確的待驗證密碼.
$conf["input"]="abc";
#$conf["password"],字串,透過encodePassword加密後的密碼.
$conf["password"]="$2y$10$6bGfUY44f/AMB9Aldf6dp.iEtST8tTc2CitrVEqV4WzUF3Tie/8ua";
#可省略參數:
#無
$validPassword=authenticate::validPassword($conf);
unset($conf);

#如果執行失敗
if($validPassword["status"]==="false"){
        
        #印出結果
        var_dump($validPassword);
        
        #結束執行
        exit;
        
        }#if end
        
#印出結果
var_dump($validPassword["passed"]);

*/

/*

#分隔線與函數名稱
echo"<hr>authenticate::gl_reCAPTCHA_client & gl_reCAPTCHA_server - testCase 1<br>";

#函式說明:
#產生 google reCAPTCHA 的使用者界面
#回傳結果:
#
#必填參數:
#$conf["sitekey"],字串,要用 recaptcha 的 site key.
$conf["sitekey"]="6LfCWj0UAAAAAF-R04tBKWxFc3obKTuHwZsNadal";
#可省略參數:
#無
#參考資料:
#
$gl_reCAPTCHA_client=authenticate::gl_reCAPTCHA_client($conf);
unset($conf);

#如果建立 google reCAPTCHA 失敗
if($gl_reCAPTCHA_client["status"]==="false"){
        
        #印出結果
        var_dump($gl_reCAPTCHA_client);
        
        }#if end

#印出語法
var_dump($gl_reCAPTCHA_client);

*/

/*

echo"<hr>authenticate::gl_reCAPTCH_authCheck - testCase 1<br>";

#涵式說明:
#檢查是否擁有透過gl_reCAPTCHA_server授權的session網址記錄.
#回傳結果:
#$result["status"],執行正常與否,"false"代表不正常;"true"代表正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],函式名稱.
#$result["passed"],"true"代表通過檢查,"false"代表沒有通過檢查.
#必填參數:
#$conf["url"],字串,要有什麼的網址才通過檢查
$conf["url"]="https://169.254.1.1/~qbpwcf/samplePage/phplib/qbpwcf/testCase/authenticateT.php"; 
$gl_reCAPTCH_authCheck=authenticate::gl_reCAPTCH_authCheck($conf);
unset($conf);

#如果建立 google reCAPTCHA 失敗
if($gl_reCAPTCH_authCheck["status"]==="false"){
        
        #印出結果
        var_dump($gl_reCAPTCH_authCheck);
        
        }#if end

#印出語法
var_dump($gl_reCAPTCH_authCheck);

*/

/*

#echo"<hr>authenticate::verifyCodeAndFormData - testCase 1<br>";

#涵式說明:
#產生亂數驗證碼或驗證亂數驗證碼與表單資料
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息.
#$result["argu"],使用的參數.
#$result["function"],當前執行的函數名稱.
#$result["content"],語法.
#必填參數:
#$conf["fileArgu"]
$conf["fileArgu"]=__FILE__;
#可省略參數:       
#$conf["sendedName"],字串,傳送的post變數名稱,預設爲"formData".
#$conf["sendedName"]="";        
#$conf["codeFormName"],字串,驗證碼表單的名稱,預設為"randomCode".
#$conf["codeFormName"]="randomCode";
#$conf["names"],字串陣列,需要處理的表單變數.
#$conf["names"]=array();
#備註:
#建構中...
$verifyCodeAndFormData=authenticate::verifyCodeAndFormData($conf);
unset($conf);

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

        #印出結果
        var_dump($verifyCodeAndFormData);

        #結束執行   
        exit;

        }#if end

#印出jsono
echo $verifyCodeAndFormData["content"];

*/

?>