]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
use a random mirror
authorEvan Prodromou <evan@prodromou.name>
Thu, 24 Jul 2008 17:12:13 +0000 (13:12 -0400)
committerEvan Prodromou <evan@prodromou.name>
Thu, 24 Jul 2008 17:12:13 +0000 (13:12 -0400)
darcs-hash:20080724171213-84dde-4668d0e57ce1766da7df22a5372aa94466b2fae5.gz

index.php

index 21d5ed275354a052ed3df81dad4bff1b4b2c706c..fad6266466a6a49f586f60f63e1bb81fa674a8b7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -34,6 +34,16 @@ if (file_exists($actionfile)) {
     require_once($actionfile);
     $action_class = ucfirst($action)."Action";
     $action_obj = new $action_class();
+       if ($config['db']['mirror'] && $action_obj->is_readonly()) {
+               if (is_array($config['db']['mirror'])) {
+                       # "load balancing", ha ha
+                       $k = array_rand($config['db']['mirror']);
+                       $mirror = $config['db']['mirror'][$k];
+               } else {
+                       $mirror = $config['db']['mirror'];
+               }
+               $config['db']['database'] = $mirror;
+       }
     call_user_func(array($action_obj, 'handle'), $_REQUEST);
 } else {
     common_user_error(_('Unknown action'));