Make use of config file for manageurs webservice
authorJean-Marc Coic <jean-marc.coic@polytechnique.org>
Sun, 16 Jan 2005 14:49:14 +0000 (14:49 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:42 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-355

hooks/manageurs.inc.php [new file with mode: 0644]
htdocs/webservices/manageurs.php
include/webservices/manageurs.inc.php
include/webservices/manageurs.server.inc.php

diff --git a/hooks/manageurs.inc.php b/hooks/manageurs.inc.php
new file mode 100644 (file)
index 0000000..ee223ae
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 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                *
+ ***************************************************************************/
+
+// {{{ config HOOK
+// {{{ class ManageursConfig
+
+class ManageursConfig
+{
+    var $authorized_ips = '129.104.30.32 129.104.30.33';
+    var $manageurs_cipher_key = '';
+    var $manageurs_pass = '';
+}
+
+// }}}
+
+function manageurs_config()
+{
+    global $globals;
+    $globals->manageurs = new ManageursConfig;
+}
+
+// }}}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
index ce09df2..4db6f6b 100644 (file)
@@ -22,8 +22,9 @@
 require_once('xorg.inc.php');
 require_once('webservices/manageurs.server.inc.php');
 
+$ips = array_flip(split(' ',$globals->manageurs->authorized_ips));
 
-if(isset($GLOBALS['manageurs_authorized_ips'][$_SERVER['REMOTE_ADDR']])){
+if($ips && isset($ips[$_SERVER['REMOTE_ADDR']])){
 
   $server = xmlrpc_server_create();
 
index 8a6bc4e..2dd15d0 100644 (file)
@@ -24,14 +24,14 @@ $tripledes = '';
 
 
 function manageurs_encrypt_init($id_assoce){
-  global $tripledes;
+  global $tripledes, $globals;
   if(!$tripledes){
-    if(empty($GLOBALS['manageurs_cipher_key'])){
+    if(empty($globals->manageurs->manageurs_cipher_key)){
       return 1;
     }
     $tripledes = mcrypt_module_open('tripledes', '', 'ecb', '');
     $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($tripledes), MCRYPT_RAND);
-    mcrypt_generic_init($tripledes, $GLOBALS['manageurs_cipher_key'].$id_assoce, $iv);
+    mcrypt_generic_init($tripledes, $globals->manageurs->manageurs_cipher_key.$id_assoce, $iv);
     return 0;
   }
 }
@@ -41,6 +41,7 @@ function manageurs_encrypt_close(){
   if($tripledes){
     mcrypt_generic_deinit($tripledes);
     mcrypt_module_close($tripledes);
+    $tripledes = '';
   }
 }
 
index f112b5c..dc2cb08 100644 (file)
@@ -16,7 +16,7 @@ function get_annuaire_infos($method, $params) {
     global $error_mat, $error_key, $globals;
 
     //verif du mdp
-    if(!isset($params[0]) || ($params[0] != $GLOBALS['manageurs_pass'])){return false;}
+    if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)){return false;}
 
     //si on a adresse == -1 => on ne recupère aucune adresse
     if(isset($params[2]) && ($params[2] == -1)) unset($params[2]);