7 changes from Mon Aug 22 02:37:20 2011 +0200 to Mon Aug 22 03:16:48 2011 +0000

empty
fix relative date display

fixes http://what.cd/forums.php?action=viewthread&threadid=138447
This commit is contained in:
Git 2011-08-22 08:00:05 +00:00
parent cd4b22489c
commit 9c7079266d
21 changed files with 153 additions and 44 deletions

View File

@ -12,7 +12,7 @@ function time_ago($TimeStamp) {
return time()-$TimeStamp;
}
function time_diff($TimeStamp,$Levels=2,$Span=true) {
function time_diff($TimeStamp,$Levels=2,$Span=true, $Lowercase=false) {
if(!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
if($TimeStamp == '0000-00-00 00:00:00') { return 'Never'; }
$TimeStamp = strtotime($TimeStamp);
@ -122,6 +122,10 @@ function time_diff($TimeStamp,$Levels=2,$Span=true) {
} elseif (!isset($HideAgo)) {
$Return .= ' ago';
}
if ($Lowercase) {
$Return = strtolower($Return);
}
if ($Span) {
return '<span class="time" title="'.date('M d Y, H:i', $TimeStamp).'">'.$Return.'</span>';

View File

@ -86,9 +86,6 @@
?>
</head>
<body id="<?=$Document == 'collages' ? 'collage' : $Document?>" <?= ((!$Mobile && $LoggedUser['Rippy'] == 'On') ? 'onload="say()"' : '') ?>>
<?
} ?>
<div id="wrapper">
<h1 class="hidden"><?=SITE_NAME?></h1>

View File

@ -388,6 +388,15 @@ CREATE TABLE `news` (
KEY `Time` (`Time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `ocelot_query_times` (
`buffer` enum('users','torrents','snatches','peers') NOT NULL,
`starttime` datetime NOT NULL,
`ocelotinstance` datetime NOT NULL,
`querylength` int(11) NOT NULL,
`timespent` int(11) NOT NULL,
UNIQUE KEY `starttime` (`starttime`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `permissions` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Level` int(10) unsigned NOT NULL,
@ -1075,7 +1084,8 @@ CREATE TABLE `users_info` (
KEY `JoinDate` (`JoinDate`),
KEY `Inviter` (`Inviter`),
KEY `RatioWatchEnds` (`RatioWatchEnds`),
KEY `RatioWatchDownload` (`RatioWatchDownload`)
KEY `RatioWatchDownload` (`RatioWatchDownload`),
KEY `BitcoinAddress` (`BitcoinAddress`(4))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users_main` (

View File

@ -44,7 +44,7 @@
<input type="text" name="image" size="92" value="<?=$Image?>" /><br />
<h3>Artist info</h3>
<textarea name="body" cols="91" rows="20"><?=$Body?></textarea> <br />
<h3>Vanity House <input type="checkbox" name="vanity_house" value="1" <?=( check_perms('artist_edit_vanityhouse') ? '' : 'disabled="disabled"' )?> <?=($VanityHouse ? 'checked="checked"' : '')?>" /></h3>
<h3>Vanity House <input type="checkbox" name="vanity_house" value="1" <?=( check_perms('artist_edit_vanityhouse') ? '' : 'disabled="disabled"' )?> <?=($VanityHouse ? 'checked="checked"' : '')?> /></h3>
<h3>Edit summary</h3>
<input type="text" name="summary" size="92" /><br />
<div style="text-align: center;">

View File

@ -41,6 +41,7 @@
<? if (count($ArtistList) == 0) { ?>
<h2>You have not bookmarked any artists.</h2>
</div>
</div><!--content-->
<?
show_footer();
die();

View File

@ -17,13 +17,10 @@
break;
case 'remove_snatched':
header('Location: bookmarks.php');
die();
error(0); // disable this for now as it's the heaviest part of the entire site
authorize();
$DB->query("DELETE b FROM bookmarks_torrents AS b WHERE b.UserID='".$LoggedUser['ID']."' AND b.GroupID IN(SELECT DISTINCT t.GroupID FROM torrents AS t INNER JOIN xbt_snatched AS s ON s.fid=t.ID AND s.uid='".$LoggedUser['ID']."')");
$Cache->delete_value('bookmarks_torrents_'.$UserID);
$Cache->delete_value('bookmarks_torrents_'.$UserID.'_full');
$Cache->delete_value('bookmarks_torrent_'.$UserID);
$Cache->delete_value('bookmarks_torrent_'.$UserID.'_full');
header('Location: bookmarks.php');
die();
break;

View File

@ -255,14 +255,14 @@ function compare($X, $Y){
<a href="bookmarks.php?type=requests">[Requests]</a>
<? if (count($TorrentList) > 0) { ?>
<br /><br />
<a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="alert('This feature is temporarily disabled');">[Remove Snatched]</a>
<?//onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">[Remove Snatched]</a>?>
<a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">[Remove Snatched]</a>
<? } ?>
</div>
<? if (count($TorrentList) == 0) { ?>
<div class="box pad" align="center">
<h2>You have not bookmarked any torrents.</h2>
</div>
</div><!--content-->
<?
show_footer();
die();

View File

@ -140,8 +140,8 @@
<? } else { ?>
<h2>Browse collages<?=(!empty($UserLink) ? (isset($CollageIDs) ? ' with contributions by '.$UserLink : ' started by '.$UserLink) : '')?></h2>
<? } ?>
<div>
<? if (!$BookmarkView) { ?>
<div>
<form action="" method="get">
<div><input type="hidden" name="action" value="search" /></div>
<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
@ -197,8 +197,7 @@
</div>
<? } // if (!$BookmarkView) ?>
<div class="linkbox">
<? if (!$BookmarkView) { ?>
<?
<? if (!$BookmarkView) {
if (check_perms('site_collages_create')) { ?>
<a href="collages.php?action=new">[New collage]</a>
<? }
@ -232,7 +231,6 @@
<a href="bookmarks.php?type=collages">[Collages]</a>
<a href="bookmarks.php?type=requests">[Requests]</a>
<? } ?>
<br /><br />
<?
$Pages=get_pages($Page,$NumResults,COLLAGES_PER_PAGE,9);
echo $Pages;
@ -246,7 +244,8 @@
<h2>Your search did not match anything.</h2>
<p>Make sure all names are spelled correctly, or try making your search less specific.</p>
<? } ?>
</div>
</div><!--box-->
</div><!--content-->
<? show_footer(); die();
} ?>
<table width="100%">

View File

@ -67,7 +67,7 @@
<? if($Depth < count($Edits)) { ?>
<a href="#edit_info_<?=$PostID?>" onclick="LoadEdit('<?=$Type?>', <?=$PostID?>, <?=($Depth + 1)?>); return false;">&laquo;</a>
<?=(($Depth == 0) ? 'Last edited by' : 'Edited by')?>
<?=format_username($UserID, $Username) ?> <?=strtolower(time_diff($Time))?>
<?=format_username($UserID, $Username) ?> <?=time_diff($Time,2,true,true)?>
<? } else { ?>
<em>Original Post</em>
<? }

View File

@ -390,7 +390,7 @@
<a href="#content<?=$PostID?>" onclick="LoadEdit('forums', <?=$PostID?>, 1); return false;">&laquo;</a>
<? } ?>
Last edited by
<?=format_username($EditedUserID, $EditedUsername) ?> <?=strtolower(time_diff($EditedTime))?>
<?=format_username($EditedUserID, $EditedUsername) ?> <?=time_diff($EditedTime,2,true,true)?>
<? } ?>
</div>
</td>

View File

@ -75,7 +75,9 @@
<div class="head">
<strong><?=$Users[(int)$SenderID]['UserStr']?></strong> <?=time_diff($SentDate)?> - <a href="#quickpost" onclick="Quote('<?=$MessageID?>','<?=$Users[(int)$SenderID]['Username']?>');">[Quote]</a>
</div>
<div class="body" id="message<?=$MessageID?>"><?=$Text->full_format($Body)?></div>
<div class="body" id="message<?=$MessageID?>">
<?=$Text->full_format($Body)?>
</div>
</div>
<?
}

View File

@ -2,7 +2,7 @@
enforce_login();
include(SERVER_ROOT.'/sections/requests/functions.php');
$RequestTax = 0.5;
$RequestTax = 0.1;
// Minimum and default amount of upload to remove from the user when they vote.
// Also change in static/functions/requests.js

View File

@ -421,7 +421,7 @@
<a href="#content<?=$PostID?>" onclick="LoadEdit('requests', <?=$PostID?>, 1); return false;">&laquo;</a>
<? } ?>
Last edited by
<?=format_username($EditedUserID, $EditedUsername) ?> <?=strtolower(time_diff($EditedTime))?>
<?=format_username($EditedUserID, $EditedUsername) ?> <?=time_diff($EditedTime,2,true,true)?>
<? } ?>
</div>
</td>

View File

@ -86,10 +86,11 @@
BitrateList,
FormatList,
MediaList,
LogCue
LogCue,
TimeStampDiff(MINUTE, LastVote, NOW())
FROM requests
WHERE ID = ".$RequestID);
list($Title, $RequesterID, $OldTorrentID, $RequestCategoryID, $RequestReleaseType, $RequestCatalogueNumber, $BitrateList, $FormatList, $MediaList, $LogCue) = $DB->next_record();
list($Title, $RequesterID, $OldTorrentID, $RequestCategoryID, $RequestReleaseType, $RequestCatalogueNumber, $BitrateList, $FormatList, $MediaList, $LogCue, $VoteTime) = $DB->next_record();
if(!empty($OldTorrentID)) {
$Err = "This request has already been filled";
@ -160,8 +161,7 @@
FillerID = ".$FillerID.",
TorrentID = ".$TorrentID.",
TimeFilled = '".sqltime()."'
WHERE ID = ".$RequestID);
WHERE ID = ".$RequestID);
if($CategoryName == "Music") {
$ArtistForm = get_request_artists($RequestID);
@ -174,8 +174,8 @@
$DB->query("SELECT UserID FROM requests_votes WHERE RequestID = ".$RequestID);
$UserIDs = $DB->to_array();
foreach ($UserIDs as $User) {
list($UserID) = $User;
send_pm($UserID, 0, db_string("The request '".$FullName."' has been filled"), db_string("One of your requests - [url=http://".NONSSL_SITE_URL."/requests.php?action=view&id=".$RequestID."]".$FullName."[/url] - has been filled. You can view it at [url]http://".NONSSL_SITE_URL."/torrents.php?torrentid=".$TorrentID), '');
list($VoterID) = $User;
send_pm($VoterID, 0, db_string("The request '".$FullName."' has been filled"), db_string("One of your requests - [url=http://".NONSSL_SITE_URL."/requests.php?action=view&id=".$RequestID."]".$FullName."[/url] - has been filled. You can view it at [url]http://".NONSSL_SITE_URL."/torrents.php?torrentid=".$TorrentID), '');
}
$RequestVotes = get_votes_array($RequestID);
@ -192,6 +192,7 @@
$Cache->delete_value('request_'.$RequestID);
$DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
$ArtistIDs = $DB->to_array();
foreach($ArtistIDs as $ArtistID) {

View File

@ -19,12 +19,13 @@
</tr>
<?
while ($row = $DB->next_record()) {
$amount = "&nbsp;";
$amount = false;
foreach ($Receiveds as $R) {
if ($R->address == $row['BitcoinAddress']) {
$amount = $R->amount . ' BTC';
}
}
if ($amount === false) { continue; }
?>
<tr>
<td><?=format_username($row['ID'],$row['Username'],$row['Donor'])?></td>

View File

@ -214,6 +214,10 @@
break;
case 'canariesv2':
include('data/canariesv2.php');
break;
case 'ip_ban':
//TODO: Clean up db table ip_bans.
include("managers/bans.php");

View File

@ -1,5 +1,7 @@
<?
if (!check_perms('users_mod') && empty($LoggedUser['CustomPermissions'])) { error(403); }
if (!check_perms('users_mod')) {
error(403);
}
show_header('Staff Tools');
?>
<div class="permissions">

View File

@ -334,7 +334,7 @@ function filelist($Str) {
//There was a type but it wasn't an option!
$ReportType = $Types['master']['other'];
}
$ReportInfo .= "<tr><td>".(check_perms('admin_reports') ? "<a href='user.php?id=$ReporterID'>$ReporterName</a> <a href='reportsv2.php?view=report&amp;id=$ReportID'>reported it</a> " : "Someone reported it ").strtolower(time_diff($ReportedTime))." for the reason '".$ReportType['title']."':";
$ReportInfo .= "<tr><td>".(check_perms('admin_reports') ? "<a href='user.php?id=$ReporterID'>$ReporterName</a> <a href='reportsv2.php?view=report&amp;id=$ReportID'>reported it</a> " : "Someone reported it ").time_diff($ReportedTime,2,true,true)." for the reason '".$ReportType['title']."':";
$ReportInfo .= "<blockquote>".$Text->full_format($ReportReason)."</blockquote></td></tr>";
}
$ReportInfo .= "</table>";
@ -616,7 +616,7 @@ function filelist($Str) {
<a href="#content<?=$PostID?>" onclick="LoadEdit('torrents', <?=$PostID?>, 1); return false;">&laquo;</a>
<? } ?>
Last edited by
<?=format_username($EditedUserID, $EditedUsername) ?> <?=strtolower(time_diff($EditedTime))?>
<?=format_username($EditedUserID, $EditedUsername) ?> <?=time_diff($EditedTime,2,true,true)?>
<? } ?>
</div>
</td>

View File

@ -145,7 +145,7 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
$Val->SetFields('ratio', '0', 'inarray', 'Invalid ratio field', $NumberChoices);
$Val->SetFields('uploaded', '0', 'inarray', 'Invalid uploaded field', $NumberChoices);
$Val->SetFields('downloaded', '0', 'inarray', 'Invalid downloaded field', $NumberChoices);
$Val->SetFields('snatched', '0', 'inarray', 'Invalid snatched field', $NumberChoices);
//$Val->SetFields('snatched', '0', 'inarray', 'Invalid snatched field', $NumberChoices);
$Val->SetFields('matchtype', '0', 'inarray', 'Invalid matchtype field', array('inarray'=>array('strict', 'fuzzy', 'regex')));
@ -194,9 +194,13 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
um1.ID,
um1.Username,
um1.Uploaded,
um1.Downloaded,
(SELECT COUNT(uid) FROM xbt_snatched AS xs WHERE xs.uid=um1.ID) AS Snatches,
um1.PermissionID,
um1.Downloaded,';
if ($_GET['snatched'] == "off") {
$SQL .= "'X' AS Snatches,";
} else {
$SQL .= "(SELECT COUNT(uid) FROM xbt_snatched AS xs WHERE xs.uid=um1.ID) AS Snatches,";
}
$SQL .= 'um1.PermissionID,
um1.Email,
um1.Enabled,
um1.IP,
@ -254,15 +258,24 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
}
if (!empty($_GET['cc'])) {
$Where[]="um1.ipcc = '".$_GET['cc']."'";
if ($_GET['cc_op'] == "equal") {
$Where[]="um1.ipcc = '".$_GET['cc']."'";
} else {
$Where[]="um1.ipcc != '".$_GET['cc']."'";
}
}
if(!empty($_GET['tracker_ip'])){
$Distinct = 'DISTINCT ';
$Join[]=' JOIN xbt_files_users AS xfu ON um1.ID=xfu.uid ';
$Where[]= ' (xfu.ipa '.$Match.wrap((int) ip2long($_GET['tracker_ip'])).' OR xfu.ip '.$Match.wrap($_GET['tracker_ip']).')';
$Where[]= ' xfu.ip '.$Match.wrap($_GET['tracker_ip']);
}
// if(!empty($_GET['tracker_ip'])){
// $Distinct = 'DISTINCT ';
// $Join[]=' JOIN xbt_snatched AS xs ON um1.ID=xs.uid ';
// $Where[]= ' xs.IP '.$Match.wrap($_GET['ip']);
// }
if(!empty($_GET['comment'])){
$Where[]='ui1.AdminComment'.$Match.wrap($_GET['comment']);
@ -553,6 +566,7 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
<option value="above"<? if(isset($_GET['snatched']) && $_GET['snatched']==='above'){echo ' selected="selected"';}?>>Above</option>
<option value="below"<? if(isset($_GET['snatched']) && $_GET['snatched']==='below'){echo ' selected="selected"';}?>>Below</option>
<option value="between"<? if(isset($_GET['snatched']) && $_GET['snatched']==='between'){echo ' selected="selected"';}?>>Between</option>
<option value="off"<? if(isset($_GET['snatched']) && $_GET['snatched']==='off'){echo ' selected="selected"';}?>>Off</option>
</select>
<input type="text" name="snatched1" size="6" value="<?=display_str($_GET['snatched1'])?>" />
<input type="text" name="snatched2" size="6" value="<?=display_str($_GET['snatched2'])?>" />
@ -603,7 +617,11 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
</select>
</td>
<td class="label nobr">Country Code:</td>
<td>
<td width="30%">
<select name="cc_op">
<option value="equal"<? if ($_GET['cc_op']==='equal'){ echo ' selected="selected"';}?>>Equals</option>
<option value="not_equal"<? if ($_GET['cc_op']==='not_equal'){ echo ' selected="selected"';}?>>Not Equal</option>
</select>
<input type="text" name="cc" size="2" value="<?=display_str($_GET['cc'])?>" />
</td>
</tr>
@ -692,7 +710,7 @@ function num_compare($Field, $Operand, $Num1, $Num2 = ''){
$DB->set_query_id($Results);
?>
<td><?=(int)$Downloads?></td>
<td><?=number_format($Snatched)?></td>
<td><?=is_numeric($Snatched) ? number_format($Snatched) : display_str($Snatched)?></td>
<td><? if($DisableInvites) { echo 'X'; } else { echo $Invites; } ?></td>
</tr>
<?

View File

@ -782,9 +782,82 @@ function check_paranoia_here($Setting) {
<?
}
}
include_once(SERVER_ROOT.'/sections/staff/functions.php');
$FLS = get_fls();
$IsFLS = false;
foreach($FLS as $F) {
if($LoggedUser['ID'] == $F['ID']) {
$IsFLS = true;
break;
}
}
if (check_perms('users_mod', $Class) || $IsFLS) {
$UserLevel = $LoggedUser['Class'];
$DB->query("SELECT
SQL_CALC_FOUND_ROWS
ID,
Subject,
Status,
Level,
AssignedToUser,
Date,
ResolverID
FROM staff_pm_conversations
WHERE UserID = $UserID AND (Level <= $UserLevel OR AssignedToUser='".$LoggedUser['ID']."')
ORDER BY Date DESC");
if ($DB->record_count()) {
$StaffPMs = $DB->to_array();
?>
<div class="box">
<div class="head">Staff PMs <a href="#" onclick="$('#staffpms').toggle();return false;">(View)</a></div>
<table width="100%" class="hidden" id="staffpms">
<tr class="colhead">
<td>Subject</td>
<td>Date</td>
<td>Assigned To</td>
<td>Resolved By</td>
</tr>
<? foreach($StaffPMs as $StaffPM) {
list($ID, $Subject, $Status, $Level, $AssignedTo, $Date, $ResolverID) = $StaffPM;
// Get assigned
if ($AssignedToUser == '') {
// Assigned to class
$Assigned = ($Level == 0) ? "First Line Support" : $ClassLevels[$Level]['Name'];
// No + on Sysops
if ($Assigned != 'Sysop') { $Assigned .= "+"; }
} else {
// Assigned to user
$UserInfo = user_info($AssignedToUser);
$Assigned = format_username($UserID, $UserInfo['Username'], $UserInfo['Donor'], $UserInfo['Warned'], $UserInfo['Enabled'], $UserInfo['PermissionID']);
}
if ($ResolverID) {
$UserInfo = user_info($ResolverID);
$Resolver = format_username($ResolverID, $UserInfo['Username'], $UserInfo['Donor'], $UserInfo['Warned'], $UserInfo['Enabled'], $UserInfo['PermissionID']);
} else {
$Resolver = "(unresolved)";
}
?>
<tr>
<td><a href="staffpm.php?action=viewconv&amp;id=<?=$ID?>"><?=display_str($Subject)?></a></td>
<td><?=time_diff($Date, 2, true)?></td>
<td><?=$Assigned?></td>
<td><?=$Resolver?></td>
</tr>
<? } ?>
</table>
</div>
<? }
}
?>
<br />
<? if (check_perms('users_mod', $Class)) { ?>
<?
if (check_perms('users_mod', $Class)) { ?>
<form id="form" action="user.php" method="post">
<input type="hidden" name="action" value="moderate" />
<input type="hidden" name="userid" value="<?=$UserID?>" />

View File

@ -309,7 +309,7 @@
<a href="#content<?=$PostID?>" onclick="LoadEdit(<?=$PostID?>, 1)">&laquo;</a>
<? } ?>
Last edited by
<?=format_username($EditedUserID, $EditedUsername) ?> <?=strtolower(time_diff($EditedTime))?>
<?=format_username($EditedUserID, $EditedUsername) ?> <?=time_diff($EditedTime,2,true,true)?>
<? } ?>
</div>
</td>