-
Notifications
You must be signed in to change notification settings - Fork 0
/
husbando.php
162 lines (143 loc) · 4.63 KB
/
husbando.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
/**
* Husbando core
*/
function what_is_my_husbando($screen_name, $tweet_id)
{
$dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8', DB_USER, DB_PASS);
// Detect if this user already have a husbnado for today
$sql = "
SELECT COUNT(*) as 'count'
FROM husbandos
WHERE username = '".$screen_name."'
AND (
tweet_id = '".$tweet_id."'
OR married_at BETWEEN '".date('Y-m-d')." 00:00:00' AND '".date('Y-m-d')." 23:59:59'
)
";
$result = $dbh->query($sql, PDO::FETCH_ASSOC);
$rows = $result->fetchAll();
if ($rows[0]['count'] == 0) {
$husbandos = array(
array(
'name' => 'Akihiko Sanada',
'picture' => 'akihiko_sanada.png'
),
array(
'name' => 'Aomine Daiki',
'picture' => 'aomine_daiki.jpg'
),
array(
'name' => 'Aquarius Camus',
'picture' => 'aquarius_camus.jpg'
),
array(
'name' => 'Dio Brando',
'picture' => 'dio_brando.jpg'
),
array(
'name' => 'Fuuma Monou',
'picture' => 'fuuma_monou.jpg'
),
array(
'name' => 'Gaara',
'picture' => 'gaara.png'
),
array(
'name' => 'Hak',
'picture' => 'hak.png'
),
array(
'name' => 'Haruka Nanase',
'picture' => 'haruka_nanase.png'
),
array(
'name' => 'Hijirikawa Masato',
'picture' => 'hijirikawa_masato.png'
),
array(
'name' => 'Hisoka',
'picture' => 'Hisoka.jpg'
),
array(
'name' => 'Hiei',
'picture' => 'hiei.jpg'
),
array(
'name' => 'Ittoki Otoya',
'picture' => 'ittoki_otoya.png'
),
array(
'name' => 'Kou Mabuchi',
'picture' => 'kou_mabuchi.jpg'
),
array(
'name' => 'Kurapika',
'picture' => 'kurapika.jpg'
),
array(
'name' => 'Kogami Shinya',
'picture' => 'kogami_shinya.jpg'
),
array(
'name' => 'Makoto Tachinaba',
'picture' => 'makoto_tachinaba.png'
),
array(
'name' => 'Mamoru Chiba',
'picture' => 'mamoru_chiba.png'
),
array(
'name' => 'Mitsuyoshi Anzai',
'picture' => 'mitsuyoshi_anzai.png'
),
array(
'name' => 'Rukawa Kaede',
'picture' => 'rukawa_kaede.jpg'
),
array(
'name' => 'Ryoga Hibiki',
'picture' => 'ryoga_hibiki.jpg'
),
array(
'name' => 'Sanosuke Sagara',
'picture' => 'sanosuke_sagara.jpg'
),
array(
'name' => 'Shinji Ikari',
'picture' => 'shinji_ikari.jpg'
),
array(
'name' => 'Spike Spiegel',
'picture' => 'spike_spiegel.jpg'
),
array(
'name' => 'Touya Kinomoto',
'picture' => 'touya_kinomoto.jpg'
),
array(
'name' => 'Tooru Oikawa',
'picture' => 'tooru_oikawa.jpg'
),
array(
'name' => 'Trunks',
'picture' => 'trunks.jpg'
),
array(
'name' => 'Wakasa',
'picture' => 'Wakasa.jpg'
),
array(
'name' => 'Yosuke Hanamura',
'picture' => 'yosuke_hanamura.png'
),
);
$husbando = $husbandos[array_rand($husbandos)];
// Registering a husbando for user
$insert = "INSERT INTO husbandos (username, husbando, married_at, tweet_id) VALUES ('".$screen_name."', '".$husbando['name']."', '".date('Y-m-d H:i:s')."', '".$tweet_id."')";
$result = $dbh->exec($insert);
return $husbando;
} else {
return false;
}
}