From 22c29ba0e1397c7dbbcd4104852ffda27a3dee7f Mon Sep 17 00:00:00 2001
From: Git <git@what.cd>
Date: Tue, 31 Jan 2012 08:00:23 +0000
Subject: [PATCH] Empty commit

---
 classes/script_start.php       |  2 +-
 sections/ajax/request.php      |  2 ++
 sections/ajax/requests.php     |  2 ++
 sections/schedule/index.php    | 10 ++++++++--
 sections/user/takemoderate.php |  6 +++++-
 sections/user/user.php         |  6 ++++--
 6 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/classes/script_start.php b/classes/script_start.php
index efb14a0a..10a1269f 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -2090,7 +2090,7 @@ function update_tracker($Action, $Updates, $ToIRC = false) {
 		$ResHeader = '';
 		do {
 			$ResHeader .= fread($File, 1);
-		} while (!ends_with($ResHeader, "\r\n\r\n"));
+		} while (!feof($File) && !ends_with($ResHeader, "\r\n\r\n"));
 
 		$Response = '';
 		while($Line = fgets($File)) {
diff --git a/sections/ajax/request.php b/sections/ajax/request.php
index faebbf1c..626bb912 100644
--- a/sections/ajax/request.php
+++ b/sections/ajax/request.php
@@ -1,5 +1,7 @@
 <?
 
+authorize(true);
+
 $RequestTax = 0.1;
 
 // Minimum and default amount of upload to remove from the user when they vote.
diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php
index e591f6ad..6328561e 100644
--- a/sections/ajax/requests.php
+++ b/sections/ajax/requests.php
@@ -2,6 +2,8 @@
 
 authorize(true);
 
+include(SERVER_ROOT.'/sections/requests/functions.php');
+
 $Queries = array();
 
 $OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
diff --git a/sections/schedule/index.php b/sections/schedule/index.php
index 9e71a0bb..5ca188b4 100644
--- a/sections/schedule/index.php
+++ b/sections/schedule/index.php
@@ -622,6 +622,7 @@ function next_hour() {
 			$Cache->expire_value('thread_'.$TopicID.'_info',3600*24*30);
 		}
 	}
+	echo "Old threads locked\n";
 
 	//------------- Delete dead torrents ------------------------------------//
 	
