Ejemplo n.º 1
0
 public function testWrap()
 {/*{{{*/
     $dir = dirname(__FILE__);
     $wrapper = new Wrapper;
     $xsltFile = $dir.'/demo.xslt';
     $xmlFile = $dir.'/demo.xml';
     $result = $wrapper->wrap($xsltFile, $xmlFile);
     $expectedRes = '<?xml version="1.0" encoding="gbk"?>
                         <document>
                         <item>
                         <hospitalfacultyname>testÒ½Ôºtest¿Æ</hospitalfacultyname>
                         <url>www.haodf.com</url>
                         </item>
                         </document>';
     $resArray = XString::xmlToArray($result);
     $expectedResArray = XString::xmlToArray($expectedRes);
     $this->assertEquals($expectedResArray, $resArray);
 }/*}}}*/
Ejemplo n.º 2
0
    public function testFile()
    {/*{{{*/
        $maxFileSize = 10*1024*1024;
        $maxItemCount = 10000;
        $configs =  BeanFinder::get('configs');
        $dataPath = $configs->dataPath."complete/";
        
        //文件夹存在
        $this->assertTrue(is_dir($dataPath));

        //取所有文件夹下的文件
        $dirList = XString::listDir($dataPath);

        if ($dirList)
        {
            foreach ($dirList as $dir)
            {
                $fileList = XString::listFile($dataPath.$dir);
                foreach ($fileList as $file)
                {
                    //单个文件不超过10M
                    $this->assertFalse((filesize($file) > $maxFileSize), $file."过大\n");
                }
            }

            foreach ($dirList as $dir)
            {
                $fileList = XString::listFile($dataPath.$dir);
                foreach ($fileList as $file)
                {
                    $xmlData = $xmlHospitalList = $xmlHospital = array();
                    $xmlData = file_get_contents($file);
                    $xmlHospitalList = XString::xmlToArray($xmlData);
                    if (isset($xmlHospitalList['item']) && $xmlHospitalList['item'])
                    {
                        //每个文件数量不超过10000
                        $xmlHospital = array_pop($xmlHospitalList['item']);
                        $this->assertFalse(count($xmlHospital) > $maxItemCount);
                    }
                }
            }
        }
    }/*}}}*/
    public function __construct($request, $response) 
    {/*{{{*/
        $ioFaculty = new IOFaculty();
        $this->IOConverter = $ioFaculty->run(IOFaculty::TYPE_XML); 
        $response->confLogPath = PhoneConferenceClient::getInstance()->getConfLogPath();

        $items = '';
        if ($request instanceof Request && CallCenterApiFaculty::SPTYPE_CLOUD != $request->callbacktype)
        {
            $arr = $request->getAllRequest();
            $items = $this->getLogStr($arr);
        }
        else
        {
            $items =  file_get_contents("php://input");
            $items = preg_replace("/<S.* \/>/","",$items);
            $items = $this->getLogStr(XString::xmlToArray($items));
        }
        $this->logTxt .= XDateTime::now()->toString().$items."\n";
        $this->setCallBack($request->callbacktype, $response);
    }/*}}}*/
Ejemplo n.º 4
0
 private function xmlData($filePath="", $type = 'baidu')
 {/*{{{*/
     $xml = array();
     if ($filePath)
     {
         $xmlData = file_get_contents($filePath);
         $xmlDataList = XString::xmlToArray($xmlData);
         if ($xmlDataList)
         {
             if ($type == 'baidu')
             {
                 $xml = array_pop($xmlDataList['item']);
             }
             elseif ($type == 'soso')
             {
                 $xml = array_pop($xmlDataList['datalist']['item']);
             }
         }
     }
     $this->assertFalse(empty($xml), "没有内容\n");
     return XString::convertEncoding($xml, 'GBK', 'auto');
 }/*}}}*/
Ejemplo n.º 5
0
 public function initCallBackData(array $data, $name)
 {
     /*{{{*/
     $sign = $data["sign"];
     $content = "notify_data=" . $data["notify_data"];
     $res = $this->verify($content, $sign);
     if (false == $res) {
         return $res;
     } else {
         $out_trade_no = $this->getDataForXML($data["notify_data"], '/notify/out_trade_no');
         list($sn, $type) = Pay::explodeSN($out_trade_no);
         Pay::checkNameInValidNames($name);
         $this->sn = $sn;
         $this->name = $name;
         $this->type = Pay::$typeDescs[$type];
         $arrcontent = XString::xmlToArray($data["notify_data"]);
         $arrcontent['name'] = $name;
         $arrcontent = XString::convertEncoding($arrcontent, 'gbk', 'utf8');
         $this->content = $arrcontent;
         $this->total_fee = $this->getDataForXML($data["notify_data"], '/notify/total_fee');
         $this->total_fee = (array) $this->total_fee;
         $this->total_fee = $this->total_fee[0];
         $this->trade_status = $this->getDataForXML($data["notify_data"], '/notify/trade_status');
         $this->trade_status = (array) $this->trade_status;
         $this->trade_status = $this->trade_status[0];
         $this->data = $arrcontent;
         return $this;
     }
 }
Ejemplo n.º 6
0
 public function initCallBackData(array $data, $name)
 {
     /*{{{*/
     $waperAlipayFunction = wap_alipay_function::getInstance();
     $out_trade_no = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/out_trade_no');
     list($sn, $type) = Pay::explodeSN($out_trade_no);
     Pay::checkNameInValidNames($name);
     $this->sn = $sn;
     $this->name = $name;
     $this->type = Pay::$typeDescs[$type];
     $arrcontent = XString::xmlToArray($data["notify_data"]);
     $arrcontent['name'] = $name;
     $arrcontent = XString::convertEncoding($arrcontent, 'gbk', 'utf8');
     $this->content = $arrcontent;
     $this->total_fee = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/total_fee');
     $this->total_fee = (array) $this->total_fee;
     $this->total_fee = $this->total_fee[0];
     $this->trade_status = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/trade_status');
     $this->trade_status = (array) $this->trade_status;
     $this->trade_status = $this->trade_status[0];
     $this->data = $arrcontent;
     return $this;
 }