Empty commit

This commit is contained in:
Git 2013-07-24 08:00:46 +00:00
parent d4724365ea
commit df16f6adee
15 changed files with 136 additions and 230 deletions

View File

@ -1,131 +1,35 @@
<?
/**
* Load classes automatically when they're needed
*
* @param string $ClassName class name
*/
spl_autoload_register(function ($ClassName) {
$FileName = '';
switch ($ClassName) {
case 'Artists':
$FileName = 'artists.class';
break;
case 'Bencode':
$FileName = 'bencode.class';
break;
case 'BencodeDecode':
$FileName = 'bencodedecode.class';
break;
case 'BencodeTorrent':
$FileName = 'bencodetorrent.class';
break;
case 'Bookmarks':
$FileName = 'bookmarks.class';
break;
case 'Collages':
$FileName = 'collages.class';
break;
case 'Format':
$FileName = 'format.class';
break;
case 'Forums':
$FileName = 'forums.class';
break;
case 'Forum':
$FileName = 'forum.class';
break;
case 'ForumView':
$FileName = 'forumsview.class';
break;
case 'G':
$FileName = 'g.class';
break;
case 'ImageTools':
$FileName = 'image_tools.class';
break;
case 'Inbox':
$FileName = 'inbox.class';
break;
case 'LastFM':
$FileName = 'lastfm.class';
break;
case 'MASS_USER_BOOKMARKS_EDITOR':
$FileName = 'mass_user_bookmarks_editor.class';
break;
case 'MASS_USER_TORRENTS_EDITOR':
$FileName = 'mass_user_torrents_editor.class';
break;
case 'MASS_USER_TORRENTS_TABLE_VIEW':
$FileName = 'mass_user_torrents_table_view.class';
break;
case 'Misc':
$FileName = 'misc.class';
break;
case 'Permissions':
$FileName = 'permissions.class';
break;
case 'Requests':
$FileName = 'requests.class';
break;
case 'Rippy':
$FileName = 'rippy.class';
break;
case 'Rules':
$FileName = 'rules.class';
break;
case 'Sphinxql':
$FileName = 'sphinxql.class';
break;
case 'SphinxqlQuery':
$FileName = 'sphinxqlquery.class';
break;
case 'SphinxqlResult':
$FileName = 'sphinxqlresult.class';
break;
case 'Tags':
$FileName = 'tags.class';
break;
case 'TEXTAREA_PREVIEW':
$FileName = 'textarea_preview.class';
break;
case 'Thread':
$FileName = 'thread.class';
break;
case 'Tools':
$FileName = 'tools.class';
break;
case 'TORRENT':
case 'BENCODE_DICT':
case 'BENCODE_LIST':
$FileName = 'torrent.class';
break;
case 'Torrents':
$FileName = 'torrents.class';
break;
case 'TorrentsDL':
$FileName = 'torrentsdl.class';
break;
case 'Tracker':
$FileName = 'tracker.class';
break;
case 'UserAgent':
$FileName = 'useragent.class';
break;
case 'UserRank':
$FileName = 'user_rank.class';
break;
case 'Users':
$FileName = 'users.class';
break;
case 'View':
$FileName = 'view.class';
break;
case 'Votes':
$FileName = 'votes.class';
break;
case 'Wiki':
$FileName = 'wiki.class';
break;
case 'Zip':
$FileName = 'zip.class';
break;
default:
die("Couldn't import class $ClassName");
$FilePath = SERVER_ROOT . '/classes/' . strtolower($ClassName) . '.class.php';
if (!file_exists($FilePath)) {
// TODO: Rename the following classes to conform with the code guidelines
switch ($ClassName) {
case 'MASS_USER_BOOKMARKS_EDITOR':
$FileName = 'mass_user_bookmarks_editor.class';
break;
case 'MASS_USER_TORRENTS_EDITOR':
$FileName = 'mass_user_torrents_editor.class';
break;
case 'MASS_USER_TORRENTS_TABLE_VIEW':
$FileName = 'mass_user_torrents_table_view.class';
break;
case 'TEXTAREA_PREVIEW':
$FileName = 'textarea_preview.class';
break;
case 'TORRENT':
case 'BENCODE_DICT':
case 'BENCODE_LIST':
$FileName = 'torrent.class';
break;
default:
die("Couldn't import class $ClassName");
}
$FilePath = SERVER_ROOT . "/classes/$FileName.php";
}
require_once(SERVER_ROOT . "/classes/$FileName.php");
});
require_once($FilePath);
});

View File

