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
db7ddd0378
commit
3e3fdfb804
@ -1,2 +0,0 @@
|
|||||||
<?
|
|
||||||
require('classes/script_start.php');
|
|
@ -6,23 +6,25 @@ function convert($str) {
|
|||||||
|
|
||||||
//Alternative approach with potential.
|
//Alternative approach with potential.
|
||||||
function flush() {
|
function flush() {
|
||||||
global $Cache, $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT Alias, ArticleID
|
SELECT Alias, ArticleID
|
||||||
FROM wiki_aliases");
|
FROM wiki_aliases");
|
||||||
$Aliases = $DB->to_array('Alias');
|
$Aliases = G::$DB->to_array('Alias');
|
||||||
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
||||||
}
|
}
|
||||||
|
|
||||||
function to_id($Alias) {
|
function to_id($Alias) {
|
||||||
global $Cache, $DB;
|
$Aliases = G::$Cache->get_value('wiki_aliases');
|
||||||
$Aliases = $Cache->get_value('wiki_aliases');
|
|
||||||
if (!$Aliases) {
|
if (!$Aliases) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT Alias, ArticleID
|
SELECT Alias, ArticleID
|
||||||
FROM wiki_aliases");
|
FROM wiki_aliases");
|
||||||
$Aliases = $DB->to_array('Alias');
|
$Aliases = G::$DB->to_array('Alias');
|
||||||
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
||||||
}
|
}
|
||||||
return $Aliases[$this->convert($Alias)]['ArticleID'];
|
return $Aliases[$this->convert($Alias)]['ArticleID'];
|
||||||
}
|
}
|
||||||
@ -32,21 +34,20 @@ function flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function to_id($Alias) {
|
function to_id($Alias) {
|
||||||
global $DB;
|
|
||||||
$Alias = $this->convert($Alias);
|
$Alias = $this->convert($Alias);
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT ArticleID
|
SELECT ArticleID
|
||||||
FROM wiki_aliases
|
FROM wiki_aliases
|
||||||
WHERE Alias LIKE '$Alias'");
|
WHERE Alias LIKE '$Alias'");
|
||||||
list($ArticleID) = $DB->next_record();
|
list($ArticleID) = G::$DB->next_record();
|
||||||
return $ArticleID;
|
return $ArticleID;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
function article($ArticleID, $Error = true) {
|
function article($ArticleID, $Error = true) {
|
||||||
global $Cache, $DB;
|
$Contents = G::$Cache->get_value('wiki_article_'.$ArticleID);
|
||||||
$Contents = $Cache->get_value('wiki_article_'.$ArticleID);
|
|
||||||
if (!$Contents) {
|
if (!$Contents) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
w.Revision,
|
w.Revision,
|
||||||
w.Title,
|
w.Title,
|
||||||
@ -63,11 +64,12 @@ function article($ArticleID, $Error = true) {
|
|||||||
LEFT JOIN users_main AS u ON u.ID=w.Author
|
LEFT JOIN users_main AS u ON u.ID=w.Author
|
||||||
WHERE w.ID='$ArticleID'
|
WHERE w.ID='$ArticleID'
|
||||||
GROUP BY w.ID");
|
GROUP BY w.ID");
|
||||||
if (!$DB->has_results() && $Error) {
|
if (!G::$DB->has_results() && $Error) {
|
||||||
error(404);
|
error(404);
|
||||||
}
|
}
|
||||||
$Contents = $DB->to_array();
|
$Contents = G::$DB->to_array();
|
||||||
$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600 * 24 * 14); // 2 weeks
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600 * 24 * 14); // 2 weeks
|
||||||
}
|
}
|
||||||
return $Contents;
|
return $Contents;
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,13 @@ class Artists {
|
|||||||
* 6 => DJ
|
* 6 => DJ
|
||||||
*/
|
*/
|
||||||
public static function get_artists($GroupIDs) {
|
public static function get_artists($GroupIDs) {
|
||||||
global $Cache, $DB;
|
|
||||||
$Results = array();
|
$Results = array();
|
||||||
$DBs = array();
|
$DBs = array();
|
||||||
foreach ($GroupIDs as $GroupID) {
|
foreach ($GroupIDs as $GroupID) {
|
||||||
if (!is_number($GroupID)) {
|
if (!is_number($GroupID)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$Artists = $Cache->get_value('groups_artists_'.$GroupID);
|
$Artists = G::$Cache->get_value('groups_artists_'.$GroupID);
|
||||||
if (is_array($Artists)) {
|
if (is_array($Artists)) {
|
||||||
$Results[$GroupID] = $Artists;
|
$Results[$GroupID] = $Artists;
|
||||||
} else {
|
} else {
|
||||||
@ -37,7 +36,8 @@ public static function get_artists($GroupIDs) {
|
|||||||
if (empty($IDs)) {
|
if (empty($IDs)) {
|
||||||
$IDs = "null";
|
$IDs = "null";
|
||||||
}
|
}
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT ta.GroupID,
|
SELECT ta.GroupID,
|
||||||
ta.ArtistID,
|
ta.ArtistID,
|
||||||
aa.Name,
|
aa.Name,
|
||||||
@ -49,16 +49,17 @@ public static function get_artists($GroupIDs) {
|
|||||||
ORDER BY ta.GroupID ASC,
|
ORDER BY ta.GroupID ASC,
|
||||||
ta.Importance ASC,
|
ta.Importance ASC,
|
||||||
aa.Name ASC;");
|
aa.Name ASC;");
|
||||||
while (list($GroupID, $ArtistID, $ArtistName, $ArtistImportance, $AliasID) = $DB->next_record(MYSQLI_BOTH, false)) {
|
while (list($GroupID, $ArtistID, $ArtistName, $ArtistImportance, $AliasID) = G::$DB->next_record(MYSQLI_BOTH, false)) {
|
||||||
$Results[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID);
|
$Results[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID);
|
||||||
$New[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID);
|
$New[$GroupID][$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName, 'aliasid' => $AliasID);
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
foreach ($DBs as $GroupID) {
|
foreach ($DBs as $GroupID) {
|
||||||
if (isset($New[$GroupID])) {
|
if (isset($New[$GroupID])) {
|
||||||
$Cache->cache_value('groups_artists_'.$GroupID, $New[$GroupID]);
|
G::$Cache->cache_value('groups_artists_'.$GroupID, $New[$GroupID]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Cache->cache_value('groups_artists_'.$GroupID, array());
|
G::$Cache->cache_value('groups_artists_'.$GroupID, array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$Missing = array_diff($GroupIDs, array_keys($Results));
|
$Missing = array_diff($GroupIDs, array_keys($Results));
|
||||||
@ -216,50 +217,53 @@ public static function display_artist($Artist, $MakeLink = true, $Escape = true)
|
|||||||
* @param int $ArtistID
|
* @param int $ArtistID
|
||||||
*/
|
*/
|
||||||
public static function delete_artist($ArtistID) {
|
public static function delete_artist($ArtistID) {
|
||||||
global $DB, $LoggedUser, $Cache;
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
$DB->query("
|
|
||||||
SELECT Name
|
SELECT Name
|
||||||
FROM artists_group
|
FROM artists_group
|
||||||
WHERE ArtistID = ".$ArtistID);
|
WHERE ArtistID = ".$ArtistID);
|
||||||
list($Name) = $DB->next_record(MYSQLI_NUM, false);
|
list($Name) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
|
|
||||||
// Delete requests
|
// Delete requests
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT RequestID
|
SELECT RequestID
|
||||||
FROM requests_artists
|
FROM requests_artists
|
||||||
WHERE ArtistID = $ArtistID
|
WHERE ArtistID = $ArtistID
|
||||||
AND ArtistID != 0");
|
AND ArtistID != 0");
|
||||||
$Requests = $DB->to_array();
|
$Requests = G::$DB->to_array();
|
||||||
foreach ($Requests AS $Request) {
|
foreach ($Requests AS $Request) {
|
||||||
list($RequestID) = $Request;
|
list($RequestID) = $Request;
|
||||||
$DB->query('DELETE FROM requests WHERE ID='.$RequestID);
|
G::$DB->query('DELETE FROM requests WHERE ID='.$RequestID);
|
||||||
$DB->query('DELETE FROM requests_votes WHERE RequestID='.$RequestID);
|
G::$DB->query('DELETE FROM requests_votes WHERE RequestID='.$RequestID);
|
||||||
$DB->query('DELETE FROM requests_tags WHERE RequestID='.$RequestID);
|
G::$DB->query('DELETE FROM requests_tags WHERE RequestID='.$RequestID);
|
||||||
$DB->query('DELETE FROM requests_artists WHERE RequestID='.$RequestID);
|
G::$DB->query('DELETE FROM requests_artists WHERE RequestID='.$RequestID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete artist
|
// Delete artist
|
||||||
$DB->query('DELETE FROM artists_group WHERE ArtistID='.$ArtistID);
|
G::$DB->query('DELETE FROM artists_group WHERE ArtistID='.$ArtistID);
|
||||||
$DB->query('DELETE FROM artists_alias WHERE ArtistID='.$ArtistID);
|
G::$DB->query('DELETE FROM artists_alias WHERE ArtistID='.$ArtistID);
|
||||||
$Cache->decrement('stats_artist_count');
|
G::$Cache->decrement('stats_artist_count');
|
||||||
|
|
||||||
// Delete wiki revisions
|
// Delete wiki revisions
|
||||||
$DB->query('DELETE FROM wiki_artists WHERE PageID='.$ArtistID);
|
G::$DB->query('DELETE FROM wiki_artists WHERE PageID='.$ArtistID);
|
||||||
|
|
||||||
// Delete tags
|
// Delete tags
|
||||||
$DB->query('DELETE FROM artists_tags WHERE ArtistID='.$ArtistID);
|
G::$DB->query('DELETE FROM artists_tags WHERE ArtistID='.$ArtistID);
|
||||||
|
|
||||||
$Cache->delete_value('artist_'.$ArtistID);
|
// Delete artist comments, subscriptions and quote notifications
|
||||||
$Cache->delete_value('artist_groups_'.$ArtistID);
|
Comments::delete_page('artist', $ArtistID);
|
||||||
|
|
||||||
|
G::$Cache->delete_value('artist_'.$ArtistID);
|
||||||
|
G::$Cache->delete_value('artist_groups_'.$ArtistID);
|
||||||
// Record in log
|
// Record in log
|
||||||
|
|
||||||
if (!empty($LoggedUser['Username'])) {
|
if (!empty(G::$LoggedUser['Username'])) {
|
||||||
$Username = $LoggedUser['Username'];
|
$Username = G::$LoggedUser['Username'];
|
||||||
} else {
|
} else {
|
||||||
$Username = 'System';
|
$Username = 'System';
|
||||||
}
|
}
|
||||||
Misc::write_log("Artist $ArtistID ($Name) was deleted by $Username");
|
Misc::write_log("Artist $ArtistID ($Name) was deleted by $Username");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,17 +39,18 @@ function load_data($Data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function set_up() {
|
function set_up() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
$this->x = ceil(WIDTH / 2);
|
$this->x = ceil(WIDTH / 2);
|
||||||
$this->y = ceil(HEIGHT / 2);
|
$this->y = ceil(HEIGHT / 2);
|
||||||
|
|
||||||
$this->xValues[$this->x] = $this->ID;
|
$this->xValues[$this->x] = $this->ID;
|
||||||
$this->yValues[$this->y] = $this->ID;
|
$this->yValues[$this->y] = $this->ID;
|
||||||
|
|
||||||
global $DB;
|
|
||||||
|
|
||||||
// Get artists that are directly similar to the artist
|
// Get artists that are directly similar to the artist
|
||||||
$ArtistIDs = array();
|
$ArtistIDs = array();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
s2.ArtistID,
|
s2.ArtistID,
|
||||||
ag.Name,
|
ag.Name,
|
||||||
@ -62,12 +63,12 @@ function set_up() {
|
|||||||
ORDER BY ass.Score DESC
|
ORDER BY ass.Score DESC
|
||||||
LIMIT 14");
|
LIMIT 14");
|
||||||
|
|
||||||
if (!$DB->has_results()) {
|
if (!G::$DB->has_results()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build into array. Each artist is its own object in $this->Artists
|
// Build into array. Each artist is its own object in $this->Artists
|
||||||
while (list($ArtistID, $Name, $Score) = $DB->next_record(MYSQLI_NUM, false)) {
|
while (list($ArtistID, $Name, $Score) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
||||||
if ($Score < 0) {
|
if ($Score < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ function set_up() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get similarities between artists on the map
|
// Get similarities between artists on the map
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
s1.ArtistID,
|
s1.ArtistID,
|
||||||
s2.ArtistID
|
s2.ArtistID
|
||||||
@ -90,7 +91,7 @@ function set_up() {
|
|||||||
AND s2.ArtistID IN('.implode(',', $ArtistIDs).')');
|
AND s2.ArtistID IN('.implode(',', $ArtistIDs).')');
|
||||||
|
|
||||||
// Build into array
|
// Build into array
|
||||||
while (list($Artist1ID, $Artist2ID) = $DB->next_record()) {
|
while (list($Artist1ID, $Artist2ID) = G::$DB->next_record()) {
|
||||||
$this->Artists[$Artist1ID]->Similar[$Artist2ID] = array('ID'=>$Artist2ID);
|
$this->Artists[$Artist1ID]->Similar[$Artist2ID] = array('ID'=>$Artist2ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +108,8 @@ function set_up() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset($this->Artists);
|
reset($this->Artists);
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_positions() {
|
function set_positions() {
|
||||||
|
32
classes/bitcoinrpc.class.php
Normal file
32
classes/bitcoinrpc.class.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
class BitcoinRpc {
|
||||||
|
|
||||||
|
public static function __callStatic($Method, $Args) {
|
||||||
|
if (!defined('BITCOIN_RPC_URL')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$MessageID = mt_rand();
|
||||||
|
$Params = json_encode(array(
|
||||||
|
'method' => $Method,
|
||||||
|
'params' => $Args,
|
||||||
|
'id' => $MessageID)
|
||||||
|
);
|
||||||
|
|
||||||
|
$Request = array(
|
||||||
|
'http' => array(
|
||||||
|
'method' => 'POST',
|
||||||
|
'header' => 'Content-type: application/json',
|
||||||
|
'content' => $Params
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$Response = file_get_contents(BITCOIN_RPC_URL, false, stream_context_create($Request))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$Response = json_decode($Response);
|
||||||
|
if ($Response->id != $MessageID || !empty($Response->error) || empty($Response->result)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $Response->result;
|
||||||
|
}
|
||||||
|
}
|
@ -69,7 +69,7 @@ public static function has_bookmarked($Type, $ID) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all bookmarks of a certain type for a user.
|
* Fetch all bookmarks of a certain type for a user.
|
||||||
* If UserID is false than defaults to $LoggedUser['ID']
|
* If UserID is false than defaults to G::$LoggedUser['ID']
|
||||||
*
|
*
|
||||||
* @param string $Type
|
* @param string $Type
|
||||||
* type of bookmarks to fetch
|
* type of bookmarks to fetch
|
||||||
@ -78,19 +78,20 @@ public static function has_bookmarked($Type, $ID) {
|
|||||||
* @return array the bookmarks
|
* @return array the bookmarks
|
||||||
*/
|
*/
|
||||||
public static function all_bookmarks($Type, $UserID = false) {
|
public static function all_bookmarks($Type, $UserID = false) {
|
||||||
global $DB, $Cache, $LoggedUser;
|
|
||||||
if ($UserID === false) {
|
if ($UserID === false) {
|
||||||
$UserID = $LoggedUser['ID'];
|
$UserID = G::$LoggedUser['ID'];
|
||||||
}
|
}
|
||||||
$CacheKey = 'bookmarks_' . $Type . '_' . $UserID;
|
$CacheKey = 'bookmarks_' . $Type . '_' . $UserID;
|
||||||
if (($Bookmarks = $Cache->get_value($CacheKey)) === false) {
|
if (($Bookmarks = G::$Cache->get_value($CacheKey)) === false) {
|
||||||
list ($Table, $Col) = self::bookmark_schema($Type);
|
list ($Table, $Col) = self::bookmark_schema($Type);
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT $Col
|
SELECT $Col
|
||||||
FROM $Table
|
FROM $Table
|
||||||
WHERE UserID = '$UserID'");
|
WHERE UserID = '$UserID'");
|
||||||
$Bookmarks = $DB->collect($Col);
|
$Bookmarks = G::$DB->collect($Col);
|
||||||
$Cache->cache_value($CacheKey, $Bookmarks, 0);
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value($CacheKey, $Bookmarks, 0);
|
||||||
}
|
}
|
||||||
return $Bookmarks;
|
return $Bookmarks;
|
||||||
}
|
}
|
||||||
|
@ -40,15 +40,18 @@ class CACHE extends Memcache {
|
|||||||
protected $InTransaction = false;
|
protected $InTransaction = false;
|
||||||
public $Time = 0;
|
public $Time = 0;
|
||||||
private $PersistentKeys = array(
|
private $PersistentKeys = array(
|
||||||
'stats_*',
|
'ajax_requests_*',
|
||||||
'percentiles_*',
|
|
||||||
'top10tor_*',
|
|
||||||
'query_lock_*',
|
'query_lock_*',
|
||||||
|
'stats_*',
|
||||||
|
'top10tor_*',
|
||||||
'top10votes_*',
|
'top10votes_*',
|
||||||
// 'similar_albums_*',
|
|
||||||
'users_snatched_*',
|
'users_snatched_*',
|
||||||
'ajax_requests_*'
|
|
||||||
|
// Cache-based features
|
||||||
|
'global_notification',
|
||||||
|
'notifications_one_reads_*',
|
||||||
);
|
);
|
||||||
|
private $ClearedKeys = array();
|
||||||
|
|
||||||
public $CanClear = false;
|
public $CanClear = false;
|
||||||
public $InternalCache = true;
|
public $InternalCache = true;
|
||||||
@ -110,21 +113,27 @@ public function get_value($Key, $NoCache = false) {
|
|||||||
// Because of this, not user cache data will require a secondary pageload following the clearcache to update
|
// Because of this, not user cache data will require a secondary pageload following the clearcache to update
|
||||||
if (count($this->CacheHits) > 0) {
|
if (count($this->CacheHits) > 0) {
|
||||||
foreach (array_keys($this->CacheHits) as $HitKey) {
|
foreach (array_keys($this->CacheHits) as $HitKey) {
|
||||||
if (!Misc::in_array_partial($HitKey, $this->PersistentKeys)) {
|
if (!isset($this->ClearedKeys[$HitKey]) && !Misc::in_array_partial($HitKey, $this->PersistentKeys)) {
|
||||||
$this->delete($HitKey);
|
$this->delete($HitKey);
|
||||||
unset($this->CacheHits[$HitKey]);
|
unset($this->CacheHits[$HitKey]);
|
||||||
|
$this->ClearedKeys[$HitKey] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isset($this->ClearedKeys[$Key])) {
|
||||||
$this->delete($Key);
|
$this->delete($Key);
|
||||||
|
$this->ClearedKeys[$Key] = true;
|
||||||
$this->Time += (microtime(true) - $StartTime) * 1000;
|
$this->Time += (microtime(true) - $StartTime) * 1000;
|
||||||
return false;
|
return false;
|
||||||
} elseif ($_GET['clearcache'] == $Key) {
|
}
|
||||||
|
} elseif (!isset($this->ClearedKeys[$Key]) && $_GET['clearcache'] == $Key) {
|
||||||
$this->delete($Key);
|
$this->delete($Key);
|
||||||
|
$this->ClearedKeys[$Key] = true;
|
||||||
$this->Time += (microtime(true) - $StartTime) * 1000;
|
$this->Time += (microtime(true) - $StartTime) * 1000;
|
||||||
return false;
|
return false;
|
||||||
} elseif (in_array($_GET['clearcache'], $this->CacheHits)) {
|
} elseif (!isset($this->ClearedKeys[$_GET['clearcache']]) && in_array($_GET['clearcache'], $this->CacheHits)) {
|
||||||
unset($this->CacheHits[$_GET['clearcache']]);
|
unset($this->CacheHits[$_GET['clearcache']]);
|
||||||
|
$this->ClearedKeys[$_GET['clearcache']] = true;
|
||||||
$this->delete($_GET['clearcache']);
|
$this->delete($_GET['clearcache']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
139
classes/calendar.class.php
Normal file
139
classes/calendar.class.php
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?
|
||||||
|
class Calendar {
|
||||||
|
public static $Categories = array(1 => "IRC Meeting", "IRC Brainstorm", "Poll Deadline", "Feature Release", "Blog Post", "Announcement", "Featured Album", "Product Release", "Staff Picks", "Forum Brainstorm", "Forum Discussion", "Promotion");
|
||||||
|
public static $Importances = array(1 => "Critical", "Important", "Average", "Meh");
|
||||||
|
public static $Colors = array(
|
||||||
|
"Critical" => "red",
|
||||||
|
"Important" => "yellow",
|
||||||
|
"Average" => "green",
|
||||||
|
"Meh" => "blue");
|
||||||
|
|
||||||
|
public static $Teams = array(
|
||||||
|
0 => "Everyone",
|
||||||
|
1 => "Staff"
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
public static function can_view() {
|
||||||
|
return check_perms('users_mod')
|
||||||
|
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function get_teams_query() {
|
||||||
|
$Teams = array(0);
|
||||||
|
$IsMod = check_perms("users_mod");
|
||||||
|
if ($IsMod) {
|
||||||
|
$Teams[] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Team IN (" . implode(",", $Teams) . ") ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_events($Month, $Year) {
|
||||||
|
if (empty($Month) || empty($Year)) {
|
||||||
|
$Date = getdate();
|
||||||
|
$Month = $Date['mon'];
|
||||||
|
$Year = $Date['year'];
|
||||||
|
}
|
||||||
|
$Month = (int) $Month;
|
||||||
|
$Year = (int) $Year;
|
||||||
|
|
||||||
|
$TeamsSQL = self::get_teams_query();
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
ID, Team, Title, Category, Importance, DAY(StartDate) AS StartDay, DAY(EndDate) AS EndDay
|
||||||
|
FROM calendar
|
||||||
|
WHERE
|
||||||
|
MONTH(StartDate) = '$Month'
|
||||||
|
AND
|
||||||
|
YEAR(StartDate) = '$Year'
|
||||||
|
AND
|
||||||
|
$TeamsSQL");
|
||||||
|
$Events = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Events;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_event($ID) {
|
||||||
|
$ID = (int) $ID;
|
||||||
|
if (empty($ID)) {
|
||||||
|
error("Invalid ID");
|
||||||
|
}
|
||||||
|
$TeamsSQL = self::get_teams_query();
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
ID, Team, Title, Body, Category, Importance, AddedBy, StartDate, EndDate
|
||||||
|
FROM calendar
|
||||||
|
WHERE
|
||||||
|
ID = '$ID'
|
||||||
|
AND
|
||||||
|
$TeamsSQL");
|
||||||
|
$Event = G::$DB->next_record(MYSQLI_ASSOC);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create_event($Title, $Body, $Category, $Importance, $Team, $UserID, $StartDate, $EndDate = null) {
|
||||||
|
if (empty($Title) || empty($Body) || !is_number($Category) || !is_number($Importance) || !is_number($Team) || empty($StartDate)) {
|
||||||
|
error("Error adding event");
|
||||||
|
}
|
||||||
|
$Title = db_string($Title);
|
||||||
|
$Body = db_string($Body);
|
||||||
|
$Category = (int) $Category;
|
||||||
|
$Importance = (int) $Importance;
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
$Team = (int) $Team;
|
||||||
|
$StartDate = db_string($StartDate);
|
||||||
|
$EndDate = db_string($EndDate);
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO calendar
|
||||||
|
(Title, Body, Category, Importance, Team, StartDate, EndDate, AddedBy)
|
||||||
|
VALUES
|
||||||
|
('$Title', '$Body', '$Category', '$Importance', '$Team' '$StartDate', '$EndDate', '$UserID')");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function update_event($ID, $Title, $Body, $Category, $Importance, $Team, $StartDate, $EndDate = null) {
|
||||||
|
if (!is_number($ID) || empty($Title) || empty($Body) || !is_number($Category) || !is_number($Importance) || !is_number($Team) || empty($StartDate)) {
|
||||||
|
error("Error updating event");
|
||||||
|
}
|
||||||
|
$ID = (int) $ID;
|
||||||
|
$Title = db_string($Title);
|
||||||
|
$Body = db_string($Body);
|
||||||
|
$Category = (int) $Category;
|
||||||
|
$Importance = (int) $Importance;
|
||||||
|
$Team = (int) $Team;
|
||||||
|
$StartDate = db_string($StartDate);
|
||||||
|
$EndDate = db_string($EndDate);
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE calendar
|
||||||
|
SET
|
||||||
|
Title = '$Title',
|
||||||
|
Body = '$Body',
|
||||||
|
Category = '$Category',
|
||||||
|
Importance = '$Importance',
|
||||||
|
Team = '$Team',
|
||||||
|
StartDate = '$StartDate',
|
||||||
|
EndDate = '$EndDate'
|
||||||
|
WHERE
|
||||||
|
ID = '$ID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function remove_event($ID) {
|
||||||
|
$ID = (int) $ID;
|
||||||
|
if (!empty($ID)) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("DELETE FROM calendar WHERE ID = '$ID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
109
classes/calendarview.class.php
Normal file
109
classes/calendarview.class.php
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
class CalendarView {
|
||||||
|
private static $Days = array('S','M','T','W','T','F','S');
|
||||||
|
private static $Headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
|
||||||
|
private static $Events;
|
||||||
|
|
||||||
|
public static function render_title($Month, $Year) {
|
||||||
|
$NextMonth = $Month % 12 == 0 ? 1 : $Month + 1;
|
||||||
|
$PreviousMonth = $Month == 1 ? 12 : $Month - 1;
|
||||||
|
$NextYear = $Year;
|
||||||
|
if ($NextMonth == 1) {
|
||||||
|
$NextYear++;
|
||||||
|
}
|
||||||
|
$PreviousYear = $Year;
|
||||||
|
if ($PreviousMonth == 12) {
|
||||||
|
$PreviousYear--;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<h1 class="center">
|
||||||
|
<a href="tools.php?action=calendar&month=<?=$PreviousMonth?>&year=<?=$PreviousYear?>"><</a>
|
||||||
|
<?=date("F", mktime(0, 0, 0, $Month, 10)) . " " . $Year?>
|
||||||
|
<a href="tools.php?action=calendar&month=<?=$NextMonth?>&year=<?=$NextYear?>">></a>
|
||||||
|
</h1>
|
||||||
|
<input type="hidden" id="month" value="<?=$Month?>"/>
|
||||||
|
<input type="hidden" id="year" value="<?=$Year?>"/>
|
||||||
|
<? }
|
||||||
|
|
||||||
|
private static function get_events_on($Day, $Events) {
|
||||||
|
// Linear search, Lol.
|
||||||
|
$Results = array();
|
||||||
|
foreach($Events as $Event) {
|
||||||
|
if ($Event['StartDay'] == $Day || ($Event['StartDay'] <= $Day && $Event['EndDay'] >= $Day)) {
|
||||||
|
$Results[] = $Event;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $Results;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static function render_events_day($Day, $Events) {
|
||||||
|
$Events = self::get_events_on($Day, $Events);
|
||||||
|
foreach ($Events as $Event) {
|
||||||
|
$Color = Calendar::$Colors[Calendar::$Importances[$Event['Importance']]];
|
||||||
|
$Category = Calendar::$Categories[$Event['Category']];
|
||||||
|
$Tooltip = $Event['Title'] . " - " . Calendar::$Categories[$Event['Category']] . " - " . Calendar::$Importances[$Event['Importance']];
|
||||||
|
?>
|
||||||
|
<p><a href="#" class="event_day tooltip" title="<?=$Tooltip?>" data-gazelle-id="<?=$Event['ID']?>" style="color: <?=$Color?>;"><?=Format::cut_string($Event['Title'], 8, true)?></a></p>
|
||||||
|
<? }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function render_calendar($Month, $Year, $Events) {
|
||||||
|
$RunningDay = date('w',mktime(0, 0, 0, $Month, 1, $Year));
|
||||||
|
$DaysInMonth = date('t',mktime(0 ,0 ,0, $Month, 1, $Year));
|
||||||
|
$DaysThisWeek = 1;
|
||||||
|
$DayCounter = 0;
|
||||||
|
$DatesArray = array();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<table class="calendar">
|
||||||
|
<? foreach(self::$Headings as $Heading) { ?>
|
||||||
|
<td class="calendar-row calendar-heading">
|
||||||
|
<strong><?=$Heading?></strong>
|
||||||
|
</td>
|
||||||
|
<? } ?>
|
||||||
|
<tr class="calendar-row">
|
||||||
|
|
||||||
|
<? for ($x = 0; $x < $RunningDay; $x++) { ?>
|
||||||
|
<td class="calendar-day-np"></td>
|
||||||
|
<? $DaysThisWeek++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $DaysInMonth; $i++) { ?>
|
||||||
|
<td class="calendar-day">
|
||||||
|
<div class="day-events">
|
||||||
|
<? self::render_events_day($i, $Events); ?>
|
||||||
|
</div>
|
||||||
|
<div class="day-number">
|
||||||
|
<?=$i?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<? if ($RunningDay == 6) { ?>
|
||||||
|
</tr>
|
||||||
|
<? if (($DayCounter+1) != $DaysInMonth) { ?>
|
||||||
|
<tr class="calendar-row">
|
||||||
|
<? }
|
||||||
|
$RunningDay = -1;
|
||||||
|
$DaysThisWeek = 0;
|
||||||
|
}
|
||||||
|
$DaysThisWeek++;
|
||||||
|
$RunningDay++;
|
||||||
|
$DayCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($DaysThisWeek < 8) {
|
||||||
|
for ($x = 1; $x <= (8 - $DaysThisWeek); $x++) { ?>
|
||||||
|
<td class="calendar-day-np"></td>
|
||||||
|
<? }
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<?
|
||||||
|
echo $Calendar;
|
||||||
|
}
|
||||||
|
}
|
@ -1,82 +1,48 @@
|
|||||||
<?
|
<?
|
||||||
class Collages {
|
class Collages {
|
||||||
public static function get_comment_count($CollageID) {
|
|
||||||
global $DB, $Cache;
|
|
||||||
$NumComments = $Cache->get_value('collage_comments_'.$CollageID);
|
|
||||||
if ($NumComments === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE CollageID = '$CollageID'");
|
|
||||||
list($NumComments) = $DB->next_record();
|
|
||||||
$Cache->cache_value('collage_comments_'.$CollageID, $NumComments, 0);
|
|
||||||
}
|
|
||||||
return $NumComments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function get_comment_catalogue($CollageID, $CatalogueID) {
|
|
||||||
global $DB, $Cache;
|
|
||||||
$Catalogue = $Cache->get_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
|
|
||||||
if ($Catalogue === false) {
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
ID,
|
|
||||||
UserID,
|
|
||||||
Time,
|
|
||||||
Body
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE CollageID = '$CollageID'
|
|
||||||
LIMIT $CatalogueLimit");
|
|
||||||
$Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
|
|
||||||
$Cache->cache_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
|
|
||||||
}
|
|
||||||
return $Catalogue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function increase_subscriptions($CollageID) {
|
public static function increase_subscriptions($CollageID) {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE collages
|
UPDATE collages
|
||||||
SET Subscribers = Subscribers + 1
|
SET Subscribers = Subscribers + 1
|
||||||
WHERE ID = '$CollageID'");
|
WHERE ID = '$CollageID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function decrease_subscriptions($CollageID) {
|
public static function decrease_subscriptions($CollageID) {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE collages
|
UPDATE collages
|
||||||
SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
|
SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
|
||||||
WHERE ID = '$CollageID'");
|
WHERE ID = '$CollageID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create_personal_collage() {
|
public static function create_personal_collage() {
|
||||||
global $DB, $LoggedUser;
|
G::$DB->query("
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(ID)
|
COUNT(ID)
|
||||||
FROM collages
|
FROM collages
|
||||||
WHERE UserID = '$LoggedUser[ID]'
|
WHERE UserID = '" . G::$LoggedUser['ID'] . "'
|
||||||
AND CategoryID = '0'
|
AND CategoryID = '0'
|
||||||
AND Deleted = '0'");
|
AND Deleted = '0'");
|
||||||
list($CollageCount) = $DB->next_record();
|
list($CollageCount) = G::$DB->next_record();
|
||||||
|
|
||||||
if ($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) {
|
if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
|
||||||
list($CollageID) = $DB->next_record();
|
// TODO: fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
|
||||||
|
list($CollageID) = G::$DB->next_record();
|
||||||
header('Location: collage.php?id='.$CollageID);
|
header('Location: collage.php?id='.$CollageID);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
$NameStr = ($CollageCount > 0) ? ' no. ' . ($CollageCount + 1) : '';
|
$NameStr = db_string(G::$LoggedUser['Username'] . "'s personal collage" . ($CollageCount > 0 ? ' no. ' . ($CollageCount + 1) : ''));
|
||||||
$DB->query("
|
$Description = db_string('Personal collage for ' . G::$LoggedUser['Username'] . '. The first 5 albums will appear on his or her [url=https://' . SSL_SITE_URL . '/user.php?id= ' . G::$LoggedUser['ID'] . ']profile[/url].');
|
||||||
|
G::$DB->query("
|
||||||
INSERT INTO collages
|
INSERT INTO collages
|
||||||
(Name, Description, CategoryID, UserID)
|
(Name, Description, CategoryID, UserID)
|
||||||
VALUES
|
VALUES
|
||||||
('$LoggedUser[Username]\'s personal collage$NameStr', 'Personal collage for $LoggedUser[Username]. The first 5 albums will appear on his or her [url=https:\/\/".SSL_SITE_URL."\/user.php?id=$LoggedUser[ID]]profile[\/url].', '0', $LoggedUser[ID])");
|
('$NameStr', '$Description', '0', " . G::$LoggedUser['ID'] . ")");
|
||||||
$CollageID = $DB->inserted_id();
|
$CollageID = G::$DB->inserted_id();
|
||||||
header('Location: collage.php?id='.$CollageID);
|
header('Location: collage.php?id='.$CollageID);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
395
classes/comments.class.php
Normal file
395
classes/comments.class.php
Normal file
@ -0,0 +1,395 @@
|
|||||||
|
<?
|
||||||
|
class Comments {
|
||||||
|
/*
|
||||||
|
* For all functions:
|
||||||
|
* $Page = 'artist', 'collages', 'requests' or 'torrents'
|
||||||
|
* $PageID = ArtistID, CollageID, RequestID or GroupID, respectively
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post a comment on an artist, request or torrent page.
|
||||||
|
* @param string $Page
|
||||||
|
* @param int $PageID
|
||||||
|
* @param string $Body
|
||||||
|
* @return int ID of the new comment
|
||||||
|
*/
|
||||||
|
public static function post($Page, $PageID, $Body) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
CEIL(
|
||||||
|
(
|
||||||
|
SELECT COUNT(ID)+1
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page'
|
||||||
|
AND PageID = $PageID
|
||||||
|
)/" . TORRENT_COMMENTS_PER_PAGE . "
|
||||||
|
) AS Pages");
|
||||||
|
list($Pages) = G::$DB->next_record();
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO comments (Page, PageID, AuthorID, AddedTime, Body)
|
||||||
|
VALUES ('$Page', $PageID, " . G::$LoggedUser['ID'] . ", '" . sqltime() . "', '" . db_string($Body) . "')");
|
||||||
|
$PostID = G::$DB->inserted_id();
|
||||||
|
|
||||||
|
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
G::$Cache->delete_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
|
||||||
|
G::$Cache->delete_value($Page.'_comments_'.$PageID);
|
||||||
|
|
||||||
|
Subscriptions::flush_subscriptions($Page, $PageID);
|
||||||
|
Subscriptions::quote_notify($Body, $PostID, $Page, $PageID);
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
return $PostID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit a comment
|
||||||
|
* @param int $PostID
|
||||||
|
* @param string $NewBody
|
||||||
|
* @todo move permission check out of here/remove hardcoded error(404)
|
||||||
|
*/
|
||||||
|
public static function edit($PostID, $NewBody) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
Body,
|
||||||
|
AuthorID,
|
||||||
|
Page,
|
||||||
|
PageID,
|
||||||
|
AddedTime
|
||||||
|
FROM comments
|
||||||
|
WHERE ID = $PostID");
|
||||||
|
if (!G::$DB->has_results()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
|
||||||
|
|
||||||
|
if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page'
|
||||||
|
AND PageID = $PageID
|
||||||
|
AND ID <= $PostID");
|
||||||
|
list($CommPage) = G::$DB->next_record();
|
||||||
|
|
||||||
|
// Perform the update
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE comments
|
||||||
|
SET
|
||||||
|
Body = '" . db_string($NewBody) . "',
|
||||||
|
EditedUserID = " . G::$LoggedUser['ID'] . ",
|
||||||
|
EditedTime = '" . sqltime() . "'
|
||||||
|
WHERE ID = $PostID");
|
||||||
|
|
||||||
|
// Update the cache
|
||||||
|
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
|
||||||
|
|
||||||
|
if ($Page == 'collages') {
|
||||||
|
// On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
|
||||||
|
G::$Cache->delete_value('collage_' . $PageID);
|
||||||
|
}
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
|
||||||
|
VALUES ('$Page', $PostID, " . G::$LoggedUser['ID'] . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
return true; // TODO: this should reflect whether or not the update was actually successful, e.g. by checking G::$DB->affected_rows after the UPDATE query
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a comment
|
||||||
|
* @param int $PostID
|
||||||
|
*/
|
||||||
|
public static function delete($PostID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
// Get page, pageid
|
||||||
|
G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = $PostID");
|
||||||
|
if (!G::$DB->has_results()) {
|
||||||
|
// no such comment?
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list ($Page, $PageID) = G::$DB->next_record();
|
||||||
|
// get number of pages
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
|
||||||
|
CEIL(SUM(IF(ID <= $PostID, 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page' AND PageID = $PageID
|
||||||
|
GROUP BY PageID");
|
||||||
|
if (!G::$DB->has_results()) {
|
||||||
|
// the comment $PostID was probably not posted on $Page
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list($CommPages, $CommPage) = G::$DB->next_record();
|
||||||
|
|
||||||
|
// $CommPages = number of pages in the thread
|
||||||
|
// $CommPage = which page the post is on
|
||||||
|
// These are set for cache clearing.
|
||||||
|
|
||||||
|
G::$DB->query("DELETE FROM comments WHERE ID = $PostID");
|
||||||
|
G::$DB->query("DELETE FROM comments_edits WHERE Page = '$Page' AND PostID = $PostID");
|
||||||
|
|
||||||
|
G::$DB->query("DELETE FROM users_notify_quoted WHERE Page = '$Page' AND PostID = $PostID");
|
||||||
|
|
||||||
|
Subscriptions::flush_subscriptions($Page, $PageID);
|
||||||
|
Subscriptions::flush_quote_notifications($Page, $PageID);
|
||||||
|
|
||||||
|
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
|
||||||
|
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
for ($i = $ThisCatalogue; $i <= $LastCatalogue; ++$i) {
|
||||||
|
G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
|
||||||
|
}
|
||||||
|
|
||||||
|
G::$Cache->delete_value($Page . '_comments_' . $PageID);
|
||||||
|
|
||||||
|
if ($Page == 'collages') {
|
||||||
|
// On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
|
||||||
|
G::$Cache->delete_value('collage_' . $PageID);
|
||||||
|
}
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL to a comment, already knowing the Page and PostID
|
||||||
|
* @param string $Page
|
||||||
|
* @param int $PageID
|
||||||
|
* @param int $PostID
|
||||||
|
* @return string|bool The URL to the comment or false on error
|
||||||
|
*/
|
||||||
|
public static function get_url($Page, $PageID, $PostID = null) {
|
||||||
|
$Post = (!empty($PostID) ? "&postid=$PostID#post$PostID" : '');
|
||||||
|
switch ($Page) {
|
||||||
|
case 'artist':
|
||||||
|
return "artist.php?id=$PageID$Post";
|
||||||
|
case 'collages':
|
||||||
|
return "collages.php?action=comments&collageid=$PageID$Post";
|
||||||
|
case 'requests':
|
||||||
|
return "requests.php?action=view&id=$PageID$Post";
|
||||||
|
case 'torrents':
|
||||||
|
return "torrents.php?id=$PageID$Post";
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL to a comment
|
||||||
|
* @param int $PostID
|
||||||
|
* @return string|bool The URL to the comment or false on error
|
||||||
|
*/
|
||||||
|
public static function get_url_query($PostID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = $PostID");
|
||||||
|
if (!G::$DB->has_results()) {
|
||||||
|
error(404);
|
||||||
|
}
|
||||||
|
list($Page, $PageID) = G::$DB->next_record();
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
return self::get_url($Page, $PageID, $PostID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a page's comments. This takes care of `postid` and (indirectly) `page` parameters passed in $_GET.
|
||||||
|
* Quote notifications and last read are also handled here, unless $HandleSubscriptions = false is passed.
|
||||||
|
* @param string $Page
|
||||||
|
* @param int $PageID
|
||||||
|
* @param bool $HandleSubscriptions Whether or not to handle subscriptions (last read & quote notifications)
|
||||||
|
* @return array ($NumComments, $Page, $Thread, $LastRead)
|
||||||
|
* $NumComments: the total number of comments on this artist/request/torrent group
|
||||||
|
* $Page: the page we're currently on
|
||||||
|
* $Thread: an array of all posts on this page
|
||||||
|
* $LastRead: ID of the last comment read by the current user in this thread;
|
||||||
|
* will be false if $HandleSubscriptions == false or if there are no comments on this page
|
||||||
|
*/
|
||||||
|
public static function load($Page, $PageID, $HandleSubscriptions = true) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
// Get the total number of comments
|
||||||
|
$NumComments = G::$Cache->get_value($Page.'_comments_'.$PageID);
|
||||||
|
if ($NumComments === false) {
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT COUNT(ID)
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page'
|
||||||
|
AND PageID = $PageID");
|
||||||
|
list($NumComments) = G::$DB->next_record();
|
||||||
|
G::$Cache->cache_value($Page.'_comments_'.$PageID, $NumComments, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a postid was passed, we need to determine which page that comment is on.
|
||||||
|
// Format::page_limit handles a potential $_GET['page']
|
||||||
|
if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT COUNT(ID)
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page'
|
||||||
|
AND PageID = $PageID
|
||||||
|
AND ID <= $_GET[postid]");
|
||||||
|
list($PostNum) = G::$DB->next_record();
|
||||||
|
list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
|
||||||
|
} else {
|
||||||
|
list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the cache catalogue
|
||||||
|
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
|
||||||
|
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
|
||||||
|
$Catalogue = G::$Cache->get_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
|
||||||
|
if ($Catalogue === false) {
|
||||||
|
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
c.ID,
|
||||||
|
c.AuthorID,
|
||||||
|
c.AddedTime,
|
||||||
|
c.Body,
|
||||||
|
c.EditedUserID,
|
||||||
|
c.EditedTime,
|
||||||
|
u.Username
|
||||||
|
FROM comments AS c
|
||||||
|
LEFT JOIN users_main AS u ON u.ID = c.EditedUserID
|
||||||
|
WHERE c.Page = '$Page' AND c.PageID = $PageID
|
||||||
|
ORDER BY c.ID
|
||||||
|
LIMIT $CatalogueLimit");
|
||||||
|
$Catalogue = G::$DB->to_array(false, MYSQLI_ASSOC);
|
||||||
|
G::$Cache->cache_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
|
||||||
|
$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
|
||||||
|
|
||||||
|
if ($HandleSubscriptions && count($Thread) > 0) {
|
||||||
|
// quote notifications
|
||||||
|
$LastPost = end($Thread);
|
||||||
|
$LastPost = $LastPost['ID'];
|
||||||
|
$FirstPost = reset($Thread);
|
||||||
|
$FirstPost = $FirstPost['ID'];
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_notify_quoted
|
||||||
|
SET UnRead = false
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID'] . "
|
||||||
|
AND Page = '$Page'
|
||||||
|
AND PageID = $PageID
|
||||||
|
AND PostID >= $FirstPost
|
||||||
|
AND PostID <= $LastPost");
|
||||||
|
if (G::$DB->affected_rows()) {
|
||||||
|
G::$Cache->delete_value('notify_quoted_' . G::$LoggedUser['ID']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// last read
|
||||||
|
G::$DB->query("SELECT PostID FROM users_comments_last_read WHERE UserID = " . G::$LoggedUser['ID'] . " AND Page = '$Page' AND PageID = $PageID");
|
||||||
|
list($LastRead) = G::$DB->next_record();
|
||||||
|
if($LastRead < $LastPost) {
|
||||||
|
G::$DB->query("INSERT INTO users_comments_last_read
|
||||||
|
(UserID, Page, PageID, PostID) VALUES
|
||||||
|
(" . G::$LoggedUser['ID'] . ", '$Page', $PageID, $LastPost)
|
||||||
|
ON DUPLICATE KEY UPDATE PostID = $LastPost");
|
||||||
|
G::$Cache->delete_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$LastRead = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
return array($NumComments, $CommPage, $Thread, $LastRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges all comments from $Page/$PageID into $Page/$TargetPageID. This also takes care of quote notifications, subscriptions and cache.
|
||||||
|
* @param type $Page
|
||||||
|
* @param type $PageID
|
||||||
|
* @param type $TargetPageID
|
||||||
|
*/
|
||||||
|
public static function merge($Page, $PageID, $TargetPageID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
G::$DB->query("UPDATE comments SET PageID = $TargetPageID WHERE Page = '$Page' AND PageID = $PageID");
|
||||||
|
|
||||||
|
// quote notifications
|
||||||
|
G::$DB->query("UPDATE users_notify_quoted SET PageID = $TargetPageID WHERE Page = '$Page' AND PageID = $PageID");
|
||||||
|
|
||||||
|
// comment subscriptions
|
||||||
|
Subscriptions::move_subscriptions($Page, $PageID, $TargetPageID);
|
||||||
|
|
||||||
|
// cache (we need to clear all comment catalogues)
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page'
|
||||||
|
AND PageID = $TargetPageID
|
||||||
|
GROUP BY PageID");
|
||||||
|
list($CommPages) = G::$DB->next_record();
|
||||||
|
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
for ($i = 0; $i <= $LastCatalogue; ++$i) {
|
||||||
|
G::$Cache->delete_value($Page . '_comments_' . $TargetPageID . '_catalogue_' . $i);
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value($Page.'_comments_'.$TargetPageID);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
|
||||||
|
* @param string $Page
|
||||||
|
* @param int $PageID
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function delete_page($Page, $PageID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
// get number of pages
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
|
||||||
|
FROM comments
|
||||||
|
WHERE Page = '$Page' AND PageID = $PageID
|
||||||
|
GROUP BY PageID");
|
||||||
|
if (!G::$DB->has_results()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list($CommPages) = G::$DB->next_record();
|
||||||
|
|
||||||
|
// Delete comments
|
||||||
|
G::$DB->query("DELETE FROM comments WHERE Page = '$Page' AND PageID = $PageID");
|
||||||
|
|
||||||
|
// Delete quote notifications
|
||||||
|
Subscriptions::flush_quote_notifications($Page, $PageID);
|
||||||
|
G::$DB->query("DELETE FROM users_notify_quoted WHERE Page = '$Page' AND PageID = $PageID");
|
||||||
|
|
||||||
|
// Deal with subscriptions
|
||||||
|
Subscriptions::move_subscriptions($Page, $PageID, null);
|
||||||
|
|
||||||
|
// Clear cache
|
||||||
|
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
|
for ($i = 0; $i <= $LastCatalogue; ++$i) {
|
||||||
|
G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value($Page.'_comments_'.$PageID);
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
94
classes/commentsview.class.php
Normal file
94
classes/commentsview.class.php
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?
|
||||||
|
class CommentsView {
|
||||||
|
/**
|
||||||
|
* Render a thread of comments
|
||||||
|
* @param array $Thread An array as returned by Comments::load
|
||||||
|
* @param int $LastRead PostID of the last read post
|
||||||
|
* @param string $Baselink Link to the site these comments are on
|
||||||
|
*/
|
||||||
|
public static function render_comments($Thread, $LastRead, $Baselink) {
|
||||||
|
foreach ($Thread as $Post) {
|
||||||
|
list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
|
||||||
|
self::render_comment($AuthorID, $PostID, $CommentBody, $AddedTime, $EditedUserID, $EditedTime, $Baselink . "&postid=$PostID#post$PostID", ($PostID > $LastRead));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render one comment
|
||||||
|
* @param int $AuthorID
|
||||||
|
* @param int $PostID
|
||||||
|
* @param string $Body
|
||||||
|
* @param string $AddedTime
|
||||||
|
* @param int $EditedUserID
|
||||||
|
* @param string $EditedTime
|
||||||
|
* @param string $Link The link to the post elsewhere on the site
|
||||||
|
* @param string $Header The header used in the post
|
||||||
|
* @param bool $Tools Whether or not to show [Edit], [Report] etc.
|
||||||
|
* @todo Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
|
||||||
|
*/
|
||||||
|
function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true) {
|
||||||
|
global $Text; // TODO: convert Text class to static and get rid of this crap
|
||||||
|
$UserInfo = Users::user_info($AuthorID);
|
||||||
|
$Header = '<strong>' . Users::format_username($AuthorID, true, true, true, true, false) . '</strong> ' . time_diff($AddedTime) . $Header;
|
||||||
|
?>
|
||||||
|
<table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '') . ($Unread ? ' forum_unread' : '')?>" id="post<?=$PostID?>">
|
||||||
|
<colgroup>
|
||||||
|
<? if (Users::has_avatars_enabled()) { ?>
|
||||||
|
<col class="col_avatar" />
|
||||||
|
<? } ?>
|
||||||
|
<col class="col_post_body" />
|
||||||
|
</colgroup>
|
||||||
|
<tr class="colhead_dark">
|
||||||
|
<td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
|
||||||
|
<div style="float: left;"><a class="post_id" href="<?=$Link?>">#<?=$PostID?></a>
|
||||||
|
<?=$Header?>
|
||||||
|
<? if ($Tools) { ?>
|
||||||
|
- <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$UserInfo['Username']?>', true);" class="brackets">Quote</a>
|
||||||
|
<? if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
|
||||||
|
- <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','<?=$Key?>');" class="brackets">Edit</a>
|
||||||
|
<? }
|
||||||
|
if (check_perms('site_moderate_forums')) { ?>
|
||||||
|
- <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a>
|
||||||
|
<? } ?>
|
||||||
|
</div>
|
||||||
|
<div id="bar<?=$PostID?>" style="float: right;">
|
||||||
|
<a href="reports.php?action=report&type=comment&id=<?=$PostID?>" class="brackets">Report</a>
|
||||||
|
<?
|
||||||
|
if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
|
||||||
|
?>
|
||||||
|
<form class="manage_form hidden" name="user" id="warn<?=$PostID?>" action="comments.php" method="post">
|
||||||
|
<input type="hidden" name="action" value="warn" />
|
||||||
|
<input type="hidden" name="postid" value="<?=$PostID?>" />
|
||||||
|
</form>
|
||||||
|
- <a href="#" onclick="$('#warn<?=$PostID?>').raw().submit(); return false;" class="brackets">Warn</a>
|
||||||
|
<? } ?>
|
||||||
|
|
||||||
|
<a href="#">↑</a>
|
||||||
|
<? } ?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<? if (Users::has_avatars_enabled()) { ?>
|
||||||
|
<td class="avatar" valign="top">
|
||||||
|
<?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
|
||||||
|
</td>
|
||||||
|
<? } ?>
|
||||||
|
<td class="body" valign="top">
|
||||||
|
<div id="content<?=$PostID?>">
|
||||||
|
<?=$Text->full_format($Body)?>
|
||||||
|
<? if ($EditedUserID) { ?>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<? if (check_perms('site_admin_forums')) { ?>
|
||||||
|
<a href="#content<?=$PostID?>" onclick="LoadEdit('<?=substr($Link, 0, strcspn($Link, '.'))?>', <?=$PostID?>, 1); return false;">«</a>
|
||||||
|
<? } ?>
|
||||||
|
Last edited by
|
||||||
|
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime, 2, true, true)?>
|
||||||
|
<? } ?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<? }
|
||||||
|
}
|
@ -127,6 +127,16 @@ define('LAB_CHAN', '#');
|
|||||||
define('STATUS_CHAN', '#');
|
define('STATUS_CHAN', '#');
|
||||||
|
|
||||||
// Miscellaneous values
|
// Miscellaneous values
|
||||||
|
define('RANK_ONE_COST', 5);
|
||||||
|
define('RANK_TWO_COST', 10);
|
||||||
|
define('RANK_THREE_COST', 15);
|
||||||
|
define('RANK_FOUR_COST', 20);
|
||||||
|
define('RANK_FIVE_COST', 30);
|
||||||
|
define('MAX_RANK', 6);
|
||||||
|
define('MAX_EXTRA_RANK', 8);
|
||||||
|
define('DONOR_FORUM_RANK', 6);
|
||||||
|
define('DONOR_FORUM', 70);
|
||||||
|
define('MAX_SPECIAL_RANK', 3);
|
||||||
|
|
||||||
$ForumsRevealVoters = array();
|
$ForumsRevealVoters = array();
|
||||||
$ForumsDoublePost = array();
|
$ForumsDoublePost = array();
|
||||||
|
@ -13,7 +13,7 @@ class DEBUG {
|
|||||||
private $LoggedVars = array();
|
private $LoggedVars = array();
|
||||||
|
|
||||||
public function profile($Automatic = '') {
|
public function profile($Automatic = '') {
|
||||||
global $ScriptStartTime, $DB;
|
global $ScriptStartTime;
|
||||||
$Reason = array();
|
$Reason = array();
|
||||||
|
|
||||||
if (!empty($Automatic)) {
|
if (!empty($Automatic)) {
|
||||||
@ -40,7 +40,7 @@ public function profile($Automatic = '') {
|
|||||||
$Reason[] = Format::get_size($Ram).' RAM used';
|
$Reason[] = Format::get_size($Ram).' RAM used';
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->warnings(); // see comment in MYSQL::query
|
G::$DB->warnings(); // see comment in MYSQL::query
|
||||||
/*$Queries = $this->get_queries();
|
/*$Queries = $this->get_queries();
|
||||||
$DBWarningCount = 0;
|
$DBWarningCount = 0;
|
||||||
foreach ($Queries as $Query) {
|
foreach ($Queries as $Query) {
|
||||||
@ -53,8 +53,7 @@ public function profile($Automatic = '') {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (isset($_REQUEST['profile'])) {
|
if (isset($_REQUEST['profile'])) {
|
||||||
global $LoggedUser;
|
$Reason[] = 'Requested by ' . G::$LoggedUser['Username'];
|
||||||
$Reason[] = 'Requested by '.$LoggedUser['Username'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Perf['Memory usage'] = (($Ram>>10) / 1024).' MB';
|
$this->Perf['Memory usage'] = (($Ram>>10) / 1024).' MB';
|
||||||
@ -70,12 +69,12 @@ public function profile($Automatic = '') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function analysis($Message, $Report = '', $Time = 43200) {
|
public function analysis($Message, $Report = '', $Time = 43200) {
|
||||||
global $Cache, $Document;
|
global $Document;
|
||||||
if (empty($Report)) {
|
if (empty($Report)) {
|
||||||
$Report = $Message;
|
$Report = $Message;
|
||||||
}
|
}
|
||||||
$Identifier = Users::make_secret(5);
|
$Identifier = Users::make_secret(5);
|
||||||
$Cache->cache_value(
|
G::$Cache->cache_value(
|
||||||
'analysis_'.$Identifier,
|
'analysis_'.$Identifier,
|
||||||
array(
|
array(
|
||||||
'url' => $_SERVER['REQUEST_URI'],
|
'url' => $_SERVER['REQUEST_URI'],
|
||||||
@ -269,13 +268,11 @@ public function get_includes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_cache_time() {
|
public function get_cache_time() {
|
||||||
global $Cache;
|
return G::$Cache->Time;
|
||||||
return $Cache->Time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_cache_keys() {
|
public function get_cache_keys() {
|
||||||
global $Cache;
|
return array_keys(G::$Cache->CacheHits);
|
||||||
return array_keys($Cache->CacheHits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_sphinx_queries() {
|
public function get_sphinx_queries() {
|
||||||
@ -301,13 +298,11 @@ public function get_sphinxql_time() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_queries() {
|
public function get_queries() {
|
||||||
global $DB;
|
return G::$DB->Queries;
|
||||||
return $DB->Queries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_query_time() {
|
public function get_query_time() {
|
||||||
global $DB;
|
return G::$DB->Time;
|
||||||
return $DB->Time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_logged_vars() {
|
public function get_logged_vars() {
|
||||||
@ -467,7 +462,6 @@ public function constant_table($Constants = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function cache_table($CacheKeys = false) {
|
public function cache_table($CacheKeys = false) {
|
||||||
global $Cache;
|
|
||||||
$Header = 'Cache keys';
|
$Header = 'Cache keys';
|
||||||
if (!is_array($CacheKeys)) {
|
if (!is_array($CacheKeys)) {
|
||||||
$CacheKeys = $this->get_cache_keys();
|
$CacheKeys = $this->get_cache_keys();
|
||||||
@ -492,7 +486,7 @@ public function cache_table($CacheKeys = false) {
|
|||||||
<a href="tools.php?action=clear_cache&key=<?=$Key?>&type=clear" target="_blank" class="brackets">Clear this cache key</a>
|
<a href="tools.php?action=clear_cache&key=<?=$Key?>&type=clear" target="_blank" class="brackets">Clear this cache key</a>
|
||||||
</td>
|
</td>
|
||||||
<td align="left" class="debug_data debug_cache_data">
|
<td align="left" class="debug_data debug_cache_data">
|
||||||
<pre id="debug_cache_<?=$Key?>" class="hidden"><?=display_str(print_r($Cache->get_value($Key, true), true))?></pre>
|
<pre id="debug_cache_<?=$Key?>" class="hidden"><?=display_str(print_r(G::$Cache->get_value($Key, true), true))?></pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
836
classes/donations.class.php
Normal file
836
classes/donations.class.php
Normal file
@ -0,0 +1,836 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
define('BTC_API_URL', 'https://blockchain.info/ticker');
|
||||||
|
define('USD_API_URL', 'http://www.google.com/ig/calculator?hl=en&q=1USD=?EUR');
|
||||||
|
|
||||||
|
class Donations {
|
||||||
|
private static $ForumDescriptions = array(
|
||||||
|
"I want only two houses, rather than seven... I feel like letting go of things",
|
||||||
|
"A billion here, a billion there, sooner or later it adds up to real money.",
|
||||||
|
"I've cut back, because I'm buying a house in the West Village.",
|
||||||
|
"Some girls are just born with glitter in their veins.",
|
||||||
|
"I get half a million just to show up at parties. My life is, like, really, really fun.",
|
||||||
|
"Some people change when they think they're a star or something",
|
||||||
|
"I'd rather not talk about money. It’s kind of gross.",
|
||||||
|
"I have not been to my house in Bermuda for two or three years, and the same goes for my house in Portofino. How long do I have to keep leading this life of sacrifice?",
|
||||||
|
"When I see someone who is making anywhere from $300,000 to $750,000 a year, that's middle class.",
|
||||||
|
"Money doesn't make you happy. I now have $50 million but I was just as happy when I had $48 million.",
|
||||||
|
"I'd rather smoke crack than eat cheese from a tin.",
|
||||||
|
"I am who I am. I can’t pretend to be somebody who makes $25,000 a year.",
|
||||||
|
"A girl never knows when she might need a couple of diamonds at ten 'o' clock in the morning.",
|
||||||
|
"I wouldn't run for president. I wouldn't want to move to a smaller house.",
|
||||||
|
"I have the stardom glow.",
|
||||||
|
"What's Walmart? Do they like, sell wall stuff?",
|
||||||
|
"Whenever I watch TV and see those poor starving kids all over the world, I can't help but cry. I mean I'd love to be skinny like that, but not with all those flies and death and stuff.",
|
||||||
|
"Too much money ain't enough money.",
|
||||||
|
"What's a soup kitchen?",
|
||||||
|
"I work very hard and I’m worth every cent!",
|
||||||
|
"To all my Barbies out there who date Benjamin Franklin, George Washington, Abraham Lincoln, you'll be better off in life. Get that money."
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
private static $IsSchedule = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function regular_donate($UserID, $DonationAmount, $Source, $Reason, $Currency = "EUR") {
|
||||||
|
self::donate($UserID, array(
|
||||||
|
"Source" => $Source,
|
||||||
|
"Price" => $DonationAmount,
|
||||||
|
"Currency" => $Currency,
|
||||||
|
"Source" => $Source,
|
||||||
|
"Reason" => $Reason,
|
||||||
|
"SendPM" => true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function donate($UserID, $Args) {
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
G::$DB->query("SELECT 1 FROM users_main WHERE ID = '$UserID'");
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
G::$Cache->InternalCache = false;
|
||||||
|
foreach($Args as &$Arg) {
|
||||||
|
$Arg = db_string($Arg);
|
||||||
|
}
|
||||||
|
extract($Args);
|
||||||
|
|
||||||
|
// We don't always get a date passed in.
|
||||||
|
if (empty($Date)) {
|
||||||
|
$Date = sqltime();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the ID of the staff member making the edit
|
||||||
|
$AddedBy = 0;
|
||||||
|
if (!self::$IsSchedule) {
|
||||||
|
$AddedBy = G::$LoggedUser['ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy donor, should remove at some point
|
||||||
|
G::$DB->query("UPDATE users_info SET Donor = '1' WHERE UserID = '$UserID'");
|
||||||
|
// Give them the extra invite
|
||||||
|
$ExtraInvite = G::$DB->affected_rows();
|
||||||
|
|
||||||
|
// A staff member is directly manipulating donor points
|
||||||
|
if ($Manipulation == "Direct") {
|
||||||
|
$DonorPoints = $Rank;
|
||||||
|
$AdjustedRank = $Rank >= MAX_EXTRA_RANK ? MAX_EXTRA_RANK : $Rank;
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO users_donor_ranks
|
||||||
|
(UserID, Rank, TotalRank, DonationTime)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '$AdjustedRank', '$TotalRank', '$Date')
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
Rank = '$AdjustedRank',
|
||||||
|
TotalRank = '$TotalRank',
|
||||||
|
DonationTime = '$Date'");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Donations from the store get donor points directly, no need to calculate them
|
||||||
|
if ($Source == "Store Parser") {
|
||||||
|
$ConvertedPrice = self::currency_exchange($Amount * $Price, $Currency);
|
||||||
|
} else {
|
||||||
|
$ConvertedPrice = self::currency_exchange($Price, $Currency);
|
||||||
|
$DonorPoints = self::calculate_rank($ConvertedPrice);
|
||||||
|
}
|
||||||
|
$IncreaseRank = $DonorPoints;
|
||||||
|
|
||||||
|
// Rank is the same thing as DonorPoints
|
||||||
|
$CurrentRank = self::get_rank($UserID);
|
||||||
|
// A user's donor rank can never exceed MAX_EXTRA_RANK
|
||||||
|
// If the amount they donated causes it to overflow, chnage it to MAX_EXTRA_RANK
|
||||||
|
// The total rank isn't affected by this, so their original donor point value is added to it
|
||||||
|
if (($CurrentRank + $DonorPoints) >= MAX_EXTRA_RANK) {
|
||||||
|
$AdjustedRank = MAX_EXTRA_RANK;
|
||||||
|
} else {
|
||||||
|
$AdjustedRank = $CurrentRank + $DonorPoints;
|
||||||
|
}
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO users_donor_ranks
|
||||||
|
(UserID, Rank, TotalRank, DonationTime)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '$AdjustedRank', '$DonorPoints', '$Date')
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
Rank = '$AdjustedRank',
|
||||||
|
TotalRank = TotalRank + '$DonorPoints',
|
||||||
|
DonationTime = '$Date'");
|
||||||
|
}
|
||||||
|
// Clear the rank cache key
|
||||||
|
G::$Cache->delete_value("donor_rank_$UserID");
|
||||||
|
|
||||||
|
// Get their rank
|
||||||
|
$Rank = self::get_rank($UserID);
|
||||||
|
$TotalRank = self::get_total_rank($UserID);
|
||||||
|
|
||||||
|
// Now that their rank and total rank has been set, we can calculate their special rank
|
||||||
|
self::calculate_special_rank($UserID);
|
||||||
|
|
||||||
|
// Hand out invites
|
||||||
|
G::$DB->query("SELECT InvitesRecievedRank FROM users_donor_ranks WHERE UserID = '$UserID'");
|
||||||
|
list($InvitesRecievedRank) = G::$DB->next_record();
|
||||||
|
$AdjustedRank = $Rank >= MAX_RANK ? (MAX_RANK - 1) : $Rank;
|
||||||
|
$InviteRank = $AdjustedRank - $InvitesRecievedRank;
|
||||||
|
if ($InviteRank > 0) {
|
||||||
|
$Invites = $ExtraInvite ? ($InviteRank + 1) : $InviteRank;
|
||||||
|
G::$DB->query("UPDATE users_main SET Invites = Invites + '$Invites' WHERE ID = $UserID");
|
||||||
|
G::$DB->query("UPDATE users_donor_ranks SET InvitesRecievedRank = '$AdjustedRank' WHERE UserID = '$UserID'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send them a thank you PM
|
||||||
|
if ($SendPM) {
|
||||||
|
$Subject = "Your contribution has been received and credited. Thank you!";
|
||||||
|
$Body = self::get_pm_body($Source, $Currency, $Price, $IncreaseRank, $Rank);
|
||||||
|
Misc::send_pm($UserID, 0, $Subject, $Body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lastly, add this donation to our history
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO donations
|
||||||
|
(UserID, Amount, Source, Reason, Currency, Email, Time, AddedBy, Rank, TotalRank)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '$ConvertedPrice', '$Source', '$Reason', '$Currency', '$Email', '$Date', '$AddedBy', '$DonorPoints', '$TotalRank')");
|
||||||
|
|
||||||
|
|
||||||
|
// Clear their user cache keys because the users_info values has been modified
|
||||||
|
G::$Cache->delete_value("user_info_$UserID");
|
||||||
|
G::$Cache->delete_value("user_info_heavy_$UserID");
|
||||||
|
G::$Cache->delete_value("donor_rank_$UserID");
|
||||||
|
G::$Cache->delete_value("donor_special_rank_$UserID");
|
||||||
|
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function calculate_special_rank($UserID) {
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
// Are they are special?
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT TotalRank, SpecialRank
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
// Adjust their special rank depending on the total rank.
|
||||||
|
list($TotalRank, $SpecialRank) = G::$DB->next_record();
|
||||||
|
if ($TotalRank < 10) {
|
||||||
|
$SpecialRank = 0;
|
||||||
|
}
|
||||||
|
if ($TotalRank >= 10) {
|
||||||
|
Misc::send_pm($UserID, 0, "You've Reached Special Donor Rank #1! You've Earned: One User Pick. Details Inside.", self::get_special_rank_one_pm());
|
||||||
|
$SpecialRank = 1;
|
||||||
|
}
|
||||||
|
if ($TotalRank >= 20) {
|
||||||
|
Misc::send_pm($UserID, 0, "You've Reached Special Donor Rank #2! You've Earned: The Double-Avatar. Details Inside.", self::get_special_rank_two_pm());
|
||||||
|
$SpecialRank = 2;
|
||||||
|
}
|
||||||
|
if ($TotalRank >= 50) {
|
||||||
|
Misc::send_pm($UserID, 0, "You've Reached Special Donor Rank #3! You've Earned: Diamond Rank. Details Inside.", self::get_special_rank_three_pm());
|
||||||
|
$SpecialRank = 3;
|
||||||
|
}
|
||||||
|
// Make them special
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_donor_ranks
|
||||||
|
SET SpecialRank = '$SpecialRank'
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
G::$Cache->delete_value("donor_special_rank_$UserID");
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function schedule() {
|
||||||
|
self::$IsSchedule = true;
|
||||||
|
|
||||||
|
DonationsBitcoin::find_new_donations();
|
||||||
|
//self::expire_ranks();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function expire_ranks() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT UserID, Rank
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE Rank > 1
|
||||||
|
AND SpecialRank != 3
|
||||||
|
AND DonationTime < NOW() - INTERVAL 32 DAY");
|
||||||
|
|
||||||
|
if (G::$DB->record_count() > 0) {
|
||||||
|
$UserIDs = array();
|
||||||
|
while (list($UserID, $Rank) = G::$DB->next_record()) {
|
||||||
|
G::$Cache->delete_value("donor_rank_$UserID");
|
||||||
|
G::$Cache->delete_value("donor_rewards_$UserID");
|
||||||
|
$UserIDs[] = $UserID;
|
||||||
|
}
|
||||||
|
$In = implode(',', $UserIDs);
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_donor_ranks
|
||||||
|
SET Rank = Rank - IF(Rank = " . MAX_RANK . ", 2, 1)
|
||||||
|
WHERE UserID IN ($In)");
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function calculate_rank($Amount) {
|
||||||
|
return floor($Amount / 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function update_rank($UserID, $Rank, $TotalRank, $Reason) {
|
||||||
|
$Rank = (int)$Rank;
|
||||||
|
$TotalRank = (int)$TotalRank;
|
||||||
|
|
||||||
|
self::donate($UserID, array(
|
||||||
|
"Manipulation" => "Direct",
|
||||||
|
"Rank" => $Rank,
|
||||||
|
"TotalRank" => $TotalRank,
|
||||||
|
"Reason" => $Reason,
|
||||||
|
"Source" => "Modify Values",
|
||||||
|
"Currency" => "EUR"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function hide_stats($UserID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO users_donor_ranks
|
||||||
|
(UserID, Hidden)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '1')
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
Hidden = '1'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function show_stats($UserID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO users_donor_ranks
|
||||||
|
(UserID, Hidden)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '0')
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
Hidden = '0'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function is_visible($UserID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT Hidden
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE Hidden = '0'
|
||||||
|
AND UserID = '$UserID'");
|
||||||
|
$HasResults = G::$DB->has_results();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $HasResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function has_donor_forum($UserID) {
|
||||||
|
return self::get_rank($UserID) >= DONOR_FORUM_RANK || self::get_special_rank($UserID) >= MAX_SPECIAL_RANK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function is_mod($UserID) {
|
||||||
|
$Permissions = Permissions::get_permissions_for_user($UserID);
|
||||||
|
return $Permissions['users_mod'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function get_rank($UserID) {
|
||||||
|
$Rank = G::$Cache->get_value("donor_rank_$UserID");
|
||||||
|
if ($Rank === false) {
|
||||||
|
if (self::is_mod($UserID)) {
|
||||||
|
$Rank = MAX_EXTRA_RANK;
|
||||||
|
} else {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT Rank
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
list($Rank) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
G::$Cache->cache_value("donor_rank_$UserID", $Rank, 0);
|
||||||
|
}
|
||||||
|
return $Rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_special_rank($UserID) {
|
||||||
|
$SpecialRank = G::$Cache->get_value("donor_special_rank_$UserID");
|
||||||
|
if ($SpecialRank === false) {
|
||||||
|
if (self::is_mod($UserID)) {
|
||||||
|
$SpecialRank = MAX_SPECIAL_RANK;
|
||||||
|
} else {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT SpecialRank
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
list($SpecialRank) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
G::$Cache->cache_value("donor_special_rank_$UserID", $SpecialRank, 0);
|
||||||
|
}
|
||||||
|
return $SpecialRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_total_rank($UserID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT TotalRank
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
list($Rank) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_donation_time($UserID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT DonationTime
|
||||||
|
FROM users_donor_ranks
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
list($DonationTime) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $DonationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_titles($UserID) {
|
||||||
|
$Results = G::$Cache->get_value("donor_title_$UserID");
|
||||||
|
if ($Results === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT Prefix, Suffix, UseComma
|
||||||
|
FROM donor_forum_usernames
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
$Results = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("donor_title_$UserID", $Results, 0);
|
||||||
|
}
|
||||||
|
return $Results;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function get_enabled_rewards($UserID) {
|
||||||
|
$Rewards = array();
|
||||||
|
$Rank = self::get_rank($UserID);
|
||||||
|
$SpecialRank = self::get_special_rank($UserID);
|
||||||
|
$HasAll = $SpecialRank == 3;
|
||||||
|
|
||||||
|
if ($Rank >= 1 || $HasAll) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($Rank >= 2 || $HasAll) {
|
||||||
|
$Rewards["HasDonorIconMouseOverText"] = true;
|
||||||
|
$Rewards["HasProfileInfo1"] = true;
|
||||||
|
}
|
||||||
|
if ($Rank >= 3 || $HasAll) {
|
||||||
|
$Rewards["HasAvatarMouseOverText"] = true;
|
||||||
|
$Rewards["HasProfileInfo2"] = true;
|
||||||
|
}
|
||||||
|
if ($Rank >= 4 || $HasAll) {
|
||||||
|
$Rewards["HasDonorIconLink"] = true;
|
||||||
|
$Rewards["HasProfileInfo3"] = true;
|
||||||
|
}
|
||||||
|
if ($Rank >= MAX_RANK || $HasAll) {
|
||||||
|
$Rewards["HasCustomDonorIcon"] = true;
|
||||||
|
$Rewards["HasDonorForum"] = true;
|
||||||
|
$Rewards["HasProfileInfo4"] = true;
|
||||||
|
}
|
||||||
|
if ($SpecialRank >= 2) {
|
||||||
|
$Rewards["HasSecondAvatar"] = true;
|
||||||
|
}
|
||||||
|
return $Rewards;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_rewards($UserID) {
|
||||||
|
$Results = G::$Cache->get_value("donor_rewards_$UserID");
|
||||||
|
if ($Results === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
IconMouseOverText,
|
||||||
|
AvatarMouseOverText,
|
||||||
|
CustomIcon,
|
||||||
|
CustomIconLink,
|
||||||
|
SecondAvatar
|
||||||
|
FROM donor_rewards
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
$Results = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("donor_rewards_$UserID", $Results, 0);
|
||||||
|
}
|
||||||
|
return $Results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_profile_rewards($UserID) {
|
||||||
|
$Results = G::$Cache->get_value("donor_profile_rewards_$UserID");
|
||||||
|
if ($Results === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
ProfileInfo1,
|
||||||
|
ProfileInfoTitle1,
|
||||||
|
ProfileInfo2,
|
||||||
|
ProfileInfoTitle2,
|
||||||
|
ProfileInfo3,
|
||||||
|
ProfileInfoTitle3,
|
||||||
|
ProfileInfo4,
|
||||||
|
ProfileInfoTitle4
|
||||||
|
FROM donor_rewards
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
$Results = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("donor_profile_rewards_$UserID", $Results, 0);
|
||||||
|
}
|
||||||
|
return $Results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function add_profile_info_reward($Counter, &$Insert, &$Values, &$Update) {
|
||||||
|
if (isset($_POST["profile_title_" . $Counter]) && isset($_POST["profile_info_" . $Counter])) {
|
||||||
|
$ProfileTitle = db_string($_POST["profile_title_" . $Counter]);
|
||||||
|
$ProfileInfo = db_string($_POST["profile_info_" . $Counter]);
|
||||||
|
$ProfileInfoTitleSQL = "ProfileInfoTitle" . $Counter;
|
||||||
|
$ProfileInfoSQL = "ProfileInfo" . $Counter;
|
||||||
|
$Insert[] = "$ProfileInfoTitleSQL";
|
||||||
|
$Values[] = "'$ProfileInfoTitle'";
|
||||||
|
$Update[] = "$ProfileInfoTitleSQL = '$ProfileTitle'";
|
||||||
|
$Insert[] = "$ProfileInfoSQL";
|
||||||
|
$Values[] = "'$ProfileInfo'";
|
||||||
|
$Update[] = "$ProfileInfoSQL = '$ProfileInfo'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function update_rewards($UserID) {
|
||||||
|
$Rank = self::get_rank($UserID);
|
||||||
|
$SpecialRank = self::get_special_rank($UserID);
|
||||||
|
$HasAll = $SpecialRank == 3;
|
||||||
|
$Counter = 0;
|
||||||
|
$Insert = array();
|
||||||
|
$Values = array();
|
||||||
|
$Update = array();
|
||||||
|
|
||||||
|
$Insert[] = "UserID";
|
||||||
|
$Values[] = "'$UserID'";
|
||||||
|
if ($Rank >= 1 || $HasAll) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($Rank >= 2 || $HasAll) {
|
||||||
|
if (isset($_POST['donor_icon_mouse_over_text'])) {
|
||||||
|
$IconMouseOverText = db_string($_POST['donor_icon_mouse_over_text']);
|
||||||
|
$Insert[] = "IconMouseOverText";
|
||||||
|
$Values[] = "'$IconMouseOverText'";
|
||||||
|
$Update[] = "IconMouseOverText = '$IconMouseOverText'";
|
||||||
|
}
|
||||||
|
$Counter++;
|
||||||
|
}
|
||||||
|
if ($Rank >= 3 || $HasAll) {
|
||||||
|
if (isset($_POST['avatar_mouse_over_text'])) {
|
||||||
|
$AvatarMouseOverText = db_string($_POST['avatar_mouse_over_text']);
|
||||||
|
$Insert[] = "AvatarMouseOverText";
|
||||||
|
$Values[] = "'$AvatarMouseOverText'";
|
||||||
|
$Update[] = "AvatarMouseOverText = '$AvatarMouseOverText'";
|
||||||
|
}
|
||||||
|
$Counter++;
|
||||||
|
}
|
||||||
|
if ($Rank >= 4 || $HasAll) {
|
||||||
|
if (isset($_POST['donor_icon_link'])) {
|
||||||
|
$CustomIconLink = db_string($_POST['donor_icon_link']);
|
||||||
|
if (!Misc::is_valid_url($CustomIconLink)) {
|
||||||
|
$CustomIconLink = '';
|
||||||
|
}
|
||||||
|
$Insert[] = "CustomIconLink";
|
||||||
|
$Values[] = "'$CustomIconLink'";
|
||||||
|
$Update[] = "CustomIconLink = '$CustomIconLink'";
|
||||||
|
}
|
||||||
|
$Counter++;
|
||||||
|
}
|
||||||
|
if ($Rank >= MAX_RANK || $HasAll) {
|
||||||
|
if (isset($_POST['donor_icon_custom_url'])) {
|
||||||
|
$CustomIcon = db_string($_POST['donor_icon_custom_url']);
|
||||||
|
if (!Misc::is_valid_url($CustomIcon)) {
|
||||||
|
$CustomIcon = '';
|
||||||
|
}
|
||||||
|
$Insert[] = "CustomIcon";
|
||||||
|
$Values[] = "'$CustomIcon'";
|
||||||
|
$Update[] = "CustomIcon = '$CustomIcon'";
|
||||||
|
}
|
||||||
|
self::update_titles($UserID, $_POST['donor_title_prefix'], $_POST['donor_title_suffix'], $_POST['donor_title_comma']);
|
||||||
|
$Counter++;
|
||||||
|
}
|
||||||
|
for ($i = 1; $i <= $Counter; $i++) {
|
||||||
|
self::add_profile_info_reward($i, $Insert, $Values, $Update);
|
||||||
|
}
|
||||||
|
if ($SpecialRank >= 2) {
|
||||||
|
if (isset($_POST['second_avatar'])) {
|
||||||
|
$SecondAvatar = db_string($_POST['second_avatar']);
|
||||||
|
if (!Misc::is_valid_url($SecondAvatar)) {
|
||||||
|
$SecondAvatar = '';
|
||||||
|
}
|
||||||
|
$Insert[] = "SecondAvatar";
|
||||||
|
$Values[] = "'$SecondAvatar'";
|
||||||
|
$Update[] = "SecondAvatar = '$SecondAvatar'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$Insert = implode(', ', $Insert);
|
||||||
|
$Values = implode(', ', $Values);
|
||||||
|
$Update = implode(', ', $Update);
|
||||||
|
if ($Counter > 0) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO donor_rewards
|
||||||
|
($Insert)
|
||||||
|
VALUES
|
||||||
|
($Values)
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
$Update");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value("donor_profile_rewards_$UserID");
|
||||||
|
G::$Cache->delete_value("donor_rewards_$UserID");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function update_titles($UserID, $Prefix, $Suffix, $UseComma) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
$Prefix = trim(db_string($Prefix));
|
||||||
|
$Suffix = trim(db_string($Suffix));
|
||||||
|
$UseComma = empty($UseComma) ? true : false;
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO donor_forum_usernames
|
||||||
|
(UserID, Prefix, Suffix, UseComma)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '$Prefix', '$Suffix', '$UseComma')
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
Prefix = '$Prefix',
|
||||||
|
Suffix = '$Suffix',
|
||||||
|
UseComma = '$UseComma'");
|
||||||
|
G::$Cache->delete_value("donor_title_$UserID");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function get_donation_history($UserID) {
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
if (empty($UserID)) {
|
||||||
|
error(404);
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT Amount, Email, Time, Currency, Reason, Source, AddedBy, Rank, TotalRank
|
||||||
|
FROM donations
|
||||||
|
WHERE UserID = '$UserID'
|
||||||
|
ORDER BY Time DESC");
|
||||||
|
$DonationHistory = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $DonationHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_rank_expiration($UserID) {
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("SELECT Rank, SpecialRank, (DonationTime + INTERVAL 32 DAY) AS Expiration FROM users_donor_ranks WHERE UserID = '$UserID'");
|
||||||
|
$Return = "";
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
list($Rank, $SpecialRank, $Expiration) = G::$DB->next_record();
|
||||||
|
$Expiration = time_diff($Expiration);
|
||||||
|
if ($Expiration != "Never") {
|
||||||
|
$Expiration = "in " . $Expiration;
|
||||||
|
}
|
||||||
|
$Return = $SpecialRank == MAX_SPECIAL_RANK || $Rank == 1 ? "Never" : $Expiration;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_leaderboard_position($UserID) {
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("SET @RowNum := 0");
|
||||||
|
G::$DB->query("SELECT Position FROM (SELECT d.UserID, @RowNum := @RowNum + 1 AS Position FROM users_donor_ranks d ORDER BY TotalRank DESC) l WHERE UserID = '$UserID'");
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
list($Position) = G::$DB->next_record();
|
||||||
|
} else {
|
||||||
|
$Position = 0;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function is_donor($UserID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("SELECT 1 FROM users_donor_ranks WHERE UserID = '$UserID'");
|
||||||
|
$HasResults = G::$DB->has_results();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $HasResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function currency_exchange($Amount, $Currency) {
|
||||||
|
if (!self::is_valid_currency($Currency)) {
|
||||||
|
error("$Currency is not valid currency");
|
||||||
|
}
|
||||||
|
switch ($Currency) {
|
||||||
|
case 'USD':
|
||||||
|
$Amount = self::usd_to_euro($Amount);
|
||||||
|
break;
|
||||||
|
case 'BTC':
|
||||||
|
$Amount = self::btc_to_euro($Amount);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return round($Amount, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function is_valid_currency($Currency) {
|
||||||
|
return $Currency == 'EUR' || $Currency == 'BTC' || $Currency == 'USD';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function btc_to_euro($Amount) {
|
||||||
|
$Rate = G::$Cache->get_value('btc_rate');
|
||||||
|
if (empty($Rate)) {
|
||||||
|
if ($Response = file_get_contents(BTC_API_URL)) {
|
||||||
|
$Response = json_decode($Response, true);
|
||||||
|
if (isset($Response['EUR'])) {
|
||||||
|
$Rate = round($Response['EUR']['24h'], 4); // We don't need good precision
|
||||||
|
self::set_stored_conversion_rate('BTC', $Rate);
|
||||||
|
$CacheTime = 86400; // Cache fresh value for 24 hours;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($Rate)) {
|
||||||
|
$Rate = self::get_stored_conversion_rate('BTC');
|
||||||
|
$CacheTime = 3600; // Cache old value for 1 hour;
|
||||||
|
}
|
||||||
|
G::$Cache->cache_value('btc_rate', $Rate, $CacheTime);
|
||||||
|
}
|
||||||
|
return $Rate * $Amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function usd_to_euro($Amount) {
|
||||||
|
$Rate = G::$Cache->get_value('usd_rate');
|
||||||
|
if (empty($Rate)) {
|
||||||
|
if ($Response = file_get_contents(USD_API_URL)) {
|
||||||
|
// Valid JSON isn't returned so we make it valid.
|
||||||
|
$Replace = array(
|
||||||
|
'lhs' => '"lhs"',
|
||||||
|
'rhs' => '"rhs"',
|
||||||
|
'error' => '"error"',
|
||||||
|
'icc' => '"icc"'
|
||||||
|
);
|
||||||
|
|
||||||
|
$Response = str_replace(array_keys($Replace), array_values($Replace), $Response);
|
||||||
|
$Response = json_decode($Response, true);
|
||||||
|
if (isset($Response['rhs'])) {
|
||||||
|
// The response is in format "# Euroes", extracts the numbers.
|
||||||
|
$Rate = preg_split("/[\s,]+/", $Response['rhs']);
|
||||||
|
$Rate = round($Rate[0], 4); // We don't need good precision
|
||||||
|
self::set_stored_conversion_rate('USD', $Rate);
|
||||||
|
$CacheTime = 86400; // Cache fresh value for 24 hours;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($Rate)) {
|
||||||
|
$Rate = self::get_stored_conversion_rate('USD');
|
||||||
|
$CacheTime = 3600; // Cache old value for 1 hour;
|
||||||
|
}
|
||||||
|
G::$Cache->cache_value('usd_rate', $Rate, $CacheTime);
|
||||||
|
}
|
||||||
|
return $Rate * $Amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_stored_conversion_rate($Currency) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT Rate
|
||||||
|
FROM currency_conversion_rates
|
||||||
|
WHERE Currency = '$Currency'");
|
||||||
|
list($Rate) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function set_stored_conversion_rate($Currency, $Rate) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
REPLACE INTO currency_conversion_rates
|
||||||
|
(Currency, Rate, Time)
|
||||||
|
VALUES
|
||||||
|
('$Currency', $Rate, NOW())");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_forum_description() {
|
||||||
|
return self::$ForumDescriptions[rand(0, count(self::$ForumDescriptions) - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function get_pm_body($Source, $Currency, $DonationAmount, $ReceivedRank, $CurrentRank) {
|
||||||
|
if ($Source == 'Store Parser') {
|
||||||
|
$String = "[*][b]You Purchased:[/b] $DonationAmount $Currency";
|
||||||
|
} else {
|
||||||
|
$String = "[*][b]You Donated:[/b] $DonationAmount $Currency";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Thank you for your generosity and support. It\'s users like you who make all of this possible. What follows is a brief description of your transaction:
|
||||||
|
|
||||||
|
' . $String . '
|
||||||
|
[*][b]You Received:[/b] ' . $ReceivedRank . ' Donor Point' . ($ReceivedRank == 1 ? '' : 's') . '
|
||||||
|
[*][b]Your Donor Rank:[/b] Donor Rank # ' . $CurrentRank . '
|
||||||
|
Once again, thank you for your continued support of the site.
|
||||||
|
|
||||||
|
Sincerely,
|
||||||
|
|
||||||
|
'.SITE_NAME.' Staff
|
||||||
|
|
||||||
|
[align=center][If you have any questions or concerns, please [url=https://'.SSL_SITE_URL.'/staffpm.php]send a Staff PM[/url].]';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function get_special_rank_one_pm() {
|
||||||
|
return 'Congratulations on reaching [url=https://'.SSL_SITE_URL.'/staffpm.php]Special Rank #1[/url]! You\'ve been awarded [b]one user pick[/b]! This user pick will be featured on the '.SITE_NAME.' front page during an upcoming event. After you submit your pick, there is no guarantee as to how long it will take before your pick is featured. Picks will be featured on a first-submitted, first-served basis. Please abide by the following guidelines when making your selection:
|
||||||
|
|
||||||
|
[*]Pick something that hasn\'t been chosen. You can tell if a pick has been used previously by looking at the collages it\'s in.
|
||||||
|
[*]Complete the enclosed form carefully and completely.
|
||||||
|
[*]Send a [url=https://'.SSL_SITE_URL.'/forums.php?action=viewthread&threadid=178640&postid=4839790#post4839790]Staff PM[/url] with the completed form. Title this PM "Special Rank User Pick".
|
||||||
|
[important][align=center]**The following form must be used. Do not edit the BBCode. Send a Staff PM with the completed form.**[/align][/important]
|
||||||
|
[quote][plain]FRONT PAGE:------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
[b][size=5][user]<NAME>[/user]\'s Special Donor Pick[/size][/b]
|
||||||
|
|
||||||
|
[b]Artist Name - Album Title[/b]
|
||||||
|
|
||||||
|
[b]Genre:[/b] Alternative, Rock, Grunge
|
||||||
|
|
||||||
|
[b]Torrents:[/b] Link Goes Here
|
||||||
|
|
||||||
|
[b]Review:[/b] [quote]Review Here (Limit: 1 Paragraph)[/quote]
|
||||||
|
|
||||||
|
|
||||||
|
FORUM POST:------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
[b][size=5][user]<NAME>[/user]\'s Special Donor Pick[/size][/b]
|
||||||
|
|
||||||
|
[img=Album Cover]
|
||||||
|
|
||||||
|
[b]Artist Name - Album Title[/b]
|
||||||
|
|
||||||
|
[b]Genre:[/b] Alternative, Rock, Grunge
|
||||||
|
|
||||||
|
[b]Torrents:[/b] Link Goes Here
|
||||||
|
|
||||||
|
[b]Release Info[/b]
|
||||||
|
|
||||||
|
[u]Release Date:[/u] Date
|
||||||
|
[u]Tracks:[/u] Tracks
|
||||||
|
[u]Length:[/u] Length
|
||||||
|
[u]Label:[/u] Label
|
||||||
|
|
||||||
|
[u]Band Member — Instruments[/u]
|
||||||
|
Member 1 — Guitar
|
||||||
|
Member 2 — Drums
|
||||||
|
|
||||||
|
[b]Track Listing:[/b]
|
||||||
|
|
||||||
|
01. Remove
|
||||||
|
02. These
|
||||||
|
03. As Is
|
||||||
|
04. Necessary
|
||||||
|
05. Track 05
|
||||||
|
06. Track 06
|
||||||
|
07. Track 07
|
||||||
|
08. Track 08
|
||||||
|
09. Track 09
|
||||||
|
10. Track 10
|
||||||
|
|
||||||
|
[b]Web site:[/b] Link
|
||||||
|
|
||||||
|
[b]Review:[/b] [quote]Review Here (No Length Limit)[/quote]
|
||||||
|
[/plain][/quote]Alternately, you may use this [url=http://pick.thehash.es/]pick generator tool[/url] to assist you in properly formatting your pick.
|
||||||
|
|
||||||
|
At this time, we\'d like to thank you for your continued support of the site. The fact that you\'ve reached this milestone is testament to your belief in '.SITE_NAME.' as a project. It\'s dedicated users like you that keep us alive. We look forward to featuring your pick in an upcoming announcement.
|
||||||
|
|
||||||
|
Sincerely,
|
||||||
|
|
||||||
|
'.SITE_NAME.' Staff';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function get_special_rank_two_pm() {
|
||||||
|
return 'Congratulations on reaching [url=https://'.SSL_SITE_URL.'/forums.php?action=viewthread&threadid=178640&postid=4839790#post4839790]Special Rank #2[/url]! You\'ve been awarded [b]double avatar functionality[/b]! To set a second avatar, please enter a URL leading to a valid image in the new field which has been unlocked in your [b]Personal Settings[/b]. Any avatar you choose must abide by normal avatar rules. When running your cursor over your avatar, it will flip to the alternate choice you\'ve established. Other users will also be able to view both of your avatars using this method.
|
||||||
|
|
||||||
|
At this time, we\'d like to thank you for your continued support of the site. The fact that you\'ve reached this milestone is testament to your belief in '.SITE_NAME.' as a project. It\'s dedicated users like you that keep us alive. Have fun with the new toy.
|
||||||
|
|
||||||
|
Sincerely,
|
||||||
|
|
||||||
|
'.SITE_NAME.' Staff';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function get_special_rank_three_pm() {
|
||||||
|
return 'Congratulations on reaching [url=https://'.SSL_SITE_URL.'/forums.php?action=viewthread&threadid=178640&postid=4839790#post4839790]Special Rank #3[/url]! You\'ve been awarded [b]Diamond Rank[/b]! Diamond Rank grants you the benefits associated with every Donor Rank up to and including Gold ([url=https://'.SSL_SITE_URL.'/forums.php?action=viewthread&threadid=178640&postid=4839789#post4839789]Donor Rank #5[/url]). But unlike Donor Rank #5 - because Diamond Rank is a Special Rank - it will never expire.
|
||||||
|
|
||||||
|
At this time, we\'d like to thank you for your continued support of the site. The fact that you\'ve reached this milestone is testament to your belief in '.SITE_NAME.' as a project. It\'s dedicated users like you that keep us alive. Consider yourself one of our top supporters!
|
||||||
|
|
||||||
|
Sincerely,
|
||||||
|
|
||||||
|
'.SITE_NAME.' Staff';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
186
classes/donationsbitcoin.class.php
Normal file
186
classes/donationsbitcoin.class.php
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
<?
|
||||||
|
class DonationsBitcoin {
|
||||||
|
/**
|
||||||
|
* Ask bitcoind for a list of all addresses that have received bitcoins
|
||||||
|
*
|
||||||
|
* @return array (BitcoinAddress => Amount, ...)
|
||||||
|
*/
|
||||||
|
public static function get_received() {
|
||||||
|
if (defined('BITCOIN_RPC_URL')) {
|
||||||
|
$Donations = BitcoinRpc::listreceivedbyaddress();
|
||||||
|
}
|
||||||
|
if (empty($Donations)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$BTCUsers = array();
|
||||||
|
foreach ($Donations as $Account) {
|
||||||
|
$BTCUsers[$Account->address] = $Account->amount;
|
||||||
|
}
|
||||||
|
return $BTCUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask bitcoind for the current account balance
|
||||||
|
*
|
||||||
|
* @return float balance
|
||||||
|
*/
|
||||||
|
public static function get_balance() {
|
||||||
|
if (defined('BITCOIN_RPC_URL')) {
|
||||||
|
return BitcoinRpc::getbalance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a user's existing bitcoin address or generate a new one
|
||||||
|
*
|
||||||
|
* @param int $UserID
|
||||||
|
* @param bool $GenAddress whether to create a new address if it doesn't exist
|
||||||
|
* @return false if no address exists and $GenAddress is false
|
||||||
|
* string bitcoin address otherwise
|
||||||
|
*/
|
||||||
|
public static function get_address($UserID, $GenAddress = false) {
|
||||||
|
$UserID = (int)$UserID;
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT BitcoinAddress
|
||||||
|
FROM users_info
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
list($Addr) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
if (!empty($Addr)) {
|
||||||
|
return $Addr;
|
||||||
|
} elseif ($GenAddress) {
|
||||||
|
if (defined('BITCOIN_RPC_URL')) {
|
||||||
|
$NewAddr = BitcoinRpc::getnewaddress();
|
||||||
|
}
|
||||||
|
if (empty($NewAddr)) {
|
||||||
|
error(0);
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_info
|
||||||
|
SET BitcoinAddress = '".db_string($NewAddr)."'
|
||||||
|
WHERE UserID = '$UserID'
|
||||||
|
AND BitcoinAddress IS NULL");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $NewAddr;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask bitcoind for the total amount of bitcoins received
|
||||||
|
*
|
||||||
|
* @return float amount
|
||||||
|
*/
|
||||||
|
public static function get_total_received() {
|
||||||
|
if (defined('BITCOIN_RPC_URL')) {
|
||||||
|
$Accounts = BitcoinRpc::listreceivedbyaccount();
|
||||||
|
}
|
||||||
|
if (empty($Accounts)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
foreach ($Accounts as $Account) {
|
||||||
|
if ($Account->account == '') {
|
||||||
|
return $Account->amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate bitcoin addresses to user IDs
|
||||||
|
*
|
||||||
|
* @param array $Addresses list of bitcoin addresses
|
||||||
|
* @return array (BitcoinAddress => UserID, ...)
|
||||||
|
*/
|
||||||
|
public static function get_userids($Addresses) {
|
||||||
|
if (!is_array($Addresses) || empty($Addresses)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT BitcoinAddress, UserID
|
||||||
|
FROM users_info
|
||||||
|
WHERE BitcoinAddress IN ('" . implode("', '", $Addresses) . "')");
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
$UserIDs = G::$DB->to_pair(0, 1);
|
||||||
|
} else {
|
||||||
|
$UserIDs = array();
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $UserIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find and process new donations since the last time this function was called.
|
||||||
|
*/
|
||||||
|
public static function find_new_donations() {
|
||||||
|
global $Debug;
|
||||||
|
if (($OldAmount = G::$Cache->get_value('btc_total_received')) === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT IFNULL(SUM(Amount), 0)
|
||||||
|
FROM donations_bitcoin");
|
||||||
|
list($OldAmount) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
$NewAmount = self::get_total_received();
|
||||||
|
if ($NewAmount < $OldAmount) {
|
||||||
|
// This shouldn't happen. Perhaps bitcoind was restarted recently
|
||||||
|
// or the block index was removed. Either way, try again later
|
||||||
|
send_irc('PRIVMSG ' . LAB_CHAN . " :Bad bitcoin donation data (is $NewAmount, was $OldAmount). If this persists, something is probably wrong");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($NewAmount > $OldAmount) {
|
||||||
|
// I really wish we didn't have to do it like this
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT BitcoinAddress, SUM(Amount)
|
||||||
|
FROM donations_bitcoin
|
||||||
|
GROUP BY BitcoinAddress");
|
||||||
|
$OldDonations = G::$DB->to_pair(0, 1, false);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
$NewDonations = self::get_received();
|
||||||
|
foreach ($NewDonations as $Address => &$Amount) {
|
||||||
|
if (isset($OldDonations[$Address])) {
|
||||||
|
if ($Amount == $OldDonations[$Address]) { // Direct comparison should be fine as everything comes from bitcoind
|
||||||
|
unset($NewDonations[$Address]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$Debug->log_var(array('old' => $OldDonations[$Address], 'new' => $Amount), "New donations from $Address");
|
||||||
|
// PHP doesn't do fixed-point math, and json_decode has already botched the precision
|
||||||
|
// so let's just round this off to satoshis and pray that we're on a 64 bit system
|
||||||
|
$Amount = round($Amount - $OldDonations[$Address], 8);
|
||||||
|
}
|
||||||
|
$NewDonations[$Address] = $Amount;
|
||||||
|
}
|
||||||
|
$Debug->log_var($NewDonations, '$NewDonations');
|
||||||
|
foreach (self::get_userids(array_keys($NewDonations)) as $Address => $UserID) {
|
||||||
|
Donations::regular_donate($UserID, $NewDonations[$Address], 'Bitcoin Parser', '', 'BTC');
|
||||||
|
self::store_donation($Address, $NewDonations[$Address]);
|
||||||
|
}
|
||||||
|
G::$Cache->cache_value('btc_total_received', $NewAmount, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record a donation in the database
|
||||||
|
*
|
||||||
|
* @param string $Address bitcoin address
|
||||||
|
* @param double $Amount amount of bitcoins transferred
|
||||||
|
*/
|
||||||
|
public static function store_donation($Address, $Amount) {
|
||||||
|
if (!is_numeric($Amount) || $Amount <= 0) {
|
||||||
|
// Panic!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO donations_bitcoin
|
||||||
|
(BitcoinAddress, Amount)
|
||||||
|
VALUES
|
||||||
|
('$Address', $Amount)");
|
||||||
|
}
|
||||||
|
}
|
212
classes/donationsview.class.php
Normal file
212
classes/donationsview.class.php
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
class DonationsView {
|
||||||
|
public static function render_mod_donations($UserID) { ?>
|
||||||
|
<table class="layout" id="donation_box">
|
||||||
|
<tr class="colhead">
|
||||||
|
<td colspan="2">
|
||||||
|
<a href="#donor_ranks" class="brackets anchor">#</a> Donor System (add points)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Value</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="donation_value" onkeypress="return isNumberKey(event);" />
|
||||||
|
<select name="donation_currency">
|
||||||
|
<option value="EUR">EUR</option>
|
||||||
|
<option value="USD">USD</option>
|
||||||
|
<option value="BTC">BTC</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Reason</td>
|
||||||
|
<td><input type="text" class="wide_input_text" name="donation_reason" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right" colspan="2">
|
||||||
|
<input type="submit" name="donor_points_submit" value="Add donor points" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table class="layout" id="donor_points_box">
|
||||||
|
<tr class="colhead">
|
||||||
|
<td colspan="3" class="tooltip" title='Use this tool only when manually correcting values. If crediting donations normally, use the "Donor System (add points)" tool'>
|
||||||
|
<a href="#donor_points" class="brackets anchor">#</a> Donor System (modify values)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Active points determine a user's Donor Rank and do expire.">Active points</td>
|
||||||
|
<td><input type="text" name="donor_rank" onkeypress="return isNumberKey(event);" value="<?=Donations::get_rank($UserID)?>" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Total points represent a user's overall total and never expire. Total points determines a user's Special Rank and Donor Leaderboard placement.">Total points</td>
|
||||||
|
<td><input type="text" name="total_donor_rank" onkeypress="return isNumberKey(event);" value="<?=Donations::get_total_rank($UserID)?>" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Reason</td>
|
||||||
|
<td><input type="text" class="wide_input_text" name="reason" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right" colspan="2">
|
||||||
|
<input type="submit" name="donor_values_submit" value="Change point values" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function render_donor_stats($UserID) {
|
||||||
|
$OwnProfile = G::$LoggedUser['ID'] == $UserID;
|
||||||
|
if (check_perms("users_mod") || $OwnProfile || Donations::is_visible($UserID)) { ?>
|
||||||
|
<div class="box box_info box_userinfo_donor_stats">
|
||||||
|
<div class="head colhead_dark">Donor Statistics</div>
|
||||||
|
<ul class="stats nobullet">
|
||||||
|
<?
|
||||||
|
if (Donations::is_donor($UserID)) {
|
||||||
|
if (check_perms('users_mod') || $OwnProfile) { ?>
|
||||||
|
<li>
|
||||||
|
Total donor points: <?=Donations::get_total_rank($UserID)?>
|
||||||
|
</li>
|
||||||
|
<? } ?>
|
||||||
|
<li>
|
||||||
|
Current donor rank: <?=self::render_rank(Donations::get_rank($UserID), Donations::get_special_rank($UserID), true)?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Leaderboard position: <?=Donations::get_leaderboard_position($UserID)?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Last donated: <?=time_diff(Donations::get_donation_time($UserID))?>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Rank expires: <?=(Donations::get_rank_expiration($UserID))?>
|
||||||
|
</li>
|
||||||
|
<? } else { ?>
|
||||||
|
<li>
|
||||||
|
This user hasn't donated.
|
||||||
|
</li>
|
||||||
|
<? } ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function render_profile_rewards($EnabledRewards, $ProfileRewards) {
|
||||||
|
$Text = new Text;
|
||||||
|
for ($i = 1; $i <= 4; $i++) {
|
||||||
|
if (isset($EnabledRewards['HasProfileInfo' . $i]) && $ProfileRewards['ProfileInfo' . $i]) { ?>
|
||||||
|
<div class="box">
|
||||||
|
<div class="head" style="height: 13px;">
|
||||||
|
<span style="float: left;"><?=!empty($ProfileRewards['ProfileInfoTitle' . $i]) ? display_str($ProfileRewards['ProfileInfoTitle' . $i]) : "Extra Profile " . ($i + 1)?></span>
|
||||||
|
<span style="float: right;"><a href="#" onclick="$('#profilediv_<?=$i?>').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Hide</a></span>
|
||||||
|
</div>
|
||||||
|
<div class="pad" id="profilediv_<?=$i?>">
|
||||||
|
<? echo $Text->full_format($ProfileRewards['ProfileInfo' . $i]); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function render_donation_history($DonationHistory) {
|
||||||
|
if (empty($DonationHistory)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="box box2" id="donation_history_box">
|
||||||
|
<div class="head">
|
||||||
|
<a href="#donation_history_box" class="brackets anchor">#</a> Donation History <a href="#" onclick="$('#donation_history').gtoggle(); return false;" class="brackets">View</a>
|
||||||
|
</div>
|
||||||
|
<? $Row = 'b'; ?>
|
||||||
|
<div class="hidden" id="donation_history">
|
||||||
|
<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr class="colhead_dark">
|
||||||
|
<td>
|
||||||
|
<strong>Source</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>Date</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>Amount (EUR)</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>Added Points</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>Total Points</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>Email</strong>
|
||||||
|
</td>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<strong>Reason</strong>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? foreach ($DonationHistory as $Donation) { ?>
|
||||||
|
<tr class="row<?=$Row?>">
|
||||||
|
<td>
|
||||||
|
<?=$Donation['Source']?> (<?=Users::format_username($Donation['AddedBy'])?>)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$Donation['Time']?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$Donation['Amount']?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$Donation['Rank']?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$Donation['TotalRank']?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$Donation['Email']?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$Donation['Reason']?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?
|
||||||
|
$Row = $Row == 'b' ? 'a' : 'b';
|
||||||
|
} ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function render_rank($Rank, $SpecialRank, $ShowOverflow = false) {
|
||||||
|
if ($SpecialRank == 3) {
|
||||||
|
$Display = '∞ [Diamond]';
|
||||||
|
} else {
|
||||||
|
$CurrentRank = $Rank >= MAX_RANK ? MAX_RANK : $Rank;
|
||||||
|
$Overflow = $Rank - $CurrentRank;
|
||||||
|
$Display = $CurrentRank;
|
||||||
|
if ($Display == 5 || $Display == 6) {
|
||||||
|
$Display--;
|
||||||
|
}
|
||||||
|
if ($ShowOverflow && $Overflow) {
|
||||||
|
$Display .= " (+$Overflow)";
|
||||||
|
}
|
||||||
|
if ($Rank >= 6) {
|
||||||
|
$Display .= ' [Gold]';
|
||||||
|
} elseif ($Rank >= 4) {
|
||||||
|
$Display .= ' [Silver]';
|
||||||
|
} elseif ($Rank >= 3) {
|
||||||
|
$Display .= ' [Bronze]';
|
||||||
|
} elseif ($Rank >= 2) {
|
||||||
|
$Display .= ' [Copper]';
|
||||||
|
} elseif ($Rank >= 1) {
|
||||||
|
$Display .= ' [Red]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo $Display;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -53,6 +53,7 @@ public static function cut_string($Str, $Length, $Hard = false, $ShowDots = true
|
|||||||
$CutDesc = implode(' ', $DescArr);
|
$CutDesc = implode(' ', $DescArr);
|
||||||
}
|
}
|
||||||
if ($ShowDots) {
|
if ($ShowDots) {
|
||||||
|
//TODO: should we replace the three dots with an ellipsis character?
|
||||||
$CutDesc .= '...';
|
$CutDesc .= '...';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -123,7 +124,7 @@ public static function get_ratio_html($Dividend, $Divisor, $Color = true) {
|
|||||||
* Returns ratio
|
* Returns ratio
|
||||||
* @param int $Dividend
|
* @param int $Dividend
|
||||||
* @param int $Divisor
|
* @param int $Divisor
|
||||||
* @param int $Decimal floor to n decimals (e.g. Subtract .005 to floor to 2 decimals)
|
* @param int $Decimal floor to n decimals (e.g. subtract .005 to floor to 2 decimals)
|
||||||
* @return boolean|string
|
* @return boolean|string
|
||||||
*/
|
*/
|
||||||
public function get_ratio ($Dividend, $Divisor, $Decimal = 2) {
|
public function get_ratio ($Dividend, $Divisor, $Decimal = 2) {
|
||||||
@ -188,7 +189,7 @@ public static function page_limit($PerPage, $DefaultResult = 1) {
|
|||||||
if ($Page <= 0) {
|
if ($Page <= 0) {
|
||||||
$Page = 1;
|
$Page = 1;
|
||||||
}
|
}
|
||||||
$Limit = $PerPage * $Page - $PerPage . ', ' . $PerPage;
|
$Limit = $PerPage * $Page - $PerPage . ", $PerPage";
|
||||||
}
|
}
|
||||||
return array($Page, $Limit);
|
return array($Page, $Limit);
|
||||||
}
|
}
|
||||||
@ -196,8 +197,8 @@ public static function page_limit($PerPage, $DefaultResult = 1) {
|
|||||||
// A9 magic. Some other poor soul can write the phpdoc.
|
// A9 magic. Some other poor soul can write the phpdoc.
|
||||||
// For data stored in memcached catalogues (giant arrays), e.g. forum threads
|
// For data stored in memcached catalogues (giant arrays), e.g. forum threads
|
||||||
public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500) {
|
public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500) {
|
||||||
$CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize);;
|
$CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize);
|
||||||
$CatalogueLimit = ($CatalogueID * $CatalogueSize).', '.$CatalogueSize;
|
$CatalogueLimit = ($CatalogueID * $CatalogueSize).", $CatalogueSize";
|
||||||
return array($CatalogueID, $CatalogueLimit);
|
return array($CatalogueID, $CatalogueLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +225,7 @@ public static function catalogue_select($Catalogue, $Page, $PerPage, $CatalogueS
|
|||||||
*/
|
*/
|
||||||
public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $ShowPages = 11, $Anchor = '') {
|
public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $ShowPages = 11, $Anchor = '') {
|
||||||
global $Document, $Method, $Mobile;
|
global $Document, $Method, $Mobile;
|
||||||
$Location = $Document.'.php';
|
$Location = "$Document.php";
|
||||||
$StartPage = ceil($StartPage);
|
$StartPage = ceil($StartPage);
|
||||||
$TotalPages = 0;
|
$TotalPages = 0;
|
||||||
if ($TotalRecords > 0) {
|
if ($TotalRecords > 0) {
|
||||||
@ -255,25 +256,25 @@ public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $Show
|
|||||||
|
|
||||||
$QueryString = self::get_url(array('page', 'post'));
|
$QueryString = self::get_url(array('page', 'post'));
|
||||||
if ($QueryString != '') {
|
if ($QueryString != '') {
|
||||||
$QueryString = '&'.$QueryString;
|
$QueryString = "&$QueryString";
|
||||||
}
|
}
|
||||||
|
|
||||||
$Pages = '';
|
$Pages = '';
|
||||||
|
|
||||||
if ($StartPage > 1) {
|
if ($StartPage > 1) {
|
||||||
$Pages .= '<a href="'.$Location.'?page=1'.$QueryString.$Anchor.'"><strong><< First</strong></a> ';
|
$Pages .= "<a href=\"$Location?page=1$QueryString$Anchor\"><strong><< First</strong></a> ";
|
||||||
$Pages .= '<a href="'.$Location.'?page='.($StartPage - 1).$QueryString.$Anchor.'" class="pager_prev"><strong>< Prev</strong></a> | ';
|
$Pages .= "<a href=\"$Location?page=".($StartPage - 1).$QueryString.$Anchor.'" class="pager_prev"><strong>< Prev</strong></a> | ';
|
||||||
}
|
}
|
||||||
//End change
|
//End change
|
||||||
|
|
||||||
if (!$Mobile) {
|
if (!$Mobile) {
|
||||||
for ($i = $StartPosition; $i <= $StopPage; $i++) {
|
for ($i = $StartPosition; $i <= $StopPage; $i++) {
|
||||||
if ($i != $StartPage) {
|
if ($i != $StartPage) {
|
||||||
$Pages .= '<a href="'.$Location.'?page='.$i.$QueryString.$Anchor.'">';
|
$Pages .= "<a href=\"$Location?page=$i$QueryString$Anchor\">";
|
||||||
}
|
}
|
||||||
$Pages .= "<strong>";
|
$Pages .= '<strong>';
|
||||||
if ($i * $ItemsPerPage > $TotalRecords) {
|
if ($i * $ItemsPerPage > $TotalRecords) {
|
||||||
$Pages .= ((($i - 1) * $ItemsPerPage) + 1).'-'.($TotalRecords);
|
$Pages .= ((($i - 1) * $ItemsPerPage) + 1)."-$TotalRecords";
|
||||||
} else {
|
} else {
|
||||||
$Pages .= ((($i - 1) * $ItemsPerPage) + 1).'-'.($i * $ItemsPerPage);
|
$Pages .= ((($i - 1) * $ItemsPerPage) + 1).'-'.($i * $ItemsPerPage);
|
||||||
}
|
}
|
||||||
@ -291,8 +292,8 @@ public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $Show
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($StartPage && $StartPage < $TotalPages) {
|
if ($StartPage && $StartPage < $TotalPages) {
|
||||||
$Pages .= ' | <a href="'.$Location.'?page='.($StartPage + 1).$QueryString.$Anchor.'" class="pager_next"><strong>Next ></strong></a> ';
|
$Pages .= " | <a href=\"$Location?page=".($StartPage + 1).$QueryString.$Anchor.'" class="pager_next"><strong>Next ></strong></a> ';
|
||||||
$Pages .= '<a href="'.$Location.'?page='.$TotalPages.$QueryString.$Anchor.'"><strong> Last >></strong></a>';
|
$Pages .= "<a href=\"$Location?page=$TotalPages$QueryString$Anchor\"><strong> Last >></strong></a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($TotalPages > 1) {
|
if ($TotalPages > 1) {
|
||||||
@ -303,6 +304,8 @@ public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $Show
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a size in bytes as a human readable string in KiB/MiB/...
|
* Format a size in bytes as a human readable string in KiB/MiB/...
|
||||||
|
* Note: KiB, MiB, etc. are the IEC units, which are in base 2.
|
||||||
|
* KB, MB are the SI units, which are in base 10.
|
||||||
*
|
*
|
||||||
* @param int $Size
|
* @param int $Size
|
||||||
* @param int $Levels Number of decimal places. Defaults to 2, unless the size >= 1TB, in which case it defaults to 4.
|
* @param int $Levels Number of decimal places. Defaults to 2, unless the size >= 1TB, in which case it defaults to 4.
|
||||||
@ -413,7 +416,7 @@ public static function selected($Name, $Value, $Attribute = 'selected', $Array =
|
|||||||
}
|
}
|
||||||
if (isset($Array[$Name]) && $Array[$Name] !== '') {
|
if (isset($Array[$Name]) && $Array[$Name] !== '') {
|
||||||
if ($Array[$Name] == $Value) {
|
if ($Array[$Name] == $Value) {
|
||||||
echo ' '.$Attribute.'="'.$Attribute.'"';
|
echo " $Attribute=\"$Attribute\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -428,13 +431,12 @@ public static function selected($Name, $Value, $Attribute = 'selected', $Array =
|
|||||||
* 2-dimensional array: At least one array must be identical to $Target
|
* 2-dimensional array: At least one array must be identical to $Target
|
||||||
* @param string $ClassName CSS class name to return
|
* @param string $ClassName CSS class name to return
|
||||||
* @param bool $AddAttribute Whether to include the "class" attribute in the output
|
* @param bool $AddAttribute Whether to include the "class" attribute in the output
|
||||||
* @param string $UserIDKey Key in _REQUEST for a user id parameter, which if given will be compared to $LoggedUser[ID]
|
* @param string $UserIDKey Key in _REQUEST for a user ID parameter, which if given will be compared to G::$LoggedUser[ID]
|
||||||
*
|
*
|
||||||
* @return class name on match, otherwise an empty string
|
* @return class name on match, otherwise an empty string
|
||||||
*/
|
*/
|
||||||
public static function add_class($Target, $Tests, $ClassName, $AddAttribute, $UserIDKey = false) {
|
public static function add_class($Target, $Tests, $ClassName, $AddAttribute, $UserIDKey = false) {
|
||||||
global $LoggedUser;
|
if ($UserIDKey && isset($_REQUEST[$UserIDKey]) && G::$LoggedUser['ID'] != $_REQUEST[$UserIDKey]) {
|
||||||
if ($UserIDKey && isset($_REQUEST[$UserIDKey]) && $LoggedUser['ID'] != $_REQUEST[$UserIDKey]) {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$Pass = true;
|
$Pass = true;
|
||||||
@ -469,7 +471,7 @@ public static function add_class($Target, $Tests, $ClassName, $AddAttribute, $Us
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if ($AddAttribute) {
|
if ($AddAttribute) {
|
||||||
return ' class="'.$ClassName.'"';
|
return " class=\"$ClassName\"";
|
||||||
}
|
}
|
||||||
return " $ClassName";
|
return " $ClassName";
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,286 @@
|
|||||||
<?
|
<?
|
||||||
class Forums {
|
class Forums {
|
||||||
/**
|
/**
|
||||||
* @param string $Body
|
* Get information on a thread.
|
||||||
* @param int $PostID
|
*
|
||||||
* @param string $Page
|
* @param int $ThreadID
|
||||||
* @param int $PageID
|
* the thread ID.
|
||||||
|
* @param boolean $Return
|
||||||
|
* indicates whether thread info should be returned.
|
||||||
|
* @param Boolean $SelectiveCache
|
||||||
|
* cache thread info/
|
||||||
|
* @return array holding thread information.
|
||||||
*/
|
*/
|
||||||
public static function quote_notify($Body, $PostID, $Page, $PageID) {
|
public static function get_thread_info($ThreadID, $Return = true, $SelectiveCache = false) {
|
||||||
/*
|
if ((!$ThreadInfo = G::$Cache->get_value('thread_' . $ThreadID . '_info')) || !isset($ThreadInfo['OP'])) {
|
||||||
* Explanation of the parameters PageID and Page:
|
$QueryID = G::$DB->get_query_id();
|
||||||
* Page contains where this quote comes from and can be forums, artist,
|
G::$DB->query("SELECT
|
||||||
* collages, requests or torrents. The PageID contains the additional
|
t.Title,
|
||||||
* value that is necessary for the users_notify_quoted table.
|
t.ForumID,
|
||||||
* The PageIDs for the different Page are:
|
t.IsLocked,
|
||||||
* forums: TopicID
|
t.IsSticky,
|
||||||
* artist: ArtistID
|
COUNT(fp.id) AS Posts,
|
||||||
* collages: CollageID
|
t.LastPostAuthorID,
|
||||||
* requests: RequestID
|
ISNULL(p.TopicID) AS NoPoll,
|
||||||
* torrents: GroupID
|
t.StickyPostID,
|
||||||
*/
|
t.AuthorID as OP
|
||||||
global $LoggedUser, $Cache, $DB;
|
FROM forums_topics AS t
|
||||||
|
JOIN forums_posts AS fp ON fp.TopicID = t.ID
|
||||||
$Matches = array();
|
LEFT JOIN forums_polls AS p ON p.TopicID=t.ID
|
||||||
preg_match_all('/\[quote(?:=(.*)(?:\|.*)?)?]|\[\/quote]/iU', $Body, $Matches, PREG_SET_ORDER);
|
WHERE t.ID = '$ThreadID'
|
||||||
|
GROUP BY fp.TopicID");
|
||||||
if (count($Matches)) {
|
if (G::$DB->record_count() == 0) {
|
||||||
$Usernames = array();
|
error(404);
|
||||||
$Level = 0;
|
|
||||||
foreach ($Matches as $M) {
|
|
||||||
if ($M[0] != '[/quote]') {
|
|
||||||
if ($Level == 0 && isset($M[1]) && strlen($M[1]) > 0 && preg_match(USERNAME_REGEX, $M[1])) {
|
|
||||||
$Usernames[] = preg_replace('/(^[.,]*)|([.,]*$)/', '', $M[1]); // wut?
|
|
||||||
}
|
}
|
||||||
++$Level;
|
$ThreadInfo = G::$DB->next_record(MYSQLI_ASSOC, false);
|
||||||
|
if ($ThreadInfo['StickyPostID']) {
|
||||||
|
$ThreadInfo['Posts']--;
|
||||||
|
G::$DB->query("SELECT
|
||||||
|
p.ID,
|
||||||
|
p.AuthorID,
|
||||||
|
p.AddedTime,
|
||||||
|
p.Body,
|
||||||
|
p.EditedUserID,
|
||||||
|
p.EditedTime,
|
||||||
|
ed.Username
|
||||||
|
FROM forums_posts as p
|
||||||
|
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
|
||||||
|
WHERE p.TopicID = '$ThreadID' AND p.ID = '" . $ThreadInfo['StickyPostID'] . "'");
|
||||||
|
list ($ThreadInfo['StickyPost']) = G::$DB->to_array(false, MYSQLI_ASSOC);
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
if (!$SelectiveCache || !$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
|
||||||
|
G::$Cache->cache_value('thread_' . $ThreadID . '_info', $ThreadInfo, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($Return) {
|
||||||
|
return $ThreadInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether user has permissions on a forum.
|
||||||
|
*
|
||||||
|
* @param int $ForumID
|
||||||
|
* the forum ID.
|
||||||
|
* @param string $Perm
|
||||||
|
* the permissision to check, defaults to 'Read'
|
||||||
|
* @return boolean true if user has permission
|
||||||
|
*/
|
||||||
|
public static function check_forumperm($ForumID, $Perm = 'Read') {
|
||||||
|
$Forums = self::get_forums();
|
||||||
|
if (G::$LoggedUser['CustomForums'][$ForumID] == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($ForumID == DONOR_FORUM && Donations::has_donor_forum(G::$LoggedUser['ID'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($Forums[$ForumID]['MinClass' . $Perm] > G::$LoggedUser['Class'] && (!isset(G::$LoggedUser['CustomForums'][$ForumID]) || G::$LoggedUser['CustomForums'][$ForumID] == 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset(G::$LoggedUser['CustomForums'][$ForumID]) && G::$LoggedUser['CustomForums'][$ForumID] == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets basic info on a forum.
|
||||||
|
*
|
||||||
|
* @param int $ForumID
|
||||||
|
* the forum ID.
|
||||||
|
*/
|
||||||
|
public static function get_forum_info($ForumID) {
|
||||||
|
$Forum = G::$Cache->get_value('ForumInfo_' . $ForumID);
|
||||||
|
if (!$Forum) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("SELECT
|
||||||
|
Name,
|
||||||
|
MinClassRead,
|
||||||
|
MinClassWrite,
|
||||||
|
MinClassCreate,
|
||||||
|
COUNT(forums_topics.ID) AS Topics
|
||||||
|
FROM forums
|
||||||
|
LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID
|
||||||
|
WHERE forums.ID='$ForumID'
|
||||||
|
GROUP BY ForumID");
|
||||||
|
if (G::$DB->record_count() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Makes an array, with $Forum['Name'], etc.
|
||||||
|
$Forum = G::$DB->next_record(MYSQLI_ASSOC);
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
G::$Cache->cache_value('ForumInfo_' . $ForumID, $Forum, 86400);
|
||||||
|
}
|
||||||
|
return $Forum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the forum categories
|
||||||
|
* @return array ForumCategoryID => Name
|
||||||
|
*/
|
||||||
|
public static function get_forum_categories() {
|
||||||
|
$ForumCats = G::$Cache->get_value('forums_categories');
|
||||||
|
if ($ForumCats === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("SELECT ID, Name FROM forums_categories");
|
||||||
|
$ForumCats = array();
|
||||||
|
while (list ($ID, $Name) = G::$DB->next_record()) {
|
||||||
|
$ForumCats[$ID] = $Name;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('forums_categories', $ForumCats, 0);
|
||||||
|
}
|
||||||
|
return $ForumCats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the forums
|
||||||
|
* @return array ForumID => (various information about the forum)
|
||||||
|
*/
|
||||||
|
public static function get_forums() {
|
||||||
|
if (!$Forums = G::$Cache->get_value('forums_list')) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
f.ID,
|
||||||
|
f.CategoryID,
|
||||||
|
f.Name,
|
||||||
|
f.Description,
|
||||||
|
f.MinClassRead AS MinClassRead,
|
||||||
|
f.MinClassWrite AS MinClassWrite,
|
||||||
|
f.MinClassCreate AS MinClassCreate,
|
||||||
|
f.NumTopics,
|
||||||
|
f.NumPosts,
|
||||||
|
f.LastPostID,
|
||||||
|
f.LastPostAuthorID,
|
||||||
|
f.LastPostTopicID,
|
||||||
|
f.LastPostTime,
|
||||||
|
0 AS SpecificRules,
|
||||||
|
t.Title,
|
||||||
|
t.IsLocked AS Locked,
|
||||||
|
t.IsSticky AS Sticky
|
||||||
|
FROM forums AS f
|
||||||
|
JOIN forums_categories AS fc ON fc.ID = f.CategoryID
|
||||||
|
LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID
|
||||||
|
GROUP BY f.ID
|
||||||
|
ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort");
|
||||||
|
$Forums = G::$DB->to_array('ID', MYSQLI_ASSOC, false);
|
||||||
|
|
||||||
|
G::$DB->query("SELECT ForumID, ThreadID FROM forums_specific_rules");
|
||||||
|
$SpecificRules = array();
|
||||||
|
while (list($ForumID, $ThreadID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
||||||
|
$SpecificRules[$ForumID][] = $ThreadID;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
foreach ($Forums as $ForumID => &$Forum) {
|
||||||
|
if (isset($SpecificRules[$ForumID])) {
|
||||||
|
$Forum['SpecificRules'] = $SpecificRules[$ForumID];
|
||||||
} else {
|
} else {
|
||||||
--$Level;
|
$Forum['SpecificRules'] = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
G::$Cache->cache_value('forums_list', $Forums, 0);
|
||||||
|
}
|
||||||
|
return $Forums;
|
||||||
}
|
}
|
||||||
//remove any dupes in the array (the fast way)
|
|
||||||
$Usernames = array_flip(array_flip($Usernames));
|
|
||||||
|
|
||||||
$DB->query("
|
/**
|
||||||
SELECT m.ID, p.PushService
|
* Get all forums that the current user has special access to ("Extra forums" in the profile)
|
||||||
FROM users_main AS m
|
* @return array Array of ForumIDs
|
||||||
LEFT JOIN users_info AS i ON i.UserID = m.ID
|
*/
|
||||||
LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
|
public static function get_permitted_forums() {
|
||||||
WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
|
return (array)array_keys(G::$LoggedUser['CustomForums'], 1);
|
||||||
AND i.NotifyOnQuote = '1'
|
}
|
||||||
AND i.UserID != $LoggedUser[ID]");
|
|
||||||
|
|
||||||
$Results = $DB->to_array();
|
/**
|
||||||
foreach ($Results as $Result) {
|
* Get all forums that the current user does not have access to ("Restricted forums" in the profile)
|
||||||
$UserID = db_string($Result['ID']);
|
* @return array Array of ForumIDs
|
||||||
$PushService = $Result['PushService'];
|
*/
|
||||||
$QuoterID = db_string($LoggedUser['ID']);
|
public static function get_restricted_forums() {
|
||||||
$Page = db_string($Page);
|
return (array)array_keys(G::$LoggedUser['CustomForums'], 0);
|
||||||
$PageID = db_string($PageID);
|
}
|
||||||
$PostID = db_string($PostID);
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
INSERT IGNORE INTO users_notify_quoted
|
|
||||||
(UserID, QuoterID, Page, PageID, PostID, Date)
|
|
||||||
VALUES
|
|
||||||
('$UserID', '$QuoterID', '$Page', '$PageID', '$PostID', '" . sqltime() . "')");
|
|
||||||
$Cache->delete_value('notify_quoted_' . $UserID);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last read posts for the current user
|
||||||
|
* @param array $Forums Array of forums as returned by self::get_forums()
|
||||||
|
* @return array TopicID => array(TopicID, PostID, Page) where PostID is the ID of the last read post and Page is the page on which that post is
|
||||||
|
*/
|
||||||
|
public static function get_last_read($Forums) {
|
||||||
|
if (isset(G::$LoggedUser['PostsPerPage'])) {
|
||||||
|
$PerPage = G::$LoggedUser['PostsPerPage'];
|
||||||
|
} else {
|
||||||
|
$PerPage = POSTS_PER_PAGE;
|
||||||
|
}
|
||||||
|
$TopicIDs = array();
|
||||||
|
foreach ($Forums as $Forum) {
|
||||||
|
if (!empty($Forum['LastPostTopicID'])) {
|
||||||
|
$TopicIDs[] = $Forum['LastPostTopicID'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty($TopicIDs)) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
l.TopicID,
|
||||||
|
l.PostID,
|
||||||
|
CEIL(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COUNT(ID)
|
||||||
|
FROM forums_posts
|
||||||
|
WHERE forums_posts.TopicID = l.TopicID
|
||||||
|
AND forums_posts.ID<=l.PostID
|
||||||
|
)/$PerPage
|
||||||
|
) AS Page
|
||||||
|
FROM forums_last_read_topics AS l
|
||||||
|
WHERE TopicID IN(" . implode(',', $TopicIDs) . ") AND
|
||||||
|
UserID='" . G::$LoggedUser['ID'] . "'");
|
||||||
|
$LastRead = G::$DB->to_array('TopicID', MYSQLI_ASSOC);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
} else {
|
||||||
|
$LastRead = array();
|
||||||
|
}
|
||||||
|
return $LastRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a thread is unread
|
||||||
|
* @param bool $Locked
|
||||||
|
* @param bool $Sticky
|
||||||
|
* @param int $LastPostID
|
||||||
|
* @param array $LastRead An array as returned by self::get_last_read
|
||||||
|
* @param int $LastTopicID TopicID of the thread where the most recent post was made
|
||||||
|
* @param string $LastTime Datetime of the last post
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function is_unread($Locked, $Sticky, $LastPostID, $LastRead, $LastTopicID, $LastTime) {
|
||||||
|
return (!$Locked || $Sticky) && $LastPostID != 0 && ((empty($LastRead[$LastTopicID]) || $LastRead[$LastTopicID]['PostID'] < $LastPostID) && strtotime($LastTime) > G::$LoggedUser['CatchupTime']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the part of WHERE in the sql queries used to filter forums for a
|
||||||
|
* specific user (MinClassRead, restricted and permitted forums).
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function user_forums_sql() {
|
||||||
|
// I couldn't come up with a good name, please rename this if you can. -- Y
|
||||||
|
$RestrictedForums = self::get_restricted_forums();
|
||||||
|
$PermittedForums = self::get_permitted_forums();
|
||||||
|
if (Donations::has_donor_forum(G::$LoggedUser['ID']) && !in_array(DONOR_FORUM, $PermittedForums)) {
|
||||||
|
$PermittedForums[] = DONOR_FORUM;
|
||||||
|
}
|
||||||
|
$SQL = "((f.MinClassRead <= '" . G::$LoggedUser['Class'] . "'";
|
||||||
|
if (count($RestrictedForums)) {
|
||||||
|
$SQL .= " AND f.ID NOT IN ('" . implode("', '", $RestrictedForums) . "')";
|
||||||
|
}
|
||||||
|
$SQL .= ')';
|
||||||
|
if (count($PermittedForums)) {
|
||||||
|
$SQL .= " OR f.ID IN ('" . implode("', '", $PermittedForums) . "')";
|
||||||
|
}
|
||||||
|
$SQL .= ')';
|
||||||
|
return $SQL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ public static function initialize() {
|
|||||||
global $DB, $Cache, $LoggedUser;
|
global $DB, $Cache, $LoggedUser;
|
||||||
self::$DB = $DB;
|
self::$DB = $DB;
|
||||||
self::$Cache = $Cache;
|
self::$Cache = $Cache;
|
||||||
self::$LoggedUser = $LoggedUser;
|
self::$LoggedUser =& $LoggedUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,9 +9,8 @@ class Inbox {
|
|||||||
* @return string - the URL to a user's inbox
|
* @return string - the URL to a user's inbox
|
||||||
*/
|
*/
|
||||||
public static function get_inbox_link($WhichBox = 'inbox') {
|
public static function get_inbox_link($WhichBox = 'inbox') {
|
||||||
global $LoggedUser;
|
|
||||||
|
|
||||||
$ListFirst = $LoggedUser['ListUnreadPMsFirst'];
|
$ListFirst = G::$LoggedUser['ListUnreadPMsFirst'];
|
||||||
|
|
||||||
if ($WhichBox == 'inbox') {
|
if ($WhichBox == 'inbox') {
|
||||||
if ($ListFirst) {
|
if ($ListFirst) {
|
||||||
|
@ -19,21 +19,22 @@ function INVITE_TREE($UserID, $Options = array()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function make_tree() {
|
function make_tree() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
$UserID = $this->UserID;
|
$UserID = $this->UserID;
|
||||||
global $DB;
|
|
||||||
?>
|
?>
|
||||||
<div class="invitetree pad">
|
<div class="invitetree pad">
|
||||||
<?
|
<?
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT TreePosition, TreeID, TreeLevel
|
SELECT TreePosition, TreeID, TreeLevel
|
||||||
FROM invite_tree
|
FROM invite_tree
|
||||||
WHERE UserID = $UserID");
|
WHERE UserID = $UserID");
|
||||||
list($TreePosition, $TreeID, $TreeLevel) = $DB->next_record(MYSQLI_NUM, false);
|
list($TreePosition, $TreeID, $TreeLevel) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
|
|
||||||
if (!$TreeID) {
|
if (!$TreeID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT TreePosition
|
SELECT TreePosition
|
||||||
FROM invite_tree
|
FROM invite_tree
|
||||||
WHERE TreeID = $TreeID
|
WHERE TreeID = $TreeID
|
||||||
@ -41,12 +42,12 @@ function make_tree() {
|
|||||||
AND TreePosition > $TreePosition
|
AND TreePosition > $TreePosition
|
||||||
ORDER BY TreePosition ASC
|
ORDER BY TreePosition ASC
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($MaxPosition) = $DB->next_record(MYSQLI_NUM, false);
|
list($MaxPosition) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
} else {
|
} else {
|
||||||
$MaxPosition = false;
|
$MaxPosition = false;
|
||||||
}
|
}
|
||||||
$TreeQuery = $DB->query("
|
$TreeQuery = G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
it.UserID,
|
it.UserID,
|
||||||
Enabled,
|
Enabled,
|
||||||
@ -90,7 +91,7 @@ function make_tree() {
|
|||||||
|
|
||||||
// We store this in an output buffer, so we can show the summary at the top without having to loop through twice
|
// We store this in an output buffer, so we can show the summary at the top without having to loop through twice
|
||||||
ob_start();
|
ob_start();
|
||||||
while (list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = $DB->next_record()) {
|
while (list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = G::$DB->next_record()) {
|
||||||
|
|
||||||
// Do stats
|
// Do stats
|
||||||
$Count++;
|
$Count++;
|
||||||
@ -146,7 +147,7 @@ function make_tree() {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<? $PreviousTreeLevel = $TreeLevel;
|
<? $PreviousTreeLevel = $TreeLevel;
|
||||||
$DB->set_query_id($TreeQuery);
|
G::$DB->set_query_id($TreeQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
$Tree = ob_get_clean();
|
$Tree = ob_get_clean();
|
||||||
@ -235,6 +236,7 @@ function make_tree() {
|
|||||||
<?=$Tree?>
|
<?=$Tree?>
|
||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
class IRC_DB extends DB_MYSQL {
|
class IRC_DB extends DB_MYSQL {
|
||||||
function halt($Msg) {
|
function halt($Msg) {
|
||||||
global $Bot;
|
global $Bot;
|
||||||
global $DB;
|
|
||||||
$Bot->send_to($Bot->get_channel(),'The database is currently unavailable; try again later.');
|
$Bot->send_to($Bot->get_channel(),'The database is currently unavailable; try again later.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +134,6 @@ protected function whois($Nick) {
|
|||||||
This function uses blacklisted_ip, which is no longer in RC2.
|
This function uses blacklisted_ip, which is no longer in RC2.
|
||||||
You can probably find it in old RC1 code kicking aronud if you need it.
|
You can probably find it in old RC1 code kicking aronud if you need it.
|
||||||
protected function ip_check($IP, $Gline = false, $Channel = BOT_REPORT_CHAN) {
|
protected function ip_check($IP, $Gline = false, $Channel = BOT_REPORT_CHAN) {
|
||||||
global $Cache, $DB;
|
|
||||||
if (blacklisted_ip($IP)) {
|
if (blacklisted_ip($IP)) {
|
||||||
$this->send_to($Channel, 'TOR IP Detected: '.$IP);
|
$this->send_to($Channel, 'TOR IP Detected: '.$IP);
|
||||||
if ($Gline) {
|
if ($Gline) {
|
||||||
@ -151,8 +149,7 @@ protected function ip_check($IP, $Gline = false, $Channel = BOT_REPORT_CHAN) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
protected function listen() {
|
protected function listen() {
|
||||||
global $Cache, $DB;
|
G::$Cache->InternalCache = false;
|
||||||
$Cache->InternalCache = false;
|
|
||||||
stream_set_timeout($this->Socket, 10000000000);
|
stream_set_timeout($this->Socket, 10000000000);
|
||||||
while ($this->State == 1) {
|
while ($this->State == 1) {
|
||||||
if ($this->Data = fgets($this->Socket, 256)) {
|
if ($this->Data = fgets($this->Socket, 256)) {
|
||||||
@ -182,20 +179,20 @@ protected function listen() {
|
|||||||
unset($this->Identified[$Nick[1]]);
|
unset($this->Identified[$Nick[1]]);
|
||||||
}
|
}
|
||||||
if (isset($this->DisabledUsers[$Nick[1]])) {
|
if (isset($this->DisabledUsers[$Nick[1]])) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM disable_list
|
DELETE FROM disable_list
|
||||||
WHERE Nick = '$Nick[1]'");
|
WHERE Nick = '$Nick[1]'");
|
||||||
$Cache->increment_value('num_disablees', -1);
|
G::$Cache->increment_value('num_disablees', -1);
|
||||||
unset($this->DisabledUsers[$Nick[1]]);
|
unset($this->DisabledUsers[$Nick[1]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match("/:([^!]+)![^\s]* PART ".BOT_DISABLED_CHAN.'/', $this->Data, $Nick)) {
|
if (preg_match("/:([^!]+)![^\s]* PART ".BOT_DISABLED_CHAN.'/', $this->Data, $Nick)) {
|
||||||
if (isset($this->DisabledUsers[$Nick[1]])) {
|
if (isset($this->DisabledUsers[$Nick[1]])) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM disable_list
|
DELETE FROM disable_list
|
||||||
WHERE Nick = '$Nick[1]'");
|
WHERE Nick = '$Nick[1]'");
|
||||||
$Cache->increment_value('num_disablees', -1);
|
G::$Cache->increment_value('num_disablees', -1);
|
||||||
unset($this->DisabledUsers[$Nick[1]]);
|
unset($this->DisabledUsers[$Nick[1]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,10 +200,10 @@ protected function listen() {
|
|||||||
if (preg_match("/:([^!]+)![^\s]* KICK ".BOT_DISABLED_CHAN.'.* /', $this->Data, $Nick)) {
|
if (preg_match("/:([^!]+)![^\s]* KICK ".BOT_DISABLED_CHAN.'.* /', $this->Data, $Nick)) {
|
||||||
$Nick = explode(' ', $Nick[0]);
|
$Nick = explode(' ', $Nick[0]);
|
||||||
if (isset($this->DisabledUsers[$Nick[3]])) {
|
if (isset($this->DisabledUsers[$Nick[3]])) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM disable_list
|
DELETE FROM disable_list
|
||||||
WHERE Nick = '$Nick[3]'");
|
WHERE Nick = '$Nick[3]'");
|
||||||
$Cache->increment_value('num_disablees', -1);
|
G::$Cache->increment_value('num_disablees', -1);
|
||||||
unset($this->DisabledUsers[$Nick[3]]);
|
unset($this->DisabledUsers[$Nick[3]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,8 +229,8 @@ protected function listen() {
|
|||||||
$this->listener_events();
|
$this->listener_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->LinkID = false;
|
G::$DB->LinkID = false;
|
||||||
$DB->Queries = array();
|
G::$DB->Queries = array();
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,123 +4,121 @@
|
|||||||
class LastFM {
|
class LastFM {
|
||||||
|
|
||||||
public static function get_artist_events($ArtistID, $Artist, $Limit = 15) {
|
public static function get_artist_events($ArtistID, $Artist, $Limit = 15) {
|
||||||
global $Cache;
|
$ArtistEvents = G::$Cache->get_value("artist_events_$ArtistID");
|
||||||
$ArtistEvents = $Cache->get_value("artist_events_$ArtistID");
|
|
||||||
if (empty($ArtistEvents)) {
|
if (empty($ArtistEvents)) {
|
||||||
$ArtistEvents = self::lastfm_request("artist.getEvents", array("artist" => $Artist, "limit" => $Limit));
|
$ArtistEvents = self::lastfm_request("artist.getEvents", array("artist" => $Artist, "limit" => $Limit));
|
||||||
$Cache->cache_value("artist_events_$ArtistID", $ArtistEvents, 432000);
|
G::$Cache->cache_value("artist_events_$ArtistID", $ArtistEvents, 432000);
|
||||||
}
|
}
|
||||||
return $ArtistEvents;
|
return $ArtistEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_user_info($Username) {
|
public static function get_user_info($Username) {
|
||||||
global $Cache;
|
$Response = G::$Cache->get_value("lastfm_user_info_$Username");
|
||||||
$Response = $Cache->get_value("lastfm_user_info_$Username");
|
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
$Response = self::lastfm_request("user.getInfo", array("user" => $Username));
|
$Response = self::lastfm_request("user.getInfo", array("user" => $Username));
|
||||||
$Cache->cache_value("lastfm_user_info_$Username", $Response, 86400);
|
G::$Cache->cache_value("lastfm_user_info_$Username", $Response, 86400);
|
||||||
}
|
}
|
||||||
return $Response;
|
return $Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function compare_user_with($Username1, $Limit = 15) {
|
public static function compare_user_with($Username1, $Limit = 15) {
|
||||||
global $Cache, $LoggedUser, $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT username
|
SELECT username
|
||||||
FROM lastfm_users
|
FROM lastfm_users
|
||||||
WHERE ID = '$LoggedUser[ID]'");
|
WHERE ID = '" . G::$LoggedUser['ID'] . "'");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($Username2) = $DB->next_record();
|
list($Username2) = G::$DB->next_record();
|
||||||
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
||||||
if (strcasecmp($Username1, $Username2)) {
|
if (strcasecmp($Username1, $Username2)) {
|
||||||
$Temp = $Username1;
|
$Temp = $Username1;
|
||||||
$Username1 = $Username2;
|
$Username1 = $Username2;
|
||||||
$Username2 = $Temp;
|
$Username2 = $Temp;
|
||||||
}
|
}
|
||||||
$Response = $Cache->get_value("lastfm_compare_$Username1" . "_$Username2");
|
$Response = G::$Cache->get_value("lastfm_compare_$Username1" . "_$Username2");
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
$Response = self::lastfm_request("tasteometer.compare", array("type1" => "user", "type2" => "user", "value1" => $Username1, "value2" => $Username2, "limit" => $Limit));
|
$Response = self::lastfm_request("tasteometer.compare", array("type1" => "user", "type2" => "user", "value1" => $Username1, "value2" => $Username2, "limit" => $Limit));
|
||||||
$Response = json_encode($Response);
|
$Response = json_encode($Response);
|
||||||
$Cache->cache_value("lastfm_compare_$Username1" . "_$Username2", $Response, 86400);
|
G::$Cache->cache_value("lastfm_compare_$Username1" . "_$Username2", $Response, 86400);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$Response = null;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
return $Response;
|
return $Response;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static function get_last_played_track($Username) {
|
public static function get_last_played_track($Username) {
|
||||||
global $Cache;
|
$Response = G::$Cache->get_value("lastfm_last_played_track_$Username");
|
||||||
$Response = $Cache->get_value("lastfm_last_played_track_$Username");
|
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
$Response = self::lastfm_request("user.getRecentTracks", array("user" => $Username, "limit" => 1));
|
$Response = self::lastfm_request("user.getRecentTracks", array("user" => $Username, "limit" => 1));
|
||||||
// Take the single last played track out of the response.
|
// Take the single last played track out of the response.
|
||||||
$Response = $Response['recenttracks']['track'];
|
$Response = $Response['recenttracks']['track'];
|
||||||
$Response = json_encode($Response);
|
$Response = json_encode($Response);
|
||||||
$Cache->cache_value("lastfm_last_played_track_$Username", $Response, 7200);
|
G::$Cache->cache_value("lastfm_last_played_track_$Username", $Response, 7200);
|
||||||
}
|
}
|
||||||
return $Response;
|
return $Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_top_artists($Username, $Limit = 15) {
|
public static function get_top_artists($Username, $Limit = 15) {
|
||||||
global $Cache;
|
$Response = G::$Cache->get_value("lastfm_top_artists_$Username");
|
||||||
$Response = $Cache->get_value("lastfm_top_artists_$Username");
|
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$Response = self::lastfm_request("user.getTopArtists", array("user" => $Username, "limit" => $Limit));
|
$Response = self::lastfm_request("user.getTopArtists", array("user" => $Username, "limit" => $Limit));
|
||||||
$Response = json_encode($Response);
|
$Response = json_encode($Response);
|
||||||
$Cache->cache_value("lastfm_top_artists_$Username", $Response, 86400);
|
G::$Cache->cache_value("lastfm_top_artists_$Username", $Response, 86400);
|
||||||
}
|
}
|
||||||
return $Response;
|
return $Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_top_albums($Username, $Limit = 15) {
|
public static function get_top_albums($Username, $Limit = 15) {
|
||||||
global $Cache;
|
$Response = G::$Cache->get_value("lastfm_top_albums_$Username");
|
||||||
$Response = $Cache->get_value("lastfm_top_albums_$Username");
|
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
sleep(2);
|
sleep(2);
|
||||||
$Response = self::lastfm_request("user.getTopAlbums", array("user" => $Username, "limit" => $Limit));
|
$Response = self::lastfm_request("user.getTopAlbums", array("user" => $Username, "limit" => $Limit));
|
||||||
$Response = json_encode($Response);
|
$Response = json_encode($Response);
|
||||||
$Cache->cache_value("lastfm_top_albums_$Username", $Response, 86400);
|
G::$Cache->cache_value("lastfm_top_albums_$Username", $Response, 86400);
|
||||||
}
|
}
|
||||||
return $Response;
|
return $Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_top_tracks($Username, $Limit = 15) {
|
public static function get_top_tracks($Username, $Limit = 15) {
|
||||||
global $Cache;
|
$Response = G::$Cache->get_value("lastfm_top_tracks_$Username");
|
||||||
$Response = $Cache->get_value("lastfm_top_tracks_$Username");
|
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
sleep(3);
|
sleep(3);
|
||||||
$Response = self::lastfm_request("user.getTopTracks", array("user" => $Username, "limit" => $Limit));
|
$Response = self::lastfm_request("user.getTopTracks", array("user" => $Username, "limit" => $Limit));
|
||||||
$Response = json_encode($Response);
|
$Response = json_encode($Response);
|
||||||
$Cache->cache_value("lastfm_top_tracks_$Username", $Response, 86400);
|
G::$Cache->cache_value("lastfm_top_tracks_$Username", $Response, 86400);
|
||||||
}
|
}
|
||||||
return $Response;
|
return $Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function clear_cache($Username, $Uid) {
|
public static function clear_cache($Username, $Uid) {
|
||||||
global $Cache, $LoggedUser, $DB;
|
$Response = G::$Cache->get_value('lastfm_clear_cache_' . G::$LoggedUser['ID'] . '_' . $_GET['id']);
|
||||||
$Response = $Cache->get_value("lastfm_clear_cache_$LoggedUser" . '_' . $_GET['id']);
|
|
||||||
if (empty($Response)) {
|
if (empty($Response)) {
|
||||||
// Prevent clearing the cache on the same uid page for the next 10 minutes.
|
// Prevent clearing the cache on the same uid page for the next 10 minutes.
|
||||||
$Response = $Cache->cache_value("lastfm_clear_cache_$LoggedUser" . "_$Uid", $Username, 600);
|
$Response = G::$Cache->cache_value('lastfm_clear_cache_' . G::$LoggedUser['ID'] . "_$Uid", $Username, 600);
|
||||||
$Cache->delete_value("lastfm_user_info_$Username");
|
G::$Cache->delete_value("lastfm_user_info_$Username");
|
||||||
$Cache->delete_value("lastfm_last_played_track_$Username");
|
G::$Cache->delete_value("lastfm_last_played_track_$Username");
|
||||||
$Cache->delete_value("lastfm_top_artists_$Username");
|
G::$Cache->delete_value("lastfm_top_artists_$Username");
|
||||||
$Cache->delete_value("lastfm_top_albums_$Username");
|
G::$Cache->delete_value("lastfm_top_albums_$Username");
|
||||||
$Cache->delete_value("lastfm_top_tracks_$Username");
|
G::$Cache->delete_value("lastfm_top_tracks_$Username");
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT username
|
SELECT username
|
||||||
FROM lastfm_users
|
FROM lastfm_users
|
||||||
WHERE ID = '$LoggedUser[ID]'");
|
WHERE ID = '" . G::$LoggedUser['ID'] . "'");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($Username2) = $DB->next_record();
|
list($Username2) = G::$DB->next_record();
|
||||||
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
//Make sure the usernames are in the correct order to avoid dupe cache keys.
|
||||||
if (strcasecmp($Username, $Username2)) {
|
if (strcasecmp($Username, $Username2)) {
|
||||||
$Temp = $Username;
|
$Temp = $Username;
|
||||||
$Username = $Username2;
|
$Username = $Username2;
|
||||||
$Username2 = $Temp;
|
$Username2 = $Temp;
|
||||||
}
|
}
|
||||||
$Cache->delete_value("lastfm_compare_$Username" . "_$Username2");
|
G::$Cache->delete_value("lastfm_compare_$Username" . "_$Username2");
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,13 +17,15 @@ public function __construct ($Table = 'bookmarks_torrents') {
|
|||||||
/**
|
/**
|
||||||
* Runs a SQL query and clears the Cache key
|
* Runs a SQL query and clears the Cache key
|
||||||
*
|
*
|
||||||
* $Cache->delete_value didn't always work, but setting the key to null, did. (?)
|
* G::$Cache->delete_value didn't always work, but setting the key to null, did. (?)
|
||||||
*
|
*
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
*/
|
*/
|
||||||
protected function query_and_clear_cache ($sql) {
|
protected function query_and_clear_cache ($sql) {
|
||||||
if (is_string($sql) && $this->DB->query($sql))
|
$QueryID = G::$DB->get_query_id();
|
||||||
$this->Cache->delete_value('bookmarks_group_ids_' . $this->UserID);
|
if (is_string($sql) && G::$DB->query($sql))
|
||||||
|
G::$Cache->delete_value('bookmarks_group_ids_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +43,7 @@ public function mass_remove () {
|
|||||||
if (!empty($SQL)) {
|
if (!empty($SQL)) {
|
||||||
$SQL = sprintf('DELETE FROM %s WHERE UserID = %d AND GroupID IN (%s)',
|
$SQL = sprintf('DELETE FROM %s WHERE UserID = %d AND GroupID IN (%s)',
|
||||||
$this->Table,
|
$this->Table,
|
||||||
$this->UserID,
|
G::$LoggedUser['ID'],
|
||||||
implode(', ', $SQL)
|
implode(', ', $SQL)
|
||||||
);
|
);
|
||||||
$this->query_and_clear_cache($SQL);
|
$this->query_and_clear_cache($SQL);
|
||||||
@ -55,7 +57,7 @@ public function mass_update () {
|
|||||||
$SQL = array();
|
$SQL = array();
|
||||||
foreach ($_POST['sort'] as $GroupID => $Sort) {
|
foreach ($_POST['sort'] as $GroupID => $Sort) {
|
||||||
if (is_number($Sort) && is_number($GroupID))
|
if (is_number($Sort) && is_number($GroupID))
|
||||||
$SQL[] = sprintf('(%d, %d, %d)', $GroupID, $Sort, $this->UserID);
|
$SQL[] = sprintf('(%d, %d, %d)', $GroupID, $Sort, G::$LoggedUser['ID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($SQL)) {
|
if (!empty($SQL)) {
|
||||||
|
@ -13,64 +13,26 @@
|
|||||||
*
|
*
|
||||||
* It could also be used for other types like collages.
|
* It could also be used for other types like collages.
|
||||||
*/
|
*/
|
||||||
abstract class MASS_USER_TORRENTS_EDITOR
|
abstract class MASS_USER_TORRENTS_EDITOR {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Internal access to the Cache
|
|
||||||
* @var Cache $Cache
|
|
||||||
*/
|
|
||||||
protected $Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal access to the Database
|
|
||||||
* @var DB_MYSQL $DB
|
|
||||||
*/
|
|
||||||
protected $DB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current User's ID
|
|
||||||
* @var str|int $UserID
|
|
||||||
*/
|
|
||||||
protected $UserID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The affected DB table
|
* The affected DB table
|
||||||
* @var string $Table
|
* @var string $Table
|
||||||
*/
|
*/
|
||||||
protected $Table;
|
protected $Table;
|
||||||
|
|
||||||
/**
|
|
||||||
* Extended classes should call this method.
|
|
||||||
* @example parent::__construct()
|
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @global string|int $UserID
|
|
||||||
*/
|
|
||||||
public function __construct (/*CACHE &$Cache, DB_MYSQL &$DB, $UserID*/)
|
|
||||||
{
|
|
||||||
global $Cache, $DB, $UserID;
|
|
||||||
$this->Cache = $Cache;
|
|
||||||
$this->DB = $DB;
|
|
||||||
$this->UserID = (int) $UserID;
|
|
||||||
if ($this->UserID < 1) error(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Table
|
* Set the Table
|
||||||
* @param string $Table
|
* @param string $Table
|
||||||
*/
|
*/
|
||||||
final public function set_table ($Table)
|
final public function set_table($Table) {
|
||||||
{
|
|
||||||
$this->Table = db_string($Table);
|
$this->Table = db_string($Table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Table
|
* Get the Table
|
||||||
* @param sting $Table
|
|
||||||
* @return string $Table
|
* @return string $Table
|
||||||
*/
|
*/
|
||||||
final public function get_table ()
|
final public function get_table() {
|
||||||
{
|
|
||||||
return $this->Table;
|
return $this->Table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,24 +36,12 @@ class MASS_USER_TORRENTS_TABLE_VIEW {
|
|||||||
*/
|
*/
|
||||||
private $TorrentList;
|
private $TorrentList;
|
||||||
|
|
||||||
/**
|
|
||||||
* Ref. to $LoggedUser
|
|
||||||
* @var array $LoggedUser
|
|
||||||
*/
|
|
||||||
private $LoggedUser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref. to $CollageDataList
|
* Ref. to $CollageDataList
|
||||||
* @var array $CollageDataList
|
* @var array $CollageDataList
|
||||||
*/
|
*/
|
||||||
private $CollageDataList;
|
private $CollageDataList;
|
||||||
|
|
||||||
/**
|
|
||||||
* The UserID
|
|
||||||
* @var int $UserID
|
|
||||||
*/
|
|
||||||
private $UserID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counter for number of groups
|
* Counter for number of groups
|
||||||
* @var in $NumGroups
|
* @var in $NumGroups
|
||||||
@ -64,22 +52,15 @@ class MASS_USER_TORRENTS_TABLE_VIEW {
|
|||||||
* When creating a new instance of this class, TorrentList and
|
* When creating a new instance of this class, TorrentList and
|
||||||
* CollageDataList must be passed. Additionally, a heading can be added.
|
* CollageDataList must be passed. Additionally, a heading can be added.
|
||||||
*
|
*
|
||||||
* @global int|string $UserID
|
|
||||||
* @global array $LoggedUser
|
|
||||||
* @param array $TorrentList
|
* @param array $TorrentList
|
||||||
* @param array $CollageDataList
|
* @param array $CollageDataList
|
||||||
* @param string $EditType
|
* @param string $EditType
|
||||||
* @param string $Heading
|
* @param string $Heading
|
||||||
*/
|
*/
|
||||||
public function __construct (array &$TorrentList, array &$CollageDataList, $EditType, $Heading = null) {
|
public function __construct (array &$TorrentList, array &$CollageDataList, $EditType, $Heading = null) {
|
||||||
global $UserID, $LoggedUser;
|
|
||||||
|
|
||||||
$this->set_heading($Heading);
|
$this->set_heading($Heading);
|
||||||
$this->set_edit_type($EditType);
|
$this->set_edit_type($EditType);
|
||||||
|
|
||||||
$this->UserID = (int) $UserID;
|
|
||||||
$this->LoggedUser = &$LoggedUser;
|
|
||||||
|
|
||||||
$this->TorrentList = $TorrentList;
|
$this->TorrentList = $TorrentList;
|
||||||
$this->CollageDataList = $CollageDataList;
|
$this->CollageDataList = $CollageDataList;
|
||||||
|
|
||||||
@ -116,7 +97,7 @@ public function render_all () {
|
|||||||
* form, table, etc.
|
* form, table, etc.
|
||||||
*/
|
*/
|
||||||
public function header () {
|
public function header () {
|
||||||
if ($this->HasTorrents) :
|
if ($this->HasTorrents) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="thin">
|
<div class="thin">
|
||||||
@ -134,7 +115,6 @@ public function header () {
|
|||||||
<li>Click and drag any row to change its order.</li>
|
<li>Click and drag any row to change its order.</li>
|
||||||
<li>Double-click on a row to check it.</li>
|
<li>Double-click on a row to check it.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<noscript><ul><li><strong class="important_text">Enable JavaScript!</strong></li></ul></noscript>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -157,14 +137,14 @@ public function header () {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?
|
<?
|
||||||
endif;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes header code
|
* Closes header code
|
||||||
*/
|
*/
|
||||||
public function footer () {
|
public function footer () {
|
||||||
if ($this->HasTorrents) :
|
if ($this->HasTorrents) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -175,13 +155,13 @@ public function footer () {
|
|||||||
<div>
|
<div>
|
||||||
<input type="hidden" name="action" value="mass_edit" />
|
<input type="hidden" name="action" value="mass_edit" />
|
||||||
<input type="hidden" name="type" value="<?=display_str($this->EditType)?>" />
|
<input type="hidden" name="type" value="<?=display_str($this->EditType)?>" />
|
||||||
<input type="hidden" name="auth" value="<?=$this->LoggedUser['AuthKey']?>" />
|
<input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?
|
<?
|
||||||
endif;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,26 +43,29 @@ public static function file_string($EscapeStr) {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
||||||
global $DB, $Cache, $Time;
|
global $Time;
|
||||||
$Subject = db_string($Subject);
|
$Subject = db_string($Subject);
|
||||||
$Body = db_string($Body);
|
$Body = db_string($Body);
|
||||||
if ($ToID == 0 || $ToID == $FromID) {
|
if ($ToID == 0 || $ToID == $FromID) {
|
||||||
// Don't allow users to send messages to the system or themselves
|
// Don't allow users to send messages to the system or themselves
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
if ($ConvID == '') {
|
if ($ConvID == '') {
|
||||||
// Create a new conversation.
|
// Create a new conversation.
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO pm_conversations (Subject)
|
INSERT INTO pm_conversations (Subject)
|
||||||
VALUES ('$Subject')");
|
VALUES ('$Subject')");
|
||||||
$ConvID = $DB->inserted_id();
|
$ConvID = G::$DB->inserted_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO pm_conversations_users
|
INSERT INTO pm_conversations_users
|
||||||
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
|
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
|
||||||
VALUES
|
VALUES
|
||||||
('$ToID', '$ConvID', '1','0','".sqltime()."', '".sqltime()."', '1')");
|
('$ToID', '$ConvID', '1','0','".sqltime()."', '".sqltime()."', '1')");
|
||||||
if ($FromID != 0) {
|
if ($FromID != 0) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO pm_conversations_users
|
INSERT INTO pm_conversations_users
|
||||||
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
|
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
|
||||||
VALUES
|
VALUES
|
||||||
@ -71,7 +74,7 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
|||||||
$ToID = array($ToID);
|
$ToID = array($ToID);
|
||||||
} else {
|
} else {
|
||||||
// Update the pre-existing conversations.
|
// Update the pre-existing conversations.
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE pm_conversations_users
|
UPDATE pm_conversations_users
|
||||||
SET
|
SET
|
||||||
InInbox='1',
|
InInbox='1',
|
||||||
@ -80,7 +83,7 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
|||||||
WHERE UserID IN (".implode(',', $ToID).")
|
WHERE UserID IN (".implode(',', $ToID).")
|
||||||
AND ConvID='$ConvID'");
|
AND ConvID='$ConvID'");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE pm_conversations_users
|
UPDATE pm_conversations_users
|
||||||
SET
|
SET
|
||||||
InSentbox='1',
|
InSentbox='1',
|
||||||
@ -90,7 +93,7 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have a $ConvID for sure, send the message.
|
// Now that we have a $ConvID for sure, send the message.
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO pm_messages
|
INSERT INTO pm_messages
|
||||||
(SenderID, ConvID, SentDate, Body)
|
(SenderID, ConvID, SentDate, Body)
|
||||||
VALUES
|
VALUES
|
||||||
@ -98,33 +101,35 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
|||||||
|
|
||||||
// Update the cached new message count.
|
// Update the cached new message count.
|
||||||
foreach ($ToID as $ID) {
|
foreach ($ToID as $ID) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ConvID)
|
SELECT COUNT(ConvID)
|
||||||
FROM pm_conversations_users
|
FROM pm_conversations_users
|
||||||
WHERE UnRead = '1'
|
WHERE UnRead = '1'
|
||||||
AND UserID='$ID'
|
AND UserID='$ID'
|
||||||
AND InInbox = '1'");
|
AND InInbox = '1'");
|
||||||
list($UnRead) = $DB->next_record();
|
list($UnRead) = G::$DB->next_record();
|
||||||
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
|
G::$Cache->cache_value('inbox_new_'.$ID, $UnRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT Username
|
SELECT Username
|
||||||
FROM users_main
|
FROM users_main
|
||||||
WHERE ID = '$FromID'");
|
WHERE ID = '$FromID'");
|
||||||
list($SenderName) = $DB->next_record();
|
list($SenderName) = G::$DB->next_record();
|
||||||
foreach ($ToID as $ID) {
|
foreach ($ToID as $ID) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ConvID)
|
SELECT COUNT(ConvID)
|
||||||
FROM pm_conversations_users
|
FROM pm_conversations_users
|
||||||
WHERE UnRead = '1'
|
WHERE UnRead = '1'
|
||||||
AND UserID='$ID'
|
AND UserID='$ID'
|
||||||
AND InInbox = '1'");
|
AND InInbox = '1'");
|
||||||
list($UnRead) = $DB->next_record();
|
list($UnRead) = G::$DB->next_record();
|
||||||
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
|
G::$Cache->cache_value('inbox_new_'.$ID, $UnRead);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
return $ConvID;
|
return $ConvID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,40 +144,43 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
|||||||
* @return -1 on error, -2 on user not existing, thread id on success.
|
* @return -1 on error, -2 on user not existing, thread id on success.
|
||||||
*/
|
*/
|
||||||
public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
||||||
global $DB, $Cache, $Time;
|
global $Time;
|
||||||
if (!$ForumID || !$AuthorID || !is_number($AuthorID) || !$Title || !$PostBody) {
|
if (!$ForumID || !$AuthorID || !is_number($AuthorID) || !$Title || !$PostBody) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
SELECT Username
|
SELECT Username
|
||||||
FROM users_main
|
FROM users_main
|
||||||
WHERE ID=".$AuthorID);
|
WHERE ID=".$AuthorID);
|
||||||
if (!$DB->has_results()) {
|
if (!G::$DB->has_results()) {
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
list($AuthorName) = $DB->next_record();
|
list($AuthorName) = G::$DB->next_record();
|
||||||
|
|
||||||
$ThreadInfo = array();
|
$ThreadInfo = array();
|
||||||
$ThreadInfo['IsLocked'] = 0;
|
$ThreadInfo['IsLocked'] = 0;
|
||||||
$ThreadInfo['IsSticky'] = 0;
|
$ThreadInfo['IsSticky'] = 0;
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO forums_topics
|
INSERT INTO forums_topics
|
||||||
(Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID)
|
(Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID)
|
||||||
VALUES
|
VALUES
|
||||||
('$Title', '$AuthorID', '$ForumID', '".sqltime()."', '$AuthorID')");
|
('$Title', '$AuthorID', '$ForumID', '".sqltime()."', '$AuthorID')");
|
||||||
$TopicID = $DB->inserted_id();
|
$TopicID = G::$DB->inserted_id();
|
||||||
$Posts = 1;
|
$Posts = 1;
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO forums_posts
|
INSERT INTO forums_posts
|
||||||
(TopicID, AuthorID, AddedTime, Body)
|
(TopicID, AuthorID, AddedTime, Body)
|
||||||
VALUES
|
VALUES
|
||||||
('$TopicID', '$AuthorID', '".sqltime()."', '$PostBody')");
|
('$TopicID', '$AuthorID', '".sqltime()."', '$PostBody')");
|
||||||
$PostID = $DB->inserted_id();
|
$PostID = G::$DB->inserted_id();
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE forums
|
UPDATE forums
|
||||||
SET
|
SET
|
||||||
NumPosts = NumPosts+1,
|
NumPosts = NumPosts+1,
|
||||||
@ -183,7 +191,7 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
|||||||
LastPostTime = '".sqltime()."'
|
LastPostTime = '".sqltime()."'
|
||||||
WHERE ID = '$ForumID'");
|
WHERE ID = '$ForumID'");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE forums_topics
|
UPDATE forums_topics
|
||||||
SET
|
SET
|
||||||
NumPosts = NumPosts+1,
|
NumPosts = NumPosts+1,
|
||||||
@ -193,16 +201,16 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
|||||||
WHERE ID = '$TopicID'");
|
WHERE ID = '$TopicID'");
|
||||||
|
|
||||||
// Bump this topic to head of the cache
|
// Bump this topic to head of the cache
|
||||||
list($Forum,,, $Stickies) = $Cache->get_value('forums_'.$ForumID);
|
list($Forum,,, $Stickies) = G::$Cache->get_value('forums_'.$ForumID);
|
||||||
if (!empty($Forum)) {
|
if (!empty($Forum)) {
|
||||||
if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
|
if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
|
||||||
array_pop($Forum);
|
array_pop($Forum);
|
||||||
}
|
}
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT f.IsLocked, f.IsSticky, f.NumPosts
|
SELECT f.IsLocked, f.IsSticky, f.NumPosts
|
||||||
FROM forums_topics AS f
|
FROM forums_topics AS f
|
||||||
WHERE f.ID ='$TopicID'");
|
WHERE f.ID ='$TopicID'");
|
||||||
list($IsLocked, $IsSticky, $NumPosts) = $DB->next_record();
|
list($IsLocked, $IsSticky, $NumPosts) = G::$DB->next_record();
|
||||||
$Part1 = array_slice($Forum, 0, $Stickies, true); //Stickys
|
$Part1 = array_slice($Forum, 0, $Stickies, true); //Stickys
|
||||||
$Part2 = array(
|
$Part2 = array(
|
||||||
$TopicID => array(
|
$TopicID => array(
|
||||||
@ -228,11 +236,11 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
|||||||
if (is_null($Part1)) { $Part1 = array(); }
|
if (is_null($Part1)) { $Part1 = array(); }
|
||||||
if (is_null($Part3)) { $Part3 = array(); }
|
if (is_null($Part3)) { $Part3 = array(); }
|
||||||
$Forum = $Part1 + $Part2 + $Part3;
|
$Forum = $Part1 + $Part2 + $Part3;
|
||||||
$Cache->cache_value('forums_'.$ForumID, array($Forum, '', 0, $Stickies), 0);
|
G::$Cache->cache_value('forums_'.$ForumID, array($Forum, '', 0, $Stickies), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the forum root
|
//Update the forum root
|
||||||
$Cache->begin_transaction('forums_list');
|
G::$Cache->begin_transaction('forums_list');
|
||||||
$UpdateArray = array(
|
$UpdateArray = array(
|
||||||
'NumPosts'=>'+1',
|
'NumPosts'=>'+1',
|
||||||
'NumTopics'=>'+1',
|
'NumTopics'=>'+1',
|
||||||
@ -247,26 +255,28 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
|||||||
|
|
||||||
$UpdateArray['NumTopics'] = '+1';
|
$UpdateArray['NumTopics'] = '+1';
|
||||||
|
|
||||||
$Cache->update_row($ForumID, $UpdateArray);
|
G::$Cache->update_row($ForumID, $UpdateArray);
|
||||||
$Cache->commit_transaction(0);
|
G::$Cache->commit_transaction(0);
|
||||||
|
|
||||||
$CatalogueID = floor((POSTS_PER_PAGE * ceil($Posts / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
|
$CatalogueID = floor((POSTS_PER_PAGE * ceil($Posts / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||||
$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
|
G::$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
|
||||||
$Post = array(
|
$Post = array(
|
||||||
'ID'=>$PostID,
|
'ID'=>$PostID,
|
||||||
'AuthorID'=>$LoggedUser['ID'],
|
'AuthorID'=>G::$LoggedUser['ID'],
|
||||||
'AddedTime'=>sqltime(),
|
'AddedTime'=>sqltime(),
|
||||||
'Body'=>$PostBody,
|
'Body'=>$PostBody,
|
||||||
'EditedUserID'=>0,
|
'EditedUserID'=>0,
|
||||||
'EditedTime'=>'0000-00-00 00:00:00',
|
'EditedTime'=>'0000-00-00 00:00:00',
|
||||||
'Username'=>''
|
'Username'=>''
|
||||||
);
|
);
|
||||||
$Cache->insert('', $Post);
|
G::$Cache->insert('', $Post);
|
||||||
$Cache->commit_transaction(0);
|
G::$Cache->commit_transaction(0);
|
||||||
|
|
||||||
$Cache->begin_transaction('thread_'.$TopicID.'_info');
|
G::$Cache->begin_transaction('thread_'.$TopicID.'_info');
|
||||||
$Cache->update_row(false, array('Posts'=>'+1', 'LastPostAuthorID'=>$AuthorID));
|
G::$Cache->update_row(false, array('Posts'=>'+1', 'LastPostAuthorID'=>$AuthorID));
|
||||||
$Cache->commit_transaction(0);
|
G::$Cache->commit_transaction(0);
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
return $TopicID;
|
return $TopicID;
|
||||||
}
|
}
|
||||||
@ -355,24 +365,25 @@ public static function assert_isset_request($Request, $Keys = NULL, $AllowEmpty
|
|||||||
* @return array IDs
|
* @return array IDs
|
||||||
*/
|
*/
|
||||||
public static function get_tags($TagNames) {
|
public static function get_tags($TagNames) {
|
||||||
global $Cache, $DB;
|
|
||||||
$TagIDs = array();
|
$TagIDs = array();
|
||||||
foreach ($TagNames as $Index => $TagName) {
|
foreach ($TagNames as $Index => $TagName) {
|
||||||
$Tag = $Cache->get_value('tag_id_'.$TagName);
|
$Tag = G::$Cache->get_value('tag_id_'.$TagName);
|
||||||
if (is_array($Tag)) {
|
if (is_array($Tag)) {
|
||||||
unset($TagNames[$Index]);
|
unset($TagNames[$Index]);
|
||||||
$TagIDs[$Tag['ID']] = $Tag['Name'];
|
$TagIDs[$Tag['ID']] = $Tag['Name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($TagNames) > 0) {
|
if (count($TagNames) > 0) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT ID, Name
|
SELECT ID, Name
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE Name IN ('".implode("', '", $TagNames)."')");
|
WHERE Name IN ('".implode("', '", $TagNames)."')");
|
||||||
$SQLTagIDs = $DB->to_array();
|
$SQLTagIDs = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
foreach ($SQLTagIDs as $Tag) {
|
foreach ($SQLTagIDs as $Tag) {
|
||||||
$TagIDs[$Tag['ID']] = $Tag['Name'];
|
$TagIDs[$Tag['ID']] = $Tag['Name'];
|
||||||
$Cache->cache_value('tag_id_'.$Tag['Name'], $Tag, 0);
|
G::$Cache->cache_value('tag_id_'.$Tag['Name'], $Tag, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,17 +398,19 @@ public static function get_tags($TagNames) {
|
|||||||
* @return string The aliased tag.
|
* @return string The aliased tag.
|
||||||
*/
|
*/
|
||||||
public static function get_alias_tag($BadTag) {
|
public static function get_alias_tag($BadTag) {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT AliasTag
|
SELECT AliasTag
|
||||||
FROM tag_aliases
|
FROM tag_aliases
|
||||||
WHERE BadTag = '$BadTag'
|
WHERE BadTag = '$BadTag'
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($AliasTag) = $DB->next_record();
|
list($AliasTag) = G::$DB->next_record();
|
||||||
return $AliasTag;
|
} else {
|
||||||
|
$AliasTag = $BadTag;
|
||||||
}
|
}
|
||||||
return $BadTag;
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $AliasTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -407,10 +420,12 @@ public static function get_alias_tag($BadTag) {
|
|||||||
* @param string $Message the message to write.
|
* @param string $Message the message to write.
|
||||||
*/
|
*/
|
||||||
public static function write_log($Message) {
|
public static function write_log($Message) {
|
||||||
global $DB, $Time;
|
global $Time;
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
INSERT INTO log (Message, Time)
|
INSERT INTO log (Message, Time)
|
||||||
VALUES ('" . db_string($Message) . "', '" . sqltime() . "')");
|
VALUES ('" . db_string($Message) . "', '" . sqltime() . "')");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -491,7 +506,6 @@ public static function is_new_torrent(&$Data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function display_recommend($ID, $Type, $Hide = true) {
|
public static function display_recommend($ID, $Type, $Hide = true) {
|
||||||
global $DB, $LoggedUser;
|
|
||||||
if ($Hide) {
|
if ($Hide) {
|
||||||
$Hide = ' style="display: none;"';
|
$Hide = ' style="display: none;"';
|
||||||
}
|
}
|
||||||
@ -509,5 +523,9 @@ public static function display_recommend($ID, $Type, $Hide = true) {
|
|||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function is_valid_url($URL) {
|
||||||
|
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $URL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
This class can only hold one result set at a time. Using set_query_id allows
|
This class can only hold one result set at a time. Using set_query_id allows
|
||||||
you to set the result set that the class is using to the result set in
|
you to set the result set that the class is using to the result set in
|
||||||
$ResultSet. This result set should have been obtained earlier by using
|
$ResultSet. This result set should have been obtained earlier by using
|
||||||
$DB-query().
|
$DB->query().
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ function __construct($Database = SQLDB, $User = SQLLOGIN, $Pass = SQLPASS, $Serv
|
|||||||
}
|
}
|
||||||
|
|
||||||
function halt($Msg) {
|
function halt($Msg) {
|
||||||
global $LoggedUser, $Cache, $Debug, $argv;
|
global $Debug, $argv;
|
||||||
$DBError = 'MySQL: '.strval($Msg).' SQL error: '.strval($this->Errno).' ('.strval($this->Error).')';
|
$DBError = 'MySQL: '.strval($Msg).' SQL error: '.strval($this->Errno).' ('.strval($this->Error).')';
|
||||||
if ($this->Errno == 1194) {
|
if ($this->Errno == 1194) {
|
||||||
send_irc('PRIVMSG '.ADMIN_CHAN.' :'.$this->Error);
|
send_irc('PRIVMSG '.ADMIN_CHAN.' :'.$this->Error);
|
||||||
@ -205,7 +205,7 @@ function connect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function query($Query, $AutoHandle = 1) {
|
function query($Query, $AutoHandle = 1) {
|
||||||
global $LoggedUser, $Debug;
|
global $Debug;
|
||||||
/*
|
/*
|
||||||
* If there was a previous query, we store the warnings. We cannot do
|
* If there was a previous query, we store the warnings. We cannot do
|
||||||
* this immediately after mysqli_query because mysqli_insert_id will
|
* this immediately after mysqli_query because mysqli_insert_id will
|
||||||
|
659
classes/notificationsmanager.class.php
Normal file
659
classes/notificationsmanager.class.php
Normal file
@ -0,0 +1,659 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
class NotificationsManager {
|
||||||
|
// Importances
|
||||||
|
const IMPORTANT = "information";
|
||||||
|
const CRITICAL = "error";
|
||||||
|
const WARNING = "warning";
|
||||||
|
const INFO = "confirmation";
|
||||||
|
|
||||||
|
public static $Importances = array(
|
||||||
|
"important" => "information",
|
||||||
|
"critical" => "error",
|
||||||
|
"warning" => "warning",
|
||||||
|
"info" => "confirmation");
|
||||||
|
|
||||||
|
// Types. These names must correspond to column names in users_notifications_settings
|
||||||
|
const NEWS = "News";
|
||||||
|
const BLOG = "Blog";
|
||||||
|
const STAFFBLOG = "StaffBlog";
|
||||||
|
const STAFFPM = "StaffPM";
|
||||||
|
const INBOX = "Inbox";
|
||||||
|
const QUOTES = "Quotes";
|
||||||
|
const SUBSCRIPTIONS = "Subscriptions";
|
||||||
|
const TORRENTS = "Torrents";
|
||||||
|
const COLLAGES = "Collages";
|
||||||
|
const SITEALERTS = "SiteAlerts";
|
||||||
|
const FORUMALERTS = "ForumAlerts";
|
||||||
|
const REQUESTALERTS = "RequestAlerts";
|
||||||
|
const COLLAGEALERTS = "CollageAlerts";
|
||||||
|
const TORRENTALERTS = "TorrentAlerts";
|
||||||
|
const GLOBALNOTICE = "Global";
|
||||||
|
|
||||||
|
|
||||||
|
public static $Types = array(
|
||||||
|
"News",
|
||||||
|
"Blog",
|
||||||
|
"StaffPM",
|
||||||
|
"Inbox",
|
||||||
|
"Quotes",
|
||||||
|
"Subscriptions",
|
||||||
|
"Torrents",
|
||||||
|
"Collages",
|
||||||
|
"SiteAlerts",
|
||||||
|
"ForumAlerts",
|
||||||
|
"RequestAlerts",
|
||||||
|
"CollageAlerts",
|
||||||
|
"TorrentAlerts");
|
||||||
|
|
||||||
|
private $UserID;
|
||||||
|
private $Notifications;
|
||||||
|
private $Settings;
|
||||||
|
|
||||||
|
function __construct($UserID, $Skip = array(), $Load = true, $AutoSkip = true) {
|
||||||
|
$this->UserID = $UserID;
|
||||||
|
$this->Notifications = array();
|
||||||
|
$this->Settings = self::get_settings($UserID);
|
||||||
|
if ($AutoSkip) {
|
||||||
|
foreach ($this->Settings as $Key => $Value) {
|
||||||
|
// Skip disabled and traditional settings
|
||||||
|
if ($Value == 0 || $Value == 2) {
|
||||||
|
$Skip[] = $Key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($Load) {
|
||||||
|
$this->load_global_notification();
|
||||||
|
if (!in_array(self::NEWS, $Skip)) {
|
||||||
|
$this->load_news();
|
||||||
|
}
|
||||||
|
if (!in_array(self::BLOG, $Skip)) {
|
||||||
|
$this->load_blog();
|
||||||
|
}
|
||||||
|
// if (!in_array(self::STAFFBLOG, $Skip)) {
|
||||||
|
// $this->load_staff_blog();
|
||||||
|
// }
|
||||||
|
if (!in_array(self::STAFFPM, $Skip)) {
|
||||||
|
$this->load_staff_pms();
|
||||||
|
}
|
||||||
|
if (!in_array(self::INBOX, $Skip)) {
|
||||||
|
$this->load_inbox();
|
||||||
|
}
|
||||||
|
if (!in_array(self::TORRENTS, $Skip)) {
|
||||||
|
$this->load_torrent_notifications();
|
||||||
|
}
|
||||||
|
if (!in_array(self::COLLAGES, $Skip)) {
|
||||||
|
$this->load_collage_subscriptions();
|
||||||
|
}
|
||||||
|
if (!in_array(self::QUOTES, $Skip)) {
|
||||||
|
$this->load_quote_notifications();
|
||||||
|
}
|
||||||
|
if (!in_array(self::SUBSCRIPTIONS, $Skip)) {
|
||||||
|
$this->load_subscriptions();
|
||||||
|
}
|
||||||
|
$this->load_one_reads();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_notifications() {
|
||||||
|
return $this->Notifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear_notifications_array() {
|
||||||
|
unset($this->Notifications);
|
||||||
|
$this->Notifications = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function create_notification($Type, $ID, $Message, $URL, $Importance) {
|
||||||
|
$this->Notifications[$Type] = array("contents" => array("id" => (int) $ID, "message" => $Message, "url" => $URL, "importance" => $Importance));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function notify_user($UserID, $Type, $Message, $URL, $Importance) {
|
||||||
|
self::notify_users(array($UserID), $Type, $Message, $URL, $Importance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function notify_users($UserIDs, $Type, $Message, $URL, $Importance) {
|
||||||
|
/**
|
||||||
|
if (!isset($Importance)) {
|
||||||
|
$Importance = self::INFO;
|
||||||
|
}
|
||||||
|
$Type = db_string($Type);
|
||||||
|
if (!empty($UserIDs)) {
|
||||||
|
$UserIDs = implode(',', $UserIDs);
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT UserID
|
||||||
|
FROM users_notifications_settings
|
||||||
|
WHERE $Type != 0
|
||||||
|
AND UserID IN ($UserIDs)");
|
||||||
|
$UserIDs = array();
|
||||||
|
while (list($ID) = G::$DB->next_record()) {
|
||||||
|
$UserIDs[] = $ID;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
foreach ($UserIDs as $UserID) {
|
||||||
|
$OneReads = G::$Cache->get_value("notifications_one_reads_$UserID");
|
||||||
|
if (!$OneReads) {
|
||||||
|
$OneReads = array();
|
||||||
|
}
|
||||||
|
array_unshift($OneReads, $this->create_notification($OneReads, "oneread_" . uniqid(), null, $Message, $URL, $Importance));
|
||||||
|
$OneReads = array_filter($OneReads);
|
||||||
|
G::$Cache->cache_value("notifications_one_reads_$UserID", $OneReads, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
**/
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_notification_enabled_users($Type, $UserID) {
|
||||||
|
$Type = db_string($Type);
|
||||||
|
$UserWhere = '';
|
||||||
|
if (isset($UserID)) {
|
||||||
|
$UserID = (int) $UserID;
|
||||||
|
$UserWhere = " AND UserID = '$UserID'";
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT UserID
|
||||||
|
FROM users_notifications_settings
|
||||||
|
WHERE $Type != 0
|
||||||
|
$UserWhere");
|
||||||
|
$IDs = array();
|
||||||
|
while (list($ID) = G::$DB->next_record()) {
|
||||||
|
$IDs[] = $ID;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $IDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_one_reads() {
|
||||||
|
$OneReads = G::$Cache->get_value('notifications_one_reads_' . G::$LoggedUser['ID']);
|
||||||
|
if (is_array($OneReads)) {
|
||||||
|
$this->Notifications = $this->Notifications + $OneReads;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_one_read($ID) {
|
||||||
|
$OneReads = G::$Cache->get_value('notifications_one_reads_' . G::$LoggedUser['ID']);
|
||||||
|
if ($OneReads) {
|
||||||
|
unset($OneReads[$ID]);
|
||||||
|
if (count($OneReads) > 0) {
|
||||||
|
G::$Cache->cache_value('notifications_one_reads_' . G::$LoggedUser['ID'], $OneReads, 0);
|
||||||
|
} else {
|
||||||
|
G::$Cache->delete_value('notifications_one_reads_' . G::$LoggedUser['ID']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_global_notification() {
|
||||||
|
$GlobalNotification = G::$Cache->get_value('global_notification');
|
||||||
|
if ($GlobalNotification) {
|
||||||
|
$Read = G::$Cache->get_value('user_read_global_' . G::$LoggedUser['ID']);
|
||||||
|
if (!$Read) {
|
||||||
|
$this->create_notification(self::GLOBALNOTICE, null, $GlobalNotification['Message'], $GlobalNotification['URL'], $GlobalNotification['Importance']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_global_notification() {
|
||||||
|
return G::$Cache->get_value('global_notification');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function set_global_notification($Message, $URL, $Importance, $Expiration) {
|
||||||
|
if (empty($Message) || empty($Expiration)) {
|
||||||
|
error('Error setting notification');
|
||||||
|
}
|
||||||
|
G::$Cache->cache_value('global_notification', array("Message" => $Message, "URL" => $URL, "Importance" => $Importance, "Expiration" => $Expiration), $Expiration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function delete_global_notification() {
|
||||||
|
G::$Cache->delete_value('global_notification');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_global_notification() {
|
||||||
|
$GlobalNotification = G::$Cache->get_value('global_notification');
|
||||||
|
if ($GlobalNotification) {
|
||||||
|
// This is some trickery
|
||||||
|
// since we can't know which users have the read cache key set
|
||||||
|
// wet set the expiration time of their cache key to that of the length of the notification
|
||||||
|
// this gaurantees that their cache key will expire after the notification expires
|
||||||
|
G::$Cache->cache_value('user_read_global_' . G::$LoggedUser['ID'], true, $GlobalNotification['Expiration']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_news() {
|
||||||
|
$MyNews = G::$LoggedUser['LastReadNews'];
|
||||||
|
$CurrentNews = G::$Cache->get_value('news_latest_id');
|
||||||
|
$Title = G::$Cache->get_value('news_latest_title');
|
||||||
|
if ($CurrentNews === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query('
|
||||||
|
SELECT ID, Title
|
||||||
|
FROM news
|
||||||
|
ORDER BY Time DESC
|
||||||
|
LIMIT 1');
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
list($CurrentNews, $Title) = G::$DB->next_record();
|
||||||
|
} else {
|
||||||
|
$CurrentNews = -1;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('news_latest_id', $CurrentNews, 0);
|
||||||
|
G::$Cache->cache_value('news_latest_title', $Title, 0);
|
||||||
|
}
|
||||||
|
if ($MyNews < $CurrentNews) {
|
||||||
|
$this->create_notification(self::NEWS, $CurrentNews, "Announcement: $Title", "index.php#news$CurrentNews", self::IMPORTANT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_blog() {
|
||||||
|
$MyBlog = G::$LoggedUser['LastReadBlog'];
|
||||||
|
$CurrentBlog = G::$Cache->get_value('blog_latest_id');
|
||||||
|
$Title = G::$Cache->get_value('blog_latest_title');
|
||||||
|
if ($CurrentBlog === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query('
|
||||||
|
SELECT ID, Title
|
||||||
|
FROM blog
|
||||||
|
WHERE Important = 1
|
||||||
|
ORDER BY Time DESC
|
||||||
|
LIMIT 1');
|
||||||
|
if (G::$DB->has_results()) {
|
||||||
|
list($CurrentBlog, $Title) = G::$DB->next_record();
|
||||||
|
} else {
|
||||||
|
$CurrentBlog = -1;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('blog_latest_id', $CurrentBlog, 0);
|
||||||
|
G::$Cache->cache_value('blog_latest_title', $Title, 0);
|
||||||
|
}
|
||||||
|
if ($MyBlog < $CurrentBlog) {
|
||||||
|
$this->create_notification(self::BLOG, $CurrentBlog, "Blog: $Title", "blog.php#blog$CurrentBlog", self::IMPORTANT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_staff_blog() {
|
||||||
|
if (check_perms('users_mod')) {
|
||||||
|
global $SBlogReadTime, $LatestSBlogTime;
|
||||||
|
if (!$SBlogReadTime && ($SBlogReadTime = G::$Cache->get_value('staff_blog_read_' . G::$LoggedUser['ID'])) === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT Time
|
||||||
|
FROM staff_blog_visits
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID']);
|
||||||
|
if (list($SBlogReadTime) = G::$DB->next_record()) {
|
||||||
|
$SBlogReadTime = strtotime($SBlogReadTime);
|
||||||
|
} else {
|
||||||
|
$SBlogReadTime = 0;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('staff_blog_read_' . G::$LoggedUser['ID'], $SBlogReadTime, 1209600);
|
||||||
|
}
|
||||||
|
if (!$LatestSBlogTime && ($LatestSBlogTime = G::$Cache->get_value('staff_blog_latest_time')) === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query('
|
||||||
|
SELECT MAX(Time)
|
||||||
|
FROM staff_blog');
|
||||||
|
if (list($LatestSBlogTime) = G::$DB->next_record()) {
|
||||||
|
$LatestSBlogTime = strtotime($LatestSBlogTime);
|
||||||
|
} else {
|
||||||
|
$LatestSBlogTime = 0;
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600);
|
||||||
|
}
|
||||||
|
if ($SBlogReadTime < $LatestSBlogTime) {
|
||||||
|
$this->create_notification(self::STAFFBLOG, '', 'New Staff Blog Post!', 'staffblog.php', self::IMPORTANT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_staff_pms() {
|
||||||
|
$NewStaffPMs = G::$Cache->get_value('staff_pm_new_' . G::$LoggedUser['ID']);
|
||||||
|
if ($NewStaffPMs === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT COUNT(ID)
|
||||||
|
FROM staff_pm_conversations
|
||||||
|
WHERE UserID = '" . G::$LoggedUser['ID'] . "'
|
||||||
|
AND Unread = '1'");
|
||||||
|
list($NewStaffPMs) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('staff_pm_new_' . G::$LoggedUser['ID'], $NewStaffPMs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($NewStaffPMs > 0) {
|
||||||
|
$Title = 'You have new ' . ($NewStaffPMs == 1 ? 'a' : $NewStaffPMs) . ' Staff PM' . ($NewStaffPMs > 1 ? 's' : '');
|
||||||
|
$this->create_notification(self::STAFFPM, '', $Title, 'staffpm.php', self::INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_inbox() {
|
||||||
|
$NewMessages = G::$Cache->get_value('inbox_new_' . G::$LoggedUser['ID']);
|
||||||
|
if ($NewMessages === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT COUNT(UnRead)
|
||||||
|
FROM pm_conversations_users
|
||||||
|
WHERE UserID = '" . G::$LoggedUser['ID'] . "'
|
||||||
|
AND UnRead = '1'
|
||||||
|
AND InInbox = '1'");
|
||||||
|
list($NewMessages) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('inbox_new_' . G::$LoggedUser['ID'], $NewMessages, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($NewMessages > 0) {
|
||||||
|
$Title = 'You have ' . ($NewMessages == 1 ? 'a' : $NewMessages) . ' new message' . ($NewMessages > 1 ? 's' : '');
|
||||||
|
$this->create_notification(self::INBOX, '', $Title, Inbox::get_inbox_link(), self::INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_torrent_notifications() {
|
||||||
|
if (check_perms('site_torrents_notify')) {
|
||||||
|
$NewNotifications = G::$Cache->get_value('notifications_new_' . G::$LoggedUser['ID']);
|
||||||
|
if ($NewNotifications === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT COUNT(UserID)
|
||||||
|
FROM users_notify_torrents
|
||||||
|
WHERE UserID = ' " . G::$LoggedUser['ID'] . "'
|
||||||
|
AND UnRead = '1'");
|
||||||
|
list($NewNotifications) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('notifications_new_' . G::$LoggedUser['ID'], $NewNotifications, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($NewNotifications > 0) {
|
||||||
|
$Title = 'You have ' . ($NewNotifications == 1 ? 'a' : $NewNotifications) . ' new torrent notification' . ($NewNotifications > 1 ? 's' : '');
|
||||||
|
$this->create_notification(self::TORRENTS, '', $Title, 'torrents.php?action=notify', self::INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_collage_subscriptions() {
|
||||||
|
if (check_perms('site_collages_subscribe')) {
|
||||||
|
$NewCollages = G::$Cache->get_value('collage_subs_user_new_' . G::$LoggedUser['ID']);
|
||||||
|
if ($NewCollages === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT COUNT(DISTINCT s.CollageID)
|
||||||
|
FROM users_collage_subs as s
|
||||||
|
JOIN collages as c ON s.CollageID = c.ID
|
||||||
|
JOIN collages_torrents as ct on ct.CollageID = c.ID
|
||||||
|
WHERE s.UserID = " . G::$LoggedUser['ID'] . "
|
||||||
|
AND ct.AddedOn > s.LastVisit
|
||||||
|
AND c.Deleted = '0'");
|
||||||
|
list($NewCollages) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('collage_subs_user_new_' . G::$LoggedUser['ID'], $NewCollages, 0);
|
||||||
|
}
|
||||||
|
if ($NewCollages > 0) {
|
||||||
|
$Title = 'You have ' . ($NewCollages == 1 ? 'a' : $NewCollages) . ' new collage update' . ($NewCollages > 1 ? 's' : '');
|
||||||
|
$this->create_notification(self::COLLAGES, '', $Title, 'userhistory.php?action=subscribed_collages', self::INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_quote_notifications() {
|
||||||
|
if (G::$LoggedUser['NotifyOnQuote']) {
|
||||||
|
$QuoteNotificationsCount = Subscriptions::has_new_quote_notifications();
|
||||||
|
if ($QuoteNotificationsCount > 0) {
|
||||||
|
$Title = 'New quote' . ($QuoteNotificationsCount > 1 ? 's' : '');
|
||||||
|
$this->create_notification(self::QUOTES, null, $Title, 'userhistory.php?action=quote_notifications', self::INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_subscriptions() {
|
||||||
|
$SubscriptionsCount = Subscriptions::has_new_subscriptions();
|
||||||
|
if ($SubscriptionsCount > 0) {
|
||||||
|
$Title = 'New subscription' . ($SubscriptionsCount > 1 ? 's' : '');
|
||||||
|
$this->create_notification(self::SUBSCRIPTIONS, null, $Title, 'userhistory.php?action=subscriptions', self::INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function clear_news($News) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
if (!$News) {
|
||||||
|
if (!$News = G::$Cache->get_value('news')) {
|
||||||
|
G::$DB->query('
|
||||||
|
SELECT
|
||||||
|
ID,
|
||||||
|
Title,
|
||||||
|
Body,
|
||||||
|
Time
|
||||||
|
FROM news
|
||||||
|
ORDER BY Time DESC
|
||||||
|
LIMIT 1');
|
||||||
|
$News = G::$DB->to_array(false, MYSQLI_NUM, false);
|
||||||
|
G::$Cache->cache_value('news_latest_id', $News[0][0], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (G::$LoggedUser['LastReadNews'] != $News[0][0]) {
|
||||||
|
G::$Cache->begin_transaction('user_info_heavy_' . G::$LoggedUser['ID']);
|
||||||
|
G::$Cache->update_row(false, array('LastReadNews' => $News[0][0]));
|
||||||
|
G::$Cache->commit_transaction(0);
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_info
|
||||||
|
SET LastReadNews = '".$News[0][0]."'
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID']);
|
||||||
|
G::$LoggedUser['LastReadNews'] = $News[0][0];
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_blog($Blog) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
if (!$Blog) {
|
||||||
|
if (!$Blog = G::$Cache->get_value('blog')) {
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT
|
||||||
|
b.ID,
|
||||||
|
um.Username,
|
||||||
|
b.Title,
|
||||||
|
b.Body,
|
||||||
|
b.Time,
|
||||||
|
b.ThreadID
|
||||||
|
FROM blog AS b
|
||||||
|
LEFT JOIN users_main AS um ON b.UserID = um.ID
|
||||||
|
ORDER BY Time DESC
|
||||||
|
LIMIT 1");
|
||||||
|
$Blog = G::$DB->to_array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (G::$LoggedUser['LastReadBlog'] < $Blog[0][0]) {
|
||||||
|
G::$Cache->begin_transaction('user_info_heavy_' . G::$LoggedUser['ID']);
|
||||||
|
G::$Cache->update_row(false, array('LastReadBlog' => $Blog[0][0]));
|
||||||
|
G::$Cache->commit_transaction(0);
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_info
|
||||||
|
SET LastReadBlog = '". $Blog[0][0]."'
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID']);
|
||||||
|
G::$LoggedUser['LastReadBlog'] = $Blog[0][0];
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_staff_pms() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT ID
|
||||||
|
FROM staff_pm_conversations
|
||||||
|
WHERE Unread = true
|
||||||
|
AND UserID = " . G::$LoggedUser['ID']);
|
||||||
|
$IDs = array();
|
||||||
|
while (list($ID) = G::$DB->next_record()) {
|
||||||
|
$IDs[] = $ID;
|
||||||
|
}
|
||||||
|
$IDs = implode(',', $IDs);
|
||||||
|
if (!empty($IDs)) {
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE staff_pm_conversations
|
||||||
|
SET Unread = false
|
||||||
|
WHERE ID IN ($IDs)");
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value('staff_pm_new_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_inbox() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT ConvID
|
||||||
|
FROM pm_conversations_users
|
||||||
|
WHERE Unread = '1'
|
||||||
|
AND UserID = " . G::$LoggedUser['ID']);
|
||||||
|
$IDs = array();
|
||||||
|
while (list($ID) = G::$DB->next_record()) {
|
||||||
|
$IDs[] = $ID;
|
||||||
|
}
|
||||||
|
$IDs = implode(',', $IDs);
|
||||||
|
if (!empty($IDs)) {
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE pm_conversations_users
|
||||||
|
SET Unread = '0'
|
||||||
|
WHERE ConvID IN ($IDs)
|
||||||
|
AND UserID = " . G::$LoggedUser['ID']);
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value('inbox_new_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_torrents() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT TorrentID
|
||||||
|
FROM users_notify_torrents
|
||||||
|
WHERE UserID = ' " . G::$LoggedUser['ID'] . "'
|
||||||
|
AND UnRead = '1'");
|
||||||
|
$IDs = array();
|
||||||
|
while (list($ID) = G::$DB->next_record()) {
|
||||||
|
$IDs[] = $ID;
|
||||||
|
}
|
||||||
|
$IDs = implode(',', $IDs);
|
||||||
|
if (!empty($IDs)) {
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_notify_torrents
|
||||||
|
SET Unread = '0'
|
||||||
|
WHERE TorrentID IN ($IDs)
|
||||||
|
AND UserID = " . G::$LoggedUser['ID']);
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value('notifications_new_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_collages() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_collage_subs
|
||||||
|
SET LastVisit = NOW()
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID']);
|
||||||
|
G::$Cache->delete_value('collage_subs_user_new_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_quotes() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_notify_quoted
|
||||||
|
SET UnRead = '0'
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID']);
|
||||||
|
G::$Cache->delete_value('notify_quoted_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clear_subscriptions() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
if (($UserSubscriptions = G::$Cache->get_value('subscriptions_user_' . G::$LoggedUser['ID'])) === false) {
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT TopicID
|
||||||
|
FROM users_subscriptions
|
||||||
|
WHERE UserID = " . G::$LoggedUser['ID']);
|
||||||
|
if ($UserSubscriptions = G::$DB->collect(0)) {
|
||||||
|
G::$Cache->cache_value('subscriptions_user_' . G::$LoggedUser['ID'], $UserSubscriptions, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($UserSubscriptions)) {
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT INTO forums_last_read_topics (UserID, TopicID, PostID)
|
||||||
|
SELECT '" . G::$LoggedUser['ID'] . "', ID, LastPostID
|
||||||
|
FROM forums_topics
|
||||||
|
WHERE ID IN (".implode(',', $UserSubscriptions).')
|
||||||
|
ON DUPLICATE KEY
|
||||||
|
UPDATE PostID = LastPostID');
|
||||||
|
}
|
||||||
|
G::$Cache->delete_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function send_notification($UserID, $ID, $Type, $Message, $URL, $Importance = 'alert', $AutoExpire = false) {
|
||||||
|
$Notifications = G::$Cache->get_value("user_cache_notifications_$UserID");
|
||||||
|
if (empty($Notifications)) {
|
||||||
|
$Notifications = array();
|
||||||
|
}
|
||||||
|
array_unshift($Notifications, $this->create_notification($Type, $ID, $Message, $URL, $Importance, $AutoExpire));
|
||||||
|
G::$Cache->cache_value("user_cache_notifications_$UserID", $Notifications, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function clear_notification($UserID, $Index) {
|
||||||
|
$Notifications = G::$Cache->get_value("user_cache_notifications_$UserID");
|
||||||
|
if (count($Notifications)) {
|
||||||
|
unset($Notifications[$Index]);
|
||||||
|
$Notifications = array_values($Notifications);
|
||||||
|
G::$Cache->cache_value("user_cache_notifications_$UserID", $Notifications, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_settings($UserID) {
|
||||||
|
$Results = G::$Cache->get_value("users_notifications_settings_$UserID");
|
||||||
|
if (!$Results) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT *
|
||||||
|
FROM users_notifications_settings
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
$Results = G::$DB->next_record(MYSQLI_ASSOC);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("users_notifications_settings_$UserID", $Results, 0);
|
||||||
|
}
|
||||||
|
return $Results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function save_settings($UserID, $Settings) {
|
||||||
|
if (!is_array($Settings)) {
|
||||||
|
// A little cheat technique, gets all keys in the $_POST array starting with 'notifications_'
|
||||||
|
$Settings = array_intersect_key($_POST, array_flip(preg_grep('/^notifications_/', array_keys($_POST))));
|
||||||
|
}
|
||||||
|
$Update = array();
|
||||||
|
$Types = self::$Types;
|
||||||
|
foreach ($Types as $Type) {
|
||||||
|
$Popup = array_key_exists("notifications_$Type" . '_popup', $Settings);
|
||||||
|
$Traditional = array_key_exists("notifications_$Type" . '_traditional', $Settings);
|
||||||
|
$Result = 0;
|
||||||
|
if ($Popup) {
|
||||||
|
$Result = 1;
|
||||||
|
} elseif ($Traditional) {
|
||||||
|
$Result = 2;
|
||||||
|
}
|
||||||
|
$Update[] = "$Type = $Result";
|
||||||
|
}
|
||||||
|
$Update = implode(',', $Update);
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
|
UPDATE users_notifications_settings
|
||||||
|
SET $Update
|
||||||
|
WHERE UserID = '$UserID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->delete_value("users_notifications_settings_$UserID");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_traditional($Type) {
|
||||||
|
return $this->Settings[$Type] == 2;
|
||||||
|
}
|
||||||
|
}
|
151
classes/notificationsmanagerview.class.php
Normal file
151
classes/notificationsmanagerview.class.php
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
class NotificationsManagerView {
|
||||||
|
private static $Settings;
|
||||||
|
|
||||||
|
public static function load_js() { ?>
|
||||||
|
<script type="text/javascript" src="<?=STATIC_SERVER?>functions/noty/noty.js"></script>
|
||||||
|
<script type="text/javascript" src="<?=STATIC_SERVER?>functions/noty/layouts/bottomRight.js"></script>
|
||||||
|
<script type="text/javascript" src="<?=STATIC_SERVER?>functions/noty/themes/default.js"></script>
|
||||||
|
<script type="text/javascript" src="<?=STATIC_SERVER?>functions/user_notifications.js"></script>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function render_settings($Settings) {
|
||||||
|
self::$Settings = $Settings;
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when a new sitewide news announcement is made.">
|
||||||
|
<strong>News announcements</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::NEWS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when a new sitewide blog post is made.">
|
||||||
|
<strong>Blog announcements</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::BLOG); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when you receive a new private message.">
|
||||||
|
<strong>Inbox messages</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::INBOX, true); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when you receive a new private message from a member of the <?=SITE_NAME?> staff.">
|
||||||
|
<strong>Staff messages</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::STAFFPM); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when a thread you have subscribed to receives a new post.">
|
||||||
|
<strong>Thread subscriptions</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::SUBSCRIPTIONS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification whenever someone quotes you in the forums.">
|
||||||
|
<strong>Quote notifications</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::QUOTES); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? if (check_perms('site_torrents_notify')) { ?>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when the torrent notification filters you have established are triggered.">
|
||||||
|
<strong>Torrent notifications</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::TORRENTS, true); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? } ?>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="Enabling this will give you a notification when a torrent is added to a collage you are subscribed to.">
|
||||||
|
<strong>Collage subscriptions</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::COLLAGES); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? /**
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="">
|
||||||
|
<strong>Site alerts</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::SITEALERTS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="">
|
||||||
|
<strong>Forum alerts</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::FORUMALERTS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="">
|
||||||
|
<strong>Request alerts</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::REQUESTALERTS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="">
|
||||||
|
<strong>Collage alerts</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::COLLAGEALERTS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label tooltip" title="">
|
||||||
|
<strong>Torrent alerts</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? self::render_checkbox(NotificationsManager::TORRENTALERTS); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? **/
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: The use of radio buttons with different "name" attributes is an ugly
|
||||||
|
* workaround for how NotificationsManager::save_settings() is coded.
|
||||||
|
*/
|
||||||
|
private static function render_checkbox($Name, $Both = false) {
|
||||||
|
$Checked = self::$Settings[$Name];
|
||||||
|
if ($Both) {
|
||||||
|
$IsChecked = $Checked == 2 ? ' checked="checked"' : '';
|
||||||
|
?>
|
||||||
|
<input type="radio" value="1" name="notifications_<?=$Name?>_traditional" id="notifications_<?=$Name?>_traditional"<?=$IsChecked?> />
|
||||||
|
<label for="notifications_<?=$Name?>_traditional">Traditional</label>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
$IsChecked = $Checked == 1 || !isset($Checked) ? ' checked="checked"' : '';
|
||||||
|
?>
|
||||||
|
<input <?=$Both ? 'type="radio" value="1"' : 'type="checkbox"'?> name="notifications_<?=$Name?>_popup" id="notifications_<?=$Name?>_popup"<?=$IsChecked?> />
|
||||||
|
<label for="notifications_<?=$Name?>_popup">Pop-up</label>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function format_traditional($Contents) {
|
||||||
|
return '<a href="' . $Contents['url'] . '">' . $Contents['message'] . '</a>';
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@
|
|||||||
define("PARANOIA_OVERRIDDEN", 2);
|
define("PARANOIA_OVERRIDDEN", 2);
|
||||||
|
|
||||||
function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
|
function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
|
||||||
global $LoggedUser, $Classes;
|
global $Classes;
|
||||||
if ($Property == false) {
|
if ($Property == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
|
|||||||
}
|
}
|
||||||
return $all;
|
return $all;
|
||||||
} else {
|
} else {
|
||||||
if (($UserID !== false) && ($LoggedUser['ID'] == $UserID)) {
|
if (($UserID !== false) && (G::$LoggedUser['ID'] == $UserID)) {
|
||||||
return PARANOIA_ALLOWED;
|
return PARANOIA_ALLOWED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,11 @@ class Permissions {
|
|||||||
* @param string $MinClass Return false if the user's class level is below this.
|
* @param string $MinClass Return false if the user's class level is below this.
|
||||||
*/
|
*/
|
||||||
public static function check_perms($PermissionName, $MinClass = 0) {
|
public static function check_perms($PermissionName, $MinClass = 0) {
|
||||||
global $LoggedUser;
|
|
||||||
return (
|
return (
|
||||||
isset($LoggedUser['Permissions'][$PermissionName])
|
isset(G::$LoggedUser['Permissions'][$PermissionName])
|
||||||
&& $LoggedUser['Permissions'][$PermissionName]
|
&& G::$LoggedUser['Permissions'][$PermissionName]
|
||||||
&& ($LoggedUser['Class'] >= $MinClass
|
&& (G::$LoggedUser['Class'] >= $MinClass
|
||||||
|| $LoggedUser['EffectiveClass'] >= $MinClass)
|
|| G::$LoggedUser['EffectiveClass'] >= $MinClass)
|
||||||
) ? true : false;
|
) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,16 +22,17 @@ public static function check_perms($PermissionName, $MinClass = 0) {
|
|||||||
* @return array permissions
|
* @return array permissions
|
||||||
*/
|
*/
|
||||||
public static function get_permissions($PermissionID) {
|
public static function get_permissions($PermissionID) {
|
||||||
global $DB, $Cache;
|
$Permission = G::$Cache->get_value('perm_'.$PermissionID);
|
||||||
$Permission = $Cache->get_value('perm_'.$PermissionID);
|
|
||||||
if (empty($Permission)) {
|
if (empty($Permission)) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums
|
SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums
|
||||||
FROM permissions AS p
|
FROM permissions AS p
|
||||||
WHERE ID='$PermissionID'");
|
WHERE ID='$PermissionID'");
|
||||||
$Permission = $DB->next_record(MYSQLI_ASSOC, array('Permissions'));
|
$Permission = G::$DB->next_record(MYSQLI_ASSOC, array('Permissions'));
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
$Permission['Permissions'] = unserialize($Permission['Permissions']);
|
$Permission['Permissions'] = unserialize($Permission['Permissions']);
|
||||||
$Cache->cache_value('perm_'.$PermissionID, $Permission, 2592000);
|
G::$Cache->cache_value('perm_'.$PermissionID, $Permission, 2592000);
|
||||||
}
|
}
|
||||||
return $Permission;
|
return $Permission;
|
||||||
}
|
}
|
||||||
@ -47,17 +47,18 @@ public static function get_permissions($PermissionID) {
|
|||||||
* @return array Mapping of PermissionName=>bool/int
|
* @return array Mapping of PermissionName=>bool/int
|
||||||
*/
|
*/
|
||||||
public static function get_permissions_for_user($UserID, $CustomPermissions = false) {
|
public static function get_permissions_for_user($UserID, $CustomPermissions = false) {
|
||||||
global $DB;
|
|
||||||
|
|
||||||
$UserInfo = Users::user_info($UserID);
|
$UserInfo = Users::user_info($UserID);
|
||||||
|
|
||||||
// Fetch custom permissions if they weren't passed in.
|
// Fetch custom permissions if they weren't passed in.
|
||||||
if ($CustomPermissions === false) {
|
if ($CustomPermissions === false) {
|
||||||
$DB->query('
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query('
|
||||||
SELECT um.CustomPermissions
|
SELECT um.CustomPermissions
|
||||||
FROM users_main AS um
|
FROM users_main AS um
|
||||||
WHERE um.ID = '.((int)$UserID));
|
WHERE um.ID = '.((int)$UserID));
|
||||||
list($CustomPermissions) = $DB->next_record(MYSQLI_NUM, false);
|
list($CustomPermissions) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($CustomPermissions) && !is_array($CustomPermissions)) {
|
if (!empty($CustomPermissions) && !is_array($CustomPermissions)) {
|
||||||
@ -89,10 +90,12 @@ public static function get_permissions_for_user($UserID, $CustomPermissions = fa
|
|||||||
$DonorPerms = array('Permissions' => array());
|
$DonorPerms = array('Permissions' => array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$DonorCollages = self::get_personal_collages($UserID, $Permissions['Permissions']['users_mod']);
|
||||||
|
|
||||||
$MaxCollages = $Permissions['Permissions']['MaxCollages']
|
$MaxCollages = $Permissions['Permissions']['MaxCollages']
|
||||||
+ $BonusCollages
|
+ $BonusCollages
|
||||||
+ $CustomPerms['MaxCollages']
|
+ $CustomPerms['MaxCollages']
|
||||||
+ $DonorPerms['Permissions']['MaxCollages'];
|
+ $DonorCollages;
|
||||||
|
|
||||||
//Combine the permissions
|
//Combine the permissions
|
||||||
return array_merge(
|
return array_merge(
|
||||||
@ -102,5 +105,39 @@ public static function get_permissions_for_user($UserID, $CustomPermissions = fa
|
|||||||
$DonorPerms['Permissions'],
|
$DonorPerms['Permissions'],
|
||||||
array('MaxCollages' => $MaxCollages));
|
array('MaxCollages' => $MaxCollages));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function get_personal_collages($UserID, $HasAll) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
if (!$HasAll) {
|
||||||
|
$SpecialRank = G::$Cache->get_value("donor_special_rank_$UserID");
|
||||||
|
if ($SpecialRank === false) {
|
||||||
|
G::$DB->query("SELECT SpecialRank FROM users_donor_ranks WHERE UserID = '$UserID'");
|
||||||
|
list($SpecialRank) = G::$DB->next_record();
|
||||||
|
$HasAll = $SpecialRank == MAX_SPECIAL_RANK ? true : false;
|
||||||
|
G::$Cache->cache_value("donor_special_rank_$UserID", $SpecialRank, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
G::$Cache->cache_value("donor_special_rank_$UserID", MAX_SPECIAL_RANK, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($HasAll) {
|
||||||
|
$Collages = 5;
|
||||||
|
} else {
|
||||||
|
$Collages = 0;
|
||||||
|
$Rank = G::$Cache->get_value("donor_rank_$UserID");
|
||||||
|
if ($Rank === false) {
|
||||||
|
G::$DB->query("SELECT Rank FROM users_donor_ranks WHERE UserID = '$UserID'");
|
||||||
|
list($Rank) = G::$DB->next_record();
|
||||||
|
G::$Cache->cache_value("donor_rank_$UserID", $Rank, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$Rank = min($Rank, 5);
|
||||||
|
for ($i = 1; $i <= $Rank; $i++) {
|
||||||
|
$Collages++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Collages;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -229,7 +229,6 @@ function permissions_form() { ?>
|
|||||||
<? display_perm('edit_unknowns', 'Can edit unknown release information.'); ?>
|
<? display_perm('edit_unknowns', 'Can edit unknown release information.'); ?>
|
||||||
<? display_perm('torrents_edit_vanityhouse', 'Can mark groups as part of Vanity House.'); ?>
|
<? display_perm('torrents_edit_vanityhouse', 'Can mark groups as part of Vanity House.'); ?>
|
||||||
<? display_perm('artist_edit_vanityhouse', 'Can mark artists as part of Vanity House.'); ?>
|
<? display_perm('artist_edit_vanityhouse', 'Can mark artists as part of Vanity House.'); ?>
|
||||||
<? display_perm('site_add_logs', 'Can add logs to torrents after upload'); ?>
|
|
||||||
<? display_perm('torrents_hide_dnu', 'Hide the Do Not Upload list by default.'); ?>
|
<? display_perm('torrents_hide_dnu', 'Hide the Do Not Upload list by default.'); ?>
|
||||||
<? display_perm('torrents_fix_ghosts', 'Can fix ghost groups on artist pages.'); ?>
|
<? display_perm('torrents_fix_ghosts', 'Can fix ghost groups on artist pages.'); ?>
|
||||||
</td>
|
</td>
|
||||||
|
@ -6,9 +6,8 @@ class Requests {
|
|||||||
* @param $RequestID
|
* @param $RequestID
|
||||||
*/
|
*/
|
||||||
public static function update_sphinx_requests($RequestID) {
|
public static function update_sphinx_requests($RequestID) {
|
||||||
global $DB, $Cache;
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
$DB->query("
|
|
||||||
REPLACE INTO sphinx_requests_delta (
|
REPLACE INTO sphinx_requests_delta (
|
||||||
ID, UserID, TimeAdded, LastVote, CategoryID, Title,
|
ID, UserID, TimeAdded, LastVote, CategoryID, Title,
|
||||||
Year, ReleaseType, CatalogueNumber, BitrateList,
|
Year, ReleaseType, CatalogueNumber, BitrateList,
|
||||||
@ -25,8 +24,7 @@ public static function update_sphinx_requests($RequestID) {
|
|||||||
LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
|
LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
|
||||||
WHERE ID = $RequestID
|
WHERE ID = $RequestID
|
||||||
GROUP BY r.ID");
|
GROUP BY r.ID");
|
||||||
|
G::$DB->query("
|
||||||
$DB->query("
|
|
||||||
UPDATE sphinx_requests_delta
|
UPDATE sphinx_requests_delta
|
||||||
SET ArtistList = (
|
SET ArtistList = (
|
||||||
SELECT GROUP_CONCAT(aa.Name SEPARATOR ' ')
|
SELECT GROUP_CONCAT(aa.Name SEPARATOR ' ')
|
||||||
@ -36,8 +34,9 @@ public static function update_sphinx_requests($RequestID) {
|
|||||||
GROUP BY NULL
|
GROUP BY NULL
|
||||||
)
|
)
|
||||||
WHERE ID = $RequestID");
|
WHERE ID = $RequestID");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
$Cache->delete_value("requests_$RequestID");
|
G::$Cache->delete_value("requests_$RequestID");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,14 +54,13 @@ public static function update_sphinx_requests($RequestID) {
|
|||||||
//
|
//
|
||||||
//In places where the output from this is merged with sphinx filters, it will be in a different order.
|
//In places where the output from this is merged with sphinx filters, it will be in a different order.
|
||||||
public static function get_requests($RequestIDs, $Return = true) {
|
public static function get_requests($RequestIDs, $Return = true) {
|
||||||
global $DB, $Cache;
|
|
||||||
|
|
||||||
// Try to fetch the requests from the cache first.
|
// Try to fetch the requests from the cache first.
|
||||||
$Found = array_flip($RequestIDs);
|
$Found = array_flip($RequestIDs);
|
||||||
$NotFound = array_flip($RequestIDs);
|
$NotFound = array_flip($RequestIDs);
|
||||||
|
|
||||||
foreach ($RequestIDs as $RequestID) {
|
foreach ($RequestIDs as $RequestID) {
|
||||||
$Data = $Cache->get_value("request_$RequestID");
|
$Data = G::$Cache->get_value("request_$RequestID");
|
||||||
if (!empty($Data)) {
|
if (!empty($Data)) {
|
||||||
unset($NotFound[$RequestID]);
|
unset($NotFound[$RequestID]);
|
||||||
$Found[$RequestID] = $Data;
|
$Found[$RequestID] = $Data;
|
||||||
@ -76,7 +74,9 @@ public static function get_requests($RequestIDs, $Return = true) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (count($NotFound) > 0) {
|
if (count($NotFound) > 0) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
r.ID AS ID,
|
r.ID AS ID,
|
||||||
r.UserID,
|
r.UserID,
|
||||||
@ -106,13 +106,14 @@ public static function get_requests($RequestIDs, $Return = true) {
|
|||||||
LEFT JOIN users_main AS filler ON filler.ID = FillerID AND FillerID != 0
|
LEFT JOIN users_main AS filler ON filler.ID = FillerID AND FillerID != 0
|
||||||
WHERE r.ID IN ($IDs)
|
WHERE r.ID IN ($IDs)
|
||||||
ORDER BY ID");
|
ORDER BY ID");
|
||||||
|
$Requests = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
$Requests = $DB->to_array();
|
|
||||||
foreach ($Requests as $Request) {
|
foreach ($Requests as $Request) {
|
||||||
unset($NotFound[$Request['ID']]);
|
unset($NotFound[$Request['ID']]);
|
||||||
$Request['Tags'] = self::get_tags($Request['ID']);
|
$Request['Tags'] = self::get_tags($Request['ID']);
|
||||||
$Found[$Request['ID']] = $Request;
|
$Found[$Request['ID']] = $Request;
|
||||||
$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
|
G::$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,53 +123,14 @@ public static function get_requests($RequestIDs, $Return = true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_comment_count($RequestID) {
|
|
||||||
global $Cache, $DB;
|
|
||||||
$NumComments = $Cache->get_value("request_comments_$RequestID");
|
|
||||||
if ($NumComments === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM requests_comments
|
|
||||||
WHERE RequestID = '$RequestID'");
|
|
||||||
list($NumComments) = $DB->next_record();
|
|
||||||
$Cache->cache_value("request_comments_$RequestID", $NumComments, 0);
|
|
||||||
}
|
|
||||||
return $NumComments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function get_comment_catalogue($RequestID, $CatalogueID) {
|
|
||||||
global $Cache, $DB;
|
|
||||||
$Catalogue = $Cache->get_value("request_comments_$RequestID"."_catalogue_$CatalogueID");
|
|
||||||
if ($Catalogue === false) {
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
c.ID,
|
|
||||||
c.AuthorID,
|
|
||||||
c.AddedTime,
|
|
||||||
c.Body,
|
|
||||||
c.EditedUserID,
|
|
||||||
c.EditedTime,
|
|
||||||
u.Username
|
|
||||||
FROM requests_comments as c
|
|
||||||
LEFT JOIN users_main AS u ON u.ID = c.EditedUserID
|
|
||||||
WHERE c.RequestID = '$RequestID'
|
|
||||||
ORDER BY c.ID
|
|
||||||
LIMIT $CatalogueLimit");
|
|
||||||
$Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
|
|
||||||
$Cache->cache_value("request_comments_$RequestID"."_catalogue_$CatalogueID", $Catalogue, 0);
|
|
||||||
}
|
|
||||||
return $Catalogue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function get_artists($RequestID) {
|
public static function get_artists($RequestID) {
|
||||||
global $Cache, $DB;
|
$Artists = G::$Cache->get_value("request_artists_$RequestID");
|
||||||
$Artists = $Cache->get_value("request_artists_$RequestID");
|
|
||||||
if (is_array($Artists)) {
|
if (is_array($Artists)) {
|
||||||
$Results = $Artists;
|
$Results = $Artists;
|
||||||
} else {
|
} else {
|
||||||
$Results = array();
|
$Results = array();
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
ra.ArtistID,
|
ra.ArtistID,
|
||||||
aa.Name,
|
aa.Name,
|
||||||
@ -177,20 +139,20 @@ public static function get_artists($RequestID) {
|
|||||||
JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID
|
JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID
|
||||||
WHERE ra.RequestID = $RequestID
|
WHERE ra.RequestID = $RequestID
|
||||||
ORDER BY ra.Importance ASC, aa.Name ASC;");
|
ORDER BY ra.Importance ASC, aa.Name ASC;");
|
||||||
|
$ArtistRaw = G::$DB->to_array();
|
||||||
$ArtistRaw = $DB->to_array();
|
G::$DB->set_query_id($QueryID);
|
||||||
foreach ($ArtistRaw as $ArtistRow) {
|
foreach ($ArtistRaw as $ArtistRow) {
|
||||||
list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow;
|
list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow;
|
||||||
$Results[$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName);
|
$Results[$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName);
|
||||||
}
|
}
|
||||||
$Cache->cache_value("request_artists_$RequestID", $Results);
|
G::$Cache->cache_value("request_artists_$RequestID", $Results);
|
||||||
}
|
}
|
||||||
return $Results;
|
return $Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_tags($RequestID) {
|
public static function get_tags($RequestID) {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
rt.TagID,
|
rt.TagID,
|
||||||
t.Name
|
t.Name
|
||||||
@ -198,7 +160,8 @@ public static function get_tags($RequestID) {
|
|||||||
JOIN tags AS t ON rt.TagID = t.ID
|
JOIN tags AS t ON rt.TagID = t.ID
|
||||||
WHERE rt.RequestID = $RequestID
|
WHERE rt.RequestID = $RequestID
|
||||||
ORDER BY rt.TagID ASC");
|
ORDER BY rt.TagID ASC");
|
||||||
$Tags = $DB->to_array();
|
$Tags = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
$Results = array();
|
$Results = array();
|
||||||
foreach ($Tags as $TagsRow) {
|
foreach ($Tags as $TagsRow) {
|
||||||
list($TagID, $TagName) = $TagsRow;
|
list($TagID, $TagName) = $TagsRow;
|
||||||
@ -208,11 +171,11 @@ public static function get_tags($RequestID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function get_votes_array($RequestID) {
|
public static function get_votes_array($RequestID) {
|
||||||
global $Cache, $DB;
|
|
||||||
|
|
||||||
$RequestVotes = $Cache->get_value("request_votes_$RequestID");
|
$RequestVotes = G::$Cache->get_value("request_votes_$RequestID");
|
||||||
if (!is_array($RequestVotes)) {
|
if (!is_array($RequestVotes)) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
rv.UserID,
|
rv.UserID,
|
||||||
rv.Bounty,
|
rv.Bounty,
|
||||||
@ -221,13 +184,13 @@ public static function get_votes_array($RequestID) {
|
|||||||
LEFT JOIN users_main AS u ON u.ID = rv.UserID
|
LEFT JOIN users_main AS u ON u.ID = rv.UserID
|
||||||
WHERE rv.RequestID = $RequestID
|
WHERE rv.RequestID = $RequestID
|
||||||
ORDER BY rv.Bounty DESC");
|
ORDER BY rv.Bounty DESC");
|
||||||
if (!$DB->has_results()) {
|
if (!G::$DB->has_results()) {
|
||||||
error(0);
|
error(0);
|
||||||
} else {
|
} else {
|
||||||
$Votes = $DB->to_array();
|
$Votes = G::$DB->to_array();
|
||||||
|
|
||||||
$RequestVotes = array();
|
$RequestVotes = array();
|
||||||
$RequestVotes['TotalBounty'] = array_sum($DB->collect('Bounty'));
|
$RequestVotes['TotalBounty'] = array_sum(G::$DB->collect('Bounty'));
|
||||||
|
|
||||||
foreach ($Votes as $Vote) {
|
foreach ($Votes as $Vote) {
|
||||||
list($UserID, $Bounty, $Username) = $Vote;
|
list($UserID, $Bounty, $Username) = $Vote;
|
||||||
@ -236,8 +199,9 @@ public static function get_votes_array($RequestID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$RequestVotes['Voters'] = $VotesArray;
|
$RequestVotes['Voters'] = $VotesArray;
|
||||||
$Cache->cache_value("request_votes_$RequestID", $RequestVotes);
|
G::$Cache->cache_value("request_votes_$RequestID", $RequestVotes);
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
return $RequestVotes;
|
return $RequestVotes;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,10 @@
|
|||||||
// Autoload classes.
|
// Autoload classes.
|
||||||
require(SERVER_ROOT.'/classes/classloader.php');
|
require(SERVER_ROOT.'/classes/classloader.php');
|
||||||
|
|
||||||
|
// Note: G::initialize is called twice.
|
||||||
|
// This is necessary as the code inbetween (initialization of $LoggedUser) makes use of G::$DB and G::$Cache.
|
||||||
|
// TODO: remove one of the calls once we're moving everything into that class
|
||||||
|
G::initialize();
|
||||||
|
|
||||||
//Begin browser identification
|
//Begin browser identification
|
||||||
|
|
||||||
@ -310,24 +314,24 @@
|
|||||||
* Log out the current session
|
* Log out the current session
|
||||||
*/
|
*/
|
||||||
function logout() {
|
function logout() {
|
||||||
global $SessionID, $LoggedUser, $DB, $Cache;
|
global $SessionID;
|
||||||
setcookie('session', '', time() - 60 * 60 * 24 * 365, '/', '', false);
|
setcookie('session', '', time() - 60 * 60 * 24 * 365, '/', '', false);
|
||||||
setcookie('keeplogged', '', time() - 60 * 60 * 24 * 365, '/', '', false);
|
setcookie('keeplogged', '', time() - 60 * 60 * 24 * 365, '/', '', false);
|
||||||
setcookie('session', '', time() - 60 * 60 * 24 * 365, '/', '', false);
|
setcookie('session', '', time() - 60 * 60 * 24 * 365, '/', '', false);
|
||||||
if ($SessionID) {
|
if ($SessionID) {
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM users_sessions
|
DELETE FROM users_sessions
|
||||||
WHERE UserID = '$LoggedUser[ID]'
|
WHERE UserID = '" . G::$LoggedUser['ID'] . "'
|
||||||
AND SessionID = '".db_string($SessionID)."'");
|
AND SessionID = '".db_string($SessionID)."'");
|
||||||
|
|
||||||
$Cache->begin_transaction('users_sessions_'.$LoggedUser['ID']);
|
G::$Cache->begin_transaction('users_sessions_' . G::$LoggedUser['ID']);
|
||||||
$Cache->delete_row($SessionID);
|
G::$Cache->delete_row($SessionID);
|
||||||
$Cache->commit_transaction(0);
|
G::$Cache->commit_transaction(0);
|
||||||
}
|
}
|
||||||
$Cache->delete_value('user_info_'.$LoggedUser['ID']);
|
G::$Cache->delete_value('user_info_' . G::$LoggedUser['ID']);
|
||||||
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
|
G::$Cache->delete_value('user_stats_' . G::$LoggedUser['ID']);
|
||||||
$Cache->delete_value('user_info_heavy_'.$LoggedUser['ID']);
|
G::$Cache->delete_value('user_info_heavy_' . G::$LoggedUser['ID']);
|
||||||
|
|
||||||
header('Location: login.php');
|
header('Location: login.php');
|
||||||
|
|
||||||
@ -335,8 +339,8 @@ function logout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function enforce_login() {
|
function enforce_login() {
|
||||||
global $SessionID, $LoggedUser;
|
global $SessionID;
|
||||||
if (!$SessionID || !$LoggedUser) {
|
if (!$SessionID || !G::$LoggedUser) {
|
||||||
setcookie('redirect', $_SERVER['REQUEST_URI'], time() + 60 * 30, '/', '', false);
|
setcookie('redirect', $_SERVER['REQUEST_URI'], time() + 60 * 30, '/', '', false);
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
@ -350,9 +354,8 @@ function enforce_login() {
|
|||||||
* @return authorisation status. Prints an error message to LAB_CHAN on IRC on failure.
|
* @return authorisation status. Prints an error message to LAB_CHAN on IRC on failure.
|
||||||
*/
|
*/
|
||||||
function authorize($Ajax = false) {
|
function authorize($Ajax = false) {
|
||||||
global $LoggedUser;
|
if (empty($_REQUEST['auth']) || $_REQUEST['auth'] != G::$LoggedUser['AuthKey']) {
|
||||||
if (empty($_REQUEST['auth']) || $_REQUEST['auth'] != $LoggedUser['AuthKey']) {
|
send_irc("PRIVMSG ".LAB_CHAN." :".G::$LoggedUser['Username']." just failed authorize on ".$_SERVER['REQUEST_URI']." coming from ".$_SERVER['HTTP_REFERER']);
|
||||||
send_irc("PRIVMSG ".LAB_CHAN." :".$LoggedUser['Username']." just failed authorize on ".$_SERVER['REQUEST_URI']." coming from ".$_SERVER['HTTP_REFERER']);
|
|
||||||
error('Invalid authorization key. Go back, refresh, and try again.', $Ajax);
|
error('Invalid authorization key. Go back, refresh, and try again.', $Ajax);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ function SPHINX_SEARCH() {
|
|||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
function search($Query = '', $CachePrefix = '', $CacheLength = 0, $ReturnData = array(), $SQL = '', $IDColumn = 'ID') {
|
function search($Query = '', $CachePrefix = '', $CacheLength = 0, $ReturnData = array(), $SQL = '', $IDColumn = 'ID') {
|
||||||
global $Cache, $DB;
|
|
||||||
$QueryStartTime = microtime(true);
|
$QueryStartTime = microtime(true);
|
||||||
$Result = $this->Query($Query, $this->Index);
|
$Result = $this->Query($Query, $this->Index);
|
||||||
$QueryEndTime = microtime(true);
|
$QueryEndTime = microtime(true);
|
||||||
@ -61,9 +60,9 @@ function search($Query = '', $CachePrefix = '', $CacheLength = 0, $ReturnData =
|
|||||||
$this->Time += ($QueryEndTime - $QueryStartTime) * 1000;
|
$this->Time += ($QueryEndTime - $QueryStartTime) * 1000;
|
||||||
|
|
||||||
if ($Result === false) {
|
if ($Result === false) {
|
||||||
if ($this->_connerror && !$Cache->get_value('sphinx_crash_reported')) {
|
if ($this->_connerror && !G::$Cache->get_value('sphinx_crash_reported')) {
|
||||||
send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed');
|
send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed');
|
||||||
$Cache->cache_value('sphinx_crash_reported', 1, 3600);
|
G::$Cache->cache_value('sphinx_crash_reported', 1, 3600);
|
||||||
}
|
}
|
||||||
send_irc('PRIVMSG '.LAB_CHAN." :Search for \"$Query\" (".str_replace("\n", '', print_r($this->Filters, true)).') failed: '.$this->GetLastError());
|
send_irc('PRIVMSG '.LAB_CHAN." :Search for \"$Query\" (".str_replace("\n", '', print_r($this->Filters, true)).') failed: '.$this->GetLastError());
|
||||||
}
|
}
|
||||||
@ -89,7 +88,7 @@ function search($Query = '', $CachePrefix = '', $CacheLength = 0, $ReturnData =
|
|||||||
foreach ($MatchIDs as $Match) {
|
foreach ($MatchIDs as $Match) {
|
||||||
$Matches[$Match] = $Matches[$Match]['attrs'];
|
$Matches[$Match] = $Matches[$Match]['attrs'];
|
||||||
if (!empty($CachePrefix)) {
|
if (!empty($CachePrefix)) {
|
||||||
$Data = $Cache->get_value($CachePrefix."_$Match");
|
$Data = G::$Cache->get_value($CachePrefix."_$Match");
|
||||||
if ($Data == false) {
|
if ($Data == false) {
|
||||||
$NotFound[] = $Match;
|
$NotFound[] = $Match;
|
||||||
continue;
|
continue;
|
||||||
@ -121,11 +120,13 @@ function search($Query = '', $CachePrefix = '', $CacheLength = 0, $ReturnData =
|
|||||||
|
|
||||||
if ($SQL != '') {
|
if ($SQL != '') {
|
||||||
if (!empty($NotFound)) {
|
if (!empty($NotFound)) {
|
||||||
$DB->query(str_replace('%ids', implode(',', $NotFound), $SQL));
|
$QueryID = G::$DB->get_query_id();
|
||||||
while ($Data = $DB->next_record(MYSQLI_ASSOC)) {
|
G::$DB->query(str_replace('%ids', implode(',', $NotFound), $SQL));
|
||||||
|
while ($Data = G::$DB->next_record(MYSQLI_ASSOC)) {
|
||||||
$Matches[$Data[$IDColumn]] = array_merge($Matches[$Data[$IDColumn]], $Data);
|
$Matches[$Data[$IDColumn]] = array_merge($Matches[$Data[$IDColumn]], $Data);
|
||||||
$Cache->cache_value($CachePrefix.'_'.$Data[$IDColumn], $Data, $CacheLength);
|
G::$Cache->cache_value($CachePrefix.'_'.$Data[$IDColumn], $Data, $CacheLength);
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$Matches = array('matches' => $Matches, 'notfound' => $NotFound);
|
$Matches = array('matches' => $Matches, 'notfound' => $NotFound);
|
||||||
|
@ -67,12 +67,14 @@ class SiteHistory {
|
|||||||
public static function get_months() {
|
public static function get_months() {
|
||||||
$Results = G::$Cache->get_value("site_history_months");
|
$Results = G::$Cache->get_value("site_history_months");
|
||||||
if (!$Results) {
|
if (!$Results) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("
|
G::$DB->query("
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
YEAR(DATE) AS Year, MONTH(Date) AS Month, MONTHNAME(Date) AS MonthName
|
YEAR(DATE) AS Year, MONTH(Date) AS Month, MONTHNAME(Date) AS MonthName
|
||||||
FROM site_history
|
FROM site_history
|
||||||
ORDER BY Date DESC");
|
ORDER BY Date DESC");
|
||||||
$Results = G::$DB->to_array();
|
$Results = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
G::$Cache->cache_value("site_history_months", $Results, 0);
|
G::$Cache->cache_value("site_history_months", $Results, 0);
|
||||||
}
|
}
|
||||||
return $Results;
|
return $Results;
|
||||||
@ -80,13 +82,16 @@ public static function get_months() {
|
|||||||
|
|
||||||
public static function get_event($ID) {
|
public static function get_event($ID) {
|
||||||
if (!empty($ID)) {
|
if (!empty($ID)) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
ID, Title, Url, Category, SubCategory, Tags, Body, AddedBy, Date
|
ID, Title, Url, Category, SubCategory, Tags, Body, AddedBy, Date
|
||||||
FROM site_history
|
FROM site_history
|
||||||
WHERE ID = '$ID'
|
WHERE ID = '$ID'
|
||||||
ORDER BY Date DESC");
|
ORDER BY Date DESC");
|
||||||
return G::$DB->next_record();
|
$Event = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,29 +124,30 @@ public static function get_events($Month, $Year, $Title, $Category, $SubCategory
|
|||||||
$Where[] = " SubCategory = '$SubCategory '";
|
$Where[] = " SubCategory = '$SubCategory '";
|
||||||
}
|
}
|
||||||
if (!empty($Tags)) {
|
if (!empty($Tags)) {
|
||||||
$Tags = explode(",", $Tags);
|
$Tags = explode(',', $Tags);
|
||||||
$Or = "(";
|
$Or = '(';
|
||||||
foreach ($Tags as $Tag) {
|
foreach ($Tags as $Tag) {
|
||||||
$Tag = trim($Tag);
|
$Tag = trim($Tag);
|
||||||
$Or .= " Tags LIKE '%$Tag%' OR ";
|
$Or .= " Tags LIKE '%$Tag%' OR ";
|
||||||
}
|
}
|
||||||
if (strlen($Or) > 1) {
|
if (strlen($Or) > 1) {
|
||||||
$Or = rtrim($Or, "OR ");
|
$Or = rtrim($Or, 'OR ');
|
||||||
$Or .= ")";
|
$Or .= ')';
|
||||||
$Where[] = $Or;
|
$Where[] = $Or;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($Limit)) {
|
if (!empty($Limit)) {
|
||||||
$Limit = " LIMIT $Limit";
|
$Limit = " LIMIT $Limit";
|
||||||
} else {
|
} else {
|
||||||
$Limit = "";
|
$Limit = '';
|
||||||
}
|
}
|
||||||
if (count($Where) > 0) {
|
if (count($Where) > 0) {
|
||||||
$Query = " WHERE " . implode("AND", $Where);
|
$Query = ' WHERE ' . implode('AND', $Where);
|
||||||
} else {
|
} else {
|
||||||
$Query = "";
|
$Query = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
ID, Title, Url, Category, SubCategory, Tags, Body, AddedBy, Date
|
ID, Title, Url, Category, SubCategory, Tags, Body, AddedBy, Date
|
||||||
@ -149,7 +155,9 @@ public static function get_events($Month, $Year, $Title, $Category, $SubCategory
|
|||||||
$Query
|
$Query
|
||||||
ORDER BY Date DESC
|
ORDER BY Date DESC
|
||||||
$Limit");
|
$Limit");
|
||||||
return G::$DB->to_array();
|
$Events = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $Events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function add_event($Date, $Title, $Link, $Category, $SubCategory, $Tags, $Body, $UserID) {
|
public static function add_event($Date, $Title, $Link, $Category, $SubCategory, $Tags, $Body, $UserID) {
|
||||||
@ -166,7 +174,7 @@ public static function add_event($Date, $Title, $Link, $Category, $SubCategory,
|
|||||||
$Category = (int)$Category;
|
$Category = (int)$Category;
|
||||||
$SubCategory = (int)$SubCategory;
|
$SubCategory = (int)$SubCategory;
|
||||||
$Tags = db_string(strtolower((preg_replace('/\s+/', '', $Tags))));
|
$Tags = db_string(strtolower((preg_replace('/\s+/', '', $Tags))));
|
||||||
$ExplodedTags = explode(",", $Tags);
|
$ExplodedTags = explode(',', $Tags);
|
||||||
foreach ($ExplodedTags as $Tag) {
|
foreach ($ExplodedTags as $Tag) {
|
||||||
if (!in_array($Tag, self::get_tags())) {
|
if (!in_array($Tag, self::get_tags())) {
|
||||||
error("Invalid tag");
|
error("Invalid tag");
|
||||||
@ -179,11 +187,13 @@ public static function add_event($Date, $Title, $Link, $Category, $SubCategory,
|
|||||||
error("Error");
|
error("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO site_history
|
INSERT INTO site_history
|
||||||
(Title, Url, Category, SubCategory, Tags, Body, AddedBy, Date)
|
(Title, Url, Category, SubCategory, Tags, Body, AddedBy, Date)
|
||||||
VALUES
|
VALUES
|
||||||
('$Title', '$Link', '$Category', '$SubCategory', '$Tags', '$Body', '$UserID', '$Date')");
|
('$Title', '$Link', '$Category', '$SubCategory', '$Tags', '$Body', '$UserID', '$Date')");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
G::$Cache->delete_value("site_history_months");
|
G::$Cache->delete_value("site_history_months");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +226,7 @@ public static function update_event($ID, $Date, $Title, $Link, $Category, $SubCa
|
|||||||
error("Error");
|
error("Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("
|
G::$DB->query("
|
||||||
UPDATE site_history
|
UPDATE site_history
|
||||||
SET
|
SET
|
||||||
@ -229,6 +240,7 @@ public static function update_event($ID, $Date, $Title, $Link, $Category, $SubCa
|
|||||||
Date = '$Date'
|
Date = '$Date'
|
||||||
WHERE
|
WHERE
|
||||||
ID = '$ID'");
|
ID = '$ID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
G::$Cache->delete_value("site_history_months");
|
G::$Cache->delete_value("site_history_months");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +248,9 @@ public static function delete_event($ID) {
|
|||||||
if (empty($ID)) {
|
if (empty($ID)) {
|
||||||
error(404);
|
error(404);
|
||||||
}
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("DELETE FROM site_history WHERE ID = '$ID'");
|
G::$DB->query("DELETE FROM site_history WHERE ID = '$ID'");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
G::$Cache->delete_value("site_history_months");
|
G::$Cache->delete_value("site_history_months");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public static function render_events($Events) {
|
|||||||
private static function render_tags($Tags) {
|
private static function render_tags($Tags) {
|
||||||
$Tags = explode(',', $Tags);
|
$Tags = explode(',', $Tags);
|
||||||
natcasesort($Tags);
|
natcasesort($Tags);
|
||||||
$FormattedTags = "";
|
$FormattedTags = '';
|
||||||
foreach ($Tags as $Tag) {
|
foreach ($Tags as $Tag) {
|
||||||
$FormattedTags .= "<a href='sitehistory.php?action=search&tags=". $Tag . "'>" . $Tag . "</a>, ";
|
$FormattedTags .= "<a href='sitehistory.php?action=search&tags=". $Tag . "'>" . $Tag . "</a>, ";
|
||||||
}
|
}
|
||||||
|
334
classes/subscriptions.class.php
Normal file
334
classes/subscriptions.class.php
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
<?
|
||||||
|
class Subscriptions {
|
||||||
|
/**
|
||||||
|
* Parse a post/comment body for quotes and notify all quoted users that have quote notifications enabled.
|
||||||
|
* @param string $Body
|
||||||
|
* @param int $PostID
|
||||||
|
* @param string $Page
|
||||||
|
* @param int $PageID
|
||||||
|
*/
|
||||||
|
public static function quote_notify($Body, $PostID, $Page, $PageID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
/*
|
||||||
|
* Explanation of the parameters PageID and Page: Page contains where
|
||||||
|
* this quote comes from and can be forums, artist, collages, requests
|
||||||
|
* or torrents. The PageID contains the additional value that is
|
||||||
|
* necessary for the users_notify_quoted table. The PageIDs for the
|
||||||
|
* different Page are: forums: TopicID artist: ArtistID collages:
|
||||||
|
* CollageID requests: RequestID torrents: GroupID
|
||||||
|
*/
|
||||||
|
$Matches = array();
|
||||||
|
preg_match_all('/\[quote(?:=(.*)(?:\|.*)?)?]|\[\/quote]/iU', $Body, $Matches, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
if (count($Matches)) {
|
||||||
|
$Usernames = array();
|
||||||
|
$Level = 0;
|
||||||
|
foreach ($Matches as $M) {
|
||||||
|
if ($M[0] != '[/quote]') {
|
||||||
|
if ($Level == 0 && isset($M[1]) && strlen($M[1]) > 0 && preg_match(USERNAME_REGEX, $M[1])) {
|
||||||
|
$Usernames[] = preg_replace('/(^[.,]*)|([.,]*$)/', '', $M[1]); // wut?
|
||||||
|
}
|
||||||
|
++$Level;
|
||||||
|
} else {
|
||||||
|
--$Level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// remove any dupes in the array (the fast way)
|
||||||
|
$Usernames = array_flip(array_flip($Usernames));
|
||||||
|
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT m.ID
|
||||||
|
FROM users_main AS m
|
||||||
|
LEFT JOIN users_info AS i ON i.UserID = m.ID
|
||||||
|
WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
|
||||||
|
AND i.NotifyOnQuote = '1'
|
||||||
|
AND i.UserID != " . G::$LoggedUser['ID']);
|
||||||
|
|
||||||
|
|
||||||
|
$Results = G::$DB->to_array();
|
||||||
|
foreach ($Results as $Result) {
|
||||||
|
$UserID = db_string($Result['ID']);
|
||||||
|
$QuoterID = db_string(G::$LoggedUser['ID']);
|
||||||
|
$Page = db_string($Page);
|
||||||
|
$PageID = db_string($PageID);
|
||||||
|
$PostID = db_string($PostID);
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
|
INSERT IGNORE INTO users_notify_quoted
|
||||||
|
(UserID, QuoterID, Page, PageID, PostID, Date)
|
||||||
|
VALUES
|
||||||
|
('$UserID', '$QuoterID', '$Page', '$PageID', '$PostID', '" . sqltime() . "')");
|
||||||
|
G::$Cache->delete_value('notify_quoted_' . $UserID);
|
||||||
|
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Un)subscribe from a forum thread.
|
||||||
|
* If UserID == 0, G::$LoggedUser[ID] is used
|
||||||
|
* @param int $TopicID
|
||||||
|
* @param int $UserID
|
||||||
|
*/
|
||||||
|
public static function subscribe($TopicID, $UserID = 0) {
|
||||||
|
if ($UserID == 0) {
|
||||||
|
$UserID = G::$LoggedUser['ID'];
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
$UserSubscriptions = self::get_subscriptions();
|
||||||
|
$Key = self::has_subscribed($TopicID);
|
||||||
|
if ($Key !== false) {
|
||||||
|
G::$DB->query('DELETE FROM users_subscriptions WHERE UserID = ' . db_string($UserID) . ' AND TopicID = ' . db_string($TopicID));
|
||||||
|
unset($UserSubscriptions[$Key]);
|
||||||
|
} else {
|
||||||
|
G::$DB->query("INSERT IGNORE INTO users_subscriptions (UserID, TopicID) VALUES ($UserID, " . db_string($TopicID) . ")");
|
||||||
|
array_push($UserSubscriptions, $TopicID);
|
||||||
|
}
|
||||||
|
G::$Cache->replace_value('subscriptions_user_' . $UserID, $UserSubscriptions, 0);
|
||||||
|
G::$Cache->delete_value('subscriptions_user_new_' . $UserID);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Un)subscribe from comments.
|
||||||
|
* If UserID == 0, G::$LoggedUser[ID] is used
|
||||||
|
* @param string $Page 'artist', 'collages', 'requests' or 'torrents'
|
||||||
|
* @param int $PageID ArtistID, CollageID, RequestID or GroupID
|
||||||
|
* @param int $UserID
|
||||||
|
*/
|
||||||
|
public static function subscribe_comments($Page, $PageID, $UserID = 0) {
|
||||||
|
if ($UserID == 0) {
|
||||||
|
$UserID = G::$LoggedUser['ID'];
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
$UserCommentSubscriptions = self::get_comment_subscriptions();
|
||||||
|
$Key = self::has_subscribed_comments($Page, $PageID);
|
||||||
|
if ($Key !== false) {
|
||||||
|
G::$DB->query("DELETE FROM users_subscriptions_comments WHERE UserID = " . db_string($UserID) . " AND Page = '" . db_string($Page) . "' AND PageID = " . db_string($PageID));
|
||||||
|
unset($UserCommentSubscriptions[$Key]);
|
||||||
|
} else {
|
||||||
|
G::$DB->query("INSERT IGNORE INTO users_subscriptions_comments (UserID, Page, PageID) VALUES ($UserID, '" . db_string($Page) . "', " . db_string($PageID) . ")");
|
||||||
|
array_push($UserCommentSubscriptions, array($Page, $PageID));
|
||||||
|
}
|
||||||
|
G::$Cache->replace_value('subscriptions_comments_user_' . $UserID, $UserCommentSubscriptions, 0);
|
||||||
|
G::$Cache->delete_value('subscriptions_comments_user_new_' . $UserID);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read $UserID's subscriptions. If the cache key isn't set, it gets filled.
|
||||||
|
* If UserID == 0, G::$LoggedUser[ID] is used
|
||||||
|
* @param int $UserID
|
||||||
|
* @return array Array of TopicIDs
|
||||||
|
*/
|
||||||
|
public static function get_subscriptions($UserID = 0) {
|
||||||
|
if ($UserID == 0) {
|
||||||
|
$UserID = G::$LoggedUser['ID'];
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
$UserSubscriptions = G::$Cache->get_value('subscriptions_user_' . $UserID);
|
||||||
|
if ($UserSubscriptions === false) {
|
||||||
|
G::$DB->query('SELECT TopicID FROM users_subscriptions WHERE UserID = ' . db_string($UserID));
|
||||||
|
$UserSubscriptions = G::$DB->collect(0);
|
||||||
|
G::$Cache->cache_value('subscriptions_user_' . $UserID, $UserSubscriptions, 0);
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $UserSubscriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as self::get_subscriptions, but for comment subscriptions
|
||||||
|
* @param int $UserID
|
||||||
|
* @return array Array of ($Page, $PageID)
|
||||||
|
*/
|
||||||
|
public static function get_comment_subscriptions($UserID = 0) {
|
||||||
|
if ($UserID == 0) {
|
||||||
|
$UserID = G::$LoggedUser['ID'];
|
||||||
|
}
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
$UserCommentSubscriptions = G::$Cache->get_value('subscriptions_comments_user_' . $UserID);
|
||||||
|
if ($UserCommentSubscriptions === false) {
|
||||||
|
G::$DB->query('SELECT Page, PageID FROM users_subscriptions_comments WHERE UserID = ' . db_string($UserID));
|
||||||
|
$UserCommentSubscriptions = G::$DB->to_array(false, MYSQLI_NUM);
|
||||||
|
G::$Cache->cache_value('subscriptions_comments_user_' . $UserID, $UserCommentSubscriptions, 0);
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return $UserCommentSubscriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the current user has new subscriptions. This handles both forum and comment subscriptions.
|
||||||
|
* @return int Number of unread subscribed threads/comments
|
||||||
|
*/
|
||||||
|
public static function has_new_subscriptions() {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
|
$NewSubscriptions = G::$Cache->get_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
|
||||||
|
if ($NewSubscriptions === false) {
|
||||||
|
// forum subscriptions
|
||||||
|
G::$DB->query("SELECT COUNT(1)
|
||||||
|
FROM users_subscriptions AS s
|
||||||
|
LEFT JOIN forums_last_read_topics AS l ON l.UserID = s.UserID AND l.TopicID = s.TopicID
|
||||||
|
JOIN forums_topics AS t ON t.ID = s.TopicID
|
||||||
|
JOIN forums AS f ON f.ID = t.ForumID
|
||||||
|
WHERE " . Forums::user_forums_sql() . "
|
||||||
|
AND IF(t.IsLocked = '1' AND t.IsSticky = '0'" . ", t.LastPostID, IF(l.PostID IS NULL, 0, l.PostID)) < t.LastPostID
|
||||||
|
AND s.UserID = " . G::$LoggedUser['ID']);
|
||||||
|
list($NewForumSubscriptions) = G::$DB->next_record();
|
||||||
|
|
||||||
|
// comment subscriptions
|
||||||
|
G::$DB->query("SELECT COUNT(1)
|
||||||
|
FROM users_subscriptions_comments AS s
|
||||||
|
LEFT JOIN users_comments_last_read AS lr ON lr.UserID = s.UserID AND lr.Page = s.Page AND lr.PageID = s.PageID
|
||||||
|
LEFT JOIN comments AS c ON c.ID = (SELECT MAX(ID) FROM comments WHERE Page = s.Page AND PageID = s.PageID)
|
||||||
|
LEFT JOIN collages AS co ON s.Page = 'collages' AND co.ID = s.PageID
|
||||||
|
WHERE s.UserID = " . G::$LoggedUser['ID'] . "
|
||||||
|
AND (s.Page != 'collages' OR co.Deleted = '0')
|
||||||
|
AND IF(lr.PostID IS NULL, 0, lr.PostID) < c.ID");
|
||||||
|
list($NewCommentSubscriptions) = G::$DB->next_record();
|
||||||
|
|
||||||
|
$NewSubscriptions = $NewForumSubscriptions + $NewCommentSubscriptions;
|
||||||
|
G::$Cache->cache_value('subscriptions_user_new_' . G::$LoggedUser['ID'], $NewSubscriptions, 0);
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
return (int)$NewSubscriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the current user has new quote notifications.
|
||||||
|
* @return int Number of unread quote notifications
|
||||||
|
*/
|
||||||
|
public static function has_new_quote_notifications() {
|
||||||
|
$QuoteNotificationsCount = G::$Cache->get_value('notify_quoted_' . G::$LoggedUser['ID']);
|
||||||
|
if ($QuoteNotificationsCount === false) {
|
||||||
|
$sql = "
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM users_notify_quoted AS q
|
||||||
|
LEFT JOIN forums_topics AS t ON t.ID = q.PageID
|
||||||
|
LEFT JOIN forums AS f ON f.ID = t.ForumID
|
||||||
|
LEFT JOIN collages AS c ON q.Page = 'collages' AND c.ID = q.PageID
|
||||||
|
WHERE q.UserID = " . G::$LoggedUser['ID'] . "
|
||||||
|
AND q.UnRead
|
||||||
|
AND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")
|
||||||
|
AND (q.Page != 'collages' OR c.Deleted = '0')";
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query($sql);
|
||||||
|
list($QuoteNotificationsCount) = G::$DB->next_record();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('notify_quoted_' . G::$LoggedUser['ID'], $QuoteNotificationsCount, 0);
|
||||||
|
}
|
||||||
|
return (int)$QuoteNotificationsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the key which holds this $TopicID in the subscription array.
|
||||||
|
* Use type-aware comparison operators with this! (ie. if (self::has_subscribed($TopicID) !== false) { ... })
|
||||||
|
* @param int $TopicID
|
||||||
|
* @return bool|int
|
||||||
|
*/
|
||||||
|
public static function has_subscribed($TopicID) {
|
||||||
|
$UserSubscriptions = self::get_subscriptions();
|
||||||
|
return array_search($TopicID, $UserSubscriptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as has_subscribed, but for comment subscriptions.
|
||||||
|
* @param string $Page 'artist', 'collages', 'requests' or 'torrents'
|
||||||
|
* @param int $PageID
|
||||||
|
* @return bool|int
|
||||||
|
*/
|
||||||
|
public static function has_subscribed_comments($Page, $PageID) {
|
||||||
|
$UserCommentSubscriptions = self::get_comment_subscriptions();
|
||||||
|
return array_search(array($Page, $PageID), $UserCommentSubscriptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the subscription cache for all subscribers of a forum thread or artist/collage/request/torrent comments.
|
||||||
|
* @param type $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
|
||||||
|
* @param type $PageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
|
||||||
|
*/
|
||||||
|
public static function flush_subscriptions($Page, $PageID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
if ($Page == 'forums') {
|
||||||
|
G::$DB->query("SELECT UserID FROM users_subscriptions WHERE TopicID = '$PageID'");
|
||||||
|
} else {
|
||||||
|
G::$DB->query("SELECT UserID FROM users_subscriptions_comments WHERE Page = '$Page' AND PageID = '$PageID'");
|
||||||
|
}
|
||||||
|
$Subscribers = G::$DB->collect('UserID');
|
||||||
|
foreach($Subscribers as $Subscriber) {
|
||||||
|
G::$Cache->delete_value('subscriptions_user_new_'.$Subscriber);
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move all $Page subscriptions from $OldPageID to $NewPageID (for example when merging torrent groups).
|
||||||
|
* Passing $NewPageID = null will delete the subscriptions.
|
||||||
|
* @param string $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
|
||||||
|
* @param int $OldPageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
|
||||||
|
* @param int|null $NewPageID As $OldPageID, or null to delete the subscriptions
|
||||||
|
*/
|
||||||
|
public static function move_subscriptions($Page, $OldPageID, $NewPageID) {
|
||||||
|
self::flush_subscriptions($Page, $OldPageID);
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
if ($Page == 'forums') {
|
||||||
|
if ($NewPageID !== null) {
|
||||||
|
G::$DB->query("UPDATE IGNORE users_subscriptions SET TopicID = '$NewPageID' WHERE TopicID = '$OldPageID'");
|
||||||
|
// explanation see below
|
||||||
|
G::$DB->query("UPDATE IGNORE forums_last_read_topics SET TopicID = $NewPageID WHERE TopicID = $OldPageID");
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT UserID, MIN(PostID)
|
||||||
|
FROM forums_last_read_topics
|
||||||
|
WHERE TopicID IN ($OldPageID, $NewPageID)
|
||||||
|
GROUP BY UserID
|
||||||
|
HAVING COUNT(1) = 2");
|
||||||
|
$Results = G::$DB->to_array(false, MYSQLI_NUM);
|
||||||
|
foreach ($Results as $Result) {
|
||||||
|
G::$DB->query("UPDATE forums_last_read_topics SET PostID = $Result[1] WHERE TopicID = $NewPageID AND UserID = $Result[0]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
G::$DB->query("DELETE FROM users_subscriptions WHERE TopicID = '$OldPageID'");
|
||||||
|
G::$DB->query("DELETE FROM forums_last_read_topics WHERE TopicID = $OldPageID");
|
||||||
|
} else {
|
||||||
|
if($NewPageID !== null) {
|
||||||
|
G::$DB->query("UPDATE IGNORE users_subscriptions_comments SET PageID = '$NewPageID' WHERE Page = '$Page' AND PageID = '$OldPageID'");
|
||||||
|
// last read handling
|
||||||
|
// 1) update all rows that have no key collisions (i.e. users that haven't previously read both pages or if there are only comments on one page)
|
||||||
|
G::$DB->query("UPDATE IGNORE users_comments_last_read SET PageID = '$NewPageID' WHERE Page = '$Page' AND PageID = $OldPageID");
|
||||||
|
// 2) get all last read records with key collisions (i.e. there are records for one user for both PageIDs)
|
||||||
|
G::$DB->query("
|
||||||
|
SELECT UserID, MIN(PostID)
|
||||||
|
FROM users_comments_last_read
|
||||||
|
WHERE Page = '$Page'
|
||||||
|
AND PageID IN ($OldPageID, $NewPageID)
|
||||||
|
GROUP BY UserID
|
||||||
|
HAVING COUNT(1) = 2");
|
||||||
|
$Results = G::$DB->to_array(false, MYSQLI_NUM);
|
||||||
|
// 3) update rows for those people found in 2) to the earlier post
|
||||||
|
foreach ($Results as $Result) {
|
||||||
|
G::$DB->query("UPDATE users_comments_last_read SET PostID = $Result[1] WHERE Page = '$Page' AND PageID = $NewPageID AND UserID = $Result[0]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
G::$DB->query("DELETE FROM users_subscriptions_comments WHERE Page = '$Page' AND PageID = '$OldPageID'");
|
||||||
|
G::$DB->query("DELETE FROM users_comments_last_read WHERE Page = '$Page' AND PageID = '$OldPageID'");
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the quote notification cache for all subscribers of a forum thread or artist/collage/request/torrent comments.
|
||||||
|
* @param string $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
|
||||||
|
* @param int $PageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
|
||||||
|
*/
|
||||||
|
public static function flush_quote_notifications($Page, $PageID) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("SELECT UserID FROM users_notify_quoted WHERE Page = '$Page' AND PageID = $PageID");
|
||||||
|
$Subscribers = G::$DB->collect('UserID');
|
||||||
|
foreach($Subscribers as $Subscriber) {
|
||||||
|
G::$Cache->delete_value('notify_quoted_'.$Subscriber);
|
||||||
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
}
|
||||||
|
}
|
@ -727,9 +727,10 @@ private function to_html ($Array) {
|
|||||||
}
|
}
|
||||||
if (!empty($Block['Attr'])) {
|
if (!empty($Block['Attr'])) {
|
||||||
$Exploded = explode('|', $this->to_html($Block['Attr']));
|
$Exploded = explode('|', $this->to_html($Block['Attr']));
|
||||||
if (isset($Exploded[1]) && is_numeric($Exploded[1])) {
|
if (isset($Exploded[1]) && (is_numeric($Exploded[1]) || (in_array($Exploded[1][0], array('a', 't', 'c', 'r')) && is_numeric(substr($Exploded[1], 1))))) {
|
||||||
|
// the part after | is either a number or starts with a, t, c or r, followed by a number (forum post, artist comment, torrent comment, collage comment or request comment, respectively)
|
||||||
$PostID = trim($Exploded[1]);
|
$PostID = trim($Exploded[1]);
|
||||||
$Str .= '<a href="forums.php?action=viewthread&postid='.$PostID.'" onclick="QuoteJump(event, '.$PostID.'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
|
$Str .= '<a href="#" onclick="QuoteJump(event, \''.$PostID.'\'); return false;"><strong class="quoteheader">'.$Exploded[0].'</strong> wrote: </a>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Str .= '<strong class="quoteheader">'.$Exploded[0].'</strong> wrote: ';
|
$Str .= '<strong class="quoteheader">'.$Exploded[0].'</strong> wrote: ';
|
||||||
@ -747,8 +748,7 @@ private function to_html ($Array) {
|
|||||||
$Str .= '<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
|
$Str .= '<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
|
||||||
break;
|
break;
|
||||||
case 'mature':
|
case 'mature':
|
||||||
global $LoggedUser;
|
if (G::$LoggedUser['EnableMatureContent']) {
|
||||||
if ($LoggedUser['EnableMatureContent']) {
|
|
||||||
if (!empty($Block['Attr'])) {
|
if (!empty($Block['Attr'])) {
|
||||||
$Str .= '<strong class="mature" style="font-size: 1.2em;">Mature content:</strong><strong> ' . $Block['Attr'] . '</strong><br /> <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
|
$Str .= '<strong class="mature" style="font-size: 1.2em;">Mature content:</strong><strong> ' . $Block['Attr'] . '</strong><br /> <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
|
||||||
$Str .= '<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
|
$Str .= '<blockquote class="hidden spoiler">'.$this->to_html($Block['Val']).'</blockquote>';
|
||||||
@ -758,7 +758,7 @@ private function to_html ($Array) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Str .= '<span class="mature_blocked" style="font-style: italic;"><a href="wiki.php?action=article&id=1063">Mature content</a> has been blocked. You can choose to view mature content by editing your <a href="user.php?action=edit&userid=' . $LoggedUser['ID'] . '">settings</a>.</span>';
|
$Str .= '<span class="mature_blocked" style="font-style: italic;"><a href="wiki.php?action=article&id=1063">Mature content</a> has been blocked. You can choose to view mature content by editing your <a href="user.php?action=edit&userid=' . G::$LoggedUser['ID'] . '">settings</a>.</span>';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'img':
|
case 'img':
|
||||||
@ -905,8 +905,7 @@ private function raw_text ($Array) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function smileys ($Str) {
|
private function smileys ($Str) {
|
||||||
global $LoggedUser;
|
if (!empty(G::$LoggedUser['DisableSmileys'])) {
|
||||||
if (!empty($LoggedUser['DisableSmileys'])) {
|
|
||||||
return $Str;
|
return $Str;
|
||||||
}
|
}
|
||||||
$Str = strtr($Str, $this->Smileys);
|
$Str = strtr($Str, $this->Smileys);
|
||||||
|
@ -62,9 +62,9 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
|
|
||||||
if ($Years > 0 && $Levels > 0) {
|
if ($Years > 0 && $Levels > 0) {
|
||||||
if ($Years > 1) {
|
if ($Years > 1) {
|
||||||
$Return .= $Years.' years';
|
$Return .= "$Years years";
|
||||||
} else {
|
} else {
|
||||||
$Return .= $Years.' year';
|
$Return .= "$Years year";
|
||||||
}
|
}
|
||||||
$Levels--;
|
$Levels--;
|
||||||
}
|
}
|
||||||
@ -74,9 +74,9 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
$Return .= ', ';
|
$Return .= ', ';
|
||||||
}
|
}
|
||||||
if ($Months > 1) {
|
if ($Months > 1) {
|
||||||
$Return.=$Months.' months';
|
$Return .= "$Months months";
|
||||||
} else {
|
} else {
|
||||||
$Return.=$Months.' month';
|
$Return .= "$Months month";
|
||||||
}
|
}
|
||||||
$Levels--;
|
$Levels--;
|
||||||
}
|
}
|
||||||
@ -86,9 +86,9 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
$Return .= ', ';
|
$Return .= ', ';
|
||||||
}
|
}
|
||||||
if ($Weeks > 1) {
|
if ($Weeks > 1) {
|
||||||
$Return.=$Weeks.' weeks';
|
$Return .= "$Weeks weeks";
|
||||||
} else {
|
} else {
|
||||||
$Return.=$Weeks.' week';
|
$Return .= "$Weeks week";
|
||||||
}
|
}
|
||||||
$Levels--;
|
$Levels--;
|
||||||
}
|
}
|
||||||
@ -98,9 +98,9 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
$Return .= ', ';
|
$Return .= ', ';
|
||||||
}
|
}
|
||||||
if ($Days > 1) {
|
if ($Days > 1) {
|
||||||
$Return.=$Days.' days';
|
$Return .= "$Days days";
|
||||||
} else {
|
} else {
|
||||||
$Return.=$Days.' day';
|
$Return .= "$Days day";
|
||||||
}
|
}
|
||||||
$Levels--;
|
$Levels--;
|
||||||
}
|
}
|
||||||
@ -110,9 +110,9 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
$Return .= ', ';
|
$Return .= ', ';
|
||||||
}
|
}
|
||||||
if ($Hours > 1) {
|
if ($Hours > 1) {
|
||||||
$Return.=$Hours.' hours';
|
$Return .= "$Hours hours";
|
||||||
} else {
|
} else {
|
||||||
$Return.=$Hours.' hour';
|
$Return .= "$Hours hour";
|
||||||
}
|
}
|
||||||
$Levels--;
|
$Levels--;
|
||||||
}
|
}
|
||||||
@ -122,9 +122,9 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
$Return .= ' and ';
|
$Return .= ' and ';
|
||||||
}
|
}
|
||||||
if ($Minutes > 1) {
|
if ($Minutes > 1) {
|
||||||
$Return.=$Minutes.' mins';
|
$Return .= "$Minutes mins";
|
||||||
} else {
|
} else {
|
||||||
$Return.=$Minutes.' min';
|
$Return .= "$Minutes min";
|
||||||
}
|
}
|
||||||
$Levels--;
|
$Levels--;
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Span) {
|
if ($Span) {
|
||||||
return '<span class="time" title="'.date('M d Y, H:i', $TimeStamp).'">'.$Return.'</span>';
|
return '<span class="time tooltip" title="'.date('M d Y, H:i', $TimeStamp).'">'.$Return.'</span>';
|
||||||
} else {
|
} else {
|
||||||
return $Return;
|
return $Return;
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,20 @@ class Tools {
|
|||||||
* @param string $IP
|
* @param string $IP
|
||||||
*/
|
*/
|
||||||
public static function site_ban_ip($IP) {
|
public static function site_ban_ip($IP) {
|
||||||
global $DB, $Cache, $Debug;
|
global $Debug;
|
||||||
$A = substr($IP, 0, strcspn($IP, '.'));
|
$A = substr($IP, 0, strcspn($IP, '.'));
|
||||||
$IPNum = Tools::ip_to_unsigned($IP);
|
$IPNum = Tools::ip_to_unsigned($IP);
|
||||||
$IPBans = $Cache->get_value('ip_bans_'.$A);
|
$IPBans = G::$Cache->get_value('ip_bans_'.$A);
|
||||||
if (!is_array($IPBans)) {
|
if (!is_array($IPBans)) {
|
||||||
$SQL = sprintf("
|
$SQL = sprintf("
|
||||||
SELECT ID, FromIP, ToIP
|
SELECT ID, FromIP, ToIP
|
||||||
FROM ip_bans
|
FROM ip_bans
|
||||||
WHERE FromIP BETWEEN %d << 24 AND (%d << 24) - 1", $A, $A + 1);
|
WHERE FromIP BETWEEN %d << 24 AND (%d << 24) - 1", $A, $A + 1);
|
||||||
$DB->query($SQL);
|
$QueryID = G::$DB->get_query_id();
|
||||||
$IPBans = $DB->to_array(0, MYSQLI_NUM);
|
G::$DB->query($SQL);
|
||||||
$Cache->cache_value('ip_bans_'.$A, $IPBans, 0);
|
$IPBans = G::$DB->to_array(0, MYSQLI_NUM);
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('ip_bans_'.$A, $IPBans, 0);
|
||||||
}
|
}
|
||||||
$Debug->log_var($IPBans, 'IP bans for class '.$A);
|
$Debug->log_var($IPBans, 'IP bans for class '.$A);
|
||||||
foreach ($IPBans as $Index => $IPBan) {
|
foreach ($IPBans as $Index => $IPBan) {
|
||||||
@ -59,16 +61,17 @@ public static function geoip($IP) {
|
|||||||
if (!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
|
if (!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT EndIP, Code
|
SELECT EndIP, Code
|
||||||
FROM geoip_country
|
FROM geoip_country
|
||||||
WHERE $Long >= StartIP
|
WHERE $Long >= StartIP
|
||||||
ORDER BY StartIP DESC
|
ORDER BY StartIP DESC
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
if ((!list($EndIP, $Country) = $DB->next_record()) || $EndIP < $Long) {
|
if ((!list($EndIP, $Country) = G::$DB->next_record()) || $EndIP < $Long) {
|
||||||
$Country = '?';
|
$Country = '?';
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
$IPs[$IP] = $Country;
|
$IPs[$IP] = $Country;
|
||||||
return $Country;
|
return $Country;
|
||||||
}
|
}
|
||||||
@ -115,7 +118,7 @@ public static function get_host_by_ajax($IP) {
|
|||||||
* @return string the host.
|
* @return string the host.
|
||||||
*/
|
*/
|
||||||
public static function lookup_ip($IP) {
|
public static function lookup_ip($IP) {
|
||||||
//TODO: use the $Cache
|
//TODO: use the G::$Cache
|
||||||
$Output = explode(' ',shell_exec('host -W 1 '.escapeshellarg($IP)));
|
$Output = explode(' ',shell_exec('host -W 1 '.escapeshellarg($IP)));
|
||||||
if (count($Output) == 1 && empty($Output[0])) {
|
if (count($Output) == 1 && empty($Output[0])) {
|
||||||
//No output at all implies the command failed
|
//No output at all implies the command failed
|
||||||
@ -156,11 +159,11 @@ public static function get_country_code_by_ajax($IP) {
|
|||||||
* @param BanReason 0 - Unknown, 1 - Manual, 2 - Ratio, 3 - Inactive, 4 - Unused.
|
* @param BanReason 0 - Unknown, 1 - Manual, 2 - Ratio, 3 - Inactive, 4 - Unused.
|
||||||
*/
|
*/
|
||||||
public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
||||||
global $Cache, $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
if (!is_array($UserIDs)) {
|
if (!is_array($UserIDs)) {
|
||||||
$UserIDs = array($UserIDs);
|
$UserIDs = array($UserIDs);
|
||||||
}
|
}
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE users_info AS i
|
UPDATE users_info AS i
|
||||||
JOIN users_main AS m ON m.ID=i.UserID
|
JOIN users_main AS m ON m.ID=i.UserID
|
||||||
SET m.Enabled='2',
|
SET m.Enabled='2',
|
||||||
@ -170,35 +173,35 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
|||||||
i.BanReason='$BanReason',
|
i.BanReason='$BanReason',
|
||||||
i.RatioWatchDownload=".($BanReason == 2 ? 'm.Downloaded' : "'0'")."
|
i.RatioWatchDownload=".($BanReason == 2 ? 'm.Downloaded' : "'0'")."
|
||||||
WHERE m.ID IN(".implode(',', $UserIDs).') ');
|
WHERE m.ID IN(".implode(',', $UserIDs).') ');
|
||||||
$Cache->decrement('stats_user_count', $DB->affected_rows());
|
G::$Cache->decrement('stats_user_count', G::$DB->affected_rows());
|
||||||
foreach ($UserIDs as $UserID) {
|
foreach ($UserIDs as $UserID) {
|
||||||
$Cache->delete_value('enabled_'.$UserID);
|
G::$Cache->delete_value("enabled_$UserID");
|
||||||
$Cache->delete_value('user_info_'.$UserID);
|
G::$Cache->delete_value("user_info_$UserID");
|
||||||
$Cache->delete_value('user_info_heavy_'.$UserID);
|
G::$Cache->delete_value("user_info_heavy_$UserID");
|
||||||
$Cache->delete_value('user_stats_'.$UserID);
|
G::$Cache->delete_value("user_stats_$UserID");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT SessionID
|
SELECT SessionID
|
||||||
FROM users_sessions
|
FROM users_sessions
|
||||||
WHERE UserID = '$UserID'
|
WHERE UserID = '$UserID'
|
||||||
AND Active = 1");
|
AND Active = 1");
|
||||||
while (list($SessionID) = $DB->next_record()) {
|
while (list($SessionID) = G::$DB->next_record()) {
|
||||||
$Cache->delete_value('session_'.$UserID.'_'.$SessionID);
|
G::$Cache->delete_value("session_$UserID"."_$SessionID");
|
||||||
}
|
}
|
||||||
$Cache->delete_value('users_sessions_'.$UserID);
|
G::$Cache->delete_value("users_sessions_$UserID");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM users_sessions
|
DELETE FROM users_sessions
|
||||||
WHERE UserID = '$UserID'");
|
WHERE UserID = '$UserID'");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the users from the tracker.
|
// Remove the users from the tracker.
|
||||||
$DB->query("
|
G::$DB->query('
|
||||||
SELECT torrent_pass
|
SELECT torrent_pass
|
||||||
FROM users_main
|
FROM users_main
|
||||||
WHERE ID in (".implode(', ', $UserIDs).')');
|
WHERE ID in ('.implode(', ', $UserIDs).')');
|
||||||
$PassKeys = $DB->collect('torrent_pass');
|
$PassKeys = G::$DB->collect('torrent_pass');
|
||||||
$Concat = '';
|
$Concat = '';
|
||||||
foreach ($PassKeys as $PassKey) {
|
foreach ($PassKeys as $PassKey) {
|
||||||
if (strlen($Concat) > 3950) { // Ocelot's read buffer is 4 KiB and anything exceeding it is truncated
|
if (strlen($Concat) > 3950) { // Ocelot's read buffer is 4 KiB and anything exceeding it is truncated
|
||||||
@ -209,6 +212,7 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
|
Tracker::update_tracker('remove_users', array('passkeys' => $Concat));
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,25 +223,26 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
|
|||||||
* @param string $reason
|
* @param string $reason
|
||||||
*/
|
*/
|
||||||
public static function warn_user($UserID, $Duration, $Reason) {
|
public static function warn_user($UserID, $Duration, $Reason) {
|
||||||
global $LoggedUser, $DB, $Cache, $Time;
|
global $Time;
|
||||||
|
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT Warned
|
SELECT Warned
|
||||||
FROM users_info
|
FROM users_info
|
||||||
WHERE UserID = $UserID
|
WHERE UserID = $UserID
|
||||||
AND Warned != '0000-00-00 00:00:00'");
|
AND Warned != '0000-00-00 00:00:00'");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
//User was already warned, appending new warning to old.
|
//User was already warned, appending new warning to old.
|
||||||
list($OldDate) = $DB->next_record();
|
list($OldDate) = G::$DB->next_record();
|
||||||
$NewExpDate = date('Y-m-d H:i:s', strtotime($OldDate) + $Duration);
|
$NewExpDate = date('Y-m-d H:i:s', strtotime($OldDate) + $Duration);
|
||||||
|
|
||||||
Misc::send_pm($UserID, 0,
|
Misc::send_pm($UserID, 0,
|
||||||
'You have received multiple warnings.',
|
'You have received multiple warnings.',
|
||||||
"When you received your latest warning (set to expire on ".date('Y-m-d', (time() + $Duration)).'), you already had a different warning (set to expire on '.date('Y-m-d', strtotime($OldDate)).").\n\n Due to this collision, your warning status will now expire at ".$NewExpDate.'.');
|
"When you received your latest warning (set to expire on ".date('Y-m-d', (time() + $Duration)).'), you already had a different warning (set to expire on '.date('Y-m-d', strtotime($OldDate)).").\n\n Due to this collision, your warning status will now expire at $NewExpDate.");
|
||||||
|
|
||||||
$AdminComment = date('Y-m-d').' - Warning (Clash) extended to expire at '.$NewExpDate.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n";
|
$AdminComment = date('Y-m-d')." - Warning (Clash) extended to expire at $NewExpDate by " . G::$LoggedUser['Username'] . "\nReason: $Reason\n\n";
|
||||||
|
|
||||||
$DB->query('
|
G::$DB->query('
|
||||||
UPDATE users_info
|
UPDATE users_info
|
||||||
SET
|
SET
|
||||||
Warned = \''.db_string($NewExpDate).'\',
|
Warned = \''.db_string($NewExpDate).'\',
|
||||||
@ -248,13 +253,13 @@ public static function warn_user($UserID, $Duration, $Reason) {
|
|||||||
//Not changing, user was not already warned
|
//Not changing, user was not already warned
|
||||||
$WarnTime = time_plus($Duration);
|
$WarnTime = time_plus($Duration);
|
||||||
|
|
||||||
$Cache->begin_transaction('user_info_'.$UserID);
|
G::$Cache->begin_transaction("user_info_$UserID");
|
||||||
$Cache->update_row(false, array('Warned' => $WarnTime));
|
G::$Cache->update_row(false, array('Warned' => $WarnTime));
|
||||||
$Cache->commit_transaction(0);
|
G::$Cache->commit_transaction(0);
|
||||||
|
|
||||||
$AdminComment = date('Y-m-d').' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n";
|
$AdminComment = date('Y-m-d')." - Warned until $WarnTime by " . G::$LoggedUser['Username'] . "\nReason: $Reason\n\n";
|
||||||
|
|
||||||
$DB->query('
|
G::$DB->query('
|
||||||
UPDATE users_info
|
UPDATE users_info
|
||||||
SET
|
SET
|
||||||
Warned = \''.db_string($WarnTime).'\',
|
Warned = \''.db_string($WarnTime).'\',
|
||||||
@ -262,6 +267,7 @@ public static function warn_user($UserID, $Duration, $Reason) {
|
|||||||
AdminComment = CONCAT(\''.db_string($AdminComment).'\',AdminComment)
|
AdminComment = CONCAT(\''.db_string($AdminComment).'\',AdminComment)
|
||||||
WHERE UserID = \''.db_string($UserID).'\'');
|
WHERE UserID = \''.db_string($UserID).'\'');
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -270,11 +276,12 @@ public static function warn_user($UserID, $Duration, $Reason) {
|
|||||||
* @param unknown $AdminComment Comment to update with
|
* @param unknown $AdminComment Comment to update with
|
||||||
*/
|
*/
|
||||||
public static function update_user_notes($UserID, $AdminComment) {
|
public static function update_user_notes($UserID, $AdminComment) {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query('
|
G::$DB->query('
|
||||||
UPDATE users_info
|
UPDATE users_info
|
||||||
SET AdminComment = CONCAT(\''.db_string($AdminComment).'\',AdminComment)
|
SET AdminComment = CONCAT(\''.db_string($AdminComment).'\',AdminComment)
|
||||||
WHERE UserID = \''.db_string($UserID).'\'');
|
WHERE UserID = \''.db_string($UserID).'\'');
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -45,14 +45,13 @@ function TORRENT_FORM($Torrent = false, $Error = false, $NewTorrent = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function head() {
|
function head() {
|
||||||
global $LoggedUser;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="thin">
|
<div class="thin">
|
||||||
<? if ($this->NewTorrent) { ?>
|
<? if ($this->NewTorrent) { ?>
|
||||||
<p style="text-align: center;">
|
<p style="text-align: center;">
|
||||||
Your personal announce URL is:<br />
|
Your personal announce URL is:<br />
|
||||||
<input type="text" value="<?= ANNOUNCE_URL.'/'.$LoggedUser['torrent_pass'].'/announce'?>" size="71" onclick="this.select()" readonly="readonly" />
|
<input type="text" value="<?= ANNOUNCE_URL . '/' . G::$LoggedUser['torrent_pass'] . '/announce'?>" size="71" onclick="this.select()" readonly="readonly" />
|
||||||
</p>
|
</p>
|
||||||
<? }
|
<? }
|
||||||
if ($this->Error) {
|
if ($this->Error) {
|
||||||
@ -62,7 +61,7 @@ function head() {
|
|||||||
<form class="create_form" name="torrent" action="" enctype="multipart/form-data" method="post" id="upload_table" onsubmit="$('#post').raw().disabled = 'disabled'">
|
<form class="create_form" name="torrent" action="" enctype="multipart/form-data" method="post" id="upload_table" onsubmit="$('#post').raw().disabled = 'disabled'">
|
||||||
<div>
|
<div>
|
||||||
<input type="hidden" name="submit" value="true" />
|
<input type="hidden" name="submit" value="true" />
|
||||||
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
<input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
|
||||||
<? if (!$this->NewTorrent) { ?>
|
<? if (!$this->NewTorrent) { ?>
|
||||||
<input type="hidden" name="action" value="takeedit" />
|
<input type="hidden" name="action" value="takeedit" />
|
||||||
<input type="hidden" name="torrentid" value="<?=display_str($this->TorrentID)?>" />
|
<input type="hidden" name="torrentid" value="<?=display_str($this->TorrentID)?>" />
|
||||||
@ -150,13 +149,13 @@ function foot() {
|
|||||||
|
|
||||||
|
|
||||||
function music_form($GenreTags) {
|
function music_form($GenreTags) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
$Torrent = $this->Torrent;
|
$Torrent = $this->Torrent;
|
||||||
$IsRemaster = !empty($Torrent['Remastered']);
|
$IsRemaster = !empty($Torrent['Remastered']);
|
||||||
$UnknownRelease = !$this->NewTorrent && $IsRemaster && !$Torrent['RemasterYear'];
|
$UnknownRelease = !$this->NewTorrent && $IsRemaster && !$Torrent['RemasterYear'];
|
||||||
|
|
||||||
if ($Torrent['GroupID']) {
|
if ($Torrent['GroupID']) {
|
||||||
global $DB;
|
G::$DB->query('
|
||||||
$DB->query('
|
|
||||||
SELECT
|
SELECT
|
||||||
ID,
|
ID,
|
||||||
RemasterYear,
|
RemasterYear,
|
||||||
@ -172,12 +171,11 @@ function music_form($GenreTags) {
|
|||||||
RemasterRecordLabel DESC,
|
RemasterRecordLabel DESC,
|
||||||
RemasterCatalogueNumber DESC");
|
RemasterCatalogueNumber DESC");
|
||||||
|
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
$GroupRemasters = $DB->to_array(false, MYSQLI_BOTH, false);
|
$GroupRemasters = G::$DB->to_array(false, MYSQLI_BOTH, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global $DB;
|
|
||||||
$HasLog = $Torrent['HasLog'];
|
$HasLog = $Torrent['HasLog'];
|
||||||
$HasCue = $Torrent['HasCue'];
|
$HasCue = $Torrent['HasCue'];
|
||||||
$BadTags = $Torrent['BadTags'];
|
$BadTags = $Torrent['BadTags'];
|
||||||
@ -244,7 +242,7 @@ function music_form($GenreTags) {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="musicbrainz_tr">
|
<tr id="musicbrainz_tr">
|
||||||
<td class="label" title="Click the "Find Info" button to automatically fill out parts of the upload form by selecting an entry in MusicBrainz">MusicBrainz:</td>
|
<td class="label tooltip" title="Click the "Find Info" button to automatically fill out parts of the upload form by selecting an entry in MusicBrainz">MusicBrainz:</td>
|
||||||
<td><input type="button" value="Find Info" id="musicbrainz_button" /></td>
|
<td><input type="button" value="Find Info" id="musicbrainz_button" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<div id="musicbrainz_popup">
|
<div id="musicbrainz_popup">
|
||||||
@ -336,7 +334,7 @@ function show() {
|
|||||||
<input type="checkbox" id="remaster" name="remaster"<? if ($IsRemaster) { echo ' checked="checked"';} ?> onclick="Remaster();<? if ($this->NewTorrent) { ?> CheckYear();<? } ?>" />
|
<input type="checkbox" id="remaster" name="remaster"<? if ($IsRemaster) { echo ' checked="checked"';} ?> onclick="Remaster();<? if ($this->NewTorrent) { ?> CheckYear();<? } ?>" />
|
||||||
<label for="remaster">Check this box if this torrent is a different release to the original, for example a limited or country specific edition or a release that includes additional bonus tracks or is a bonus disc.</label>
|
<label for="remaster">Check this box if this torrent is a different release to the original, for example a limited or country specific edition or a release that includes additional bonus tracks or is a bonus disc.</label>
|
||||||
<div id="remaster_true"<? if (!$IsRemaster) { echo ' class="hidden"';} ?>>
|
<div id="remaster_true"<? if (!$IsRemaster) { echo ' class="hidden"';} ?>>
|
||||||
<? if (check_perms('edit_unknowns') || $LoggedUser['ID'] == $Torrent['UserID']) { ?>
|
<? if (check_perms('edit_unknowns') || G::$LoggedUser['ID'] == $Torrent['UserID']) { ?>
|
||||||
<br />
|
<br />
|
||||||
<input type="checkbox" id="unknown" name="unknown"<? if ($UnknownRelease) { echo ' checked="checked"';} ?> onclick="<? if ($this->NewTorrent) { ?> CheckYear();<? } ?>ToggleUnknown();" /> <label for="unknown">Unknown Release</label>
|
<input type="checkbox" id="unknown" name="unknown"<? if ($UnknownRelease) { echo ' checked="checked"';} ?> onclick="<? if ($this->NewTorrent) { ?> CheckYear();<? } ?>ToggleUnknown();" /> <label for="unknown">Unknown Release</label>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
@ -509,16 +507,15 @@ function show() {
|
|||||||
<input type="checkbox" id="flac_log" name="flac_log"<? if ($HasLog) { echo ' checked="checked"';} ?> /> <label for="flac_log">Check this box if the torrent has, or should have, a log file.</label><br />
|
<input type="checkbox" id="flac_log" name="flac_log"<? if ($HasLog) { echo ' checked="checked"';} ?> /> <label for="flac_log">Check this box if the torrent has, or should have, a log file.</label><br />
|
||||||
<input type="checkbox" id="flac_cue" name="flac_cue"<? if ($HasCue) { echo ' checked="checked"';} ?> /> <label for="flac_cue">Check this box if the torrent has, or should have, a cue file.</label><br />
|
<input type="checkbox" id="flac_cue" name="flac_cue"<? if ($HasCue) { echo ' checked="checked"';} ?> /> <label for="flac_cue">Check this box if the torrent has, or should have, a cue file.</label><br />
|
||||||
<? }
|
<? }
|
||||||
global $LoggedUser;
|
if ((check_perms('users_mod') || G::$LoggedUser['ID'] == $Torrent['UserID']) && ($Torrent['LogScore'] == 100 || $Torrent['LogScore'] == 99)) {
|
||||||
if ((check_perms('users_mod') || $LoggedUser['ID'] == $Torrent['UserID']) && ($Torrent['LogScore'] == 100 || $Torrent['LogScore'] == 99)) {
|
|
||||||
|
|
||||||
$DB->query('
|
G::$DB->query('
|
||||||
SELECT LogID
|
SELECT LogID
|
||||||
FROM torrents_logs_new
|
FROM torrents_logs_new
|
||||||
WHERE TorrentID = '.$this->TorrentID."
|
WHERE TorrentID = '.$this->TorrentID."
|
||||||
AND Log LIKE 'EAC extraction logfile%'
|
AND Log LIKE 'EAC extraction logfile%'
|
||||||
AND (Adjusted = '0' OR Adjusted = '')");
|
AND (Adjusted = '0' OR Adjusted = '')");
|
||||||
list($LogID) = $DB->next_record();
|
list($LogID) = G::$DB->next_record();
|
||||||
if ($LogID) {
|
if ($LogID) {
|
||||||
if (!check_perms('users_mod')) { ?>
|
if (!check_perms('users_mod')) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
@ -619,6 +616,7 @@ function show() {
|
|||||||
if ($_SERVER['SCRIPT_NAME'] === '/ajax.php')
|
if ($_SERVER['SCRIPT_NAME'] === '/ajax.php')
|
||||||
TEXTAREA_PREVIEW::JavaScript(false);
|
TEXTAREA_PREVIEW::JavaScript(false);
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}//function music_form
|
}//function music_form
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class Torrents {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, $Torrents = true) {
|
public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, $Torrents = true) {
|
||||||
global $DB, $Cache, $Debug;
|
global $Debug;
|
||||||
|
|
||||||
// Make sure there's something in $GroupIDs, otherwise the SQL
|
// Make sure there's something in $GroupIDs, otherwise the SQL
|
||||||
// will break
|
// will break
|
||||||
@ -59,7 +59,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
|||||||
$Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_';
|
$Key = $Torrents ? 'torrent_group_' : 'torrent_group_light_';
|
||||||
|
|
||||||
foreach ($GroupIDs as $GroupID) {
|
foreach ($GroupIDs as $GroupID) {
|
||||||
$Data = $Cache->get_value($Key.$GroupID, true);
|
$Data = G::$Cache->get_value($Key.$GroupID, true);
|
||||||
if (!empty($Data) && (@$Data['ver'] == CACHE::GROUP_VERSION)) {
|
if (!empty($Data) && (@$Data['ver'] == CACHE::GROUP_VERSION)) {
|
||||||
unset($NotFound[$GroupID]);
|
unset($NotFound[$GroupID]);
|
||||||
$Found[$GroupID] = $Data['d'];
|
$Found[$GroupID] = $Data['d'];
|
||||||
@ -77,18 +77,20 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (count($NotFound) > 0) {
|
if (count($NotFound) > 0) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID
|
g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID
|
||||||
FROM torrents_group AS g
|
FROM torrents_group AS g
|
||||||
WHERE g.ID IN ($IDs)");
|
WHERE g.ID IN ($IDs)");
|
||||||
|
|
||||||
while ($Group = $DB->next_record(MYSQLI_ASSOC, true)) {
|
while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) {
|
||||||
unset($NotFound[$Group['ID']]);
|
unset($NotFound[$Group['ID']]);
|
||||||
$Found[$Group['ID']] = $Group;
|
$Found[$Group['ID']] = $Group;
|
||||||
$Found[$Group['ID']]['Torrents'] = array();
|
$Found[$Group['ID']]['Torrents'] = array();
|
||||||
$Found[$Group['ID']]['Artists'] = array();
|
$Found[$Group['ID']]['Artists'] = array();
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
// Orphan torrents. There shouldn't ever be any
|
// Orphan torrents. There shouldn't ever be any
|
||||||
if (count($NotFound) > 0) {
|
if (count($NotFound) > 0) {
|
||||||
@ -98,7 +100,8 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Torrents) {
|
if ($Torrents) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle,
|
ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle,
|
||||||
RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
|
RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
|
||||||
@ -107,21 +110,22 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
|
|||||||
WHERE GroupID IN($IDs)
|
WHERE GroupID IN($IDs)
|
||||||
ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
|
ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
|
||||||
RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID");
|
RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID");
|
||||||
while ($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) {
|
while ($Torrent = G::$DB->next_record(MYSQLI_ASSOC, true)) {
|
||||||
$Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
|
$Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
// Cache it all
|
// Cache it all
|
||||||
foreach ($Found as $GroupID => $GroupInfo) {
|
foreach ($Found as $GroupID => $GroupInfo) {
|
||||||
$Cache->cache_value("torrent_group_$GroupID",
|
G::$Cache->cache_value("torrent_group_$GroupID",
|
||||||
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
|
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
|
||||||
$Cache->cache_value("torrent_group_light_$GroupID",
|
G::$Cache->cache_value("torrent_group_light_$GroupID",
|
||||||
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
|
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
foreach ($Found as $Group) {
|
foreach ($Found as $Group) {
|
||||||
$Cache->cache_value('torrent_group_light_'.$Group['ID'], array('ver' => CACHE::GROUP_VERSION, 'd' => $Found[$Group['ID']]), 0);
|
G::$Cache->cache_value('torrent_group_light_'.$Group['ID'], array('ver' => CACHE::GROUP_VERSION, 'd' => $Found[$Group['ID']]), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,12 +218,14 @@ public static function torrent_properties(&$Torrent, &$Flags) {
|
|||||||
* @param boolean $Hidden Currently does fuck all. TODO: Fix that.
|
* @param boolean $Hidden Currently does fuck all. TODO: Fix that.
|
||||||
*/
|
*/
|
||||||
public static function write_group_log($GroupID, $TorrentID, $UserID, $Message, $Hidden) {
|
public static function write_group_log($GroupID, $TorrentID, $UserID, $Message, $Hidden) {
|
||||||
global $DB, $Time;
|
global $Time;
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
INSERT INTO group_log
|
INSERT INTO group_log
|
||||||
(GroupID, TorrentID, UserID, Info, Time, Hidden)
|
(GroupID, TorrentID, UserID, Info, Time, Hidden)
|
||||||
VALUES
|
VALUES
|
||||||
($GroupID, $TorrentID, $UserID, '".db_string($Message)."', '".sqltime()."', $Hidden)");
|
($GroupID, $TorrentID, $UserID, '".db_string($Message)."', '".sqltime()."', $Hidden)");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -231,49 +237,49 @@ public static function write_group_log($GroupID, $TorrentID, $UserID, $Message,
|
|||||||
* @param string $OcelotReason The deletion reason for ocelot to report to users.
|
* @param string $OcelotReason The deletion reason for ocelot to report to users.
|
||||||
*/
|
*/
|
||||||
public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
|
public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
|
||||||
global $DB, $Cache, $LoggedUser;
|
$QueryID = G::$DB->get_query_id();
|
||||||
if (!$GroupID) {
|
if (!$GroupID) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT GroupID, UserID
|
SELECT GroupID, UserID
|
||||||
FROM torrents
|
FROM torrents
|
||||||
WHERE ID = '$ID'");
|
WHERE ID = '$ID'");
|
||||||
list($GroupID, $UploaderID) = $DB->next_record();
|
list($GroupID, $UploaderID) = G::$DB->next_record();
|
||||||
}
|
}
|
||||||
if (empty($UserID)) {
|
if (empty($UserID)) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT UserID
|
SELECT UserID
|
||||||
FROM torrents
|
FROM torrents
|
||||||
WHERE ID = '$ID'");
|
WHERE ID = '$ID'");
|
||||||
list($UserID) = $DB->next_record();
|
list($UserID) = G::$DB->next_record();
|
||||||
}
|
}
|
||||||
|
|
||||||
$RecentUploads = $Cache->get_value("recent_uploads_$UserID");
|
$RecentUploads = G::$Cache->get_value("recent_uploads_$UserID");
|
||||||
if (is_array($RecentUploads)) {
|
if (is_array($RecentUploads)) {
|
||||||
foreach ($RecentUploads as $Key => $Recent) {
|
foreach ($RecentUploads as $Key => $Recent) {
|
||||||
if ($Recent['ID'] == $GroupID) {
|
if ($Recent['ID'] == $GroupID) {
|
||||||
$Cache->delete_value("recent_uploads_$UserID");
|
G::$Cache->delete_value("recent_uploads_$UserID");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT info_hash
|
SELECT info_hash
|
||||||
FROM torrents
|
FROM torrents
|
||||||
WHERE ID = $ID");
|
WHERE ID = $ID");
|
||||||
list($InfoHash) = $DB->next_record(MYSQLI_BOTH, false);
|
list($InfoHash) = G::$DB->next_record(MYSQLI_BOTH, false);
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents
|
DELETE FROM torrents
|
||||||
WHERE ID = $ID");
|
WHERE ID = $ID");
|
||||||
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
|
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
|
||||||
|
|
||||||
$Cache->decrement('stats_torrent_count');
|
G::$Cache->decrement('stats_torrent_count');
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM torrents
|
FROM torrents
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
list($Count) = $DB->next_record();
|
list($Count) = G::$DB->next_record();
|
||||||
|
|
||||||
if ($Count == 0) {
|
if ($Count == 0) {
|
||||||
Torrents::delete_group($GroupID);
|
Torrents::delete_group($GroupID);
|
||||||
@ -282,18 +288,18 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Torrent notifications
|
// Torrent notifications
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT UserID
|
SELECT UserID
|
||||||
FROM users_notify_torrents
|
FROM users_notify_torrents
|
||||||
WHERE TorrentID = '$ID'");
|
WHERE TorrentID = '$ID'");
|
||||||
while (list($UserID) = $DB->next_record()) {
|
while (list($UserID) = G::$DB->next_record()) {
|
||||||
$Cache->delete_value("notifications_new_$UserID");
|
G::$Cache->delete_value("notifications_new_$UserID");
|
||||||
}
|
}
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM users_notify_torrents
|
DELETE FROM users_notify_torrents
|
||||||
WHERE TorrentID = '$ID'");
|
WHERE TorrentID = '$ID'");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE reportsv2
|
UPDATE reportsv2
|
||||||
SET
|
SET
|
||||||
Status = 'Resolved',
|
Status = 'Resolved',
|
||||||
@ -301,41 +307,42 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
|
|||||||
ModComment = 'Report already dealt with (torrent deleted)'
|
ModComment = 'Report already dealt with (torrent deleted)'
|
||||||
WHERE TorrentID = $ID
|
WHERE TorrentID = $ID
|
||||||
AND Status != 'Resolved'");
|
AND Status != 'Resolved'");
|
||||||
$Reports = $DB->affected_rows();
|
$Reports = G::$DB->affected_rows();
|
||||||
if ($Reports) {
|
if ($Reports) {
|
||||||
$Cache->decrement('num_torrent_reportsv2', $Reports);
|
G::$Cache->decrement('num_torrent_reportsv2', $Reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_files
|
DELETE FROM torrents_files
|
||||||
WHERE TorrentID = '$ID'");
|
WHERE TorrentID = '$ID'");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_bad_tags
|
DELETE FROM torrents_bad_tags
|
||||||
WHERE TorrentID = $ID");
|
WHERE TorrentID = $ID");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_bad_folders
|
DELETE FROM torrents_bad_folders
|
||||||
WHERE TorrentID = $ID");
|
WHERE TorrentID = $ID");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_bad_files
|
DELETE FROM torrents_bad_files
|
||||||
WHERE TorrentID = $ID");
|
WHERE TorrentID = $ID");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_cassette_approved
|
DELETE FROM torrents_cassette_approved
|
||||||
WHERE TorrentID = $ID");
|
WHERE TorrentID = $ID");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_lossymaster_approved
|
DELETE FROM torrents_lossymaster_approved
|
||||||
WHERE TorrentID = $ID");
|
WHERE TorrentID = $ID");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_lossyweb_approved
|
DELETE FROM torrents_lossyweb_approved
|
||||||
WHERE TorrentID = $ID");
|
WHERE TorrentID = $ID");
|
||||||
|
|
||||||
// Tells Sphinx that the group is removed
|
// Tells Sphinx that the group is removed
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
REPLACE INTO sphinx_delta (ID, Time)
|
REPLACE INTO sphinx_delta (ID, Time)
|
||||||
VALUES ($ID, UNIX_TIMESTAMP())");
|
VALUES ($ID, UNIX_TIMESTAMP())");
|
||||||
|
|
||||||
$Cache->delete_value("torrent_download_$ID");
|
G::$Cache->delete_value("torrent_download_$ID");
|
||||||
$Cache->delete_value("torrent_group_$GroupID");
|
G::$Cache->delete_value("torrent_group_$GroupID");
|
||||||
$Cache->delete_value("torrents_details_$GroupID");
|
G::$Cache->delete_value("torrents_details_$GroupID");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -346,52 +353,52 @@ public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
|
|||||||
* @param int $GroupID
|
* @param int $GroupID
|
||||||
*/
|
*/
|
||||||
public static function delete_group($GroupID) {
|
public static function delete_group($GroupID) {
|
||||||
global $DB, $Cache;
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
Misc::write_log("Group $GroupID automatically deleted (No torrents have this group).");
|
Misc::write_log("Group $GroupID automatically deleted (No torrents have this group).");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT CategoryID
|
SELECT CategoryID
|
||||||
FROM torrents_group
|
FROM torrents_group
|
||||||
WHERE ID = '$GroupID'");
|
WHERE ID = '$GroupID'");
|
||||||
list($Category) = $DB->next_record();
|
list($Category) = G::$DB->next_record();
|
||||||
if ($Category == 1) {
|
if ($Category == 1) {
|
||||||
$Cache->decrement('stats_album_count');
|
G::$Cache->decrement('stats_album_count');
|
||||||
}
|
}
|
||||||
$Cache->decrement('stats_group_count');
|
G::$Cache->decrement('stats_group_count');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Collages
|
// Collages
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT CollageID
|
SELECT CollageID
|
||||||
FROM collages_torrents
|
FROM collages_torrents
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
$CollageIDs = $DB->collect('CollageID');
|
$CollageIDs = G::$DB->collect('CollageID');
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE collages
|
UPDATE collages
|
||||||
SET NumTorrents = NumTorrents - 1
|
SET NumTorrents = NumTorrents - 1
|
||||||
WHERE ID IN (".implode(', ', $CollageIDs).')');
|
WHERE ID IN (".implode(', ', $CollageIDs).')');
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM collages_torrents
|
DELETE FROM collages_torrents
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
|
|
||||||
foreach ($CollageIDs as $CollageID) {
|
foreach ($CollageIDs as $CollageID) {
|
||||||
$Cache->delete_value("collage_$CollageID");
|
G::$Cache->delete_value("collage_$CollageID");
|
||||||
}
|
}
|
||||||
$Cache->delete_value("torrent_collages_$GroupID");
|
G::$Cache->delete_value("torrent_collages_$GroupID");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Artists
|
// Artists
|
||||||
// Collect the artist IDs and then wipe the torrents_artist entry
|
// Collect the artist IDs and then wipe the torrents_artist entry
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT ArtistID
|
SELECT ArtistID
|
||||||
FROM torrents_artists
|
FROM torrents_artists
|
||||||
WHERE GroupID = $GroupID");
|
WHERE GroupID = $GroupID");
|
||||||
$Artists = $DB->collect('ArtistID');
|
$Artists = G::$DB->collect('ArtistID');
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_artists
|
DELETE FROM torrents_artists
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
|
|
||||||
@ -400,65 +407,66 @@ public static function delete_group($GroupID) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Get a count of how many groups or requests use the artist ID
|
// Get a count of how many groups or requests use the artist ID
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ag.ArtistID)
|
SELECT COUNT(ag.ArtistID)
|
||||||
FROM artists_group as ag
|
FROM artists_group as ag
|
||||||
LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
|
LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
|
||||||
WHERE ra.ArtistID IS NOT NULL
|
WHERE ra.ArtistID IS NOT NULL
|
||||||
AND ag.ArtistID = '$ArtistID'");
|
AND ag.ArtistID = '$ArtistID'");
|
||||||
list($ReqCount) = $DB->next_record();
|
list($ReqCount) = G::$DB->next_record();
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ag.ArtistID)
|
SELECT COUNT(ag.ArtistID)
|
||||||
FROM artists_group as ag
|
FROM artists_group as ag
|
||||||
LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
|
LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
|
||||||
WHERE ta.ArtistID IS NOT NULL
|
WHERE ta.ArtistID IS NOT NULL
|
||||||
AND ag.ArtistID = '$ArtistID'");
|
AND ag.ArtistID = '$ArtistID'");
|
||||||
list($GroupCount) = $DB->next_record();
|
list($GroupCount) = G::$DB->next_record();
|
||||||
if (($ReqCount + $GroupCount) == 0) {
|
if (($ReqCount + $GroupCount) == 0) {
|
||||||
//The only group to use this artist
|
//The only group to use this artist
|
||||||
Artists::delete_artist($ArtistID);
|
Artists::delete_artist($ArtistID);
|
||||||
} else {
|
} else {
|
||||||
//Not the only group, still need to clear cache
|
//Not the only group, still need to clear cache
|
||||||
$Cache->delete_value("artist_groups_$ArtistID");
|
G::$Cache->delete_value("artist_groups_$ArtistID");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requests
|
// Requests
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT ID
|
SELECT ID
|
||||||
FROM requests
|
FROM requests
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
$Requests = $DB->collect('ID');
|
$Requests = G::$DB->collect('ID');
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE requests
|
UPDATE requests
|
||||||
SET GroupID = NULL
|
SET GroupID = NULL
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
foreach ($Requests as $RequestID) {
|
foreach ($Requests as $RequestID) {
|
||||||
$Cache->delete_value("request_$RequestID");
|
G::$Cache->delete_value("request_$RequestID");
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query("
|
// comments
|
||||||
|
Comments::delete_page('torrents', $GroupID);
|
||||||
|
|
||||||
|
G::$DB->query("
|
||||||
DELETE FROM torrents_group
|
DELETE FROM torrents_group
|
||||||
WHERE ID = '$GroupID'");
|
WHERE ID = '$GroupID'");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_tags
|
DELETE FROM torrents_tags
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_tags_votes
|
DELETE FROM torrents_tags_votes
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM torrents_comments
|
|
||||||
WHERE GroupID = '$GroupID'");
|
|
||||||
$DB->query("
|
|
||||||
DELETE FROM bookmarks_torrents
|
DELETE FROM bookmarks_torrents
|
||||||
WHERE GroupID = '$GroupID'");
|
WHERE GroupID = '$GroupID'");
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DELETE FROM wiki_torrents
|
DELETE FROM wiki_torrents
|
||||||
WHERE PageID = '$GroupID'");
|
WHERE PageID = '$GroupID'");
|
||||||
|
|
||||||
$Cache->delete_value("torrents_details_$GroupID");
|
G::$Cache->delete_value("torrents_details_$GroupID");
|
||||||
$Cache->delete_value("torrent_group_$GroupID");
|
G::$Cache->delete_value("torrent_group_$GroupID");
|
||||||
$Cache->delete_value("groups_artists_$GroupID");
|
G::$Cache->delete_value("groups_artists_$GroupID");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -468,8 +476,9 @@ public static function delete_group($GroupID) {
|
|||||||
* @param int $GroupID
|
* @param int $GroupID
|
||||||
*/
|
*/
|
||||||
public static function update_hash($GroupID) {
|
public static function update_hash($GroupID) {
|
||||||
global $DB, $Cache;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
|
||||||
|
G::$DB->query("
|
||||||
UPDATE torrents_group
|
UPDATE torrents_group
|
||||||
SET TagList = (
|
SET TagList = (
|
||||||
SELECT REPLACE(GROUP_CONCAT(tags.Name SEPARATOR ' '), '.', '_')
|
SELECT REPLACE(GROUP_CONCAT(tags.Name SEPARATOR ' '), '.', '_')
|
||||||
@ -481,31 +490,31 @@ public static function update_hash($GroupID) {
|
|||||||
WHERE ID = '$GroupID'");
|
WHERE ID = '$GroupID'");
|
||||||
|
|
||||||
// Fetch album vote score
|
// Fetch album vote score
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT Score
|
SELECT Score
|
||||||
FROM torrents_votes
|
FROM torrents_votes
|
||||||
WHERE GroupID = $GroupID");
|
WHERE GroupID = $GroupID");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($VoteScore) = $DB->next_record();
|
list($VoteScore) = G::$DB->next_record();
|
||||||
} else {
|
} else {
|
||||||
$VoteScore = 0;
|
$VoteScore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch album artists
|
// Fetch album artists
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT GROUP_CONCAT(aa.Name separator ' ')
|
SELECT GROUP_CONCAT(aa.Name separator ' ')
|
||||||
FROM torrents_artists AS ta
|
FROM torrents_artists AS ta
|
||||||
JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
|
JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
|
||||||
WHERE ta.GroupID = $GroupID
|
WHERE ta.GroupID = $GroupID
|
||||||
AND ta.Importance IN ('1', '4', '5', '6')
|
AND ta.Importance IN ('1', '4', '5', '6')
|
||||||
GROUP BY ta.GroupID");
|
GROUP BY ta.GroupID");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
|
list($ArtistName) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
} else {
|
} else {
|
||||||
$ArtistName = '';
|
$ArtistName = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
REPLACE INTO sphinx_delta
|
REPLACE INTO sphinx_delta
|
||||||
(ID, GroupID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel,
|
(ID, GroupID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel,
|
||||||
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore, Scene,
|
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore, Scene,
|
||||||
@ -522,7 +531,7 @@ public static function update_hash($GroupID) {
|
|||||||
JOIN torrents_group AS g ON g.ID = t.GroupID
|
JOIN torrents_group AS g ON g.ID = t.GroupID
|
||||||
WHERE g.ID = $GroupID");
|
WHERE g.ID = $GroupID");
|
||||||
|
|
||||||
/* $DB->query("
|
/* G::$DB->query("
|
||||||
INSERT INTO sphinx_delta
|
INSERT INTO sphinx_delta
|
||||||
(ID, ArtistName)
|
(ID, ArtistName)
|
||||||
SELECT torrents.ID, artists.ArtistName
|
SELECT torrents.ID, artists.ArtistName
|
||||||
@ -539,17 +548,18 @@ public static function update_hash($GroupID) {
|
|||||||
JOIN torrents USING(GroupID)
|
JOIN torrents USING(GroupID)
|
||||||
ON DUPLICATE KEY UPDATE ArtistName = VALUES(ArtistName)");
|
ON DUPLICATE KEY UPDATE ArtistName = VALUES(ArtistName)");
|
||||||
*/
|
*/
|
||||||
$Cache->delete_value("torrents_details_$GroupID");
|
G::$Cache->delete_value("torrents_details_$GroupID");
|
||||||
$Cache->delete_value("torrent_group_$GroupID");
|
G::$Cache->delete_value("torrent_group_$GroupID");
|
||||||
|
|
||||||
$ArtistInfo = Artists::get_artist($GroupID);
|
$ArtistInfo = Artists::get_artist($GroupID);
|
||||||
foreach ($ArtistInfo as $Importances => $Importance) {
|
foreach ($ArtistInfo as $Importances => $Importance) {
|
||||||
foreach ($Importance as $Artist) {
|
foreach ($Importance as $Artist) {
|
||||||
$Cache->delete_value('artist_groups_'.$Artist['id']); //Needed for at least freeleech change, if not others.
|
G::$Cache->delete_value('artist_groups_'.$Artist['id']); //Needed for at least freeleech change, if not others.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$Cache->delete_value("groups_artists_$GroupID");
|
G::$Cache->delete_value("groups_artists_$GroupID");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -559,16 +569,17 @@ public static function update_hash($GroupID) {
|
|||||||
* @param int $TorrentID
|
* @param int $TorrentID
|
||||||
*/
|
*/
|
||||||
public static function regenerate_filelist($TorrentID) {
|
public static function regenerate_filelist($TorrentID) {
|
||||||
global $DB, $Cache;
|
$QueryID = G::$DB->get_query_id();
|
||||||
$DB->query("
|
|
||||||
|
G::$DB->query("
|
||||||
SELECT tg.ID,
|
SELECT tg.ID,
|
||||||
tf.File
|
tf.File
|
||||||
FROM torrents_files AS tf
|
FROM torrents_files AS tf
|
||||||
JOIN torrents AS t ON t.ID = tf.TorrentID
|
JOIN torrents AS t ON t.ID = tf.TorrentID
|
||||||
JOIN torrents_group AS tg ON tg.ID = t.GroupID
|
JOIN torrents_group AS tg ON tg.ID = t.GroupID
|
||||||
WHERE tf.TorrentID = $TorrentID");
|
WHERE tf.TorrentID = $TorrentID");
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
list($GroupID, $Contents) = $DB->next_record(MYSQLI_NUM, false);
|
list($GroupID, $Contents) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
if (Misc::is_new_torrent($Contents)) {
|
if (Misc::is_new_torrent($Contents)) {
|
||||||
$Tor = new BencodeTorrent($Contents);
|
$Tor = new BencodeTorrent($Contents);
|
||||||
$FilePath = (isset($Tor->Dec['info']['files']) ? Format::make_utf8($Tor->get_name()) : '');
|
$FilePath = (isset($Tor->Dec['info']['files']) ? Format::make_utf8($Tor->get_name()) : '');
|
||||||
@ -581,12 +592,13 @@ public static function regenerate_filelist($TorrentID) {
|
|||||||
$TmpFileList[] = self::filelist_format_file($File);
|
$TmpFileList[] = self::filelist_format_file($File);
|
||||||
}
|
}
|
||||||
$FileString = implode("\n", $TmpFileList);
|
$FileString = implode("\n", $TmpFileList);
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE torrents
|
UPDATE torrents
|
||||||
SET Size = $TotalSize, FilePath = '".db_string($FilePath)."', FileList = '".db_string($FileString)."'
|
SET Size = $TotalSize, FilePath = '".db_string($FilePath)."', FileList = '".db_string($FileString)."'
|
||||||
WHERE ID = $TorrentID");
|
WHERE ID = $TorrentID");
|
||||||
$Cache->delete_value("torrents_details_$GroupID");
|
G::$Cache->delete_value("torrents_details_$GroupID");
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -714,31 +726,31 @@ public static function torrent_info($Data, $ShowMedia = false, $ShowEdition = fa
|
|||||||
* @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House
|
* @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House
|
||||||
*/
|
*/
|
||||||
public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLeechType = 0) {
|
public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLeechType = 0) {
|
||||||
global $DB, $Cache, $LoggedUser;
|
|
||||||
|
|
||||||
if (!is_array($TorrentIDs)) {
|
if (!is_array($TorrentIDs)) {
|
||||||
$TorrentIDs = array($TorrentIDs);
|
$TorrentIDs = array($TorrentIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
UPDATE torrents
|
UPDATE torrents
|
||||||
SET FreeTorrent = '$FreeNeutral', FreeLeechType = '$FreeLeechType'
|
SET FreeTorrent = '$FreeNeutral', FreeLeechType = '$FreeLeechType'
|
||||||
WHERE ID IN (".implode(', ', $TorrentIDs).')');
|
WHERE ID IN (".implode(', ', $TorrentIDs).')');
|
||||||
|
|
||||||
$DB->query('
|
G::$DB->query('
|
||||||
SELECT ID, GroupID, info_hash
|
SELECT ID, GroupID, info_hash
|
||||||
FROM torrents
|
FROM torrents
|
||||||
WHERE ID IN ('.implode(', ', $TorrentIDs).')
|
WHERE ID IN ('.implode(', ', $TorrentIDs).')
|
||||||
ORDER BY GroupID ASC');
|
ORDER BY GroupID ASC');
|
||||||
$Torrents = $DB->to_array(false, MYSQLI_NUM, false);
|
$Torrents = G::$DB->to_array(false, MYSQLI_NUM, false);
|
||||||
$GroupIDs = $DB->collect('GroupID');
|
$GroupIDs = G::$DB->collect('GroupID');
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
foreach ($Torrents as $Torrent) {
|
foreach ($Torrents as $Torrent) {
|
||||||
list($TorrentID, $GroupID, $InfoHash) = $Torrent;
|
list($TorrentID, $GroupID, $InfoHash) = $Torrent;
|
||||||
Tracker::update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral));
|
Tracker::update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral));
|
||||||
$Cache->delete_value("torrent_download_$TorrentID");
|
G::$Cache->delete_value("torrent_download_$TorrentID");
|
||||||
Misc::write_log($LoggedUser['Username']." marked torrent $TorrentID freeleech type $FreeLeechType!");
|
Misc::write_log(G::$LoggedUser['Username']." marked torrent $TorrentID freeleech type $FreeLeechType!");
|
||||||
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], "marked as freeleech type $FreeLeechType!", 0);
|
Torrents::write_group_log($GroupID, $TorrentID, G::$LoggedUser['ID'], "marked as freeleech type $FreeLeechType!", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($GroupIDs as $GroupID) {
|
foreach ($GroupIDs as $GroupID) {
|
||||||
@ -755,20 +767,21 @@ public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLe
|
|||||||
* @param int $FreeLeechType see Torrents::freeleech_torrents()
|
* @param int $FreeLeechType see Torrents::freeleech_torrents()
|
||||||
*/
|
*/
|
||||||
public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechType = 0) {
|
public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechType = 0) {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
if (!is_array($GroupIDs)) {
|
if (!is_array($GroupIDs)) {
|
||||||
$GroupIDs = array($GroupIDs);
|
$GroupIDs = array($GroupIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$DB->query('
|
G::$DB->query('
|
||||||
SELECT ID
|
SELECT ID
|
||||||
FROM torrents
|
FROM torrents
|
||||||
WHERE GroupID IN ('.implode(', ', $GroupIDs).')');
|
WHERE GroupID IN ('.implode(', ', $GroupIDs).')');
|
||||||
if ($DB->has_results()) {
|
if (G::$DB->has_results()) {
|
||||||
$TorrentIDs = $DB->collect('ID');
|
$TorrentIDs = G::$DB->collect('ID');
|
||||||
Torrents::freeleech_torrents($TorrentIDs, $FreeNeutral, $FreeLeechType);
|
Torrents::freeleech_torrents($TorrentIDs, $FreeNeutral, $FreeLeechType);
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -779,23 +792,24 @@ public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechT
|
|||||||
* @return true if an active token exists
|
* @return true if an active token exists
|
||||||
*/
|
*/
|
||||||
public static function has_token($TorrentID) {
|
public static function has_token($TorrentID) {
|
||||||
global $DB, $Cache, $LoggedUser;
|
if (empty(G::$LoggedUser)) {
|
||||||
if (empty($LoggedUser)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static $TokenTorrents;
|
static $TokenTorrents;
|
||||||
$UserID = $LoggedUser['ID'];
|
$UserID = G::$LoggedUser['ID'];
|
||||||
if (!isset($TokenTorrents)) {
|
if (!isset($TokenTorrents)) {
|
||||||
$TokenTorrents = $Cache->get_value("users_tokens_$UserID");
|
$TokenTorrents = G::$Cache->get_value("users_tokens_$UserID");
|
||||||
if ($TokenTorrents === false) {
|
if ($TokenTorrents === false) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT TorrentID
|
SELECT TorrentID
|
||||||
FROM users_freeleeches
|
FROM users_freeleeches
|
||||||
WHERE UserID = $UserID
|
WHERE UserID = $UserID
|
||||||
AND Expired = 0");
|
AND Expired = 0");
|
||||||
$TokenTorrents = array_fill_keys($DB->collect('TorrentID', false), true);
|
$TokenTorrents = array_fill_keys(G::$DB->collect('TorrentID', false), true);
|
||||||
$Cache->cache_value("users_tokens_$UserID", $TokenTorrents);
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("users_tokens_$UserID", $TokenTorrents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isset($TokenTorrents[$TorrentID]);
|
return isset($TokenTorrents[$TorrentID]);
|
||||||
@ -809,25 +823,23 @@ public static function has_token($TorrentID) {
|
|||||||
* @return boolen True if user is allowed to use a token
|
* @return boolen True if user is allowed to use a token
|
||||||
*/
|
*/
|
||||||
public static function can_use_token($Torrent) {
|
public static function can_use_token($Torrent) {
|
||||||
global $LoggedUser;
|
if (empty(G::$LoggedUser)) {
|
||||||
if (empty($LoggedUser)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ($LoggedUser['FLTokens'] > 0
|
return (G::$LoggedUser['FLTokens'] > 0
|
||||||
&& $Torrent['Size'] < 1073741824
|
&& $Torrent['Size'] < 1073741824
|
||||||
&& !$Torrent['PersonalFL']
|
&& !$Torrent['PersonalFL']
|
||||||
&& empty($Torrent['FreeTorrent'])
|
&& empty($Torrent['FreeTorrent'])
|
||||||
&& $LoggedUser['CanLeech'] == '1');
|
&& G::$LoggedUser['CanLeech'] == '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function has_snatched($TorrentID, $AllUsers = false) {
|
public static function has_snatched($TorrentID, $AllUsers = false) {
|
||||||
global $DB, $Cache, $LoggedUser;
|
if (!$AllUsers && (empty(G::$LoggedUser) || !G::$LoggedUser['ShowSnatched'])) {
|
||||||
if (!$AllUsers && (empty($LoggedUser) || !$LoggedUser['ShowSnatched'])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$UserID = $LoggedUser['ID'];
|
$UserID = G::$LoggedUser['ID'];
|
||||||
$Buckets = 64;
|
$Buckets = 64;
|
||||||
$LastBucket = $Buckets - 1;
|
$LastBucket = $Buckets - 1;
|
||||||
$BucketID = $TorrentID & $LastBucket;
|
$BucketID = $TorrentID & $LastBucket;
|
||||||
@ -835,7 +847,7 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
|
|||||||
|
|
||||||
if (empty($SnatchedTorrents)) {
|
if (empty($SnatchedTorrents)) {
|
||||||
$SnatchedTorrents = array_fill(0, $Buckets, false);
|
$SnatchedTorrents = array_fill(0, $Buckets, false);
|
||||||
$LastUpdate = $Cache->get_value("users_snatched_{$UserID}_lastupdate") ?: 0;
|
$LastUpdate = G::$Cache->get_value("users_snatched_{$UserID}_lastupdate") ?: 0;
|
||||||
} elseif (isset($SnatchedTorrents[$BucketID][$TorrentID])) {
|
} elseif (isset($SnatchedTorrents[$BucketID][$TorrentID])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -845,19 +857,20 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
|
|||||||
if ($CurSnatchedTorrents === false) {
|
if ($CurSnatchedTorrents === false) {
|
||||||
$CurTime = time();
|
$CurTime = time();
|
||||||
// This bucket hasn't been checked before
|
// This bucket hasn't been checked before
|
||||||
$CurSnatchedTorrents = $Cache->get_value("users_snatched_{$UserID}_$BucketID", true);
|
$CurSnatchedTorrents = G::$Cache->get_value("users_snatched_{$UserID}_$BucketID", true);
|
||||||
if ($CurSnatchedTorrents === false || $CurTime - $LastUpdate > 1800) {
|
if ($CurSnatchedTorrents === false || $CurTime - $LastUpdate > 1800) {
|
||||||
$Updated = array();
|
$Updated = array();
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
if ($CurSnatchedTorrents === false || $LastUpdate == 0) {
|
if ($CurSnatchedTorrents === false || $LastUpdate == 0) {
|
||||||
for ($i = 0; $i < $Buckets; $i++) {
|
for ($i = 0; $i < $Buckets; $i++) {
|
||||||
$SnatchedTorrents[$i] = array();
|
$SnatchedTorrents[$i] = array();
|
||||||
}
|
}
|
||||||
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
|
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT fid, tstamp AS TorrentID
|
SELECT fid, tstamp AS TorrentID
|
||||||
FROM xbt_snatched
|
FROM xbt_snatched
|
||||||
WHERE uid = '$UserID'");
|
WHERE uid = '$UserID'");
|
||||||
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
||||||
$SnatchedTorrents[$ID & $LastBucket][(int)$ID] = true;
|
$SnatchedTorrents[$ID & $LastBucket][(int)$ID] = true;
|
||||||
}
|
}
|
||||||
$Updated = array_fill(0, $Buckets, true);
|
$Updated = array_fill(0, $Buckets, true);
|
||||||
@ -866,15 +879,15 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Old cache, check if torrent has been snatched recently
|
// Old cache, check if torrent has been snatched recently
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT fid
|
SELECT fid
|
||||||
FROM xbt_snatched
|
FROM xbt_snatched
|
||||||
WHERE uid = '$UserID'
|
WHERE uid = '$UserID'
|
||||||
AND tstamp >= $LastUpdate");
|
AND tstamp >= $LastUpdate");
|
||||||
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
||||||
$CurBucketID = $ID & $LastBucket;
|
$CurBucketID = $ID & $LastBucket;
|
||||||
if ($SnatchedTorrents[$CurBucketID] === false) {
|
if ($SnatchedTorrents[$CurBucketID] === false) {
|
||||||
$SnatchedTorrents[$CurBucketID] = $Cache->get_value("users_snatched_{$UserID}_$CurBucketID", true);
|
$SnatchedTorrents[$CurBucketID] = G::$Cache->get_value("users_snatched_{$UserID}_$CurBucketID", true);
|
||||||
if ($SnatchedTorrents[$CurBucketID] === false) {
|
if ($SnatchedTorrents[$CurBucketID] === false) {
|
||||||
$SnatchedTorrents[$CurBucketID] = array();
|
$SnatchedTorrents[$CurBucketID] = array();
|
||||||
}
|
}
|
||||||
@ -883,12 +896,13 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
|
|||||||
$Updated[$CurBucketID] = true;
|
$Updated[$CurBucketID] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
for ($i = 0; $i < $Buckets; $i++) {
|
for ($i = 0; $i < $Buckets; $i++) {
|
||||||
if ($Updated[$i]) {
|
if ($Updated[$i]) {
|
||||||
$Cache->cache_value("users_snatched_{$UserID}_$i", $SnatchedTorrents[$i], 0);
|
G::$Cache->cache_value("users_snatched_{$UserID}_$i", $SnatchedTorrents[$i], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$Cache->cache_value("users_snatched_{$UserID}_lastupdate", $CurTime, 0);
|
G::$Cache->cache_value("users_snatched_{$UserID}_lastupdate", $CurTime, 0);
|
||||||
$LastUpdate = $CurTime;
|
$LastUpdate = $CurTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -937,6 +951,7 @@ public static function edition_string(array $Torrent, array $Group) {
|
|||||||
public static function get_reports($TorrentID) {
|
public static function get_reports($TorrentID) {
|
||||||
$Reports = G::$Cache->get_value("reports_torrent_$TorrentID");
|
$Reports = G::$Cache->get_value("reports_torrent_$TorrentID");
|
||||||
if ($Reports === false) {
|
if ($Reports === false) {
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
G::$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
r.ID,
|
r.ID,
|
||||||
@ -949,6 +964,7 @@ public static function get_reports($TorrentID) {
|
|||||||
AND Type != 'edited'
|
AND Type != 'edited'
|
||||||
AND Status != 'Resolved'");
|
AND Status != 'Resolved'");
|
||||||
$Reports = G::$DB->to_array();
|
$Reports = G::$DB->to_array();
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
G::$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
|
G::$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
|
||||||
}
|
}
|
||||||
return $Reports;
|
return $Reports;
|
||||||
|
@ -14,7 +14,7 @@ class TorrentsDL {
|
|||||||
private $NumFound = 0;
|
private $NumFound = 0;
|
||||||
private $Size = 0;
|
private $Size = 0;
|
||||||
private $Title;
|
private $Title;
|
||||||
private $Username;
|
private $User;
|
||||||
private $AnnounceURL;
|
private $AnnounceURL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,13 +25,12 @@ class TorrentsDL {
|
|||||||
* @param string $AnnounceURL URL to add to the created torrents
|
* @param string $AnnounceURL URL to add to the created torrents
|
||||||
*/
|
*/
|
||||||
public function __construct(&$QueryResult, $Title) {
|
public function __construct(&$QueryResult, $Title) {
|
||||||
global $Cache, $LoggedUser;
|
G::$Cache->InternalCache = false; // The internal cache is almost completely useless for this
|
||||||
$Cache->InternalCache = false; // The internal cache is almost completely useless for this
|
|
||||||
Zip::unlimit(); // Need more memory and longer timeout
|
Zip::unlimit(); // Need more memory and longer timeout
|
||||||
$this->QueryResult = $QueryResult;
|
$this->QueryResult = $QueryResult;
|
||||||
$this->Title = $Title;
|
$this->Title = $Title;
|
||||||
$this->User = $LoggedUser;
|
$this->User = G::$LoggedUser;
|
||||||
$this->AnnounceURL = ANNOUNCE_URL . "/$LoggedUser[torrent_pass]/announce";
|
$this->AnnounceURL = ANNOUNCE_URL . '/' . G::$LoggedUser['torrent_pass'] . '/announce';
|
||||||
$this->Zip = new Zip(Misc::file_string($Title));
|
$this->Zip = new Zip(Misc::file_string($Title));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,19 +41,18 @@ public function __construct(&$QueryResult, $Title) {
|
|||||||
* @return array with results and torrent group IDs or false if there are no results left
|
* @return array with results and torrent group IDs or false if there are no results left
|
||||||
*/
|
*/
|
||||||
public function get_downloads($Key) {
|
public function get_downloads($Key) {
|
||||||
global $DB;
|
|
||||||
$GroupIDs = $Downloads = array();
|
$GroupIDs = $Downloads = array();
|
||||||
$OldQuery = $DB->get_query_id();
|
$OldQuery = G::$DB->get_query_id();
|
||||||
$DB->set_query_id($this->QueryResult);
|
G::$DB->set_query_id($this->QueryResult);
|
||||||
if (!isset($this->IDBoundaries)) {
|
if (!isset($this->IDBoundaries)) {
|
||||||
if ($Key == 'TorrentID') {
|
if ($Key == 'TorrentID') {
|
||||||
$this->IDBoundaries = false;
|
$this->IDBoundaries = false;
|
||||||
} else {
|
} else {
|
||||||
$this->IDBoundaries = $DB->to_pair($Key, 'TorrentID', false);
|
$this->IDBoundaries = G::$DB->to_pair($Key, 'TorrentID', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$Found = 0;
|
$Found = 0;
|
||||||
while ($Download = $DB->next_record(MYSQLI_ASSOC, false)) {
|
while ($Download = G::$DB->next_record(MYSQLI_ASSOC, false)) {
|
||||||
if (!$this->IDBoundaries || $Download['TorrentID'] == $this->IDBoundaries[$Download[$Key]]) {
|
if (!$this->IDBoundaries || $Download['TorrentID'] == $this->IDBoundaries[$Download[$Key]]) {
|
||||||
$Found++;
|
$Found++;
|
||||||
$Downloads[$Download[$Key]] = $Download;
|
$Downloads[$Download[$Key]] = $Download;
|
||||||
@ -65,7 +63,7 @@ public function get_downloads($Key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->NumFound += $Found;
|
$this->NumFound += $Found;
|
||||||
$DB->set_query_id($OldQuery);
|
G::$DB->set_query_id($OldQuery);
|
||||||
if (empty($Downloads)) {
|
if (empty($Downloads)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ class Tracker {
|
|||||||
* @param boolean $ToIRC Sends a message to the channel #tracker with the GET URL.
|
* @param boolean $ToIRC Sends a message to the channel #tracker with the GET URL.
|
||||||
*/
|
*/
|
||||||
public static function update_tracker($Action, $Updates, $ToIRC = false) {
|
public static function update_tracker($Action, $Updates, $ToIRC = false) {
|
||||||
global $Cache;
|
|
||||||
//Build request
|
//Build request
|
||||||
$Get = '/update?action='.$Action;
|
$Get = '/update?action='.$Action;
|
||||||
foreach ($Updates as $Key => $Value) {
|
foreach ($Updates as $Key => $Value) {
|
||||||
@ -62,9 +61,9 @@ public static function update_tracker($Action, $Updates, $ToIRC = false) {
|
|||||||
|
|
||||||
if ($Return != "success") {
|
if ($Return != "success") {
|
||||||
send_irc("PRIVMSG #tracker :{$Attempts} {$Err} {$Get}");
|
send_irc("PRIVMSG #tracker :{$Attempts} {$Err} {$Get}");
|
||||||
if ($Cache->get_value('ocelot_error_reported') === false) {
|
if (G::$Cache->get_value('ocelot_error_reported') === false) {
|
||||||
send_irc("PRIVMSG ".ADMIN_CHAN." :Failed to update ocelot: ".$Err." : ".$Get);
|
send_irc("PRIVMSG ".ADMIN_CHAN." :Failed to update ocelot: ".$Err." : ".$Get);
|
||||||
$Cache->cache_value('ocelot_error_reported', true, 3600);
|
G::$Cache->cache_value('ocelot_error_reported', true, 3600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ($Return == "success");
|
return ($Return == "success");
|
||||||
|
@ -7,35 +7,37 @@ class UserRank {
|
|||||||
// Returns a 101 row array (101 percentiles - 0 - 100), with the minimum value for that percentile as the value for each row
|
// Returns a 101 row array (101 percentiles - 0 - 100), with the minimum value for that percentile as the value for each row
|
||||||
// BTW - ingenious
|
// BTW - ingenious
|
||||||
private static function build_table($MemKey, $Query) {
|
private static function build_table($MemKey, $Query) {
|
||||||
global $Cache, $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
DROP TEMPORARY TABLE IF EXISTS temp_stats");
|
DROP TEMPORARY TABLE IF EXISTS temp_stats");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
CREATE TEMPORARY TABLE temp_stats (
|
CREATE TEMPORARY TABLE temp_stats (
|
||||||
ID int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
ID int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
Val bigint(20) NOT NULL
|
Val bigint(20) NOT NULL
|
||||||
);");
|
);");
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
INSERT INTO temp_stats (Val) ".
|
INSERT INTO temp_stats (Val) ".
|
||||||
$Query);
|
$Query);
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM temp_stats");
|
FROM temp_stats");
|
||||||
list($UserCount) = $DB->next_record();
|
list($UserCount) = G::$DB->next_record();
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT MIN(Val)
|
SELECT MIN(Val)
|
||||||
FROM temp_stats
|
FROM temp_stats
|
||||||
GROUP BY CEIL(ID / (".(int)$UserCount." / 100));");
|
GROUP BY CEIL(ID / (".(int)$UserCount." / 100));");
|
||||||
|
|
||||||
$Table = $DB->to_array();
|
$Table = G::$DB->to_array();
|
||||||
|
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
// Give a little variation to the cache length, so all the tables don't expire at the same time
|
// Give a little variation to the cache length, so all the tables don't expire at the same time
|
||||||
$Cache->cache_value($MemKey, $Table, 3600 * 24 * rand(800, 1000) * 0.001);
|
G::$Cache->cache_value($MemKey, $Table, 3600 * 24 * rand(800, 1000) * 0.001);
|
||||||
|
|
||||||
return $Table;
|
return $Table;
|
||||||
}
|
}
|
||||||
@ -112,18 +114,17 @@ public static function get_rank($TableName, $Value) {
|
|||||||
if ($Value == 0) {
|
if ($Value == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
global $Cache, $DB;
|
|
||||||
|
|
||||||
$Table = $Cache->get_value(PREFIX.$TableName);
|
$Table = G::$Cache->get_value(PREFIX.$TableName);
|
||||||
if (!$Table) {
|
if (!$Table) {
|
||||||
//Cache lock!
|
//Cache lock!
|
||||||
$Lock = $Cache->get_value(PREFIX.$TableName.'_lock');
|
$Lock = G::$Cache->get_value(PREFIX.$TableName.'_lock');
|
||||||
if ($Lock) {
|
if ($Lock) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$Cache->cache_value(PREFIX.$TableName.'_lock', '1', 300);
|
G::$Cache->cache_value(PREFIX.$TableName.'_lock', '1', 300);
|
||||||
$Table = self::build_table(PREFIX.$TableName, self::table_query($TableName));
|
$Table = self::build_table(PREFIX.$TableName, self::table_query($TableName));
|
||||||
$Cache->delete_value(PREFIX.$TableName.'_lock');
|
G::$Cache->delete_value(PREFIX.$TableName.'_lock');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$LastPercentile = 0;
|
$LastPercentile = 0;
|
||||||
|
@ -6,17 +6,19 @@ class Users {
|
|||||||
* @return array ($Classes, $ClassLevels)
|
* @return array ($Classes, $ClassLevels)
|
||||||
*/
|
*/
|
||||||
public static function get_classes() {
|
public static function get_classes() {
|
||||||
global $Cache, $DB, $Debug;
|
global $Debug;
|
||||||
// Get permissions
|
// Get permissions
|
||||||
list($Classes, $ClassLevels) = $Cache->get_value('classes');
|
list($Classes, $ClassLevels) = G::$Cache->get_value('classes');
|
||||||
if (!$Classes || !$ClassLevels) {
|
if (!$Classes || !$ClassLevels) {
|
||||||
$DB->query('
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query('
|
||||||
SELECT ID, Name, Level, Secondary
|
SELECT ID, Name, Level, Secondary
|
||||||
FROM permissions
|
FROM permissions
|
||||||
ORDER BY Level');
|
ORDER BY Level');
|
||||||
$Classes = $DB->to_array('ID');
|
$Classes = G::$DB->to_array('ID');
|
||||||
$ClassLevels = $DB->to_array('Level');
|
$ClassLevels = G::$DB->to_array('Level');
|
||||||
$Cache->cache_value('classes', array($Classes, $ClassLevels), 0);
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('classes', array($Classes, $ClassLevels), 0);
|
||||||
}
|
}
|
||||||
$Debug->set_flag('Loaded permissions');
|
$Debug->set_flag('Loaded permissions');
|
||||||
|
|
||||||
@ -45,13 +47,12 @@ public static function get_classes() {
|
|||||||
* int EffectiveClass - the highest level of their main and secondary classes
|
* int EffectiveClass - the highest level of their main and secondary classes
|
||||||
*/
|
*/
|
||||||
public static function user_info($UserID) {
|
public static function user_info($UserID) {
|
||||||
global $DB, $Cache, $Classes, $SSL;
|
global $Classes, $SSL;
|
||||||
$UserInfo = $Cache->get_value("user_info_$UserID");
|
$UserInfo = G::$Cache->get_value("user_info_$UserID");
|
||||||
// the !isset($UserInfo['Paranoia']) can be removed after a transition period
|
// the !isset($UserInfo['Paranoia']) can be removed after a transition period
|
||||||
if (empty($UserInfo) || empty($UserInfo['ID']) || !isset($UserInfo['Paranoia']) || empty($UserInfo['Class'])) {
|
if (empty($UserInfo) || empty($UserInfo['ID']) || !isset($UserInfo['Paranoia']) || empty($UserInfo['Class'])) {
|
||||||
$OldQueryID = $DB->get_query_id();
|
$OldQueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
$DB->query("
|
|
||||||
SELECT
|
SELECT
|
||||||
m.ID,
|
m.ID,
|
||||||
m.Username,
|
m.Username,
|
||||||
@ -71,11 +72,12 @@ public static function user_info($UserID) {
|
|||||||
LEFT JOIN users_levels AS ul ON ul.UserID = m.ID
|
LEFT JOIN users_levels AS ul ON ul.UserID = m.ID
|
||||||
WHERE m.ID = '$UserID'
|
WHERE m.ID = '$UserID'
|
||||||
GROUP BY m.ID");
|
GROUP BY m.ID");
|
||||||
if (!$DB->has_results()) { // Deleted user, maybe?
|
if (!G::$DB->has_results()) { // Deleted user, maybe?
|
||||||
$UserInfo = array(
|
$UserInfo = array(
|
||||||
'ID' => '',
|
'ID' => $UserID,
|
||||||
'Username' => '',
|
'Username' => '',
|
||||||
'PermissionID' => 0,
|
'PermissionID' => 0,
|
||||||
|
'Paranoia' => array(),
|
||||||
'Artist' => false,
|
'Artist' => false,
|
||||||
'Donor' => false,
|
'Donor' => false,
|
||||||
'Warned' => '0000-00-00 00:00:00',
|
'Warned' => '0000-00-00 00:00:00',
|
||||||
@ -83,10 +85,10 @@ public static function user_info($UserID) {
|
|||||||
'Enabled' => 0,
|
'Enabled' => 0,
|
||||||
'Title' => '',
|
'Title' => '',
|
||||||
'CatchupTime' => 0,
|
'CatchupTime' => 0,
|
||||||
'Visible' => '1');
|
'Visible' => '1',
|
||||||
|
'Levels' => '');
|
||||||
} else {
|
} else {
|
||||||
$UserInfo = $DB->next_record(MYSQLI_ASSOC, array('Paranoia', 'Title'));
|
$UserInfo = G::$DB->next_record(MYSQLI_ASSOC, array('Paranoia', 'Title'));
|
||||||
$UserInfo['CatchupTime'] = strtotime($UserInfo['CatchupTime']);
|
$UserInfo['CatchupTime'] = strtotime($UserInfo['CatchupTime']);
|
||||||
$UserInfo['Paranoia'] = unserialize($UserInfo['Paranoia']);
|
$UserInfo['Paranoia'] = unserialize($UserInfo['Paranoia']);
|
||||||
if ($UserInfo['Paranoia'] === false) {
|
if ($UserInfo['Paranoia'] === false) {
|
||||||
@ -109,12 +111,12 @@ public static function user_info($UserID) {
|
|||||||
}
|
}
|
||||||
$UserInfo['EffectiveClass'] = $EffectiveClass;
|
$UserInfo['EffectiveClass'] = $EffectiveClass;
|
||||||
|
|
||||||
$Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
|
G::$Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
|
||||||
$DB->set_query_id($OldQueryID);
|
G::$DB->set_query_id($OldQueryID);
|
||||||
}
|
}
|
||||||
if (strtotime($UserInfo['Warned']) < time()) {
|
if (strtotime($UserInfo['Warned']) < time()) {
|
||||||
$UserInfo['Warned'] = '0000-00-00 00:00:00';
|
$UserInfo['Warned'] = '0000-00-00 00:00:00';
|
||||||
$Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
|
G::$Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $UserInfo;
|
return $UserInfo;
|
||||||
@ -129,12 +131,12 @@ public static function user_info($UserID) {
|
|||||||
* Just read the goddamn code, I don't have time to comment this shit.
|
* Just read the goddamn code, I don't have time to comment this shit.
|
||||||
*/
|
*/
|
||||||
public static function user_heavy_info($UserID) {
|
public static function user_heavy_info($UserID) {
|
||||||
global $DB, $Cache;
|
|
||||||
|
|
||||||
$HeavyInfo = $Cache->get_value("user_info_heavy_$UserID");
|
$HeavyInfo = G::$Cache->get_value("user_info_heavy_$UserID");
|
||||||
if (empty($HeavyInfo)) {
|
if (empty($HeavyInfo)) {
|
||||||
|
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
m.Invites,
|
m.Invites,
|
||||||
m.torrent_pass,
|
m.torrent_pass,
|
||||||
@ -154,7 +156,7 @@ public static function user_heavy_info($UserID) {
|
|||||||
i.DisablePM,
|
i.DisablePM,
|
||||||
i.DisableRequests,
|
i.DisableRequests,
|
||||||
i.DisableForums,
|
i.DisableForums,
|
||||||
i.DisableTagging,
|
i.DisableTagging," . "
|
||||||
i.SiteOptions,
|
i.SiteOptions,
|
||||||
i.DownloadAlt,
|
i.DownloadAlt,
|
||||||
i.LastReadNews,
|
i.LastReadNews,
|
||||||
@ -166,7 +168,7 @@ public static function user_heavy_info($UserID) {
|
|||||||
FROM users_main AS m
|
FROM users_main AS m
|
||||||
INNER JOIN users_info AS i ON i.UserID = m.ID
|
INNER JOIN users_info AS i ON i.UserID = m.ID
|
||||||
WHERE m.ID = '$UserID'");
|
WHERE m.ID = '$UserID'");
|
||||||
$HeavyInfo = $DB->next_record(MYSQLI_ASSOC, array('CustomPermissions', 'SiteOptions'));
|
$HeavyInfo = G::$DB->next_record(MYSQLI_ASSOC, array('CustomPermissions', 'SiteOptions'));
|
||||||
|
|
||||||
if (!empty($HeavyInfo['CustomPermissions'])) {
|
if (!empty($HeavyInfo['CustomPermissions'])) {
|
||||||
$HeavyInfo['CustomPermissions'] = unserialize($HeavyInfo['CustomPermissions']);
|
$HeavyInfo['CustomPermissions'] = unserialize($HeavyInfo['CustomPermissions']);
|
||||||
@ -187,11 +189,11 @@ public static function user_heavy_info($UserID) {
|
|||||||
}
|
}
|
||||||
unset($HeavyInfo['PermittedForums']);
|
unset($HeavyInfo['PermittedForums']);
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT PermissionID
|
SELECT PermissionID
|
||||||
FROM users_levels
|
FROM users_levels
|
||||||
WHERE UserID = $UserID");
|
WHERE UserID = $UserID");
|
||||||
$PermIDs = $DB->collect('PermissionID');
|
$PermIDs = G::$DB->collect('PermissionID');
|
||||||
foreach ($PermIDs AS $PermID) {
|
foreach ($PermIDs AS $PermID) {
|
||||||
$Perms = Permissions::get_permissions($PermID);
|
$Perms = Permissions::get_permissions($PermID);
|
||||||
if (!empty($Perms['PermittedForums'])) {
|
if (!empty($Perms['PermittedForums'])) {
|
||||||
@ -225,7 +227,9 @@ public static function user_heavy_info($UserID) {
|
|||||||
}
|
}
|
||||||
unset($HeavyInfo['SiteOptions']);
|
unset($HeavyInfo['SiteOptions']);
|
||||||
|
|
||||||
$Cache->cache_value("user_info_heavy_$UserID", $HeavyInfo, 0);
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
|
G::$Cache->cache_value("user_info_heavy_$UserID", $HeavyInfo, 0);
|
||||||
}
|
}
|
||||||
return $HeavyInfo;
|
return $HeavyInfo;
|
||||||
}
|
}
|
||||||
@ -244,14 +248,15 @@ public static function update_site_options($UserID, $NewOptions) {
|
|||||||
if (empty($NewOptions)) {
|
if (empty($NewOptions)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
global $DB, $Cache, $LoggedUser;
|
|
||||||
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
// Get SiteOptions
|
// Get SiteOptions
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT SiteOptions
|
SELECT SiteOptions
|
||||||
FROM users_info
|
FROM users_info
|
||||||
WHERE UserID = $UserID");
|
WHERE UserID = $UserID");
|
||||||
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
|
list($SiteOptions) = G::$DB->next_record(MYSQLI_NUM, false);
|
||||||
$SiteOptions = unserialize($SiteOptions);
|
$SiteOptions = unserialize($SiteOptions);
|
||||||
|
|
||||||
// Get HeavyInfo
|
// Get HeavyInfo
|
||||||
@ -262,18 +267,19 @@ public static function update_site_options($UserID, $NewOptions) {
|
|||||||
$HeavyInfo = array_merge($HeavyInfo, $NewOptions);
|
$HeavyInfo = array_merge($HeavyInfo, $NewOptions);
|
||||||
|
|
||||||
// Update DB
|
// Update DB
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
UPDATE users_info
|
UPDATE users_info
|
||||||
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
|
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
|
||||||
WHERE UserID = $UserID");
|
WHERE UserID = $UserID");
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
|
|
||||||
// Update cache
|
// Update cache
|
||||||
$Cache->cache_value("user_info_heavy_$UserID", $HeavyInfo, 0);
|
G::$Cache->cache_value("user_info_heavy_$UserID", $HeavyInfo, 0);
|
||||||
|
|
||||||
// Update $LoggedUser if the options are changed for the current
|
// Update G::$LoggedUser if the options are changed for the current
|
||||||
if ($LoggedUser['ID'] == $UserID) {
|
if (G::$LoggedUser['ID'] == $UserID) {
|
||||||
$LoggedUser = array_merge($LoggedUser, $NewOptions);
|
G::$LoggedUser = array_merge(G::$LoggedUser, $NewOptions);
|
||||||
$LoggedUser['ID'] = $UserID; // We don't want to allow userid switching
|
G::$LoggedUser['ID'] = $UserID; // We don't want to allow userid switching
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -448,8 +454,8 @@ public static function gen_crypt_salt() {
|
|||||||
* @param boolean $Title whether or not to show the title
|
* @param boolean $Title whether or not to show the title
|
||||||
* @return HTML formatted username
|
* @return HTML formatted username
|
||||||
*/
|
*/
|
||||||
public static function format_username($UserID, $Badges = false, $IsWarned = true, $IsEnabled = true, $Class = false, $Title = false) {
|
public static function format_username($UserID, $Badges = false, $IsWarned = true, $IsEnabled = true, $Class = false, $Title = false, $IsDonorForum = false) {
|
||||||
global $Classes, $LoggedUser;
|
global $Classes;
|
||||||
|
|
||||||
// This array is a hack that should be made less retarded, but whatevs
|
// This array is a hack that should be made less retarded, but whatevs
|
||||||
// PermID => ShortForm
|
// PermID => ShortForm
|
||||||
@ -467,28 +473,58 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru
|
|||||||
|
|
||||||
$Str = '';
|
$Str = '';
|
||||||
|
|
||||||
|
$Username = $UserInfo['Username'];
|
||||||
|
$Paranoia = $UserInfo['Paranoia'];
|
||||||
|
$ShowDonorIcon = !in_array('hide_donor_heart', $Paranoia);
|
||||||
|
|
||||||
|
if ($IsDonorForum) {
|
||||||
|
list($Prefix, $Suffix, $HasComma) = Donations::get_titles($UserID);
|
||||||
|
$Username = "$Prefix $Username" . ($HasComma ? ', ' : ' ') . "$Suffix ";
|
||||||
|
}
|
||||||
|
|
||||||
if ($Title) {
|
if ($Title) {
|
||||||
$Str .= '<strong><a href="user.php?id='.$UserID.'">'.$UserInfo['Username'].'</a></strong>';
|
$Str .= "<strong><a href=\"user.php?id=$UserID\">$Username</a></strong>";
|
||||||
} else {
|
} else {
|
||||||
$Str .= '<a href="user.php?id='.$UserID.'">'.$UserInfo['Username'].'</a>';
|
$Str .= "<a href=\"user.php?id=$UserID\">$Username</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Badges) {
|
if ($Badges) {
|
||||||
$Str .= ($UserInfo['Donor'] == 1) ? '<a href="donate.php"><img src="'.STATIC_SERVER.'common/symbols/donor.png" alt="Donor" title="Donor" /></a>' : '';
|
$DonorRank = Donations::get_rank($UserID);
|
||||||
|
$SpecialRank = Donations::get_special_rank($UserID);
|
||||||
|
if ($DonorRank >= 2 && $ShowDonorIcon) {
|
||||||
|
$DonorRewards = Donations::get_rewards($UserID);
|
||||||
|
$IconText = $DonorRewards['IconMouseOverText'];
|
||||||
|
$IconLink = 'donate.php';
|
||||||
|
$IconImage = 'donor.png';
|
||||||
|
$DonorRank = $DonorRank == 5 ? ($DonorRank - 1) : $DonorRank;
|
||||||
|
if ($DonorRank >= MAX_RANK || $SpecialRank >= MAX_SPECIAL_RANK) {
|
||||||
|
$IconLink = !empty($DonorRewards['CustomIconLink']) ? $DonorRewards['CustomIconLink'] : 'donate.php';
|
||||||
|
if ($SpecialRank >= MAX_SPECIAL_RANK) {
|
||||||
|
$DonorHeart = 6;
|
||||||
|
} else {
|
||||||
|
$DonorHeart = 5;
|
||||||
|
}
|
||||||
|
$IconImage = !empty($DonorRewards['CustomIcon']) ? ImageTools::process($DonorRewards['CustomIcon']) : STATIC_SERVER . "common/symbols/donor_$DonorHeart" . '.png';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$IconImage = STATIC_SERVER . "common/symbols/donor_$DonorRank" . '.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
$Str .= (($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? '<a href="wiki.php?action=article&id=218"'
|
$Str .= "<a href=\"$IconLink\"><img class=\"donor_icon\" src=\"$IconImage\" alt=\"$IconText\" title=\"$IconText\" /></a>";
|
||||||
|
} elseif (($DonorRank == 1 || $UserInfo['Donor'] == 1) && $ShowDonorIcon) {
|
||||||
|
$Str .= '<a href="donate.php"><img src="'.STATIC_SERVER.'common/symbols/donor.png" alt="Donor" title="Donor" /></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Str .= ($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? '<a href="wiki.php?action=article&id=218"'
|
||||||
. '><img src="'.STATIC_SERVER.'common/symbols/warned.png" alt="Warned" title="Warned'
|
. '><img src="'.STATIC_SERVER.'common/symbols/warned.png" alt="Warned" title="Warned'
|
||||||
. ($LoggedUser['ID'] === $UserID ? ' - Expires ' . date('Y-m-d H:i', strtotime($UserInfo['Warned'])) : '')
|
. (G::$LoggedUser['ID'] === $UserID ? ' - Expires ' . date('Y-m-d H:i', strtotime($UserInfo['Warned'])) : '')
|
||||||
. '" /></a>' : '');
|
. '" /></a>' : '';
|
||||||
$Str .= (($IsEnabled && $UserInfo['Enabled'] == 2) ? '<a href="rules.php"><img src="'.STATIC_SERVER.'common/symbols/disabled.png" alt="Banned" title="Be good, and you won\'t end up like this user" /></a>' : '');
|
$Str .= ($IsEnabled && $UserInfo['Enabled'] == 2) ? '<a href="rules.php"><img src="'.STATIC_SERVER.'common/symbols/disabled.png" alt="Banned" title="Be good, and you won\'t end up like this user" /></a>' : '';
|
||||||
|
|
||||||
if ($Badges) {
|
if ($Badges) {
|
||||||
$ClassesDisplay = array();
|
$ClassesDisplay = array();
|
||||||
foreach ($SecondaryClasses as $PermID => $PermHTML) {
|
foreach (array_intersect_key($SecondaryClasses, $UserInfo['ExtraClasses']) as $PermID => $PermShort) {
|
||||||
if ($UserInfo['ExtraClasses'][$PermID]) {
|
$ClassesDisplay[] = '<span class="secondary_class" title="'.$Classes[$PermID]['Name'].'">'.$PermShort.'</span>';
|
||||||
$ClassesDisplay[] = '<span class="secondary_class" title="'.$Classes[$PermID]['Name'].'">'.$PermHTML.'</span>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!empty($ClassesDisplay)) {
|
if (!empty($ClassesDisplay)) {
|
||||||
$Str .= ' '.implode(' ', $ClassesDisplay);
|
$Str .= ' '.implode(' ', $ClassesDisplay);
|
||||||
@ -532,29 +568,26 @@ public static function make_class_string($ClassID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array with User Bookmark data: group ids, collage data, torrent data
|
* Returns an array with User Bookmark data: group IDs, collage data, torrent data
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @param string|int $UserID
|
* @param string|int $UserID
|
||||||
* @return array Group IDs, Bookmark Data, Torrent List
|
* @return array Group IDs, Bookmark Data, Torrent List
|
||||||
*/
|
*/
|
||||||
public static function get_bookmarks ($UserID)
|
public static function get_bookmarks($UserID) {
|
||||||
{
|
|
||||||
global $Cache, $DB;
|
|
||||||
|
|
||||||
$UserID = (int) $UserID;
|
$UserID = (int) $UserID;
|
||||||
|
|
||||||
if (($Data = $Cache->get_value("bookmarks_group_ids_$UserID"))) {
|
if (($Data = G::$Cache->get_value("bookmarks_group_ids_$UserID"))) {
|
||||||
list($GroupIDs, $BookmarkData) = $Data;
|
list($GroupIDs, $BookmarkData) = $Data;
|
||||||
} else {
|
} else {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT GroupID, Sort, `Time`
|
SELECT GroupID, Sort, `Time`
|
||||||
FROM bookmarks_torrents
|
FROM bookmarks_torrents
|
||||||
WHERE UserID = $UserID
|
WHERE UserID = $UserID
|
||||||
ORDER BY Sort, `Time` ASC");
|
ORDER BY Sort, `Time` ASC");
|
||||||
$GroupIDs = $DB->collect('GroupID');
|
$GroupIDs = G::$DB->collect('GroupID');
|
||||||
$BookmarkData = $DB->to_array('GroupID', MYSQLI_ASSOC);
|
$BookmarkData = G::$DB->to_array('GroupID', MYSQLI_ASSOC);
|
||||||
$Cache->cache_value("bookmarks_group_ids_$UserID",
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("bookmarks_group_ids_$UserID",
|
||||||
array($GroupIDs, $BookmarkData), 3600);
|
array($GroupIDs, $BookmarkData), 3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,23 +606,39 @@ public static function get_bookmarks ($UserID)
|
|||||||
* @param string $ReturnHTML
|
* @param string $ReturnHTML
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function show_avatar($Avatar, $Username, $Setting, $Size = 150, $ReturnHTML = True) {
|
public static function show_avatar($Avatar, $UserID, $Username, $Setting, $Size = 150, $ReturnHTML = True) {
|
||||||
global $LoggedUser;
|
|
||||||
$Avatar = ImageTools::process($Avatar);
|
$Avatar = ImageTools::process($Avatar);
|
||||||
|
$Style = 'style="max-height: 400px;"';
|
||||||
|
$AvatarMouseOverText = '';
|
||||||
|
$SecondAvatar = '';
|
||||||
|
$Class = 'class="double_avatar"';
|
||||||
|
$EnabledRewards = Donations::get_enabled_rewards($UserID);
|
||||||
|
|
||||||
|
if ($EnabledRewards['HasAvatarMouseOverText']) {
|
||||||
|
$Rewards = Donations::get_rewards($UserID);
|
||||||
|
$AvatarMouseOverText = $Rewards['AvatarMouseOverText'];
|
||||||
|
}
|
||||||
|
if (!empty($AvatarMouseOverText)) {
|
||||||
|
$AvatarMouseOverText = "title=\"$AvatarMouseOverText\" alt=\"$AvatarMouseOverText\"";
|
||||||
|
}
|
||||||
|
if ($EnabledRewards['HasSecondAvatar'] && !empty($Rewards['SecondAvatar'])) {
|
||||||
|
$SecondAvatar = 'data-gazelle-second-avatar="' . ImageTools::process($Rewards['SecondAvatar']) . '"';
|
||||||
|
}
|
||||||
// case 1 is avatars disabled
|
// case 1 is avatars disabled
|
||||||
switch ($Setting) {
|
switch ($Setting) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!empty($Avatar)) {
|
if (!empty($Avatar)) {
|
||||||
$ToReturn = ($ReturnHTML ? "<img src=\"$Avatar\" width=\"$Size\" style=\"max-height: 400px;\" alt=\"$Username avatar\" />" : $Avatar);
|
$ToReturn = ($ReturnHTML ? "<img src=\"$Avatar\" width=\"$Size\" $Style $AvatarMouseOverText $SecondAvatar $Class />" : $Avatar);
|
||||||
} else {
|
} else {
|
||||||
$URL = STATIC_SERVER.'common/avatars/default.png';
|
$URL = STATIC_SERVER.'common/avatars/default.png';
|
||||||
$ToReturn = ($ReturnHTML ? "<img src=\"$URL\" width=\"$Size\" style=\"max-height: 400px;\" alt=\"Default avatar\" />" : $URL);
|
//TODO: what is the $JS variable for? why is it unassigned?
|
||||||
|
$ToReturn = ($ReturnHTML ? "<img src=\"$URL\" width=\"$Size\" $Style $AvatarMouseOverText $SecondAvatar $JS />" : $URL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$ShowAvatar = True;
|
$ShowAvatar = true;
|
||||||
case 3:
|
case 3:
|
||||||
switch ($LoggedUser['Identicons']) {
|
switch (G::$LoggedUser['Identicons']) {
|
||||||
case 0:
|
case 0:
|
||||||
$Type = 'identicon';
|
$Type = 'identicon';
|
||||||
break;
|
break;
|
||||||
@ -604,15 +653,15 @@ public static function show_avatar($Avatar, $Username, $Setting, $Size = 150, $R
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$Type = '1';
|
$Type = '1';
|
||||||
$Robot = True;
|
$Robot = true;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
$Type = '2';
|
$Type = '2';
|
||||||
$Robot = True;
|
$Robot = true;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$Type = '3';
|
$Type = '3';
|
||||||
$Robot = True;
|
$Robot = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$Type = 'identicon';
|
$Type = 'identicon';
|
||||||
@ -623,15 +672,15 @@ public static function show_avatar($Avatar, $Username, $Setting, $Size = 150, $R
|
|||||||
} else {
|
} else {
|
||||||
$URL = 'https://robohash.org/'.md5($Username)."?set=set$Type&size={$Size}x$Size";
|
$URL = 'https://robohash.org/'.md5($Username)."?set=set$Type&size={$Size}x$Size";
|
||||||
}
|
}
|
||||||
if ($ShowAvatar == True && !empty($Avatar)) {
|
if ($ShowAvatar == true && !empty($Avatar)) {
|
||||||
$ToReturn = ($ReturnHTML ? "<img src=\"$Avatar\" width=\"$Size\" style=\"max-height: 400px;\" alt=\"$Username avatar\" />" : $Avatar);
|
$ToReturn = ($ReturnHTML ? "<img src=\"$Avatar\" width=\"$Size\" $Style $AvatarMouseOverText $SecondAvatar $Class/>" : $Avatar);
|
||||||
} else {
|
} else {
|
||||||
$ToReturn = ($ReturnHTML ? "<img src=\"$URL\" width=\"$Size\" style=\"max-height: 400px;\" alt=\"Default avatar\" />" : $URL);
|
$ToReturn = ($ReturnHTML ? "<img src=\"$URL\" width=\"$Size\" $Style $AvatarMouseOverText $SecondAvatar $Class/>" : $URL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$URL = STATIC_SERVER.'common/avatars/default.png';
|
$URL = STATIC_SERVER.'common/avatars/default.png';
|
||||||
$ToReturn = ($ReturnHTML ? "<img src=\"$URL\" width=\"$Size\" style=\"max-height: 400px;\" alt=\"Default avatar\" />" : $URL);
|
$ToReturn = ($ReturnHTML ? "<img src=\"$URL\" width=\"$Size\" $Style $AvatarMouseOverText $SecondAvatar $Class/>" : $URL);
|
||||||
}
|
}
|
||||||
return $ToReturn;
|
return $ToReturn;
|
||||||
}
|
}
|
||||||
@ -651,19 +700,18 @@ public static function has_avatars_enabled() {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function has_autocomplete_enabled($Type, $Output = true) {
|
public static function has_autocomplete_enabled($Type, $Output = true) {
|
||||||
global $LoggedUser;
|
|
||||||
$Enabled = false;
|
$Enabled = false;
|
||||||
if (empty($LoggedUser['AutoComplete'])) {
|
if (empty(G::$LoggedUser['AutoComplete'])) {
|
||||||
$Enabled = true;
|
$Enabled = true;
|
||||||
} elseif ($LoggedUser['AutoComplete'] !== 1) {
|
} elseif (G::$LoggedUser['AutoComplete'] !== 1) {
|
||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
case 'search':
|
case 'search':
|
||||||
if ($LoggedUser['AutoComplete'] == 2) {
|
if (G::$LoggedUser['AutoComplete'] == 2) {
|
||||||
$Enabled = true;
|
$Enabled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'other':
|
case 'other':
|
||||||
if ($LoggedUser['AutoComplete'] != 2) {
|
if (G::$LoggedUser['AutoComplete'] != 2) {
|
||||||
$Enabled = true;
|
$Enabled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -13,8 +13,8 @@ class View {
|
|||||||
* the page. ONLY PUT THE RELATIVE LOCATION WITHOUT '.js'
|
* the page. ONLY PUT THE RELATIVE LOCATION WITHOUT '.js'
|
||||||
* example: 'somefile,somedir/somefile'
|
* example: 'somefile,somedir/somefile'
|
||||||
*/
|
*/
|
||||||
public static function show_header($PageTitle = '', $JSIncludes = '') {
|
public static function show_header($PageTitle = '', $JSIncludes = '', $CSSIncludes = '') {
|
||||||
global $Document, $Cache, $DB, $LoggedUser, $Mobile, $Classes;
|
global $Document, $Mobile, $Classes;
|
||||||
|
|
||||||
if ($PageTitle != '') {
|
if ($PageTitle != '') {
|
||||||
$PageTitle .= ' :: ';
|
$PageTitle .= ' :: ';
|
||||||
@ -26,7 +26,7 @@ public static function show_header($PageTitle = '', $JSIncludes = '') {
|
|||||||
empty($_REQUEST['type']) ? false : $_REQUEST['type'] // Type
|
empty($_REQUEST['type']) ? false : $_REQUEST['type'] // Type
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_array($LoggedUser) || empty($LoggedUser['ID'])) {
|
if (!is_array(G::$LoggedUser) || empty(G::$LoggedUser['ID'])) {
|
||||||
require(SERVER_ROOT.'/design/publicheader.php');
|
require(SERVER_ROOT.'/design/publicheader.php');
|
||||||
} else {
|
} else {
|
||||||
require(SERVER_ROOT.'/design/privateheader.php');
|
require(SERVER_ROOT.'/design/privateheader.php');
|
||||||
@ -42,8 +42,8 @@ public static function show_header($PageTitle = '', $JSIncludes = '') {
|
|||||||
* ['disclaimer'] = [boolean] (False) Displays the disclaimer in the footer
|
* ['disclaimer'] = [boolean] (False) Displays the disclaimer in the footer
|
||||||
*/
|
*/
|
||||||
public static function show_footer ($Options = array()) {
|
public static function show_footer ($Options = array()) {
|
||||||
global $ScriptStartTime, $LoggedUser, $Cache, $DB, $SessionID, $UserSessions, $Debug, $Time;
|
global $ScriptStartTime, $SessionID, $UserSessions, $Debug, $Time;
|
||||||
if (!is_array($LoggedUser)) {
|
if (!is_array(G::$LoggedUser)) {
|
||||||
require(SERVER_ROOT.'/design/publicfooter.php');
|
require(SERVER_ROOT.'/design/publicfooter.php');
|
||||||
} else {
|
} else {
|
||||||
require(SERVER_ROOT.'/design/privatefooter.php');
|
require(SERVER_ROOT.'/design/privatefooter.php');
|
||||||
|
@ -2,72 +2,66 @@
|
|||||||
class Votes {
|
class Votes {
|
||||||
/**
|
/**
|
||||||
* Generate voting links for torrent pages, etc.
|
* Generate voting links for torrent pages, etc.
|
||||||
* @global $LoggedUser
|
|
||||||
* @param $GroupID
|
* @param $GroupID
|
||||||
* @param $Vote The pre-existing vote, if it exists 'Up'|'Down'
|
* @param $Vote The pre-existing vote, if it exists 'Up'|'Down'
|
||||||
*/
|
*/
|
||||||
public static function vote_link($GroupID, $Vote = '') {
|
public static function vote_link($GroupID, $Vote = '') {
|
||||||
global $LoggedUser;
|
if (!G::$LoggedUser['NoVoteLinks'] && check_perms('site_album_votes')) { ?>
|
||||||
if (!$LoggedUser['NoVoteLinks'] && check_perms('site_album_votes')) { ?>
|
|
||||||
<span class="votespan brackets" style="white-space: nowrap;">
|
<span class="votespan brackets" style="white-space: nowrap;">
|
||||||
Vote:
|
Vote:
|
||||||
<a href="#" onclick="UpVoteGroup(<?=$GroupID?>, '<?=$LoggedUser['AuthKey']?>'); return false;" class="small_upvote vote_link_<?=$GroupID?><?=(!empty($Vote) ? ' hidden' : '')?>" title="Upvote">↑</a>
|
<a href="#" onclick="UpVoteGroup(<?=$GroupID?>, '<?=G::$LoggedUser['AuthKey']?>'); return false;" class="tooltip small_upvote vote_link_<?=$GroupID?><?=(!empty($Vote) ? ' hidden' : '')?>" title="Upvote">↑</a>
|
||||||
<span class="voted_type small_upvoted voted_up_<?=$GroupID?><?=(($Vote == 'Down' || empty($Vote)) ? ' hidden' : '')?>" title="Upvoted">↑</span>
|
<span class="tooltip voted_type small_upvoted voted_up_<?=$GroupID?><?=(($Vote == 'Down' || empty($Vote)) ? ' hidden' : '')?>" title="Upvoted">↑</span>
|
||||||
<a href="#" onclick="DownVoteGroup(<?=$GroupID?>, '<?=$LoggedUser['AuthKey']?>'); return false;" class="small_downvote vote_link_<?=$GroupID?><?=(!empty($Vote) ? ' hidden' : '')?>" title="Downvote">↓</a>
|
<a href="#" onclick="DownVoteGroup(<?=$GroupID?>, '<?=G::$LoggedUser['AuthKey']?>'); return false;" class="tooltip small_downvote vote_link_<?=$GroupID?><?=(!empty($Vote) ? ' hidden' : '')?>" title="Downvote">↓</a>
|
||||||
<span class="voted_type small_downvoted voted_down_<?=$GroupID?><?=(($Vote == 'Up' || empty($Vote)) ? ' hidden' : '')?>" title="Downvoted">↓</span>
|
<span class="tooltip voted_type small_downvoted voted_down_<?=$GroupID?><?=(($Vote == 'Up' || empty($Vote)) ? ' hidden' : '')?>" title="Downvoted">↓</span>
|
||||||
<a href="#" onclick="UnvoteGroup(<?=$GroupID?>, '<?=$LoggedUser['AuthKey']?>'); return false;" class="small_clearvote vote_clear_<?=$GroupID?><?=(empty($Vote) ? ' hidden' : '')?>" title="Clear your vote">x</a>
|
<a href="#" onclick="UnvoteGroup(<?=$GroupID?>, '<?=G::$LoggedUser['AuthKey']?>'); return false;" class="tooltip small_clearvote vote_clear_<?=$GroupID?><?=(empty($Vote) ? ' hidden' : '')?>" title="Clear your vote">x</a>
|
||||||
</span>
|
</span>
|
||||||
<? }
|
<? }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array with User Vote data: GroupID and vote type
|
* Returns an array with User Vote data: GroupID and vote type
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @param string|int $UserID
|
* @param string|int $UserID
|
||||||
* @return array GroupID=>(GroupID, 'Up'|'Down')
|
* @return array GroupID=>(GroupID, 'Up'|'Down')
|
||||||
*/
|
*/
|
||||||
public static function get_user_votes($UserID) {
|
public static function get_user_votes($UserID) {
|
||||||
global $DB, $Cache;
|
|
||||||
|
|
||||||
if ((int)$UserID == 0) {
|
if ((int)$UserID == 0) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$UserVotes = $Cache->get_value("voted_albums_$UserID");
|
$UserVotes = G::$Cache->get_value("voted_albums_$UserID");
|
||||||
if ($UserVotes === false) {
|
if ($UserVotes === false) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT GroupID, Type
|
SELECT GroupID, Type
|
||||||
FROM users_votes
|
FROM users_votes
|
||||||
WHERE UserID = $UserID");
|
WHERE UserID = $UserID");
|
||||||
$UserVotes = $DB->to_array('GroupID', MYSQL_ASSOC, false);
|
$UserVotes = G::$DB->to_array('GroupID', MYSQL_ASSOC, false);
|
||||||
$Cache->cache_value("voted_albums_$UserID", $UserVotes);
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("voted_albums_$UserID", $UserVotes);
|
||||||
}
|
}
|
||||||
return $UserVotes;
|
return $UserVotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array with torrent group vote data
|
* Returns an array with torrent group vote data
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @param string|int $GroupID
|
* @param string|int $GroupID
|
||||||
* @return array (Upvotes, Total Votes)
|
* @return array (Upvotes, Total Votes)
|
||||||
*/
|
*/
|
||||||
public static function get_group_votes($GroupID) {
|
public static function get_group_votes($GroupID) {
|
||||||
global $DB, $Cache;
|
$GroupVotes = G::$Cache->get_value("votes_$GroupID");
|
||||||
|
|
||||||
$GroupVotes = $Cache->get_value("votes_$GroupID");
|
|
||||||
if ($GroupVotes === false) {
|
if ($GroupVotes === false) {
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT Ups AS Ups, Total AS Total
|
SELECT Ups AS Ups, Total AS Total
|
||||||
FROM torrents_votes
|
FROM torrents_votes
|
||||||
WHERE GroupID = $GroupID");
|
WHERE GroupID = $GroupID");
|
||||||
if (!$DB->has_results()) {
|
if (!G::$DB->has_results()) {
|
||||||
$GroupVotes = array('Ups' => 0, 'Total' => 0);
|
$GroupVotes = array('Ups' => 0, 'Total' => 0);
|
||||||
} else {
|
} else {
|
||||||
$GroupVotes = $DB->next_record(MYSQLI_ASSOC, false);
|
$GroupVotes = G::$DB->next_record(MYSQLI_ASSOC, false);
|
||||||
}
|
}
|
||||||
$Cache->cache_value("votes_$GroupID", $GroupVotes, 259200); // 3 days
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("votes_$GroupID", $GroupVotes, 259200); // 3 days
|
||||||
}
|
}
|
||||||
return $GroupVotes;
|
return $GroupVotes;
|
||||||
}
|
}
|
||||||
@ -198,32 +192,30 @@ public static function get_ranking($GroupID, $Year) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets where this album ranks overall.
|
* Gets where this album ranks overall.
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @param int $GroupID GroupID of the album
|
* @param int $GroupID GroupID of the album
|
||||||
* @return int Rank
|
* @return int Rank
|
||||||
*/
|
*/
|
||||||
public static function get_rank_all($GroupID) {
|
public static function get_rank_all($GroupID) {
|
||||||
global $Cache, $DB;
|
|
||||||
|
|
||||||
$GroupID = (int)$GroupID;
|
$GroupID = (int)$GroupID;
|
||||||
if ($GroupID <= 0) {
|
if ($GroupID <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Rankings = $Cache->get_value('voting_ranks_overall');
|
$Rankings = G::$Cache->get_value('voting_ranks_overall');
|
||||||
if ($Rankings === false) {
|
if ($Rankings === false) {
|
||||||
$Rankings = array();
|
$Rankings = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$DB->query('
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query('
|
||||||
SELECT GroupID
|
SELECT GroupID
|
||||||
FROM torrents_votes
|
FROM torrents_votes
|
||||||
ORDER BY Score DESC
|
ORDER BY Score DESC
|
||||||
LIMIT 100');
|
LIMIT 100');
|
||||||
while (list($GID) = $DB->next_record()) {
|
while (list($GID) = G::$DB->next_record()) {
|
||||||
$Rankings[$GID] = ++$i;
|
$Rankings[$GID] = ++$i;
|
||||||
}
|
}
|
||||||
$Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days
|
||||||
}
|
}
|
||||||
|
|
||||||
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
|
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
|
||||||
@ -231,36 +223,34 @@ public static function get_rank_all($GroupID) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets where this album ranks in its year.
|
* Gets where this album ranks in its year.
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @param int $GroupID GroupID of the album
|
* @param int $GroupID GroupID of the album
|
||||||
* @param int $Year Year it was released
|
* @param int $Year Year it was released
|
||||||
* @return int Rank for its year
|
* @return int Rank for its year
|
||||||
*/
|
*/
|
||||||
public static function get_rank_year($GroupID, $Year) {
|
public static function get_rank_year($GroupID, $Year) {
|
||||||
global $Cache, $DB;
|
|
||||||
|
|
||||||
$GroupID = (int)$GroupID;
|
$GroupID = (int)$GroupID;
|
||||||
$Year = (int)$Year;
|
$Year = (int)$Year;
|
||||||
if ($GroupID <= 0 || $Year <= 0) {
|
if ($GroupID <= 0 || $Year <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Rankings = $Cache->get_value("voting_ranks_year_$Year");
|
$Rankings = G::$Cache->get_value("voting_ranks_year_$Year");
|
||||||
if ($Rankings === false) {
|
if ($Rankings === false) {
|
||||||
$Rankings = array();
|
$Rankings = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT GroupID
|
SELECT GroupID
|
||||||
FROM torrents_votes AS v
|
FROM torrents_votes AS v
|
||||||
JOIN torrents_group AS g ON g.ID = v.GroupID
|
JOIN torrents_group AS g ON g.ID = v.GroupID
|
||||||
WHERE g.Year = $Year
|
WHERE g.Year = $Year
|
||||||
ORDER BY Score DESC
|
ORDER BY Score DESC
|
||||||
LIMIT 100");
|
LIMIT 100");
|
||||||
while (list($GID) = $DB->next_record()) {
|
while (list($GID) = G::$DB->next_record()) {
|
||||||
$Rankings[$GID] = ++$i;
|
$Rankings[$GID] = ++$i;
|
||||||
}
|
}
|
||||||
$Cache->cache_value("voting_ranks_year_$Year", $Rankings, 259200); // 3 days
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("voting_ranks_year_$Year", $Rankings, 259200); // 3 days
|
||||||
}
|
}
|
||||||
|
|
||||||
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
|
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
|
||||||
@ -268,30 +258,26 @@ public static function get_rank_year($GroupID, $Year) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets where this album ranks in its decade.
|
* Gets where this album ranks in its decade.
|
||||||
* @global CACHE $Cache
|
|
||||||
* @global DB_MYSQL $DB
|
|
||||||
* @param int $GroupID GroupID of the album
|
* @param int $GroupID GroupID of the album
|
||||||
* @param int $Year Year it was released
|
* @param int $Year Year it was released
|
||||||
* @return int Rank for its year
|
* @return int Rank for its year
|
||||||
*/
|
*/
|
||||||
public static function get_rank_decade($GroupID, $Year) {
|
public static function get_rank_decade($GroupID, $Year) {
|
||||||
global $Cache, $DB;
|
|
||||||
|
|
||||||
$GroupID = (int)$GroupID;
|
$GroupID = (int)$GroupID;
|
||||||
$Year = (int)$Year;
|
$Year = (int)$Year;
|
||||||
$Year = (int)$Year;
|
if ($GroupID <= 0 || $Year <= 0) {
|
||||||
if ((int)$GroupID <= 0 || (int)$Year <= 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First year of the decade
|
// First year of the decade
|
||||||
$Year = $Year - ($Year % 10);
|
$Year = $Year - ($Year % 10);
|
||||||
|
|
||||||
$Rankings = $Cache->get_value("voting_ranks_decade_$Year");
|
$Rankings = G::$Cache->get_value("voting_ranks_decade_$Year");
|
||||||
if ($Rankings === false) {
|
if ($Rankings === false) {
|
||||||
$Rankings = array();
|
$Rankings = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$DB->query("
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
G::$DB->query("
|
||||||
SELECT GroupID
|
SELECT GroupID
|
||||||
FROM torrents_votes AS v
|
FROM torrents_votes AS v
|
||||||
JOIN torrents_group AS g ON g.ID = v.GroupID
|
JOIN torrents_group AS g ON g.ID = v.GroupID
|
||||||
@ -299,10 +285,11 @@ public static function get_rank_decade($GroupID, $Year) {
|
|||||||
AND g.CategoryID = 1
|
AND g.CategoryID = 1
|
||||||
ORDER BY Score DESC
|
ORDER BY Score DESC
|
||||||
LIMIT 100");
|
LIMIT 100");
|
||||||
while (list($GID) = $DB->next_record()) {
|
while (list($GID) = G::$DB->next_record()) {
|
||||||
$Rankings[$GID] = ++$i;
|
$Rankings[$GID] = ++$i;
|
||||||
}
|
}
|
||||||
$Cache->cache_value("voting_ranks_decade_$Year", $Rankings, 259200); // 3 days
|
G::$DB->set_query_id($QueryID);
|
||||||
|
G::$Cache->cache_value("voting_ranks_decade_$Year", $Rankings, 259200); // 3 days
|
||||||
}
|
}
|
||||||
|
|
||||||
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
|
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
|
||||||
|
@ -33,9 +33,9 @@
|
|||||||
class Wiki {
|
class Wiki {
|
||||||
|
|
||||||
public static function revision_history($Table = '', $PageID = 0, $BaseURL = '') {
|
public static function revision_history($Table = '', $PageID = 0, $BaseURL = '') {
|
||||||
global $DB;
|
$QueryID = G::$DB->get_query_id();
|
||||||
|
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
RevisionID,
|
RevisionID,
|
||||||
Summary,
|
Summary,
|
||||||
@ -54,7 +54,7 @@ public static function revision_history($Table = '', $PageID = 0, $BaseURL = '')
|
|||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
$Row = 'a';
|
$Row = 'a';
|
||||||
while (list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()) {
|
while (list($RevisionID, $Summary, $Time, $UserID, $Username) = G::$DB->next_record()) {
|
||||||
$Row = (($Row == 'a') ? 'b' : 'a');
|
$Row = (($Row == 'a') ? 'b' : 'a');
|
||||||
?>
|
?>
|
||||||
<tr class="row<?=$Row?>">
|
<tr class="row<?=$Row?>">
|
||||||
@ -74,6 +74,7 @@ public static function revision_history($Table = '', $PageID = 0, $BaseURL = '')
|
|||||||
<? } // while ?>
|
<? } // while ?>
|
||||||
</table>
|
</table>
|
||||||
<?
|
<?
|
||||||
|
G::$DB->set_query_id($QueryID);
|
||||||
} // function
|
} // function
|
||||||
} // class
|
} // class
|
||||||
?>
|
?>
|
||||||
|
@ -21,7 +21,11 @@
|
|||||||
?>
|
?>
|
||||||
<p>Site and design © <?=date('Y')?> <?=SITE_NAME?></p>
|
<p>Site and design © <?=date('Y')?> <?=SITE_NAME?></p>
|
||||||
<? if (!empty($LastActive)) { ?>
|
<? if (!empty($LastActive)) { ?>
|
||||||
<p><a href="user.php?action=sessions" title="Manage sessions">Last activity <?=time_diff($LastActive['LastUpdate'])?> from <?=$LastActive['IP']?>.</a></p>
|
<p>
|
||||||
|
<a href="user.php?action=sessions">
|
||||||
|
<span class="tooltip" title="Manage sessions">Last activity </span><?=time_diff($LastActive['LastUpdate'])?><span class="tooltip" title="Manage sessions"> from <?=$LastActive['IP']?>.</span>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<p>
|
<p>
|
||||||
<strong>Time:</strong> <?=number_format(((microtime(true) - $ScriptStartTime) * 1000), 5)?> ms
|
<strong>Time:</strong> <?=number_format(((microtime(true) - $ScriptStartTime) * 1000), 5)?> ms
|
||||||
|
@ -10,106 +10,92 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<link rel="shortcut icon" href="favicon.ico" />
|
<link rel="shortcut icon" href="favicon.ico" />
|
||||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Torrents" href="opensearch.php?type=torrents" />
|
||||||
title="<?=SITE_NAME?> Torrents" href="opensearch.php?type=torrents" />
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Artists" href="opensearch.php?type=artists" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Requests" href="opensearch.php?type=requests" />
|
||||||
title="<?=SITE_NAME?> Artists" href="opensearch.php?type=artists" />
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Forums" href="opensearch.php?type=forums" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Log" href="opensearch.php?type=log" />
|
||||||
title="<?=SITE_NAME?> Requests" href="opensearch.php?type=requests" />
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Users" href="opensearch.php?type=users" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
<link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?> Wiki" href="opensearch.php?type=wiki" />
|
||||||
title="<?=SITE_NAME?> Forums" href="opensearch.php?type=forums" />
|
<link rel="alternate" type="application/rss+xml" href="feeds.php?feed=feed_news&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>" title="<?=SITE_NAME?> - News" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
<link rel="alternate" type="application/rss+xml" href="feeds.php?feed=feed_blog&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>" title="<?=SITE_NAME?> - Blog" />
|
||||||
title="<?=SITE_NAME?> Log" href="opensearch.php?type=log" />
|
<link rel="alternate" type="application/rss+xml" href="feeds.php?feed=feed_changelog&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>" title="<?=SITE_NAME?> - Gazelle Change Log" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
<link rel="alternate" type="application/rss+xml" href="feeds.php?feed=torrents_notify_<?=G::$LoggedUser['torrent_pass']?>&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>" title="<?=SITE_NAME?> - P.T.N." />
|
||||||
title="<?=SITE_NAME?> Users" href="opensearch.php?type=users" />
|
|
||||||
<link rel="search" type="application/opensearchdescription+xml"
|
|
||||||
title="<?=SITE_NAME?> Wiki" href="opensearch.php?type=wiki" />
|
|
||||||
<link rel="alternate" type="application/rss+xml"
|
|
||||||
href="feeds.php?feed=feed_news&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
|
||||||
title="<?=SITE_NAME?> - News" />
|
|
||||||
<link rel="alternate" type="application/rss+xml"
|
|
||||||
href="feeds.php?feed=feed_blog&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
|
||||||
title="<?=SITE_NAME?> - Blog" />
|
|
||||||
<link rel="alternate" type="application/rss+xml"
|
|
||||||
href="feeds.php?feed=feed_changelog&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
|
||||||
title="<?=SITE_NAME?> - Gazelle Change Log" />
|
|
||||||
<link rel="alternate" type="application/rss+xml"
|
|
||||||
href="feeds.php?feed=torrents_notify_<?=$LoggedUser['torrent_pass']?>&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
|
||||||
title="<?=SITE_NAME?> - P.T.N." />
|
|
||||||
<?
|
<?
|
||||||
if (isset($LoggedUser['Notify'])) {
|
if (isset(G::$LoggedUser['Notify'])) {
|
||||||
foreach ($LoggedUser['Notify'] as $Filter) {
|
foreach (G::$LoggedUser['Notify'] as $Filter) {
|
||||||
list($FilterID, $FilterName) = $Filter;
|
list($FilterID, $FilterName) = $Filter;
|
||||||
?>
|
?>
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml" href="feeds.php?feed=torrents_notify_<?=$FilterID?>_<?=G::$LoggedUser['torrent_pass']?>&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>&name=<?=urlencode($FilterName)?>" title="<?=SITE_NAME?> - <?=display_str($FilterName)?>" />
|
||||||
href="feeds.php?feed=torrents_notify_<?=$FilterID?>_<?=$LoggedUser['torrent_pass']?>&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>&name=<?=urlencode($FilterName)?>"
|
|
||||||
title="<?=SITE_NAME?> - <?=display_str($FilterName)?>" />
|
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$UseTooltipster = !isset(G::$LoggedUser['Tooltipster']) || G::$LoggedUser['Tooltipster'];
|
||||||
?>
|
?>
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_all&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_all&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - All Torrents" />
|
title="<?=SITE_NAME?> - All Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_music&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_music&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Music Torrents" />
|
title="<?=SITE_NAME?> - Music Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_apps&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_apps&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Application Torrents" />
|
title="<?=SITE_NAME?> - Application Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_ebooks&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_ebooks&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - E-Book Torrents" />
|
title="<?=SITE_NAME?> - E-Book Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_abooks&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_abooks&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Audiobooks Torrents" />
|
title="<?=SITE_NAME?> - Audiobooks Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_evids&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_evids&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - E-Learning Video Torrents" />
|
title="<?=SITE_NAME?> - E-Learning Video Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_comedy&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_comedy&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Comedy Torrents" />
|
title="<?=SITE_NAME?> - Comedy Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_comics&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_comics&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Comic Torrents" />
|
title="<?=SITE_NAME?> - Comic Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_mp3&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_mp3&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - MP3 Torrents" />
|
title="<?=SITE_NAME?> - MP3 Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_flac&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_flac&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - FLAC Torrents" />
|
title="<?=SITE_NAME?> - FLAC Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_vinyl&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_vinyl&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Vinyl Sourced Torrents" />
|
title="<?=SITE_NAME?> - Vinyl Sourced Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_lossless&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_lossless&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - Lossless Torrents" />
|
title="<?=SITE_NAME?> - Lossless Torrents" />
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
href="feeds.php?feed=torrents_lossless24&user=<?=$LoggedUser['ID']?>&auth=<?=$LoggedUser['RSS_Auth']?>&passkey=<?=$LoggedUser['torrent_pass']?>&authkey=<?=$LoggedUser['AuthKey']?>"
|
href="feeds.php?feed=torrents_lossless24&user=<?=G::$LoggedUser['ID']?>&auth=<?=G::$LoggedUser['RSS_Auth']?>&passkey=<?=G::$LoggedUser['torrent_pass']?>&authkey=<?=G::$LoggedUser['AuthKey']?>"
|
||||||
title="<?=SITE_NAME?> - 24bit Lossless Torrents" />
|
title="<?=SITE_NAME?> - 24bit Lossless Torrents" />
|
||||||
|
|
||||||
<link
|
<link
|
||||||
href="<?=STATIC_SERVER?>styles/global.css?v=<?=filemtime(SERVER_ROOT.'/static/styles/global.css')?>"
|
href="<?=STATIC_SERVER?>styles/global.css?v=<?=filemtime(SERVER_ROOT.'/static/styles/global.css')?>"
|
||||||
rel="stylesheet" type="text/css" />
|
rel="stylesheet" type="text/css" />
|
||||||
<? if ($Mobile) { ?>
|
<? if ($UseTooltipster) { ?>
|
||||||
|
<link rel="stylesheet" href="<?=STATIC_SERVER?>styles/tooltipster/style.css" type="text/css" media="screen"/>
|
||||||
|
<? }
|
||||||
|
if ($Mobile) { ?>
|
||||||
<meta name="viewport"
|
<meta name="viewport"
|
||||||
content="width=device-width; initial-scale=1.0; maximum-scale=1.0, user-scalable=no;" />
|
content="width=device-width; initial-scale=1.0; maximum-scale=1.0, user-scalable=no;" />
|
||||||
<link href="<?=STATIC_SERVER ?>styles/mobile/style.css" rel="stylesheet"
|
<link href="<?=STATIC_SERVER ?>styles/mobile/style.css" rel="stylesheet"
|
||||||
type="text/css" />
|
type="text/css" />
|
||||||
<?
|
<?
|
||||||
} else {
|
} else {
|
||||||
if (empty($LoggedUser['StyleURL'])) {
|
if (empty(G::$LoggedUser['StyleURL'])) {
|
||||||
?>
|
?>
|
||||||
<link
|
<link
|
||||||
href="<?=STATIC_SERVER?>styles/<?=$LoggedUser['StyleName']?>/style.css?v=<?=filemtime(SERVER_ROOT.'/static/styles/'.$LoggedUser['StyleName'].'/style.css')?>"
|
href="<?=STATIC_SERVER?>styles/<?=G::$LoggedUser['StyleName']?>/style.css?v=<?=filemtime(SERVER_ROOT.'/static/styles/'.G::$LoggedUser['StyleName'].'/style.css')?>"
|
||||||
title="<?=$LoggedUser['StyleName']?>" rel="stylesheet" type="text/css"
|
title="<?=G::$LoggedUser['StyleName']?>" rel="stylesheet" type="text/css"
|
||||||
media="screen" />
|
media="screen" />
|
||||||
<? } else { ?>
|
<? } else { ?>
|
||||||
<link href="<?=$LoggedUser['StyleURL']?>" title="External CSS"
|
<link href="<?=G::$LoggedUser['StyleURL']?>" title="External CSS"
|
||||||
rel="stylesheet" type="text/css" media="screen" />
|
rel="stylesheet" type="text/css" media="screen" />
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
if ($LoggedUser['UseOpenDyslexic']) {
|
if (!empty(G::$LoggedUser['UseOpenDyslexic'])) {
|
||||||
// load the OpenDyslexic font ?>
|
// load the OpenDyslexic font ?>
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
href="<?=STATIC_SERVER?>styles/opendyslexic/style.css?v=<?=filemtime(SERVER_ROOT.'/static/styles/opendyslexic/style.css')?>"
|
href="<?=STATIC_SERVER?>styles/opendyslexic/style.css?v=<?=filemtime(SERVER_ROOT.'/static/styles/opendyslexic/style.css')?>"
|
||||||
@ -119,7 +105,14 @@
|
|||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
$ExtraCSS = explode(',', $CSSIncludes);
|
||||||
|
foreach ($ExtraCSS as $CSS) {
|
||||||
|
if (empty($CSS)) {
|
||||||
|
continue;
|
||||||
|
} ?>
|
||||||
|
<link rel="stylesheet" href="<?=STATIC_SERVER?>styles/<?=$CSS?>/style.css" type="text/css" media="screen"/>
|
||||||
|
<?
|
||||||
|
} ?>
|
||||||
|
|
||||||
<script src="<?=STATIC_SERVER?>functions/jquery.js"
|
<script src="<?=STATIC_SERVER?>functions/jquery.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
@ -130,8 +123,8 @@
|
|||||||
src="<?=STATIC_SERVER?>functions/ajax.class.js?v=<?=filemtime(SERVER_ROOT.'/static/functions/ajax.class.js')?>"
|
src="<?=STATIC_SERVER?>functions/ajax.class.js?v=<?=filemtime(SERVER_ROOT.'/static/functions/ajax.class.js')?>"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
var authkey = "<?=$LoggedUser['AuthKey']?>";
|
var authkey = "<?=G::$LoggedUser['AuthKey']?>";
|
||||||
var userid = <?=$LoggedUser['ID']?>;
|
var userid = <?=G::$LoggedUser['ID']?>;
|
||||||
//]]></script>
|
//]]></script>
|
||||||
<script
|
<script
|
||||||
src="<?=STATIC_SERVER?>functions/global.js?v=<?=filemtime(SERVER_ROOT.'/static/functions/global.js')?>"
|
src="<?=STATIC_SERVER?>functions/global.js?v=<?=filemtime(SERVER_ROOT.'/static/functions/global.js')?>"
|
||||||
@ -140,8 +133,14 @@
|
|||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="<?=STATIC_SERVER?>functions/autocomplete.js"
|
<script src="<?=STATIC_SERVER?>functions/autocomplete.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
|
<? if ($UseTooltipster) { ?>
|
||||||
|
<script src="<?=STATIC_SERVER?>functions/tooltipster.js"
|
||||||
|
type="text/javascript"></script>
|
||||||
|
<? } ?>
|
||||||
|
<script src="<?=STATIC_SERVER?>functions/tooltipster_settings.js"
|
||||||
|
type="text/javascript"></script>
|
||||||
<?
|
<?
|
||||||
|
NotificationsManagerView::load_js();
|
||||||
|
|
||||||
$Scripts = explode(',', $JSIncludes);
|
$Scripts = explode(',', $JSIncludes);
|
||||||
foreach ($Scripts as $Script) {
|
foreach ($Scripts as $Script) {
|
||||||
@ -173,12 +172,12 @@
|
|||||||
<ul id="userinfo_username">
|
<ul id="userinfo_username">
|
||||||
<li id="nav_userinfo"
|
<li id="nav_userinfo"
|
||||||
<?=Format::add_class($PageID, array('user',false,false), 'active', true, 'id')?>><a
|
<?=Format::add_class($PageID, array('user',false,false), 'active', true, 'id')?>><a
|
||||||
href="user.php?id=<?=$LoggedUser['ID']?>" class="username"><?=$LoggedUser['Username']?></a></li>
|
href="user.php?id=<?=G::$LoggedUser['ID']?>" class="username"><?=G::$LoggedUser['Username']?></a></li>
|
||||||
<li id="nav_useredit"
|
<li id="nav_useredit"
|
||||||
class="brackets<?=Format::add_class($PageID, array('user','edit'), 'active', false)?>"><a
|
class="brackets<?=Format::add_class($PageID, array('user','edit'), 'active', false)?>"><a
|
||||||
href="user.php?action=edit&userid=<?=$LoggedUser['ID']?>">Edit</a></li>
|
href="user.php?action=edit&userid=<?=G::$LoggedUser['ID']?>">Edit</a></li>
|
||||||
<li id="nav_logout" class="brackets"><a
|
<li id="nav_logout" class="brackets"><a
|
||||||
href="logout.php?auth=<?=$LoggedUser['AuthKey']?>">Logout</a></li>
|
href="logout.php?auth=<?=G::$LoggedUser['AuthKey']?>">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="userinfo_major">
|
<ul id="userinfo_major">
|
||||||
<li id="nav_upload"
|
<li id="nav_upload"
|
||||||
@ -187,8 +186,8 @@ class="brackets<?=Format::add_class($PageID, array('upload'), 'active', false)?>
|
|||||||
<?
|
<?
|
||||||
if (check_perms('site_send_unlimited_invites')) {
|
if (check_perms('site_send_unlimited_invites')) {
|
||||||
$Invites = ' (∞)';
|
$Invites = ' (∞)';
|
||||||
} elseif ($LoggedUser['Invites'] > 0) {
|
} elseif (G::$LoggedUser['Invites'] > 0) {
|
||||||
$Invites = ' ('.$LoggedUser['Invites'].')';
|
$Invites = ' ('.G::$LoggedUser['Invites'].')';
|
||||||
} else {
|
} else {
|
||||||
$Invites = '';
|
$Invites = '';
|
||||||
}
|
}
|
||||||
@ -203,49 +202,26 @@ class="brackets<?=Format::add_class($PageID, array('donate'), 'active', false)?>
|
|||||||
</ul>
|
</ul>
|
||||||
<ul id="userinfo_stats">
|
<ul id="userinfo_stats">
|
||||||
<li id="stats_seeding"><a
|
<li id="stats_seeding"><a
|
||||||
href="torrents.php?type=seeding&userid=<?=$LoggedUser['ID']?>">Up</a>:
|
href="torrents.php?type=seeding&userid=<?=G::$LoggedUser['ID']?>">Up</a>:
|
||||||
<span class="stat"
|
<span class="stat"
|
||||||
title="<?=Format::get_size($LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span></li>
|
title="<?=Format::get_size(G::$LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesUploaded'])?></span></li>
|
||||||
<li id="stats_leeching"><a
|
<li id="stats_leeching"><a
|
||||||
href="torrents.php?type=leeching&userid=<?=$LoggedUser['ID']?>">Down</a>:
|
href="torrents.php?type=leeching&userid=<?=G::$LoggedUser['ID']?>">Down</a>:
|
||||||
<span class="stat"
|
<span class="stat"
|
||||||
title="<?=Format::get_size($LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesDownloaded'])?></span></li>
|
title="<?=Format::get_size(G::$LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesDownloaded'])?></span></li>
|
||||||
<li id="stats_ratio">Ratio: <span class="stat"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span></li>
|
<li id="stats_ratio">Ratio: <span class="stat"><?=Format::get_ratio_html(G::$LoggedUser['BytesUploaded'], G::$LoggedUser['BytesDownloaded'])?></span></li>
|
||||||
<? if (!empty($LoggedUser['RequiredRatio'])) { ?>
|
<? if (!empty(G::$LoggedUser['RequiredRatio'])) { ?>
|
||||||
<li id="stats_required"><a href="rules.php?p=ratio">Required</a>: <span
|
<li id="stats_required"><a href="rules.php?p=ratio">Required</a>: <span
|
||||||
class="stat"
|
class="stat"
|
||||||
title="<?=number_format($LoggedUser['RequiredRatio'], 5)?>"><?=number_format($LoggedUser['RequiredRatio'], 2)?></span></li>
|
title="<?=number_format(G::$LoggedUser['RequiredRatio'], 5)?>"><?=number_format(G::$LoggedUser['RequiredRatio'], 2)?></span></li>
|
||||||
<? }
|
<? }
|
||||||
if ($LoggedUser['FLTokens'] > 0) { ?>
|
if (G::$LoggedUser['FLTokens'] > 0) { ?>
|
||||||
<li id="fl_tokens"><a href="wiki.php?action=article&id=754">Tokens</a>:
|
<li id="fl_tokens"><a href="wiki.php?action=article&id=754">Tokens</a>:
|
||||||
<span class="stat"><a
|
<span class="stat"><a
|
||||||
href="userhistory.php?action=token_history&userid=<?=$LoggedUser['ID']?>"><?=$LoggedUser['FLTokens']?></a></span></li>
|
href="userhistory.php?action=token_history&userid=<?=G::$LoggedUser['ID']?>"><?=G::$LoggedUser['FLTokens']?></a></span></li>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?
|
<ul id="userinfo_minor">
|
||||||
$NewSubscriptions = $Cache->get_value('subscriptions_user_new_'.$LoggedUser['ID']);
|
|
||||||
if ($NewSubscriptions === false) {
|
|
||||||
if ($LoggedUser['CustomForums']) {
|
|
||||||
unset($LoggedUser['CustomForums']['']);
|
|
||||||
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
|
|
||||||
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
|
|
||||||
}
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(s.TopicID)
|
|
||||||
FROM users_subscriptions AS s
|
|
||||||
JOIN forums_last_read_topics AS l ON s.UserID = l.UserID AND s.TopicID = l.TopicID
|
|
||||||
JOIN forums_topics AS t ON l.TopicID = t.ID
|
|
||||||
JOIN forums AS f ON t.ForumID = f.ID
|
|
||||||
WHERE (f.MinClassRead <= ".$LoggedUser['Class']." OR f.ID IN ('$PermittedForums'))
|
|
||||||
AND l.PostID < t.LastPostID
|
|
||||||
AND s.UserID = ".$LoggedUser['ID'].
|
|
||||||
(!empty($RestrictedForums) ? "
|
|
||||||
AND f.ID NOT IN ('$RestrictedForums')" : ''));
|
|
||||||
list($NewSubscriptions) = $DB->next_record();
|
|
||||||
$Cache->cache_value('subscriptions_user_new_'.$LoggedUser['ID'], $NewSubscriptions, 0);
|
|
||||||
} ?>
|
|
||||||
<ul id="userinfo_minor"
|
|
||||||
<?=($NewSubscriptions ? ' class="highlite"' : '')?>>
|
|
||||||
<li id="nav_inbox"
|
<li id="nav_inbox"
|
||||||
<?=Format::add_class($PageID, array('inbox'), 'active', true)?>><a
|
<?=Format::add_class($PageID, array('inbox'), 'active', true)?>><a
|
||||||
onmousedown="Stats('inbox');"
|
onmousedown="Stats('inbox');"
|
||||||
@ -256,7 +232,7 @@ class="stat"
|
|||||||
<li id="nav_uploaded"
|
<li id="nav_uploaded"
|
||||||
<?=Format::add_class($PageID, array('torrents',false,'uploaded'), 'active', true, 'userid')?>><a
|
<?=Format::add_class($PageID, array('torrents',false,'uploaded'), 'active', true, 'userid')?>><a
|
||||||
onmousedown="Stats('uploads');"
|
onmousedown="Stats('uploads');"
|
||||||
href="torrents.php?type=uploaded&userid=<?=$LoggedUser['ID']?>">Uploads</a></li>
|
href="torrents.php?type=uploaded&userid=<?=G::$LoggedUser['ID']?>">Uploads</a></li>
|
||||||
<li id="nav_bookmarks"
|
<li id="nav_bookmarks"
|
||||||
<?=Format::add_class($PageID, array('bookmarks'), 'active', true)?>><a
|
<?=Format::add_class($PageID, array('bookmarks'), 'active', true)?>><a
|
||||||
onmousedown="Stats('bookmarks');"
|
onmousedown="Stats('bookmarks');"
|
||||||
@ -270,8 +246,7 @@ class="stat"
|
|||||||
<li id="nav_subscriptions"
|
<li id="nav_subscriptions"
|
||||||
<?=Format::add_class($PageID, array('userhistory','subscriptions'), 'active', true)?>><a
|
<?=Format::add_class($PageID, array('userhistory','subscriptions'), 'active', true)?>><a
|
||||||
onmousedown="Stats('subscriptions');"
|
onmousedown="Stats('subscriptions');"
|
||||||
href="userhistory.php?action=subscriptions"
|
href="userhistory.php?action=subscriptions">Subscriptions</a></li>
|
||||||
<?=($NewSubscriptions ? ' class="new-subscriptions"' : '')?>>Subscriptions</a></li>
|
|
||||||
<li id="nav_comments"
|
<li id="nav_comments"
|
||||||
<?=Format::add_class($PageID, array('comments'), 'active', true, 'userid')?>><a
|
<?=Format::add_class($PageID, array('comments'), 'active', true, 'userid')?>><a
|
||||||
onmousedown="Stats('comments');" href="comments.php">Comments</a></li>
|
onmousedown="Stats('comments');" href="comments.php">Comments</a></li>
|
||||||
@ -320,220 +295,91 @@ class="stat"
|
|||||||
$Alerts = array();
|
$Alerts = array();
|
||||||
$ModBar = array();
|
$ModBar = array();
|
||||||
|
|
||||||
//Quotes
|
$NotificationsManager = new NotificationsManager(G::$LoggedUser['ID'], false, false, false);
|
||||||
if ($LoggedUser['NotifyOnQuote']) {
|
|
||||||
$QuoteNotificationsCount = $Cache->get_value('notify_quoted_'.$LoggedUser['ID']);
|
|
||||||
if ($QuoteNotificationsCount === false) {
|
|
||||||
if ($LoggedUser['CustomForums']) {
|
|
||||||
unset($LoggedUser['CustomForums']['']);
|
|
||||||
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
|
|
||||||
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
|
|
||||||
}
|
|
||||||
$sql = "
|
|
||||||
SELECT COUNT(q.UnRead)
|
|
||||||
FROM users_notify_quoted AS q
|
|
||||||
LEFT JOIN forums_topics AS t ON t.ID = q.PageID
|
|
||||||
LEFT JOIN forums AS f ON f.ID = t.ForumID
|
|
||||||
WHERE q.UserID = $LoggedUser[ID]
|
|
||||||
AND q.UnRead = 1
|
|
||||||
AND q.Page = 'forums'
|
|
||||||
AND ((f.MinClassRead <= '$LoggedUser[Class]'";
|
|
||||||
if (!empty($RestrictedForums)) {
|
|
||||||
$sql .= " AND f.ID NOT IN ('$RestrictedForums')";
|
|
||||||
}
|
|
||||||
$sql .= ')';
|
|
||||||
if (!empty($PermittedForums)) {
|
|
||||||
$sql .= " OR f.ID IN ('$PermittedForums')";
|
|
||||||
}
|
|
||||||
$sql .= ')';
|
|
||||||
$DB->query($sql);
|
|
||||||
list($QuoteNotificationsCount) = $DB->next_record();
|
|
||||||
$Cache->cache_value('notify_quoted_'.$LoggedUser['ID'], $QuoteNotificationsCount, 0);
|
|
||||||
}
|
|
||||||
if ($QuoteNotificationsCount > 0) {
|
|
||||||
$Alerts[] = '<a href="userhistory.php?action=quote_notifications">'. 'New quote'. ($QuoteNotificationsCount > 1 ? 's' : '') . '</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// News
|
|
||||||
$MyNews = $LoggedUser['LastReadNews'];
|
|
||||||
$CurrentNews = $Cache->get_value('news_latest_id');
|
|
||||||
if ($CurrentNews === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT ID
|
|
||||||
FROM news
|
|
||||||
ORDER BY Time DESC
|
|
||||||
LIMIT 1");
|
|
||||||
if ($DB->record_count() === 1) {
|
|
||||||
list($CurrentNews) = $DB->next_record();
|
|
||||||
} else {
|
|
||||||
$CurrentNews = -1;
|
|
||||||
}
|
|
||||||
$Cache->cache_value('news_latest_id', $CurrentNews, 0);
|
|
||||||
}
|
|
||||||
if ($MyNews < $CurrentNews) {
|
|
||||||
$Alerts[] = '<a href="index.php">New announcement!</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Blog
|
|
||||||
$MyBlog = $LoggedUser['LastReadBlog'];
|
|
||||||
$CurrentBlog = $Cache->get_value('blog_latest_id');
|
|
||||||
if ($CurrentBlog === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT ID
|
|
||||||
FROM blog
|
|
||||||
WHERE Important = 1
|
|
||||||
ORDER BY Time DESC
|
|
||||||
LIMIT 1");
|
|
||||||
if ($DB->record_count() === 1) {
|
|
||||||
list($CurrentBlog) = $DB->next_record();
|
|
||||||
} else {
|
|
||||||
$CurrentBlog = -1;
|
|
||||||
}
|
|
||||||
$Cache->cache_value('blog_latest_id', $CurrentBlog, 0);
|
|
||||||
}
|
|
||||||
if ($MyBlog < $CurrentBlog) {
|
|
||||||
$Alerts[] = '<a href="blog.php">New blog post!</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Staff blog
|
// Staff blog
|
||||||
if (check_perms('users_mod')) {
|
if (check_perms('users_mod')) {
|
||||||
global $SBlogReadTime, $LatestSBlogTime;
|
global $SBlogReadTime, $LatestSBlogTime;
|
||||||
if (!$SBlogReadTime && ($SBlogReadTime = $Cache->get_value('staff_blog_read_'.$LoggedUser['ID'])) === false) {
|
if (!$SBlogReadTime && ($SBlogReadTime = G::$Cache->get_value('staff_blog_read_'.G::$LoggedUser['ID'])) === false) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT Time
|
SELECT Time
|
||||||
FROM staff_blog_visits
|
FROM staff_blog_visits
|
||||||
WHERE UserID = ".$LoggedUser['ID']);
|
WHERE UserID = ".G::$LoggedUser['ID']);
|
||||||
if (list($SBlogReadTime) = $DB->next_record()) {
|
if (list($SBlogReadTime) = G::$DB->next_record()) {
|
||||||
$SBlogReadTime = strtotime($SBlogReadTime);
|
$SBlogReadTime = strtotime($SBlogReadTime);
|
||||||
} else {
|
} else {
|
||||||
$SBlogReadTime = 0;
|
$SBlogReadTime = 0;
|
||||||
}
|
}
|
||||||
$Cache->cache_value('staff_blog_read_'.$LoggedUser['ID'], $SBlogReadTime, 1209600);
|
G::$Cache->cache_value('staff_blog_read_'.G::$LoggedUser['ID'], $SBlogReadTime, 1209600);
|
||||||
}
|
}
|
||||||
if (!$LatestSBlogTime && ($LatestSBlogTime = $Cache->get_value('staff_blog_latest_time')) === false) {
|
if (!$LatestSBlogTime && ($LatestSBlogTime = G::$Cache->get_value('staff_blog_latest_time')) === false) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT MAX(Time)
|
SELECT MAX(Time)
|
||||||
FROM staff_blog");
|
FROM staff_blog");
|
||||||
if (list($LatestSBlogTime) = $DB->next_record()) {
|
list($LatestSBlogTime) = G::$DB->next_record();
|
||||||
|
if ($LatestSBlogTime) {
|
||||||
$LatestSBlogTime = strtotime($LatestSBlogTime);
|
$LatestSBlogTime = strtotime($LatestSBlogTime);
|
||||||
} else {
|
} else {
|
||||||
$LatestSBlogTime = 0;
|
$LatestSBlogTime = 0;
|
||||||
}
|
}
|
||||||
$Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600);
|
G::$Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600);
|
||||||
}
|
}
|
||||||
if ($SBlogReadTime < $LatestSBlogTime) {
|
if ($SBlogReadTime < $LatestSBlogTime) {
|
||||||
$Alerts[] = '<a href="staffblog.php">New staff blog post!</a>';
|
$Alerts[] = '<a href="staffblog.php">New staff blog post!</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Staff PM
|
|
||||||
$NewStaffPMs = $Cache->get_value('staff_pm_new_'.$LoggedUser['ID']);
|
|
||||||
if ($NewStaffPMs === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM staff_pm_conversations
|
|
||||||
WHERE UserID = '".$LoggedUser['ID']."'
|
|
||||||
AND Unread = '1'");
|
|
||||||
list($NewStaffPMs) = $DB->next_record();
|
|
||||||
$Cache->cache_value('staff_pm_new_'.$LoggedUser['ID'], $NewStaffPMs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($NewStaffPMs > 0) {
|
|
||||||
$Alerts[] = '<a href="staffpm.php">You have '.$NewStaffPMs.(($NewStaffPMs > 1) ? ' new staff messages' : ' new staff message').'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inbox
|
// Inbox
|
||||||
$NewMessages = $Cache->get_value('inbox_new_'.$LoggedUser['ID']);
|
if ($NotificationsManager->is_traditional(NotificationsManager::INBOX)) {
|
||||||
if ($NewMessages === false) {
|
$NotificationsManager->load_inbox();
|
||||||
$DB->query("
|
$NewMessages = $NotificationsManager->get_notifications()[NotificationsManager::INBOX];
|
||||||
SELECT COUNT(UnRead)
|
if (isset($NewMessages)) {
|
||||||
FROM pm_conversations_users
|
$Alerts[] = NotificationsManagerView::format_traditional($NewMessages['contents']);
|
||||||
WHERE UserID = '".$LoggedUser['ID']."'
|
}
|
||||||
AND UnRead = '1'
|
$NotificationsManager->clear_notifications_array();
|
||||||
AND InInbox = '1'");
|
|
||||||
list($NewMessages) = $DB->next_record();
|
|
||||||
$Cache->cache_value('inbox_new_'.$LoggedUser['ID'], $NewMessages, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($NewMessages > 0) {
|
if (G::$LoggedUser['RatioWatch']) {
|
||||||
$Alerts[] = '<a href="' . Inbox::get_inbox_link() . "\">You have $NewMessages".(($NewMessages > 1) ? ' new messages' : ' new message').'</a>';
|
$Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: You have '.time_diff(G::$LoggedUser['RatioWatchEnds'], 3).' to get your ratio over your required ratio or your leeching abilities will be disabled.';
|
||||||
}
|
} elseif (G::$LoggedUser['CanLeech'] != 1) {
|
||||||
|
|
||||||
if ($LoggedUser['RatioWatch']) {
|
|
||||||
$Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: You have '.time_diff($LoggedUser['RatioWatchEnds'], 3).' to get your ratio over your required ratio or your leeching abilities will be disabled.';
|
|
||||||
} elseif ($LoggedUser['CanLeech'] != 1) {
|
|
||||||
$Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: Your downloading privileges are disabled until you meet your required ratio.';
|
$Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: Your downloading privileges are disabled until you meet your required ratio.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_perms('site_torrents_notify')) {
|
// Torrents
|
||||||
$NewNotifications = $Cache->get_value('notifications_new_'.$LoggedUser['ID']);
|
if ($NotificationsManager->is_traditional(NotificationsManager::TORRENTS)) {
|
||||||
if ($NewNotifications === false) {
|
$NotificationsManager->load_torrent_notifications();
|
||||||
$DB->query("
|
$NewTorrents = $NotificationsManager->get_notifications()[NotificationsManager::TORRENTS];
|
||||||
SELECT COUNT(UserID)
|
if (isset($NewTorrents)) {
|
||||||
FROM users_notify_torrents
|
$Alerts[] = NotificationsManagerView::format_traditional($NewTorrents['contents']);
|
||||||
WHERE UserID = '$LoggedUser[ID]'
|
|
||||||
AND UnRead = '1'");
|
|
||||||
list($NewNotifications) = $DB->next_record();
|
|
||||||
/* if ($NewNotifications && !check_perms('site_torrents_notify')) {
|
|
||||||
$DB->query("
|
|
||||||
DELETE FROM users_notify_torrents
|
|
||||||
WHERE UserID = '$LoggedUser[ID]'");
|
|
||||||
$DB->query("
|
|
||||||
DELETE FROM users_notify_filters
|
|
||||||
WHERE UserID = '$LoggedUser[ID]'");
|
|
||||||
} */
|
|
||||||
$Cache->cache_value('notifications_new_'.$LoggedUser['ID'], $NewNotifications, 0);
|
|
||||||
}
|
|
||||||
if ($NewNotifications > 0) {
|
|
||||||
$Alerts[] = '<a href="torrents.php?action=notify">You have '.$NewNotifications.(($NewNotifications > 1) ? ' new torrent notifications' : ' new torrent notification').'</a>';
|
|
||||||
}
|
}
|
||||||
|
$NotificationsManager->clear_notifications_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collage subscriptions
|
|
||||||
if (check_perms('site_collages_subscribe')) {
|
|
||||||
$NewCollages = $Cache->get_value('collage_subs_user_new_'.$LoggedUser['ID']);
|
|
||||||
if ($NewCollages === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(DISTINCT s.CollageID)
|
|
||||||
FROM users_collage_subs as s
|
|
||||||
JOIN collages as c ON s.CollageID = c.ID
|
|
||||||
JOIN collages_torrents as ct on ct.CollageID = c.ID
|
|
||||||
WHERE s.UserID = $LoggedUser[ID]
|
|
||||||
AND ct.AddedOn > s.LastVisit
|
|
||||||
AND c.Deleted = '0'");
|
|
||||||
list($NewCollages) = $DB->next_record();
|
|
||||||
$Cache->cache_value('collage_subs_user_new_'.$LoggedUser['ID'], $NewCollages, 0);
|
|
||||||
}
|
|
||||||
if ($NewCollages > 0) {
|
|
||||||
$Alerts[] = '<a href="userhistory.php?action=subscribed_collages">You have '.$NewCollages.(($NewCollages > 1) ? ' new collage updates' : ' new collage update').'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (check_perms('users_mod')) {
|
if (check_perms('users_mod')) {
|
||||||
$ModBar[] = '<a href="tools.php">Toolbox</a>';
|
$ModBar[] = '<a href="tools.php">Toolbox</a>';
|
||||||
}
|
}
|
||||||
if (check_perms('users_mod') || $LoggedUser['PermissionID'] == FORUM_MOD) {
|
if (check_perms('users_mod') || G::$LoggedUser['PermissionID'] == FORUM_MOD) {
|
||||||
$NumStaffPMs = $Cache->get_value('num_staff_pms_'.$LoggedUser['ID']);
|
$NumStaffPMs = G::$Cache->get_value('num_staff_pms_'.G::$LoggedUser['ID']);
|
||||||
if ($NumStaffPMs === false) {
|
if ($NumStaffPMs === false) {
|
||||||
if (check_perms('users_mod')) {
|
if (check_perms('users_mod')) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM staff_pm_conversations
|
FROM staff_pm_conversations
|
||||||
WHERE Status = 'Unanswered'
|
WHERE Status = 'Unanswered'
|
||||||
AND (AssignedToUser = ".$LoggedUser['ID']."
|
AND (AssignedToUser = ".G::$LoggedUser['ID']."
|
||||||
OR (Level >= ".max(700, $Classes[MOD]['Level'])."
|
OR (Level >= ".max(700, $Classes[MOD]['Level'])."
|
||||||
AND Level <= ".$LoggedUser['Class']."))");
|
AND Level <= ".G::$LoggedUser['Class']."))");
|
||||||
}
|
}
|
||||||
if ($LoggedUser['PermissionID'] == FORUM_MOD) {
|
if (G::$LoggedUser['PermissionID'] == FORUM_MOD) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM staff_pm_conversations
|
FROM staff_pm_conversations
|
||||||
WHERE Status='Unanswered'
|
WHERE Status='Unanswered'
|
||||||
AND (AssignedToUser = ".$LoggedUser['ID']."
|
AND (AssignedToUser = ".G::$LoggedUser['ID']."
|
||||||
OR Level = '". $Classes[FORUM_MOD]['Level'] . "')");
|
OR Level = '". $Classes[FORUM_MOD]['Level'] . "')");
|
||||||
}
|
}
|
||||||
list($NumStaffPMs) = $DB->next_record();
|
list($NumStaffPMs) = G::$DB->next_record();
|
||||||
$Cache->cache_value('num_staff_pms_'.$LoggedUser['ID'], $NumStaffPMs , 1000);
|
G::$Cache->cache_value('num_staff_pms_'.G::$LoggedUser['ID'], $NumStaffPMs , 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($NumStaffPMs > 0) {
|
if ($NumStaffPMs > 0) {
|
||||||
@ -542,57 +388,57 @@ class="stat"
|
|||||||
}
|
}
|
||||||
if (check_perms('admin_reports')) {
|
if (check_perms('admin_reports')) {
|
||||||
// Torrent reports code
|
// Torrent reports code
|
||||||
$NumTorrentReports = $Cache->get_value('num_torrent_reportsv2');
|
$NumTorrentReports = G::$Cache->get_value('num_torrent_reportsv2');
|
||||||
if ($NumTorrentReports === false) {
|
if ($NumTorrentReports === false) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM reportsv2
|
FROM reportsv2
|
||||||
WHERE Status = 'New'");
|
WHERE Status = 'New'");
|
||||||
list($NumTorrentReports) = $DB->next_record();
|
list($NumTorrentReports) = G::$DB->next_record();
|
||||||
$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
|
G::$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ModBar[] = '<a href="reportsv2.php">'.$NumTorrentReports.(($NumTorrentReports == 1) ? ' Report' : ' Reports').'</a>';
|
$ModBar[] = '<a href="reportsv2.php">'.$NumTorrentReports.(($NumTorrentReports == 1) ? ' Report' : ' Reports').'</a>';
|
||||||
|
|
||||||
// Other reports code
|
// Other reports code
|
||||||
$NumOtherReports = $Cache->get_value('num_other_reports');
|
$NumOtherReports = G::$Cache->get_value('num_other_reports');
|
||||||
if ($NumOtherReports === false) {
|
if ($NumOtherReports === false) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM reports
|
FROM reports
|
||||||
WHERE Status = 'New'");
|
WHERE Status = 'New'");
|
||||||
list($NumOtherReports) = $DB->next_record();
|
list($NumOtherReports) = G::$DB->next_record();
|
||||||
$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
|
G::$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($NumOtherReports > 0) {
|
if ($NumOtherReports > 0) {
|
||||||
$ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports == 1) ? ' Other report' : ' Other reports').'</a>';
|
$ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports == 1) ? ' Other report' : ' Other reports').'</a>';
|
||||||
}
|
}
|
||||||
} elseif (check_perms('project_team')) {
|
} elseif (check_perms('project_team')) {
|
||||||
$NumUpdateReports = $Cache->get_value('num_update_reports');
|
$NumUpdateReports = G::$Cache->get_value('num_update_reports');
|
||||||
if ($NumUpdateReports === false) {
|
if ($NumUpdateReports === false) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM reports
|
FROM reports
|
||||||
WHERE Status = 'New'
|
WHERE Status = 'New'
|
||||||
AND Type = 'request_update'");
|
AND Type = 'request_update'");
|
||||||
list($NumUpdateReports) = $DB->next_record();
|
list($NumUpdateReports) = G::$DB->next_record();
|
||||||
$Cache->cache_value('num_update_reports', $NumUpdateReports, 0);
|
G::$Cache->cache_value('num_update_reports', $NumUpdateReports, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($NumUpdateReports > 0) {
|
if ($NumUpdateReports > 0) {
|
||||||
$ModBar[] = '<a href="reports.php">Request update reports</a>';
|
$ModBar[] = '<a href="reports.php">Request update reports</a>';
|
||||||
}
|
}
|
||||||
} elseif (check_perms('site_moderate_forums')) {
|
} elseif (check_perms('site_moderate_forums')) {
|
||||||
$NumForumReports = $Cache->get_value('num_forum_reports');
|
$NumForumReports = G::$Cache->get_value('num_forum_reports');
|
||||||
if ($NumForumReports === false) {
|
if ($NumForumReports === false) {
|
||||||
$DB->query("
|
G::$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM reports
|
FROM reports
|
||||||
WHERE Status = 'New'
|
WHERE Status = 'New'
|
||||||
AND Type IN('artist_comment', 'collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment')");
|
AND Type IN('artist_comment', 'collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment')");
|
||||||
list($NumForumReports) = $DB->next_record();
|
list($NumForumReports) = G::$DB->next_record();
|
||||||
$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
|
G::$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($NumForumReports > 0) {
|
if ($NumForumReports > 0) {
|
||||||
@ -601,19 +447,21 @@ class="stat"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($Alerts) || !empty($ModBar)) {
|
|
||||||
?>
|
?>
|
||||||
|
<?
|
||||||
|
if (!empty($Alerts) || !empty($ModBar)) { ?>
|
||||||
<div id="alerts">
|
<div id="alerts">
|
||||||
<? foreach ($Alerts as $Alert) { ?>
|
<? foreach ($Alerts as $Alert) { ?>
|
||||||
<div class="alertbar"><?=$Alert?></div>
|
<div class="alertbar"><?=$Alert?></div>
|
||||||
<? }
|
|
||||||
if (!empty($ModBar)) { ?>
|
|
||||||
<div class="alertbar blend"><?=implode(' | ', $ModBar)?></div>
|
|
||||||
<? } ?>
|
|
||||||
</div>
|
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
|
if (!empty($ModBar)) { ?>
|
||||||
|
<div class="alertbar blend"><?=implode(' | ', $ModBar)?></div>
|
||||||
|
<?
|
||||||
|
} ?>
|
||||||
|
</div>
|
||||||
|
<? } ?>
|
||||||
|
<?
|
||||||
//Done handling alertbars
|
//Done handling alertbars
|
||||||
|
|
||||||
|
|
||||||
@ -623,13 +471,13 @@ class="stat"
|
|||||||
<li id="searchbar_torrents"><span class="hidden">Torrents: </span>
|
<li id="searchbar_torrents"><span class="hidden">Torrents: </span>
|
||||||
<form class="search_form" name="torrents" action="torrents.php"
|
<form class="search_form" name="torrents" action="torrents.php"
|
||||||
method="get">
|
method="get">
|
||||||
<? if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { // Advanced search ?>
|
<? if (isset(G::$LoggedUser['SearchType']) && G::$LoggedUser['SearchType']) { // Advanced search ?>
|
||||||
<input type="hidden" name="action" value="advanced" />
|
<input type="hidden" name="action" value="advanced" />
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<input id="torrentssearch" accesskey="t" spellcheck="false"
|
<input id="torrentssearch" accesskey="t" spellcheck="false"
|
||||||
onfocus="if (this.value == 'Torrents') this.value = '';"
|
onfocus="if (this.value == 'Torrents') this.value = '';"
|
||||||
onblur="if (this.value == '') this.value = 'Torrents';"
|
onblur="if (this.value == '') this.value = 'Torrents';"
|
||||||
<? if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { // Advanced search ?>
|
<? if (isset(G::$LoggedUser['SearchType']) && G::$LoggedUser['SearchType']) { // Advanced search ?>
|
||||||
value="Torrents" type="text" name="groupname" size="17"
|
value="Torrents" type="text" name="groupname" size="17"
|
||||||
<? } else { ?> value="Torrents" type="text" name="searchstr"
|
<? } else { ?> value="Torrents" type="text" name="searchstr"
|
||||||
size="17" <? } ?> />
|
size="17" <? } ?> />
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?
|
<?
|
||||||
global $LoggedUser, $Languages, $SSL;
|
global $LoggedUser, $SSL;
|
||||||
define('FOOTER_FILE',SERVER_ROOT.'/design/publicfooter.php');
|
define('FOOTER_FILE',SERVER_ROOT.'/design/publicfooter.php');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
@ -26,7 +25,6 @@
|
|||||||
<? if ($Mobile) { ?>
|
<? if ($Mobile) { ?>
|
||||||
<script src="<?=STATIC_SERVER?>styles/mobile/style.js?v=<?=filemtime(SERVER_ROOT.'/static/mobile/style.js')?>" type="text/javascript"></script>
|
<script src="<?=STATIC_SERVER?>styles/mobile/style.js?v=<?=filemtime(SERVER_ROOT.'/static/mobile/style.js')?>" type="text/javascript"></script>
|
||||||
<? }
|
<? }
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -44,4 +42,4 @@
|
|||||||
<? } ?>
|
<? } ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<?
|
||||||
|
@ -22,10 +22,22 @@
|
|||||||
*
|
*
|
||||||
* Globals are required as this template is included within a
|
* Globals are required as this template is included within a
|
||||||
* function scope.
|
* function scope.
|
||||||
*/
|
*
|
||||||
global $LoggedUser, $HeavyInfo, $UserSubscriptions, $ThreadInfo, $ForumsDoublePost;
|
* To add a "Subscribe" box for non-forum pages (like artist/collage/...
|
||||||
|
* comments), add a key 'SubscribeBox' to the array passed to View::parse.
|
||||||
|
* Example:
|
||||||
|
|
||||||
if ($LoggedUser['DisablePosting']) {
|
View::parse('generic/reply/quickreply.php', array(
|
||||||
|
'InputTitle' => 'Post comment',
|
||||||
|
'InputName' => 'groupid',
|
||||||
|
'InputID' => $GroupID,
|
||||||
|
'TextareaCols' => 65,
|
||||||
|
'SubscribeBox' => true
|
||||||
|
));
|
||||||
|
*/
|
||||||
|
global $HeavyInfo, $UserSubscriptions, $ThreadInfo, $ForumsDoublePost, $Document;
|
||||||
|
|
||||||
|
if (G::$LoggedUser['DisablePosting']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isset($TextareaCols)) {
|
if (!isset($TextareaCols)) {
|
||||||
@ -40,6 +52,9 @@
|
|||||||
if (!isset($InputTitle)) {
|
if (!isset($InputTitle)) {
|
||||||
$InputTitle = 'Post comment';
|
$InputTitle = 'Post comment';
|
||||||
}
|
}
|
||||||
|
if (!isset($Action)) {
|
||||||
|
$Action = '';
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Remove inline styles
|
// TODO: Remove inline styles
|
||||||
|
|
||||||
@ -69,7 +84,7 @@
|
|||||||
<tr class="colhead_dark">
|
<tr class="colhead_dark">
|
||||||
<td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
|
<td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
|
||||||
<div style="float: left;"><a href="#quickreplypreview">#XXXXXX</a>
|
<div style="float: left;"><a href="#quickreplypreview">#XXXXXX</a>
|
||||||
by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true)?></strong> Just now
|
by <strong><?=Users::format_username(G::$LoggedUser['ID'], true, true, true, true)?></strong> Just now
|
||||||
</div>
|
</div>
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
<a href="#quickreplypreview" class="brackets">Report</a>
|
<a href="#quickreplypreview" class="brackets">Report</a>
|
||||||
@ -81,7 +96,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<? if (Users::has_avatars_enabled()) { ?>
|
<? if (Users::has_avatars_enabled()) { ?>
|
||||||
<td class="avatar" valign="top">
|
<td class="avatar" valign="top">
|
||||||
<?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
|
<?=Users::show_avatar(G::$LoggedUser['Avatar'], G::$LoggedUser['ID'], G::$LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
|
||||||
</td>
|
</td>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<td class="body" valign="top">
|
<td class="body" valign="top">
|
||||||
@ -91,9 +106,9 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<form class="send_form center" name="reply" id="quickpostform" action="" method="post"<? if (!check_perms('users_mod')) { ?> onsubmit="quickpostform.submit_button.disabled=true;" <? } ?>>
|
<form class="send_form center" name="reply" id="quickpostform" action="<?=$Action?>" method="post"<? if (!check_perms('users_mod')) { ?> onsubmit="quickpostform.submit_button.disabled=true;" <? } ?>>
|
||||||
<input type="hidden" name="action" value="<?=$InputAction?>" />
|
<input type="hidden" name="action" value="<?=$InputAction?>" />
|
||||||
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
<input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
|
||||||
<input type="hidden" name="<?=$InputName?>" value="<?=$InputID?>" />
|
<input type="hidden" name="<?=$InputName?>" value="<?=$InputID?>" />
|
||||||
<div id="quickreplytext">
|
<div id="quickreplytext">
|
||||||
<?
|
<?
|
||||||
@ -103,15 +118,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="preview_submit">
|
<div class="preview_submit">
|
||||||
<?
|
<?
|
||||||
// Forum thread logic
|
if (isset($SubscribeBox) && !isset($ForumID) && Subscriptions::has_subscribed_comments($Document, $InputID) === false) { ?>
|
||||||
// This might use some more abstraction
|
|
||||||
if ($ForumID) { ?>
|
|
||||||
<? if (!in_array($InputID, $UserSubscriptions)) { ?>
|
|
||||||
<input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?> tabindex="2" />
|
<input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?> tabindex="2" />
|
||||||
<label for="subscribebox">Subscribe</label>
|
<label for="subscribebox">Subscribe</label>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID']
|
// Forum thread logic
|
||||||
|
// This might use some more abstraction
|
||||||
|
if (isset($ForumID)) {
|
||||||
|
if (!Subscriptions::has_subscribed($InputID)) { ?>
|
||||||
|
<input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?> tabindex="2" />
|
||||||
|
<label for="subscribebox">Subscribe</label>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
if ($ThreadInfo['LastPostAuthorID'] == G::$LoggedUser['ID']
|
||||||
&& (check_perms('site_forums_double_post')
|
&& (check_perms('site_forums_double_post')
|
||||||
|| in_array($ForumID, $ForumsDoublePost))
|
|| in_array($ForumID, $ForumsDoublePost))
|
||||||
) {
|
) {
|
||||||
@ -119,7 +139,7 @@
|
|||||||
<input id="mergebox" type="checkbox" name="merge" tabindex="2" />
|
<input id="mergebox" type="checkbox" name="merge" tabindex="2" />
|
||||||
<label for="mergebox">Merge</label>
|
<label for="mergebox">Merge</label>
|
||||||
<? }
|
<? }
|
||||||
if (!$LoggedUser['DisableAutoSave']) { ?>
|
if (!G::$LoggedUser['DisableAutoSave']) { ?>
|
||||||
<script type="application/javascript">var storedTempTextarea = new StoreText('quickpost', 'quickpostform', <?=$InputID?>);</script>
|
<script type="application/javascript">var storedTempTextarea = new StoreText('quickpost', 'quickpostform', <?=$InputID?>);</script>
|
||||||
<? }
|
<? }
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,26 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
2013-08-28 by porkpie
|
||||||
|
Add an option for the styled tooltips
|
||||||
|
|
||||||
|
2013-08-25 by Y
|
||||||
|
Comment subscriptions, quote notifications and quote linking
|
||||||
|
|
||||||
|
2013-08-24 by Ajax
|
||||||
|
Notifications Manager class and noty.js library to provide popup notifications
|
||||||
|
|
||||||
|
2013-08-24 by Ajax
|
||||||
|
Redesigned user settings page
|
||||||
|
|
||||||
|
2013-08-24 by Ajax
|
||||||
|
Tooltipster library added for tooltips
|
||||||
|
|
||||||
|
2013-08-24 by Ajax
|
||||||
|
Calendar in Staff Toolbox
|
||||||
|
|
||||||
|
2013-08-24 by Ajax
|
||||||
|
Donor Rank system and rewrite of all donation code
|
||||||
|
|
||||||
2013-08-08 by Squiffy
|
2013-08-08 by Squiffy
|
||||||
Drag and Drop ordering on the Do Not Upload page in toolbox
|
Drag and Drop ordering on the Do Not Upload page in toolbox
|
||||||
|
|
||||||
|
776
gazelle.sql
776
gazelle.sql
File diff suppressed because it is too large
Load Diff
39
sections/ajax/clear_user_notification.php
Normal file
39
sections/ajax/clear_user_notification.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
$Type = $_POST['type'];
|
||||||
|
|
||||||
|
switch($Type) {
|
||||||
|
case NotificationsManager::INBOX:
|
||||||
|
NotificationsManager::clear_inbox();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::NEWS:
|
||||||
|
NotificationsManager::clear_news();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::BLOG:
|
||||||
|
NotificationsManager::clear_blog();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::STAFFPM:
|
||||||
|
NotificationsManager::clear_staff_pms();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::TORRENTS:
|
||||||
|
NotificationsManager::clear_torrents();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::QUOTES:
|
||||||
|
NotificationsManager::clear_quotes();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::SUBSCRIPTIONS:
|
||||||
|
NotificationsManager::clear_subscriptions();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::COLLAGES:
|
||||||
|
NotificationsManager::clear_collages();
|
||||||
|
break;
|
||||||
|
case NotificationsManager::GLOBALNOTICE:
|
||||||
|
NotificationsManager::clear_global_notification();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($Type, "oneread_") === 0) {
|
||||||
|
NotificationsManager::clear_one_read($Type);
|
||||||
|
}
|
@ -134,14 +134,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Handle subscriptions
|
//Handle subscriptions
|
||||||
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
|
$UserSubscriptions = Subscriptions::get_subscriptions();
|
||||||
$DB->query("
|
|
||||||
SELECT TopicID
|
|
||||||
FROM users_subscriptions
|
|
||||||
WHERE UserID = '$LoggedUser[ID]'");
|
|
||||||
$UserSubscriptions = $DB->collect(0);
|
|
||||||
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($UserSubscriptions)) {
|
if (empty($UserSubscriptions)) {
|
||||||
$UserSubscriptions = array();
|
$UserSubscriptions = array();
|
||||||
|
9
sections/ajax/get_user_notifications.php
Normal file
9
sections/ajax/get_user_notifications.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
$Skip = array();
|
||||||
|
$Skip[] = db_string($_GET['skip']);
|
||||||
|
$NotificationsManager = new NotificationsManager($LoggedUser['ID'], $Skip);
|
||||||
|
|
||||||
|
json_die("success", $NotificationsManager->get_notifications());
|
||||||
|
|
||||||
|
//echo '{"status":"success","response":[[{"message":"1st notification","url":"https:\/\/www.google.com\/","importance":"alert","AutoExpire":false},{"message":"2nd notification","url":"","importance":"alert","AutoExpire":true}]]}';
|
@ -157,6 +157,12 @@
|
|||||||
case 'raw_bbcode':
|
case 'raw_bbcode':
|
||||||
require(SERVER_ROOT . '/sections/ajax/raw_bbcode.php');
|
require(SERVER_ROOT . '/sections/ajax/raw_bbcode.php');
|
||||||
break;
|
break;
|
||||||
|
case 'get_user_notifications':
|
||||||
|
require(SERVER_ROOT . '/sections/ajax/get_user_notifications.php');
|
||||||
|
break;
|
||||||
|
case 'clear_user_notification':
|
||||||
|
require(SERVER_ROOT . '/sections/ajax/clear_user_notification.php');
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// If they're screwing around with the query string
|
// If they're screwing around with the query string
|
||||||
json_die("failure");
|
json_die("failure");
|
||||||
|
@ -91,27 +91,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
$NewSubscriptions = $Cache->get_value('subscriptions_user_new_' . $LoggedUser['ID']);
|
$NewSubscriptions = Subscriptions::has_new_subscriptions();
|
||||||
if ($NewSubscriptions === false) {
|
|
||||||
if ($LoggedUser['CustomForums']) {
|
|
||||||
unset($LoggedUser['CustomForums']['']);
|
|
||||||
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
|
|
||||||
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
|
|
||||||
}
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(s.TopicID)
|
|
||||||
FROM users_subscriptions AS s
|
|
||||||
JOIN forums_last_read_topics AS l ON s.UserID = l.UserID AND s.TopicID = l.TopicID
|
|
||||||
JOIN forums_topics AS t ON l.TopicID = t.ID
|
|
||||||
JOIN forums AS f ON t.ForumID = f.ID
|
|
||||||
WHERE (f.MinClassRead <= " . $LoggedUser['Class'] . " OR f.ID IN ('$PermittedForums'))
|
|
||||||
AND l.PostID < t.LastPostID
|
|
||||||
AND s.UserID = " . $LoggedUser['ID'] .
|
|
||||||
(!empty($RestrictedForums) ? "
|
|
||||||
AND f.ID NOT IN ('" . $RestrictedForums . "')" : ''));
|
|
||||||
list($NewSubscriptions) = $DB->next_record();
|
|
||||||
$Cache->cache_value('subscriptions_user_new_' . $LoggedUser['ID'], $NewSubscriptions, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
json_die("success", array(
|
json_die("success", array(
|
||||||
'username' => $LoggedUser['Username'],
|
'username' => $LoggedUser['Username'],
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
$RequestTax = 0.1;
|
$RequestTax = 0.1;
|
||||||
|
|
||||||
// Minimum and default amount of upload to remove from the user when they vote.
|
// Minimum and default amount of upload to remove from the user when they vote.
|
||||||
@ -17,7 +16,7 @@
|
|||||||
json_die("failure");
|
json_die("failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
$RequestID = $_GET['id'];
|
$RequestID = (int)$_GET['id'];
|
||||||
|
|
||||||
//First things first, lets get the data for the request.
|
//First things first, lets get the data for the request.
|
||||||
|
|
||||||
@ -92,47 +91,7 @@
|
|||||||
}
|
}
|
||||||
reset($RequestVotes['Voters']);
|
reset($RequestVotes['Voters']);
|
||||||
|
|
||||||
$Results = $Cache->get_value('request_comments_'.$RequestID);
|
list($NumComments, $Page, $Thread) = Comments::load('requests', $RequestID, false);
|
||||||
if ($Results === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(c.ID)
|
|
||||||
FROM requests_comments as c
|
|
||||||
WHERE c.RequestID = '$RequestID'");
|
|
||||||
list($Results) = $DB->next_record();
|
|
||||||
$Cache->cache_value('request_comments_'.$RequestID, $Results, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $Results);
|
|
||||||
|
|
||||||
// Get the cache catalogue
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
|
|
||||||
//---------- Get some data to start processing
|
|
||||||
|
|
||||||
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
|
|
||||||
$Catalogue = $Cache->get_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
|
|
||||||
if ($Catalogue === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
c.ID,
|
|
||||||
c.AuthorID,
|
|
||||||
c.AddedTime,
|
|
||||||
c.Body,
|
|
||||||
c.EditedUserID,
|
|
||||||
c.EditedTime,
|
|
||||||
u.Username
|
|
||||||
FROM requests_comments as c
|
|
||||||
LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
|
|
||||||
WHERE c.RequestID = '$RequestID'
|
|
||||||
ORDER BY c.ID
|
|
||||||
LIMIT $CatalogueLimit");
|
|
||||||
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
|
|
||||||
$Cache->cache_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
|
|
||||||
$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
|
|
||||||
|
|
||||||
$JsonRequestComments = array();
|
$JsonRequestComments = array();
|
||||||
foreach ($Thread as $Key => $Post) {
|
foreach ($Thread as $Key => $Post) {
|
||||||
@ -197,7 +156,7 @@
|
|||||||
'tags' => $JsonTags,
|
'tags' => $JsonTags,
|
||||||
'comments' => $JsonRequestComments,
|
'comments' => $JsonRequestComments,
|
||||||
'commentPage' => (int) $Page,
|
'commentPage' => (int) $Page,
|
||||||
'commentPages' => (int) ceil($Results / TORRENT_COMMENTS_PER_PAGE),
|
'commentPages' => (int) ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
|
||||||
'recordLabel' => $RecordLabel,
|
'recordLabel' => $RecordLabel,
|
||||||
'oclc' => $OCLC
|
'oclc' => $OCLC
|
||||||
));
|
));
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
}
|
}
|
||||||
list($Page, $Limit) = Format::page_limit($PerPage);
|
list($Page, $Limit) = Format::page_limit($PerPage);
|
||||||
|
|
||||||
if ($LoggedUser['CustomForums']) {
|
|
||||||
unset($LoggedUser['CustomForums']['']);
|
|
||||||
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
|
|
||||||
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
$ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
|
$ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
|
||||||
$ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
|
$ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
|
||||||
$sql = '
|
$sql = '
|
||||||
@ -36,15 +30,7 @@
|
|||||||
LEFT JOIN forums_last_read_topics AS l ON p.TopicID = l.TopicID AND l.UserID = s.UserID
|
LEFT JOIN forums_last_read_topics AS l ON p.TopicID = l.TopicID AND l.UserID = s.UserID
|
||||||
WHERE s.UserID = '.$LoggedUser['ID'].'
|
WHERE s.UserID = '.$LoggedUser['ID'].'
|
||||||
AND p.ID <= IFNULL(l.PostID,t.LastPostID)
|
AND p.ID <= IFNULL(l.PostID,t.LastPostID)
|
||||||
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
|
AND ' . Forums::user_forums_sql();
|
||||||
if (!empty($RestrictedForums)) {
|
|
||||||
$sql.=" AND f.ID NOT IN ('$RestrictedForums')";
|
|
||||||
}
|
|
||||||
$sql .= ')';
|
|
||||||
if (!empty($PermittedForums)) {
|
|
||||||
$sql.=" OR f.ID IN ('$PermittedForums')";
|
|
||||||
}
|
|
||||||
$sql .= ')';
|
|
||||||
if ($ShowUnread) {
|
if ($ShowUnread) {
|
||||||
$sql .= '
|
$sql .= '
|
||||||
AND IF(l.PostID IS NULL OR (t.IsLocked = \'1\' && t.IsSticky = \'0\'), t.LastPostID, l.PostID) < t.LastPostID';
|
AND IF(l.PostID IS NULL OR (t.IsLocked = \'1\' && t.IsSticky = \'0\'), t.LastPostID, l.PostID) < t.LastPostID';
|
||||||
|
@ -1,62 +1,12 @@
|
|||||||
<?php
|
<?
|
||||||
|
|
||||||
include(SERVER_ROOT.'/classes/text.class.php');
|
include(SERVER_ROOT.'/classes/text.class.php');
|
||||||
$Text = new TEXT;
|
$Text = new TEXT;
|
||||||
|
|
||||||
$GroupID=ceil($_GET['id']);
|
if (empty($_GET['id']) || !is_number($_GET['id'])) {
|
||||||
|
json_die("failure");
|
||||||
$Results = $Cache->get_value('torrent_comments_'.$GroupID);
|
|
||||||
if ($Results === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
COUNT(c.ID)
|
|
||||||
FROM torrents_comments as c
|
|
||||||
WHERE c.GroupID = '$GroupID'");
|
|
||||||
list($Results) = $DB->next_record();
|
|
||||||
$Cache->cache_value('torrent_comments_'.$GroupID, $Results, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
|
list($NumComments, $Page, $Thread) = Comments::load('torrents', (int)$_GET['id'], false);
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM torrents_comments
|
|
||||||
WHERE GroupID = $GroupID
|
|
||||||
AND ID <= $_GET[postid]");
|
|
||||||
list($PostNum) = $DB->next_record();
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
|
|
||||||
} else {
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $Results);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the cache catalogue
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
|
|
||||||
//---------- Get some data to start processing
|
|
||||||
|
|
||||||
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
|
|
||||||
$Catalogue = $Cache->get_value('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
|
|
||||||
if ($Catalogue === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
c.ID,
|
|
||||||
c.AuthorID,
|
|
||||||
c.AddedTime,
|
|
||||||
c.Body,
|
|
||||||
c.EditedUserID,
|
|
||||||
c.EditedTime,
|
|
||||||
u.Username
|
|
||||||
FROM torrents_comments as c
|
|
||||||
LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
|
|
||||||
WHERE c.GroupID = '$GroupID'
|
|
||||||
ORDER BY c.ID
|
|
||||||
LIMIT $CatalogueLimit");
|
|
||||||
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
|
|
||||||
$Cache->cache_value('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
|
|
||||||
$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
|
|
||||||
|
|
||||||
//---------- Begin printing
|
//---------- Begin printing
|
||||||
$JsonComments = array();
|
$JsonComments = array();
|
||||||
@ -86,6 +36,6 @@
|
|||||||
|
|
||||||
json_die("success", array(
|
json_die("success", array(
|
||||||
'page' => (int) $Page,
|
'page' => (int) $Page,
|
||||||
'pages' => ceil($Results / TORRENT_COMMENTS_PER_PAGE),
|
'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
|
||||||
'comments' => $JsonComments
|
'comments' => $JsonComments
|
||||||
));
|
));
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
i.JoinDate,
|
i.JoinDate,
|
||||||
i.Info,
|
i.Info,
|
||||||
i.Avatar,
|
i.Avatar,
|
||||||
i.Country,
|
|
||||||
i.Donor,
|
i.Donor,
|
||||||
i.Warned,
|
i.Warned,
|
||||||
COUNT(posts.id) AS ForumPosts,
|
COUNT(posts.id) AS ForumPosts,
|
||||||
@ -54,7 +53,7 @@
|
|||||||
json_die("failure", "no such user");
|
json_die("failure", "no such user");
|
||||||
}
|
}
|
||||||
|
|
||||||
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $Enabled, $Paranoia, $Invites, $CustomTitle, $torrent_pass, $DisableLeech, $JoinDate, $Info, $Avatar, $Country, $Donor, $Warned, $ForumPosts, $InviterID, $DisableInvites, $InviterName, $RatioWatchEnds, $RatioWatchDownload) = $DB->next_record(MYSQLI_NUM, array(9, 11));
|
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $Enabled, $Paranoia, $Invites, $CustomTitle, $torrent_pass, $DisableLeech, $JoinDate, $Info, $Avatar, $Donor, $Warned, $ForumPosts, $InviterID, $DisableInvites, $InviterName, $RatioWatchEnds, $RatioWatchDownload) = $DB->next_record(MYSQLI_NUM, array(9, 11));
|
||||||
|
|
||||||
$Paranoia = unserialize($Paranoia);
|
$Paranoia = unserialize($Paranoia);
|
||||||
if (!is_array($Paranoia)) {
|
if (!is_array($Paranoia)) {
|
||||||
@ -188,8 +187,9 @@ function check_paranoia_here($Setting) {
|
|||||||
if (check_paranoia_here(array('torrentcomments', 'torrentcomments+'))) {
|
if (check_paranoia_here(array('torrentcomments', 'torrentcomments+'))) {
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT COUNT(ID)
|
SELECT COUNT(ID)
|
||||||
FROM torrents_comments
|
FROM comments
|
||||||
WHERE AuthorID = '$UserID'");
|
WHERE Page = 'torrents'
|
||||||
|
AND AuthorID = '$UserID'");
|
||||||
list($NumComments) = $DB->next_record();
|
list($NumComments) = $DB->next_record();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +275,11 @@ function check_paranoia_here($Setting) {
|
|||||||
if (!check_paranoia_here('lastseen')) {
|
if (!check_paranoia_here('lastseen')) {
|
||||||
$LastAccess = '';
|
$LastAccess = '';
|
||||||
}
|
}
|
||||||
|
if (check_paranoia_here('ratio')) {
|
||||||
|
$Ratio = Format::get_ratio($Uploaded, $Downloaded, 5);
|
||||||
|
} else {
|
||||||
|
$Ratio = null;
|
||||||
|
}
|
||||||
if (!check_paranoia_here('uploaded')) {
|
if (!check_paranoia_here('uploaded')) {
|
||||||
$Uploaded = null;
|
$Uploaded = null;
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,6 @@ function error_out($reason = '') {
|
|||||||
$UserInfo = Users::user_info($UserID);
|
$UserInfo = Users::user_info($UserID);
|
||||||
extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned'))));
|
extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned'))));
|
||||||
|
|
||||||
if ($LoggedUser['CustomForums']) {
|
|
||||||
unset($LoggedUser['CustomForums']['']);
|
|
||||||
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
|
|
||||||
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
|
|
||||||
}
|
|
||||||
$ViewingOwn = ($UserID === $LoggedUser['ID']);
|
$ViewingOwn = ($UserID === $LoggedUser['ID']);
|
||||||
$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread']));
|
$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread']));
|
||||||
$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group']));
|
$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group']));
|
||||||
@ -58,17 +53,7 @@ function error_out($reason = '') {
|
|||||||
$SQL .= '
|
$SQL .= '
|
||||||
LEFT JOIN forums AS f ON f.ID = t.ForumID
|
LEFT JOIN forums AS f ON f.ID = t.ForumID
|
||||||
WHERE p.AuthorID = '.$UserID.'
|
WHERE p.AuthorID = '.$UserID.'
|
||||||
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
|
AND ' . Forums::user_forums_sql();
|
||||||
if (!empty($RestrictedForums)) {
|
|
||||||
$SQL .= "
|
|
||||||
AND f.ID NOT IN ('$RestrictedForums')";
|
|
||||||
}
|
|
||||||
$SQL .= ')';
|
|
||||||
if (!empty($PermittedForums)) {
|
|
||||||
$SQL .= "
|
|
||||||
OR f.ID IN ('$PermittedForums')";
|
|
||||||
}
|
|
||||||
$SQL .= ')';
|
|
||||||
if ($ShowUnread) {
|
if ($ShowUnread) {
|
||||||
$SQL .= '
|
$SQL .= '
|
||||||
AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
|
AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
|
||||||
@ -145,21 +130,7 @@ function error_out($reason = '') {
|
|||||||
JOIN forums AS f ON f.ID = t.ForumID
|
JOIN forums AS f ON f.ID = t.ForumID
|
||||||
LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID
|
LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID
|
||||||
WHERE p.AuthorID = $UserID
|
WHERE p.AuthorID = $UserID
|
||||||
AND ((f.MinClassRead <= ".$LoggedUser['Class'];
|
AND " . Forums::user_forums_sql();
|
||||||
|
|
||||||
if (!empty($RestrictedForums)) {
|
|
||||||
$SQL .= "
|
|
||||||
AND f.ID NOT IN ('$RestrictedForums')";
|
|
||||||
}
|
|
||||||
$SQL .= '
|
|
||||||
)';
|
|
||||||
|
|
||||||
if (!empty($PermittedForums)) {
|
|
||||||
$SQL .= "
|
|
||||||
OR f.ID IN ('$PermittedForums')";
|
|
||||||
}
|
|
||||||
$SQL .= '
|
|
||||||
)';
|
|
||||||
|
|
||||||
if ($ShowUnread) {
|
if ($ShowUnread) {
|
||||||
$SQL .= '
|
$SQL .= '
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
empty($_GET['req']) ||
|
empty($_GET['req'])
|
||||||
empty($_GET['uid']) ||
|
|| empty($_GET['uid'])
|
||||||
empty($_GET['aid']) ||
|
|| empty($_GET['aid'])
|
||||||
empty($_GET['key']) ||
|
|| empty($_GET['key'])
|
||||||
!is_number($_GET['uid']) ||
|
|| !is_number($_GET['uid'])
|
||||||
!is_number($_GET['aid']) ||
|
|| !is_number($_GET['aid'])
|
||||||
!in_array($_GET['req'], $Available, true)
|
|| !in_array($_GET['req'], $Available, true)
|
||||||
) {
|
) {
|
||||||
error('invalid');
|
error('invalid');
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ function compare($X, $Y) {
|
|||||||
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
|
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
|
||||||
$Text = new TEXT;
|
$Text = new TEXT;
|
||||||
|
|
||||||
// Similar artist map
|
// Similar Artist Map
|
||||||
include(SERVER_ROOT.'/classes/artists_similar.class.php');
|
include(SERVER_ROOT.'/classes/artists_similar.class.php');
|
||||||
|
|
||||||
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
|
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
|
||||||
@ -343,9 +343,9 @@ function compare($X, $Y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$DisplayName = "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
|
$DisplayName = "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
|
||||||
if (check_perms('users_mod') || check_perms('torrents_fix_ghosts')) {
|
if (check_perms('users_mod') || check_perms('torrents_fix_ghosts')) {
|
||||||
$DisplayName .= ' <a href="torrents.php?action=fix_group&groupid='.$GroupID.'&artistid='.$ArtistID.'&auth='.$LoggedUser['AuthKey'].'" class="brackets" title="Fix ghost DB entry">Fix</a>';
|
$DisplayName .= ' <a href="torrents.php?action=fix_group&groupid='.$GroupID.'&artistid='.$ArtistID.'&auth='.$LoggedUser['AuthKey'].'" class="brackets tooltip" title="Fix ghost DB entry">Fix</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -390,22 +390,22 @@ function compare($X, $Y) {
|
|||||||
?>
|
?>
|
||||||
<tr class="releases_<?=$ReleaseType?> group discog<?=$SnatchedGroupClass . $HideDiscog?>">
|
<tr class="releases_<?=$ReleaseType?> group discog<?=$SnatchedGroupClass . $HideDiscog?>">
|
||||||
<td class="center">
|
<td class="center">
|
||||||
<div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
|
<div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
|
||||||
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group. Hold "Ctrl" while clicking to collapse all groups in this release type."></a>
|
<a href="#" class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold "Ctrl" while clicking to collapse all groups in this release type."></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="5" class="big_info">
|
<td colspan="5" class="big_info">
|
||||||
<? if ($LoggedUser['CoverArt']) : ?>
|
<? if ($LoggedUser['CoverArt']) { ?>
|
||||||
<div class="group_image float_left clear">
|
<div class="group_image float_left clear">
|
||||||
<? ImageTools::cover_thumb($WikiImage, $GroupCategoryID) ?>
|
<? ImageTools::cover_thumb($WikiImage, $GroupCategoryID) ?>
|
||||||
</div>
|
</div>
|
||||||
<? endif; ?>
|
<? } ?>
|
||||||
<div class="group_info clear">
|
<div class="group_info clear">
|
||||||
<strong><?=$DisplayName?></strong>
|
<strong><?=$DisplayName?></strong>
|
||||||
<? if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
|
<? if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
|
||||||
echo "<a style=\"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"remove_bookmark brackets\" title=\"Unbookmark\" onclick=\"Unbookmark('torrent', $GroupID, 'Bookmark'); return false;\">Unbookmark</a>";
|
echo "<a style=\"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"remove_bookmark brackets\" onclick=\"Unbookmark('torrent', $GroupID, 'Bookmark'); return false;\">Remove bookmark</a>";
|
||||||
} else {
|
} else {
|
||||||
echo "<a style=\"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"add_bookmark brackets\" title=\"Bookmark\" onclick=\"Bookmark('torrent', $GroupID, 'Unbookmark'); return false;\">Bookmark</a>";
|
echo "<a style=\"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"add_bookmark brackets\" onclick=\"Bookmark('torrent', $GroupID, 'Remove bookmark'); return false;\">Bookmark</a>";
|
||||||
} ?>
|
} ?>
|
||||||
<?Votes::vote_link($GroupID, $UserVotes[$GroupID]['Type']);?>
|
<?Votes::vote_link($GroupID, $UserVotes[$GroupID]['Type']);?>
|
||||||
<div class="tags"><?=$TorrentTags->format('torrents.php?taglist=', $Name)?></div>
|
<div class="tags"><?=$TorrentTags->format('torrents.php?taglist=', $Name)?></div>
|
||||||
@ -428,16 +428,19 @@ function compare($X, $Y) {
|
|||||||
}
|
}
|
||||||
$SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : '');
|
$SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : '');
|
||||||
|
|
||||||
if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
|
if ($Torrent['RemasterTitle'] != $LastRemasterTitle
|
||||||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] !=
|
|| $Torrent['RemasterYear'] != $LastRemasterYear
|
||||||
$LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia
|
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|
||||||
|
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|
||||||
|
|| $FirstUnknown
|
||||||
|
|| $Torrent['Media'] != $LastMedia
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$EditionID++;
|
$EditionID++;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr class="releases_<?=$ReleaseType?> groupid_<?=$GroupID?> edition group_torrent discog<?=$SnatchedGroupClass . $HideDiscog . $HideTorrents?>">
|
<tr class="releases_<?=$ReleaseType?> groupid_<?=$GroupID?> edition group_torrent discog<?=$SnatchedGroupClass . $HideDiscog . $HideTorrents?>">
|
||||||
<td colspan="6" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?=Torrents::edition_string($Torrent, $TorrentList[$Group['GroupID']])?></strong></td>
|
<td colspan="6" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event);" class="tooltip" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?=Torrents::edition_string($Torrent, $TorrentList[$Group['GroupID']])?></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -452,15 +455,15 @@ function compare($X, $Y) {
|
|||||||
<span>
|
<span>
|
||||||
[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$Torrent['HasFile'] ? 'DL' : 'Missing'?></a>
|
[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download"><?=$Torrent['HasFile'] ? 'DL' : 'Missing'?></a>
|
||||||
<? if (Torrents::can_use_token($Torrent)) { ?>
|
<? if (Torrents::can_use_token($Torrent)) { ?>
|
||||||
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
|
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');" class="tooltip">FL</a>
|
||||||
<? } ?> ]
|
<? } ?> ]
|
||||||
</span>
|
</span>
|
||||||
» <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
|
» <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
|
||||||
</td>
|
</td>
|
||||||
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
||||||
<td><?=number_format($Torrent['Snatched'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
|
||||||
<td<?=(($Torrent['Seeders'] == 0) ? ' class="r00"' : '')?>><?=number_format($Torrent['Seeders'])?></td>
|
<td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
|
||||||
<td><?=number_format($Torrent['Leechers'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -475,7 +478,7 @@ function compare($X, $Y) {
|
|||||||
|
|
||||||
//----------------- End building list and getting stats
|
//----------------- End building list and getting stats
|
||||||
|
|
||||||
View::show_header($Name, 'browse,requests,bbcode,comments,voting,recommend');
|
View::show_header($Name, 'browse,requests,bbcode,comments,voting,recommend,subscriptions');
|
||||||
?>
|
?>
|
||||||
<div class="thin">
|
<div class="thin">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -497,7 +500,7 @@ function compare($X, $Y) {
|
|||||||
$Notify = $DB->next_record(MYSQLI_ASSOC, false);
|
$Notify = $DB->next_record(MYSQLI_ASSOC, false);
|
||||||
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
|
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
|
||||||
}
|
}
|
||||||
if (stripos($Notify['Artists'], '|'.$Name.'|') === false) {
|
if (stripos($Notify['Artists'], "|$Name|") === false) {
|
||||||
?>
|
?>
|
||||||
<a href="artist.php?action=notify&artistid=<?=$ArtistID?>&auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Notify of new uploads</a>
|
<a href="artist.php?action=notify&artistid=<?=$ArtistID?>&auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Notify of new uploads</a>
|
||||||
<? } else { ?>
|
<? } else { ?>
|
||||||
@ -512,6 +515,7 @@ function compare($X, $Y) {
|
|||||||
<? } else { ?>
|
<? } else { ?>
|
||||||
<a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Bookmark('artist', <?=$ArtistID?>, 'Remove bookmark'); return false;" class="brackets">Bookmark</a>
|
<a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Bookmark('artist', <?=$ArtistID?>, 'Remove bookmark'); return false;" class="brackets">Bookmark</a>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
<a href="#" id="subscribelink_artist<?=$ArtistID?>" class="brackets" onclick="SubscribeComments('artist',<?=$ArtistID?>);return false;"><?=Subscriptions::has_subscribed_comments('artist', $ArtistID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
|
||||||
<!-- <a href="#" id="recommend" class="brackets">Recommend</a> -->
|
<!-- <a href="#" id="recommend" class="brackets">Recommend</a> -->
|
||||||
<?
|
<?
|
||||||
if (check_perms('site_edit_wiki')) {
|
if (check_perms('site_edit_wiki')) {
|
||||||
@ -544,7 +548,7 @@ function compare($X, $Y) {
|
|||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
||||||
<div class="box box_search">
|
<div class="box box_search">
|
||||||
<div class="head"><strong>Search file lists</strong></div>
|
<div class="head"><strong>File Lists Search</strong></div>
|
||||||
<ul class="nobullet">
|
<ul class="nobullet">
|
||||||
<li>
|
<li>
|
||||||
<form class="search_form" name="filelists" action="torrents.php">
|
<form class="search_form" name="filelists" action="torrents.php">
|
||||||
@ -617,17 +621,15 @@ function compare($X, $Y) {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<? } ?>
|
<?
|
||||||
|
} //if (check_perms('zip_downloader')) ?>
|
||||||
<div class="box box_tags">
|
<div class="box box_tags">
|
||||||
<div class="head"><strong>Tags</strong></div>
|
<div class="head"><strong>Tags</strong></div>
|
||||||
<ul class="stats nobullet">
|
<ul class="stats nobullet">
|
||||||
<?
|
<? Tags::format_top(50, 'torrents.php?taglist=', $Name); ?>
|
||||||
Tags::format_top(50, "torrents.php?taglist=", $Name);
|
|
||||||
?>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
|
|
||||||
// Stats
|
// Stats
|
||||||
?>
|
?>
|
||||||
<div class="box box_info box_statistics_artist">
|
<div class="box box_info box_statistics_artist">
|
||||||
@ -663,12 +665,12 @@ function compare($X, $Y) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="box box_artists">
|
<div class="box box_artists">
|
||||||
<div class="head"><strong>Similar artists</strong></div>
|
<div class="head"><strong>Similar Artists</strong></div>
|
||||||
<ul class="stats nobullet">
|
<ul class="stats nobullet">
|
||||||
<?
|
<? if ($NumSimilar == 0) { ?>
|
||||||
if ($NumSimilar == 0) { ?>
|
|
||||||
<li><span style="font-style: italic;">None found</span></li>
|
<li><span style="font-style: italic;">None found</span></li>
|
||||||
<? }
|
<?
|
||||||
|
}
|
||||||
$First = true;
|
$First = true;
|
||||||
foreach ($SimilarArray as $SimilarArtist) {
|
foreach ($SimilarArray as $SimilarArtist) {
|
||||||
list($Artist2ID, $Artist2Name, $Score, $SimilarID) = $SimilarArtist;
|
list($Artist2ID, $Artist2Name, $Score, $SimilarID) = $SimilarArtist;
|
||||||
@ -678,16 +680,16 @@ function compare($X, $Y) {
|
|||||||
$First = false;
|
$First = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$FontSize = (ceil((((($Score - 2) / $Max - 2) * 4)))) + 8;
|
$FontSize = (ceil(((($Score - 2) / $Max - 2) * 4))) + 8;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<span title="<?=$Score?>"><a href="artist.php?id=<?=$Artist2ID?>" style="float: left; display: block;"><?=$Artist2Name?></a></span>
|
<span title="<?=$Score?>"><a href="artist.php?id=<?=$Artist2ID?>" style="float: left; display: block;"><?=$Artist2Name?></a></span>
|
||||||
<div style="float: right; display: block; letter-spacing: -1px;">
|
<div style="float: right; display: block; letter-spacing: -1px;">
|
||||||
<a href="artist.php?action=vote_similar&artistid=<?=$ArtistID?>&similarid=<?=$SimilarID?>&way=down" style="font-family: monospace;" title="Vote down this similar artist. Use this when you feel that the two artists are not all that similar." class="brackets">−</a>
|
<a href="artist.php?action=vote_similar&artistid=<?=$ArtistID?>&similarid=<?=$SimilarID?>&way=down" style="font-family: monospace;" class="tooltip" title="Vote down this similar artist. Use this when you feel that the two artists are not all that similar." class="brackets">−</a>
|
||||||
<a href="artist.php?action=vote_similar&artistid=<?=$ArtistID?>&similarid=<?=$SimilarID?>&way=up" style="font-family: monospace;" title="Vote up this similar artist. Use this when you feel that the two artists are quite similar." class="brackets">+</a>
|
<a href="artist.php?action=vote_similar&artistid=<?=$ArtistID?>&similarid=<?=$SimilarID?>&way=up" style="font-family: monospace;" class="tooltip" title="Vote up this similar artist. Use this when you feel that the two artists are quite similar." class="brackets">+</a>
|
||||||
<? if (check_perms('site_delete_tag')) { ?>
|
<? if (check_perms('site_delete_tag')) { ?>
|
||||||
<span class="remove remove_artist"><a href="artist.php?action=delete_similar&similarid=<?=$SimilarID?>&auth=<?=$LoggedUser['AuthKey']?>" title="Remove this similar artist" class="brackets">X</a></span>
|
<span class="remove remove_artist"><a href="artist.php?action=delete_similar&similarid=<?=$SimilarID?>&auth=<?=$LoggedUser['AuthKey']?>" class="tooltip" title="Remove this similar artist" class="brackets">X</a></span>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
</div>
|
</div>
|
||||||
<br style="clear: both;" />
|
<br style="clear: both;" />
|
||||||
@ -744,7 +746,8 @@ function compare($X, $Y) {
|
|||||||
<td width="85%"><a href="#">↑</a> This artist is in <?=number_format(count($Collages))?> collage<?=((count($Collages) > 1) ? 's' : '')?><?=$SeeAll?></td>
|
<td width="85%"><a href="#">↑</a> This artist is in <?=number_format(count($Collages))?> collage<?=((count($Collages) > 1) ? 's' : '')?><?=$SeeAll?></td>
|
||||||
<td># artists</td>
|
<td># artists</td>
|
||||||
</tr>
|
</tr>
|
||||||
<? foreach ($Indices as $i) {
|
<?
|
||||||
|
foreach ($Indices as $i) {
|
||||||
list($CollageName, $CollageArtists, $CollageID) = $Collages[$i];
|
list($CollageName, $CollageArtists, $CollageID) = $Collages[$i];
|
||||||
unset($Collages[$i]);
|
unset($Collages[$i]);
|
||||||
?>
|
?>
|
||||||
@ -752,7 +755,8 @@ function compare($X, $Y) {
|
|||||||
<td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
|
<td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
|
||||||
<td><?=number_format($CollageArtists)?></td>
|
<td><?=number_format($CollageArtists)?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<? }
|
<?
|
||||||
|
}
|
||||||
foreach ($Collages as $Collage) {
|
foreach ($Collages as $Collage) {
|
||||||
list($CollageName, $CollageArtists, $CollageID) = $Collage;
|
list($CollageName, $CollageArtists, $CollageID) = $Collage;
|
||||||
?>
|
?>
|
||||||
@ -800,7 +804,7 @@ function compare($X, $Y) {
|
|||||||
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title</a>";
|
$FullName = "<a href=\"requests.php?action=view&id=$RequestID\">$Title</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$Row = ($Row == 'a') ? 'b' : 'a';
|
$Row = $Row === 'a' ? 'b' : 'a';
|
||||||
|
|
||||||
$Tags = Requests::get_tags($RequestID);
|
$Tags = Requests::get_tags($RequestID);
|
||||||
$ReqTagList = array();
|
$ReqTagList = array();
|
||||||
@ -833,7 +837,7 @@ function compare($X, $Y) {
|
|||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar artist map
|
// Similar Artist Map
|
||||||
|
|
||||||
if ($NumSimilar > 0) {
|
if ($NumSimilar > 0) {
|
||||||
if ($SimilarData = $Cache->get_value("similar_positions_$ArtistID")) {
|
if ($SimilarData = $Cache->get_value("similar_positions_$ArtistID")) {
|
||||||
@ -862,7 +866,7 @@ function compare($X, $Y) {
|
|||||||
<div id="similar_artist_map" class="box">
|
<div id="similar_artist_map" class="box">
|
||||||
<div id="flipper_head" class="head">
|
<div id="flipper_head" class="head">
|
||||||
<a href="#">↑</a>
|
<a href="#">↑</a>
|
||||||
<strong id="flipper_title">Similar artist map</strong>
|
<strong id="flipper_title">Similar Artist Map</strong>
|
||||||
<a id="flip_to" class="brackets" href="#" onclick="flipView(); return false;">Switch to cloud</a>
|
<a id="flip_to" class="brackets" href="#" onclick="flipView(); return false;">Switch to cloud</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="flip_view_1" style="display: block; width: <?=(WIDTH)?>px; height: <?=(HEIGHT)?>px; position: relative; background-image: url(static/similar/<?=($ArtistID)?>.png?t=<?=(time())?>);">
|
<div id="flip_view_1" style="display: block; width: <?=(WIDTH)?>px; height: <?=(HEIGHT)?>px; position: relative; background-image: url(static/similar/<?=($ArtistID)?>.png?t=<?=(time())?>);">
|
||||||
@ -871,7 +875,7 @@ function compare($X, $Y) {
|
|||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div id="flip_view_2" style="display: none; width: <?=WIDTH?>px; height: <?=HEIGHT?>px;">
|
<div id="flip_view_2" style="display: none; width: <?=WIDTH?>px; height: <?=HEIGHT?>px;">
|
||||||
<canvas width="<?=(WIDTH)?>px" height="<?=(HEIGHT - 20)?>px" id="similarArtistsCanvas"></canvas>
|
<canvas width="<?=WIDTH?>px" height="<?=(HEIGHT - 20)?>px" id="similarArtistsCanvas"></canvas>
|
||||||
<div id="artistTags" style="display: none;">
|
<div id="artistTags" style="display: none;">
|
||||||
<ul><li></li></ul>
|
<ul><li></li></ul>
|
||||||
</div>
|
</div>
|
||||||
@ -888,7 +892,7 @@ function flipView() {
|
|||||||
if (state) {
|
if (state) {
|
||||||
document.getElementById('flip_view_1').style.display = 'none';
|
document.getElementById('flip_view_1').style.display = 'none';
|
||||||
document.getElementById('flip_view_2').style.display = 'block';
|
document.getElementById('flip_view_2').style.display = 'block';
|
||||||
document.getElementById('flipper_title').innerHTML = 'Similar artist cloud';
|
document.getElementById('flipper_title').innerHTML = 'Similar Artist Cloud';
|
||||||
document.getElementById('flip_to').innerHTML = 'Switch to map';
|
document.getElementById('flip_to').innerHTML = 'Switch to map';
|
||||||
|
|
||||||
if (!cloudLoaded) {
|
if (!cloudLoaded) {
|
||||||
@ -902,7 +906,7 @@ function flipView() {
|
|||||||
else {
|
else {
|
||||||
document.getElementById('flip_view_1').style.display = 'block';
|
document.getElementById('flip_view_1').style.display = 'block';
|
||||||
document.getElementById('flip_view_2').style.display = 'none';
|
document.getElementById('flip_view_2').style.display = 'none';
|
||||||
document.getElementById('flipper_title').innerHTML = 'Similar artist map';
|
document.getElementById('flipper_title').innerHTML = 'Similar Artist Map';
|
||||||
document.getElementById('flip_to').innerHTML = 'Switch to cloud';
|
document.getElementById('flip_to').innerHTML = 'Switch to cloud';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -939,154 +943,37 @@ function require(file, callback) {
|
|||||||
</div>
|
</div>
|
||||||
<div id="body" class="body"><?=$Text->full_format($Body)?></div>
|
<div id="body" class="body"><?=$Text->full_format($Body)?></div>
|
||||||
</div>
|
</div>
|
||||||
<? if (defined('LASTFM_API_KEY')) {
|
<?
|
||||||
|
if (defined('LASTFM_API_KEY')) {
|
||||||
include(SERVER_ROOT.'/sections/artist/concerts.php');
|
include(SERVER_ROOT.'/sections/artist/concerts.php');
|
||||||
} ?>
|
}
|
||||||
<?php
|
|
||||||
// --- Comments ---
|
// --- Comments ---
|
||||||
|
|
||||||
// gets the amount of comments for this group
|
list($NumComments, $Page, $Thread, $LastRead) = Comments::load('artist', $ArtistID);
|
||||||
$Results = $Cache->get_value("artist_comments_$ArtistID");
|
$Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
|
||||||
if ($Results === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
COUNT(c.ID)
|
|
||||||
FROM artist_comments as c
|
|
||||||
WHERE c.ArtistID = '$ArtistID'");
|
|
||||||
list($Results) = $DB->next_record();
|
|
||||||
$Cache->cache_value("artist_comments_$ArtistID", $Results, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM artist_comments
|
|
||||||
WHERE ArtistID = $ArtistID
|
|
||||||
AND ID <= $_GET[postid]");
|
|
||||||
list($PostNum) = $DB->next_record();
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
|
|
||||||
} else {
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $Results);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the cache catalogue
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
|
|
||||||
//---------- Get some data to start processing
|
|
||||||
|
|
||||||
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
|
|
||||||
$Catalogue = $Cache->get_value("artist_comments_{$ArtistID}_catalogue_$CatalogueID");
|
|
||||||
if ($Catalogue === false) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
c.ID,
|
|
||||||
c.AuthorID,
|
|
||||||
c.AddedTime,
|
|
||||||
c.Body,
|
|
||||||
c.EditedUserID,
|
|
||||||
c.EditedTime,
|
|
||||||
u.Username
|
|
||||||
FROM artist_comments as c
|
|
||||||
LEFT JOIN users_main AS u ON u.ID = c.EditedUserID
|
|
||||||
WHERE c.ArtistID = '$ArtistID'
|
|
||||||
ORDER BY c.ID
|
|
||||||
LIMIT $CatalogueLimit");
|
|
||||||
$Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
|
|
||||||
$Cache->cache_value("artist_comments_{$ArtistID}_catalogue_$CatalogueID", $Catalogue, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
|
|
||||||
$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
|
|
||||||
?>
|
?>
|
||||||
<div id="artistcomments" class="linkbox">
|
<div id="artistcomments" class="linkbox">
|
||||||
<a name="comments"></a>
|
<a name="comments"></a>
|
||||||
<?
|
<?=$Pages?>
|
||||||
$Pages = Format::get_pages($Page, $Results, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
|
|
||||||
echo $Pages;
|
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
|
|
||||||
//---------- Begin printing
|
//---------- Begin printing
|
||||||
foreach ($Thread as $Key => $Post) {
|
CommentsView::render_comments($Thread, $LastRead, "artist.php?id=$ArtistID");
|
||||||
list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
|
|
||||||
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
|
|
||||||
?>
|
?>
|
||||||
<table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '')?>" id="post<?=$PostID?>">
|
|
||||||
<colgroup>
|
|
||||||
<? if (Users::has_avatars_enabled()) { ?>
|
|
||||||
<col class="col_avatar" />
|
|
||||||
<? } ?>
|
|
||||||
<col class="col_post_body" />
|
|
||||||
</colgroup>
|
|
||||||
<tr class="colhead_dark">
|
|
||||||
<td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
|
|
||||||
<div style="float: left;"><a class="post_id" href="artist.php?id=<?=$ArtistID?>&postid=<?=$PostID?>#post<?=$PostID?>">#<?=$PostID?></a>
|
|
||||||
<strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?>
|
|
||||||
- <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');" class="brackets">Quote</a>
|
|
||||||
<? if ($AuthorID == $LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
|
|
||||||
- <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','<?=$Key?>');" class="brackets">Edit</a>
|
|
||||||
<?
|
|
||||||
}
|
|
||||||
if (check_perms('site_moderate_forums')) { ?>
|
|
||||||
- <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a>
|
|
||||||
<? } ?>
|
|
||||||
</div>
|
|
||||||
<div id="bar<?=$PostID?>" style="float: right;">
|
|
||||||
<a href="reports.php?action=report&type=artist_comment&id=<?=$PostID?>" class="brackets">Report</a>
|
|
||||||
<?
|
|
||||||
if (check_perms('users_warn') && $AuthorID != $LoggedUser['ID']) {
|
|
||||||
$AuthorInfo = Users::user_info($AuthorID);
|
|
||||||
if ($LoggedUser['Class'] >= $AuthorInfo['Class']) {
|
|
||||||
?>
|
|
||||||
<form class="manage_form hidden" name="user" id="warn<?=$PostID?>" action="" method="post">
|
|
||||||
<input type="hidden" name="action" value="warn" />
|
|
||||||
<input type="hidden" name="artistid" value="<?=$ArtistID?>" />
|
|
||||||
<input type="hidden" name="postid" value="<?=$PostID?>" />
|
|
||||||
<input type="hidden" name="userid" value="<?=$AuthorID?>" />
|
|
||||||
<input type="hidden" name="key" value="<?=$Key?>" />
|
|
||||||
</form>
|
|
||||||
- <a href="#" onclick="$('#warn<?=$PostID?>').raw().submit(); return false;" class="brackets">Warn</a>
|
|
||||||
<?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<a href="#">↑</a>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<? if (Users::has_avatars_enabled()) { ?>
|
|
||||||
<td class="avatar" valign="top">
|
|
||||||
<?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
|
|
||||||
</td>
|
|
||||||
<? } ?>
|
|
||||||
<td class="body" valign="top">
|
|
||||||
<div id="content<?=$PostID?>">
|
|
||||||
<?=$Text->full_format($CommentBody)?>
|
|
||||||
<? if ($EditedUserID) { ?>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<? if (check_perms('site_admin_forums')) { ?>
|
|
||||||
<a href="#content<?=$PostID?>" onclick="LoadEdit('artist', <?=$PostID?>, 1); return false;">«</a>
|
|
||||||
<? } ?>
|
|
||||||
Last edited by
|
|
||||||
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime, 2, true, true)?>
|
|
||||||
<? } ?>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<? } ?>
|
|
||||||
<div class="linkbox">
|
<div class="linkbox">
|
||||||
<?=($Pages)?>
|
<?=($Pages)?>
|
||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
View::parse('generic/reply/quickreply.php', array(
|
View::parse('generic/reply/quickreply.php', array(
|
||||||
'InputName' => 'artistid',
|
'InputName' => 'pageid',
|
||||||
'InputID' => $ArtistID));
|
'InputID' => $ArtistID,
|
||||||
|
'Action' => 'comments.php?page=artist',
|
||||||
|
'InputAction' => 'take_post',
|
||||||
|
'SubscribeBox' => true
|
||||||
|
));
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1099,7 +986,7 @@ function require(file, callback) {
|
|||||||
if ($RevisionID) {
|
if ($RevisionID) {
|
||||||
$Key = "artist_$ArtistID" . "_revision_$RevisionID";
|
$Key = "artist_$ArtistID" . "_revision_$RevisionID";
|
||||||
} else {
|
} else {
|
||||||
$Key = 'artist_' . $ArtistID;
|
$Key = "artist_$ArtistID";
|
||||||
}
|
}
|
||||||
|
|
||||||
$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, array(), array(), $VanityHouseArtist));
|
$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, array(), array(), $VanityHouseArtist));
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
if ($DB->has_results()) {
|
if ($DB->has_results()) {
|
||||||
?>
|
?>
|
||||||
<div class="thin">
|
<div class="thin">
|
||||||
There are still torrents that have <a href="artist.php?id=<?=$ArtistID?>" title="View Artist"><?=$Name?></a> as an artist.<br />
|
There are still torrents that have <a href="artist.php?id=<?=$ArtistID?>" class="tooltip" title="View artist"><?=$Name?></a> as an artist.<br />
|
||||||
Please remove the artist from these torrents manually before attempting to delete.<br />
|
Please remove the artist from these torrents manually before attempting to delete.<br />
|
||||||
<div class="box pad">
|
<div class="box pad">
|
||||||
<ul>
|
<ul>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
if ($DB->has_results()) {
|
if ($DB->has_results()) {
|
||||||
?>
|
?>
|
||||||
<div class="thin">
|
<div class="thin">
|
||||||
There are still requests that have <a href="artist.php?id=<?=$ArtistID?>" title="View Artist"><?=$Name?></a> as an artist.<br />
|
There are still requests that have <a href="artist.php?id=<?=$ArtistID?>" class="tooltip" title="View artist"><?=$Name?></a> as an artist.<br />
|
||||||
Please remove the artist from these requests manually before attempting to delete.<br />
|
Please remove the artist from these requests manually before attempting to delete.<br />
|
||||||
<div class="box pad">
|
<div class="box pad">
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -112,14 +112,14 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<span title="Alias ID"><?=$AliasID?></span>. <span title="Alias name"><?=$AliasName?></span>
|
<span class="tooltip" title="Alias ID"><?=$AliasID?></span>. <span class="tooltip" title="Alias name"><?=$AliasName?></span>
|
||||||
<? if ($User) { ?>
|
<? if ($User) { ?>
|
||||||
<a href="user.php?id=<?=$User?>" title="Alias creator" class="brackets">User</a>
|
<a href="user.php?id=<?=$User?>" title="Alias creator" class="brackets tooltip">User</a>
|
||||||
<? }
|
<? }
|
||||||
if ($Redirect) { ?>
|
if ($Redirect) { ?>
|
||||||
(writes redirect to <span title="Target alias ID"><?=$Redirect?></span>)
|
(writes redirect to <span class="tooltip" title="Target alias ID"><?=$Redirect?></span>)
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<a href="artist.php?action=delete_alias&aliasid=<?=$AliasID?>&auth=<?=$LoggedUser['AuthKey']?>" title="Delete this alias" class="brackets">X</a>
|
<a href="artist.php?action=delete_alias&aliasid=<?=$AliasID?>&auth=<?=$LoggedUser['AuthKey']?>" title="Delete this alias" class="brackets tooltip">X</a>
|
||||||
</li>
|
</li>
|
||||||
<? }
|
<? }
|
||||||
?>
|
?>
|
||||||
|
@ -34,61 +34,6 @@
|
|||||||
case 'change_artistid':
|
case 'change_artistid':
|
||||||
require(SERVER_ROOT . '/sections/artist/change_artistid.php');
|
require(SERVER_ROOT . '/sections/artist/change_artistid.php');
|
||||||
break;
|
break;
|
||||||
case 'reply':
|
|
||||||
authorize();
|
|
||||||
|
|
||||||
if (!isset($_POST['artistid']) || !isset($_POST['body']) || !is_number($_POST['artistid']) || trim($_POST['body']) === '') {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
if ($LoggedUser['DisablePosting']) {
|
|
||||||
error('Your posting privileges have been removed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ArtistID = $_POST['artistid'];
|
|
||||||
if (!$ArtistID) {
|
|
||||||
error(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
CEIL((
|
|
||||||
SELECT COUNT(ID) + 1
|
|
||||||
FROM artist_comments AS ac
|
|
||||||
WHERE ac.ArtistID = '" . db_string($ArtistID) . "'
|
|
||||||
) / " . TORRENT_COMMENTS_PER_PAGE . "
|
|
||||||
) AS Pages");
|
|
||||||
list($Pages) = $DB->next_record();
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
INSERT INTO artist_comments
|
|
||||||
(ArtistID, AuthorID, AddedTime, Body)
|
|
||||||
VALUES
|
|
||||||
('" . db_string($ArtistID) . "', '" . db_string($LoggedUser['ID']) . "', '" . sqltime() . "', '" . db_string($_POST['body']) . "')");
|
|
||||||
$PostID = $DB->inserted_id();
|
|
||||||
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
|
|
||||||
$Post = array(
|
|
||||||
'ID' => $PostID,
|
|
||||||
'AuthorID' => $LoggedUser['ID'],
|
|
||||||
'AddedTime' => sqltime(),
|
|
||||||
'Body' => $_POST['body'],
|
|
||||||
'EditedUserID' => 0,
|
|
||||||
'EditedTime' => '0000-00-00 00:00:00',
|
|
||||||
'Username' => ''
|
|
||||||
);
|
|
||||||
$Cache->insert('', $Post);
|
|
||||||
$Cache->commit_transaction(0);
|
|
||||||
$Cache->increment("artist_comments_$ArtistID");
|
|
||||||
|
|
||||||
header("Location: artist.php?id=$ArtistID&page=$Pages");
|
|
||||||
break;
|
|
||||||
case 'warn' :
|
|
||||||
include(SERVER_ROOT . '/sections/artist/warn.php');
|
|
||||||
break;
|
|
||||||
case 'take_warn' :
|
|
||||||
include(SERVER_ROOT . '/sections/artist/take_warn.php');
|
|
||||||
break;
|
|
||||||
case 'concert_thread':
|
case 'concert_thread':
|
||||||
include(SERVER_ROOT . '/sections/artist/concert_thread.php');
|
include(SERVER_ROOT . '/sections/artist/concert_thread.php');
|
||||||
break;
|
break;
|
||||||
@ -103,135 +48,6 @@
|
|||||||
case 'autocomplete':
|
case 'autocomplete':
|
||||||
require('sections/artist/autocomplete.php');
|
require('sections/artist/autocomplete.php');
|
||||||
break;
|
break;
|
||||||
case 'get_post':
|
|
||||||
if (!$_GET['post'] || !is_number($_GET['post'])) {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
$DB->query("
|
|
||||||
SELECT Body
|
|
||||||
FROM artist_comments
|
|
||||||
WHERE ID = '" . db_string($_GET['post']) . "'");
|
|
||||||
list($Body) = $DB->next_record(MYSQLI_NUM);
|
|
||||||
echo trim($Body);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'delete_comment':
|
|
||||||
authorize();
|
|
||||||
|
|
||||||
// Quick SQL injection check
|
|
||||||
if (!$_GET['postid'] || !is_number($_GET['postid'])) {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure they are moderators
|
|
||||||
if (!check_perms('site_moderate_forums')) {
|
|
||||||
error(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get topicid, forumid, number of pages
|
|
||||||
$DB->query('
|
|
||||||
SELECT
|
|
||||||
ArtistID,
|
|
||||||
CEIL(COUNT(ac.ID) / ' . TORRENT_COMMENTS_PER_PAGE . ') AS Pages,
|
|
||||||
CEIL(SUM(IF(ac.ID <= ' . $_GET['postid'] . ', 1, 0)) / ' . TORRENT_COMMENTS_PER_PAGE . ') AS Page
|
|
||||||
FROM artist_comments AS ac
|
|
||||||
WHERE ac.ArtistID = (
|
|
||||||
SELECT ArtistID
|
|
||||||
FROM artist_comments
|
|
||||||
WHERE ID = ' . $_GET['postid'] . '
|
|
||||||
)
|
|
||||||
GROUP BY ac.ArtistID');
|
|
||||||
list($ArtistID, $Pages, $Page) = $DB->next_record();
|
|
||||||
|
|
||||||
// $Pages = number of pages in the thread
|
|
||||||
// $Page = which page the post is on
|
|
||||||
// These are set for cache clearing.
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
DELETE FROM artist_comments
|
|
||||||
WHERE ID = '" . db_string($_GET['postid']) . "'");
|
|
||||||
|
|
||||||
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
|
|
||||||
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
|
|
||||||
$Cache->delete_value("artist_comments_$ArtistID" . "_catalogue_$i");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete thread info cache (eg. number of pages)
|
|
||||||
$Cache->delete_value("artist_comments_$ArtistID");
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'takeedit_post':
|
|
||||||
authorize();
|
|
||||||
|
|
||||||
include(SERVER_ROOT . '/classes/text.class.php'); // Text formatting class
|
|
||||||
$Text = new TEXT;
|
|
||||||
|
|
||||||
// Quick SQL injection check
|
|
||||||
if (!$_POST['post'] || !is_number($_POST['post'])) {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mainly
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
ac.Body,
|
|
||||||
ac.AuthorID,
|
|
||||||
ac.ArtistID,
|
|
||||||
ac.AddedTime
|
|
||||||
FROM artist_comments AS ac
|
|
||||||
WHERE ac.ID = '" . db_string($_POST['post']) . "'");
|
|
||||||
list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record();
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
|
|
||||||
FROM artist_comments
|
|
||||||
WHERE ArtistID = $ArtistID
|
|
||||||
AND ID <= $_POST[post]");
|
|
||||||
list($Page) = $DB->next_record();
|
|
||||||
|
|
||||||
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
|
|
||||||
error(404);
|
|
||||||
}
|
|
||||||
if (!$DB->has_results()) {
|
|
||||||
error(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform the update
|
|
||||||
$DB->query("
|
|
||||||
UPDATE artist_comments
|
|
||||||
SET
|
|
||||||
Body = '" . db_string($_POST['body']) . "',
|
|
||||||
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
|
|
||||||
EditedTime = '" . sqltime() . "'
|
|
||||||
WHERE ID = '" . db_string($_POST['post']) . "'");
|
|
||||||
|
|
||||||
// Update the cache
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
|
|
||||||
|
|
||||||
$Cache->update_row($_POST['key'], array(
|
|
||||||
'ID' => $_POST['post'],
|
|
||||||
'AuthorID' => $AuthorID,
|
|
||||||
'AddedTime' => $AddedTime,
|
|
||||||
'Body' => $_POST['body'],
|
|
||||||
'EditedUserID' => db_string($LoggedUser['ID']),
|
|
||||||
'EditedTime' => sqltime(),
|
|
||||||
'Username' => $LoggedUser['Username']
|
|
||||||
));
|
|
||||||
$Cache->commit_transaction(0);
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
INSERT INTO comments_edits
|
|
||||||
(Page, PostID, EditUser, EditTime, Body)
|
|
||||||
VALUES
|
|
||||||
('artist', " . db_string($_POST['post']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
|
|
||||||
|
|
||||||
// This gets sent to the browser, which echoes it in place of the old body
|
|
||||||
echo $Text->full_format($_POST['body']);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
require(SERVER_ROOT . '/sections/artist/edit.php');
|
require(SERVER_ROOT . '/sections/artist/edit.php');
|
||||||
|
@ -218,6 +218,8 @@
|
|||||||
Requests::update_sphinx_requests($RequestID);
|
Requests::update_sphinx_requests($RequestID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Comments::merge('artist', $ArtistID, $TargetArtistID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
if (!check_perms('users_warn')) {
|
|
||||||
error(404);
|
|
||||||
}
|
|
||||||
Misc::assert_isset_request($_POST, array('reason', 'privatemessage', 'body', 'length', 'artistid', 'postid', 'userid'));
|
|
||||||
|
|
||||||
$Reason = $_POST['reason'];
|
|
||||||
$PrivateMessage = $_POST['privatemessage'];
|
|
||||||
$Body = $_POST['body'];
|
|
||||||
$Length = $_POST['length'];
|
|
||||||
$ArtistID = (int)$_POST['artistid'];
|
|
||||||
$PostID = (int)$_POST['postid'];
|
|
||||||
$UserID = (int)$_POST['userid'];
|
|
||||||
$Key = (int)$_POST['key'];
|
|
||||||
$SQLTime = sqltime();
|
|
||||||
$UserInfo = Users::user_info($UserID);
|
|
||||||
if ($UserInfo['Class'] > $LoggedUser['Class']) {
|
|
||||||
error(403);
|
|
||||||
}
|
|
||||||
$URL = "https://". SSL_SITE_URL."/artist.php?id=$ArtistID&postid=$PostID#post$PostID";
|
|
||||||
if ($Length != 'verbal') {
|
|
||||||
$Time = ((int)$Length) * (7 * 24 * 60 * 60);
|
|
||||||
Tools::warn_user($UserID, $Time, "$URL - $Reason");
|
|
||||||
$Subject = 'You have received a warning';
|
|
||||||
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this artist comment.[/url]\n\n$PrivateMessage";
|
|
||||||
$WarnTime = time_plus($Time);
|
|
||||||
$AdminComment = date('Y-m-d') . " - Warned until $WarnTime by " . $LoggedUser['Username'] . "\nReason: $URL - $Reason\n\n";
|
|
||||||
} else {
|
|
||||||
$Subject = 'You have received a verbal warning';
|
|
||||||
$PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n$PrivateMessage";
|
|
||||||
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
|
|
||||||
Tools::update_user_notes($UserID, $AdminComment);
|
|
||||||
}
|
|
||||||
$DB->query("
|
|
||||||
INSERT INTO users_warnings_forums (UserID, Comment)
|
|
||||||
VALUES('$UserID', '" . db_string($AdminComment) . "')
|
|
||||||
ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
|
|
||||||
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
|
|
||||||
|
|
||||||
// Mainly
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
ac.Body,
|
|
||||||
ac.AuthorID,
|
|
||||||
ac.ArtistID,
|
|
||||||
ac.AddedTime
|
|
||||||
FROM artist_comments AS ac
|
|
||||||
WHERE ac.ID = '$PostID'");
|
|
||||||
list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record();
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
|
|
||||||
FROM artist_comments
|
|
||||||
WHERE ArtistID = $ArtistID
|
|
||||||
AND ID <= $PostID");
|
|
||||||
list($Page) = $DB->next_record();
|
|
||||||
|
|
||||||
// Perform the update
|
|
||||||
$DB->query("
|
|
||||||
UPDATE artist_comments
|
|
||||||
SET
|
|
||||||
Body = '" . db_string($Body) . "',
|
|
||||||
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
|
|
||||||
EditedTime = '" . sqltime() . "'
|
|
||||||
WHERE ID = '$PostID'");
|
|
||||||
|
|
||||||
// Update the cache
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
|
|
||||||
|
|
||||||
$Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $Body, 'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
|
|
||||||
$Cache->commit_transaction(0);
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
|
|
||||||
VALUES ('artist', " . db_string($_POST['postid']) . ', ' . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
|
|
||||||
|
|
||||||
header("Location: artist.php?id=$ArtistID&postid=$PostID#post$PostID");
|
|
||||||
?>
|
|
@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
if (!check_perms('users_warn')) {
|
|
||||||
error(404);
|
|
||||||
}
|
|
||||||
Misc::assert_isset_request($_POST, array('artistid', 'postid', 'userid', 'key'));
|
|
||||||
|
|
||||||
$ArtistID = (int) $_POST['artistid'];
|
|
||||||
$PostID = (int) $_POST['postid'];
|
|
||||||
$UserID = (int) $_POST['userid'];
|
|
||||||
$Key = (int) $_POST['key'];
|
|
||||||
$UserInfo = Users::user_info($UserID);
|
|
||||||
$DB->query("
|
|
||||||
SELECT ac.Body, ac.AddedTime
|
|
||||||
FROM artist_comments AS ac
|
|
||||||
WHERE ac.ID = '" . db_string($PostID) . "'");
|
|
||||||
list($PostBody) = $DB -> next_record();
|
|
||||||
|
|
||||||
View::show_header('Warn User');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="thin">
|
|
||||||
<div class="header">
|
|
||||||
<h2>Warning <a href="user.php?id=<?=$UserID?>"><?=$UserInfo['Username']?></a></h2>
|
|
||||||
</div>
|
|
||||||
<div class="thin box pad">
|
|
||||||
<form class="create_form" name="warning" action="" onsubmit="quickpostform.submit_button.disabled=true;" method="post">
|
|
||||||
<input type="hidden" name="artistid" value="<?=$ArtistID?>" />
|
|
||||||
<input type="hidden" name="postid" value="<?=$PostID?>" />
|
|
||||||
<input type="hidden" name="userid" value="<?=$UserID?>" />
|
|
||||||
<input type="hidden" name="key" value="<?=$Key?>" />
|
|
||||||
<input type="hidden" name="action" value="take_warn" />
|
|
||||||
<table class="layout" align="center">
|
|
||||||
<tr>
|
|
||||||
<td class="label">Reason:</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="reason" size="30" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="label">Length:</td>
|
|
||||||
<td>
|
|
||||||
<select name="length">
|
|
||||||
<option value="verbal">Verbal</option>
|
|
||||||
<option value="1">1 week</option>
|
|
||||||
<option value="2">2 weeks</option>
|
|
||||||
<option value="4">4 weeks</option>
|
|
||||||
<? if (check_perms('users_mod')) { ?>
|
|
||||||
<option value="8">8 weeks</option>
|
|
||||||
<? } ?>
|
|
||||||
</select></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="label">Private message:</td>
|
|
||||||
<td>
|
|
||||||
<textarea id="message" style="width: 95%;" tabindex="1" onkeyup="resize('message');" name="privatemessage" cols="90" rows="4"></textarea>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="label">Edit post:</td>
|
|
||||||
<td>
|
|
||||||
<textarea id="body" style="width: 95%;" tabindex="1" onkeyup="resize('body');" name="body" cols="90" rows="8"><?=$PostBody?></textarea>
|
|
||||||
<br />
|
|
||||||
<input type="submit" id="submit_button" value="Warn user" tabindex="1" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<? View::show_footer(); ?>
|
|
@ -66,7 +66,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$DisplayName = '';
|
$DisplayName = '';
|
||||||
}
|
}
|
||||||
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
|
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$DisplayName = '';
|
$DisplayName = '';
|
||||||
}
|
}
|
||||||
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
|
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
}
|
}
|
||||||
$FlacID = $GroupIDs[$GroupID]['TorrentID'];
|
$FlacID = $GroupIDs[$GroupID]['TorrentID'];
|
||||||
|
|
||||||
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'&torrentid='.$FlacID.'" title="View Torrent">'.$GroupName.'</a>';
|
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&torrentid=$FlacID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@
|
|||||||
if (!$Edition['FlacID'] || count($Edition['Formats']) === 3) {
|
if (!$Edition['FlacID'] || count($Edition['Formats']) === 3) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent">'.$GroupName.'</a>';
|
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$DisplayName = '';
|
$DisplayName = '';
|
||||||
}
|
}
|
||||||
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'&torrentid='.$TorrentID.'#torrent'.$TorrentID.'" title="View Torrent">'.$GroupName.'</a>';
|
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&torrentid=$TorrentID#torrent$TorrentID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@
|
|||||||
$Debug->log_var($Edition, 'Skipping '.$RemIdent);
|
$Debug->log_var($Edition, 'Skipping '.$RemIdent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent">'.$GroupName.'</a>';
|
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ function transcode_parse_groups($Groups) {
|
|||||||
foreach ($Group['Editions'] as $RemIdent => $Edition) {
|
foreach ($Group['Editions'] as $RemIdent => $Edition) {
|
||||||
// TODO: point to the correct FLAC (?)
|
// TODO: point to the correct FLAC (?)
|
||||||
$FlacID = array_search(true, $Edition['FlacIDs']);
|
$FlacID = array_search(true, $Edition['FlacIDs']);
|
||||||
$DisplayName = $ArtistNames . "<a href=\"torrents.php?id=$GroupID&torrentid=$FlacID#torrent$FlacID\" title=\"View Torrent\">$GroupName</a>";
|
$DisplayName = $ArtistNames . "<a href=\"torrents.php?id=$GroupID&torrentid=$FlacID#torrent$FlacID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@
|
|||||||
if (!$Edition['FlacID'] || count($Edition['Formats']) === 3) {
|
if (!$Edition['FlacID'] || count($Edition['Formats']) === 3) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent">'.$GroupName.'</a>';
|
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
|
||||||
if ($GroupYear > 0) {
|
if ($GroupYear > 0) {
|
||||||
$DisplayName .= " [$GroupYear]";
|
$DisplayName .= " [$GroupYear]";
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ function compare($X, $Y) {
|
|||||||
?>
|
?>
|
||||||
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
|
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
|
||||||
<td class="center">
|
<td class="center">
|
||||||
<div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
|
<div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
|
||||||
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold "Ctrl" while clicking to collape all groups on this page."></a>
|
<a href="#" class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold "Ctrl" while clicking to collape all groups on this page."></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="center">
|
<td class="center">
|
||||||
@ -93,7 +93,7 @@ function compare($X, $Y) {
|
|||||||
<strong><?=$DisplayName?></strong>
|
<strong><?=$DisplayName?></strong>
|
||||||
<span style="text-align: right;" class="float_right">
|
<span style="text-align: right;" class="float_right">
|
||||||
<? if (!$Sneaky) { ?>
|
<? if (!$Sneaky) { ?>
|
||||||
<a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" title="Remove bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, '');return false;">Unbookmark</a>
|
<a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove bookmark</a>
|
||||||
<br />
|
<br />
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<?=time_diff($AddedTime);?>
|
<?=time_diff($AddedTime);?>
|
||||||
@ -129,7 +129,7 @@ function compare($X, $Y) {
|
|||||||
$EditionID++;
|
$EditionID++;
|
||||||
?>
|
?>
|
||||||
<tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
|
<tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
|
||||||
<td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
|
<td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" class="tooltip" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -143,16 +143,16 @@ function compare($X, $Y) {
|
|||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<span>[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
<span>[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
||||||
<? if (Torrents::can_use_token($Torrent)) { ?>
|
<? if (Torrents::can_use_token($Torrent)) { ?>
|
||||||
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
|
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');" class="tooltip">FL</a>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a> ]
|
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a> ]
|
||||||
</span>
|
</span>
|
||||||
» <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
|
» <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
|
||||||
</td>
|
</td>
|
||||||
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
||||||
<td><?=number_format($Torrent['Snatched'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
|
||||||
<td<?=(($Torrent['Seeders'] == 0) ? ' class="r00"' : '')?>><?=number_format($Torrent['Seeders'])?></td>
|
<td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
|
||||||
<td><?=number_format($Torrent['Leechers'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -185,22 +185,22 @@ function compare($X, $Y) {
|
|||||||
<span>
|
<span>
|
||||||
[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
||||||
<? if (Torrents::can_use_token($Torrent)) { ?>
|
<? if (Torrents::can_use_token($Torrent)) { ?>
|
||||||
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
|
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');" class="tooltip">FL</a>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a> ]
|
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a> ]
|
||||||
</span>
|
</span>
|
||||||
<strong><?=$DisplayName?></strong>
|
<strong><?=$DisplayName?></strong>
|
||||||
<div class="tags"><?=$TorrentTags->format()?></div>
|
<div class="tags"><?=$TorrentTags->format()?></div>
|
||||||
<? if (!$Sneaky) { ?>
|
<? if (!$Sneaky) { ?>
|
||||||
<span class="float_right float_clear"><a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" title="Remove bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, '');return false;">Unbookmark</a></span>
|
<span class="float_right float_clear"><a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove bookmark</a></span>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<span class="float_right float_clear"><?=time_diff($AddedTime);?></span>
|
<span class="float_right float_clear"><?=time_diff($AddedTime);?></span>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
||||||
<td><?=number_format($Torrent['Snatched'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
|
||||||
<td<?=(($Torrent['Seeders'] == 0) ? ' class="r00"' : '')?>><?=number_format($Torrent['Seeders'])?></td>
|
<td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
|
||||||
<td><?=number_format($Torrent['Leechers'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
<?
|
|
||||||
authorize();
|
|
||||||
|
|
||||||
if (empty($_POST['collageid']) || !is_number($_POST['collageid']) || $_POST['body'] === '' || !isset($_POST['body'])) {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
$CollageID = $_POST['collageid'];
|
|
||||||
|
|
||||||
if ($LoggedUser['DisablePosting']) {
|
|
||||||
error('Your posting privileges have been removed'); // Should this be logged?
|
|
||||||
}
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
CEIL(
|
|
||||||
(
|
|
||||||
SELECT COUNT(ID) + 1
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE CollageID = '".db_string($CollageID)."'
|
|
||||||
) / ".TORRENT_COMMENTS_PER_PAGE."
|
|
||||||
) AS Pages");
|
|
||||||
list($Pages) = $DB->next_record();
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
INSERT INTO collages_comments
|
|
||||||
(CollageID, Body, UserID, Time)
|
|
||||||
VALUES
|
|
||||||
('$CollageID', '".db_string($_POST['body'])."', '$LoggedUser[ID]', '".sqltime()."')");
|
|
||||||
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
|
|
||||||
$Cache->delete_value("collage_$CollageID");
|
|
||||||
$Cache->delete_value("collage_comments_{$CollageID}_catalogue_$CatalogueID");
|
|
||||||
$Cache->increment("collage_comments_$CollageID");
|
|
||||||
header('Location: collages.php?id='.$CollageID);
|
|
||||||
|
|
||||||
?>
|
|
@ -14,37 +14,12 @@
|
|||||||
$Text = new TEXT;
|
$Text = new TEXT;
|
||||||
|
|
||||||
// Check for lame SQL injection attempts
|
// Check for lame SQL injection attempts
|
||||||
$CollageID = $_GET['collageid'];
|
if (!is_number($_GET['collageid'])) {
|
||||||
if (!is_number($CollageID)) {
|
|
||||||
error(0);
|
error(0);
|
||||||
}
|
}
|
||||||
|
$CollageID = (int)$_GET['collageid'];
|
||||||
|
|
||||||
// gets the amount of comments for this collage
|
list($NumComments, $Page, $Thread, $LastRead) = Comments::load('collages', $CollageID);
|
||||||
$NumComments = Collages::get_comment_count($CollageID);
|
|
||||||
|
|
||||||
if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
|
|
||||||
$DB->query("
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE CollageID = $CollageID
|
|
||||||
AND ID <= $_GET[postid]");
|
|
||||||
list($PostNum) = $DB->next_record();
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
|
|
||||||
} else {
|
|
||||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the cache catalogue
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
|
||||||
|
|
||||||
//---------- Get some data to start processing
|
|
||||||
|
|
||||||
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
|
|
||||||
$Catalogue = Collages::get_comment_catalogue($CollageID, $CatalogueID);
|
|
||||||
|
|
||||||
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
|
|
||||||
$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
|
|
||||||
|
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT Name
|
SELECT Name
|
||||||
@ -53,7 +28,7 @@
|
|||||||
list($Name) = $DB->next_record();
|
list($Name) = $DB->next_record();
|
||||||
|
|
||||||
// Start printing
|
// Start printing
|
||||||
View::show_header("Comments for collage $Name", 'comments,bbcode');
|
View::show_header("Comments for collage $Name", 'comments,bbcode,subscriptions');
|
||||||
?>
|
?>
|
||||||
<div class="thin">
|
<div class="thin">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -62,63 +37,29 @@
|
|||||||
<a href="collages.php?id=<?=$CollageID?>"><?=$Name?></a>
|
<a href="collages.php?id=<?=$CollageID?>"><?=$Name?></a>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="linkbox">
|
<div class="linkbox">
|
||||||
|
<a href="#" id="subscribelink_collages<?=$CollageID?>" class="brackets" onclick="SubscribeComments('collages',<?=$CollageID?>);return false;"><?=Subscriptions::has_subscribed_comments('collages', $CollageID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
|
||||||
<?
|
<?
|
||||||
$Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9);
|
$Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9);
|
||||||
echo $Pages;
|
if ($Pages) {
|
||||||
|
echo '<br /><br />' . $Pages;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?
|
<?
|
||||||
|
|
||||||
//---------- Begin printing
|
//---------- Begin printing
|
||||||
foreach ($Thread as $Post) {
|
CommentsView::render_comments($Thread, $LastRead, "collages.php?action=comments&collageid=$CollageID");
|
||||||
list($PostID, $AuthorID, $AddedTime, $Body) = array_values($Post);
|
|
||||||
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
|
|
||||||
?>
|
|
||||||
<table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '')?>" id="post<?=$PostID?>">
|
|
||||||
<colgroup>
|
|
||||||
<? if (Users::has_avatars_enabled()) { ?>
|
|
||||||
<col class="col_avatar" />
|
|
||||||
<? } ?>
|
|
||||||
<col class="col_post_body" />
|
|
||||||
</colgroup>
|
|
||||||
<tr class="colhead_dark">
|
|
||||||
<td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
|
|
||||||
<span style="float: left;"><a href="#post<?=$PostID?>">#<?=$PostID?></a>
|
|
||||||
<?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?>
|
|
||||||
<? if (!$ThreadInfo['IsLocked']) { ?> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');" class="brackets">Quote</a><? }
|
|
||||||
if ($AuthorID === $LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?> - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>');" class="brackets">Edit</a><? }
|
|
||||||
if (check_perms('site_moderate_forums')) { ?> - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a> <? } ?>
|
|
||||||
</span>
|
|
||||||
<span id="bar<?=$PostID?>" style="float: right;">
|
|
||||||
<a href="reports.php?action=report&type=collages_comment&id=<?=$PostID?>" class="brackets">Report</a>
|
|
||||||
<a href="#">↑</a>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<? if (Users::has_avatars_enabled()) { ?>
|
|
||||||
<td class="avatar" valign="top">
|
|
||||||
<?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
|
|
||||||
</td>
|
|
||||||
<? } ?>
|
|
||||||
<td class="body" valign="top">
|
|
||||||
<div id="content<?=$PostID?>">
|
|
||||||
<?=$Text->full_format($Body)?>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<?
|
|
||||||
}
|
|
||||||
if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
|
if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
|
||||||
if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {
|
if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {
|
||||||
|
|
||||||
View::parse('generic/reply/quickreply.php', array(
|
View::parse('generic/reply/quickreply.php', array(
|
||||||
'InputName' => 'collageid',
|
'InputName' => 'pageid',
|
||||||
'InputID' => $CollageID,
|
'InputID' => $CollageID,
|
||||||
'InputAction' => 'add_comment',
|
'Action' => 'comments.php?page=collages',
|
||||||
'TextareaCols' => 90));
|
'InputAction' => 'take_post',
|
||||||
|
'TextareaCols' => 90,
|
||||||
|
'SubscribeBox' => true
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -205,15 +205,16 @@
|
|||||||
if (empty($CommentList)) {
|
if (empty($CommentList)) {
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
cc.ID,
|
c.ID,
|
||||||
cc.Body,
|
c.Body,
|
||||||
cc.UserID,
|
c.AuthorID,
|
||||||
um.Username,
|
um.Username,
|
||||||
cc.Time
|
c.AddedTime
|
||||||
FROM collages_comments AS cc
|
FROM comments AS c
|
||||||
LEFT JOIN users_main AS um ON um.ID = cc.UserID
|
LEFT JOIN users_main AS um ON um.ID = c.AuthorID
|
||||||
WHERE CollageID = '$CollageID'
|
WHERE c.Page = 'collages'
|
||||||
ORDER BY ID DESC
|
AND c.PageID = $CollageID
|
||||||
|
ORDER BY c.ID DESC
|
||||||
LIMIT 15");
|
LIMIT 15");
|
||||||
$CommentList = $DB->to_array(false, MYSQLI_NUM);
|
$CommentList = $DB->to_array(false, MYSQLI_NUM);
|
||||||
}
|
}
|
||||||
@ -239,10 +240,11 @@
|
|||||||
?>
|
?>
|
||||||
<div class="box box_addcomment">
|
<div class="box box_addcomment">
|
||||||
<div class="head"><strong>Add comment</strong></div>
|
<div class="head"><strong>Add comment</strong></div>
|
||||||
<form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;" action="collages.php" method="post">
|
<form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;" action="comments.php" method="post">
|
||||||
<input type="hidden" name="action" value="add_comment" />
|
<input type="hidden" name="action" value="take_post" />
|
||||||
|
<input type="hidden" name="page" value="collages" />
|
||||||
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
||||||
<input type="hidden" name="collageid" value="<?=$CollageID?>" />
|
<input type="hidden" name="pageid" value="<?=$CollageID?>" />
|
||||||
<div class="pad">
|
<div class="pad">
|
||||||
<div class="field_div">
|
<div class="field_div">
|
||||||
<textarea name="body" cols="24" rows="5"></textarea>
|
<textarea name="body" cols="24" rows="5"></textarea>
|
||||||
|
@ -307,7 +307,7 @@
|
|||||||
$Row = 'a'; // For the pretty colours
|
$Row = 'a'; // For the pretty colours
|
||||||
foreach ($Collages as $Collage) {
|
foreach ($Collages as $Collage) {
|
||||||
list($ID, $Name, $NumTorrents, $TagList, $CategoryID, $UserID, $Subscribers, $Updated) = $Collage;
|
list($ID, $Name, $NumTorrents, $TagList, $CategoryID, $UserID, $Subscribers, $Updated) = $Collage;
|
||||||
$Row = ($Row === 'a') ? 'b' : 'a';
|
$Row = $Row === 'a' ? 'b' : 'a';
|
||||||
$TorrentTags = new Tags($TagList);
|
$TorrentTags = new Tags($TagList);
|
||||||
|
|
||||||
//Print results
|
//Print results
|
||||||
@ -325,8 +325,8 @@
|
|||||||
<? } ?>
|
<? } ?>
|
||||||
<div class="tags"><?=$TorrentTags->format('collages.php?action=search&tags=')?></div>
|
<div class="tags"><?=$TorrentTags->format('collages.php?action=search&tags=')?></div>
|
||||||
</td>
|
</td>
|
||||||
<td><?=number_format((int)$NumTorrents)?></td>
|
<td class="number_column"><?=number_format((int)$NumTorrents)?></td>
|
||||||
<td><?=number_format((int)$Subscribers)?></td>
|
<td class="number_column"><?=number_format((int)$Subscribers)?></td>
|
||||||
<td><?=time_diff($Updated)?></td>
|
<td><?=time_diff($Updated)?></td>
|
||||||
<td><?=Users::format_username($UserID, false, false, false)?></td>
|
<td><?=Users::format_username($UserID, false, false, false)?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
<?
|
|
||||||
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
|
|
||||||
$Text = new TEXT;
|
|
||||||
|
|
||||||
authorize();
|
|
||||||
|
|
||||||
// Quick SQL injection check
|
|
||||||
if (!$_GET['postid'] || !is_number($_GET['postid'])) {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
$PostID = $_GET['postid'];
|
|
||||||
|
|
||||||
// Make sure they are moderators
|
|
||||||
if (!check_perms('site_moderate_forums')) {
|
|
||||||
error(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get number of pages
|
|
||||||
// $Pages = number of pages in the thread
|
|
||||||
// $Page = which page the post is on
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
CollageID,
|
|
||||||
CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
|
|
||||||
CEIL(SUM(IF(ID <= '$PostID', 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE CollageID = (
|
|
||||||
SELECT CollageID
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE ID = '$PostID'
|
|
||||||
)
|
|
||||||
GROUP BY CollageID");
|
|
||||||
list($CollageID, $Pages, $Page) = $DB->next_record();
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
DELETE FROM collages_comments
|
|
||||||
WHERE ID = '$PostID'");
|
|
||||||
|
|
||||||
$Cache->delete_value("collage_$CollageID");
|
|
||||||
$Cache->increment_value("collage_comments_$CollageID", -1);
|
|
||||||
|
|
||||||
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
|
|
||||||
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
|
|
||||||
$Cache->delete_value("collage_comments_$CollageID"."_catalogue_$i");
|
|
||||||
}
|
|
||||||
?>
|
|
@ -73,7 +73,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<? if ($CategoryID == 0) { // CategoryID == 0 is for "personal" collages ?>
|
<? if ($CategoryID == 0) { // CategoryID == 0 is for "personal" collages ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><span title="A "featured" personal collage will be listed first on your profile, along with a preview of the included torrents.">Featured</span></td>
|
<td class="label"><span class="tooltip" title="A "featured" personal collage will be listed first on your profile, along with a preview of the included torrents.">Featured</span></td>
|
||||||
<td><input type="checkbox" name="featured"<?=($Featured ? ' checked="checked"' : '')?> /></td>
|
<td><input type="checkbox" name="featured"<?=($Featured ? ' checked="checked"' : '')?> /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?
|
|
||||||
/*********************************************************************\
|
|
||||||
//--------------Get Post--------------------------------------------//
|
|
||||||
|
|
||||||
This gets the raw BBCode of a post. It's used for editing and
|
|
||||||
quoting posts.
|
|
||||||
|
|
||||||
It gets called if $_GET['action'] == 'get_post'. It requires
|
|
||||||
$_GET['post'], which is the ID of the post.
|
|
||||||
|
|
||||||
\*********************************************************************/
|
|
||||||
|
|
||||||
// Quick SQL injection check
|
|
||||||
if (!$_GET['post'] || !is_number($_GET['post'])) {
|
|
||||||
error(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Variables for database input
|
|
||||||
$PostID = $_GET['post'];
|
|
||||||
|
|
||||||
// Mainly
|
|
||||||
$DB->query("
|
|
||||||
SELECT Body
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE ID = '$PostID'");
|
|
||||||
list($Body) = $DB->next_record(MYSQLI_NUM);
|
|
||||||
|
|
||||||
// This gets sent to the browser, which echoes it wherever
|
|
||||||
|
|
||||||
echo trim($Body);
|
|
@ -76,21 +76,9 @@
|
|||||||
case 'take_delete':
|
case 'take_delete':
|
||||||
require(SERVER_ROOT.'/sections/collages/take_delete.php');
|
require(SERVER_ROOT.'/sections/collages/take_delete.php');
|
||||||
break;
|
break;
|
||||||
case 'add_comment':
|
|
||||||
require(SERVER_ROOT.'/sections/collages/add_comment.php');
|
|
||||||
break;
|
|
||||||
case 'comments':
|
case 'comments':
|
||||||
require(SERVER_ROOT.'/sections/collages/all_comments.php');
|
require(SERVER_ROOT.'/sections/collages/all_comments.php');
|
||||||
break;
|
break;
|
||||||
case 'takeedit_comment':
|
|
||||||
require(SERVER_ROOT.'/sections/collages/takeedit_comment.php');
|
|
||||||
break;
|
|
||||||
case 'delete_comment':
|
|
||||||
require(SERVER_ROOT.'/sections/collages/delete_comment.php');
|
|
||||||
break;
|
|
||||||
case 'get_post':
|
|
||||||
require(SERVER_ROOT.'/sections/collages/get_post.php');
|
|
||||||
break;
|
|
||||||
case 'download':
|
case 'download':
|
||||||
require(SERVER_ROOT.'/sections/collages/download.php');
|
require(SERVER_ROOT.'/sections/collages/download.php');
|
||||||
break;
|
break;
|
||||||
|
@ -57,13 +57,12 @@
|
|||||||
<li>Press "Save All Changes" when you are finished sorting.</li>
|
<li>Press "Save All Changes" when you are finished sorting.</li>
|
||||||
<li>Press "Edit" or "Remove" to simply modify one entry.</li>
|
<li>Press "Edit" or "Remove" to simply modify one entry.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<noscript><ul><li><strong class="important_text">Note: Enable JavaScript!</strong></li></ul></noscript>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="drag_drop_save hidden">
|
<div class="drag_drop_save hidden">
|
||||||
<input type="button" name="submit" value="Save All Changes" title="Save your changes." class="save_sortable_collage" />
|
<input type="button" name="submit" value="Save All Changes" class="save_sortable_collage" />
|
||||||
</div>
|
</div>
|
||||||
<table id="manage_collage_table">
|
<table id="manage_collage_table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -129,7 +128,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="drag_drop_save hidden">
|
<div class="drag_drop_save hidden">
|
||||||
<input type="button" name="submit" value="Save All Changes" title="Save your changes." class="save_sortable_collage" />
|
<input type="button" name="submit" value="Save All Changes" class="save_sortable_collage" />
|
||||||
</div>
|
</div>
|
||||||
<form class="dragdrop_form hidden" name="collage" action="collages.php" method="post" id="drag_drop_collage_form">
|
<form class="dragdrop_form hidden" name="collage" action="collages.php" method="post" id="drag_drop_collage_form">
|
||||||
<div>
|
<div>
|
||||||
|
@ -51,13 +51,12 @@
|
|||||||
<li>Press "Save All Changes" when you are finished sorting.</li>
|
<li>Press "Save All Changes" when you are finished sorting.</li>
|
||||||
<li>Press "Edit" or "Remove" to simply modify one entry.</li>
|
<li>Press "Edit" or "Remove" to simply modify one entry.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<noscript><ul><li><strong class="important_text">Note: Enable JavaScript!</strong></li></ul></noscript>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="drag_drop_save hidden">
|
<div class="drag_drop_save hidden">
|
||||||
<input type="button" name="submit" value="Save All Changes" title="Save your changes" class="save_sortable_collage" />
|
<input type="button" name="submit" value="Save All Changes" class="save_sortable_collage" />
|
||||||
</div>
|
</div>
|
||||||
<table id="manage_collage_table">
|
<table id="manage_collage_table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -98,7 +97,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="drag_drop_save hidden">
|
<div class="drag_drop_save hidden">
|
||||||
<input type="button" name="submit" value="Save All Changes" title="Save your changes." class="save_sortable_collage" />
|
<input type="button" name="submit" value="Save All Changes" class="save_sortable_collage" />
|
||||||
</div>
|
</div>
|
||||||
<form class="dragdrop_form hidden" name="collage" action="collages.php" method="post" id="drag_drop_collage_form">
|
<form class="dragdrop_form hidden" name="collage" action="collages.php" method="post" id="drag_drop_collage_form">
|
||||||
<div>
|
<div>
|
||||||
|
@ -33,21 +33,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Personal collages have CategoryID 0
|
//Personal collages have CategoryID 0
|
||||||
if ($CategoryID === '0') {
|
if ($CategoryID == 0) {
|
||||||
$DB->query("
|
$DB->query("DELETE FROM collages WHERE ID = '$CollageID'");
|
||||||
DELETE FROM collages
|
$DB->query("DELETE FROM collages_torrents WHERE CollageID = '$CollageID'");
|
||||||
WHERE ID = '$CollageID'");
|
Comments::delete_page('collages', $CollageID);
|
||||||
$DB->query("
|
|
||||||
DELETE FROM collages_torrents
|
|
||||||
WHERE CollageID = '$CollageID'");
|
|
||||||
$DB->query("
|
|
||||||
DELETE FROM collages_comments
|
|
||||||
WHERE CollageID = '$CollageID'");
|
|
||||||
} else {
|
} else {
|
||||||
$DB->query("
|
$DB->query("
|
||||||
UPDATE collages
|
UPDATE collages
|
||||||
SET Deleted = '1'
|
SET Deleted = '1'
|
||||||
WHERE ID = '$CollageID'");
|
WHERE ID = '$CollageID'");
|
||||||
|
Subscriptions::flush_subscriptions('collages', $CollageID);
|
||||||
|
Subscriptions::flush_quote_notifications('collages', $CollageID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Misc::write_log("Collage $CollageID ($Name) was deleted by ".$LoggedUser['Username'].": $Reason");
|
Misc::write_log("Collage $CollageID ($Name) was deleted by ".$LoggedUser['Username'].": $Reason");
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
<?
|
|
||||||
authorize();
|
|
||||||
|
|
||||||
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
|
|
||||||
$Text = new TEXT;
|
|
||||||
|
|
||||||
// Quick SQL injection check
|
|
||||||
if (!$_POST['post'] || !is_number($_POST['post'])) {
|
|
||||||
error(404);
|
|
||||||
}
|
|
||||||
// End injection check
|
|
||||||
|
|
||||||
// Variables for database input
|
|
||||||
$UserID = $LoggedUser['ID'];
|
|
||||||
$Body = db_string(urldecode($_POST['body']));
|
|
||||||
$PostID = $_POST['post'];
|
|
||||||
|
|
||||||
// Mainly
|
|
||||||
$DB->query("
|
|
||||||
SELECT
|
|
||||||
cc.Body,
|
|
||||||
cc.UserID,
|
|
||||||
cc.CollageID,
|
|
||||||
(
|
|
||||||
SELECT COUNT(ID)
|
|
||||||
FROM collages_comments
|
|
||||||
WHERE ID <= $PostID
|
|
||||||
AND collages_comments.CollageID = cc.CollageID
|
|
||||||
)
|
|
||||||
FROM collages_comments AS cc
|
|
||||||
WHERE cc.ID='$PostID'");
|
|
||||||
list($OldBody, $AuthorID, $CollageID, $PostNum) = $DB->next_record();
|
|
||||||
|
|
||||||
// Make sure they aren't trying to edit posts they shouldn't
|
|
||||||
// We use die() here instead of error() because whatever we spit out is displayed to the user in the box where his forum post is
|
|
||||||
if ($UserID != $AuthorID && !check_perms('site_moderate_forums')) {
|
|
||||||
die('Permission denied');
|
|
||||||
}
|
|
||||||
if (!$DB->has_results()) {
|
|
||||||
die('Post not found!');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform the update
|
|
||||||
$DB->query("
|
|
||||||
UPDATE collages_comments
|
|
||||||
SET
|
|
||||||
Body = '$Body'
|
|
||||||
WHERE ID='$PostID'");
|
|
||||||
|
|
||||||
$Cache->delete_value('collage_'.$CollageID);
|
|
||||||
|
|
||||||
|
|
||||||
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
|
|
||||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $PageNum - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
||||||
$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
|
|
||||||
|
|
||||||
$DB->query("
|
|
||||||
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
|
|
||||||
VALUES ('collages', $PostID, $UserID, '".sqltime()."', '".db_string($OldBody)."')");
|
|
||||||
|
|
||||||
// This gets sent to the browser, which echoes it in place of the old body
|
|
||||||
echo $Text->full_format($_POST['body']);
|
|
||||||
|
|
||||||
?>
|
|
@ -98,8 +98,8 @@
|
|||||||
?>
|
?>
|
||||||
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
|
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
|
||||||
<td class="center">
|
<td class="center">
|
||||||
<div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
|
<div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
|
||||||
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group. Hold "Ctrl" while clicking to collapse all groups on this page."></a>
|
<a href="#" class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group. Hold "Ctrl" while clicking to collapse all groups on this page."></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="center">
|
<td class="center">
|
||||||
@ -109,9 +109,9 @@
|
|||||||
<strong><?=$DisplayName?></strong>
|
<strong><?=$DisplayName?></strong>
|
||||||
<? // PHP start tag is indented for proper formatting of generated HTML
|
<? // PHP start tag is indented for proper formatting of generated HTML
|
||||||
if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
|
if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
|
||||||
echo "<a style = \"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"remove_bookmark brackets\" title=\"Unbookmark\" onclick=\"Unbookmark('torrent', $GroupID, 'Bookmark'); return false;\">Unbookmark</a>";
|
echo "<a style = \"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"remove_bookmark brackets\" onclick=\"Unbookmark('torrent', $GroupID, 'Bookmark'); return false;\">Remove bookmark</a>";
|
||||||
} else {
|
} else {
|
||||||
echo "<a style = \"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"add_bookmark brackets\" title=\"Bookmark\" onclick=\"Bookmark('torrent', $GroupID, 'Unbookmark'); return false;\">Bookmark</a>";
|
echo "<a style = \"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"add_bookmark brackets\" onclick=\"Bookmark('torrent', $GroupID, 'Remove bookmark'); return false;\">Bookmark</a>";
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo Votes::vote_link($GroupID, $UserVotes[$GroupID]['Type']); ?>
|
echo Votes::vote_link($GroupID, $UserVotes[$GroupID]['Type']); ?>
|
||||||
@ -135,12 +135,17 @@
|
|||||||
}
|
}
|
||||||
$SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : '');
|
$SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : '');
|
||||||
|
|
||||||
if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
|
if ($Torrent['RemasterTitle'] != $LastRemasterTitle
|
||||||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
|
|| $Torrent['RemasterYear'] != $LastRemasterYear
|
||||||
|
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|
||||||
|
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|
||||||
|
|| $FirstUnknown
|
||||||
|
|| $Torrent['Media'] != $LastMedia
|
||||||
|
) {
|
||||||
$EditionID++;
|
$EditionID++;
|
||||||
?>
|
?>
|
||||||
<tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
|
<tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
|
||||||
<td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
|
<td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" class="tooltip" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -155,16 +160,16 @@
|
|||||||
<span class="brackets">
|
<span class="brackets">
|
||||||
<a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
<a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
||||||
<? if (Torrents::can_use_token($Torrent)) { ?>
|
<? if (Torrents::can_use_token($Torrent)) { ?>
|
||||||
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
|
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');" class="tooltip">FL</a>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a>
|
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a>
|
||||||
</span>
|
</span>
|
||||||
» <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
|
» <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
|
||||||
</td>
|
</td>
|
||||||
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
||||||
<td><?=number_format($Torrent['Snatched'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
|
||||||
<td<?=(($Torrent['Seeders'] == 0) ? ' class="r00"' : '')?>><?=number_format($Torrent['Seeders'])?></td>
|
<td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
|
||||||
<td><?=number_format($Torrent['Leechers'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -197,7 +202,7 @@
|
|||||||
<span class="brackets">
|
<span class="brackets">
|
||||||
<a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
<a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
||||||
<? if (Torrents::can_use_token($Torrent)) { ?>
|
<? if (Torrents::can_use_token($Torrent)) { ?>
|
||||||
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
|
| <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');" class="tooltip">FL</a>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a>
|
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a>
|
||||||
</span>
|
</span>
|
||||||
@ -205,10 +210,10 @@
|
|||||||
<? Votes::vote_link($GroupID, $UserVotes[$GroupID]['Type']); ?>
|
<? Votes::vote_link($GroupID, $UserVotes[$GroupID]['Type']); ?>
|
||||||
<div class="tags"><?=$TorrentTags->format()?></div>
|
<div class="tags"><?=$TorrentTags->format()?></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
|
||||||
<td><?=number_format($Torrent['Snatched'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
|
||||||
<td<?=(($Torrent['Seeders'] == 0) ? ' class="r00"' : '')?>><?=number_format($Torrent['Seeders'])?></td>
|
<td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
|
||||||
<td><?=number_format($Torrent['Leechers'])?></td>
|
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -481,15 +486,15 @@
|
|||||||
if (empty($CommentList)) {
|
if (empty($CommentList)) {
|
||||||
$DB->query("
|
$DB->query("
|
||||||
SELECT
|
SELECT
|
||||||
cc.ID,
|
c.ID,
|
||||||
cc.Body,
|
c.Body,
|
||||||
cc.UserID,
|
c.AuthorID,
|
||||||
um.Username,
|
um.Username,
|
||||||
cc.Time
|
c.AddedTime
|
||||||
FROM collages_comments AS cc
|
FROM comments AS c
|
||||||
LEFT JOIN users_main AS um ON um.ID = cc.UserID
|
LEFT JOIN users_main AS um ON um.ID = c.AuthorID
|
||||||
WHERE CollageID = '$CollageID'
|
WHERE c.Page = 'collages' AND c.PageID = $CollageID
|
||||||
ORDER BY ID DESC
|
ORDER BY c.ID DESC
|
||||||
LIMIT 15");
|
LIMIT 15");
|
||||||
$CommentList = $DB->to_array(false, MYSQLI_NUM);
|
$CommentList = $DB->to_array(false, MYSQLI_NUM);
|
||||||
}
|
}
|
||||||
@ -515,10 +520,11 @@
|
|||||||
?>
|
?>
|
||||||
<div class="box box_addcomment">
|
<div class="box box_addcomment">
|
||||||
<div class="head"><strong>Add comment</strong></div>
|
<div class="head"><strong>Add comment</strong></div>
|
||||||
<form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;" action="collages.php" method="post">
|
<form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;" action="comments.php" method="post">
|
||||||
<input type="hidden" name="action" value="add_comment" />
|
<input type="hidden" name="action" value="take_post" />
|
||||||
|
<input type="hidden" name="page" value="collages" />
|
||||||
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
|
||||||
<input type="hidden" name="collageid" value="<?=$CollageID?>" />
|
<input type="hidden" name="pageid" value="<?=$CollageID?>" />
|
||||||
<div class="pad">
|
<div class="pad">
|
||||||
<div class="field_div">
|
<div class="field_div">
|
||||||
<textarea name="body" cols="24" rows="5"></textarea>
|
<textarea name="body" cols="24" rows="5"></textarea>
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$OtherLink = '';
|
|
||||||
|
|
||||||
$Title = 'Artist comments made by '.($Self ? 'you' : $Username);
|
|
||||||
$Header = 'Artist comments left by '.($Self ? 'you' : Users::format_username($UserID, false, false, false)).'';
|
|
||||||
|
|
||||||
$Comments = $DB->query("
|
|
||||||
SELECT
|
|
||||||
SQL_CALC_FOUND_ROWS
|
|
||||||
ac.AuthorID,
|
|
||||||
a.ArtistID,
|
|
||||||
a.Name,
|
|
||||||
ac.ID,
|
|
||||||
ac.Body,
|
|
||||||
ac.AddedTime,
|
|
||||||
ac.EditedTime,
|
|
||||||
ac.EditedUserID as EditorID
|
|
||||||
FROM artists_group as a
|
|
||||||
JOIN artist_comments as ac ON ac.ArtistID = a.ArtistID
|
|
||||||
WHERE ac.AuthorId = $UserID
|
|
||||||
GROUP BY ac.ID
|
|
||||||
ORDER BY ac.AddedTime DESC
|
|
||||||
LIMIT $Limit;
|
|
||||||
");
|
|
||||||
|
|
||||||
$DB->query("SELECT FOUND_ROWS()");
|
|
||||||
list($Results) = $DB->next_record();
|
|
||||||
$Pages = Format::get_pages($Page, $Results, $PerPage, 11);
|
|
||||||
|
|
||||||
$DB->set_query_id($Comments);
|
|
||||||
$GroupIDs = $DB->collect('GroupID');
|
|
||||||
|
|
||||||
|
|
||||||
View::show_header($Title,'bbcode');
|
|
||||||
$DB->set_query_id($Comments);
|
|
||||||
|
|
||||||
?><div class="thin">
|
|
||||||
<div class="header">
|
|
||||||
<h2><?=$Header?></h2>
|
|
||||||
<? if ($OtherLink !== '') { ?>
|
|
||||||
<div class="linkbox">
|
|
||||||
<?=$OtherLink?>
|
|
||||||
</div>
|
|
||||||
<? } ?>
|
|
||||||
</div>
|
|
||||||
<div class="linkbox">
|
|
||||||
<?=$Pages?>
|
|
||||||
</div>
|
|
||||||
<?
|
|
||||||
|
|
||||||
while (list($UserID, $ArtistID, $ArtistName, $PostID, $Body, $AddedTime, $EditedTime, $EditorID) = $DB->next_record()) {
|
|
||||||
$permalink = "artist.php?id=$ArtistID&postid=$PostID#post$PostID";
|
|
||||||
$postheader = ' on ' . "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a>";
|
|
||||||
|
|
||||||
comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime);
|
|
||||||
|
|
||||||
} /* end while loop*/ ?>
|
|
||||||
<div class="linkbox"><?=($Pages)?></div>
|
|
||||||
</div>
|
|
||||||
<?
|
|
||||||
View::show_footer();
|
|
@ -1,100 +0,0 @@
|
|||||||
<?
|
|
||||||
/*
|
|
||||||
* $_REQUEST['type']:
|
|
||||||
* created = comments left on one's collages
|
|
||||||
* contributed = comments left on collages one contributed to
|
|
||||||
* * = one's request comments
|
|
||||||
*/
|
|
||||||
|
|
||||||
$Mode = 'normal';
|
|
||||||
|
|
||||||
$ExtraJoin = $Conditions = '';
|
|
||||||
$Conditions = "c.Deleted = '0' AND ";
|
|
||||||
if (!empty($_REQUEST['type'])) {
|
|
||||||
if ($_REQUEST['type'] == 'created') {
|
|
||||||
$Conditions .= "c.UserID = $UserID AND cc.UserID != $UserID";
|
|
||||||
$Title = 'Comments left on collages ' . ($Self ? 'you' : $Username) . ' created';
|
|
||||||
$Header = 'Comments left on collages ' . ($Self ? 'you' : Users::format_username($UserID, false, false, false)) . ' created';
|
|
||||||
$Mode = 'created';
|
|
||||||
} elseif ($_REQUEST['type'] == 'contributed') {
|
|
||||||
$Conditions .= "IF(c.CategoryID = " . array_search('Artists', $CollageCats) . ", ca.ArtistID, ct.GroupID) IS NOT NULL AND cc.UserID != $UserID";
|
|
||||||
$ExtraJoin .=
|
|
||||||
"LEFT JOIN collages_torrents as ct ON ct.CollageID = c.ID AND ct.UserID = $UserID
|
|
||||||
LEFT JOIN collages_artists as ca ON ca.CollageID = c.ID AND ca.UserID = $UserID";
|
|
||||||
$Title = 'Comments left on collages ' . ($Self ? 'you\'ve' : $Username . ' has') . ' contributed to';
|
|
||||||
$Header = 'Comments left on collages ' . ($Self ? 'you\'ve' : Users::format_username($UserID, false, false, false).' has') . ' contributed to';
|
|
||||||
$Mode = 'contributed';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isset($Title)) {
|
|
||||||
$Conditions .= "cc.UserID = $UserID";
|
|
||||||
$Title = 'Collage comments made by ' . ($Self ? 'you' : $Username);
|
|
||||||
$Header = 'Collage comments made by ' . ($Self ? 'you' : Users::format_username($UserID, false, false, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
$Comments = $DB->query("
|
|
||||||
SELECT
|
|
||||||
SQL_CALC_FOUND_ROWS
|
|
||||||
cc.UserID,
|
|
||||||
c.ID as CollageID,
|
|
||||||
c.Name,
|
|
||||||
cc.ID as PostID,
|
|
||||||
cc.Body,
|
|
||||||
cc.Time
|
|
||||||
FROM collages as c
|
|
||||||
JOIN collages_comments as cc ON cc.CollageID = c.ID
|
|
||||||
$ExtraJoin
|
|
||||||
WHERE $Conditions
|
|
||||||
GROUP BY cc.ID
|
|
||||||
ORDER BY cc.ID DESC
|
|
||||||
LIMIT $Limit;");
|
|
||||||
$Count = $DB->record_count();
|
|
||||||
|
|
||||||
$DB->query("SELECT FOUND_ROWS()");
|
|
||||||
list($Results) = $DB->next_record();
|
|
||||||
$Pages = Format::get_pages($Page, $Results, $PerPage, 11);
|
|
||||||
|
|
||||||
View::show_header($Title,'bbcode');
|
|
||||||
$DB->set_query_id($Comments);
|
|
||||||
|
|
||||||
$Links = array();
|
|
||||||
$BaseLink = 'comments.php?action=collages' . (!$Self ? '&id='.$UserID : '');
|
|
||||||
if ($Mode != 'normal') {
|
|
||||||
$Links[] = '<a href="' . $BaseLink . '" class="brackets">Display collage comments ' . ($Self ? 'you\'ve' : $Username . ' has') . ' made</a>';
|
|
||||||
}
|
|
||||||
if ($Mode != 'created') {
|
|
||||||
$Links[] = '<a href="' . $BaseLink . '&type=created" class="brackets">Display comments left on ' . ($Self ? 'your collages' : 'collages created by ' .$Username) . '</a>';
|
|
||||||
}
|
|
||||||
if ($Mode != 'contributed') {
|
|
||||||
$Links[] = '<a href="' . $BaseLink . '&type=contributed" class="brackets">Display comments left on collages ' . ($Self ? 'you\'ve' : $Username . ' has') . ' contributed to</a>';
|
|
||||||
}
|
|
||||||
$Links = implode(' ', $Links);
|
|
||||||
|
|
||||||
?><div class="thin">
|
|
||||||
<div class="header">
|
|
||||||
<h2><?=$Header?></h2>
|
|
||||||
<? if ($Links !== '') { ?>
|
|
||||||
<div class="linkbox">
|
|
||||||
<?=$Links?>
|
|
||||||
</div>
|
|
||||||
<? } ?>
|
|
||||||
</div>
|
|
||||||
<div class="linkbox">
|
|
||||||
<?=$Pages?>
|
|
||||||
</div>
|
|
||||||
<?
|
|
||||||
if ($Count > 0) {
|
|
||||||
while (list($UserID, $CollageID, $Name, $PostID, $Body, $AddedTime) = $DB->next_record()) {
|
|
||||||
$permalink = "collages.php?action=comments&collageid=$CollageID&postid=$PostID#post$PostID";
|
|
||||||
$postheader = " on <a href=\"collages.php?id=$CollageID\">$Name</a>";
|
|
||||||
comment_body($UserID, $PostID, $postheader, $permalink, $Body, 0, $AddedTime, 0);
|
|
||||||
}
|
|
||||||
} else { ?>
|
|
||||||
<div class="center">No results.</div>
|
|
||||||
<? } ?>
|
|
||||||
<div class="linkbox">
|
|
||||||
<?=$Pages?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?
|
|
||||||
View::show_footer();
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user