-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinc.classes.php
More file actions
46 lines (40 loc) · 1.18 KB
/
inc.classes.php
File metadata and controls
46 lines (40 loc) · 1.18 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
<?php
class Image {
public $id, $src, $wins, $losses, $appearances, $rating;
private $exclude;
public function Image($id, $exclude = FALSE) {
if ($id == 'random') {
$exclude = is_numeric($exclude) ? "WHERE `id` <> $exclude" : '';
$sql = "SELECT * FROM `tbl_images` $exclude ORDER BY RAND() LIMIT 1";
$query = mysql_query($sql) or die(mysql_error());
$object = mysql_fetch_object($query);
}
else {
// @todo Hardcoded table name
$query = mysql_query("SELECT * FROM `tbl_images` WHERE `id` = $id LIMIT 1") or die(mysql_error());
$object = mysql_fetch_object($query);
}
$this->id = $object->id;
$this->src = $object->img;
$this->wins = $object->wins;
$this->losses = $object->losses;
$this->appearances = $object->wins + $object->losses;
$this->rating = $object->rating;
}
}
class Message {
public $text, $type;
public function Message($text, $type = 2) {
$this->text = $text;
if ($type == 0) {
$this->type = 'alert-success';
}
elseif ($type == 1) {
$this->type = 'alert-error';
}
else {
$this->type = '';
}
}
}
?>