mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-13 02:46:30 +00:00
Empty commit
This commit is contained in:
parent
468b292ff7
commit
97a5f9ba93
@ -41,7 +41,8 @@ class CACHE extends Memcache {
|
||||
'query_lock_*',
|
||||
'top10votes_*',
|
||||
// 'similar_albums_*',
|
||||
'users_snatched_*'
|
||||
'users_snatched_*',
|
||||
'ajax_requests_*'
|
||||
);
|
||||
|
||||
public $CanClear = false;
|
||||
@ -148,6 +149,12 @@ public function delete_value($Key) {
|
||||
}
|
||||
$this->Time+=(microtime(true)-$StartTime)*1000;
|
||||
}
|
||||
|
||||
public function increment_value($Key,$Value=1) {
|
||||
$StartTime=microtime(true);
|
||||
$this->increment($Key,$Value);
|
||||
$this->Time+=(microtime(true)-$StartTime)*1000;
|
||||
}
|
||||
|
||||
//---------- memcachedb functions ----------//
|
||||
|
||||
|
@ -10,8 +10,33 @@
|
||||
|
||||
enforce_login();
|
||||
|
||||
/* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds.
|
||||
e.g. array(5,10) = 5 requests every 10 seconds */
|
||||
$AJAX_LIMIT = array(5,10);
|
||||
$Limited_Pages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki');
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
// Enforce rate limiting everywhere except info.php
|
||||
if (isset($_GET['action']) && in_array($_GET['action'],$Limited_Pages)) {
|
||||
if (!$userrequests = $Cache->get_value('ajax_requests_'.$UserID)) {
|
||||
$userrequests = 0;
|
||||
$Cache->cache_value('ajax_requests_'.$UserID,'0',$AJAX_LIMIT[1]);
|
||||
}
|
||||
if ($userrequests > $AJAX_LIMIT[0]) {
|
||||
print json_encode(
|
||||
array(
|
||||
'status' => 'failure',
|
||||
'response' => 'Rate limit exceeded.'
|
||||
)
|
||||
);
|
||||
|
||||
die();
|
||||
} else {
|
||||
$Cache->increment_value('ajax_requests_'.$UserID);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($_GET['action']) {
|
||||
// things that (may be) used on the site
|
||||
case 'upload_section':
|
||||
@ -41,6 +66,9 @@
|
||||
case 'torrentgroup':
|
||||
require('torrentgroup.php');
|
||||
break;
|
||||
case 'torrentgroupalbumart': // so the album art script can function without breaking the ratelimit
|
||||
require(SERVER_ROOT . '/sections/ajax/torrentgroupalbumart.php');
|
||||
break;
|
||||
case 'tcomments':
|
||||
require(SERVER_ROOT . '/sections/ajax/tcomments.php');
|
||||
break;
|
||||
|
21
sections/ajax/torrentgroupalbumart.php
Normal file
21
sections/ajax/torrentgroupalbumart.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require(SERVER_ROOT.'/sections/torrents/functions.php');
|
||||
|
||||
$GroupID = (int)$_GET['id'];
|
||||
if ($GroupID == 0) { error('bad id parameter', true); }
|
||||
|
||||
$TorrentDetails = get_group_info($GroupID, true, 0, false);
|
||||
$TorrentDetails = $TorrentDetails[0];
|
||||
$Image = $TorrentDetails['WikiImage'];
|
||||
if (!$Image) { // handle no artwork
|
||||
$Image = STATIC_SERVER.'common/noartwork/'.$CategoryIcons[$TorrentDetails['CategoryID']-1];
|
||||
}
|
||||
|
||||
print json_encode(
|
||||
array(
|
||||
'status' => 'success',
|
||||
'response' => array(
|
||||
'wikiImage' => $Image
|
||||
)
|
||||
)
|
||||
);
|
@ -72,7 +72,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h3>What you will receive for a 5€ or 2 BTC minimum donation</h3>
|
||||
<h3>What you will receive for a 5€ or 0.5 BTC minimum donation</h3>
|
||||
<div class="box pad" style="padding:10px 10px 10px 20px;">
|
||||
<ul>
|
||||
<? if($LoggedUser['Donor']) { ?>
|
||||
|
@ -96,9 +96,9 @@
|
||||
<input type="radio" name="searchtype" value="message" /> Message
|
||||
<span style="float: right;">
|
||||
<? if(empty($_GET['sort']) || $_GET['sort'] != "unread") { ?>
|
||||
[<a href="<?=$CurURL?>sort=unread">List unread first</a>]
|
||||
<a href="<?=$CurURL?>sort=unread" class="brackets">List unread first</a>
|
||||
<? } else { ?>
|
||||
[<a href="<?=$CurURL?>">List latest first</a>]
|
||||
<a href="<?=$CurURL?>" class="brackets">List latest first</a>
|
||||
<? } ?>
|
||||
</span>
|
||||
<br />
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php'); // get_request_tags()
|
||||
|
||||
function get_group_info($GroupID, $Return = true, $RevisionID = 0) {
|
||||
function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProperties = true) {
|
||||
global $Cache, $DB;
|
||||
if (!$RevisionID) {
|
||||
$TorrentCache = $Cache->get_value('torrents_details_'.$GroupID);
|
||||
@ -132,10 +132,12 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0) {
|
||||
$TorrentList = $TorrentCache[1];
|
||||
}
|
||||
|
||||
// Fetch all user specific torrent and group properties
|
||||
$TorrentDetails['Flags'] = array('IsSnatched' => false);
|
||||
foreach ($TorrentList as &$Torrent) {
|
||||
Torrents::torrent_properties($Torrent, $TorrentDetails['Flags']);
|
||||
if ($PersonalProperties) {
|
||||
// Fetch all user specific torrent and group properties
|
||||
$TorrentDetails['Flags'] = array('IsSnatched' => false);
|
||||
foreach ($TorrentList as &$Torrent) {
|
||||
Torrents::torrent_properties($Torrent, $TorrentDetails['Flags']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($Return) {
|
||||
|
@ -749,7 +749,7 @@
|
||||
|
||||
if(!$IsNewGroup) {
|
||||
// maybe there are torrents in the same release as the new torrent. Let's find out (for notifications)
|
||||
$GroupInfo = get_group_info($GroupID);
|
||||
$GroupInfo = get_group_info($GroupID, true, 0, false);
|
||||
|
||||
$ThisMedia = display_str($Properties['Media']);
|
||||
$ThisRemastered = display_str($Properties['Remastered']);
|
||||
|
Loading…
Reference in New Issue
Block a user