Skip to content

Commit 6273679

Browse files
author
What.CD
committed
86 changes from Wed Jul 27 01:50:24 2011 -0400 to Tue Aug 9 12:47:47 2011 -0400
fix typo I introduced in schedule.php Print to LAB_CHAN if sphinx connection fails nice bitcoin display Corrects [#] tag for Mono [hateradio] bitcoin donation Fix torrent unbookmarking upgraded sphinxapi.php to r2876 as the site is running r2902 Added options to block Tor, Opera Turbo and Opera Mini check for stale cache vanity house [clone00] bookmark almost anything [patapper] new torrent edit flags [rattvis] permissions stuff from patappatch c [BBCode] new [important] tag [DutchDude] Fixed images flowing past their boxes [hateradio] [BBCode] Tag for ordered lists. [hateradio] finally fixed that annoying textarea-resizing thing renamed temporary tables fixes http://what.cd/forums.php?action=viewthread&threadid=137432&page=1#post3408738 implements http://what.cd/forums.php?action=viewthread&threadid=122832 fixes http://what.cd/forums.php?action=viewthread&threadid=136553 fixes http://what.cd/forums.php?action=viewthread&threadid=112967 implements http://what.cd/forums.php?action=viewthread&threadid=110395
1 parent 269d2b9 commit 6273679

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+796
-231
lines changed

classes/class_search.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(),
6363
if($this->_connerror && !$Cache->get_value('sphinx_crash_reported')) {
6464
send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed');
6565
$Cache->cache_value('sphinx_crash_reported', 1, 3600);
66-
} else {
67-
send_irc('PRIVMSG '.LAB_CHAN.' :Search for "'.$Query.'" ('.str_replace("\n",'',print_r($this->Filters, true)).') failed: '.$this->GetLastError());
6866
}
67+
send_irc('PRIVMSG '.LAB_CHAN.' :Search for "'.$Query.'" ('.str_replace("\n",'',print_r($this->Filters, true)).') failed: '.$this->GetLastError());
6968
}
7069

7170
$this->TotalResults = $Result['total'];

