-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_class.php
executable file
·123 lines (100 loc) · 4.09 KB
/
db_class.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
<?php
/**
* CitySearch
*
* An open source application to mine users from Soundcloud
*
* This is based on php-soundcloud available at
* https://github.com/mptre/php-soundcloud
*
*
* 2012 - 2017, gnd
*
*/
class db {
var $link;
var $prfx;
function connect() {
include "sttngs.php";
$this->db = new mysqli($db_host, $db_user, $db_pass, $db_name);
$this->prfx = $db_prfx;
}
function close() {
$this->db->close();
}
function addIgnore($uid, $iid) {
$result = $this->db->query("INSERT INTO " . $this->prfx . "_ignores VALUES(0, $uid, $iid)");
return $result;
}
function delIgnore($uid, $iid) {
$result = $this->db->query("DELETE FROM " . $this->prfx . "_ignores WHERE uid = $uid AND iid = $iid LIMIT 1");
return $result;
}
function getIgnores($uid) {
$result = $this->db->query("SELECT iid FROM " . $this->prfx . "_ignores WHERE uid = $uid");
return $result;
}
function addSeen($uid, $iid) {
$result = $this->db->query("INSERT INTO " . $this->prfx . "_seen VALUES(0, $uid, $iid, '')");
return $result;
}
function delSeen($uid, $iid) {
$result = $this->db->query("DELETE FROM " . $this->prfx . "_seen WHERE uid = $uid AND iid = $iid LIMIT 1");
return $result;
}
function getSeen($uid) {
$result = $this->db->query("SELECT iid, reason FROM " . $this->prfx . "_seen WHERE uid = $uid");
return $result;
}
function addCityAlias($uid, $city, $alias) {
$result = $this->db->query("INSERT INTO " . $this->prfx . "_alias VALUES(0, $uid, '$city', '$alias')");
return $result;
}
function delCityAlias($uid, $aliasid) {
$result = $this->db->query("DELETE FROM " . $this->prfx . "_alias WHERE uid = $uid AND id = '$aliasid' LIMIT 1");
return $result;
}
function getCityAliases($uid) {
$result = $this->db->query("SELECT id, city, alias FROM " . $this->prfx . "_alias WHERE uid = $uid");
return $result;
}
function addCountryAlias($uid, $country, $alias) {
$result = $this->db->query("INSERT INTO " . $this->prfx . "_country_alias VALUES(0, $uid, '$country', '$alias')");
return $result;
}
function delCountryAlias($uid, $aliasid) {
$result = $this->db->query("DELETE FROM " . $this->prfx . "_country_alias WHERE uid = $uid AND id = '$aliasid' LIMIT 1");
return $result;
}
function getCountryAliases($uid) {
$result = $this->db->query("SELECT id, country, alias FROM " . $this->prfx . "_country_alias WHERE uid = $uid");
return $result;
}
// create table ed_sess_status ( id int AUTO_INCREMENT PRIMARY KEY, uid int, status varchar(10), curr_dep int, max_dep int);
function updateSessionStatus($uid, $status, $current_depth, $max_depth) {
$result = $this->db->query("INSERT INTO " . $this->prfx . "_sess_status VALUES(0, $uid, '$status', $current_depth, $max_depth)");
return $result;
}
// create table ed_sess_progress ( id int AUTO_INCREMENT PRIMARY KEY, uid int, progress int);
function updateSessionProgress($uid, $progress) {
$result = $this->db->query("INSERT INTO " . $this->prfx . "_sess_progress VALUES(0, $uid, ".(int)(100*$progress).")");
return $result;
}
function getSessionStatus($uid) {
$result = $this->db->query("SELECT status, curr_dep, max_dep FROM " . $this->prfx . "_sess_status WHERE uid = $uid ORDER BY id DESC LIMIT 1");
return $result;
}
function getSessionProgress($uid) {
$result = $this->db->query("SELECT progress FROM " . $this->prfx . "_sess_progress WHERE uid = $uid ORDER BY id DESC LIMIT 1");
return $result;
}
function clearSessionStatus($uid) {
$result = $this->db->query("DELETE FROM " . $this->prfx . "_sess_status WHERE uid = $uid");
return $result;
}
function clearSessionProgress($uid) {
$result = $this->db->query("DELETE FROM " . $this->prfx . "_sess_progress WHERE uid = $uid");
return $result;
}
}
?>