-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrandom_image.php
More file actions
130 lines (103 loc) · 3.21 KB
/
random_image.php
File metadata and controls
130 lines (103 loc) · 3.21 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
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
<?
// message board image browser v.3
// include the configuration file
require('config.inc.php');
// overwrite the title
$config[title] = "Riceboy Image Browser";
// establish a connection with the database or notify an admin with the error string
$mysqli_link = mysqli_connect($config['db_host'],$config['db_user'],$config['db_pass'],$config['db_name']) or error($config[db_errstr],$config[admin_email],"mysqli_connect($config[db_host],$config[db_user],$config[db_pass])\n".mysqli_error());
// handle authentication if necessary
if ($config[auth_required] == true) {
// begin a session
session_start();
if (isset($_SESSION[username]) && isset($_SESSION[password])) {
$query = "select username from $locations[auth_table] where username = '$_SESSION[username]' and password = '$_SESSION[password]'";
$result = mysqli_query($mysqli_link, $query) or error($config[db_errstr],$config[admin_email],$query."\n".mysqli_error());
if (mysqli_num_rows($result) != 1) {
// destroy the erroneous session
session_destroy();
// leave
header("Location: $locations[login]");
exit();
}
} else {
// leave
header("Location: $locations[login]");
exit();
}
}
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
<head>
<title><?=$config[title]?></title>
<link rel="stylesheet" type="text/css" href="<?=$locations[css]?>">
<script language="Javascript" type="text/javascript">
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
}
</script>
<style type="text/css">
img {
float: left;
}
img:hover {
width: auto;
height: auto;
}
</style>
</head>
<body class='body'>
<?
$query = 'select * from ' . $locations['images_table'] . ' order by rand() limit 100';
$result = mysqli_query($mysqli_link, $query) or error($config[db_errstr],$config[admin_email],$query."\n".mysqli_error());
if (mysqli_num_rows($result) == 0) {
?>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class='borderoutline'>
<table width='100%' border='0' cellspacing='1' cellpadding='4'>
<tr class='titlelarge'>
<td colspan='2'>No images to display.</td>
</tr>
<tr class='main'>
<td colspan='2'><a href='<?=$locations[forum]?>'>Back to the Forum</a></td>
</tr>
<tr class='main'>
<td colspan='2'>
<blockquote>
<?
} else {
?>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class='borderoutline'>
<table width='100%' border='0' cellspacing='1' cellpadding='4'>
<tr class='main'>
<td colspan='2'>
<a href='<?=$locations[forum]?>'>Back to the Forum</a>
</td>
</tr>
<tr class='main'>
<td colspan='2'>
<?
while ($row = mysqli_fetch_array($result)) {
?>
<a href='<? print "$locations[forum]?d=$row[id]&t=" . (strlen($row[t]) == 5 ? '0' . $row[t] : $row[t]); ?>'><img src='<?=$row[image_url]?>' border='0' alt=''></a>
<?
}
}
?>
</td>
</tr>
</blockquote>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>