merge xmlrpc stuff, and put it in classes/
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 23 Jul 2006 11:50:01 +0000 (11:50 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 23 Jul 2006 11:50:01 +0000 (11:50 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@581 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/XmlrpcClient.php [moved from include/platal/xmlrpc-server.inc.php with 55% similarity]
htdocs/admin/lists.php
include/lists.inc.php
include/platal/xmlrpc-client.inc.php [deleted file]
include/validations/listes.inc.php
include/webservices/manageurs.client.inc.php
modules/auth.php
modules/xnetlists.php

similarity index 55%
rename from include/platal/xmlrpc-server.inc.php
rename to classes/XmlrpcClient.php
index 23b12d5..101fa74 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /******************************************************************************
  *                                                                            *
  *  Original file can be found on http://xmlrpc-epi.sourceforge.net/          *
@@ -7,42 +6,42 @@
  *                                                                            *
  *                                                The Polytechnique.org TEAM  *
  *                                                                            *
- ******************************************************************************/
+ **************************************************************************{{{*/
 
 /*
-  This file is part of, or distributed with, libXMLRPC - a C library for 
+  This file is part of, or distributed with, libXMLRPC - a C library for
   xml-encoded function calls.
 
   Author: Dan Libby (dan@libby.com)
   Epinions.com may be contacted at feedback@epinions-inc.com
 */
 
-/*  
-  Copyright 2001 Epinions, Inc. 
+/*
+  Copyright 2001 Epinions, Inc.
 
-  Subject to the following 3 conditions, Epinions, Inc.  permits you, free 
-  of charge, to (a) use, copy, distribute, modify, perform and display this 
-  software and associated documentation files (the "Software"), and (b) 
-  permit others to whom the Software is furnished to do so as well.  
+  Subject to the following 3 conditions, Epinions, Inc.  permits you, free
+  of charge, to (a) use, copy, distribute, modify, perform and display this
+  software and associated documentation files (the "Software"), and (b)
+  permit others to whom the Software is furnished to do so as well.
 
-  1) The above copyright notice and this permission notice shall be included 
-  without modification in all copies or substantial portions of the 
-  Software.  
+  1) The above copyright notice and this permission notice shall be included
+  without modification in all copies or substantial portions of the
+  Software.
 
-  2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF 
-  ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY 
-  IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR 
-  PURPOSE OR NONINFRINGEMENT.  
+  2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF
+  ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY
+  IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+  PURPOSE OR NONINFRINGEMENT.
 
-  3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, 
-  SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 
-  OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING 
-  NEGLIGENCE), EVEN IF EPINIONS, INC.  IS AWARE OF THE POSSIBILITY OF SUCH 
-  DAMAGES.    
+  3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
+  SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
+  OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING
+  NEGLIGENCE), EVEN IF EPINIONS, INC.  IS AWARE OF THE POSSIBILITY OF SUCH
+  DAMAGES.
 
 */
 
-/* xmlrpc utilities (xu) 
+/* xmlrpc utilities (xu)
  * author: Dan Libby (dan@libby.com)
  */
 
@@ -69,7 +68,7 @@ function xu_query_http_post($request, $host, $uri, $port, $timeout, $user,
                $auth .
                "User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" .
                "Content-Type: text/xml\r\n" .
-               "Content-Length: $content_len\r\n" . 
+               "Content-Length: $content_len\r\n" .
                "Connection: Close\r\n" .
                "\r\n" .
                $request;
@@ -106,7 +105,7 @@ function find_and_decode_xml($buf)
     return $retval;
 }
 
+
 /**
  * @param params         a struct containing 3 or more of these key/val pairs:
  * @param host          remote host             (required)
@@ -115,7 +114,7 @@ function find_and_decode_xml($buf)
  * @param method         name of method to call
  * @param args          arguments to send       (parameters to remote xmlrpc server)
  * @param timeout       timeout in secs.        (0 = never)
- * @param user          user name for authentication.  
+ * @param user          user name for authentication.
  * @param pass          password for authentication
  * @param secure        secure. wether to use fsockopen_ssl. (requires special php build).
  */
@@ -141,4 +140,77 @@ function xu_rpc_http_concise($params) {
    return $retval;
 }
 
+/*}}}***********************************************************************
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program 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 General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+/* taken from : http://fr2.php.net/xml-rpc
+ * Author mboeren@php.net
+ *
+ * Usage:
+ * $client = new xmlrpc_client("http://localhost:7080");
+ * print $client->echo('x')."\n";
+ * print $client->add(1, 3)."\n";
+ */
+
+class XmlrpcClient
+{
+    var $url;
+    var $urlparts;
+
+    function XmlrpcClient($url)
+    {
+        $this->url = $url;
+        $this->urlparts = parse_url($this->url);
+        foreach (array('scheme', 'host', 'user', 'pass', 'path', 'query', 'fragment') as $part) {
+            if (!isset($this->urlparts[$part])) {
+                $this->urlparts[$part] = null;
+            }
+        }
+    }
+
+    function __call($function, $arguments, &$return)
+    {
+        $requestprms['host']    = $this->urlparts['host'];
+        $requestprms['port']    = $this->urlparts['port'];
+        $requestprms['uri']     = $this->urlparts['path'];
+        $requestprms['user']    = $this->urlparts['user'];
+        $requestprms['pass']    = $this->urlparts['pass'];
+        $requestprms['method']  = $function;
+        $requestprms['args']    = $arguments;
+        $requestprms['timeout'] = 0;
+        $requestprms['secure']  = 0;
+
+        $result = xu_rpc_http_concise($requestprms);
+        if (is_array($result) && isset($result['faultCode'])) {
+            print('Error in xmlrpc call \''.$function.'\''."\n");
+            print('  code  : '.$result['faultCode']."\n");
+            print('  message: '.$result['faultString']."\n");
+            return false;
+        }
+        $return = $result;
+        return true;
+    }
+
+}
+
+overload('XmlrpcClient');
+
+// vim:set et sw=4 sts=4 sws=4:
 ?>
index 1674404..07d84fc 100644 (file)
@@ -22,8 +22,7 @@
 require_once("xorg.inc.php");
 new_admin_page('admin/lists.tpl');
 $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
-require_once('platal/xmlrpc-client.inc.php');
-require_once('lists.inc.php');
+require_once 'lists.inc.php';
 
 $client =& lists_xmlrpc(S::v('uid'), S::v('password'));
 $listes = $client->get_all_lists();
index d86b3f3..15f0d67 100644 (file)
@@ -21,7 +21,7 @@
 
 // {{{ import class definitions
 
-require_once 'platal/xmlrpc-client.inc.php';
+require_once dirname(__FILE__).'/../classes/XmlrpcClient.php';
 
 // }}}
 // {{{ function lists_xmlrpc
@@ -32,7 +32,7 @@ function &lists_xmlrpc($uid, $pass, $fqdn=null)
 
     $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn;
     $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom";
-    $client = new xmlrpc_client($url);
+    $client = new XmlrpcClient($url);
     return $client;
 }
 
diff --git a/include/platal/xmlrpc-client.inc.php b/include/platal/xmlrpc-client.inc.php
deleted file mode 100644 (file)
index fe1bec7..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program 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 General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'platal/xmlrpc-server.inc.php';
-
-/* taken from : http://fr2.php.net/xml-rpc
- * Author mboeren@php.net
- *
- * Usage:
- * $client = new xmlrpc_client("http://localhost:7080");
- * print $client->echo('x')."\n";
- * print $client->add(1, 3)."\n";
- */
-
-class xmlrpc_client
-{
-    var $url;
-    var $urlparts;
-
-    function xmlrpc_client($url)
-    {
-        $this->url = $url;
-        $this->urlparts = parse_url($this->url);
-        foreach (array('scheme', 'host', 'user', 'pass', 'path', 'query', 'fragment') as $part) {
-            if (!isset($this->urlparts[$part])) { 
-                $this->urlparts[$part] = null;
-            }
-        }
-    }
-
-    function __call($function, $arguments, &$return)
-    {
-        $requestprms['host']    = $this->urlparts['host'];
-        $requestprms['port']    = $this->urlparts['port'];
-        $requestprms['uri']     = $this->urlparts['path'];
-        $requestprms['user']    = $this->urlparts['user'];
-        $requestprms['pass']    = $this->urlparts['pass'];
-        $requestprms['method']  = $function;
-        $requestprms['args']    = $arguments;
-        $requestprms['timeout'] = 0;
-        $requestprms['secure']  = 0;
-
-        $result = xu_rpc_http_concise($requestprms);
-        if (is_array($result) && isset($result['faultCode'])) {
-            print('Error in xmlrpc call \''.$function.'\''."\n");
-            print('  code  : '.$result['faultCode']."\n");
-            print('  message: '.$result['faultString']."\n");
-            return false;
-        }
-        $return = $result;
-        return true;
-    }
-
-}
-
-overload('xmlrpc_client');
-
-// vim:set et sw=4 sts=4 sws=4:
-?>
index fe06410..e74eb02 100644 (file)
@@ -85,8 +85,7 @@ class ListeReq extends Validate
     
     function commit()
     {
-        require_once('platal/xmlrpc-client.inc.php');
-        require_once('lists.inc.php');
+        require_once 'lists.inc.php';
 
         $client =& lists_xmlrpc(S::v('uid'), S::v('password'));
         $ret = $client->create_list($this->liste, $this->desc,
index a5f47b8..9b0ecf7 100644 (file)
@@ -1,34 +1,34 @@
 <?php
 
-require_once('webservices/manageurs.inc.php');
-require_once('platal/xmlrpc-client.inc.php');
+require_once 'webservices/manageurs.inc.php';
+require_once dirname(__FILE__).'/../../XmlrpcClient.php';
 
 function get_annuaire_infos($amicale, $id_assoce, $adresse){
 
-  $url = '';
+    $url = '';
 
-  $url = 'http://www.polytechniciens.org:80/manageurs.php';
+    $url = 'http://www.polytechniciens.org:80/manageurs.php';
     //decommenter pour ajouter un webservice chez l'AX :
-   // return array('adresse' => array(0 => array('adr1' => 'test AX', 'city' => 'Trou perdu')));
-
-  $client = new xmlrpc_client($url);
-  global $globals;
-  if($array = $client->get_annuaire_infos($globals->webservice->pass, $id_assoce, $adresse)){
-    
-    if( is_string($array) ){
-      $erreur = xmlrpc_decode($array);
-      echo $erreur['erreurstring']."\n";
-      return $erreur['erreur'];
-    }
-    else{
-    manageurs_encrypt_init($id_assoce);
-    $reply = manageurs_decrypt_array($array);
-    manageurs_encrypt_close();
-    return $reply;
+    // return array('adresse' => array(0 => array('adr1' => 'test AX', 'city' => 'Trou perdu')));
+
+    $client = new XmlrpcClient($url);
+
+    global $globals;
+    if($array = $client->get_annuaire_infos($globals->webservice->pass, $id_assoce, $adresse)){
+
+        if( is_string($array) ){
+            $erreur = xmlrpc_decode($array);
+            echo $erreur['erreurstring']."\n";
+            return $erreur['erreur'];
+        }
+        else{
+            manageurs_encrypt_init($id_assoce);
+            $reply = manageurs_decrypt_array($array);
+            manageurs_encrypt_close();
+            return $reply;
+        }
     }
-  }
-  else return false;
+    else return false;
 }
 
 ?>
index afdf1c8..e3571c0 100644 (file)
@@ -48,7 +48,6 @@ class AuthModule extends PLModule
     {
         global $globals;
 
-        require_once 'platal/xmlrpc-client.inc.php';
         require_once 'lists.inc.php';
 
         $cle = $globals->core->econfiance;
index a534a5b..1201fbf 100644 (file)
@@ -146,7 +146,6 @@ class XnetListsModule extends ListsModule
             return;
         }
 
-        require_once 'platal/xmlrpc-client.inc.php';
         require_once 'lists.inc.php';
         $ret = $this->client->create_list(
                     $liste, Post::get('desc'), Post::get('advertise'),