-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink.php
111 lines (91 loc) · 3.97 KB
/
link.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
<?php
// Copyright (c) Claus Tondering. E-mail: [email protected].
//
// This code is distributed under an MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require_once 'wrapper.inc.php';
require_once 'database.inc.php';
require_once 'dataexception.inc.php';
require_once 'img.inc.php';
try {
if (!isset($_GET['picno']) || !is_numeric($_GET['picno']))
throw new DataException('Illegal picture number');
$picno = $_GET['picno'];
$res = exec_sql("SELECT * FROM {$db_prefix}photos WHERE pic_no=$picno AND published");
$row = mysqli_fetch_object($res);
if (!$row)
throw new DataException('Illegal picture number');
$allcats = find_allcats();
if (substr($row->description,0,2)=='<p')
$row->longdesc = $row->description;
else
$row->longdesc = shtml('p',$row->description); // Make sure $row->longdesc is embedded in <p>..</p>
$row->longdesc = replace_links($row->longdesc);
$longdescs = array();
$res2 = exec_sql("SELECT * FROM {$db_prefix}piccat WHERE picid=$row->id");
while ($row2 = mysqli_fetch_object($res2)) {
$thiscat = $allcats[$row2->catid];
if ($thiscat->display) {
$catval = find_cat($thiscat->values, is_null($row2->intval) ? $row2->stringval : $row2->intval);
if ($catval) {
if (isset($longdescs[$row2->catid]))
$longdescs[$row2->catid] .= '<br/>' . shtml('b',$thiscat->name . ': ') . $catval->name;
else
$longdescs[$row2->catid] = '<br/>' . shtml('b',$thiscat->name . ': ') . $catval->name;
}
}
}
ksort($longdescs);
foreach ($longdescs as $ld)
$row->longdesc .= $ld;
if (!is_null($row->date))
$row->longdesc .= '<br/>' . shtml('b','Date taken: ') . substr($row->date,0,10);
$res2 = exec_sql("SELECT name from {$db_prefix}authors WHERE $row->pic_no>=range_low AND $row->pic_no<=range_high");
if ($row2 = mysqli_fetch_object($res2))
$row->longdesc .= '<br/>'. shtml('b','Photographer: ') . $row2->name;
}
catch (DataException $e) {
$error = $e->getMessage();
}
?>
<?php
/////////////////////////////////////////////////////////////////////////////
// Start body text
/////////////////////////////////////////////////////////////////////////////
ob_start();
?>
<?php if (isset($error)): ?>
<p class="error"><?= $error ?></p>
<?php else: ?>
<img alt="<?= $row->filename ?>" src="<?= "$dirname_600/$row->filename" ?>" />
<div class="picdesc"><?= $row->longdesc ?></div>
<?php endif; ?>
<?php
$bodytext = ob_get_clean();
/////////////////////////////////////////////////////////////////////////////
// End body text
/////////////////////////////////////////////////////////////////////////////
?>
<?php
wrapme('View Picture',
null,
null,
$bodytext,
array(),
array(),
false);
?>