Added forum mod access to site reports system

Added to forum mods headers

Edit tag

[tex] class

[user profile] cosmetic fix

made autocomplete feature in artist search public

[front page] fixed the artwork of the current featured album

changed Drone message for blacklisted invites
This commit is contained in:
What.CD 2011-06-30 08:00:06 +00:00
parent 879ba11542
commit 3160f57862
9 changed files with 255 additions and 10 deletions

View File

@ -440,7 +440,7 @@ function to_html($Array) {
$Str.='<a href="wiki.php?action=article&amp;name='.urlencode($Block['Val']).'">'.$Block['Val'].'</a>';
break;
case 'tex':
$Str.='<img src="'.STATIC_SERVER.'blank.gif" onload="if (this.src.substr(this.src.length-9,this.src.length) == \'blank.gif\') { this.src = \'http://chart.apis.google.com/chart?cht=tx&amp;chf=bg,s,FFFFFF00&amp;chl='.urlencode(mb_convert_encoding($Block['Val'],"UTF-8","HTML-ENTITIES")).'&amp;chco=\' + hexify(getComputedStyle(this.parentNode,null).color); }" />';
$Str.='<img style="vertical-align: middle" src="'.STATIC_SERVER.'blank.gif" onload="if (this.src.substr(this.src.length-9,this.src.length) == \'blank.gif\') { this.src = \'http://chart.apis.google.com/chart?cht=tx&amp;chf=bg,s,FFFFFF00&amp;chl='.urlencode(mb_convert_encoding($Block['Val'],"UTF-8","HTML-ENTITIES")).'&amp;chco=\' + hexify(getComputedStyle(this.parentNode,null).color); }" />';
break;
case 'plain':
$Str.=$Block['Val'];

View File

@ -267,6 +267,17 @@
if ($NumUpdateReports > 0) {
$ModBar[] = '<a href="reports.php">'.'Request update reports'.'</a>';
}
} else if(check_perms('site_moderate_forums')) {
$NumForumReports = $Cache->get_value('num_forum_reports');
if ($NumForumReports === false) {
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status='New' AND Type IN('collages_comment', 'Post', 'requests_comment', 'thread', 'torrents_comment')");
list($NumForumReports) = $DB->next_record();
$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
}
if ($NumForumReports > 0) {
$ModBar[] = '<a href="reports.php">'.'Forum reports'.'</a>';
}
}
@ -346,7 +357,16 @@
<li id="searchbar_artists">
<span class="hidden">Artist: </span>
<form action="artist.php" method="get">
<script type="text/javascript" src="static/functions/autocomplete.js?v=<?=filemtime(SERVER_ROOT.'/static/functions/autocomplete.js')?>"></script>
<input id="artistsearch"
onkeyup="autocomp.keyup(event);"
onkeydown="autocomp.keydown(event);"
accesskey="a" spellcheck="false" autocomplete="off"
onfocus="if (this.value == 'Artists') this.value=''; autocomp.start('artist');"
onblur="if (this.value == '') this.value='Artists';"
value="Artists" type="text" name="artistname" size="17"
/>
<ul id="artistcomplete" style="visibility: hidden;"><li/></ul>
</form>
</li>
<li id="searchbar_requests">

View File

