get_config() callers in new MNET code switched to expect a single value returned
authormartinlanghoff <martinlanghoff>
Tue, 16 Jan 2007 23:27:41 +0000 (23:27 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 16 Jan 2007 23:27:41 +0000 (23:27 +0000)
Again, this simplifies the logic in a few places.

admin/mnet/trustedhosts.php
mnet/xmlrpc/client.php
mnet/xmlrpc/server.php

index da015f68c10f04de6dfadbcf62f3a9876e3f9e6d..0ea3505c0b5a8589ee5f2283e4380ab653668311 100644 (file)
 
     $trusted_hosts = '';//array();
     $old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts');
+    if (!empty($old_trusted_hosts)) {
+        $old_trusted_hosts =  explode(',', $old_trusted_hosts);
+    } else {
+        $old_trusted_hosts = array();
+    }
 
     $test_ip_address = optional_param('testipaddress', NULL, PARAM_HOST);
     $in_range = false;
     if (!empty($test_ip_address)) {
-        foreach(explode(',', $old_trusted_hosts->value) as $host) {
+        foreach($old_trusted_hosts as $host) {
             list($network, $mask) = explode('/', $host.'/');
             if (empty($network)) continue;
             if (strlen($mask) == 0) $mask = 32;
@@ -54,8 +59,8 @@
             unset($address, $mask);
         }
         set_config('mnet_trusted_hosts', str_replace("\n", ',', $trusted_hosts), 'mnet');
-    } elseif (!empty($old_trusted_hosts->value)) {
-        foreach(explode(',', $old_trusted_hosts->value) as $host) {
+    } elseif (!empty($old_trusted_hosts)) {
+        foreach($old_trusted_hosts as $host) {
             list($address, $mask) = explode('/', $host.'/');
             if (empty($address)) continue;
             if (strlen($mask) == 0) $mask = 32;
index 96e5f0d897e964745593b1f9f3aa5ff2b3c38094..c18f3d4bf5186d4bbc65c6bc51025e67882048e9 100644 (file)
@@ -204,12 +204,13 @@ class mnet_xmlrpc_client {
 
             if (!$isOpen) {
                 // Decryption failed... let's try our archived keys
-                $result = get_config('mnet', 'openssl_history');
-                if(empty($result)) {
-                    set_config('openssl_history', serialize(array()), 'mnet');
-                    $result = get_config('mnet', 'openssl_history');
+                $openssl_history = get_config('mnet', 'openssl_history');
+                if(empty($openssl_history)) {
+                    $openssl_history = array();
+                    set_config('openssl_history', serialize($openssl_history), 'mnet');
+                } else {
+                    $openssl_history = unserialize($result);
                 }
-                $openssl_history = unserialize($result->value);
                 foreach($openssl_history as $keyset) {
                     $keyresource = openssl_pkey_get_private($keyset['keypair_PEM']);
                     $isOpen      = openssl_open(base64_decode($data), $payload, base64_decode($key), $keyresource);
@@ -247,15 +248,13 @@ class mnet_xmlrpc_client {
         $remote_timestamp = $sig_parser->remote_timestamp - $hysteresis;
         $time_offset      = $remote_timestamp - $timestamp_send;
         if ($time_offset > 0) {
-            $result = get_field('config_plugins', 'value', 'plugin', 'mnet', 'name', 'drift_threshold');
-            if(empty($result)) {
+            $threshold = get_config('mnet', 'drift_threshold');
+            if(empty($threshold)) {
                 // We decided 15 seconds was a pretty good arbitrary threshold
                 // for time-drift between servers, but you can customize this in
                 // the config_plugins table. It's not advised though.
                 set_config('drift_threshold', 15, 'mnet');
                 $threshold = 15;
-            } else {
-                $threshold = $result;
             }
             if ($time_offset > $threshold) {
                 $this->error[] = 'Time gap with '.$mnet_peer->name.' ('.$time_offset.' seconds) is greater than the permitted maximum of '.$threshold.' seconds';
index ad36654b01207bc4c13bb0314a72c3c7c15a039f..90b3dfe730015b1c3d6302a1270e08d46674907f 100644 (file)
@@ -145,12 +145,13 @@ function mnet_server_strip_wrappers($HTTP_RAW_POST_DATA) {
 
             if (!$isOpen) {
                 // Decryption failed... let's try our archived keys
-                $result = get_config('mnet', 'openssl_history');
-                if(empty($result)) {
-                    set_config('openssl_history', serialize(array()), 'mnet');
-                    $result = get_config('mnet', 'openssl_history');
+                $openssl_history = get_config('mnet', 'openssl_history');
+                if(empty($openssl_history)) {
+                    $openssl_history = array();
+                    set_config('openssl_history', serialize($openssl_history), 'mnet');
+                } else {
+                    $openssl_history = unserialize($result);
                 }
-                $openssl_history = unserialize($result->value);
                 foreach($openssl_history as $keyset) {
                     $keyresource = openssl_pkey_get_private($keyset['keypair_PEM']);
                     $isOpen      = openssl_open(base64_decode($data), $payload, base64_decode($key), $keyresource);