Subversion Repositories php-qbpwcf

Rev

Blame | Last modification | View Log | RSS feed

<?php

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

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

#提示目前要測試的套件
echo "<hr>xml::getContent - testCase 1<br>";

/*

#涵式說明:
#讀取xml檔案,並取得所有節點的內容、屬性等資料
#回傳的結果:
#$result...
#必填的參數:
$conf["xmlPosition"]="xml/xmlSample.xml";#xml檔案的位置
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
var_dump($xmlContent=xml::getContent($conf));
unset($conf);

*/

#提示目前要測試的套件
echo "<hr>xml::getContent - testCase 2<br>";

/*

#涵式說明:
#讀取xml檔案,並取得所有節點的內容、屬性等資料
#回傳的結果:
#$result...
#必填的參數:
$conf["xmlPosition"]="xml/xmlSample-oneLayer.xml";#xml檔案的位置
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
var_dump($xmlContent=xml::getContent($conf));
unset($conf);

*/

#提示目前要測試的套件
echo "<hr>xml::getContent - testCase 3<br>";

/*

#涵式說明:
#讀取xml檔案,並取得所有節點的內容、屬性等資料
#回傳的結果:
#$result...
#必填的參數:
$conf["xmlPosition"]="xml/xmlSample-twoLayer.xml";#xml檔案的位置
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
var_dump($xmlContent=xml::getContent($conf));
unset($conf);

*/

#提示目前要測試的套件
echo "<hr>xml::getTagInfo - testCase 1<br>";

/*

#涵式說明:
#取得xml特定標籤的內容
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],xml物件的標籤內容.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/xmlSample-oneLayer.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["tag"],字串,目標標籤的名稱.
$conf["tag"]=array("var2");
var_dump($getTagInfo=xml::getTagInfo($conf));
unset($conf);
echo $getTagInfo["content"];
 
*/

#提示目前要測試的套件
echo "<hr>xml::getTagInfo - testCase 2<br>";

/*

#涵式說明:
#取得xml特定標籤的內容
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],xml物件的標籤內容.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/xmlSample-twoLayer.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["tag"],字串,目標標籤的名稱.
$conf["tag"]=array("var1","var1.1");
var_dump($getTagInfo=xml::getTagInfo($conf));
unset($conf);
echo $getTagInfo["content"];
 
*/

#提示目前要測試的套件
echo "<hr>xml::createEmptyXml - testCase 1<br>";

/*

#涵式說明:
#建立空的xml檔案
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],xml檔案的路徑.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/empty.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__; 
var_dump(xml::createEmptyXml($conf));
unset($conf);
        
*/

#提示目前要測試的套件
echo "<hr>xml::addTag - testCase 1<br>";

/*

#移除 xml/empty.xml
#涵式說明:
#移除檔案
#回傳的結果:
#$result["status"],"true"代表移除成功,"false"代表移除失敗.
#$result["error"],錯誤訊息陣列
#$result["warning"],警告訊息陣列
#$result["function"],當前執行的函數名稱
#必填的參數:
#$conf["fileAddress"],字串,要移除檔案的位置.
$conf["fileAddress"]="xml/empty.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
$conf["fileArgu"]=__FILE__;
#可省略參數:
#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
#$conf["commentsArray"]=array("");
$delFile=fileAccess::delFile($conf);
unset($conf);

#如果移除檔案失敗
if($delFile["status"]==="false"){
        
        #印出內容
        var_dump($delFile);
        
        #結束執行
        exit;
        
        }#if end

#涵式說明:
#建立空的xml檔案
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],xml檔案的路徑.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/empty.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__; 
$createEmptyXml=xml::createEmptyXml($conf);
unset($conf);

#如果建立 xml 檔案失敗
if($createEmptyXml["status"]==="false"){
        
        #印出內容
        var_dump($createEmptyXml);
        
        #結束執行
        exit;
        
        }#if end
 
#涵式說明:
#在目標層級新增標籤與內容
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/empty.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
$conf["tag"]=array("home","qbpwcf","Downloads");
#$conf["tagValue"],字串,目標標籤的內容要放什麼.
$conf["tagValue"]="index.html";
#參考資料:
#addchild->http://php.net/manual/en/simplexmlelement.addchild.php
$addTag=xml::addTag($conf);
unset($conf);

#如果新增 tag 失敗
if($addTag["status"]==="false"){
        
        #印出內容
        var_dump($addTag);
        
        #結束執行
        exit;
        
        }#if end

*/

