mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-14 11:26:26 +00:00
Empty commit
This commit is contained in:
parent
468b292ff7
commit
97a5f9ba93
@ -41,7 +41,8 @@ class CACHE extends Memcache {
|
|||||||
'query_lock_*',
|
'query_lock_*',
|
||||||
'top10votes_*',
|
'top10votes_*',
|
||||||
// 'similar_albums_*',
|
// 'similar_albums_*',
|
||||||
'users_snatched_*'
|
'users_snatched_*',
|
||||||
|
'ajax_requests_*'
|
||||||
);
|
);
|
||||||
|
|
||||||
public $CanClear = false;
|
public $CanClear = false;
|
||||||
@ -149,6 +150,12 @@ public function delete_value($Key) {
|
|||||||
$this->Time+=(microtime(true)-$StartTime)*1000;
|
$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 ----------//
|
//---------- memcachedb functions ----------//
|
||||||
|
|
||||||
public function begin_transaction($Key) {
|
public function begin_transaction($Key) {
|
||||||
|
@ -10,8 +10,33 @@
|
|||||||
|
|
||||||
enforce_login();
|
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');
|
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']) {
|
switch ($_GET['action']) {
|
||||||
// things that (may be) used on the site
|
// things that (may be) used on the site
|
||||||
case 'upload_section':
|
case 'upload_section':
|
||||||
@ -41,6 +66,9 @@
|
|||||||
case 'torrentgroup':
|
case 'torrentgroup':
|
||||||
require('torrentgroup.php');
|
require('torrentgroup.php');
|
||||||
break;
|
break;
|
||||||
|
case 'torrentgroupalbumart': // so the album art script can function without breaking the ratelimit
|
||||||
|
require(SERVER_ROOT . '/sections/ajax/torrentgroupalbumart.php');
|
||||||
|
break;
|
||||||
case 'tcomments':
|
case 'tcomments':
|
||||||
require(SERVER_ROOT . '/sections/ajax/tcomments.php');
|
require(SERVER_ROOT . '/sections/ajax/tcomments.php');
|
||||||
break;
|
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>
|
</form>
|
||||||
</div>
|
</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;">
|
<div class="box pad" style="padding:10px 10px 10px 20px;">
|
||||||
<ul>
|
<ul>
|
||||||
<? if($LoggedUser['Donor']) { ?>
|
<? if($LoggedUser['Donor']) { ?>
|
||||||
|
@ -96,9 +96,9 @@
|
|||||||
<input type="radio" name="searchtype" value="message" /> Message
|
<input type="radio" name="searchtype" value="message" /> Message
|
||||||
<span style="float: right;">
|
<span style="float: right;">
|
||||||
<? if(empty($_GET['sort']) || $_GET['sort'] != "unread") { ?>
|
<? 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 { ?>
|
<? } else { ?>
|
||||||
[<a href="<?=$CurURL?>">List latest first</a>]
|
<a href="<?=$CurURL?>" class="brackets">List latest first</a>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?
|
<?
|
||||||
include(SERVER_ROOT.'/sections/requests/functions.php'); // get_request_tags()
|
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;
|
global $Cache, $DB;
|
||||||
if (!$RevisionID) {
|
if (!$RevisionID) {
|
||||||
$TorrentCache = $Cache->get_value('torrents_details_'.$GroupID);
|
$TorrentCache = $Cache->get_value('torrents_details_'.$GroupID);
|
||||||
@ -132,11 +132,13 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0) {
|
|||||||
$TorrentList = $TorrentCache[1];
|
$TorrentList = $TorrentCache[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($PersonalProperties) {
|
||||||
// Fetch all user specific torrent and group properties
|
// Fetch all user specific torrent and group properties
|
||||||
$TorrentDetails['Flags'] = array('IsSnatched' => false);
|
$TorrentDetails['Flags'] = array('IsSnatched' => false);
|
||||||
foreach ($TorrentList as &$Torrent) {
|
foreach ($TorrentList as &$Torrent) {
|
||||||
Torrents::torrent_properties($Torrent, $TorrentDetails['Flags']);
|
Torrents::torrent_properties($Torrent, $TorrentDetails['Flags']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($Return) {
|
if ($Return) {
|
||||||
return array($TorrentDetails, $TorrentList);
|
return array($TorrentDetails, $TorrentList);
|
||||||
|
@ -749,7 +749,7 @@
|
|||||||
|
|
||||||
if(!$IsNewGroup) {
|
if(!$IsNewGroup) {
|
||||||
// maybe there are torrents in the same release as the new torrent. Let's find out (for notifications)
|
// 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']);
|
$ThisMedia = display_str($Properties['Media']);
|
||||||
$ThisRemastered = display_str($Properties['Remastered']);
|
$ThisRemastered = display_str($Properties['Remastered']);
|
||||||
|
Loading…
Reference in New Issue
Block a user