Empty commit

This commit is contained in:
Git 2013-07-03 08:01:01 +00:00
parent 8b04ca921c
commit f86bb1f066
21 changed files with 203 additions and 71 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
TODO fill me out

View File

@ -482,6 +482,12 @@ function authorize($Ajax = false) {
error(404);
}
$Cache->cache_value('php_' . getmypid(), array(
'start' => sqltime(),
'document' => $Document,
'query' => $_SERVER['QUERY_STRING'],
'get' => $_GET,
'post' => $_POST), 600);
require(SERVER_ROOT.'/sections/'.$Document.'/index.php');
$Debug->set_flag('completed module execution');

View File

@ -199,7 +199,7 @@ function music_form($GenreTags) {
foreach ($Torrent['Artists'] as $Importance => $Artists) {
foreach ($Artists as $Artist) {
?>
<input type="text" id="artist" name="artists[]" size="45" value="<?=display_str($Artist['name']) ?>" onblur="CheckVA();"<?=$this->Disabled?> />
<input type="text" id="artist" name="artists[]" size="45" value="<?=display_str($Artist['name']) ?>" onblur="CheckVA();" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
<select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1"<?=($Importance == '1' ? ' selected="selected"' : '')?>>Main</option>
<option value="2"<?=($Importance == '2' ? ' selected="selected"' : '')?>>Guest</option>
@ -220,7 +220,7 @@ function music_form($GenreTags) {
}
} else {
?>
<input type="text" id="artist" name="artists[]" size="45" onblur="CheckVA();"<?=$this->Disabled?> />
<input type="text" id="artist" name="artists[]" size="45" onblur="CheckVA();" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
<select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1">Main</option>
<option value="2">Guest</option>
@ -586,7 +586,7 @@ function show() {
<? } ?>
</select>
<? } ?>
<input type="text" id="tags" name="tags" size="40" value="<?=display_str($Torrent['TagList']) ?>"<?=$this->Disabled?> />
<input type="text" id="tags" name="tags" size="40" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
<br />
<? Rules::display_site_tag_rules(true) // indent the opening PHP tag with 3 tabs for proper HTML generation ?>
</td>
@ -694,7 +694,7 @@ function audiobook_form() {
<tr>
<td class="label">Tags:</td>
<td>
<input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" />
<input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?> />
</td>
</tr>
<tr>
@ -736,7 +736,7 @@ function simple_form($CategoryID) {
</tr>
<tr>
<td class="label">Tags:</td>
<td><input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" /></td>
<td><input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?>/></td>
</tr>
<tr>
<td class="label">Image (optional):</td>

View File

@ -620,4 +620,39 @@ public static function has_avatars_enabled() {
global $HeavyInfo;
return $HeavyInfo['DisableAvatars'] != 1;
}
/**
* Checks whether user has autocomplete enabled
*
* 0 - Enabled everywhere (default), 1 - Disabled, 2 - Searches only
*
* @param string $Type the type of the input.
* @param boolean $Output echo out html
* @return boolean
*/
public static function has_autocomplete_enabled($Type, $Output = true) {
global $LoggedUser;
$Enabled = false;
if (empty($LoggedUser['AutoComplete'])) {
$Enabled = true;
}
elseif ($LoggedUser['AutoComplete'] !== 1) {
switch($Type) {
case 'search':
if ($LoggedUser['AutoComplete'] == 2) {
$Enabled = true;
}
break;
case 'other':
if ($LoggedUser['AutoComplete'] != 2) {
$Enabled = true;
}
break;
}
}
if ($Enabled && $Output) {
echo 'data-gazelle-autocomplete="true"';
}
return $Enabled;
}
}

View File

@ -637,7 +637,7 @@ class="stat"
<li id="searchbar_artists"><span class="hidden">Artist: </span>
<form class="search_form" name="artists" action="artist.php"
method="get">
<input id="artistsearch"
<input id="artistsearch" <? Users::has_autocomplete_enabled('search'); ?>
accesskey="a"
spellcheck="false" autocomplete="off"
onfocus="if (this.value == 'Artists') this.value='';"

View File

@ -696,7 +696,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_similar" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="artistid" value="<?=$ArtistID?>" />
<input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20" />
<input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20" <? Users::has_autocomplete_enabled('other'); ?>/>
<input type="submit" value="+" />
</form>
</li>

View File

@ -180,7 +180,7 @@
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td>
<input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>" />&nbsp;
<input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?> <? Users::has_autocomplete_enabled('other'); ?>" />&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>
</td>

View File

@ -260,7 +260,7 @@
<option value="<?=$Genre?>"><?=$Genre?></option>
<? } ?>
</select>
<input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>" />
<input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>" <? Users::has_autocomplete_enabled('other'); ?>/>
<br />
Tags should be comma-separated, and you should use a period (".") to separate words inside a tag&#8202;&mdash;&#8202;e.g. "<strong class="important_text_alt">hip.hop</strong>".
<br /><br />

View File

@ -389,7 +389,7 @@
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td>
<input type="text" name="tags" id="tags" size="60" value="<?= (!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>" />&nbsp;
<input type="text" name="tags" id="tags" size="60" value="<?= (!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>" <? Users::has_autocomplete_enabled('other'); ?>/>&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>
</td>

View File

@ -132,7 +132,8 @@
error(403);
}
if (is_number($_POST['newsid'])) {
$DB->query("UPDATE news
$DB->query("
UPDATE news
SET Title = '".db_string($_POST['title'])."',
Body = '".db_string($_POST['body'])."'
WHERE ID = '".db_string($_POST['newsid'])."'");
@ -148,7 +149,9 @@
}
if (is_number($_GET['id'])) {
authorize();
$DB->query("DELETE FROM news WHERE ID='".db_string($_GET['id'])."'");
$DB->query("
DELETE FROM news
WHERE ID = '".db_string($_GET['id'])."'");
$Cache->delete_value('news');
$Cache->delete_value('feed_news');
@ -166,7 +169,8 @@
error(403);
}
$DB->query("INSERT INTO news (UserID, Title, Body, Time)
$DB->query("
INSERT INTO news (UserID, Title, Body, Time)
VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."')");
@ -208,7 +212,8 @@
//$Val->SetFields('test', true, 'number', 'You did not enter a valid level for this permission set.');
if (is_numeric($_REQUEST['id'])) {
$DB->query("SELECT p.ID, p.Name, p.Level, p.Secondary, p.PermittedForums, p.Values, p.DisplayStaff, COUNT(u.ID)
$DB->query("
SELECT p.ID, p.Name, p.Level, p.Secondary, p.PermittedForums, p.Values, p.DisplayStaff, COUNT(u.ID)
FROM permissions AS p
LEFT JOIN users_main AS u ON u.PermissionID = p.ID
WHERE p.ID = '".db_string($_REQUEST['id'])."'
@ -225,7 +230,10 @@
$Err = $Val->ValidateForm($_POST);
if (!is_numeric($_REQUEST['id'])) {
$DB->query("SELECT ID FROM permissions WHERE Level='".db_string($_REQUEST['level'])."'");
$DB->query("
SELECT ID
FROM permissions
WHERE Level = '".db_string($_REQUEST['level'])."'");
list($DupeCheck)=$DB->next_record();
if ($DupeCheck) {
@ -274,7 +282,7 @@
FROM users_levels
WHERE PermissionID = ".db_string($_REQUEST['id']));
while ($UserID = $DB->next_record()) {
$Cache->delete_value('user_info_heavy_'.$UserID);
$Cache->delete_value("user_info_heavy_$UserID");
}
}
}
@ -288,19 +296,32 @@
} else {
if (!empty($_REQUEST['removeid'])) {
$DB->query("DELETE FROM permissions WHERE ID='".db_string($_REQUEST['removeid'])."'");
$DB->query("SELECT UserID FROM users_levels WHERE PermissionID='".db_string($_REQUEST['removeid'])."'");
$DB->query("
DELETE FROM permissions
WHERE ID = '".db_string($_REQUEST['removeid'])."'");
$DB->query("
SELECT UserID
FROM users_levels
WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('user_info_'.$UserID);
$Cache->delete_value('user_info_heavy_'.$UserID);
$Cache->delete_value("user_info_$UserID");
$Cache->delete_value("user_info_heavy_$UserID");
}
$DB->query("DELETE FROM users_levels WHERE PermissionID='".db_string($_REQUEST['removeid'])."'");
$DB->query("SELECT ID FROM users_main WHERE PermissionID='".db_string($_REQUEST['removeid'])."'");
$DB->query("
DELETE FROM users_levels
WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
$DB->query("
SELECT ID
FROM users_main
WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('user_info_'.$UserID);
$Cache->delete_value('user_info_heavy_'.$UserID);
$Cache->delete_value("user_info_$UserID");
$Cache->delete_value("user_info_heavy_$UserID");
}
$DB->query("UPDATE users_main SET PermissionID='".USER."' WHERE PermissionID='".db_string($_REQUEST['removeid'])."'");
$DB->query("
UPDATE users_main
SET PermissionID = '".USER."'
WHERE PermissionID = '".db_string($_REQUEST['removeid'])."'");
$Cache->delete_value('classes');
}
@ -311,7 +332,7 @@
break;
case 'ip_ban':
//TODO: Clean up db table ip_bans.
//TODO: Clean up DB table ip_bans.
include("managers/bans.php");
break;
case 'quick_ban':
@ -397,6 +418,10 @@
include('misc/analysis.php');
break;
case 'process_info':
include('misc/process_info.php');
break;
case 'rerender_gallery':
include('misc/rerender_gallery.php');
break;

View File

@ -0,0 +1,41 @@
<?
if (!check_perms('site_debug')) {
error(403);
}
View::show_header('PHP Processes');
$PIDList = trim(`ps -C php-fpm -o pid --no-header`);
$PIDs = explode("\n", $PIDList);
$Debug->log_var($PIDList, 'PID list');
$Debug->log_var($PIDs, 'PIDs');
?>
<div class="thin">
<table class="process_info">
<colgroup>
<col class="process_info_pid" />
<col class="process_info_data" />
</colgroup>
<tr class="colhead_dark">
<td colspan="2">
<?=count($PIDs) . ' processes'?>
</td>
</tr>
<?
foreach ($PIDs as $PID) {
$PID = trim($PID);
if (!$ProcessInfo = $Cache->get_value("php_$PID")) {
continue;
}
?>
<tr>
<td>
<?=$PID?>
</td>
<td>
<pre><?print_r($ProcessInfo)?></pre>
</td>
</tr>
<? } ?>
</table>
</div>
<?
View::show_footer();

View File

@ -76,6 +76,7 @@
<? } if (check_perms('users_view_ips')) { ?>
<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=process_info">PHP processes</a></td></tr>
<tr><td><a href="tools.php?action=sandbox1">Sandbox (1)</a></td></tr>
<tr><td><a href="tools.php?action=sandbox2">Sandbox (2)</a></td></tr>
<tr><td><a href="tools.php?action=sandbox3">Sandbox (3)</a></td></tr>

View File

@ -68,7 +68,7 @@
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td class="ft_taglist">
<input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>" />&nbsp;
<input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>" <? Users::has_autocomplete_enabled('other'); ?>/>&nbsp;
<input type="radio" id="rdoAll" name="anyall" value="all"<?=($_GET['anyall']!='any'?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
<input type="radio" id="rdoAny" name="anyall" value="any"<?=($_GET['anyall']=='any'?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
</td>

View File

@ -409,7 +409,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_alias" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="text" id="artist" name="aliasname[]" size="17" />
<input type="text" id="artist" name="aliasname[]" size="17" <? Users::has_autocomplete_enabled('other'); ?>/>
<select name="importance[]">
<option value="1">Main</option>
<option value="2">Guest</option>
@ -490,7 +490,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_tag" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="text" name="tagname" id="tagname" size="20" />
<input type="text" name="tagname" id="tagname" size="20" <? Users::has_autocomplete_enabled('other'); ?> />
<input type="submit" value="+" />
</form>
<br /><br />

View File

@ -265,6 +265,16 @@ function checked($Checked) {
</ul>
</td>
</tr>
<tr>
<td class="label"><strong>Auto Complete</strong></td>
<td>
<select name="autocomplete">
<option value="0" <? if (empty($SiteOptions['AutoComplete'])) { ?> selected="selected" <? } ?>>Everywhere</option>
<option value="2" <? if ($SiteOptions['AutoComplete'] === 2) { ?>selected="selected" <? } ?>>Searches Only</option>
<option value="1" <? if ($SiteOptions['AutoComplete'] === 1) { ?>selected="selected" <? } ?>>Disable</option>
</select>
</td>
</tr>
<tr>
<td class="label"><strong>Voting links</strong></td>
<td>

View File

@ -218,6 +218,7 @@
$Options['NoVoteLinks'] = (!empty($_POST['novotelinks']) ? 1 : 0);
$Options['CoverArt'] = (int) !empty($_POST['coverart']);
$Options['ShowExtraCovers'] = (int) !empty($_POST['show_extra_covers']);
$Options['AutoComplete'] = (int) $_POST['autocomplete'];
if (isset($LoggedUser['DisableFreeTorrentTop10'])) {
$Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10'];

View File

@ -1,10 +1,10 @@
var ARTIST_AUTOCOMPLETE_URL = 'artist.php?action=autocomplete';
var TAGS_AUTOCOMPLETE_URL = 'torrents.php?action=autocomplete_tags';
var SELECTOR = '[data-gazelle-autocomplete="true"]';
$(document).ready(function() {
var url = new URL();
$('#artistsearch').autocomplete({
$('#artistsearch' + SELECTOR).autocomplete({
serviceUrl : ARTIST_AUTOCOMPLETE_URL,
onSelect : function(suggestion) {
window.location = 'artist.php?id=' + suggestion['data'];
@ -12,19 +12,19 @@ $(document).ready(function() {
});
if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist') {
$("#artist").autocomplete({
$("#artist" + SELECTOR).autocomplete({
serviceUrl : ARTIST_AUTOCOMPLETE_URL
});
$("#artistsimilar").autocomplete({
$("#artistsimilar" + SELECTOR).autocomplete({
serviceUrl : ARTIST_AUTOCOMPLETE_URL
});
}
if (url.path == 'torrents' || url.path == 'upload' || url.path == 'collages' || url.path == 'requests' || url.path == 'top10' || (url.path == 'requests' && url.query['action'] == 'new')) {
$("#tags").autocomplete({
$("#tags" + SELECTOR).autocomplete({
serviceUrl : TAGS_AUTOCOMPLETE_URL,
delimiter: ','
});
$("#tagname").autocomplete({
$("#tagname" + SELECTOR).autocomplete({
serviceUrl : TAGS_AUTOCOMPLETE_URL,
});
}

View File

@ -222,11 +222,13 @@ function AddArtistField() {
Importance.name = "importance[]";
Importance.innerHTML = '<option value="1">Main</option><option value="2">Guest</option><option value="4">Composer</option><option value="5">Conductor</option><option value="6">DJ / Compiler</option><option value="3">Remixer</option><option value="7">Producer</option>';
x.appendChild(Importance);
if ($("#artist").data("gazelle-autocomplete")) {
$(ArtistField).live('focus', function() {
$(ArtistField).autocomplete({
serviceUrl : 'artist.php?action=autocomplete'
});
});
}
ArtistFieldCount++;
}

View File

@ -235,11 +235,13 @@ function AddArtistField() {
x.appendChild(document.createTextNode('\n'));
x.appendChild(ImportanceField);
if ($("#artist").data("gazelle-autocomplete")) {
$(ArtistField).live('focus', function() {
$(ArtistField).autocomplete({
serviceUrl : 'artist.php?action=autocomplete'
});
});
}
ArtistCount++;
}

View File

@ -520,3 +520,14 @@ tr.torrent .bookmark>a:after {
font-weight: normal;
color: #3399FF;
}
.process_info {
table-layout: fixed;
width: 100%;
}
.process_info_pid {
width: 70px;
}
.process_info_data {
overflow: auto;
}

View File

@ -1,3 +0,0 @@
<? require("classes/script_start.php");
?>