#提示目前要測試的套件
echo "<hr>xml::updateTag - testCase 1<br>";

/*

#涵式說明:
#更新xml標籤的內容.              
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="/usr/local/etc/qbpwcf.conf.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
$conf["tag"]=array("qbpwcf","cmd","svnci","conf","password");
#$conf["tagValue"],字串,目標標籤的內容要放什麼.
$conf["tagValue"]="3c4x5z1i";
#參考資料:
#replacechild=>http://php.net/manual/en/domnode.replacechild.php
var_dump(xml::updateTag($conf));
unset($conf);
 
*/

#提示目前要測試的套件
echo "<hr>xml::removeTag - testCase 1<br>";

/*

#涵式說明:
#移除xml標籤的內容.              
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/empty.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
$conf["tag"]=array("home","qbpwcf","Downloads");        
#參考資料:
#replacechild=>http://php.net/manual/en/domnode.replacechild.php
#loadxml=>http://php.net/manual/en/domdocument.loadxml.php
#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
#備註:
#若有多個同名的tag,則只會對於第一個tag進行操作.
var_dump(xml::removeTag($conf));
unset($conf);
        
*/      

#提示目前要測試的套件
echo "<hr>xml::removeTag - testCase 2<br>";

/*

#涵式說明:
#移除xml標籤的內容.              
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#必填參數:
#$conf["xmlPosition"],字串,xml檔案的位置.
$conf["xmlPosition"]="xml/empty.xml";
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#$conf["tag"],陣列,目標標籤的名稱,每個元素代表層級的名稱.
$conf["tag"]=array("home");     
#參考資料:
#replacechild=>http://php.net/manual/en/domnode.replacechild.php
#loadxml=>http://php.net/manual/en/domdocument.loadxml.php
#update xml node value=>http://stackoverflow.com/questions/4748014/updating-xml-node-with-php
#備註:
#若有多個同名的tag,則只會對於第一個tag進行操作.
var_dump(xml::removeTag($conf));
unset($conf);

*/

/*

#xml::parseXMLstring - testCase 1";

#涵式說明:
#解析xml字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],xml物件.
#必填參數:
#$conf["xmlString"],字串,要解析的xml字串.
$conf["xmlString"]="<root>root</root>";
#可省略參數:
#無.
#備註:
#無.
$parseXMLstring=xml::parseXMLstring($conf);
unset($conf);

var_dump($parseXMLstring);

*/

/*

#xml::parseXMLstring - testCase 2";

$xmlStr="<response><returncode>SUCCESS</returncode><meetingID>fe50c498-43a9-11ec-922c-525411123501</meetingID><internalMeetingID>f983c0cd1fb2651750e82b95054f251c20fa99b4-1636715794790</internalMeetingID><parentMeetingID>bbb-none</parentMeetingID><attendeePW>MRmecHCX</attendeePW><moderatorPW>ltVj2MQE</moderatorPW><createTime>1636715794790</createTime><voiceBridge>77229</voiceBridge><dialNumber>613-555-1234</dialNumber><createDate>Fri Nov 12 06:16:34 EST 2021</createDate><hasUserJoined>false</hasUserJoined><duration>480</duration><hasBeenForciblyEnded>false</hasBeenForciblyEnded><messageKey></messageKey><message></message></response>";

#涵式說明:
#解析xml字串.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],xml物件.
#必填參數:
#$conf["xmlString"],字串,要解析的xml字串.
$conf["xmlString"]=$xmlStr;
#可省略參數:
#無.
#備註:
#無.
$parseXMLstring=xml::parseXMLstring($conf);
unset($conf);

var_dump($parseXMLstring);

*/

?>