]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/RegisterThrottle/Registration_ip.php
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / plugins / RegisterThrottle / Registration_ip.php
1 <?php
2 /**
3  * Data class for storing IP addresses of new registrants.
4  *
5  * PHP version 5
6  *
7  * @category Data
8  * @package  StatusNet
9  * @author   Evan Prodromou <evan@status.net>
10  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11  * @link     http://status.net/
12  *
13  * StatusNet - the distributed open-source microblogging tool
14  * Copyright (C) 2010, StatusNet, Inc.
15  *
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.
20  *
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.
25  *
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/>.
28  */
29
30 if (!defined('STATUSNET')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
35
36 /**
37  * Data class for storing IP addresses of new registrants.
38  *
39  * @category Spam
40  * @package  StatusNet
41  * @author   Evan Prodromou <evan@status.net>
42  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43  * @link     http://status.net/
44  */
45
46 class Registration_ip extends Memcached_DataObject
47 {
48     public $__table = 'registration_ip';     // table name
49     public $user_id;                         // int(4)  primary_key not_null
50     public $ipaddress;                       // varchar(15)
51     public $created;                         // timestamp
52
53     /**
54      * Get an instance by key
55      *
56      * @param string $k Key to use to lookup (usually 'user_id' for this class)
57      * @param mixed  $v Value to lookup
58      *
59      * @return User_greeting_count object found, or null for no hits
60      *
61      */
62
63     function staticGet($k, $v=null)
64     {
65         return Memcached_DataObject::staticGet('Registration_ip', $k, $v);
66     }
67
68     /**
69      * return table definition for DB_DataObject
70      *
71      * @return array array of column definitions
72      */
73
74     function table()
75     {
76         return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
77                      'ipaddress' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
78                      'created' => DB_DATAOBJECT_MYSQLTIMESTAMP + DB_DATAOBJECT_NOTNULL);
79     }
80
81     /**
82      * return key definitions for DB_DataObject
83      *
84      * DB_DataObject needs to know about keys that the table has; this function
85      * defines them.
86      *
87      * @return array key definitions
88      */
89
90     function keys()
91     {
92         return array('user_id' => 'K');
93     }
94
95     /**
96      * return key definitions for Memcached_DataObject
97      *
98      * Our caching system uses the same key definitions, but uses a different
99      * method to get them.
100      *
101      * @return array key definitions
102      */
103
104     function keyTypes()
105     {
106         return $this->keys();
107     }
108
109     /**
110      * Magic formula for non-autoincrementing integer primary keys
111      *
112      * If a table has a single integer column as its primary key, DB_DataObject
113      * assumes that the column is auto-incrementing and makes a sequence table
114      * to do this incrementation. Since we don't need this for our class, we
115      * overload this method and return the magic formula that DB_DataObject needs.
116      *
117      * @return array magic three-false array that stops auto-incrementing.
118      */
119
120     function sequenceKey()
121     {
122         return array(false, false, false);
123     }
124 }