@@ -651,6 +652,7 @@ function next_hour() {
 		OR t.Time < '".time_minus(3600*24*2)."'
 		AND t.last_action = 0");
 	$TorrentIDs = $DB->to_array();
+	echo "Found ".count($TorrentIDs)." inactive torrents to be deleted.\n";
 	
 	$LogEntries = array();
 	
@@ -680,7 +682,11 @@ function next_hour() {
 		$DeleteNotes[$UserID]['Count']++;
 		
 		++$i;
+		if ($i % 500 == 0) {
+			echo "$i inactive torrents removed.\n";
+		}
 	}
+	echo "$i torrents deleted for inactivity.\n";
 	
 	foreach($DeleteNotes as $UserID => $MessageInfo){
 		$Singular = ($MessageInfo['Count'] == 1) ? true : false;
@@ -766,7 +772,7 @@ function next_hour() {
 		$AddExtra='';
 		if($Format) { $ExtraInfo.=$Format; $AddExtra=' / '; }
 		if($Encoding) { $ExtraInfo.=$AddExtra.$Encoding; $AddExtra=' / '; }
-		"FLAC / Lossless / Log (100%) / Cue / CD";
+		// "FLAC / Lossless / Log (100%) / Cue / CD";
 		if($HasLog) { $ExtraInfo.=$AddExtra."Log (".$LogScore."%)"; $AddExtra=' / '; }
 		if($HasCue) { $ExtraInfo.=$AddExtra."Cue"; $AddExtra=' / '; }
 		if($Media) { $ExtraInfo.=$AddExtra.$Media; $AddExtra=' / '; }
@@ -851,7 +857,7 @@ function next_hour() {
 			$AddExtra='';
 			if($Format) { $ExtraInfo.=$Format; $AddExtra=' / '; }
 			if($Encoding) { $ExtraInfo.=$AddExtra.$Encoding; $AddExtra=' / '; }
-			"FLAC / Lossless / Log (100%) / Cue / CD";
+			// "FLAC / Lossless / Log (100%) / Cue / CD";
 			if($HasLog) { $ExtraInfo.=$AddExtra."Log (".$LogScore."%)"; $AddExtra=' / '; }
 			if($HasCue) { $ExtraInfo.=$AddExtra."Cue"; $AddExtra=' / '; }
 			if($Media) { $ExtraInfo.=$AddExtra.$Media; $AddExtra=' / '; }
diff --git a/sections/user/takemoderate.php b/sections/user/takemoderate.php
index fbe3e25f..535c33fe 100644
--- a/sections/user/takemoderate.php
+++ b/sections/user/takemoderate.php
@@ -118,7 +118,8 @@
 	DisableIRC,
 	m.RequiredRatio,
 	m.FLTokens,
-	i.RatioWatchEnds
+	i.RatioWatchEnds,
+	SHA1(i.AdminComment) AS CommentHash
 	FROM users_main AS m
 	JOIN users_info AS i ON i.UserID = m.ID
 	LEFT JOIN permissions AS p ON p.ID=m.PermissionID
@@ -129,6 +130,9 @@
 }
 
 $Cur = $DB->next_record(MYSQLI_ASSOC, false);
+if ($_POST['comment_hash'] != $Cur['CommentHash']) {
+	error("Somebody else has moderated this user since you loaded it.  Please go back and refresh the page.");
+}
 
 //NOW that we know the class of the current user, we can see if one staff member is trying to hax0r us.
 if(!check_perms('users_mod', $Cur['Class'])) {
diff --git a/sections/user/user.php b/sections/user/user.php
index 1a26b42e..576b6e73 100644
--- a/sections/user/user.php
+++ b/sections/user/user.php
@@ -60,7 +60,8 @@
 		i.DisableIRC,
 		i.DisableRequests,
 		i.HideCountryChanges,
-		m.FLTokens
+		m.FLTokens,
+		SHA1(i.AdminComment)
 		FROM users_main AS m
 		JOIN users_info AS i ON i.UserID = m.ID
 		LEFT JOIN users_main AS inviter ON i.Inviter = inviter.ID
@@ -72,7 +73,7 @@
 		header("Location: log.php?search=User+".$UserID);
 	}
 
-	list($Username,	$Email,	$LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $CustomTitle, $torrent_pass, $Enabled, $Paranoia, $Invites, $DisableLeech, $Visible, $JoinDate, $Info, $Avatar, $Country, $AdminComment, $Donor, $Artist, $Warned, $SupportFor, $RestrictedForums, $PermittedForums, $InviterID, $InviterName, $ForumPosts, $RatioWatchEnds, $RatioWatchDownload, $DisableAvatar, $DisableInvites, $DisablePosting, $DisableForums, $DisableTagging, $DisableUpload, $DisableWiki, $DisablePM, $DisableIRC, $DisableRequests, $DisableCountry, $FLTokens) = $DB->next_record(MYSQLI_NUM, array(8,11));
+	list($Username,	$Email,	$LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $CustomTitle, $torrent_pass, $Enabled, $Paranoia, $Invites, $DisableLeech, $Visible, $JoinDate, $Info, $Avatar, $Country, $AdminComment, $Donor, $Artist, $Warned, $SupportFor, $RestrictedForums, $PermittedForums, $InviterID, $InviterName, $ForumPosts, $RatioWatchEnds, $RatioWatchDownload, $DisableAvatar, $DisableInvites, $DisablePosting, $DisableForums, $DisableTagging, $DisableUpload, $DisableWiki, $DisablePM, $DisableIRC, $DisableRequests, $DisableCountry, $FLTokens, $CommentHash) = $DB->next_record(MYSQLI_NUM, array(8,11));
 } else { // Person viewing is a normal user
 	$DB->query("SELECT
 		m.Username,
@@ -913,6 +914,7 @@ function check_paranoia_here($Setting) {
 		<div class="box">
 			<div class="head">Staff Notes <a href="#" name="admincommentbutton" onclick="ChangeTo('text'); return false;">(Edit)</a></div>
 			<div class="pad">
+				<input type="hidden" name="comment_hash" value="<?=$CommentHash?>">
 				<div id="admincommentlinks" class="AdminComment box" style="width:98%;"><?=$Text->full_format($AdminComment)?></div>
 				<textarea id="admincomment" onkeyup="resize('admincomment');" class="AdminComment hidden" name="AdminComment" cols="65" rows="26" style="width:98%;"><?=display_str($AdminComment)?></textarea>
 				<a href="#" name="admincommentbutton" onclick="ChangeTo('text'); return false;">Toggle Edit</a>