微信验证，包括post来的xml解密
@param bool $return 是否返回
499171
public function valid($return=false)
    {
        $encryptStr="";
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            $postStr = file_get_contents("php://input");
            $array = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
            $this->log($postStr);
            if (isset($array['Encrypt'])) {
                $encryptStr = $array['Encrypt'];
                $this->agentidxml = isset($array['AgentID']) ? $array['AgentID']: '';
            }
        } else {
            $encryptStr = isset($_GET["echostr"]) ? $_GET["echostr"]: '';

        }
        if ($encryptStr) {
            $ret=$this->checkSignature($encryptStr);
        }
        if (!isset($ret) || !$ret) {
        	if (!$return) {
        	    die('no access');
        	} else {
        	    return false;
        	}
        }
        $pc = new Prpcrypt($this->encodingAesKey);
        $array = $pc->decrypt($encryptStr,$this->appid);
        if (!isset($array[0]) || ($array[0] != 0)) {
            if (!$return) {
        	    die('解密失败！');
        	} else {
        	    return false;
        	}
        }
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            $this->postxml = $array[1];
            //$this->log($array[1]);
            return ($this->postxml!="");
        } else {
            $echoStr = $array[1];
            if ($return) {
            	return $echoStr;
            } else {
                die($echoStr);
            }
        }
        return false;
    }
678495
public function response($data, $format, $is_success=true, $status_code = 200)
    {
        $this->httpCode($status_code);
        if ($is_success) {
            $data['status'] = 1;
        } else {
            $data['status'] = 0;
        }
        switch ($format) {
            case self::RESPONSE_TYPE_JSON:
                $response_content = JsonHelper::encode($data);
                break;
            case self::RESPONSE_TYPE_XML:
                header('Content-type:application/xml');
                $response_content = XMLHelper::encode($data);
                break;
            default:
                $response_content = '';
        }
        if (!$is_success) {
            Lb::app()->stop($response_content);
        } else {
            echo $response_content;
        }
    }
1344975
public static function getWebhookPayload($returnObject = false) {
        $data = file_get_contents("php://input");
        if ($data) {
            return self::jsonDecode($data, !$returnObject);
        } else {
            return null;
        }
    }
389915
protected function send_response() {

        //Check that the returned values are valid
        try {
            if ($this->function->returns_desc != null) {
                $validatedvalues = external_api::clean_returnvalue($this->function->returns_desc, $this->returns);
            } else {
                $validatedvalues = null;
            }
        } catch (Exception $ex) {
            $exception = $ex;
        }

        if (!empty($exception)) {
            $response =  $this->generate_error($exception);
        } else {
            //We can now convert the response to the requested REST format
            if ($this->restformat == 'json') {
                $response = json_encode($validatedvalues);
            } else {
                $response = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
                $response .= '<RESPONSE>'."\n";
                $response .= self::xmlize_result($validatedvalues, $this->function->returns_desc);
                $response .= '</RESPONSE>'."\n";
            }
        }

        $this->send_headers();
        echo $response;
    }
208934
public function XmlResponse ($output = '', $terminate = TRUE) {
		if (!$this->response->HasHeader('Content-Type'))
			$this->response->SetHeader('Content-Type', 'application/xml');
		$this->response
			->SetCode(\MvcCore\IResponse::OK)
			->SetBody($output);
		if ($terminate) $this->Terminate();
	}
1013252
public static function display_debugging_messages($return = false) {
        if (empty(self::$debuggings)) {
            return false;
        }

        $debugstring = '';
        foreach(self::$debuggings as $debug) {
            $debugstring .= 'Debugging: ' . $debug->message . "\n" . trim($debug->from) . "\n";
        }

        if ($return) {
            return $debugstring;
        }
        echo $debugstring;
        return true;
    }
171565
public function error($return = false)
    {
        if (!empty($this->error)) {
            if ($return) {
                return $this->error;
            }
            var_dump($this->error);
            return null;
        }
        return false;
    }
