summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class13
1 files changed, 9 insertions, 4 deletions
diff --git a/it_dbi.class b/it_dbi.class
index d65d1a2..f6614d8 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -454,11 +454,16 @@ function query($query, $p = array())
$p += $this->_p;
$start = gettimeofday(true);
- if ($p['server_update'] && !preg_match('/^(EXPLAIN|SELECT|SHOW) /i', $query))
+ if (!it::match('^(EXPLAIN|SELECT|SHOW)', $query))
{
- debug("switching to update server \"{$p['server_update']}\"", 5);
- $this->_p['server'] = $p['server'] = $p['server_update'];
- unset($this->_p['server_update'], $p['server_update'], $this->_link);
+ if ($p['server_update'])
+ {
+ debug("switching to update server \"{$p['server_update']}\"", 5);
+ $this->_p['server'] = $p['server'] = $p['server_update'];
+ unset($this->_p['server_update'], $p['server_update'], $this->_link);
+ }
+ else if ($p['server'] == "localhost" && ($t = @file($GLOBALS['ULTRAHOME'] . "/doc/machines.txt")) && preg_grep("/^" . gethostname() . "/", array_slice($t, 2)))
+ it::error("local write access on a replication slave machine?");
}
$this->_connect($p); # must be called after update server switching code