Gazelle/sections/collages/collage.php

103 lines
2.5 KiB
PHP
Raw Normal View History

2013-07-13 08:00:46 +00:00
<?php
ini_set('max_execution_time', 600);
2012-07-21 08:00:14 +00:00
2011-03-28 14:21:28 +00:00
//~~~~~~~~~~~ Main collage page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2013-05-04 08:00:48 +00:00
function compare($X, $Y) {
2011-03-28 14:21:28 +00:00
return($Y['count'] - $X['count']);
}
2013-05-27 08:00:58 +00:00
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
2012-06-18 08:00:14 +00:00
2011-03-28 14:21:28 +00:00
$Text = new TEXT;
2012-11-02 08:00:18 +00:00
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
2011-03-28 14:21:28 +00:00
$CollageID = $_GET['id'];
2012-11-03 08:00:19 +00:00
if (!is_number($CollageID)) {
error(0);
}
2011-03-28 14:21:28 +00:00
2013-10-29 08:01:29 +00:00
$CacheKey = "collage_$CollageID";
$Data = $Cache->get_value($CacheKey);
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
if ($Data) {
2013-10-29 08:01:29 +00:00
list($K, list($Name, $Description, $NumGroups, , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers)) = each($Data);
2011-03-28 14:21:28 +00:00
} else {
2013-07-13 08:00:46 +00:00
$DB->query("
2013-10-29 08:01:29 +00:00
SELECT
Name,
Description,
UserID,
Deleted,
CategoryID,
Locked,
MaxGroups,
MaxGroupsPerUser,
Updated,
Subscribers
2013-07-13 08:00:46 +00:00
FROM collages
WHERE ID = '$CollageID'");
2013-07-10 00:08:53 +00:00
if ($DB->has_results()) {
2013-06-14 08:18:16 +00:00
list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers) = $DB->next_record();
2013-10-29 08:01:29 +00:00
$NumGroups = null;
2011-03-28 14:21:28 +00:00
} else {
$Deleted = '1';
}
}
2013-07-13 08:00:46 +00:00
if ($Deleted === '1') {
header("Location: log.php?search=Collage+$CollageID");
2011-03-28 14:21:28 +00:00
die();
}
2013-07-13 08:00:46 +00:00
if ($CollageCategoryID === '0' && !check_perms('site_collages_delete')) {
if (!check_perms('site_collages_personal') || $CreatorID !== $LoggedUser['ID']) {
2012-11-03 08:00:19 +00:00
$PreventAdditions = true;
2011-03-28 14:21:28 +00:00
}
}
//Handle subscriptions
2013-04-13 08:00:19 +00:00
if (($CollageSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) === false) {
2013-07-13 08:00:46 +00:00
$DB->query("
SELECT CollageID
FROM users_collage_subs
WHERE UserID = '$LoggedUser[ID]'");
$CollageSubscriptions = $DB->collect(0);
2013-07-13 08:00:46 +00:00
$Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'], $CollageSubscriptions, 0);
}
2013-04-13 08:00:19 +00:00
if (empty($CollageSubscriptions)) {
$CollageSubscriptions = array();
}
2013-08-23 08:00:54 +00:00
if (in_array($CollageID, $CollageSubscriptions)) {
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);
}
2013-07-13 08:00:46 +00:00
$DB->query("
UPDATE users_collage_subs
SET LastVisit = NOW()
WHERE UserID = ".$LoggedUser['ID']."
AND CollageID = $CollageID");
2013-09-08 08:00:57 +00:00
if ((int)$CollageCategoryID === array_search(ARTIST_COLLAGE, $CollageCats)) {
2013-05-25 08:01:03 +00:00
include(SERVER_ROOT.'/sections/collages/artist_collage.php');
2012-10-28 08:00:19 +00:00
} else {
2013-05-25 08:01:03 +00:00
include(SERVER_ROOT.'/sections/collages/torrent_collage.php');
2011-03-28 14:21:28 +00:00
}
2013-10-29 08:01:29 +00:00
$Cache->cache_value($CacheKey, array(array(
$Name,
$Description,
(int)$NumGroups,
null,
$CommentList,
(bool)$Deleted,
(int)$CollageCategoryID,
(int)$CreatorID,
(bool)$Locked,
(int)$MaxGroups,
(int)$MaxGroupsPerUser,
(int)$Subscribers
)), 3600);