81654
function processRequest()
    {
        if ( $_SERVER["REQUEST_METHOD"] != "POST" )
        {
            print( "Error: this web page does only understand POST methods" );
            exit();
        }

        $xmlData = $this->stripHTTPHeader( $this->RawPostData );

        $dom = new DOMDocument( '1.0', 'utf-8' );
        $dom->preserveWhiteSpace = false;
        $success = $dom->loadXML( $xmlData );

        // Check for non-parsing XML, to avoid call to non-object error.
        if ( !$success )
        {
            $this->showResponse( 'unknown_function_name', 'unknown_namespace_uri',
                                 new eZSOAPFault( 'Server Error',
                                                  'Bad XML' ) );
            return;
        }

        // add namespace fetching on body
        // get the SOAP body
        $body = $dom->getElementsByTagName( "Body" );

        $children = $body->item( 0 )->childNodes;

        if ( $children->length == 1 )
        {
            $requestNode = $children->item( 0 );
            // get target namespace for request
            $functionName = $requestNode->localName;
            $namespaceURI = $requestNode->namespaceURI;

            $params = array();
            // check parameters
            foreach ( $requestNode->childNodes as $parameterNode )
            {
                $params[] = eZSOAPResponse::decodeDataTypes( $parameterNode );
            }

            list( $objectName, $objectFunctionName ) = preg_split('/::/', $functionName, 2, PREG_SPLIT_NO_EMPTY);
            if ( !$objectFunctionName and in_array( $functionName, $this->FunctionList ) &&
                 function_exists( $functionName ) )
            {
                $this->showResponse( $functionName, $namespaceURI,
                                     call_user_func_array( $functionName, $params ) );
            }
            else if ( $objectName and $objectFunctionName )
            {
                if ( !class_exists( $objectName ) )
                {
                    $this->showResponse( $functionName, $namespaceURI,
                                         new eZSOAPFault( 'Server Error',
                                                          'Object not found' ) );
                }
                else
                {
                    $object = new $objectName();
                    if ( !method_exists( $object, $objectFunctionName ) )
                    {
                        $this->showResponse( $functionName, $namespaceURI,
                                             new eZSOAPFault( 'Server Error',
                                                              'Objectmethod not found' ) );
                    }
                    else
                    {
                        $this->showResponse( $functionName, $namespaceURI,
                                             call_user_func_array( array( $object, $objectFunctionName ), $params ) );
                    }
                }
            }
            else
            {
                $this->showResponse( $functionName, $namespaceURI,
                                     new eZSOAPFault( 'Server Error',
                                                      'Method not found' ) );
            }
        }
        else
        {
            // error
            $this->showResponse( $functionName, $namespaceURI,
                                 new eZSOAPFault( 'Server Error',
                                                  '"Body" element in the request '.
                                                  'has wrong number of children' ) );

        }
    }
1266000
public function sendResult($result)
    {
        if (@ob_get_length()) {
            @ob_end_clean();
        }
        if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
            header('Content-Type: application/json; charset=' . APP_CHARSET, true);
        } else {
            header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
        }
        echo json_encode($result);
        die();
    }
283501
public static function backtrace($return = false, $html = true, $withArgs = true)
        {
            $trace  = debug_backtrace();
            return static::trace($trace, $return, $html, $withArgs);
        }
52120
function dump($return = false, $print = true, $depth = 1)
    {
        $dump = array();
        $dump['count'] = $this->count;
        $dump['results'] = array();
        foreach ((array)$this->records() as $key => $record) {
            if ($record instanceof Resource) {
                $dump['results'][$key] = $record->data();
                foreach ($record->links as $field => $link) {
                    if ($depth < 1) {
                        try {
                            $link_record = $record[$field];
                        } catch (ServerException $e) {
                            $link_record = array('$error' => $e->getMessage());
                        }

                        if ($link_record instanceof Resource) {
                            $dump['results'][$key][$field] = $link_record->dump(true, false, $depth+1);
                        } else {
                            $dump['results'][$key][$field] = $link_record;
                        }
                    }
                }
            }
        }
        if ($dump['results'] && $links = $this->links) {
            $dump['$links'] = $this->dump_links($links);
        }
        if ($dump['count'] > 0) {
            $dump['page'] = $this->page;
        }
        if ($this->pages) {
            $dump['pages'] = $this->pages;
        }
        
        if ($print) {
            return print_r($dump, $return);
        } else {
            return $dump;
        }
    }
