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('GNUSOCIAL')) { exit(1); }
33 * Data class for storing IP addresses of new registrants.
37 * @author Evan Prodromou <evan@status.net>
38 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
39 * @link http://status.net/
41 class Registration_ip extends Managed_DataObject
43 public $__table = 'registration_ip'; // table name
44 public $user_id; // int(4) primary_key not_null
45 public $ipaddress; // varchar(45)
46 public $created; // datetime() not_null
47 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
49 public static function schemaDef()
53 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id this registration relates to'),
54 'ipaddress' => array('type' => 'varchar', 'length' => 45, 'description' => 'IP address, max 45+null in IPv6'),
55 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
56 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
58 'primary key' => array('user_id'),
59 'foreign keys' => array(
60 'registration_ip_user_id_fkey' => array('user', array('user_id' => 'id')),
63 'registration_ip_ipaddress_idx' => array('ipaddress'),
64 'registration_ip_created_idx' => array('created'),
70 * Get the users who've registered with this ip address.
72 * @param Array $ipaddress IP address to check for
74 * @return Array IDs of users who registered with this address.
76 static function usersByIP($ipaddress)
80 $ri = new Registration_ip();
81 $ri->ipaddress = $ipaddress;
84 while ($ri->fetch()) {
85 $ids[] = $ri->user_id;