Empty commit

This commit is contained in:
Git 2013-03-25 08:00:21 +00:00
parent 24d951c055
commit 0ccae72a56
10 changed files with 105 additions and 97 deletions

66
classes/class_forums.php Normal file
View File

@ -0,0 +1,66 @@
<?
class Forums {
/**
* @param string $Body
* @param int $PostID
* @param string $Page
* @param int $PageID
*/
public static function quote_notify($Body, $PostID, $Page, $PageID) {
/*
* 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
*/
global $LoggedUser, $Cache, $DB;
$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('/^[a-z0-9_?]{1,20}$/iD', $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));
$DB->query("SELECT m.ID, p.PushService
FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
AND i.NotifyOnQuote = '1' AND i.UserID != $LoggedUser[ID]");
$Results = $DB->to_array();
foreach ($Results as $Result) {
$UserID = db_string($Result['ID']);
$PushService = $Result['PushService'];
$QuoterID = db_string($LoggedUser['ID']);
$Page = db_string($Page);
$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);
}
}
}

View File

@ -99,6 +99,9 @@
case 'Format':
$FileName = 'class_format';
break;
case 'Forums':
$FileName = 'class_forums';
break;
case 'ImageTools':
$FileName = 'class_image_tools';
break;

View File

@ -4,7 +4,8 @@
f.FriendID, u.Username
FROM friends AS f
RIGHT JOIN users_enable_recommendations AS r
ON r.ID = f.FriendID AND r.Enable = 1
ON r.ID = f.FriendID
AND r.Enable = 1
RIGHT JOIN users_main AS u
ON u.ID = f.FriendID
WHERE f.UserID = '$LoggedUser[ID]'

View File

@ -38,7 +38,8 @@
t.Seeders,
t.Leechers,
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data,
g.ReleaseType
g.ReleaseType,
t.Size
FROM torrents AS t
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID ";
@ -185,7 +186,7 @@ function generate_torrent_json($Caption, $Tag, $Details, $Limit) {
foreach ($Details as $Detail) {
list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$WikiImage,$TorrentTags,
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType) = $Detail;
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType,$Size) = $Detail;
$Artist = Artists::display_artists(Artists::get_artist($GroupID), false, true);
$TruncArtist = substr($Artist, 0, strlen($Artist)-3);
@ -220,7 +221,8 @@ function generate_torrent_json($Caption, $Tag, $Details, $Limit) {
'snatched' => (int) $Snatched,
'seeders' => (int) $Seeders,
'leechers' => (int) $Leechers,
'data' => (int) $Data
'data' => (int) $Data,
'size' => (int) $Size,
);
}

View File

@ -1,67 +0,0 @@
<?php
$Matches = array();
preg_match_all('/\[quote(.*?)]|\[\/quote]/', $Body, $Matches);
if (array_key_exists(0, $Matches)) {
$Usernames = array();
$Level = 0;
foreach ($Matches[0] as $M) {
if ($M != '[/quote]') {
if ($Level == 0) {
add_username($M);
}
$Level++;
} else {
$Level--;
}
}
}
//remove any dupes in the array
$Usernames = array_unique($Usernames);
$DB->query("SELECT m.ID, p.PushService
FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
WHERE m.Username IN " . "('" . implode("', '", $Usernames)
. "')
AND i.NotifyOnQuote = '1' AND i.UserID != $LoggedUser[ID]");
$Results = $DB->to_array();
foreach($Results as $Result) {
$UserID = $Result['ID'];
$PushService = $Result['PushService'];
$QuoterID = db_string($LoggedUser['ID']);
$UserID = db_string($UserID);
$ForumID = db_string($ForumID);
$TopicID = db_string($TopicID);
$PostID = db_string($PostID);
$DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, Page, PageID, PostID, Date)
VALUES ('$UserID', '$QuoterID', 'forums', '$TopicID', '$PostID', '" . sqltime() . "')");
$Cache->delete_value('notify_quoted_' . $UserID);
}
/*
* Validate the username and add it into the $Usernames array
*/
function add_username($Str)
{
global $Usernames;
$Matches = array();
if (preg_match('/\[quote=(.*)]/', $Str, $Matches)) {
$Username = $Matches[1];
$Username = trim($Username);
if (strlen($Username) > 0 && !preg_match('/[^a-zA-Z0-9|]/i', $Username)) {
$Exploded = explode('|', $Username);
$Username = $Exploded[0];
$Username = preg_replace('/(^[.,]*)|([.,]*$)/', '', $Username);
$Usernames[] = $Username;
}
}
}
?>

View File

@ -232,6 +232,6 @@
$Cache->delete_value('subscriptions_user_new_'.$Subscriber);
}
}
include('quote_notify.php');
Forums::quote_notify($Body, $PostID, 'forums', $TopicID);
header('Location: forums.php?action=viewthread&threadid='.$TopicID.'&page='.ceil($ThreadInfo['Posts']/$PerPage));
die();

View File

@ -68,8 +68,8 @@
<form action="" method="post" acclass="thin box pad">
<input type="hidden" name="action" value="registration_log" />
Joined After: <input type="date" name="after_date"/>
Joined Before: <input type="date" name="before_date"/>
Joined after: <input type="date" name="after_date" />
Joined before: <input type="date" name="before_date" />
<input type="submit" />
</form>

View File

@ -156,7 +156,8 @@
t.Seeders,
t.Leechers,
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data,
g.ReleaseType
g.ReleaseType,
t.Size
FROM torrents AS t
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID ";
@ -376,6 +377,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
<td class="center" style="width:15px;"></td>
<td class="cats_col"></td>
<td><strong>Name</strong></td>
<td style="text-align:right"><strong>Size</strong></td>
<td style="text-align:right"><strong>Data</strong></td>
<td style="text-align:right"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
<td style="text-align:right"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
@ -416,7 +418,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
foreach ($Details as $Detail) {
list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$WikiImage,$TagsList,
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType) = $Detail;
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType,$Size) = $Detail;
$IsBookmarked = has_bookmarked('torrent', $GroupID);
$IsSnatched = Torrents::has_snatched($TorrentID);
@ -490,6 +492,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
</div>
</td>
<td style="text-align:right" class="nobr"><?=Format::get_size($Size)?></td>
<td style="text-align:right" class="nobr"><?=Format::get_size($Data)?></td>
<td style="text-align:right"><?=number_format((double) $Snatched)?></td>
<td style="text-align:right"><?=number_format((double) $Seeders)?></td>