@ -105,7 +105,7 @@ public function get_cpu_time() {
public function log_var($Var, $VarName = false) {
$BackTrace = debug_backtrace();
$ID = uniqid();
$ID = Users::make_secret(5);
if (!$VarName) {
$VarName = $ID;
}

View File

@ -24,16 +24,17 @@ function is_number($Str) {
/**
* Check that some given variables (usually in _GET or _POST) are numbers
*
* @param array $Base Array that's supposed to contain all keys to check
* @param array $Base array that's supposed to contain all keys to check
* @param array $Keys list of keys to check
* @param mixed $Error error code or string to pass to the error() function if a key isn't numeric
*/
function assert_numbers(&$Base, $Keys, $Error = 0) {
// make sure both arguments are arrays
if (!is_array($Base) || !is_array($Keys)) {
return;
}
foreach ($Keys as $Key) {
if (empty($Base[$Key]) || !is_number($Base[$Key])) {
if (!isset($Base[$Key]) || !is_number($Base[$Key])) {
error($Error);
}
}

View File

@ -623,25 +623,25 @@ class="stat"
<li id="searchbar_torrents"><span class="hidden">Torrents: </span>
<form class="search_form" name="torrents" action="torrents.php"
method="get">
<? if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { // Advanced search ?>
<? if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { // Advanced search ?>
<input type="hidden" name="action" value="advanced" />
<? } ?>
<? } ?>
<input id="torrentssearch" accesskey="t" spellcheck="false"
onfocus="if (this.value == 'Torrents') this.value='';"
onblur="if (this.value == '') this.value='Torrents';"
<? if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { // Advanced search ?>
onfocus="if (this.value == 'Torrents') this.value = '';"
onblur="if (this.value == '') this.value = 'Torrents';"
<? if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) { // Advanced search ?>
value="Torrents" type="text" name="groupname" size="17"
<? } else { ?> value="Torrents" type="text" name="searchstr"
<? } else { ?> value="Torrents" type="text" name="searchstr"
size="17" <? } ?> />
</form></li>
<li id="searchbar_artists"><span class="hidden">Artist: </span>
<form class="search_form" name="artists" action="artist.php"
method="get">
<input id="artistsearch"<? Users::has_autocomplete_enabled('search'); ?>
accesskey="a"
<input id="artistsearch"<? Users::has_autocomplete_enabled('search');
?> accesskey="a"
spellcheck="false" autocomplete="off"
onfocus="if (this.value == 'Artists') this.value='';"
onblur="if (this.value == '') this.value='Artists';"
onfocus="if (this.value == 'Artists') this.value = '';"
onblur="if (this.value == '') this.value = 'Artists';"
value="Artists" type="text" name="artistname" size="17" />
</form>
</li>
@ -649,8 +649,8 @@ class="stat"
<form class="search_form" name="requests" action="requests.php"
method="get">
<input id="requestssearch" spellcheck="false"
onfocus="if (this.value == 'Requests') this.value='';"
onblur="if (this.value == '') this.value='Requests';"
onfocus="if (this.value == 'Requests') this.value = '';"
onblur="if (this.value == '') this.value = 'Requests';"
value="Requests" type="text" name="search" size="17" />
</form></li>
<li id="searchbar_forums"><span class="hidden">Forums: </span>
@ -658,28 +658,27 @@ class="stat"
method="get">
<input value="search" type="hidden" name="action" /> <input
id="forumssearch"
onfocus="if (this.value == 'Forums') this.value='';"
onblur="if (this.value == '') this.value='Forums';"
onfocus="if (this.value == 'Forums') this.value = '';"
onblur="if (this.value == '') this.value = 'Forums';"
value="Forums" type="text" name="search" size="17" />
</form></li>
<!--
<li id="searchbar_wiki">
<span class="hidden">Wiki: </span>
<form class="search_form" name="wiki" action="wiki.php" method="get">
<input type="hidden" name="action" value="search" />
<input
onfocus="if (this.value == 'Wiki') this.value='';"
onblur="if (this.value == '') this.value='Wiki';"
value="Wiki" type="text" name="search" size="17"
/>
</form>
</li>
<!--
<li id="searchbar_wiki"><span class="hidden">Wiki: </span>
<form class="search_form" name="wiki" action="wiki.php" method="get">
<input type="hidden" name="action" value="search" />
<input
onfocus="if (this.value == 'Wiki') this.value = '';"
onblur="if (this.value == '') this.value = 'Wiki';"
value="Wiki" type="text" name="search" size="17"
/>
</form>
</li>
-->
<li id="searchbar_log"><span class="hidden">Log: </span>
<form class="search_form" name="log" action="log.php" method="get">
<input id="logsearch"
onfocus="if (this.value == 'Log') this.value='';"
onblur="if (this.value == '') this.value='Log';" value="Log"
onfocus="if (this.value == 'Log') this.value = '';"
onblur="if (this.value == '') this.value = 'Log';" value="Log"
type="text" name="search" size="17" />
</form></li>
<li id="searchbar_users"><span class="hidden">Users: </span>
@ -687,8 +686,8 @@ class="stat"
method="get">
<input type="hidden" name="action" value="search" /> <input
id="userssearch"
onfocus="if (this.value == 'Users') this.value='';"
onblur="if (this.value == '') this.value='Users';" value="Users"
onfocus="if (this.value == 'Users') this.value = '';"
onblur="if (this.value == '') this.value = 'Users';" value="Users"
type="text" name="search" size="20" />
</form></li>
</ul>

View File

@ -62,7 +62,7 @@ Tabs shall always be used for indentation.
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
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
@ -78,13 +78,13 @@ 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.
`elseif` in PHP, `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`.
For PHP 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.
@ -102,6 +102,9 @@ printing a variable.
When declaring JavaScript variables, `var` shall always be used.
When manually type casting, whitespace should not be used between the
cast operator and the variable.
## Code styling for CSS
`property: value;` pairs shall be separated by a space, and the value

View File

@ -2,7 +2,7 @@
include(SERVER_ROOT . "/sections/forums/functions.php");
$PostID = (int) $_POST['postid'];
$PostID = (int)$_POST['postid'];
if (empty($PostID)) {
json_die("error", "empty postid");

View File

@ -45,47 +45,47 @@ function error_out($reason = '') {
$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread']));
$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group']));
if ($ShowGrouped) {
$sql = '
$SQL = '
SELECT
SQL_CALC_FOUND_ROWS
MAX(p.ID) AS ID
SQL_CALC_FOUND_ROWS
MAX(p.ID) AS ID
FROM forums_posts AS p
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID';
if ($ShowUnread) {
$sql.='
$SQL .= '
LEFT JOIN forums_last_read_topics AS l ON l.TopicID = t.ID AND l.UserID = '.$LoggedUser['ID'];
}
$sql .= '
$SQL .= '
LEFT JOIN forums AS f ON f.ID = t.ForumID
WHERE p.AuthorID = '.$UserID.'
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
if (!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
$SQL .= "
AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= ')';
$SQL .= ')';
if (!empty($PermittedForums)) {
$sql.='
OR f.ID IN (\''.$PermittedForums.'\')';
$SQL .= "
OR f.ID IN ('$PermittedForums')";
}
$sql .= ')';
$SQL .= ')';
if ($ShowUnread) {
$sql .= '
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')
AND (l.PostID<t.LastPostID OR l.PostID IS NULL))';
$SQL .= '
AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
AND (l.PostID < t.LastPostID OR l.PostID IS NULL))';
}
$sql .= "
$SQL .= "
GROUP BY t.ID
ORDER BY p.ID DESC
LIMIT $Limit";
$PostIDs = $DB->query($sql);
$PostIDs = $DB->query($SQL);
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
if ($Results > $PerPage * ($Page - 1)) {
$DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID');
$sql = "
$SQL = "
SELECT
p.ID,
p.AddedTime,
@ -108,19 +108,19 @@ function error_out($reason = '') {
LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID
WHERE p.ID IN (".implode(',', $PostIDs).')
ORDER BY p.ID DESC';
$Posts = $DB->query($sql);
$Posts = $DB->query($SQL);
}
} else {
$sql = '
$SQL = '
SELECT
SQL_CALC_FOUND_ROWS';
if ($ShowGrouped) {
$sql .= '
$SQL .= '
*
FROM (
SELECT';
}
$sql .= '
$SQL .= '
p.ID,
p.AddedTime,
p.Body,
@ -131,10 +131,10 @@ function error_out($reason = '') {
t.Title,
t.LastPostID,';
if ($UserID === $LoggedUser['ID']) {
$sql .= '
$SQL .= '
l.PostID AS LastRead,';
}
$sql .= "
$SQL .= "
t.IsLocked,
t.IsSticky
FROM forums_posts as p
@ -148,39 +148,39 @@ function error_out($reason = '') {
AND ((f.MinClassRead <= ".$LoggedUser['Class'];
if (!empty($RestrictedForums)) {
$sql .= "
$SQL .= "
AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= '
$SQL .= '
)';
if (!empty($PermittedForums)) {
$sql .= "
$SQL .= "
OR f.ID IN ('$PermittedForums')";
}
$sql .= '
$SQL .= '
)';
if ($ShowUnread) {
$sql .= '
$SQL .= '
AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
AND (l.PostID < t.LastPostID OR l.PostID IS NULL)
) ';
}
$sql .= '
$SQL .= '
ORDER BY p.ID DESC';
if ($ShowGrouped) {
$sql .= '
$SQL .= '
) AS sub
GROUP BY TopicID
ORDER BY ID DESC';
}
$sql .= "
$SQL .= "
LIMIT $Limit";
$Posts = $DB->query($sql);
$Posts = $DB->query($SQL);
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();

View File

@ -136,7 +136,7 @@ function compare($X, $Y) {
}
// Deal with torrents without release types, which can end up here
// if they're uploaded with a non-grouping category id
// if they're uploaded with a non-grouping category ID
$UnknownRT = array_search('Unknown', $ReleaseTypes);
if ($UnknownRT === false) {
$UnknownRT = 1025;

View File

@ -7,7 +7,7 @@
$Search = false;
}
$Words = explode(' ', $Search);
$sql = '
$SQL = '
SELECT
SQL_CALC_FOUND_ROWS
ID,
@ -15,24 +15,24 @@
Time
FROM log ';
if ($Search) {
$sql .= "WHERE Message LIKE '%";
$sql .= implode("%' AND Message LIKE '%", $Words);
$sql .= "%' ";
$SQL .= "WHERE Message LIKE '%";
$SQL .= implode("%' AND Message LIKE '%", $Words);
$SQL .= "%' ";
}
if (!check_perms('site_view_full_log')) {
if ($Search) {
$sql .= ' AND ';
$SQL .= ' AND ';
} else {
$sql .= ' WHERE ';
$SQL .= ' WHERE ';
}
$sql .= " Time>'".time_minus(3600 * 24 * 28)."' ";
$SQL .= " Time>'".time_minus(3600 * 24 * 28)."' ";
}
$sql .= "
$SQL .= "
ORDER BY ID DESC
LIMIT $Limit";
$Log = $DB->query($sql);
$Log = $DB->query($SQL);
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$TotalMatches = $NumResults;

View File

@ -76,35 +76,35 @@
DATE_FORMAT(JoinDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE JoinDate != '0000-00-00 00:00:00'
WHERE JoinDate != '0000-00-00 00:00:00'
GROUP BY Date
) AS j
LEFT JOIN (
SELECT
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '1'
GROUP BY Date
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '1'
GROUP BY Date
) AS m ON j.Date = m.Date
LEFT JOIN (
SELECT
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '2'
GROUP BY Date
AND BanReason = '2'
GROUP BY Date
) AS r ON j.Date = r.Date
LEFT JOIN (
SELECT
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '3'
GROUP BY Date
COUNT(UserID) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '3'
GROUP BY Date
) AS i ON j.Date = i.Date
ORDER BY j.Date DESC
LIMIT $Limit");

View File

@ -26,14 +26,14 @@ function Quote(post, user, link) {
postid = post;
// check if reply_box element exists and that user is in the forums
if(!$('#reply_box').length && url.path == "forums") {
if (!$('#reply_box').length && url.path == "forums") {
if ($("#quote_" + postid).text() == "Quote") {
original_post = $("#content" + postid).html();
$("#quote_" + postid).text("Unquote");
$.ajax({
type : "POST",
url: "ajax.php?action=raw_bbcode",
dataType: "json",
url : "ajax.php?action=raw_bbcode",
dataType : "json",
data : {
"postid" : postid
}
@ -65,8 +65,8 @@ function Edit_Form(post,key) {
//If no edit is already going underway or a previous edit was finished, make the necessary dom changes.
if (!$('#editbox' + postid).results() || $('#editbox' + postid + '.hidden').results()) {
$('#reply_box').ghide();
if (location.href.match(/torrents\.php/) ||
location.href.match(/artist\.php/)) {
if (location.href.match(/torrents\.php/)
|| location.href.match(/artist\.php/)) {
boxWidth = "50";
} else {
boxWidth = "80";

View File

@ -141,4 +141,3 @@ function select_all(el) {
textRange.select();
}
}

View File

@ -212,7 +212,7 @@ function URL() {
// jQuery plugin to prevent double submission of forms
jQuery.fn.preventDoubleSubmission = function() {
$(this).bind('submit',function(e){
$(this).bind('submit', function(e){
var $form = $(this);
if ($form.data('submitted') === true) {
@ -275,7 +275,7 @@ jQuery.extend(jQuery.prototype, {
var classes = object.className.split(' ');
var result = array_search(class_name, classes);
if (result !== false) {
classes.splice(result,1);
classes.splice(result, 1);
object.className = classes.join(' ');
}
}
@ -297,7 +297,7 @@ jQuery.extend(jQuery.prototype, {
var classes = object.className.split(' ');
var result = array_search(class_name, classes);
if (result !== false) {
classes.splice(result,1);
classes.splice(result, 1);
object.className = classes.join(' ');
} else {
if (object.className === '') {