summaryrefslogtreecommitdiff
blob: 9f331ae06f7cd4f74bcb57056d9b39679d68875d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
class sql_registrationtoken extends sql_row_obj {
	protected $table='registrationtokens', $primary_key=array('id'), $columns=array(
		'id' => array (
			'type' => 'CHAR',
			'length' => 30,
			'not_null' => true,
			'default' => ''
		),
		'owner' => array (
			'type' => 'INT',
			'length' => 10,
			'unsigned' => true
		),
		'email' => array (
			'type' => 'VARCHAR',
			'length' => 255,
			'not_null' => true,
			'default' => '',
			'unique' => true
		),
		'expire' => array (
			'type' => 'INT',
			'length' => 10,
			'unsigned' => true,
			'not_null' => true,
			'default' => 0
		)

	);
	static function create() {
		global $S;
		$id=null;
		do {
			$id=randstring(30);
			if ($S['pdo']->query('SELECT COUNT(*) FROM `registrationtokens` WHERE `id`=\''.$id.'\'')->fetch(PDO::FETCH_COLUMN))
				$id=null;
		} while ($id==null);
		return new sql_registrationtoken($id, null, null, null);
	}
}
?>