From: Raphaël Barrois Date: Mon, 15 Feb 2010 13:49:40 +0000 (+0100) Subject: Add UFC_Ip X-Git-Tag: xorg/1.0.0~332^2~214 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=f73a4f1b59d92c742c3536c54f0a0a2731e936ae;p=platal.git Add UFC_Ip Signed-off-by: Raphaël Barrois --- diff --git a/classes/userfilter.php b/classes/userfilter.php index e8aa2f2..20b9247 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -76,6 +76,28 @@ class UFC_Hruid implements UserFilterCondition } // }}} +// {{{ class UFC_Ip +/** Filters users based on one of their last IPs + * @param $ip IP from which connection are checked + */ +class UFC_Ip implements UserFilterCondition +{ + private $ip; + + public function __construct($ip) + { + $this->ip = $ip; + } + + public function buildCondition(PlFilter &$uf) + { + $sub = $uf->addLoggerFilter(); + $ip = ip_to_uint($this->ip); + return XDB::format($sub . '.ip = {?} OR ' . $sub . '.forward_ip = {?}', $ip, $ip); + } +} +// }}} + // {{{ class UFC_Comment class UFC_Comment implements UserFilterCondition { @@ -1827,6 +1849,25 @@ class UserFilter extends PlFilter } } + /** LOGGER + */ + + private $with_logger = false; + public function addLoggerFilter() + { + $this->with_logger = true; + $this->requireAccounts(); + return 'ls'; + } + protected function loggerJoins() + { + $joins = array(); + if ($this->with_logger) { + $joins['ls'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'log_sessions', '$ME.uid = $UID'); + } + return $joins; + } + /** NAMES */ diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 92e0841..611756b 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -469,8 +469,7 @@ class UFBF_Quick extends UFB_Field if (S::admin() && strpos($s, '@') !== false) { return new UFC_Email($s); } else if (S::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) { - // TODO: create UFC_Ip -// $this->conds->addChild(new UFC_Ip($s)); + $this->conds->addChild(new UFC_Ip($s)); return; }