3 * Data class for storing IP addresses of new registrants.
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2010, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
37 * Data class for storing IP addresses of new registrants.
41 * @author Evan Prodromou <evan@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://status.net/
45 class Registration_ip extends Managed_DataObject
47 public $__table = 'registration_ip'; // table name
48 public $user_id; // int(4) primary_key not_null
49 public $ipaddress; // varchar(15)
50 public $created; // timestamp
53 * return table definition for DB_DataObject
55 * @return array array of column definitions
59 return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
60 'ipaddress' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
61 'created' => DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL);
65 * return key definitions for DB_DataObject
67 * DB_DataObject needs to know about keys that the table has; this function
70 * @return array key definitions
74 return array('user_id' => 'K');
78 * return key definitions for Memcached_DataObject
80 * Our caching system uses the same key definitions, but uses a different
83 * @return array key definitions
91 * Magic formula for non-autoincrementing integer primary keys
93 * If a table has a single integer column as its primary key, DB_DataObject
94 * assumes that the column is auto-incrementing and makes a sequence table
95 * to do this incrementation. Since we don't need this for our class, we
96 * overload this method and return the magic formula that DB_DataObject needs.
98 * @return array magic three-false array that stops auto-incrementing.
100 function sequenceKey()
102 return array(false, false, false);
106 * Get the users who've registered with this ip address.
108 * @param Array $ipaddress IP address to check for
110 * @return Array IDs of users who registered with this address.
112 static function usersByIP($ipaddress)
116 $ri = new Registration_ip();
117 $ri->ipaddress = $ipaddress;
120 while ($ri->fetch()) {
121 $ids[] = $ri->user_id;