Empty commit

This commit is contained in:
Git 2013-03-02 08:00:34 +00:00
parent fbb107f586
commit 83ec73f18f
19 changed files with 490 additions and 68 deletions

View File

@ -206,6 +206,7 @@ function music_form($GenreTags) {
<option value="5"<?=($Importance == '5' ? ' selected="selected"' : '')?>>Conductor</option>
<option value="6"<?=($Importance == '6' ? ' selected="selected"' : '')?>>DJ / Compiler</option>
<option value="3"<?=($Importance == '3' ? ' selected="selected"' : '')?>>Remixer</option>
<option value="7"<?=($Importance == '7' ? ' selected="selected"' : '')?>>Producer</option>
</select>
<? if ($FirstArtist) {
if (!$this->DisabledFlag) { ?>

View File

@ -223,7 +223,7 @@
$Cache->cache_value('news_latest_id', $CurrentNews, 0);
}
if ($MyNews < $CurrentNews) {
$Alerts[] = '<a href="index.php">'.'New Announcement!'.'</a>';
$Alerts[] = '<a href="index.php">'.'New announcement!'.'</a>';
}
// Blog
@ -239,7 +239,7 @@
$Cache->cache_value('blog_latest_id', $CurrentBlog, 0);
}
if ($MyBlog < $CurrentBlog) {
$Alerts[] = '<a href="blog.php">'.'New Blog Post!'.'</a>';
$Alerts[] = '<a href="blog.php">'.'New blog post!'.'</a>';
}
// Staff blog
@ -264,7 +264,7 @@
$Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600);
}
if ($SBlogReadTime < $LatestSBlogTime) {
$Alerts[] = '<a href="staffblog.php">'.'New Staff Blog Post!'.'</a>';
$Alerts[] = '<a href="staffblog.php">'.'New staff blog post!'.'</a>';
}
}
@ -370,7 +370,7 @@
}
if ($NumOtherReports > 0) {
$ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports == 1) ? ' Other Report' : ' Other Reports').'</a>';
$ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports == 1) ? ' Other report' : ' Other reports').'</a>';
}
} else if(check_perms('project_team')) {
$NumUpdateReports = $Cache->get_value('num_update_reports');

250
docs/CodingStandards.txt Normal file
View File

@ -0,0 +1,250 @@
This document contains the coding standards for Gazelle.
This document is a work-in-progress and is subject to change.
NOTE: The standards defined in this document will likely differ from
what is actually seen in the Gazelle code. This document is the first
step in properly enforcing coding standards throughout the project.
== TABLE OF CONTENTS ==
1. FILE FORMATTING
2. CODE STYLING
2.1 Code styling for PHP and JavaScript
2.2 Code styling for CSS
2.3 Code styling for SQL
3. NAMING CONVENTIONS
3.1 Function names
3.2 Variable names
3.3 Class names
3.4 SQL names
3.5 Miscellaneous names
4. COMMENTS
5. USER INTERFACE
6. EXAMPLES
6.1 PHP examples
6.2 CSS examples
6.3 SQL examples
1. FILE FORMATTING
Tabs shall always be used for indentation. Do not use spaces to make code
blocks align in a pretty fashion.
Files shall be encoded in ASCII.
Files shall always use Unix-style line endings (LF). The program dos2unix
will take care of this for you if you have files that use Windows-style
line endings (CR+LF) or old Mac-style line endings (CR).
File names for PHP, CSS, and JavaScript files shall be all lowercase and
use underscores instead of spaces.
2. CODE STYLING
2.1 Code styling for PHP and JavaScript
All statement blocks, including functions, shall have the opening brace
at the end of the same line with a space before the brace. The astute
reader will note that this is K&R style with the exception of functions.
There shall be a space between a control structure statement (e.g. if,
elseif, for) and the following parenthesis.
There shall be a space around conditional operators.
When using ternary operators, spaces shall be used around the operators.
For conditional blocks, "elseif" is to be used instead of "else if".
In loops and conditional blocks, there shall be braces even if there is
only one statement.
In loops and conditional blocks, the statement(s) shall be placed on the
following lines.
When opening a PHP statement, "<?" shall be used instead of "<?php".
Switch cases in index files shall not contain substantial code. The use
of include statements is acceptable.
When building strings in PHP, single quotes shall be used when not
printing a variable.
When declaring JavaScript variables, "var" shall always be used.
2.2 Code styling for CSS
"property: value;" pairs shall be separated by a space, and the value
shall be followed by a semi-colon.
Multiple, related CSS selectors with the same declarations shall appear
on multiple lines to improve readability.
The opening brace shall be on the same line as the last related
selector with a space between the selector and the brace.
2.3 Code styling for SQL
Long SQL queries shall be separated on multiple lines.
Short SQL queries may be on a single line.
The primary SQL keywords should be at the same indentation level unless
part of a JOIN or other complex statement.
Use indents as appropriate to aid readability.
The SQL keywords JOIN, RIGHT JOIN, LEFT JOIN must be indented once from
the SELECT statement.
3. NAMING CONVENTIONS
Function, variable, and class names shall always be descriptive.
3.1 Function names
PHP function names shall be written in lowercase_with_underscores.
JavaScript function names shall be written in camelCase with a leading
lowercase letter.
3.2 Variable names
PHP variable names shall be written in CamelCase with a leading
uppercase letter.
JavaScript global-scope variables shall be written in camelCase with a
leading lowercase letter.
JavaScript local-scope variables shall be written in
lowercase_with_underscores.
3.3 Class names
PHP class names shall be written in CamelCase with a leading uppercase
letter.
PHP class constants shall be written in CamelCase with a leading
uppercase letter.
3.4 SQL names
All SQL keywords shall be written in all UPPERCASE.
All SQL table names shall be written in lowercase_with_underscores.
All SQL column names shall be written in CamelCase with a leading
uppercase letter.
All automatically-incremented ID columns shall be named "ID", while the
other columns for ID numbers shall have names like RequestID, TorrentID,
etc.
3.5 Miscellaneous names
PHP global constants shall be written in ALL_CAPS.
PHP constants true, false, and null shall be written in all lowercase.
4. COMMENTS
Use C89-style "/* ... */" comments for multi-line comments.
Use C99-style "// ..." comments for single-line comments.
5. USER INTERFACE
All buttons shall use sentence case.
All table headings shall use sentence case.
All text-based buttons shall use the "brackets" CSS class
6. EXAMPLES
6.1 PHP examples
if ($Foo >= 0) {
$SomeString = "this is a string $DiffString with more text";
} elseif ($Foo == 0) {
// other things happen
} else {
// more magic
}
function works_magic($Foo, $Bar) {
return $Foo;
}
echo ($Foo == true ? 'foo is true' : 'foo is false');
if ($Foo == true) {
// magic happens
}
/*
* This is a good, multi-line comment.
*
* Please comment your code!
*/
// This is a good, single-line comment.
6.2 CSS examples
<a href="foobar.php" style="font-weight: bold;">link text</a>
.spellcheck {
margin: 10px 0;
font-size: 1.25em;
font-weight: bold;
}
.linkbox .brackets:before,
.linkbox .brackets:after,
.top10_quantity_links .brackets:before,
.top10_quantity_links .brackets:after {
color: #757575;
}
6.3 SQL examples
SELECT
r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber,
l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID
FROM releases AS r
JOIN editions AS e ON e.ReleaseID = r.ID
LEFT JOIN labels AS l ON l.ID = r.LabelID
WHERE r.ID IN ($ReleaseIDsSQL)
ORDER BY e.EditionID, r.Year ASC
SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky,
cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date
FROM pm_conversations AS c
LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID
AND cu.UserID='1'
LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID
AND cu2.UserID!='1'
AND cu2.ForwardedTo=0
LEFT JOIN users_main AS um ON um.ID=cu2.UserID
WHERE um.Username LIKE 'test'
AND cu.InInbox='1'
GROUP BY c.ID
ORDER BY cu.Sticky, Date DESC
LIMIT 25
SELECT RequestID AS ID, UserID FROM bookmarks_requests
EOF

View File

@ -81,8 +81,8 @@
</colgroup>
<tr class="colhead_dark">
<td colspan="<?=Users::has_avatars_enabled() ? 2 : 1?>">
<span style="float:left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a>
by <?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?> <a href="reports.php?action=report&amp;type=collages_comment&amp;id=<?=$PostID?>" class="brackets">Report Comment</a>
<span style="float: left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a>
by <?=Users::format_username($AuthorID, true, true, true, true, true)?> <?=time_diff($AddedTime)?> <a href="reports.php?action=report&amp;type=collages_comment&amp;id=<?=$PostID?>" class="brackets">Report comment</a>
<? if (!$ThreadInfo['IsLocked']){ ?> - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');" class="brackets">Quote</a><? }
if ($AuthorID == $LoggedUser['ID'] || check_perms('site_moderate_forums')){ ?> - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>');" class="brackets">Edit</a><? }
if (check_perms('site_moderate_forums')){ ?> - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a> <? } ?>

View File

@ -173,15 +173,15 @@
<td class="label">Tags (comma-separated):</td>
<td>
<input type="text" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>" />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0" <?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1" <?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
</td>
</tr>
<tr id="categories">
<td class="label">Categories:</td>
<td>
<? foreach($CollageCats as $ID=>$Cat) { ?>
<input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>" <?if(in_array($ID, $Categories)) { echo ' checked="checked"'; }?>>
<input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>"<?if(in_array($ID, $Categories)) { echo ' checked="checked"'; }?> />
<label for="cats_<?=$ID?>"><?=$Cat?></label>&nbsp;&nbsp;
<? } ?>
</td>
@ -197,15 +197,14 @@
<td class="label">Order by:</td>
<td>
<select name="order_by" class="ft_order_by">
<?
foreach($OrderVals as $Cur){ ?>
<? foreach($OrderVals as $Cur){ ?>
<option value="<?=$Cur?>"<? if(isset($_GET['order_by']) && $_GET['order_by'] == $Cur || (!isset($_GET['order_by']) && $Cur == 'Time')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? }?>
<? } ?>
</select>
<select name="order_way" class="ft_order_way">
<? foreach($WayVals as $Cur){ ?>
<? foreach($WayVals as $Cur){ ?>
<option value="<?=$Cur?>"<? if(isset($_GET['order_way']) && $_GET['order_way'] == $Cur || (!isset($_GET['order_way']) && $Cur == 'Descending')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
<? }?>
<? } ?>
</select>
</td>
</tr>
@ -293,7 +292,7 @@
//Print results
?>
<tr class="row<?=$Row?> <?=($BookmarkView)?'bookmark_'.$ID:''?>">
<tr class="row<?=$Row?><?=($BookmarkView) ? ' bookmark_'.$ID : ''?>">
<td>
<a href="collages.php?action=search&amp;cats[<?=(int)$CategoryID?>]=1"><?=$CollageCats[(int)$CategoryID]?></a>
</td>
@ -306,7 +305,7 @@
<? } ?>
<div class="tags"><?=$TorrentTags->format('collages.php?action=search&amp;tags=')?></div>
</td>
<td><?=(int)$NumTorrents?></td>
<td><?=number_format((int)$NumTorrents)?></td>
<td><?=Users::format_username($UserID, false, false, false)?></td>
</tr>
<? } ?>

View File

@ -158,7 +158,7 @@ function compare($X, $Y){
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
<td class="center">
<div title="View" id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group"></a>
<a href="#" class="show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collapse all groups on this page."></a>
</div>
</td>
<td class="center">
@ -312,7 +312,7 @@ function compare($X, $Y){
?>
<img src="<?=ImageTools::thumbnail($WikiImage)?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?>" width="118" />
<? } else { ?>
<span style="width:107px;padding:5px"><?=$DisplayName?></span>
<span style="width: 107px; padding: 5px;"><?=$DisplayName?></span>
<? } ?>
</a>
</li>
@ -409,7 +409,7 @@ function compare($X, $Y){
<ul id="list" class="nobullet">
<? foreach ($ZIPList as $ListItem) { ?>
<li id="list<?=$ListItem?>">
<input type="hidden" name="list[]" value="<?=$ListItem?>" />
<input type="hidden" name="list[]" value="<?=$ListItem?>" />
<span class="float_left"><?=$ZIPOptions[$ListItem]['2']?></span>
<span class="remove remove_collector"><a href="#" onclick="remove_selection('<?=$ListItem?>');return false;" class="float_right brackets">X</a></span>
<br style="clear:all;" />
@ -453,11 +453,11 @@ function compare($X, $Y){
<div class="box box_info box_statistics_collage_torrents">
<div class="head"><strong>Stats</strong></div>
<ul class="stats nobullet">
<li>Torrents: <?=$NumGroups?></li>
<li>Torrents: <?=number_format($NumGroups)?></li>
<? if(!empty($TopArtists)) { ?>
<li>Artists: <?=count($TopArtists)?></li>
<li>Artists: <?=number_format(count($TopArtists))?></li>
<? } ?>
<li>Built by <?=count($Users)?> user<?=(count($Users)>1) ? 's' : ''?></li>
<li>Built by <?=number_format(count($Users))?> user<?=(count($Users) > 1 ? 's' : '')?></li>
</ul>
</div>
<div class="box box_tags">
@ -482,7 +482,7 @@ function compare($X, $Y){
$i++;
if($i>10) { break; }
?>
<li><a href="artist.php?id=<?=$ID?>"><?=$Artist['name']?></a> (<?=$Artist['count']?>)</li>
<li><a href="artist.php?id=<?=$ID?>"><?=$Artist['name']?></a> (<?=number_format($Artist['count'])?>)</li>
<?
}
?>
@ -501,7 +501,7 @@ function compare($X, $Y){
$i++;
if($i>5) { break; }
?>
<li><?=Users::format_username($ID, false, false, false)?> (<?=$User['count']?>)</li>
<li><?=Users::format_username($ID, false, false, false)?> (<?=number_format($User['count'])?>)</li>
<?
}
?>
@ -555,7 +555,7 @@ function compare($X, $Y){
list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment;
?>
<div class="box comment">
<div class="head">By <?=Users::format_username($UserID, false, false, false) ?> <?=time_diff($CommentTime) ?> <a href="reports.php?action=report&amp;type=collages_comment&amp;id=<?=$CommentID?>" class="brackets">Report Comment</a></div>
<div class="head">By <?=Users::format_username($UserID, false, false, false) ?> <?=time_diff($CommentTime) ?> <a href="reports.php?action=report&amp;type=collages_comment&amp;id=<?=$CommentID?>" class="brackets">Report comment</a></div>
<div class="pad"><?=$Text->full_format($Body)?></div>
</div>
<?

View File

@ -74,7 +74,7 @@
<? if(check_forumperm($ForumID, 'Write') && check_forumperm($ForumID, 'Create')){ ?>
<a href="forums.php?action=new&amp;forumid=<?=$ForumID?>" class="brackets">New thread</a>
<? } ?>
<a href="#" onclick="$('#searchforum').toggle(); this.innerHTML = (this.innerHTML == 'Search this Forum'?'Hide Search':'Search this Forum'); return false;" class="brackets">Search this forum</a>
<a href="#" onclick="$('#searchforum').toggle(); this.innerHTML = (this.innerHTML == 'Search this forum'?'Hide search':'Search this forum'); return false;" class="brackets">Search this forum</a>
<div id="searchforum" class="hidden center">
<div style="display: inline-block;">
<h3>Search this forum:</h3>

View File

@ -27,17 +27,17 @@
<div class="hidden" id="newthreadpreview">
<div class="linkbox">
<div class="center">
<a href="#" onclick="return false;" class="brackets">Report Thread</a>
<a href="#" onclick="return false;" class="brackets">Report thread</a>
<a href="#" onclick="return false;" class="brackets"><?=!empty($HeavyInfo['AutoSubscribe']) ? 'Unsubscribe' : 'Subscribe'?></a>
</div>
</div>
<? if (check_perms('forums_polls_create')) { ?>
<div class="box thin clear hidden" id="pollpreview">
<div class="head colhead_dark"><strong>Poll</strong> <a href="#" onclick="$('#threadpoll').toggle();return false;">(View)</a></div>
<div class="head colhead_dark"><strong>Poll</strong> <a href="#" onclick="$('#threadpoll').toggle();return false;" class="brackets">View</a></div>
<div class="pad" id="threadpoll">
<p><strong id="pollquestion"></strong></p>
<div id="pollanswers"></div>
<br /><input type="radio" name="vote" id="answer_0" value="0" /> <label for="answer_0">Blank - Show the results!</label><br /><br />
<br /><input type="radio" name="vote" id="answer_0" value="0" /> <label for="answer_0">Blank &mdash; show the results!</label><br /><br />
<input type="button" style="float: left;" value="Vote" />
</div>
</div>
@ -55,7 +55,7 @@
by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true, true)?></strong>
Just now
</span>
<span id="barpreview" style="float:right;">
<span id="barpreview" style="float: right;">
<a href="#newthreadpreview" class="brackets">Report</a>
&nbsp;
<a href="#">&uarr;</a>
@ -71,7 +71,7 @@
<? } ?>
</td>
<td class="body" valign="top">
<div id="contentpreview" style="text-align:left;"></div>
<div id="contentpreview" style="text-align: left;"></div>
</td>
</tr>
</table>
@ -93,7 +93,7 @@
<tr>
<td></td>
<td>
<input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe'])?' checked="checked"':''?> onchange="$('#subscribeboxpreview').raw().checked=this.checked;" />
<input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?> onchange="$('#subscribeboxpreview').raw().checked=this.checked;" />
<label for="subscribebox">Subscribe to topic</label>
</td>
</tr>
@ -129,7 +129,7 @@ function RemoveAnswerField() {
<tr>
<td colspan="2" class="center">
<strong>Poll Settings</strong>
<a href="#" onclick="$('#poll_question, #poll_answers').toggle();return false;">(View)</a>
<a href="#" onclick="$('#poll_question, #poll_answers').toggle();return false;" class="brackets">View</a>
</td>
</tr>
<tr id="poll_question" class="hidden">

View File

@ -161,9 +161,9 @@
</h2>
<div class="linkbox">
<div class="center">
<a href="reports.php?action=report&amp;type=thread&amp;id=<?=$ThreadID?>" class="brackets">Report Thread</a>
<a href="reports.php?action=report&amp;type=thread&amp;id=<?=$ThreadID?>" class="brackets">Report thread</a>
<a href="#" onclick="Subscribe(<?=$ThreadID?>);return false;" id="subscribelink<?=$ThreadID?>" class="brackets"><?=(in_array($ThreadID, $UserSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
<a href="#" onclick="$('#searchthread').toggle(); this.innerHTML = (this.innerHTML == 'Search this Thread'?'Hide Search':'Search this Thread'); return false;" class="brackets">Search this Thread</a>
<a href="#" onclick="$('#searchthread').toggle(); this.innerHTML = (this.innerHTML == 'Search this thread'?'Hide search':'Search this thread'); return false;" class="brackets">Search this thread</a>
</div>
<div id="searchthread" class="hidden center">
<div style="display: inline-block;">
@ -240,7 +240,7 @@
?>
<div class="box thin clear">
<div class="head colhead_dark"><strong>Poll<? if ($Closed) { echo ' [Closed]'; } ?><? if ($Featured && $Featured !== '0000-00-00 00:00:00') { echo ' [Featured]'; } ?></strong> <a href="#" onclick="$('#threadpoll').toggle();log_hit();return false;">(View)</a></div>
<div class="head colhead_dark"><strong>Poll<? if ($Closed) { echo ' [Closed]'; } ?><? if ($Featured && $Featured !== '0000-00-00 00:00:00') { echo ' [Featured]'; } ?></strong> <a href="#" onclick="$('#threadpoll').toggle();log_hit();return false;" class="brackets">View</a></div>
<div class="pad<? if (/*$LastRead !== null || */$ThreadInfo['IsLocked']) { echo ' hidden'; } ?>" id="threadpoll">
<p><strong><?=display_str($Question)?></strong></p>
<? if ($UserResponse !== null || $Closed || $ThreadInfo['IsLocked'] || !check_forumperm($ForumID)) { ?>

View File

@ -361,8 +361,8 @@
?>
<div class="box" id="recommended">
<div class="head colhead_dark">
<strong>Latest vanity house additions</strong>
<a href="#" onclick="$('#vanityhouse').toggle(); this.innerHTML=(this.innerHTML=='(Hide)'?'(Show)':'(Hide)'); return false;">(Show)</a>
<strong>Latest Vanity House additions</strong>
<a href="#" onclick="$('#vanityhouse').toggle(); this.innerHTML=(this.innerHTML=='Hide'?'Show':'Hide'); return false;" class="brackets">Show</a>
</div>
<table class="torrent_table hidden" id="vanityhouse">
@ -420,7 +420,7 @@
?>
<div id="more_news" class="box">
<div class="head">
<em>For older news posts, <a href="forums.php?action=viewforum&amp;forumid=19">click here</a></em>
<em>For older news posts, <a href="forums.php?action=viewforum&amp;forumid=19">click here</a>.</em>
</div>
</div>
</div>

View File

@ -13,8 +13,9 @@
<h2>Search</h2>
<? include('header.php'); ?>
</div>
<br />
On hold until FZeroX fixes the main torrents search; then I will steal all his work and claim it as my own.
<div class="thin box pad">
On hold until someone fixes the main torrents search.
</div>
<?
View::show_footer();
?>

View File

@ -13,10 +13,10 @@
<? } if (check_perms('admin_whitelist')) { ?>
<tr><td><a href="tools.php?action=whitelist">Whitelist</a></td></tr>
<? } if (check_perms('admin_manage_ipbans')) { ?>
<tr><td><a href="tools.php?action=ip_ban">IP Bans</a></td></tr>
<tr><td><a href="tools.php?action=ip_ban">IP address bans</a></td></tr>
<? } if (check_perms('users_view_ips')) { ?>
<tr><td><a href="tools.php?action=login_watch">Login Watch</a></td></tr>
<tr><td><a href="tools.php?action=login_watch">Login watch</a></td></tr>
<? } if (check_perms('admin_manage_forums')) { ?>
<tr><td><a href="tools.php?action=forum">Forums</a></td></tr>
<? } if (check_perms('admin_manage_news')) { ?>
@ -27,11 +27,11 @@
<tr><td><a href="tools.php?action=recommend">Vanity House additions</a></td></tr>
<? } if (check_perms('users_view_email')) { ?>
<tr><td><a href="tools.php?action=email_blacklist">Email Blacklist</a></td></tr>
<tr><td><a href="tools.php?action=email_blacklist">Email blacklist</a></td></tr>
<? } if (check_perms('users_mod')) { ?>
<tr><td><a href="tools.php?action=tokens">Manage freeleech tokens</a></td></tr>
<tr><td><a href="tools.php?action=official_tags">Official Tags Manager</a></td></tr>
<tr><td><a href="tools.php?action=tag_aliases">Tag Aliases</a></td></tr>
<tr><td><a href="tools.php?action=official_tags">Official tags manager</a></td></tr>
<tr><td><a href="tools.php?action=tag_aliases">Tag aliases</a></td></tr>
<? } ?>
@ -43,23 +43,23 @@
<?
if (check_perms('admin_donor_log')) { ?>
<tr><td><a href="tools.php?action=donation_log">Donation Log</a></td></tr>
<tr><td><a href="tools.php?action=donation_log">Donation log</a></td></tr>
<tr><td><a href="tools.php?action=bitcoin_balance">Bitcoin donation balance</a></td></tr>
<? } if (check_perms('users_view_ips') && check_perms('users_view_email')) { ?>
<tr><td><a href="tools.php?action=registration_log">Registration Log</a></td></tr>
<tr><td><a href="tools.php?action=registration_log">Registration log</a></td></tr>
<? } if (check_perms('users_view_invites')) { ?>
<tr><td><a href="tools.php?action=invite_pool">Invite Pool</a></td></tr>
<tr><td><a href="tools.php?action=invite_pool">Invite pool</a></td></tr>
<? } if (check_perms('site_view_flow')) { ?>
<tr><td><a href="tools.php?action=upscale_pool">Upscale Pool</a></td></tr>
<tr><td><a href="tools.php?action=user_flow">User Flow</a></td></tr>
<tr><td><a href="tools.php?action=torrent_stats">Torrent Stats</a></td></tr>
<tr><td><a href="tools.php?action=economic_stats">Economic Stats</a></td></tr>
<tr><td><a href="tools.php?action=upscale_pool">Upscale pool</a></td></tr>
<tr><td><a href="tools.php?action=user_flow">User flow</a></td></tr>
<tr><td><a href="tools.php?action=torrent_stats">Torrent stats</a></td></tr>
<tr><td><a href="tools.php?action=economic_stats">Economic stats</a></td></tr>
<? } if (check_perms('site_debug')) { ?>
<tr><td><a href="tools.php?action=opcode_stats">Opcode Stats</a></td></tr>
<tr><td><a href="tools.php?action=service_stats">Service Stats</a></td></tr>
<tr><td><a href="tools.php?action=opcode_stats">Opcode stats</a></td></tr>
<tr><td><a href="tools.php?action=service_stats">Service stats</a></td></tr>
<? } if (check_perms('admin_manage_permissions')) { ?>
<tr><td><a href="tools.php?action=special_users">Special Users</a></td></tr>
<tr><td><a href="tools.php?action=special_users">Special users</a></td></tr>
<? } ?>
</table>
@ -69,16 +69,16 @@
<tr class="colhead"><td>Misc</td></tr>
<? if (check_perms('users_mod')) { ?>
<tr><td><a href="tools.php?action=manipulate_tree">Manipulate Tree</a></td></tr>
<tr><td><a href="tools.php?action=manipulate_tree">Manipulate tree</a></td></tr>
<? }
if (check_perms('admin_update_geoip')) { ?>
<tr><td><a href="tools.php?action=update_geoip">Update GeoIP </a></td></tr>
<? } if (check_perms('admin_create_users')) { ?>
<tr><td><a href="tools.php?action=create_user">Create User</a></td></tr>
<tr><td><a href="tools.php?action=create_user">Create user</a></td></tr>
<? } if (check_perms('admin_clear_cache')) { ?>
<tr><td><a href="tools.php?action=clear_cache">Clear/view a cache key</a></td></tr>
<? } if (check_perms('users_view_ips')) { ?>
<tr><td><a href="tools.php?action=dupe_ips">Duplicate IPs</a></td></tr>
<tr><td><a href="tools.php?action=dupe_ips">Duplicate IP addresses</a></td></tr>
<? } if (check_perms('site_debug')) { ?>
<tr><td><a href="tools.php?action=sandbox1">Sandbox (1)</a></td></tr>
@ -92,9 +92,9 @@
<tr><td><a href="schedule.php?auth=<?=$LoggedUser['AuthKey']?>">Schedule</a></td></tr>
<? }?>
<tr><td><strong><a href="tools.php?action=public_sandbox">Public Sandbox</a></strong></td></tr>
<tr><td><strong><a href="tools.php?action=public_sandbox">Public sandbox</a></strong></td></tr>
<? if (check_perms('users_mod')) { ?>
<tr><td><strong><a href="tools.php?action=mod_sandbox">Mod level Sandbox</a></strong></td></tr>
<tr><td><strong><a href="tools.php?action=mod_sandbox">Mod-level sandbox</a></strong></td></tr>
<? } ?>
</table>
</div>

View File

@ -10,7 +10,9 @@
require(SERVER_ROOT.'/classes/class_torrent_form.php');
if(!is_number($_GET['id']) || !$_GET['id']) { error(0); }
if (!is_number($_GET['id']) || !$_GET['id']) {
error(0);
}
$TorrentID = $_GET['id'];
@ -58,11 +60,13 @@
WHERE t.ID='$TorrentID'");
list($Properties) = $DB->to_array(false,MYSQLI_BOTH);
if(!$Properties) { error(404); }
if (!$Properties) {
error(404);
}
$UploadForm = $Categories[$Properties['CategoryID']-1];
if(($LoggedUser['ID']!=$Properties['UserID'] && !check_perms('torrents_edit')) || $LoggedUser['DisableWiki']) {
if (($LoggedUser['ID'] != $Properties['UserID'] && !check_perms('torrents_edit')) || $LoggedUser['DisableWiki']) {
error(403);
}
@ -70,7 +74,7 @@
View::show_header('Edit torrent', 'upload');
if(!($Properties['Remastered'] && !$Properties['RemasterYear']) || check_perms('edit_unknowns')) {
if (!($Properties['Remastered'] && !$Properties['RemasterYear']) || check_perms('edit_unknowns')) {
$TorrentForm = new TORRENT_FORM($Properties, $Err, false);
$TorrentForm->head();
@ -97,7 +101,7 @@
}
if(check_perms('torrents_edit') && $Properties['CategoryID'] == 1) {
if (check_perms('torrents_edit') && $Properties['CategoryID'] == 1) {
?>
<div class="thin">
<h2>Change group</h2>
@ -153,6 +157,66 @@
</table>
</form>
<br />
<?
}
if (check_perms('users_mod')) { ?>
<h2>Change category</h2>
<form action="torrents.php" method="post">
<input type="hidden" name="action" value="changecategory" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
<input type="hidden" name="oldgroupid" value="<?=$Properties['GroupID']?>" />
<input type="hidden" name="oldartistid" value="<?=$Properties['ArtistID']?>" />
<input type="hidden" name="oldcategoryid" value="<?=$Properties['CategoryID']?>" />
<table>
<tr>
<td class="label">Change category</td>
<td>
<select id="newcategoryid" name="newcategoryid" onchange="ChangeCategory(this.value);">
<? foreach ($Categories as $CatID => $CatName) { ?>
<option value="<?=$CatID+1?>"<?Format::selected('CategoryID',$CatID+1,'selected',$Properties)?>><?=$CatName?></option>
<? } ?>
</select>
</td>
<tr id="split_releasetype">
<td class="label">Release type</td>
<td>
<select name="releasetype">
<? foreach ($ReleaseTypes as $RTID => $ReleaseType) { ?>
<option value="<?=$RTID?>"><?=$ReleaseType?></option>
<? } ?>
</select>
</td>
</tr>
<tr id="split_artist">
<td class="label">Artist</td>
<td>
<input type="text" name="artist" value="<?=$Properties['ArtistName']?>" size="50" />
</td>
</tr>
<tr id="split_title">
<td class="label">Title</td>
<td>
<input type="text" name="title" value="<?=$Properties['Title']?>" size="50" />
</td>
</tr>
<tr id="split_year">
<td class="label">Year</td>
<td>
<input type="text" name="year" value="<?=$Properties['Year']?>" size="10" />
</td>
</tr>
<tr>
<td colspan="2" class="center">
<input type="submit" value="Change category" />
</td>
</tr>
</table>
<script type="text/javascript">ChangeCategory($('#newcategoryid').raw().value);</script>
</form>
<?
}
?>
</div>
<?
} // if check_perms('torrents_edit')

View File

@ -34,6 +34,11 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
include(SERVER_ROOT.'/sections/torrents/editgroupid.php');
break;
case 'changecategory':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takechangecategory.php');
break;
case 'takeedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takeedit.php');

View File

@ -0,0 +1,102 @@
<?
/***************************************************************
* Temp handler for changing the category for a single torrent.
****************************************************************/
authorize();
if (!check_perms('users_mod')) {
error(403);
}
$OldGroupID = $_POST['oldgroupid'];
$TorrentID = $_POST['torrentid'];
$Title = db_string(trim($_POST['title']));
$OldCategoryID = $_POST['oldcategoryid'];
$NewCategoryID = $_POST['newcategoryid'];
if (!is_number($OldGroupID) || !is_number($TorrentID) || !$OldGroupID || !$TorrentID || empty($Title)) {
error(0);
}
switch ($Categories[$NewCategoryID-1]) {
case 'Music':
$ArtistName = db_string(trim($_POST['artist']));
$Year = trim($_POST['year']);
$ReleaseType = trim($_POST['releasetype']);
if (empty($Year) || empty($ArtistName) || !is_number($Year) || empty($ReleaseType) || !is_number($ReleaseType)) {
error(0);
}
$SearchText = "$ArtistName $Title $Year";
$DB->query("SELECT ArtistID, AliasID, Redirect, Name FROM artists_alias WHERE Name LIKE '$ArtistName'");
if ($DB->record_count() == 0) {
$Redirect = 0;
$DB->query("INSERT INTO artists_group (Name) VALUES ('$ArtistName')");
$ArtistID = $DB->inserted_id();
$DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES ('$ArtistID', '$ArtistName')");
$AliasID = $DB->inserted_id();
} else {
list($ArtistID, $AliasID, $Redirect, $ArtistName) = $DB->next_record();
if ($Redirect) {
$AliasID = $ArtistID;
}
}
$DB->query("INSERT INTO torrents_group
(ArtistID, NumArtists, CategoryID, Name, Year, ReleaseType, Time, WikiBody, WikiImage, SearchText)
VALUES
($ArtistID, '1', '1', '$Title', '$Year', '$ReleaseType', '".sqltime()."', '', '', '$SearchText')");
$GroupID = $DB->inserted_id();
$DB->query("INSERT INTO torrents_artists
(GroupID, ArtistID, AliasID, Importance, UserID) VALUES
('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')");
break;
case 'Audiobooks':
case 'Comedy':
$Year = trim($_POST['year']);
if (empty($Year) || !is_number($Year)) {
error(0);
}
$SearchText = "$Title $Year";
$DB->query("INSERT INTO torrents_group
(CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
VALUES
($NewCategoryID, '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
$GroupID = $DB->inserted_id();
break;
case 'Applications':
case 'Comics':
case 'E-Books':
case 'E-Learning Videos':
$SearchText = $Title;
$DB->query("INSERT INTO torrents_group
(CategoryID, Name, Time, WikiBody, WikiImage, SearchText)
VALUES
($NewCategoryID, '$Title', '".sqltime()."', '', '', '$SearchText')");
$GroupID = $DB->inserted_id();
break;
}
$DB->query("UPDATE torrents SET
GroupID='$GroupID'
WHERE ID='$TorrentID'");
// Delete old group if needed
$DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
if ($DB->record_count() == 0) {
$DB->query("UPDATE torrents_comments SET GroupID='$GroupID' WHERE GroupID='$OldGroupID'");
Torrents::delete_group($OldGroupID);
$Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0');
} else {
Torrents::update_hash($OldGroupID);
}
Torrents::update_hash($GroupID);
$Cache->delete_value('torrent_download_'.$TorrentID);
Misc::write_log("Torrent $TorrentID was edited by $LoggedUser[Username]");
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged from group $OldGroupID", 0);
$DB->query("UPDATE group_log SET GroupID = $GroupID WHERE GroupID = $OldGroupID");
header("Location: torrents.php?id=$GroupID");
?>

View File

@ -144,7 +144,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
break;
case 'seeding':
if(!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
$Time = '(unix_timestamp(now()) - xfu.timespent)';
$Time = '(xfu.mtime - xfu.timespent)';
$UserField = 'xfu.uid';
$ExtraWhere = 'AND xfu.active=1 AND xfu.Remaining=0';
$From = "xbt_files_users AS xfu JOIN torrents AS t ON t.ID=xfu.fid";
@ -157,7 +157,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
break;
case 'leeching':
if(!check_paranoia('leeching', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
$Time = '(unix_timestamp(now()) - xfu.timespent)';
$Time = '(xfu.mtime - xfu.timespent)';
$UserField = 'xfu.uid';
$ExtraWhere = 'AND xfu.active=1 AND xfu.Remaining>0';
$From = "xbt_files_users AS xfu JOIN torrents AS t ON t.ID=xfu.fid";