protected function _parseGrant($r) { $original = $r; $ret = array(); $data = ""; $f = array(array("GRANT"), array("ON"), array("TO"), array("IDENTIFIED", "WITH")); while (count($f)) { $keywords = array_shift($f); $r = ltrim($r); while (0 < strlen($r)) { if ($this->_isKeyword($r, $keywords, $keyword, $keywordLen)) { $data = trim($data); switch ($keyword) { case 'GRANT': break; case 'ON': $ret['grant'] = $data; break; case 'TO': if (preg_match("/`?([^\\.`]*)`?(\\..*)/", $data, $a)) { $ret['db'] = $a[1]; $ret['on'] = $a[2]; } else { $this->_out->logCritical("Can't parse ON parameter '{$data}' in: {$original}"); } break; default: $ret['to'] = $data; $ret['other'] = trim($r); $r = ""; } $r = substr($r, $keywordLen + 1); $data = ""; break; } $data .= $r[0]; $r = substr($r, 1); } } if (!array_key_exists('to', $ret)) { $ret['to'] = $data; $ret['other'] = trim($r); } // handle password in other if (preg_match("/IDENTIFIED BY (PASSWORD)? '(.*)'/", $ret['other'], $a)) { $ret['password'] = $a[2]; $ret['other'] = trim(preg_replace("/IDENTIFIED BY (PASSWORD)? '.*'/", '', $ret['other'])); } return $ret; }