Empty commit

This commit is contained in:
Git 2013-10-23 08:01:03 +00:00
parent 2473fb6261
commit d412ed5d58
18 changed files with 307 additions and 181 deletions

View File

@ -47,7 +47,11 @@ 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' LIMIT 1");
G::$DB->query("
SELECT 1
FROM users_main
WHERE ID = '$UserID'
LIMIT 1");
if (G::$DB->has_results()) {
G::$Cache->InternalCache = false;
foreach ($Args as &$Arg) {
@ -67,7 +71,10 @@ public static function donate($UserID, $Args) {
}
// Legacy donor, should remove at some point
G::$DB->query("UPDATE users_info SET Donor = '1' WHERE UserID = '$UserID'");
G::$DB->query("
UPDATE users_info
SET Donor = '1'
WHERE UserID = '$UserID'");
// Give them the extra invite
$ExtraInvite = G::$DB->affected_rows();
@ -126,14 +133,23 @@ public static function donate($UserID, $Args) {
self::calculate_special_rank($UserID);
// Hand out invites
G::$DB->query("SELECT InvitesRecievedRank FROM users_donor_ranks WHERE UserID = '$UserID'");
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'");
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
@ -189,7 +205,7 @@ private static function calculate_special_rank($UserID) {
// Make them special
G::$DB->query("
UPDATE users_donor_ranks
SET SpecialRank = '$SpecialRank'
SET SpecialRank = '$SpecialRank'
WHERE UserID = '$UserID'");
G::$Cache->delete_value("donor_info_$UserID");
}

View File

@ -48,6 +48,19 @@ class ImageTools {
'gif' => true
);
/**
* Array of user IDs whose avatars have been checked for size
* @var array $CheckedAvatars
*/
private static $CheckedAvatars = array();
private static $CheckedAvatars2 = array();
/**
* Array of user IDs whose donor icons have been checked for size
* @var array $CheckedDonorIcons
*/
private static $CheckedDonorIcons = array();
/**
* Checks from our list of valid hosts
* @param string $Host Domain/host to check
@ -151,23 +164,43 @@ private static function replace_extension($String, $Extension) {
/**
* Create image proxy URL
* @param string $Url image URL
* @param bool/string $CheckSize - accepts one of false, "avatar", "avatar2", or "donoricon"
* @param bool/string/number $UserID - user ID for avatars and donor icons
* @return image proxy URL
*/
public static function proxy_url($Url) {
public static function proxy_url($Url, $CheckSize, $UserID, &$ExtraInfo) {
global $SSL;
return ($SSL ? 'https' : 'http') . '://' . SITE_URL . '/image.php?c=1&i=' . urlencode($Url);
if ($UserID) {
$ExtraInfo = "&userid=$UserID";
if ($CheckSize === 'avatar' && !isset(self::$CheckedAvatars[$UserID])) {
$ExtraInfo .= "&type=$CheckSize";
self::$CheckedAvatars[$UserID] = true;
} elseif ($CheckSize === 'avatar2' && !isset(self::$CheckedAvatars2[$UserID])) {
$ExtraInfo .= "&type=$CheckSize";
self::$CheckedAvatars2[$UserID] = true;
} elseif ($CheckSize === 'donoricon' && !isset(self::$CheckedDonorIcons[$UserID])) {
$ExtraInfo .= "&type=$CheckSize";
self::$CheckedDonorIcons[$UserID] = true;
}
}
return ($SSL ? 'https' : 'http') . '://' . SITE_URL . "/image.php?c=1&i=" . urlencode($Url);
}
/**
* Determine the image URL. This takes care of the image proxy and thumbnailing.
* @param string $Url
* @param bool $Thumb
* @param bool/string $CheckSize - accepts one of false, "avatar", "avatar2", or "donoricon"
* @param bool/string/number $UserID - user ID for avatars and donor icons
* @return string
*/
public static function process($Url, $Thumb = false) {
public static function process($Url, $Thumb = false, $CheckSize = false, $UserID = false) {
if (empty($Url)) {
return '';
}
if ($Found = self::get_stored($Url . ($Thumb ? '_thumb' : ''))) {
return $Found;
}
@ -184,12 +217,12 @@ public static function process($Url, $Thumb = false) {
}
}
$ExtraInfo = '';
if (check_perms('site_proxy_images')) {
$ProcessedUrl = self::proxy_url($ProcessedUrl);
$ProcessedUrl = self::proxy_url($ProcessedUrl, $CheckSize, $UserID, $ExtraInfo);
}
self::store($Url . ($Thumb ? '_thumb' : ''), $ProcessedUrl);
return $ProcessedUrl;
return $ProcessedUrl . $ExtraInfo;
}
/**

View File

@ -13,6 +13,7 @@
********************************************************************************/
class TORRENT_FORM {
var $UploadForm = '';
var $Categories = array();
var $Formats = array();
var $Bitrates = array();
@ -30,8 +31,9 @@ function TORRENT_FORM($Torrent = false, $Error = false, $NewTorrent = true) {
$this->Torrent = $Torrent;
$this->Error = $Error;
global $Categories, $Formats, $Bitrates, $Media, $TorrentID;
global $UploadForm, $Categories, $Formats, $Bitrates, $Media, $TorrentID;
$this->UploadForm = $UploadForm;
$this->Categories = $Categories;
$this->Formats = $Formats;
$this->Bitrates = $Bitrates;
@ -51,14 +53,14 @@ function head() {
<? if ($this->NewTorrent) { ?>
<p style="text-align: center;">
Your personal announce URL is:<br />
<input type="text" value="<?= ANNOUNCE_URL . '/' . G::$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>
<? }
if ($this->Error) {
echo "\t".'<p style="color: red; text-align: center;">'.$this->Error."</p>\n";
}
?>
<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>
<input type="hidden" name="submit" value="true" />
<input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
@ -66,15 +68,21 @@ function head() {
<input type="hidden" name="action" value="takeedit" />
<input type="hidden" name="torrentid" value="<?=display_str($this->TorrentID)?>" />
<input type="hidden" name="type" value="<?=display_str($this->Torrent['CategoryID'])?>" />
<? } else {
if ($this->Torrent && $this->Torrent['GroupID']) { ?>
<?
} else {
if ($this->Torrent && $this->Torrent['GroupID']) {
?>
<input type="hidden" name="groupid" value="<?=display_str($this->Torrent['GroupID'])?>" />
<input type="hidden" name="type" value="Music" />
<? }
if ($this->Torrent && $this->Torrent['RequestID']) { ?>
<input type="hidden" name="type" value="<?=array_search($this->UploadForm, $this->Categories)?>" />
<?
}
if ($this->Torrent && $this->Torrent['RequestID']) {
?>
<input type="hidden" name="requestid" value="<?=display_str($this->Torrent['RequestID'])?>" />
<? }
} ?>
<?
}
}
?>
</div>
<? if ($this->NewTorrent) { ?>
<table cellpadding="3" cellspacing="1" border="0" class="layout border" width="100%">
@ -85,22 +93,24 @@ function head() {
<tr>
<td class="label">Type:</td>
<td>
<select id="categories" name="type" onchange="Categories()"<?=$this->Disabled?>>
<? foreach (Misc::display_array($this->Categories) as $Index => $Cat) {
echo "\t\t\t\t\t<option value=\"$Index\"";
<select id="categories" name="type" onchange="Categories()"<?=$this->Disabled?>>
<?
foreach (Misc::display_array($this->Categories) as $Index => $Cat) {
echo "\t\t\t\t\t\t<option value=\"$Index\"";
if ($Cat == $this->Torrent['CategoryName']) {
echo ' selected="selected"';
}
echo ">$Cat</option>\n";
}
?>
</select>
</select>
</td>
</tr>
</table>
<? }//if ?>
<div id="dynamic_form">
<? } // function head
<?
} // function head
function foot() {
@ -108,24 +118,29 @@ function foot() {
?>
</div>
<table cellpadding="3" cellspacing="1" border="0" class="layout border slice" width="100%">
<? if (!$this->NewTorrent) {
<?
if (!$this->NewTorrent) {
if (check_perms('torrents_freeleech')) {
?>
<tr id="freetorrent">
<td class="label">Freeleech</td>
<td>
<select name="freeleech">
<? $FL = array("Normal", "Free", "Neutral");
foreach ($FL as $Key => $Name) { ?>
<?
$FL = array("Normal", "Free", "Neutral");
foreach ($FL as $Key => $Name) {
?>
<option value="<?=$Key?>"<?=($Key == $Torrent['FreeTorrent'] ? ' selected="selected"' : '')?>><?=$Name?></option>
<? } ?>
<? } ?>
</select>
because
because
<select name="freeleechtype">
<? $FL = array("N/A", "Staff Pick", "Perma-FL", "Vanity House");
foreach ($FL as $Key => $Name) { ?>
<?
$FL = array("N/A", "Staff Pick", "Perma-FL", "Vanity House");
foreach ($FL as $Key => $Name) {
?>
<option value="<?=$Key?>"<?=($Key == $Torrent['FreeLeechType'] ? ' selected="selected"' : '')?>><?=$Name?></option>
<? } ?>
<? } ?>
</select>
</td>
</tr>
@ -145,7 +160,8 @@ function foot() {
</table>
</form>
</div>
<? } //function foot
<?
} //function foot
function music_form($GenreTags) {
@ -192,7 +208,8 @@ function music_form($GenreTags) {
<td class="label">Artist(s):</td>
<td id="artistfields">
<p id="vawarning" class="hidden">Please use the multiple artists feature rather than adding "Various Artists" as an artist; read <a href="wiki.php?action=article&amp;id=369" target="_blank">this</a> for more information.</p>
<? if (!empty($Torrent['Artists'])) {
<?
if (!empty($Torrent['Artists'])) {
$FirstArtist = true;
foreach ($Torrent['Artists'] as $Importance => $Artists) {
foreach ($Artists as $Artist) {
@ -209,12 +226,14 @@ function music_form($GenreTags) {
</select>
<?
if ($FirstArtist) {
if (!$this->DisabledFlag) { ?>
if (!$this->DisabledFlag) {
?>
<a href="javascript:AddArtistField()" class="brackets">+</a> <a href="javascript:RemoveArtistField()" class="brackets">&minus;</a>
<?
}
$FirstArtist = false;
} ?>
}
?>
<br />
<?
}
@ -232,9 +251,7 @@ function music_form($GenreTags) {
<option value="7">Producer</option>
</select>
<a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
<?
}
?>
<? } ?>
</td>
</tr>
<tr id="title_tr">
@ -351,7 +368,6 @@ function show() {
$Line = $Remaster['RemasterYear'].' / '.$Remaster['RemasterTitle'].' / '.$Remaster['RemasterRecordLabel'].' / '.$Remaster['RemasterCatalogueNumber'];
if ($Line != $LastLine) {
$LastLine = $Line;
?>
<option value="<?=$Index?>"<?=(($Remaster['ID'] == $this->TorrentID) ? ' selected="selected"' : '')?>><?=$Line?></option>
<?
@ -406,7 +422,8 @@ function show() {
<td>
<select id="format" name="format" onchange="Format()">
<option>---</option>
<? foreach (Misc::display_array($this->Formats) as $Format) {
<?
foreach (Misc::display_array($this->Formats) as $Format) {
echo "\t\t\t\t\t\t<option value=\"$Format\"";
if ($Format == $Torrent['Format']) {
echo ' selected="selected"';
@ -447,10 +464,11 @@ function show() {
echo ' selected="selected"';
}
echo ">$Bitrate</option>\n";
} ?>
}
?>
</select>
<span id="other_bitrate_span"<? if (!$OtherBitrate) { echo ' class="hidden"'; } ?>>
<input type="text" name="other_bitrate" size="5" id="other_bitrate"<? if ($OtherBitrate) { echo ' value="'.display_str($Torrent['Bitrate']).'"';} ?> onchange="AltBitrate()" />
<input type="text" name="other_bitrate" size="5" id="other_bitrate"<? if ($OtherBitrate) { echo ' value="'.display_str($Torrent['Bitrate']).'"';} ?> onchange="AltBitrate();" />
<input type="checkbox" id="vbr" name="vbr"<? if (isset($VBR)) { echo ' checked="checked"'; } ?> /><label for="vbr"> (VBR)</label>
</span>
</td>
@ -467,14 +485,17 @@ function show() {
</tr>
<?
}
if ($this->NewTorrent) { ?>
if ($this->NewTorrent) { ?>
<tr>
<td class="label">Multi-format uploader:</td>
<td><input type="button" value="+" id="add_format" /><input type="button" style="display: none;" value="-" id="remove_format" /></td>
</tr>
<tr id="placeholder_row_top"></tr>
<tr id="placeholder_row_bottom"></tr>
<? } if (check_perms('torrents_edit_vanityhouse') && $this->NewTorrent) { ?>
<?
}
if (check_perms('torrents_edit_vanityhouse') && $this->NewTorrent) {
?>
<tr>
<td class="label">Vanity House:</td>
<td>
@ -489,7 +510,8 @@ function show() {
<td>
<select name="media" onchange="CheckYear();" id="media">
<option>---</option>
<? foreach ($this->Media as $Media) {
<?
foreach ($this->Media as $Media) {
echo "\t\t\t\t\t\t<option value=\"$Media\"";
if (isset($Torrent['Media']) && $Media == $Torrent['Media']) {
echo ' selected="selected"';
@ -506,7 +528,8 @@ function show() {
<td>
<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 />
<? }
<?
}
if ((check_perms('users_mod') || G::$LoggedUser['ID'] == $Torrent['UserID']) && ($Torrent['LogScore'] == 100 || $Torrent['LogScore'] == 99)) {
G::$DB->query('
@ -517,7 +540,8 @@ function show() {
AND (Adjusted = '0' OR Adjusted = '')");
list($LogID) = G::$DB->next_record();
if ($LogID) {
if (!check_perms('users_mod')) { ?>
if (!check_perms('users_mod')) {
?>
<tr>
<td class="label">Trumpable:</td>
<td>
@ -530,7 +554,8 @@ function show() {
}
}
}
if (!$this->NewTorrent && check_perms('users_mod')) { ?>
if (!$this->NewTorrent && check_perms('users_mod')) {
?>
</td>
</tr>
<?/* if ($HasLog) { ?>
@ -570,13 +595,15 @@ function show() {
<td class="label">Lossy web approved:</td>
<td><input type="checkbox" id="lossyweb_approved" name="lossyweb_approved"<? if ($LossywebApproved) { echo ' checked="checked"';} ?> /> <label for="lossyweb_approved">Check this box if the torrent is an approved lossy WEB release.</label></td>
</tr>
<? }
if ($this->NewTorrent) { ?>
<?
}
if ($this->NewTorrent) {
?>
<tr>
<td class="label">Tags:</td>
<td>
<? if ($GenreTags) { ?>
<select id="genre_tags" name="genre_tags" onchange="add_tag();return false;"<?=$this->Disabled?>>
<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;"<?=$this->Disabled?>>
<option>---</option>
<? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
<option value="<?=$Genre?>"><?=$Genre?></option>
@ -609,7 +636,6 @@ function show() {
</tr>
</table>
<?
// For AJAX requests (e.g. when changing the type from Music to Applications),
// we don't need to include all scripts, but we do need to include the code
// that generates previews. It will have to be eval'd after an AJAX request.

View File

@ -506,7 +506,7 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru
$IconLink = display_str($DonorRewards['CustomIconLink']);
}
if ($EnabledRewards['HasCustomDonorIcon'] && !empty($DonorRewards['CustomIcon'])) {
$IconImage = ImageTools::process($DonorRewards['CustomIcon']);
$IconImage = ImageTools::process($DonorRewards['CustomIcon'], false, 'donoricon', $UserID);
} else {
if ($SpecialRank === MAX_SPECIAL_RANK) {
$DonorHeart = 6;
@ -609,6 +609,7 @@ public static function get_bookmarks($UserID) {
/**
* Generate HTML for a user's avatar or just return the avatar URL
* @param unknown $Avatar
* @param unknown $UserID
* @param unknown $Username
* @param unknown $Setting
* @param number $Size
@ -616,7 +617,7 @@ public static function get_bookmarks($UserID) {
* @return string
*/
public static function show_avatar($Avatar, $UserID, $Username, $Setting, $Size = 150, $ReturnHTML = True) {
$Avatar = ImageTools::process($Avatar);
$Avatar = ImageTools::process($Avatar, false, 'avatar', $UserID);
$Style = 'style="max-height: 400px;"';
$AvatarMouseOverText = '';
$SecondAvatar = '';
@ -633,7 +634,7 @@ public static function show_avatar($Avatar, $UserID, $Username, $Setting, $Size
$AvatarMouseOverText = "alt=\"$Username's avatar\"";
}
if ($EnabledRewards['HasSecondAvatar'] && !empty($Rewards['SecondAvatar'])) {
$SecondAvatar = ' data-gazelle-second-avatar="' . ImageTools::process($Rewards['SecondAvatar']) . '"';
$SecondAvatar = ' data-gazelle-second-avatar="' . ImageTools::process($Rewards['SecondAvatar'], false, 'avatar2', $UserID) . '"';
}
// case 1 is avatars disabled
switch ($Setting) {

View File

@ -1,5 +1,8 @@
CHANGE LOG
2013-10-22 by alderaan
Second avatars and donor icons will now be automatically reset by the image proxy if they are too large
2013-10-17 by porkpie
Load notifications without an Ajax request

View File

@ -92,14 +92,12 @@ only one statement.
In loops and conditional blocks, the statement(s) shall be placed on the
following lines.
When opening a PHP statement, `<?` shall be used instead of `<?php`.
When opening a PHP statement, `<?` shall be used instead of `<?php`. In
other words, use PHP's short tags.
Switch cases in index files shall not contain substantial code. The use
of include statements is acceptable.
When building strings in PHP, single quotes shall be used when not
printing a variable.
When declaring JavaScript variables, `var` shall always be used.
When manually type casting, whitespace should not be used between the

View File

@ -29,8 +29,8 @@
//---------- Get some data to start processing
// Caching anything beyond the first page of any given forum is just wasting ram
// users are more likely to search then to browse to page 2
// Caching anything beyond the first page of any given forum is just wasting RAM.
// Users are more likely to search than to browse to page 2.
if ($Page == 1) {
list($Forum,,,$Stickies) = $Cache->get_value("forums_$ForumID");
}

View File

@ -29,9 +29,9 @@
// Variables for database input
$TopicID = (int)$_POST['threadid'];
$Sticky = (isset($_POST['sticky'])) ? 1 : 0;
$Locked = (isset($_POST['locked'])) ? 1 : 0;
$Ranking = (int) $_POST['ranking'];
$Sticky = isset($_POST['sticky']) ? 1 : 0;
$Locked = isset($_POST['locked']) ? 1 : 0;
$Ranking = (int)$_POST['ranking'];
if (!$Sticky && $Ranking > 0) {
$Ranking = 0;
} elseif (0 > $Ranking) {
@ -120,7 +120,7 @@
LastPostID = '$NewLastPostID',
LastPostAuthorID = '$NewLastAuthorID',
LastPostTime = '$NewLastAddedTime'
WHERE ID='$ForumID'");
WHERE ID = '$ForumID'");
$Cache->delete_value("thread_$TopicID");
@ -181,9 +181,12 @@
ForumID = '$ForumID'
WHERE ID = '$TopicID'");
// always clear cache when editing a thread.
// if a thread title, etc. is changed, this cache key must be cleared so the thread listing
// properly shows the new thread title.
$Cache->delete_value("forums_$ForumID");
if ($ForumID != $OldForumID) { // If we're moving a thread, change the forum stats
$Cache->delete_value("forums_$ForumID");
$Cache->delete_value("forums_$OldForumID");
$DB->query("
@ -270,7 +273,8 @@
SELECT COUNT(pp.ID)
FROM forums_posts AS pp
JOIN forums_topics AS tt ON pp.TopicID = tt.ID
WHERE tt.ForumID = '$ForumID')
WHERE tt.ForumID = '$ForumID'
)
FROM forums_topics AS t
JOIN forums_posts AS p ON p.ID = t.LastPostID
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
@ -346,7 +350,7 @@
case 'editing':
if ($OldTitle != $RawTitle) {
// title edited
$TopicNotes[] = "Title edited from '$OldTitle' to '$RawTitle'";
$TopicNotes[] = "Title edited from \"$OldTitle\" to \"$RawTitle\"";
}
if ($OldLocked != $Locked) {
if (!$OldLocked) {
@ -363,7 +367,7 @@
}
}
if ($OldRanking != $Ranking) {
$TopicNotes[] = "Ranking changed from $OldRanking to $Ranking";
$TopicNotes[] = "Ranking changed from \"$OldRanking\" to \"$Ranking\"";
}
if ($ForumID != $OldForumID) {
$TopicNotes[] = "Moved from [url=https://" . SSL_SITE_URL . "/forums.php?action=viewforum&forumid=$OldForumID]${OldForumName}[/url] to [url=https://" . SSL_SITE_URL . "/forums.php?action=viewforum&forumid=$ForumID]${ForumName}[/url]";
@ -371,7 +375,7 @@
break;
case 'trashing':
$TopicNotes[] = 'Trashed';
$Notification = "Your thread '$NewLastTitle' has been trashed";
$Notification = "Your thread \"$NewLastTitle\" has been trashed";
break;
default:
break;

View File

@ -45,12 +45,13 @@
SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
AND forums_posts.ID <= '$PostID')/".POSTS_PER_PAGE."
) AS Page
AND forums_posts.ID <= '$PostID'
) / ".POSTS_PER_PAGE."
) AS Page
FROM forums_posts as p
JOIN forums_topics as t on p.TopicID = t.ID
JOIN forums as f ON t.ForumID=f.ID
WHERE p.ID='$PostID'");
JOIN forums as f ON t.ForumID = f.ID
WHERE p.ID = '$PostID'");
list($OldBody, $AuthorID, $TopicID, $IsLocked, $ForumID, $MinClassWrite, $Page) = $DB->next_record();
// Make sure they aren't trying to edit posts they shouldn't
@ -83,14 +84,14 @@
SET
Body = '" . db_string($Body) . "',
EditedUserID = '$UserID',
EditedTime = '".$SQLTime."'
WHERE ID='$PostID'");
EditedTime = '$SQLTime'
WHERE ID = '$PostID'");
$CatalogueID = floor((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
$Cache->begin_transaction("thread_$TopicID"."_catalogue_$CatalogueID");
if ($Cache->MemcacheDBArray[$Key]['ID'] != $PostID) {
$Cache->cancel_transaction();
$Cache->delete_value('thread_'.$TopicID.'_catalogue_'.$CatalogueID); //just clear the cache for would be cache-screwer-uppers
$Cache->delete_value("thread_$TopicID"."_catalogue_$CatalogueID"); //just clear the cache for would be cache-screwer-uppers
} else {
$Cache->update_row($Key, array(
'ID'=>$Cache->MemcacheDBArray[$Key]['ID'],
@ -111,14 +112,16 @@
$ThreadInfo['StickyPost']['Body'] = $Body;
$ThreadInfo['StickyPost']['EditedUserID'] = $LoggedUser['ID'];
$ThreadInfo['StickyPost']['EditedTime'] = $SQLTime;
$Cache->cache_value('thread_'.$TopicID.'_info', $ThreadInfo, 0);
$Cache->cache_value("thread_$TopicID".'_info', $ThreadInfo, 0);
}
$DB->query("
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('forums', $PostID, $UserID, '$SQLTime', '".db_string($OldBody)."')");
INSERT INTO comments_edits
(Page, PostID, EditUser, EditTime, Body)
VALUES
('forums', $PostID, $UserID, '$SQLTime', '".db_string($OldBody)."')");
$Cache->delete_value("forums_edits_$PostID");
// This gets sent to the browser, which echoes it in place of the old body
echo $Text->full_format($Body);
?>
<br /><br />Last edited by <a href="user.php?id=<?=$LoggedUser['ID']?>"><?=$LoggedUser['Username']?></a> just now
<br /><br />Last edited by <a href="user.php?id=<?=$LoggedUser['ID']?>"><?=$LoggedUser['Username']?></a> Just now

View File

@ -543,7 +543,11 @@
}
}
if (check_perms('site_moderate_forums')) {
G::$DB->query("SELECT ID, AuthorID, AddedTime, Body FROM forums_topic_notes WHERE TopicID = $ThreadID ORDER BY ID ASC");
G::$DB->query("
SELECT ID, AuthorID, AddedTime, Body
FROM forums_topic_notes
WHERE TopicID = $ThreadID
ORDER BY ID ASC");
$Notes = G::$DB->to_array();
?>
<br />

View File

@ -17,7 +17,7 @@
}
if (isset($_GET['c'])) {
list($Data, $Type) = $Cache->get_value('image_cache_'.md5($URL));
list($Data, $FileType) = $Cache->get_value('image_cache_'.md5($URL));
$Cached = true;
}
if (!isset($Data) || !$Data) {
@ -26,8 +26,8 @@
if (!$Data || empty($Data)) {
img_error('timeout');
}
$Type = image_type($Data);
if ($Type && function_exists("imagecreatefrom$Type")) {
$FileType = image_type($Data);
if ($FileType && function_exists("imagecreatefrom$FileType")) {
$Image = imagecreatefromstring($Data);
if (invisible($Image)) {
img_error('invisible');
@ -38,63 +38,105 @@
}
if (isset($_GET['c']) && strlen($Data) < 262144) {
$Cache->cache_value('image_cache_'.md5($URL), array($Data, $Type), 3600 * 24 * 7);
$Cache->cache_value('image_cache_'.md5($URL), array($Data, $FileType), 3600 * 24 * 7);
}
}
// Reset avatar, add mod note
function reset_image($UserID, $Type, $AdminComment, $PrivMessage) {
if ($Type === 'avatar') {
$CacheKey = "user_info_$UserID";
$DBTable = 'users_info';
$DBColumn = "Avatar";
$PMSubject = 'Your avatar has been automatically reset';
} elseif ($Type === 'avatar2') {
$CacheKey = "donor_info_$UserID";
$DBTable = 'donor_rewards';
$DBColumn = "SecondAvatar";
$PMSubject = 'Your second avatar has been automatically reset';
} elseif ($Type === 'donoricon') {
$CacheKey = "donor_info_$UserID";
$DBTable = 'donor_rewards';
$DBColumn = "CustomIcon";
$PMSubject = 'Your donor icon has been automatically reset';
}
$UserInfo = G::$Cache->get_value($CacheKey, true);
if ($UserInfo !== false) {
if ($UserInfo[$DBColumn] === '') {
// This image has already been reset
return;
}
$UserInfo[$DBColumn] = '';
G::$Cache->cache_value($CacheKey, $UserInfo, 2592000); // cache for 30 days
}
// reset the avatar or donor icon URL
G::$DB->query("
UPDATE $DBTable
SET $DBColumn = ''
WHERE UserID = '$UserID'");
// write comment to staff notes
G::$DB->query("
UPDATE users_info
SET AdminComment = CONCAT('".sqltime().' - '.db_string($AdminComment)."\n\n', AdminComment)
WHERE UserID = '$UserID'");
// clear cache keys
G::$Cache->delete_value($CacheKey);
Misc::send_pm($UserID, 0, $PMSubject, $PrivMessage);
}
// Enforce avatar rules
if (isset($_GET['avatar'])) {
if (!is_number($_GET['avatar'])) {
if (isset($_GET['type']) && isset($_GET['userid'])) {
$ValidTypes = array('avatar', 'avatar2', 'donoricon');
if (!is_number($_GET['userid']) || !in_array($_GET['type'], $ValidTypes)) {
die();
}
$UserID = $_GET['avatar'];
$UserID = $_GET['userid'];
$Type = $_GET['type'];
$Height = image_height($Type, $Data);
if (strlen($Data) > 256 * 1024 || $Height > 400) {
if ($Type === 'avatar' || $Type === 'avatar2') {
$MaxFileSize = 256 * 1024; // 256 kB
$MaxImageHeight = 400; // pixels
$TypeName = $Type === 'avatar' ? 'avatar' : 'second avatar';
} elseif ($Type === 'donoricon') {
$MaxFileSize = 64 * 1024; // 64 kB
$MaxImageHeight = 100; // pixels
$TypeName = 'donor icon';
}
$Height = image_height($FileType, $Data);
if (strlen($Data) > $MaxFileSize || $Height > $MaxImageHeight) {
// Sometimes the cached image we have isn't the actual image
if ($Cached) {
$Data2 = @file_get_contents($URL, 0, stream_context_create(array('http' => array('timeout' => 15))));
} else {
$Data2 = $Data;
}
if (strlen($Data2) > 256 * 1024 || image_height($Type, $Data2) > 400) {
if (strlen($Data2) > $MaxFileSize || image_height($FileType, $Data2) > $MaxImageHeight) {
require_once(SERVER_ROOT.'/classes/mysql.class.php');
require_once(SERVER_ROOT.'/classes/time.class.php'); //Require the time class
require_once(SERVER_ROOT.'/classes/time.class.php');
$DBURL = db_string($URL);
// Reset avatar, add mod note
$UserInfo = $Cache->get_value("user_info_$UserID");
$UserInfo['Avatar'] = '';
$Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
$DB->query("
UPDATE users_info
SET
Avatar = '',
AdminComment = CONCAT('".sqltime()." - Avatar reset automatically (Size: ".number_format((strlen($Data)) / 1024)." kB, Height: ".$Height."px). Used to be $DBURL\n\n', AdminComment)
WHERE UserID = '$UserID'");
// Send PM
Misc::send_pm($UserID, 0, "Your avatar has been automatically reset", SITE_NAME." has the following requirements for avatars:
[b]Avatars must not exceed 256 kB or be vertically longer than 400 px.[/b]
Your avatar at $DBURL has been found to exceed these rules. As such, it has been automatically reset. You are welcome to reinstate your avatar once it has been resized down to an acceptable size.");
$AdminComment = ucfirst($TypeName)." reset automatically (Size: ".number_format((strlen($Data)) / 1024)." kB, Height: ".$Height."px). Used to be $DBURL";
$PrivMessage = SITE_NAME." has the following requirements for {$TypeName}s:\n\n".
"[b]".ucfirst($TypeName)."s must not exceed ".($MaxFileSize / 1024)." kB or be vertically longer than {$MaxImageHeight}px.[/b]\n\n".
"Your $TypeName at $DBURL has been found to exceed these rules. As such, it has been automatically reset. You are welcome to reinstate your $TypeName once it has been resized down to an acceptable size.";
reset_image($UserID, $Type, $AdminComment, $PrivMessage);
}
}
}
/*
TODO: solve this properly for photoshop output images which prepend shit to the image file. skip it or strip it
if (!isset($Type)) {
if (!isset($FileType)) {
img_error('timeout');
}
*/
if (isset($Type)) {
header("Content-type: image/$Type");
if (isset($FileType)) {
header("Content-type: image/$FileType");
}
echo $Data;
?>

View File

@ -2,7 +2,7 @@
<span id="no-cookies" class="hidden warning">You appear to have cookies disabled.<br /><br /></span>
<noscript><span class="warning"><?=SITE_NAME?> requires JavaScript to function properly. Please enable JavaScript in your browser.</span><br /><br /></noscript>
<?
if (strtotime($BannedUntil) < time() && !$BanID) {
if (strtotime($BannedUntil) < time()) {
?>
<form class="auth_form" name="login" id="loginform" method="post" action="login.php">
<?
@ -47,13 +47,9 @@
</form>
<?
} else {
if ($BanID) {
?>
<span class="warning">Your IP address is banned indefinitely.</span>
<? } else { ?>
<span class="warning">You are banned from logging in for another <?=time_diff($BannedUntil)?>.</span>
<?
}
}
if ($Attempts > 0) {

View File

@ -74,7 +74,11 @@
Requests::update_sphinx_requests($RequestID);
echo 'success';
$DB->query("SELECT UserID FROM requests_votes WHERE RequestID = '$RequestID' AND UserID != '$LoggedUser[ID]'");
$DB->query("
SELECT UserID
FROM requests_votes
WHERE RequestID = '$RequestID'
AND UserID != '$LoggedUser[ID]'");
$UserIDs = array();
while (list($UserID) = $DB->next_record()) {
$UserIDs[] = $UserID;

View File

@ -7,12 +7,13 @@
error(404);
}
$ConvID = (int) $_POST['id'];
$ConvID = (int)$_POST['id'];
$DB->query("SELECT c.Subject, c.UserID, c.Level, c.AssignedToUser, c.Unread, c.Status, u.Donor
FROM staff_pm_conversations AS c
JOIN users_info AS u ON u.UserID = c.UserID
WHERE ID=$ConvID");
$DB->query("
SELECT c.Subject, c.UserID, c.Level, c.AssignedToUser, c.Unread, c.Status, u.Donor
FROM staff_pm_conversations AS c
JOIN users_info AS u ON u.UserID = c.UserID
WHERE ID = $ConvID");
list($Subject, $UserID, $Level, $AssignedToUser, $Unread, $Status, $Donor) = $DB->next_record();
if ($DB->record_count() == 0) {
error(404);
@ -25,20 +26,26 @@
} else {
$Message .= ' ';
}
//$DB->query("INSERT INTO staff_pm_messages (UserID, SentDate, Message, ConvID)
// VALUES (".$LoggedUser['ID'].", '".sqltime()."', '".db_string($Message)."', $ConvID)");
$DB->query("UPDATE staff_pm_conversations
SET Date='".sqltime()."',
Unread=true,
Status='Resolved',
ResolverID=".$LoggedUser['ID']."
WHERE ID=$ConvID");
/*
$DB->query("
INSERT INTO staff_pm_messages
(UserID, SentDate, Message, ConvID)
VALUES
(".$LoggedUser['ID'].", '".sqltime()."', '".db_string($Message)."', $ConvID)");
*/
$DB->query("
UPDATE staff_pm_conversations
SET Date = '".sqltime()."',
Unread = true,
Status = 'Resolved',
ResolverID = ".$LoggedUser['ID']."
WHERE ID = $ConvID");
Donations::donate($UserID, array(
"Source" => "Staff PM",
"Price" => $_POST['donation_amount'],
"Currency" => $_POST['donation_currency'],
"Reason" => $_POST['donation_reason'],
"SendPM" => true));
"Source" => "Staff PM",
"Price" => $_POST['donation_amount'],
"Currency" => $_POST['donation_currency'],
"Reason" => $_POST['donation_reason'],
"SendPM" => true));
header('Location: staffpm.php');

View File

@ -80,10 +80,10 @@
</td>
<td style="word-wrap: break-word;">
<? if (!empty($User['CustomIcon'])) { ?>
<img src="<?=ImageTools::process($User['CustomIcon'])?>" width="15" height="13" alt="" />
<img src="<?=ImageTools::process($User['CustomIcon'], false, 'donoricon', $User['UserID'])?>" width="15" height="13" alt="" />
<? } ?>
</td
> <td style="word-wrap: break-word;">
</td>
<td style="word-wrap: break-word;">
<?=$User['CustomIconLink']?>
</td>
<td style="word-wrap: break-word;">

View File

@ -26,7 +26,7 @@
$Feed = new FEED;
$Text = new TEXT;
define('QUERY_EXCEPTION',true); // Shut up debugging
define('QUERY_EXCEPTION', true); // Shut up debugging
//******************************************************************************//
//--------------- Set $Properties array ----------------------------------------//
@ -38,9 +38,9 @@
$TypeID = $_POST['type'] + 1;
$Properties['CategoryName'] = $Type;
$Properties['Title'] = $_POST['title'];
$Properties['Remastered'] = ((isset($_POST['remaster'])) ? 1 : 0);
$Properties['Remastered'] = isset($_POST['remaster']) ? 1 : 0;
if ($Properties['Remastered'] || isset($_POST['unknown'])) {
$Properties['UnknownRelease'] = ((isset($_POST['unknown'])) ? 1 : 0);
$Properties['UnknownRelease'] = isset($_POST['unknown']) ? 1 : 0;
$Properties['RemasterYear'] = $_POST['remaster_year'];
$Properties['RemasterTitle'] = $_POST['remaster_title'];
$Properties['RemasterRecordLabel'] = $_POST['remaster_record_label'];
@ -57,7 +57,7 @@
$Properties['RecordLabel'] = $_POST['record_label'];
$Properties['CatalogueNumber'] = $_POST['catalogue_number'];
$Properties['ReleaseType'] = $_POST['releasetype'];
$Properties['Scene'] = ((isset($_POST['scene'])) ? 1 : 0);
$Properties['Scene'] = isset($_POST['scene']) ? 1 : 0;
$Properties['Format'] = $_POST['format'];
$Properties['Media'] = $_POST['media'];
$Properties['Bitrate'] = $_POST['bitrate'];
@ -89,7 +89,7 @@
//******************************************************************************//
//--------------- Validate data in upload form ---------------------------------//
$Validate->SetFields('type', '1', 'inarray', 'Please select a valid type.', array('inarray'=>array_keys($Categories)));
$Validate->SetFields('type', '1', 'inarray', 'Please select a valid type.', array('inarray' => array_keys($Categories)));
switch ($Type) {
case 'Music':
if (!$_POST['groupid']) {

View File

@ -350,7 +350,7 @@
$OldPassKey = db_string($UserInfo['torrent_pass']);
$NewPassKey = db_string(Users::make_secret());
$ChangerIP = db_string($LoggedUser['IP']);
$SQL .= ",m.torrent_pass='$NewPassKey'";
$SQL .= ",m.torrent_pass = '$NewPassKey'";
$DB->query("
INSERT INTO users_history_passkeys
(UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
@ -364,7 +364,7 @@
Tracker::update_tracker('change_passkey', array('oldpasskey' => $OldPassKey, 'newpasskey' => $NewPassKey));
}
$SQL .= "WHERE m.ID='".db_string($UserID)."'";
$SQL .= "WHERE m.ID = '".db_string($UserID)."'";
$DB->query($SQL);
if ($ResetPassword) {

View File

@ -21,18 +21,7 @@
$Preview = 0;
}
$EnabledRewards = Donations::get_enabled_rewards($UserID);
$Rewards = Donations::get_rewards($UserID);
$ProfileRewards = Donations::get_profile_rewards($UserID);
$AvatarMouseOverText = '';
$SecondAvatar = '';
if ($EnabledRewards['HasAvatarMouseOverText'] && !empty($Rewards['AvatarMouseOverText'])) {
$AvatarMouseOverText = " title=\"$Rewards[AvatarMouseOverText]\" alt=\"$Rewards[AvatarMouseOverText]\"";
} else {
$AvatarMouseOverText = " alt=\"\"";
}
if ($EnabledRewards['HasSecondAvatar'] && !empty($Rewards['SecondAvatar'])) {
$SecondAvatar = ' data-gazelle-second-avatar="' . ImageTools::process($Rewards['SecondAvatar']) . '"';
}
@ -248,15 +237,11 @@ function check_paranoia_here($Setting) {
<div class="sidebar">
<?
if ($Avatar && Users::has_avatars_enabled()) {
// TODO: use Users::show_avatar; why is display_str() used a few lines below (where avatar is displayed)?
if (check_perms('site_proxy_images') && !empty($Avatar)) {
$Avatar = 'http'.($SSL ? 's' : '').'://'.SITE_URL.'/image.php?c=1&amp;avatar='.$UserID.'&amp;i='.urlencode($Avatar);
}
?>
<div class="box box_image box_image_avatar">
<div class="head colhead_dark">Avatar</div>
<div align="center">
<img class="avatar double_avatar" src="<?=display_str($Avatar)?>" width="150" style="max-height: 400px;"<?=$AvatarMouseOverText?><?=$SecondAvatar?> />
<?= Users::show_avatar($Avatar, $UserID, $Username, $HeavyInfo['DisableAvatars'])?>
</div>
</div>
<?
@ -586,25 +571,29 @@ function check_paranoia_here($Setting) {
<div class="head">Ratio watch</div>
<div class="pad">This user is currently on ratio watch and must upload <?=Format::get_size(($Downloaded * $RequiredRatio) - $Uploaded)?> in the next <?=time_diff($RatioWatchEnds)?>, or their leeching privileges will be revoked. Amount downloaded while on ratio watch: <?=Format::get_size($Downloaded - $RatioWatchDownload)?></div>
</div>
<? } ?>
<?
}
?>
<div class="box">
<div class="head">
<?=!empty($InfoTitle) ? $InfoTitle : 'Profile';?>
<span style="float: right;"><a href="#" onclick="$('#profilediv').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Hide</a></span>&nbsp;
</div>
<div class="pad" id="profilediv">
<? if (!$Info) { ?>
<?
if (!$Info) {
?>
This profile is currently empty.
<?
} else {
echo $Text->full_format($Info);
}
} else {
echo $Text->full_format($Info);
}
?>
</div>
</div>
<? DonationsView::render_profile_rewards($EnabledRewards, $ProfileRewards); ?>
<?
DonationsView::render_profile_rewards($EnabledRewards, $ProfileRewards);
if (check_paranoia_here('snatched')) {
$RecentSnatches = $Cache->get_value("recent_snatches_$UserID");
if ($RecentSnatches === false) {
@ -628,7 +617,7 @@ function check_paranoia_here($Setting) {
foreach ($RecentSnatches as $Key => $SnatchInfo) {
$RecentSnatches[$Key]['Artist'] = Artists::display_artists($Artists[$SnatchInfo['ID']], false, true);
}
$Cache->cache_value('recent_snatches_'.$UserID, $RecentSnatches, 0); //inf cache
$Cache->cache_value("recent_snatches_$UserID", $RecentSnatches, 0); //inf cache
}
if (!empty($RecentSnatches)) {
?>