File indexing completed on 2024-12-22 05:37:14

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Controller
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  */
0020 
0021 /**
0022  * Zend_XmlRpc_Request
0023  */
0024 // require_once 'Zend/XmlRpc/Request.php';
0025 
0026 /**
0027  * XmlRpc Request object -- Request via STDIN
0028  *
0029  * Extends {@link Zend_XmlRpc_Request} to accept a request via STDIN. Request is
0030  * built at construction time using data from STDIN; if no data is available, the
0031  * request is declared a fault.
0032  *
0033  * @category Zend
0034  * @package  Zend_XmlRpc
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  * @version $Id$
0038  */
0039 class Zend_XmlRpc_Request_Stdin extends Zend_XmlRpc_Request
0040 {
0041     /**
0042      * Raw XML as received via request
0043      * @var string
0044      */
0045     protected $_xml;
0046 
0047     /**
0048      * Constructor
0049      *
0050      * Attempts to read from php://stdin to get raw POST request; if an error
0051      * occurs in doing so, or if the XML is invalid, the request is declared a
0052      * fault.
0053      *
0054      * @return void
0055      */
0056     public function __construct()
0057     {
0058         $fh = fopen('php://stdin', 'r');
0059         if (!$fh) {
0060             $this->_fault = new Zend_XmlRpc_Server_Exception(630);
0061             return;
0062         }
0063 
0064         $xml = '';
0065         while (!feof($fh)) {
0066             $xml .= fgets($fh);
0067         }
0068         fclose($fh);
0069 
0070         $this->_xml = $xml;
0071 
0072         $this->loadXml($xml);
0073     }
0074 
0075     /**
0076      * Retrieve the raw XML request
0077      *
0078      * @return string
0079      */
0080     public function getRawRequest()
0081     {
0082         return $this->_xml;
0083     }
0084 }