phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api/interface class.interface_soap.php, NONE, 1.1.2.1


From: Dan Kuykendall <address@hidden>
Subject: [Phpgroupware-cvs] api/interface class.interface_soap.php, NONE, 1.1.2.1
Date: Fri, 07 Nov 2003 09:05:45 +0000

Update of /cvsroot/phpgroupware/api/interface
In directory subversions:/tmp/cvs-serv27648/api/interface

Added Files:
      Tag: proposal-branch
        class.interface_soap.php 
Log Message:
initial soap interface

--- NEW FILE: class.interface_soap.php ---
<?php
        
/**************************************************************************\
        * phpGroupWare                                                          
   *
        * http://www.phpgroupware.org                                           
   *
        * This file written by Dan Kuykendall <address@hidden>                 *
        * Copyright (C) 2003 Dan Kuykendall                                     
   *
        * 
-------------------------------------------------------------------------*
        * This library is part of the phpGroupWare API                          
   *
        * http://www.phpgroupware.org/api                                       
   * 
        * 
------------------------------------------------------------------------ *
        * This library is free software; you can redistribute it and/or modify 
it  *
        * under the terms of the GNU Lesser General Public License as published 
by *
        * the Free Software Foundation; either version 2.1 of the License,      
   *
        * or any later version.                                                 
   *
        * This library is distributed in the hope that it will be useful, but   
   *
        * WITHOUT ANY WARRANTY; without even the implied warranty of            
   *
        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  
   *
        * See the GNU Lesser General Public License for more details.           
   *
        * You should have received a copy of the GNU Lesser General Public 
License *
        * along with this library; if not, write to the Free Software 
Foundation,  *
        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA         
   *
        
\**************************************************************************/

        /* $Id: class.interface_soap.php,v 1.1.2.1 2003/11/07 09:05:43 seek3r 
Exp $ */
        /* $Source: 
/cvsroot/phpgroupware/api/interface/Attic/class.interface_soap.php,v $ */

        class api_interface
        {
                var $methodName;
                var $op;
                var $inputs;
                var $method_result;
                var $indent = '';
                var $first_input = True;
                
                function api_interface()
                {
                        $this->parse();
                        $GLOBALS['phpgw_data']['api']['op'] = $this->op;
                        $GLOBALS['phpgw_data']['server']['session_method'] = 
'url';
                }

                function output($result, $debug = False)
                {
                        if(!$debug)
                        {
                                header('Content-type: text/xml');
                                header('Content-Length: '.strlen($result));
                                echo $result;
                        }
                        else
                        {
                                echo htmlentities($result);
                        }
                }

                function get_op()
                {
                        $this->op;
                }

                function login()
                {
                        $GLOBALS['phpgw']->finish(False);
                        $this->soap_fault('1', 'Please login.');
                }

                function good_login()
                {
                        $newsid = $GLOBALS['phpgw']->session->sid();
            $result = $this->soapserver->serialize_val($newsid, 'sid');
            //$result = 
$this->soapserver->serialize_val(base64_encode($newsid), 'sid');
                        /*$result = "<?xml 
version=\"1.0\"?>\n<methodResponse>\n<params>\n<param>\n<value>\n<base64>".base64_encode($newsid)."</base64>\n</value>\n</param>\n</params>\n</methodResponse>";*/
                        $this->output($result);
                        exit;
                }
                
                function failed_login($reason = 'missing')
                {
                        if($reason == 'invalid')
                        {
                                $code = 4;
                                $msg = 'Authentication Failed!';
                        }
                        elseif($reason == 'missing')
                        {
                                $code = 3;
                                $msg = 'Username and/or password missing.';
                        }
                        $this->soap_fault($msg);
                }

                function logout()
                {
                }

                function soap_fault($msg)
                {
                        $this->soapserver->result = 'fault: '.$msg.' 
'.$this->methodName;
                        $this->soapserver->fault('Server',"$msg 
'".$this->methodName."'");
                        return $this->soapserver->fault->serialize();
                }

                function access_denied($methodname, $inputs = '')
                {
                        $this->soapserver->result = 'fault: Access denied to 
'.$this->methodName;
                        $this->soapserver->fault('Server',"Access denied to 
method '".$this->methodName."'");
                        return $this->soapserver->fault->serialize();
                }
                
                function get_inputs()
                {
                        return $this->inputs;
                }

                function handle_result($result)
                {
                        $this->method_result = $result;
                        $GLOBALS['phpgw']->finish();
                }

                function sendtoclient()
                {
                        $xml_result =  
$GLOBALS['phpgw']->base_xml->export_xml();
                        $api_data = xml2var($xml_result);

                        if(empty($this->method_result) && 
isset($api_data['APP']))
                        {
                                $this->method_result = $api_data['APP'];
                        }
            $response_packet = 
$this->soapserver->handle_result($this->method_result);
            //$response_packet = 
$this->soapserver->serialize_val($this->method_result);
//echo '<hr><hr>';
//html_print_r($this->method_result);
//exit;
                        $this->output($response_packet);
                }
                
                function parse()
                {
                        if(!isset($GLOBALS['HTTP_RAW_POST_DATA']))
                        {
                                header('Location: index.php');
                                exit;
                        }
                        
                        if(!strstr($GLOBALS['HTTP_RAW_POST_DATA'], '<?xml'))
                        {
                                $GLOBALS['HTTP_RAW_POST_DATA'] = "<?xml 
version=\"1.0\"?>\n".$GLOBALS['HTTP_RAW_POST_DATA'];
                        }

                        $this->soapserver = createobject('api_soap_server');
                        
$this->soapserver->service($GLOBALS['HTTP_RAW_POST_DATA']);

                        $this->methodName = $this->soapserver->methodname;
                        $this->soapserver->methodname = str_replace('.', '_', 
$this->soapserver->methodname);
                        switch ($this->methodName)
                        {
                                case 'system.listMethods':
                                        unset($this->op);
                                        break;
                                case 'system.methodSignature':
                                        unset($this->op);
                                        break;
                                case 'system.methodHelp':
                                        unset($this->op);
                                        break;
                                case 'system.logout':
                                        $this->op = 'api.base.logout';
                                        break;
                                default:
                                        $this->op = $this->methodName;
                        }

                        $this->inputs = $this->soapserver->inputs;
                        if(isset($this->inputs['sid']))
                        {
                                $GLOBALS['HTTP_GET_VARS']['sid'] = 
$this->inputs['sid'];
                                unset($this->inputs['sid']);
                        }                       
                        if(isset($this->inputs['phpgw_user']))
                        {
                                $GLOBALS['HTTP_GET_VARS']['phpgw_user'] = 
$this->inputs['phpgw_user'];
                                unset($this->inputs['phpgw_user']);
                        }                       
                        if(isset($this->inputs['phpgw_pass']))
                        {
                                $GLOBALS['HTTP_GET_VARS']['phpgw_pass'] = 
$this->inputs['phpgw_pass'];
                                unset($this->inputs['phpgw_pass']);
                        }                       
                }
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]