1 | <?php |
---|
2 | require_once("config.php"); |
---|
3 | require_once("globals.php"); |
---|
4 | |
---|
5 | class DBConnection |
---|
6 | { |
---|
7 | function DBConnection() |
---|
8 | { |
---|
9 | if (!$this->id_ = mysql_pconnect(DB_HOST, DB_USER, DB_PASS)) |
---|
10 | die("Unable to connect to mysql database."); |
---|
11 | |
---|
12 | mysql_selectdb(DB_NAME); |
---|
13 | } |
---|
14 | |
---|
15 | function id() |
---|
16 | { |
---|
17 | return $this->id_; |
---|
18 | } |
---|
19 | |
---|
20 | function affectedRows() |
---|
21 | { |
---|
22 | return mysql_affected_rows($this->id_); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | class DBQuery |
---|
27 | { |
---|
28 | function DBQuery() |
---|
29 | { |
---|
30 | $this->executed_ = false; |
---|
31 | $this->dbconn_ = new DBConnection; |
---|
32 | } |
---|
33 | |
---|
34 | function execute($sql) |
---|
35 | { |
---|
36 | $t1 = strtok(microtime(), ' ') + strtok(''); |
---|
37 | |
---|
38 | $this->resid_ = mysql_query($sql, $this->dbconn_->id()); |
---|
39 | |
---|
40 | if (!$this->resid_) |
---|
41 | { |
---|
42 | if (defined(DB_HALTONERROR) && DB_HALTONERROR) |
---|
43 | { |
---|
44 | echo "Database error: " . mysql_error($this->dbconn_->id()) . "<br>"; |
---|
45 | echo "SQL: " . $sql . "<br>"; |
---|
46 | exit; |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | return false; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1; |
---|
55 | $this->executed_ = true; |
---|
56 | |
---|
57 | if (KB_PROFILE == 2) |
---|
58 | { |
---|
59 | file_put_contents('/tmp/profile.lst', $sql . "\nExecution time: " . $this->exectime_ . "\n", FILE_APPEND); |
---|
60 | } |
---|
61 | |
---|
62 | return true; |
---|
63 | } |
---|
64 | |
---|
65 | function recordCount() |
---|
66 | { |
---|
67 | return mysql_num_rows($this->resid_); |
---|
68 | } |
---|
69 | |
---|
70 | function getRow() |
---|
71 | { |
---|
72 | $row = mysql_fetch_assoc($this->resid_); |
---|
73 | |
---|
74 | return $row; |
---|
75 | } |
---|
76 | |
---|
77 | function rewind() |
---|
78 | { |
---|
79 | @mysql_data_seek($this->resid_, 0); |
---|
80 | } |
---|
81 | |
---|
82 | function getInsertID() |
---|
83 | { |
---|
84 | return mysql_insert_id(); |
---|
85 | } |
---|
86 | |
---|
87 | function execTime() |
---|
88 | { |
---|
89 | return $this->exectime_; |
---|
90 | } |
---|
91 | |
---|
92 | function executed() |
---|
93 | { |
---|
94 | return $this->executed_; |
---|
95 | } |
---|
96 | |
---|
97 | function getErrorMsg() |
---|
98 | { |
---|
99 | $msg = $this->sql_ . "<br>"; |
---|
100 | $msg .= "Query failed. " . mysql_error($this->dbconn_->id()); |
---|
101 | |
---|
102 | return $msg; |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | class DBAction |
---|
107 | { |
---|
108 | function DBAction() |
---|
109 | { |
---|
110 | $this->dbconn_ = new DBConnection(); |
---|
111 | } |
---|
112 | |
---|
113 | function setDateTime($timestamp) |
---|
114 | { |
---|
115 | $this->timestamp_ = $timestamp; |
---|
116 | } |
---|
117 | |
---|
118 | function addPilot($pilot, $corpid, $timestamp) |
---|
119 | { |
---|
120 | $sql = "select * from kb3_pilots where plt_name = '" . addslashes(stripslashes($pilot)) . "'"; |
---|
121 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
122 | $qry->execute() or die($qry->getErrorMsg()); |
---|
123 | |
---|
124 | if ($qry->recordCount() == 0) |
---|
125 | { |
---|
126 | $sql = "insert into kb3_pilots values ( null, '" . addslashes(stripslashes($pilot)) . "', " . $corpid . ", 0, 0, 0, date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') )"; |
---|
127 | $qry = new DBQuery($this->dbconn_, $sql) or die ($qry->getErrorMsg()); |
---|
128 | $qry->execute() or die($qry->getErrorMsg()); |
---|
129 | $pilotid = $qry->getInsertID(); |
---|
130 | } |
---|
131 | else |
---|
132 | { |
---|
133 | $row = $qry->getRow(); |
---|
134 | $pilotid = $row['plt_id']; |
---|
135 | $dbaction = new DBAction(); |
---|
136 | |
---|
137 | if ($dbaction->isPilotUpdatable($pilotid, $timestamp) && $$row['plt_crp_id'] != $corpid) |
---|
138 | { |
---|
139 | $qry = new DBQuery($this->dbconn_, "update kb3_pilots set plt_crp_id = " . $corpid . ", plt_updated = date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') where plt_id = " . $pilotid); |
---|
140 | $qry->execute() or die($qry->getErrorMsg()); |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | return $pilotid; |
---|
145 | } |
---|
146 | |
---|
147 | function setCharacterId($pilotid, $charid) |
---|
148 | { |
---|
149 | $sql = "update kb3_pilots set plt_externalid = " . $charid . " where plt_id = " . $pilotid; |
---|
150 | |
---|
151 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
152 | $qry->execute(); |
---|
153 | } |
---|
154 | |
---|
155 | function addAlliance($alliance) |
---|
156 | { |
---|
157 | $sql = "select * from kb3_alliances where all_name = '" . addslashes(stripslashes($alliance)) . "'"; |
---|
158 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
159 | $qry->execute() or die($qry->getErrorMsg()); |
---|
160 | |
---|
161 | if ($qry->recordCount() == 0) |
---|
162 | { |
---|
163 | $sql = "insert into kb3_alliances values ( null, '" . addslashes(stripslashes($alliance)) . "', 'default' )"; |
---|
164 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
165 | $qry->execute() or die($qry->getErrorMsg()); |
---|
166 | $allianceid = $qry->getInsertID(); |
---|
167 | } |
---|
168 | else |
---|
169 | { |
---|
170 | $row = $qry->getRow(); |
---|
171 | $allianceid = $row['all_id']; |
---|
172 | } |
---|
173 | |
---|
174 | return $allianceid; |
---|
175 | } |
---|
176 | |
---|
177 | function addCorp($corp, $allianceid, $timestamp) |
---|
178 | { |
---|
179 | $sql = "select * from kb3_corps where crp_name = '" . addslashes(stripslashes($corp)) . "'"; |
---|
180 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
181 | $qry->execute() or die($qry->getErrorMsg()); |
---|
182 | |
---|
183 | if ($qry->recordCount() == 0) |
---|
184 | { |
---|
185 | $sql = "insert into kb3_corps values ( null, '" . addslashes(stripslashes($corp)) . "', " . $allianceid . ", 0, date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') )"; |
---|
186 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
187 | $qry->execute() or die($qry->getErrorMsg()); |
---|
188 | $corpid = $qry->getInsertID(); |
---|
189 | } |
---|
190 | else |
---|
191 | { |
---|
192 | $row = $qry->getRow(); |
---|
193 | $corpid = $row['crp_id']; |
---|
194 | |
---|
195 | $dbaction = new DBAction(); |
---|
196 | |
---|
197 | if ($dbaction->isCorpUpdatable($corpid, $timestamp) && $row['crp_all_id'] != $allianceid && $row['crp_trial'] != 1) |
---|
198 | { |
---|
199 | $sql = "update kb3_corps set crp_all_id = " . $allianceid . ", crp_updated = date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') |
---|
200 | where crp_id = " . $corpid; |
---|
201 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
202 | $qry->execute() or die($qry->getErrorMsg()); |
---|
203 | } |
---|
204 | } |
---|
205 | |
---|
206 | return $corpid; |
---|
207 | } |
---|
208 | |
---|
209 | function addShip($ship, $description, $baseprice) |
---|
210 | { |
---|
211 | $sql = "select * from kb3_ships where shp_name = '" . addslashes(stripslashes($ship)) . "'"; |
---|
212 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
213 | $qry->execute(); |
---|
214 | |
---|
215 | if ($qry->recordCount() == 0) |
---|
216 | { |
---|
217 | $sql = "insert into kb3_ships values ( null, '" . addslashes(stripslashes($ship)) . "', 0, 0, 0, null, 0 )"; |
---|
218 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
219 | $qry->execute(); |
---|
220 | $shipid = $qry->getInsertID(); |
---|
221 | } |
---|
222 | else |
---|
223 | { |
---|
224 | $row = $qry->getRow(); |
---|
225 | $shipid = $row['shp_id']; |
---|
226 | if ($description != "") |
---|
227 | { |
---|
228 | $sql = "update kb3_ships set shp_description = '" . addslashes(stripslashes($description)) . "', shp_baseprice = " . $baseprice . " where shp_id = " . $shipid; |
---|
229 | $qry = new DBQuery($this->dbconn_, $sql) or die($qry->getErrorMsg()); |
---|
230 | $qry->execute(); |
---|
231 | } |
---|
232 | } |
---|
233 | |
---|
234 | return $shipid; |
---|
235 | } |
---|
236 | |
---|
237 | function addItem($item, $description, $volume, $type, $icon) |
---|
238 | { |
---|
239 | $sql = "select * from kb3_items where itm_name = '" . addslashes(stripslashes($item)) . "'"; |
---|
240 | $qry = new DBQuery($this->dbconn_, $sql) or die ($qry->getErrorMsg()); |
---|
241 | $qry->execute(); |
---|
242 | |
---|
243 | if ($qry->recordCount() == 0) |
---|
244 | { |
---|
245 | $sql = "insert into kb3_items values ( null, '" . addslashes(stripslashes($item)) . "', '" . addslashes(stripslashes($description)) . "', " . $volume . ", " . $type . ", null, 1, '" . $icon . "' )"; |
---|
246 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
247 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
248 | $itemid = $qry->getInsertID(); |
---|
249 | return -1; |
---|
250 | } |
---|
251 | else |
---|
252 | { |
---|
253 | $row = $qry->getRow(); |
---|
254 | $itemid = $row['itm_id']; |
---|
255 | if ($description != "") |
---|
256 | { |
---|
257 | $sql = "update kb3_items set itm_description = '" . addslashes(stripslashes($description)) . "', itm_volume = " . $volume . ", itm_type = " . $type . ", itm_icon = '" . $icon . "' where itm_id = " . $itemid; |
---|
258 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
259 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | return $itemid; |
---|
264 | } |
---|
265 | |
---|
266 | function setIcon($itemid, $icon) |
---|
267 | { |
---|
268 | $sql = "update kb3_items set itm_icon = '" . $icon . "' where itm_id = " . $itemid; |
---|
269 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
270 | $qry->execute(); |
---|
271 | } |
---|
272 | |
---|
273 | function addSystem($system, $systemsec) |
---|
274 | { |
---|
275 | $sql = "select * from kb3_systems where sys_name = '" . addslashes(stripslashes($system)) . "'"; |
---|
276 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
277 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
278 | |
---|
279 | if ($qry->recordCount() == 0) |
---|
280 | { |
---|
281 | $sql = "insert into kb3_systems values ( null, '" . addslashes(stripslashes($system)) . "', '" . $systemsec . "', 0 )"; |
---|
282 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
283 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
284 | $systemid = $qry->getInsertID(); |
---|
285 | } |
---|
286 | else |
---|
287 | { |
---|
288 | $row = $qry->getRow(); |
---|
289 | $systemid = $row['sys_id']; |
---|
290 | } |
---|
291 | |
---|
292 | return $systemid; |
---|
293 | } |
---|
294 | |
---|
295 | function addInvolved($killid, $pilotid, $secstatus, $allianceid, $corpid, $shipid, $weaponid, $finalblow, $order) |
---|
296 | { |
---|
297 | $sql = "insert into _" . KB_SITE . "_involved values ( " . $killid . ", " . $pilotid . ", '" . $secstatus . "', " . $allianceid . ", " . $corpid . ", " . $shipid . ", " . $weaponid . ", " . $finalblow . ", " . $order . " )"; |
---|
298 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
299 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
300 | } |
---|
301 | |
---|
302 | function addDestroyedItem($killid, $itemid, $quantity, $location) |
---|
303 | { |
---|
304 | $qry = new DBQuery($this->dbconn_, "select itl_id from kb3_item_locations where itl_location = '" . $location . "'"); |
---|
305 | $qry->execute() or die($qry->getErrorMsg()); |
---|
306 | $row = $qry->getRow(); |
---|
307 | if ($row['itl_id'] != "") |
---|
308 | $locationid = $row['itl_id']; |
---|
309 | else |
---|
310 | $locationid = 0; |
---|
311 | |
---|
312 | $sql = "insert into _" . KB_SITE . "_items_destroyed values ( " . $killid . ", " . $itemid . ", " . $quantity . ", " . $locationid . " )"; |
---|
313 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
314 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
315 | } |
---|
316 | |
---|
317 | function addKill($timestamp, $victimid, $allianceid, $corpid, $shipid, $systemid) |
---|
318 | { |
---|
319 | $killid = 0; |
---|
320 | // check if the killmail already exists |
---|
321 | $sql = "select * from _" . KB_SITE . "_kills where kll_timestamp = date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') and kll_victim_id = " . $victimid . " and kll_ship_id = " . $shipid; |
---|
322 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
323 | $qry->execute(); |
---|
324 | |
---|
325 | if ($qry->recordCount() == 0) |
---|
326 | { |
---|
327 | $sql = "insert into _" . KB_SITE . "_kills values ( null, date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s'), " . $victimid . ", " . $allianceid . ", " . $corpid . ", " . $shipid . ", " . $systemid . " )"; |
---|
328 | $qry = new DBQuery($this->dbconn_, $sql); |
---|
329 | $qry->execute() or die ($qry->getErrorMsg()); |
---|
330 | $killid = $qry->getInsertID(); |
---|
331 | // log entry |
---|
332 | // $sql = "insert into kb3_log values ( ".$killid.", '".$_SERVER['REMOTE_ADDR']."', now() )"; |
---|
333 | // $qry = new DBQuery( $this->dbconn_, $sql ); |
---|
334 | // $qry->execute() or die ( $qry->getErrorMsg() ); |
---|
335 | } |
---|
336 | |
---|
337 | return $killid; |
---|
338 | } |
---|
339 | |
---|
340 | function rollback($killid) |
---|
341 | { |
---|
342 | $qry = new DBQuery($this->dbconn_, "delete from _" . KB_SITE . "_kills where kll_id = " . $killid); |
---|
343 | $qry->execute(); |
---|
344 | |
---|
345 | $qry = new DBQuery($this->dbconn_, "delete from _" . KB_SITE . "_involved where inv_kll_id = " . $killid); |
---|
346 | $qry->execute(); |
---|
347 | |
---|
348 | $qry = new DBQuery($this->dbconn_, "delete from _" . KB_SITE . "_items_destroyed where itd_kll_id = " . $killid); |
---|
349 | $qry->execute(); |
---|
350 | } |
---|
351 | |
---|
352 | function getRawMail($killid, $site = "") |
---|
353 | { |
---|
354 | if ($site == "") |
---|
355 | $site = KB_SITE; |
---|
356 | $sql = "select kll.kll_timestamp, plt.plt_id, plt.plt_name, plt.plt_externalid, crp.crp_id, crp.crp_name, ali.all_id, ali.all_name, shp.shp_name, shp.shp_externalid, scl.scl_class, sys.sys_name, sys.sys_sec, kll.kll_system_id |
---|
357 | from _" . $site . "_kills kll, kb3_pilots plt, kb3_corps crp, |
---|
358 | kb3_alliances ali, kb3_ships shp, kb3_ship_classes scl, |
---|
359 | kb3_systems sys |
---|
360 | where kll.kll_id = " . $killid . " |
---|
361 | and plt.plt_id = kll.kll_victim_id |
---|
362 | and crp.crp_id = kll.kll_crp_id |
---|
363 | and ali.all_id = kll.kll_all_id |
---|
364 | and shp.shp_id = kll.kll_ship_id |
---|
365 | and sys.sys_id = kll.kll_system_id |
---|
366 | and scl.scl_id = shp.shp_class"; |
---|
367 | |
---|
368 | $qry = new DBQuery(); |
---|
369 | if (!$qry->execute($sql)) die($qry->getErrorMsg()); |
---|
370 | $row = $qry->getRow(); |
---|
371 | |
---|
372 | $mail .= substr(str_replace('-', '.' , $row['kll_timestamp']), 0, 16) . "\r\n\r\n"; |
---|
373 | $mail .= "Victim: " . $row['plt_name'] . "\r\n"; |
---|
374 | $mail .= "Alliance: " . $row['all_name'] . "\r\n"; |
---|
375 | $mail .= "Corp: " . $row['crp_name'] . "\r\n"; |
---|
376 | $mail .= "Destroyed: " . $row['shp_name'] . "\r\n"; |
---|
377 | $mail .= "System: " . $row['sys_name'] . "\r\n"; |
---|
378 | $mail .= "Security: " . roundsec($row['sys_sec']) . "\r\n\r\n"; |
---|
379 | $mail .= "Involved parties:\r\n\r\n"; |
---|
380 | |
---|
381 | $sql = "select plt.plt_id, plt.plt_name, plt.plt_externalid, crp.crp_name, ali.all_name, shp.shp_name, shp.shp_externalid, scl.scl_class, |
---|
382 | inv.inv_final_blow, itm.itm_name, inv.inv_sec_status |
---|
383 | from _" . $site . "_involved inv, kb3_pilots plt, kb3_corps crp, kb3_alliances ali, |
---|
384 | kb3_ships shp, kb3_ship_classes scl, kb3_items itm |
---|
385 | where inv.inv_kll_id = " . $killid . " |
---|
386 | and plt.plt_id = inv.inv_plt_id |
---|
387 | and crp.crp_id = inv.inv_crp_id |
---|
388 | and ali.all_id = inv.inv_all_id |
---|
389 | and shp.shp_id = inv.inv_shp_id |
---|
390 | and scl.scl_id = shp.shp_class |
---|
391 | and itm.itm_id = inv.inv_wep_id |
---|
392 | order by inv.inv_order"; |
---|
393 | |
---|
394 | $qry = new DBQuery(); |
---|
395 | $qry->execute($sql); |
---|
396 | |
---|
397 | while ($row = $qry->getRow()) |
---|
398 | { |
---|
399 | $mail .= "Name: " . $row['plt_name']; |
---|
400 | if ($row['inv_final_blow'] == 1) |
---|
401 | $mail .= " (laid the final blow)"; |
---|
402 | $mail .= "\r\n"; |
---|
403 | |
---|
404 | $mail .= "Security: " . $row['inv_sec_status'] . "\r\n"; |
---|
405 | $mail .= "Alliance: " . $row['all_name'] . "\r\n"; |
---|
406 | $mail .= "Corp: " . $row['crp_name'] . "\r\n"; |
---|
407 | $mail .= "Ship: " . $row['shp_name'] . "\r\n"; |
---|
408 | $mail .= "Weapon: " . $row['itm_name'] . "\r\n\r\n"; |
---|
409 | } |
---|
410 | |
---|
411 | $sql = "select itd_quantity, itm.itm_name, itd.itd_itl_id |
---|
412 | from _" . $site . "_items_destroyed itd, kb3_items itm |
---|
413 | where itd.itd_kll_id = " . $killid . " |
---|
414 | and itm.itm_id = itd.itd_itm_id |
---|
415 | order by itd.itd_itl_id"; |
---|
416 | |
---|
417 | $qry = new DBQuery(); |
---|
418 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
419 | |
---|
420 | if ($qry->recordCount()) |
---|
421 | { |
---|
422 | $mail .= "\r\nDestroyed items:\r\n\r\n"; |
---|
423 | |
---|
424 | while ($row = $qry->getRow()) |
---|
425 | { |
---|
426 | $mail .= $row['itm_name']; |
---|
427 | if ($row['itd_quantity'] > 1) |
---|
428 | $mail .= ", Qty: " . $row['itd_quantity']; |
---|
429 | if ($row['itd_itl_id'] == 4) // cargo |
---|
430 | $mail .= " (Cargo)"; |
---|
431 | if ($row['itd_itl_id'] == 6) // drone |
---|
432 | $mail .= " (Drone Bay)"; |
---|
433 | $mail .= "\r\n"; |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | return $mail; |
---|
438 | } |
---|
439 | |
---|
440 | function getPostPassword() |
---|
441 | { |
---|
442 | $qry = new DBQuery($this->dbconn_, "select cfg_value from kb3_config where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_password'"); |
---|
443 | $qry->execute(); |
---|
444 | $row = $qry->getRow(); |
---|
445 | |
---|
446 | return $row['cfg_value']; |
---|
447 | } |
---|
448 | |
---|
449 | function getPostMailto() |
---|
450 | { |
---|
451 | $qry = new DBQuery($this->dbconn_, "select cfg_value from kb3_config where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_mailto'"); |
---|
452 | $qry->execute(); |
---|
453 | $row = $qry->getRow(); |
---|
454 | |
---|
455 | return $row['cfg_value']; |
---|
456 | } |
---|
457 | |
---|
458 | function setPostPassword($password) |
---|
459 | { |
---|
460 | $qry = new DBQuery($this->dbconn_, "update kb3_config set cfg_value = '" . $password . "' where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_password'"); |
---|
461 | $qry->execute(); |
---|
462 | } |
---|
463 | |
---|
464 | function setPostMailto($mailto) |
---|
465 | { |
---|
466 | $qry = new DBQuery($this->dbconn_, "update kb3_config set cfg_value = '" . $mailto . "' where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_mailto'"); |
---|
467 | $qry->execute(); |
---|
468 | } |
---|
469 | |
---|
470 | function isCorpUpdatable($crp_id, $timestamp) |
---|
471 | { |
---|
472 | $qry = new DBQuery($this->dbconn_, |
---|
473 | "select crp_id from kb3_corps |
---|
474 | where crp_id = " . $crp_id . " |
---|
475 | and ( crp_updated < date_format('" . $timestamp . "', '%Y.%m.%d %H:%i') or crp_updated is null )"); |
---|
476 | $qry->execute() or die($qry->getErrorMsg()); |
---|
477 | return $qry->recordCount(); |
---|
478 | } |
---|
479 | |
---|
480 | function isPilotUpdatable($plt_id, $timestamp) |
---|
481 | { |
---|
482 | $qry = new DBQuery($this->dbconn_, |
---|
483 | "select plt_id from kb3_pilots |
---|
484 | where plt_id = " . $plt_id . " |
---|
485 | and ( plt_updated < date_format('" . $timestamp . "', '%Y.%m.%d %H:%i') or plt_updated is null )"); |
---|
486 | $qry->execute() or die($qry->getErrorMsg()); |
---|
487 | |
---|
488 | return $qry->recordCount(); |
---|
489 | } |
---|
490 | } |
---|
491 | ?> |
---|