1 | <?php |
---|
2 | require_once("db.php"); |
---|
3 | |
---|
4 | class Killboard |
---|
5 | { |
---|
6 | function Killboard($site) |
---|
7 | { |
---|
8 | $this->qry_ = new DBQuery(); |
---|
9 | |
---|
10 | $this->site_ = $site; |
---|
11 | $this->config_ = new Config($site); |
---|
12 | } |
---|
13 | |
---|
14 | function isSuspended() |
---|
15 | { |
---|
16 | $this->execQuery(); |
---|
17 | return $this->row_['rtl_suspended'] == "1"; |
---|
18 | } |
---|
19 | |
---|
20 | function getConfig() |
---|
21 | { |
---|
22 | $this->execQuery(); |
---|
23 | return $this->config_; |
---|
24 | } |
---|
25 | |
---|
26 | function hasCampaigns($active = false) |
---|
27 | { |
---|
28 | $qry = new DBQuery(); |
---|
29 | $sql = "select ctr_id |
---|
30 | from kb3_contracts |
---|
31 | where ctr_campaign = 1 |
---|
32 | and ctr_site = '" . $this->site_ . "'"; |
---|
33 | if ($active) $sql .= " and ctr_ended is null"; |
---|
34 | $qry->execute($sql) or die ($qry->getErrorMessage()); |
---|
35 | return ($qry->recordCount() > 0); |
---|
36 | } |
---|
37 | |
---|
38 | function hasContracts($active = false) |
---|
39 | { |
---|
40 | $qry = new DBQuery(); |
---|
41 | $sql = "select ctr_id |
---|
42 | from kb3_contracts |
---|
43 | where ctr_campaign = 0 |
---|
44 | and ctr_site = '" . $this->site_ . "'"; |
---|
45 | if ($active) $sql .= " and ( ctr_ended is null or now() <= ctr_ended )"; |
---|
46 | $qry->execute($sql) or die ($qry->getErrorMessage()); |
---|
47 | return ($qry->recordCount() > 0); |
---|
48 | } |
---|
49 | |
---|
50 | function execQuery() |
---|
51 | { |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | class Config |
---|
56 | { |
---|
57 | function Config($site) |
---|
58 | { |
---|
59 | $this->qry_ = new DBQuery(); |
---|
60 | $this->sql_ = "select * from kb3_config where cfg_site = '" . $site . "'"; |
---|
61 | |
---|
62 | $this->site_ = $site; |
---|
63 | } |
---|
64 | |
---|
65 | function getStyleName() |
---|
66 | { |
---|
67 | $this->execQuery(); |
---|
68 | return $this->config['style_name']; |
---|
69 | } |
---|
70 | |
---|
71 | function getStyleBanner() |
---|
72 | { |
---|
73 | $this->execQuery(); |
---|
74 | return $this->config['style_banner']; |
---|
75 | } |
---|
76 | |
---|
77 | function getPostPassword() |
---|
78 | { |
---|
79 | $this->execQuery(); |
---|
80 | return $this->config['post_password']; |
---|
81 | } |
---|
82 | |
---|
83 | function getPostMailto() |
---|
84 | { |
---|
85 | $this->execQuery(); |
---|
86 | return $this->config['post_mailto']; |
---|
87 | } |
---|
88 | |
---|
89 | function getKillPoints() |
---|
90 | { |
---|
91 | $this->execQuery(); |
---|
92 | return $this->config['kill_points']; |
---|
93 | } |
---|
94 | |
---|
95 | function getLeastActive() |
---|
96 | { |
---|
97 | $this->execQuery(); |
---|
98 | return $this->config['least_active']; |
---|
99 | } |
---|
100 | |
---|
101 | function getConfig($key) |
---|
102 | { |
---|
103 | $this->execQuery(); |
---|
104 | if (isset($this->config[$key])) |
---|
105 | { |
---|
106 | return $this->config[$key]; |
---|
107 | } |
---|
108 | return 0; |
---|
109 | } |
---|
110 | |
---|
111 | function setConfig($key, $value) |
---|
112 | { |
---|
113 | $qry = new DBQuery(); |
---|
114 | $qry->execute("select cfg_value from kb3_config |
---|
115 | where cfg_key = '" . $key . "' |
---|
116 | and cfg_site = '" . $this->site_ . "'"); |
---|
117 | if ($qry->recordCount()) |
---|
118 | { |
---|
119 | $sql = "update kb3_config |
---|
120 | set cfg_value = '" . $value . "' |
---|
121 | where cfg_site = '" . $this->site_ . "' |
---|
122 | and cfg_key = '" . $key . "'"; |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | $sql = "insert into kb3_config values ( '" . $this->site_ . "', |
---|
127 | '" . $key . "', |
---|
128 | '" . $value . "' )"; |
---|
129 | } |
---|
130 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
131 | $this->config[$key] = $value; |
---|
132 | } |
---|
133 | |
---|
134 | function setStyleName($name) |
---|
135 | { |
---|
136 | $this->setConfig("style_name", $name); |
---|
137 | } |
---|
138 | |
---|
139 | function setStyleBanner($banner) |
---|
140 | { |
---|
141 | $this->setConfig("style_banner", $banner); |
---|
142 | } |
---|
143 | |
---|
144 | function setPostPassword($password) |
---|
145 | { |
---|
146 | $this->setConfig("post_password", $password); |
---|
147 | } |
---|
148 | |
---|
149 | function setPostMailto($mailto) |
---|
150 | { |
---|
151 | $this->setConfig("post_mailto", $mailto); |
---|
152 | } |
---|
153 | |
---|
154 | function setKillPoints($flag) |
---|
155 | { |
---|
156 | $this->setConfig("kill_points", $flag); |
---|
157 | } |
---|
158 | |
---|
159 | function setLeastActive($flag) |
---|
160 | { |
---|
161 | $this->setConfig("least_active", $flag); |
---|
162 | } |
---|
163 | |
---|
164 | function execQuery() |
---|
165 | { |
---|
166 | if (!$this->qry_->executed_) |
---|
167 | { |
---|
168 | $this->qry_->execute($this->sql_); |
---|
169 | |
---|
170 | $this->config = array(); |
---|
171 | while ($row = $this->qry_->getRow()) |
---|
172 | { |
---|
173 | $this->config[$row['cfg_key']] = $row['cfg_value']; |
---|
174 | } |
---|
175 | if (count($this->config) == 0) |
---|
176 | { |
---|
177 | // no config supplied, generate standard one |
---|
178 | |
---|
179 | $this->setConfig('style_name', 'default'); |
---|
180 | $this->setConfig('style_banner', 'default'); |
---|
181 | $this->setConfig('kill_points', 1); |
---|
182 | $this->setConfig('least_active', 0); |
---|
183 | $this->setConfig('post_password', 'CHANGEME'); |
---|
184 | } |
---|
185 | } |
---|
186 | } |
---|
187 | } |
---|
188 | ?> |
---|