-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebapp_account.php
More file actions
73 lines (57 loc) · 1.75 KB
/
Copy pathwebapp_account.php
File metadata and controls
73 lines (57 loc) · 1.75 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
class webapp_account
{
const
tablename = 'accounts',
records = 'account_records',
favorites = 'account_favorites';
private array $data;
function __construct(public readonly webapp $webapp)
{
}
function sign_in(string $id, $pwd):bool
{
//$this->webapp->mysql->
}
function create(array $accountinfo = []):array
{
$accountinfo = [
'id' => $this->webapp->random_hash(TRUE),
't0' => $this->webapp->time(),
't1' => 0,
't2' => 0,
'ip' => $this->webapp->iphex('0.0.0.0'),
'balances' => '{}',
'freezes' => '{}'
] + $accountinfo;
// $id = $this->webapp->random_hash(TRUE);
// $time = $this->webapp->time();
// var_dump( $this->webapp->mysql->{static::tablename}->insert([
// 'id' => $id,
// 't0' => $time,
// 't1' => $time,
// 'ip' => $this->webapp->iphex('0.0.0.0')
// ]) );
return $accountinfo;
}
static function createtable(webapp_mysql $mysql):bool
{
return $mysql->real_query(<<<'SQL'
CREATE TABLE ?a (
`id` char(10) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`t0` bigint unsigned NOT NULL COMMENT 'create time',
`t1` bigint unsigned NOT NULL COMMENT 'expire time',
`t2` bigint unsigned NOT NULL COMMENT 'signin time',
`ip` char(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL COMMENT 'signin hexip',
`balances` json NOT NULL,
`freezes` json NOT NULL,
`extdata` json NOT NULL,
`phone` bigint unsigned DEFAULT NULL,
`email` varchar(64) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL,
`uid` varchar(16) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
`pwd` varchar(16) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SQL, static::tablename);
}
}