566901
public static function dump(XMLReader $reader, $return = FALSE)
    {
        $node = new self($reader);

        $nodeType = $reader->nodeType;
        $nodeName = $node->getNodeTypeName();

        $extra = '';

        if ($reader->nodeType === XMLReader::ELEMENT) {
            $extra = '<' . $reader->name . '> ';
            $extra .= sprintf("(isEmptyElement: %s) ", $reader->isEmptyElement ? 'Yes' : 'No');
        }

        if ($reader->nodeType === XMLReader::END_ELEMENT) {
            $extra = '</' . $reader->name . '> ';
        }

        if ($reader->nodeType === XMLReader::ATTRIBUTE) {
            $str = $reader->value;
            $len = strlen($str);
            if ($len > 20) {
                $str = substr($str, 0, 17) . '...';
            }
            $str   = strtr($str, array("\n" => '\n'));
            $extra = sprintf('%s = (%d) "%s" ', $reader->name, strlen($str), $str);
        }

        if ($reader->nodeType === XMLReader::TEXT || $reader->nodeType === XMLReader::WHITESPACE || $reader->nodeType === XMLReader::SIGNIFICANT_WHITESPACE) {
            $str = $reader->readString();
            $len = strlen($str);
            if ($len > 20) {
                $str = substr($str, 0, 17) . '...';
            }
            $str   = strtr($str, array("\n" => '\n'));
            $extra = sprintf('(%d) "%s" ', strlen($str), $str);
        }

        $label = sprintf("(#%d) %s %s", $nodeType, $nodeName, $extra);

        if ($return) {
            return $label;
        }

        printf("%s%s\n", str_repeat('  ', $reader->depth), $label);

        return null;
    }
715165
public function export($return = false)
    {
        if ($return) {
            return var_export($this->elements, true);
        }

        var_export($this->elements, false);

        return $this;
    }
614574
public static function dump($data, $return = false)
    {
        $result = '';

        if (Fabrication::isCli()) {
            $end = "\n";
        } else {
            $end = "<br />\n";
        }

        if (is_object($data)) {

            $classname = get_class($data);

            $result = str_repeat('-', 80) . $end .
                    "\t" . __METHOD__ . ' Type: ' . gettype($data) . "\tReturn:" . var_export($return, true) . $end .
                    str_repeat('-', 80) . $end .
                    "Object Instance: $classname: $end" .
                    "Object Methods $end";

            $class_methods = get_class_methods($data);
            if (count($class_methods) > 0) {
                foreach ($class_methods as $method) {
                    $result.="\t" . $method . $end;
                }
            } else {
                $result.="No methods found.$end";
            }

            $result.= $end;
            $result.= "Object XPath:$end";
            $result.= $end;

            switch ($classname) {

                case 'DOMAttr':
                    $result.= "DOMAttr XPath: {$data->getNodePath()}$end" .
                            $data->ownerDocument->saveXML($data);
                    break;

                case 'DOMDocument':
                    $result.= "DOMDocument XPath: {$data->getNodePath()}$end" .
                            $data->saveXML($data);
                    break;

                case 'DOMElement':
                    $result.= "DOMElement XPath: {$data->getNodePath()}$end" .
                            $data->ownerDocument->saveXML($data);
                    break;

                case 'DOMNodeList':
                    for ($i = 0; $i < $data->length; $i++) {
                        $result.= "DOMNodeList Item #$i, " .
                                "XPath: {$data->item($i)->getNodePath()}$end" .
                                "{$data->item($i)->ownerDocument->saveXML($data->item($i))}$end";
                    }
                    break;

                default: $result.= var_export($data, true);
            }
        }

        if (is_array($data)) {

            $result = $end .
                $end .
                str_repeat('-', 80) . $end .
                "| DUMP Type:" . gettype($data) . "\tReturn:" . var_export($return, true) . $end .
                str_repeat('-', 80) . $end .
                $end;
        }

        if (is_string($data)) {
            $result = var_export($data, true);
        }

        if (is_int($data)) {
            $result = var_export($data, true);
        }

        if ($return) {
            return $result . $end;
        } else {
            echo $result . $end;
        }
    }
714702
function create(array $data = null, $returning = "*") {
		$query = $this->getQueryWriter()->reset();
		$query->write("INSERT INTO", $this->conn->quoteName($this->name));
		if ($data) {
			$first = true;
			$params = array();
			foreach ($data as $key => $val) {
				$query->write($first ? "(" : ",", $key);
				$params[] = $query->param($val, $this->getAttributes()->getColumn($key)->type);
				$first and $first = false;
			}
			$query->write(") VALUES (", $params, ")");
		} else {
			$query->write("DEFAULT VALUES");
		}
		
		if (strlen($returning)) {
			$query->write("RETURNING", $returning);
		}
		return $this->execute($query);
	}
573419
public function executeRedirection($return = false)
    {
        $html = $this->createForm();
        $html .= '<script>document.forms["'.$this->_setNameForm.'"].submit();</script>';

        if (!$return) {
            echo $html;

            return null;
        }

        return $html;
    }
1015601
private function postData($parameters = array())
    {
        $this->post['CustomerID'] = $this->options['login'];

        $xml = new \SimpleXMLElement('<ewaygateway></ewaygateway>');

        foreach ($this->post as $name => $value) {
            $xml->addChild("eway$name", $value);
        }

        return $xml->asXML();
    }