@ -0,0 +1,52 @@
<?
header('Content-type: application/x-suggestions+json');
require('classes/ajax_start.php');
if(empty($_GET['name'])) { die('["",[],[],[]]'); }
$MaxKeySize = 4;
if (strtolower(substr($_GET['name'],0,4)) == 'the ') {
$MaxKeySize += 4;
}
$KeySize = min($MaxKeySize,max(1,strlen($_GET['name'])));
$Letters = strtolower(substr($_GET['name'],0,$KeySize));
$AutoSuggest = $Cache->get('autocomplete_artist_'.$KeySize.'_'.$Letters);
if(!is_array($AutoSuggest)) {
if(!isset($DB) || !is_object($DB)) {
require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
}
$Limit = (($KeySize === $MaxKeySize)?250:10);
$DB->query("SELECT
a.ArtistID,
a.Name,
SUM(t.Snatched) AS Snatches
FROM artists_group AS a
INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID
INNER JOIN torrents AS t ON t.GroupID=ta.GroupID
WHERE a.Name LIKE '$Letters%'
GROUP BY ta.ArtistID
ORDER BY Snatches DESC
LIMIT $Limit");
$AutoSuggest = $DB->to_array(false,MYSQLI_NUM,false);
$Cache->cache_value('autocomplete_artist_'.$KeySize.'_'.$Letters,$AutoSuggest,1800+7200*($MaxKeySize-$KeySize)); // Can't cache things for too long in case names are edited
}
$Matched = 0;
$Suggestions = array();
$Snatches = array();
$Links = array();
foreach ($AutoSuggest as $Suggestion) {
list($ID,$Name, $Snatch) = $Suggestion;
if (stripos($Name,$_GET['name']) === 0) {
$Suggestions[] = display_str($Name);
$Snatches[] = number_format($Snatch).' snatches';
$Links[] = 'http'.($SSL?'s':'').'://'.$_SERVER['HTTP_HOST'].'/artist.php?id='.$ID;
if (++$Matched > 9) {
break;
}
}
}
echo json_encode(array($_GET['name'],$Suggestions,$Snatches,$Links));

View File

@ -33,6 +33,7 @@
if($FeaturedAlbum === false) {
$DB->query("SELECT fa.GroupID, tg.Name, tg.WikiImage, fa.ThreadID, fa.Title FROM featured_albums AS fa JOIN torrents_group AS tg ON tg.ID=fa.GroupID WHERE Ended = 0");
$FeaturedAlbum = $DB->next_record();
$FeaturedAlbum['WikiImage'] = 'http://i53.tinypic.com/if7sqr.png';
$Cache->cache_value('featured_album', $FeaturedAlbum, 0);
}
if(is_number($FeaturedAlbum['GroupID'])) {

View File

@ -2,7 +2,7 @@
/************************************************************************
************************************************************************/
if(!check_perms('admin_reports') && !check_perms('project_team')) {
if(!check_perms('admin_reports') && !check_perms('project_team') && !check_perms('site_moderate_forums')) {
error(404);
}
@ -37,7 +37,13 @@
}
if(!check_perms('admin_reports')) {
$Where .= " AND Type = 'request_update'";
if(check_perms('project_team')) {
$Where .= " AND Type = 'request_update'";
}
if(check_perms('site_moderate_forums')) {
$Where .= " AND Type IN('collages_comment', 'Post', 'requests_comment', 'thread', 'torrents_comment')";
}
}
$Reports = $DB->query("SELECT SQL_CALC_FOUND_ROWS

View File

@ -72,12 +72,15 @@
(".db_string($LoggedUser['ID']).", ".$ID." , '".$Short."', '".sqltime()."', '".db_string($Reason)."')");
$ReportID = $DB->inserted_id();
$Channels = array("#forumreports");
$Channels = array();
if($Short == "request_update") {
$Channels[] = "#requestedits";
$Cache->increment('num_update_reports');
}
if(in_array($Short, array('collages_comment', 'Post', 'requests_comment', 'thread', 'torrents_comment'))) {
$Channels[] = "#forumreports";
}
foreach($Channels as $Channel) {
send_irc("PRIVMSG ".$Channel." :".$ReportID." - ".$LoggedUser['Username']." just reported a ".$Short.": http://".NONSSL_SITE_URL."/".$Link." : ".$Reason);

View File

@ -1,7 +1,7 @@
<?
authorize();
if(!check_perms('admin_reports') && !check_perms('project_team')) {
if(!check_perms('admin_reports') && !check_perms('project_team') && !check_perms('site_moderate_forums')) {
error(403);
}
@ -14,8 +14,14 @@
$DB->query("SELECT Type FROM reports WHERE ID = ".$ReportID);
list($Type) = $DB->next_record();
if(!check_perms('admin_reports')) {
if($Type != "request_update") {
error(403);
if(check_perms('site_moderate_forums')) {
if(!in_array($Type, array('collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment'))) {
error($Type);
}
} else if(check_perms('project_team')) {
if($Type != "request_update") {
error(403);
}
}
}
@ -25,12 +31,20 @@
ResolverID='".$LoggedUser['ID']."'
WHERE ID='".db_string($ReportID)."'");
$Channels = array("#forumreports");
$Channels = array();
if($Type == "request_update") {
$Channels[] = "#requestedits";
$Cache->decrement('num_update_reports');
}
if(in_array($Type, array('collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment'))) {
$Channels[] = "#forumreports";
$Cache->decrement('num_forum_reports');
}
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'");
list($Remaining) = $DB->next_record();

View File

@ -43,7 +43,7 @@ function paranoia_level($Setting) {
function display_paranoia($FieldName) {
$Level = paranoia_level($FieldName);
print '<label><input type="checkbox" name="p_'.$FieldName.'_c" '.checked($Level >= 1).' onChange="AlterParanoia()" /> Show count</label>&nbsp;&nbsp;';
print '<label><input type="checkbox" name="p_'.$FieldName.'_c" '.checked($Level >= 1).' onChange="AlterParanoia()" /> Show count</label>'."&nbsp;&nbsp;\n";
print '<label><input type="checkbox" name="p_'.$FieldName.'_l" '.checked($Level >= 2).' onChange="AlterParanoia()" /> Show list</label>';
}

View File

@ -0,0 +1,149 @@
/*
Spent hours debugging opera, turns out they reserve the global variable autocomplete. Bitches.
*/
"use strict";
var autocomp = {
id: "",
value: "",
href: null,
timer: null,
input: null,
list: null,
pos: -1,
cache: [],
start: function (id) {
this.id = id;
this.cache[id] = ["",[],[],[]];
this.input = document.getElementById(id + "search");
this.list = document.getElementById(id + "complete");
listener.set(document.body,'click',function(){
autocomp.value = autocomp.input.value;
autocomp.end();
});
},
end: function () {
//this.input.value = this.value;
this.href = null;
this.highlight(-1);
this.list.style.visibility = 'hidden';
clearTimeout(this.timer);
},
keyup: function (e) {
clearTimeout(this.timer);
var key = (window.event)?window.event.keyCode:e.keyCode;
switch (key) {
case 27: //esc
break;
case 8: //backspace
this.href = null;
this.list.style.visibility = 'hidden';
this.timer = setTimeout("autocomp.get('" + this.input.value + "');",500);
break;
case 38: //up
case 40: //down
this.highlight(key);
this.href = this.list.children[this.pos].href;
this.input.value = this.list.children[this.pos].textContent || this.list.children[this.pos].innerText;
break;
case 13:
if(this.href != null) {
window.location = this.href;
}
return 0;
default:
this.href = null;
this.timer = setTimeout("autocomp.get('"+this.input.value+"');",300);
return 1;
}
return 0;
},
keydown: function (e) {
switch ((window.event)?window.event.keyCode:e.keyCode) {
case 9: //tab
this.value = this.input.value;
case 27: //esc
this.end();
break;
case 38:
e.preventDefault();
break;
case 13: //enter
return 0;
}
return 1;
},
highlight: function(change) {
//No highlights on no list
if (this.list.children.length === 0) {
return;
}
//Show me the
this.list.style.visibility = 'visible';
//Remove the previous highlight
if (this.pos !== -1) {
this.list.children[this.pos].className = "";
}
//Change position
if (change === 40) {
++this.pos;
} else if (change === 38) {
--this.pos;
} else {
this.pos = change;
}
//Wrap arounds
if (this.pos >= this.list.children.length) {
this.pos = -1;
} else if (this.pos < -1) {
this.pos = this.list.children.length-1;
}
if (this.pos !== -1) {
this.list.children[this.pos].className = "highlight";
} else {
this.href = null;
this.input.value = this.value;
}
},
get: function (value) {
this.pos = -1;
this.value = value;
if (typeof this.cache[this.id+value] === 'object') {
this.display(this.cache[this.id+value]);
return;
}
ajax.get(this.id+'.php?action=autocomplete&name='+this.input.value,function(jstr){
var data = json.decode(jstr);
autocomp.cache[autocomp.id+data[0]] = data;
autocomp.display(data);
});
},
display: function (data) {
var i,il,li;
this.list.innerHTML = '';
for (i=0,il=data[1].length;i<il;++i) {
li = document.createElement('li');
li.innerHTML = data[1][i];
li.i = i;
li.href = data[3][i];
listener.set(li,'mouseover',function(){
autocomp.highlight(this.i);
});
listener.set(li,'click',function(){
window.location = this.href;
});
this.list.appendChild(li);
}
if (i > 0) {
this.list.style.visibility = 'visible';
} else {
this.list.style.visibility = 'hidden';
}
}
};