classes/class_text.php

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?
22
class TEXT {
33
// tag=>max number of attributes
4-
private $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'plain'=>0
4+
private $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, '#'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'plain'=>0, 'important'=>0
55
);
66
private $Smileys = array(
77
':angry:' => 'angry.gif',
@@ -196,7 +196,7 @@ function parse($Str) {
196196

197197
// 1) Find the next tag (regex)
198198
// [name(=attribute)?]|[[wiki-link]]
199-
$IsTag = preg_match("/((\[[a-zA-Z*]+)(=(?:[^\n'\"\[\]]|\[\d*\])+)?\])|(\[\[[^\n\"'\[\]]+\]\])/", $Str, $Tag, PREG_OFFSET_CAPTURE, $i);
199+
$IsTag = preg_match("/((\[[a-zA-Z*#]+)(=(?:[^\n'\"\[\]]|\[\d*\])+)?\])|(\[\[[^\n\"'\[\]]+\]\])/", $Str, $Tag, PREG_OFFSET_CAPTURE, $i);
200200

201201
// 1a) If there aren't any tags left, write everything remaining to a block
202202
if(!$IsTag) {
@@ -276,12 +276,12 @@ function parse($Str) {
276276
$i += $CloseTag; // 5d) Move the pointer past the end of the [/close] tag.
277277
} elseif($WikiLink == true || $TagName == 'n') {
278278
// Don't need to do anything - empty tag with no closing
279-
} elseif($TagName == '*') {
279+
} elseif($TagName === '*' || $TagName === '#') {
280280
// We're in a list. Find where it ends
281281
$NewLine = $i;
282282
do { // Look for \n[*]
283283
$NewLine = strpos($Str, "\n", $NewLine+1);
284-
} while($NewLine!== false && substr($Str, $NewLine+1, 3) == '[*]');
284+
} while($NewLine!== false && substr($Str, $NewLine+1, 3) == '['.$TagName.']');
285285

286286
$CloseTag = $NewLine;
287287
if($CloseTag === false) { // block finishes with list
@@ -386,9 +386,12 @@ function parse($Str) {
386386
case 'hide':
387387
$Array[$ArrayPos] = array('Type'=>'hide', 'Attr'=>$Attrib, 'Val'=>$this->parse($Block));
388388
break;
389+
case '#':
389390
case '*':
390391
$Array[$ArrayPos] = array('Type'=>'list');
391-
$Array[$ArrayPos]['Val'] = explode('[*]', $Block);
392+
$Array[$ArrayPos]['Val'] = explode('['.$TagName.']', $Block);
393+
$Array[$ArrayPos]['ListType'] = $TagName === '*' ? 'ul' : 'ol';
394+
$Array[$ArrayPos]['Tag'] = $TagName;
392395
foreach($Array[$ArrayPos]['Val'] as $Key=>$Val) {
393396
$Array[$ArrayPos]['Val'][$Key] = $this->parse(trim($Val));
394397
}
@@ -438,6 +441,9 @@ function to_html($Array) {
438441
case 's':
439442
$Str.='<span style="text-decoration: line-through">'.$this->to_html($Block['Val']).'</span>';
440443
break;
444+
case 'important':
445+
$Str.='<strong class="important_text">'.$this->to_html($Block['Val']).'</strong>';
446+
break;
441447
case 'user':
442448
$Str.='<a href="user.php?action=search&amp;search='.urlencode($Block['Val']).'">'.$Block['Val'].'</a>';
443449
break;
@@ -460,12 +466,12 @@ function to_html($Array) {
460466
$Str.='<code>'.$Block['Val'].'</code>';
461467
break;
462468
case 'list':
463-
$Str .= '<ul>';
469+
$Str .= '<'.$Block['ListType'].'>';
464470
foreach($Block['Val'] as $Line) {
465471

466472
$Str.='<li>'.$this->to_html($Line).'</li>';
467473
}
468-
$Str.='</ul>';
474+
$Str.='</'.$Block['ListType'].'>';
469475
break;
470476
case 'align':
471477
$ValidAttribs = array('left', 'center', 'right');
@@ -514,9 +520,9 @@ function to_html($Array) {
514520
$Str.='[img]'.$Block['Val'].'[/img]';
515521
} else {
516522
if(check_perms('site_proxy_images')) {
517-
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Block['Val']).'" />';
523+
$Str.='<img class="scale_image" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Block['Val']).'" />';
518524
} else {
519-
$Str.='<img style="max-width: 500px;" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.$Block['Val'].'" />';
525+
$Str.='<img class="scale_image" onclick="lightbox.init(this,500);" alt="'.$Block['Val'].'" src="'.$Block['Val'].'" />';
520526
}
521527
}
522528
break;
@@ -614,7 +620,7 @@ function raw_text($Array) {
614620
break;
615621
case 'list':
616622
foreach($Block['Val'] as $Line) {
617-
$Str.='*'.$this->raw_text($Line);
623+
$Str.=$Block['Tag'].$this->raw_text($Line);
618624
}
619625
break;
620626

classes/class_torrent_form.php

+24
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ function music_form($GenreTags) {
182182
$BadTags = $Torrent['BadTags'];
183183
$BadFolders = $Torrent['BadFolders'];
184184
$BadFiles = $Torrent['BadFiles'];
185+
$CassetteApproved = $Torrent['CassetteApproved'];
186+
$LossymasterApproved = $Torrent['LossymasterApproved'];
185187
global $ReleaseTypes;
186188
?>
187189
<table cellpadding="3" cellspacing="1" border="0" class="border<? if($this->NewTorrent) { echo ' slice'; }?>" width="100%">
@@ -376,6 +378,16 @@ function music_form($GenreTags) {
376378
</span>
377379
</td>
378380
</tr>
381+
<tr>
382+
<td class="label">Vanity House</td>
383+
<td>
384+
<label><input type="checkbox" id="vanity_house" name="vanity_house" <?=( check_perms('torrents_edit_vanityhouse') ? $this->DisabledInputA : 'disabled="disabled"' )?> <? if($Torrent['VanityHouse']){ echo "checked='checked' ";}?>/>
385+
Check this only if you are the submitting artist or submitting on behalf of the artist and this is intended to be a Vanity House release. Checking this will also automatically add the group as a recommendation.</label>
386+
<? if ( ! check_perms('torrents_edit_vanityhouse') ) { ?>
387+
<p>You do not have permission to mark albums as vanity house. <a href="wiki.php?action=article&id=282">More information about vanity house</a></p>
388+
<? } ?>
389+
</td>
390+
</tr>
379391
<tr>
380392
<td class="label">Media</td>
381393
<td>
@@ -473,6 +485,18 @@ function music_form($GenreTags) {
473485
<input type="checkbox" id="bad_files" name="bad_files"<? if ($BadFiles) {echo " checked='checked'";}?>/> Check this box if the torrent has bad file names.
474486
</td>
475487
</tr>
488+
<tr>
489+
<td class="label">Cassette Approved</td>
490+
<td>
491+
<input type="checkbox" id="cassette_approved" name="cassette_approved"<? if ($CassetteApproved) {echo " checked='checked'";}?>/> Check this box if the torrent is an approved cassette rip.
492+
</td>
493+
</tr>
494+
<tr>
495+
<td class="label">Lossy master Approved</td>
496+
<td>
497+
<input type="checkbox" id="lossymaster_approved" name="lossymaster_approved"<? if ($LossymasterApproved) {echo " checked='checked'";}?>/> Check this box if the torrent is an approved lossy master.
498+
</td>
499+
</tr>
476500
<? } ?>
477501
<? if($this->NewTorrent) { ?>
478502
<tr>

classes/class_user_rank.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ class USER_RANK {
99
function build_table($MemKey, $Query) {
1010
global $Cache,$DB;
1111

12-
$DB->query("DROP TEMPORARY TABLE IF EXISTS stats");
12+
$DB->query("DROP TEMPORARY TABLE IF EXISTS temp_stats");
1313

14-
$DB->query("CREATE TEMPORARY TABLE stats
14+
$DB->query("CREATE TEMPORARY TABLE temp_stats
1515
(ID int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
1616
Val bigint(20) NOT NULL);");
1717

18-
$DB->query("INSERT INTO stats (Val) ".$Query);
18+
$DB->query("INSERT INTO temp_stats (Val) ".$Query);
1919

20-
$DB->query("SELECT COUNT(ID) FROM stats");
20+
$DB->query("SELECT COUNT(ID) FROM temp_stats");
2121
list($UserCount) = $DB->next_record();
2222

23-
$DB->query("SELECT MIN(Val) FROM stats GROUP BY CEIL(ID/(".(int)$UserCount."/100));");
23+
$DB->query("SELECT MIN(Val) FROM temp_stats GROUP BY CEIL(ID/(".(int)$UserCount."/100));");
2424

2525
$Table = $DB->to_array();
2626

classes/config.template

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ date_default_timezone_set('UTC');
55
define('SITE_NAME', ''); //The name of your site
66
define('NONSSL_SITE_URL', ''); //The FQDN of your site
77
define('SSL_SITE_URL', ''); //The FQDN of your site, make this different if you are using a subdomain for ssl
8+
define('SITE_IP', ''); //The IP address by which your site can be publicly accessed
89
define('SERVER_ROOT', '/path'); //The root of the server, used for includes, purpose is to shorten the path string
910
define('ANNOUNCE_URL', 'http://'.NONSSL_SITE_URL.':2710'); //Announce URL
1011

@@ -56,6 +57,8 @@ define('DEBUG_MODE', false); //Set to false if you dont want everyone to see deb
5657
define('OPEN_REGISTRATION', true); //Set to false to disable open regirstration, true to allow anyone to register
5758
define('USER_LIMIT', 5000); //The maximum number of users the site can have, 0 for no limit
5859
define('STARTING_INVITES', 0); //# of invites to give to newly registered users
60+
define('BLOCK_TOR', false); //Set to true to block Tor users
61+
define('BLOCK_OPERA_MINI', false); //Set to true to block Opera Mini proxy
5962
define('DONOR_INVITES', 2);
6063

6164
// User class IDs needed for automatic promotions. Found in the 'permissions' table

classes/permissions_form.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
'edit_unknowns' => 'Can edit unknown release information.',
102102
'forums_polls_create' => 'Can create polls in the forums.',
103103
'forums_polls_moderate' => 'Can feature and close polls.',
104-
'project_team' => 'Is part of the project team.'
104+
'project_team' => 'Is part of the project team.',
105+
'torrents_edit_vanityhouse' => 'Can mark groups as part of Vanity House.',
106+
'artist_edit_vanityhouse' => 'Can mark Artists as part of Vanity House.'
105107

106108
);
107109

@@ -213,6 +215,8 @@ function permissions_form(){ ?>
213215
<? display_perm('torrents_search_fast', 'Unlimit search frequency (for scripts).'); ?>
214216
<? display_perm('torrents_add_artist', 'Can add artists to any group.'); ?>
215217
<? display_perm('edit_unknowns', 'Can edit unknown release information.'); ?>
218+
<? display_perm('torrents_edit_vanityhouse', 'Can mark groups as part of Vanity House.'); ?>
219+
<? display_perm('artist_edit_vanityhouse', 'Can mark Artists as part of Vanity House.'); ?>
216220
<? display_perm('site_add_logs', 'Can add logs to torrents after upload'); ?>
217221
</td>
218222
</tr>

classes/script_start.php

+75-23
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,8 @@
162162
($LoggedUser['BytesDownloaded']*$LoggedUser['RequiredRatio'])>$LoggedUser['BytesUploaded']
163163
);
164164

165-
// Manage 'special' inherited permissions
166-
if($LoggedUser['Artist']) {
167-
$ArtistPerms = get_permissions(ARTIST);
168-
} else {
169-
$ArtistPerms['Permissions'] = array();
170-
}
171-
172-
if($LoggedUser['Donor']) {
173-
$DonorPerms = get_permissions(DONOR);
174-
} else {
175-
$DonorPerms['Permissions'] = array();
176-
}
177-
178-
if(is_array($LoggedUser['CustomPermissions'])) {
179-
$CustomPerms = $LoggedUser['CustomPermissions'];
180-
} else {
181-
$CustomPerms = array();
182-
}
183-
184165
//Load in the permissions
185-
$LoggedUser['Permissions'] = array_merge($LoggedUser['Permissions'], $DonorPerms['Permissions'], $ArtistPerms['Permissions'], $CustomPerms);
166+
$LoggedUser['Permissions'] = get_permissions_for_user($LoggedUser['ID'], $LoggedUser['CustomPermissions']);
186167

187168
//Change necessary triggers in external components
188169
$Cache->CanClear = check_perms('admin_clear_cache');
@@ -355,6 +336,8 @@ function user_heavy_info($UserID) {
355336

356337
if (!empty($HeavyInfo['CustomPermissions'])) {
357338
$HeavyInfo['CustomPermissions'] = unserialize($HeavyInfo['CustomPermissions']);
339+
} else {
340+
$HeavyInfo['CustomPermissions'] = array();
358341
}
359342

360343
if (!empty($HeavyInfo['RestrictedForums'])) {
@@ -387,9 +370,51 @@ function get_permissions($PermissionID) {
387370
return $Permission;
388371
}
389372

373+
function get_permissions_for_user($UserID, $CustomPermissions = false) {
374+
global $DB;
375+
376+
$UserInfo = user_info($UserID);
377+
378+
if ($CustomPermissions === false) {
379+
$DB->query('SELECT um.CustomPermissions FROM users_main AS um WHERE um.ID = '.((int)$UserID));
380+
381+
list($CustomPermissions) = $DB->next_record(MYSQLI_NUM, false);
382+
}
383+
384+
if (!empty($CustomPermissions) && !is_array($CustomPermissions)) {
385+
$CustomPermissions = unserialize($CustomPermissions);
386+
}
387+
388+
$Permissions = get_permissions($UserInfo['PermissionID']);
389+
390+
391+
// Manage 'special' inherited permissions
392+
if($UserInfo['Artist']) {
393+
$ArtistPerms = get_permissions(ARTIST);
394+
} else {
395+
$ArtistPerms = array('Permissions' => array());
396+
}
397+
398+
if($UserInfo['Donor']) {
399+
$DonorPerms = get_permissions(DONOR);
400+
} else {
401+
$DonorPerms = array('Permissions' => array());
402+
}
403+
404+
if(!empty($CustomPermissions)) {
405+
$CustomPerms = $CustomPermissions;
406+
} else {
407+
$CustomPerms = array();
408+
}
409+
410+
//Combine the permissions
411+
return array_merge($Permissions['Permissions'], $DonorPerms['Permissions'], $ArtistPerms['Permissions'], $CustomPerms);
412+
}
413+
414+
// This function is slow. Don't call it unless somebody's logging in.
390415
function site_ban_ip($IP) {
391416
global $DB, $Cache;
392-
$IP = ip2unsigned($IP);
417+
$IPNum = ip2unsigned($IP);
393418
$IPBans = $Cache->get_value('ip_bans');
394419
if(!is_array($IPBans)) {
395420
$DB->query("SELECT ID, FromIP, ToIP FROM ip_bans");
@@ -398,7 +423,17 @@ function site_ban_ip($IP) {
398423
}
399424
foreach($IPBans as $Index => $IPBan) {
400425
list($ID, $FromIP, $ToIP) = $IPBan;
401-
if($IP >= $FromIP && $IP <= $ToIP) {
426+
if($IPNum >= $FromIP && $IPNum <= $ToIP) {
427+
return true;
428+
}
429+
}
430+
if (BLOCK_TOR) {
431+
$TorIPs = $Cache->get_value('tor_ips');
432+
if (!is_array($TorIPs)) {
433+
$TorIPs = file('https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=' . SITE_IP, FILE_IGNORE_NEW_LINES);
434+
$Cache->cache_value('tor_ips', $TorIPs, 3600 * 4);
435+
}
436+
if (in_array($IP, $TorIPs)) {
402437
return true;
403438
}
404439
}
@@ -480,6 +515,21 @@ function get_host($IP) {
480515
return '<span id="host_'.$ID.'">Resolving host...<script type="text/javascript">ajax.get(\'tools.php?action=get_host&ip='.$IP.'\',function(host){$(\'#host_'.$ID.'\').raw().innerHTML=host;});</script></span>';
481516
}
482517

518+
function lookup_ip($IP) {
519+
//TODO: use the $Cache
520+
$Output = explode(' ',shell_exec('host -W 1 '.escapeshellarg($IP)));
521+
if(count($Output) == 1 && empty($Output[0])) {
522+
//No output at all implies the command failed
523+
return '';
524+
}
525+
526+
if(count($Output) != 5) {
527+
return false;
528+
} else {
529+
return $Output[4];
530+
}
531+
}
532+
483533
function get_cc($IP) {
484534
static $ID = 0;
485535
++$ID;
@@ -1044,6 +1094,8 @@ function delete_torrent($ID, $GroupID=0) {
10441094
$DB->query("DELETE FROM torrents_bad_tags WHERE TorrentID = ".$ID);
10451095
$DB->query("DELETE FROM torrents_bad_folders WHERE TorrentID = ".$ID);
10461096
$DB->query("DELETE FROM torrents_bad_files WHERE TorrentID = ".$ID);
1097+
$DB->query("DELETE FROM torrents_cassette_approved WHERE TorrentID = ".$ID);
1098+
$DB->query("DELETE FROM torrents_lossymaster_approved WHERE TorrentID = ".$ID);
10471099
$Cache->delete_value('torrent_download_'.$ID);
10481100
$Cache->delete_value('torrent_group_'.$GroupID);
10491101
$Cache->delete_value('torrents_details_'.$GroupID);
@@ -1582,7 +1634,7 @@ function get_groups($GroupIDs, $Return = true, $GetArtists = true) {
15821634
*/
15831635

15841636
if(count($NotFound)>0) {
1585-
$DB->query("SELECT g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType FROM torrents_group AS g WHERE g.ID IN ($IDs)");
1637+
$DB->query("SELECT g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse FROM torrents_group AS g WHERE g.ID IN ($IDs)");
15861638

15871639
while($Group = $DB->next_record(MYSQLI_ASSOC, true)) {
15881640
unset($NotFound[$Group['ID']]);

0 commit comments

Comments
 (0)