forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgallery_cache.php
59 lines (52 loc) · 2.18 KB
/
gallery_cache.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
<?php
use Utils\Uri\Uri;
use lib\Objects\ApplicationContainer;
use lib\Objects\GeoCache\GeoCache;
require_once ('./lib/common.inc.php');
global $hide_coords;
$view = tpl_getView();
$app = ApplicationContainer::Instance();
if (($cache = GeoCache::fromCacheIdFactory($_REQUEST['cacheid'])) === null) {
$view->redirect('/');
exit();
}
// Chceck if gallery should be visible
if (($cache->getStatus() == GeoCache::STATUS_WAITAPPROVERS
|| $cache->getStatus() == GeoCache::STATUS_NOTYETAVAILABLE
|| $cache->getStatus() == GeoCache::STATUS_BLOCKED)
&& ($app->getLoggedUser() === null
|| ($app->getLoggedUser()->getUserId() != $cache->getOwnerId()
&& ! $app->getLoggedUser()->getIsAdmin()))) {
$view->redirect('/');
exit();
}
// Prepare array of log pictures
$params = [];
$query = 'SELECT `pictures`.`url`, `pictures`.`title`, `pictures`.`uuid`, `pictures`.`spoiler`, `pictures`.`object_id`
FROM `pictures`,`cache_logs`
WHERE `pictures`.`object_id`=`cache_logs`.`id` AND `cache_logs`.`deleted` = 0
AND `pictures`.`object_type`= 1
AND `cache_logs`.`cache_id`= :cacheid
ORDER BY `pictures`.`date_created` DESC';
$params['cacheid']['value'] = $cache->getCacheId();
$params['cacheid']['data_type'] = 'integer';
$stmt = $app->db->paramQuery($query, $params);
$logpictures = [];
while ($row = $app->db->dbResultFetch($stmt)) {
$row['url'] = str_replace("images/uploads", "upload", $row['url']);
if ($row['spoiler'] == '1') {
$row['thumbUrl'] = 'tpl/stdstyle/images/thumb/thumbspoiler.gif';
} else {
$row['thumbUrl'] = 'thumbs.php?uuid=' . $row['uuid'];
}
$logpictures[] = $row;
}
$view->setVar('logpictures', $logpictures);
$view->setVar('cachepictures', $cache->getPicturesList(false));
$view->setVar('hidespoilers', ($app->getLoggedUser() === null && $hide_coords));
$view->setVar('cache', $cache);
$view->setVar('cacheicon', $cache->getCacheIcon($app->getLoggedUser()));
$view->addLocalCss(Uri::getLinkWithModificationTime('/tpl/stdstyle/viewcache/viewcache.css'));
$view->loadFancyBox();
$view->setTemplate('gallery_cache');
$view->buildView();