Empty commit

This commit is contained in:
Git 2013-05-14 08:00:34 +00:00
parent 6cbf7e6beb
commit bdb2e4fe12
40 changed files with 441 additions and 370 deletions

View File

@ -61,7 +61,7 @@ public static function get_group_votes($GroupID) {
} else {
$GroupVotes = $DB->next_record(MYSQLI_ASSOC, false);
}
$Cache->cache_value('votes_'.$GroupID, $GroupVotes, 259200);
$Cache->cache_value('votes_'.$GroupID, $GroupVotes, 259200); // 3 days
}
return $GroupVotes;
}
@ -211,7 +211,7 @@ public static function get_rank_all($GroupID) {
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_overall', $Rankings, 259200);
$Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days
}
return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
@ -246,7 +246,7 @@ public static function get_rank_year($GroupID, $Year) {
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200);
$Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200); // 3 days
}
return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
@ -286,7 +286,7 @@ public static function get_rank_decade($GroupID, $Year) {
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200);
$Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200); // 3 days
}
return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;

View File

@ -21,7 +21,6 @@ function compare($X, $Y) {
$Name = db_string(trim($_GET['artistname']));
$DB->query("SELECT ArtistID FROM artists_alias WHERE Name LIKE '$Name'");
if (!(list($ArtistID) = $DB->next_record(MYSQLI_NUM, false))) {
//if (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
json_die("failure");
}
// If we get here, we got the ID!

View File

@ -23,10 +23,12 @@
echo 'badvote';
die();
}
$Type = ($_REQUEST['vote'] == 'up')?"Up":"Down";
$Type = ($_REQUEST['vote'] == 'up') ? 'Up' : 'Down';
// Update the two votes tables if needed
$DB->query("INSERT IGNORE INTO users_votes (UserID, GroupID, Type) VALUES ($UserID, $GroupID, '$Type')");
$DB->query("
INSERT IGNORE INTO users_votes (UserID, GroupID, Type)
VALUES ($UserID, $GroupID, '$Type')");
if ($DB->affected_rows() == 0) {
echo 'noaction';
die();
@ -34,7 +36,7 @@
// Update the group's cache key
$GroupVotes['Total'] += 1;
if ($Type == "Up") {
if ($Type == 'Up') {
$GroupVotes['Ups'] += 1;
}
$Cache->cache_value('votes_'.$GroupID, $GroupVotes);
@ -117,7 +119,10 @@
}
$Type = $UserVotes[$GroupID]['Type'];
$DB->query("DELETE FROM users_votes WHERE UserID=$UserID AND GroupID=$GroupID");
$DB->query("
DELETE FROM users_votes
WHERE UserID=$UserID
AND GroupID=$GroupID");
// Update personal cache key
unset($UserVotes[$GroupID]);
@ -125,12 +130,14 @@
// Update the group's cache key
$GroupVotes['Total'] -= 1;
if ($Type == "Up") {
if ($Type == 'Up') {
$GroupVotes['Ups'] -= 1;
}
$Cache->cache_value('votes_'.$GroupID, $GroupVotes);
$DB->query("UPDATE torrents_votes SET Total = GREATEST(0, Total - 1),
$DB->query("
UPDATE torrents_votes
SET Total = GREATEST(0, Total - 1),
Score = IFNULL(binomial_ci(GREATEST(0,Ups".($Type == 'Up' ? '-1' : '')."),GREATEST(0, Total)),0)".
($Type == 'Up' ? ', Ups = GREATEST(0, Ups - 1)' : '')."
WHERE GroupID=$GroupID");

View File

@ -2,7 +2,9 @@
require(SERVER_ROOT.'/sections/torrents/functions.php');
$GroupID = (int)$_GET['id'];
if ($GroupID == 0) { error('bad id parameter', true); }
if ($GroupID == 0) {
error('bad id parameter', true);
}
$TorrentDetails = get_group_info($GroupID, true, 0, false);
$TorrentDetails = $TorrentDetails[0];

View File

@ -1,5 +1,6 @@
<?php
if (!check_perms('users_warn')) { error(404);
if (!check_perms('users_warn')) {
error(404);
}
Misc::assert_isset_request($_POST, array('reason', 'privatemessage', 'body', 'length', 'artistid', 'postid', 'userid'));

View File

@ -1,6 +1,7 @@
<?
if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) {
$DB->query("SELECT t.ID AS TorrentID,
$DB->query("SELECT
t.ID AS TorrentID,
t.GroupID AS GroupID
FROM xbt_files_users AS x
JOIN torrents AS t ON t.ID=x.fid

View File

@ -131,7 +131,9 @@
$SQL .= " AND c.ID IN(".db_string(implode(',', $CollageIDs)).")";
}
} else {
if (!check_paranoia('collages', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
if (!check_paranoia('collages', $User['Paranoia'], $UserClass, $UserID)) {
error(403);
}
$SQL .= " AND UserID='".$_GET['userid']."'";
}
$Categories[] = 0;

View File

@ -25,8 +25,14 @@ function btc_address($UserID, $GenAddress = false) {
if (!empty($Addr)) { return $Addr; }
elseif ($GenAddress) {
if (empty($NewAddr)) { error(0); }
$DB->query("UPDATE users_info SET BitcoinAddress = '".db_string($NewAddr)."' WHERE UserID = '".$UserID."' AND BitcoinAddress IS NULL");
if (empty($NewAddr)) {
error(0);
}
$DB->query("
UPDATE users_info
SET BitcoinAddress = '".db_string($NewAddr)."'
WHERE UserID = '$UserID'
AND BitcoinAddress IS NULL");
return $NewAddr;
} else {
return false;

View File

@ -21,22 +21,23 @@
if ($Length != 'verbal') {
$Time = ((int) $Length) * (7 * 24 * 60 * 60);
Tools::warn_user($UserID, $Time, "$URL - " . $Reason);
$Subject = "You have received a warning";
$Subject = 'You have received a warning';
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$WarnTime = time_plus($Time);
$AdminComment = date("Y-m-d") . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
$AdminComment = date('Y-m-d') . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
} else {
$Subject = "You have received a verbal warning";
$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";
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
}
$DB->query("INSERT INTO users_warnings_forums (UserID, Comment) VALUES('$UserID', '" . db_string($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)");
Tools::update_user_notes($UserID, $AdminComment);
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
$DB->query("SELECT
$DB->query("
SELECT
rc.Body,
rc.AuthorID,
rc.RequestID,
@ -45,14 +46,23 @@
WHERE rc.ID='".db_string($_POST['post'])."'");
list($OldBody, $AuthorID,$RequestID,$AddedTime)=$DB->next_record();
$DB->query("SELECT ceil(COUNT(ID) / ".POSTS_PER_PAGE.") AS Page FROM requests_comments WHERE RequestID = $GroupID AND ID <= $PostID");
$DB->query("
SELECT ceil(COUNT(ID) / ".POSTS_PER_PAGE.") AS Page
FROM requests_comments
WHERE RequestID = $GroupID AND ID <= $PostID");
list($Page) = $DB->next_record();
if ($LoggedUser['ID']!=$AuthorID && !check_perms('site_moderate_forums')) { error(404); }
if ($DB->record_count()==0) { error(404); }
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
error(404);
}
if ($DB->record_count() == 0) {
error(404);
}
// Perform the update
$DB->query("UPDATE requests_comments SET
$DB->query("
UPDATE requests_comments
SET
Body = '" . db_string($Body) . "',
EditedUserID = '".$LoggedUser['ID']."',
EditedTime = '".sqltime()."'
@ -73,8 +83,9 @@
));
$Cache->commit_transaction(0);
$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('requests', ".$PostID.", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
$DB->query("
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('requests', $PostID, " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
header("Location: requests.php?id=$GroupID&postid=$PostID#post$PostID");

View File

@ -17,7 +17,7 @@
$Err = 'You forgot to supply a link to the filling torrent';
} else {
$Link = $_POST['link'];
if (preg_match("/".TORRENT_REGEX."/i", $Link, $Matches) < 1) {
if (preg_match('/'.TORRENT_REGEX.'/i', $Link, $Matches) < 1) {
$Err = "Your link didn't seem to be a valid torrent link";
} else {
$TorrentID = $Matches[0];
@ -189,7 +189,8 @@
Misc::write_log("Request $RequestID (".$FullName.") was filled by user $FillerID (".$FillerUsername.") with the torrent $TorrentID for a ".Format::get_size($RequestVotes['TotalBounty']).' bounty.');
// Give bounty
$DB->query("UPDATE users_main
$DB->query("
UPDATE users_main
SET Uploaded = (Uploaded + ".$RequestVotes['TotalBounty'].")
WHERE ID = $FillerID");

View File

@ -1,7 +1,11 @@
<?
if (!check_perms('site_debug')) { error(403); }
if (!check_perms('site_debug')) {
error(403);
}
if (!isset($_GET['case']) || !$Analysis = $Cache->get_value('analysis_'.$_GET['case'])) { error(404); }
if (!isset($_GET['case']) || !$Analysis = $Cache->get_value('analysis_'.$_GET['case'])) {
error(404);
}
View::show_header('Case Analysis');
?>

View File

@ -1,6 +1,8 @@
<?php
if (!check_perms('admin_manage_ipbans')) { error(403); }
if (!check_perms('admin_manage_ipbans')) {
error(403);
}
if (isset($_GET['perform'])) {
$IPA = substr($_GET['ip'], 0, strcspn($_GET['ip'], '.'));
if ($_GET['perform'] == 'delete') {
@ -12,9 +14,9 @@
} elseif ($_GET['perform'] == 'create') {
$Notes = db_string($_GET['notes']);
$IP = Tools::ip_to_unsigned($_GET['ip']); //Sanitized by Validation regex
$DB->query("INSERT INTO ip_bans
(FromIP, ToIP, Reason) VALUES
('$IP','$IP', '$Notes')");
$DB->query("
INSERT INTO ip_bans (FromIP, ToIP, Reason)
VALUES ('$IP','$IP', '$Notes')");
$Cache->delete_value('ip_bans_'.$IPA);
}
}

View File

@ -2,7 +2,9 @@
ini_set('memory_limit', '5G');
set_time_limit(0);
//if (!check_perms('site_debug')) { error(403); }
//if (!check_perms('site_debug')) {
// error(403);
//}
View::show_header();
@ -12,32 +14,32 @@
shell_exec('rm GeoLiteCity-latest.zip');
if (($Locations = file("GeoLiteCity_".date('Ym')."07/GeoLiteCity-Location.csv", FILE_IGNORE_NEW_LINES)) === false) {
error("Download or extraction of maxmind database failed");
error('Download or extraction of maxmind database failed');
}
array_shift($Locations);
array_shift($Locations);
echo "There are ".count($Locations)." locations";
echo "<br />";
echo 'There are '.count($Locations).' locations';
echo '<br />';
$CountryIDs = array();
foreach ($Locations as $Location) {
$Parts = explode(",", $Location);
$Parts = explode(',', $Location);
//CountryIDs[1] = "AP";
$CountryIDs[trim($Parts[0], '"')] = trim($Parts[1], '"');
}
echo "There are ".count($CountryIDs)." CountryIDs";
echo "<br />";
echo 'There are '.count($CountryIDs).' CountryIDs';
echo '<br />';
if (($Blocks = file("GeoLiteCity_".date('Ym')."07/GeoLiteCity-Blocks.csv", FILE_IGNORE_NEW_LINES)) === false) {
echo "Error";
echo 'Error';
}
array_shift($Blocks);
array_shift($Blocks);
echo "There are ".count($Blocks)." blocks";
echo "<br />";
echo 'There are '.count($Blocks).' blocks';
echo '<br />';
//Because 4,000,000 rows is a lot for any server to handle, we split it into manageable groups of 10,000
$SplitOn = 10000;
@ -49,15 +51,19 @@
$StartIP = trim($StartIP, '"');
$EndIP = trim($EndIP, '"');
$CountryID = trim($CountryID, '"');
$Values[] = "('".$StartIP."', '".$EndIP."', '".$CountryIDs[$CountryID]."')";
$Values[] = "('$StartIP', '$EndIP', '".$CountryIDs[$CountryID]."')";
if ($Index % $SplitOn == 0) {
$DB->query("INSERT INTO geoip_country (StartIP, EndIP, Code) VALUES ".implode(", ", $Values));
$DB->query('
INSERT INTO geoip_country (StartIP, EndIP, Code)
VALUES '.implode(', ', $Values));
$Values = array();
}
}
if (count($Values) > 0) {
$DB->query("INSERT INTO geoip_country (StartIP, EndIP, Code) VALUES ".implode(", ", $Values));
$DB->query("
INSERT INTO geoip_country (StartIP, EndIP, Code)
VALUES ".implode(', ', $Values));
}

View File

@ -1,6 +1,8 @@
<?
$GroupID = $_GET['groupid'];
if (!is_number($GroupID)) { error(404); }
if (!is_number($GroupID)) {
error(404);
}
View::show_header("History for Group $GroupID");
@ -27,8 +29,7 @@
<?
$Log = $DB->query("SELECT TorrentID, UserID, Info, Time FROM group_log WHERE GroupID = ".$GroupID." ORDER BY Time DESC");
$LogEntries = $DB->to_array(false, MYSQL_NUM);
foreach ($LogEntries AS $LogEntry)
{
foreach ($LogEntries AS $LogEntry) {
list($TorrentID, $UserID, $Info, $Time) = $LogEntry;
?>
<tr class="rowa">
@ -39,7 +40,7 @@
list($Media, $Format, $Encoding) = $DB->next_record();
if ($DB->record_count() == 0) { ?>
<td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a> (Deleted)</td><?
} elseif ($Media == "") { ?>
} elseif ($Media == '') { ?>
<td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a></td><?
} else { ?>
<td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a> (<?=$Format?>/<?=$Encoding?>/<?=$Media?>)</td>

View File

@ -1,5 +1,5 @@
<?
//Show the "This album is number x overall, etc. box for music only
// Show the "This album is number x overall", etc. box for the "Music" category only
if ($GroupCategoryID == 1) {
$Rankings = Votes::get_ranking($GroupID, $GroupYear);
$LIs = '';
@ -19,7 +19,7 @@
$Class = 'vr_top_50';
}
$LIs .= '<li id="vote_rank_'.$key.'" class="'.$Class.'">No. '.$Rank.' '.$text.'</li>';
$LIs .= "<li id=\"vote_rank_$key\" class=\"$Class\">No. $Rank $text</li>";
}
}

View File

@ -355,9 +355,9 @@ function checked($Checked) {
<tr>
<td class="label">Preset</td>
<td>
<button type="button" onclick="ParanoiaResetOff()">Show everything</button>
<button type="button" onclick="ParanoiaResetStats()">Show stats only</button>
<!--<button type="button" onclick="ParanoiaResetOn()">Show nothing</button>-->
<input type="button" onclick="ParanoiaResetOff()">Show everything</input>
<input type="button" onclick="ParanoiaResetStats()">Show stats only</input>
<!--<input type="button" onclick="ParanoiaResetOn()">Show nothing</input>-->
</td>
</tr>
<tr>
@ -477,7 +477,7 @@ function checked($Checked) {
<tr>
<td class="label"><strong>Reset passkey</strong></td>
<td>
<label><input type="checkbox" name="resetpasskey" />
<label><input type="checkbox" name="resetpasskey" id="resetpasskey" />
Any active torrents must be downloaded again to continue leeching/seeding.</label> <br />
<a href="wiki.php?action=article&amp;name=Passkey">See this wiki article for more information.</a>
</td>
@ -509,7 +509,7 @@ function checked($Checked) {
</tr>
<tr>
<td colspan="2" class="right">
<input type="submit" value="Save Profile" />
<input type="button" value="Save Profile" onclick="userform_submit();"/>
</td>
</tr>
</table>

View File

@ -590,8 +590,10 @@
$Cache->delete_value('user_'.$Cur['torrent_pass']);
//MUST come after the case for updating can_leech.
$DB->query("INSERT INTO users_history_passkeys
(UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime) VALUES
$DB->query("
INSERT INTO users_history_passkeys
(UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
VALUES
('$UserID', '".$Cur['torrent_pass']."', '$Passkey', '0.0.0.0', '".sqltime()."')");
Tracker::update_tracker('change_passkey', array('oldpasskey' => $Cur['torrent_pass'], 'newpasskey' => $Passkey));
}
@ -621,10 +623,17 @@
$DB->query("SELECT ID, Uploaded, Downloaded FROM users_main WHERE Username LIKE '".$MergeStatsFrom."'");
if ($DB->record_count() > 0) {
list($MergeID, $MergeUploaded, $MergeDownloaded) = $DB->next_record();
$DB->query("UPDATE users_main AS um JOIN users_info AS ui ON um.ID=ui.UserID SET um.Uploaded = 0, um.Downloaded = 0, ui.AdminComment = CONCAT('".sqltime()." - Stats merged into https://".SSL_SITE_URL."/user.php?id=".$UserID." (".$Cur['Username'].") by ".$LoggedUser['Username']."\n\n', ui.AdminComment) WHERE ID = ".$MergeID);
$DB->query("
UPDATE users_main AS um
JOIN users_info AS ui ON um.ID=ui.UserID
SET
um.Uploaded = 0,
um.Downloaded = 0,
ui.AdminComment = CONCAT('".sqltime()." - Stats (Uploaded: ".Format::get_size($MergeUploaded).", Downloaded: ".Format::get_size($MergeDownloaded).", Ratio: ".Format::get_ratio($MergeUploaded, $MergeDownloaded).") merged into https://".SSL_SITE_URL."/user.php?id=".$UserID." (".$Cur['Username'].") by ".$LoggedUser['Username']."\n\n', ui.AdminComment)
WHERE ID = ".$MergeID);
$UpdateSet[] = "Uploaded = Uploaded + '$MergeUploaded'";
$UpdateSet[] = "Downloaded = Downloaded + '$MergeDownloaded'";
$EditSummary[] = "stats merged from https://".SSL_SITE_URL."/user.php?id=".$MergeID." (".$MergeStatsFrom.")";
$EditSummary[] = "stats merged from https://".SSL_SITE_URL."/user.php?id=".$MergeID." (".$MergeStatsFrom.") (previous stats: Uploaded: ".Format::get_size($Cur['Uploaded']).", Downloaded: ".Format::get_size($Cur['Downloaded']).", Ratio: ".Format::get_ratio($Cur['Uploaded'], $Cur['Downloaded']).")";
$Cache->delete_value('users_stats_'.$UserID);
$Cache->delete_value('users_stats_'.$MergeID);
}

View File

@ -13,7 +13,9 @@
} else {
$UserID = $LoggedUser['ID'];
}
if (!is_number($UserID)) { error(404); }
if (!is_number($UserID)) {
error(404);
}
$UserInfo = Users::user_info($UserID);
$Perms = Permissions::get_permissions($UserInfo['PermissionID']);
@ -26,11 +28,15 @@
}
if (isset($_GET['expire'])) {
if (!check_perms('users_mod')) { error(403); }
if (!check_perms('users_mod')) {
error(403);
}
$UserID = $_GET['userid'];
$TorrentID = $_GET['torrentid'];
if (!is_number($UserID) || !is_number($TorrentID)) { error(403); }
if (!is_number($UserID) || !is_number($TorrentID)) {
error(403);
}
$DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
$DB->query("UPDATE users_freeleeches SET Expired=TRUE WHERE UserID=$UserID AND TorrentID=$TorrentID");
@ -44,7 +50,8 @@
list($Page,$Limit) = Format::page_limit(25);
$DB->query("SELECT SQL_CALC_FOUND_ROWS
$DB->query("
SELECT SQL_CALC_FOUND_ROWS
f.TorrentID,
t.GroupID,
f.Time,
@ -97,7 +104,7 @@
$Name = $ArtistName.$Name;
}
if ($Format && $Encoding) {
$Name.=' ['.$Format.' / '.$Encoding.']';
$Name.=" [$Format / $Encoding]";
}
?>
<tr class="<?=($i ? 'rowa' : 'rowb')?>">

View File

@ -155,3 +155,15 @@ function ToggleIdenticons() {
$('#identicons').hide();
}
}
function userform_submit() {
var userform = jQuery('#userform');
if (jQuery('#resetpasskey').is(':checked')) {
if (confirm('Are you sure you want to reset your passkey?')) {
userform.submit();
}
}
else {
userform.submit();
};
}