Empty commit

This commit is contained in:
Git 2012-11-03 08:00:19 +00:00
parent b45bc4775d
commit 1537e69d8c
10 changed files with 204 additions and 96 deletions

View File

@ -45,14 +45,9 @@ public function profile($Automatic='') {
$Reason[] = 'Requested by '.$LoggedUser['Username'];
}
$this->Perf['Memory usage'] = (($Ram>>10)/1024)." MB";
$this->Perf['Page process time'] = (round($Micro)/1000)." s";
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
global $CPUTimeStart;
$RUsage = getrusage();
$this->Perf['CPU time'] = (round(($RUsage["ru_utime.tv_sec"]*1000000 + $RUsage['ru_utime.tv_usec'] - $CPUTimeStart)/1000)/1000)." s";
}
$this->Perf['Memory usage'] = (($Ram>>10)/1024).' MB';
$this->Perf['Page process time'] = number_format($Micro / 1000, 3).' s';
$this->Perf['CPU time'] = number_format($this->get_cpu_time() / 1000000, 3).' s';
if (isset($Reason[0])) {
$this->analysis(implode(', ', $Reason));
@ -86,6 +81,16 @@ public function analysis($Message, $Report='', $Time=43200) {
send_irc('PRIVMSG '.LAB_CHAN.' :'.$Message.' '.$Document.' '.' https://'.SSL_SITE_URL.'/tools.php?action=analysis&case='.$Identifier.' https://'.SSL_SITE_URL.$_SERVER['REQUEST_URI']);
}
public function get_cpu_time() {
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
global $CPUTimeStart;
$RUsage = getrusage();
$CPUTime = $RUsage['ru_utime.tv_sec']*1000000 + $RUsage['ru_utime.tv_usec'] - $CPUTimeStart;
return $CPUTime;
}
return false;
}
public function log_var($Var, $VarName = FALSE) {
$BackTrace = debug_backtrace();
$ID = uniqid();
@ -98,7 +103,7 @@ public function log_var($Var, $VarName = FALSE) {
public function set_flag($Event) {
global $ScriptStartTime;
$this->Flags[] = array($Event,(microtime(true)-$ScriptStartTime)*1000,memory_get_usage(true));
$this->Flags[] = array($Event, (microtime(true)-$ScriptStartTime)*1000, memory_get_usage(true), $this->get_cpu_time());
}
//This isn't in the constructor because $this is not available, and the function cannot be made static
@ -202,14 +207,12 @@ public function get_perf() {
if (empty($this->Perf)) {
global $ScriptStartTime;
$PageTime = (microtime(true) - $ScriptStartTime);
$Perf = array();
$Perf['Memory usage'] = Format::get_size(memory_get_usage(true));
$Perf['Page process time'] = number_format($PageTime, 3).' s';
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
global $CPUTimeStart;
$RUsage = getrusage();
$CPUTime = ($RUsage["ru_utime.tv_sec"]*1000000 + $RUsage['ru_utime.tv_usec'] - $CPUTimeStart) / 1000000;
$Perf['CPU time'] = number_format($CPUTime, 3)." s";
$CPUTime = $this->get_cpu_time();
$Perf = array(
'Memory usage' => Format::get_size(memory_get_usage(true)),
'Page process time' => number_format($PageTime, 3).' s');
if ($CPUTime) {
$Perf['CPU time'] = number_format($CPUTime / 1000000, 3).' s';
}
return $Perf;
}
@ -404,13 +407,24 @@ public function flag_table($Flags=false) {
</tr>
</table>
<table id="debug_flags" class="debug_table hidden" width="100%">
<tr valign="top">
<td align="left" class="debug_flags_event"><strong>Event</strong></td>
<td align="left" class="debug_flags_time"><strong>Page time</strong></td>
<? if ($Flags[0][3] !== false) { ?>
<td align="left" class="debug_flags_time"><strong>CPU time</strong></td>
<? } ?>
<td align="left" class="debug_flags_memory"><strong>Memory</strong></td>
</tr>
<?
foreach ($Flags as $Flag) {
list($Event,$MicroTime,$Memory) = $Flag;
list($Event, $MicroTime, $Memory, $CPUTime) = $Flag;
?>
<tr valign="top">
<td align="left"><?=$Event?></td>
<td align="left"><?=$MicroTime?> ms</td>
<td align="left"><?=number_format($MicroTime, 3)?> ms</td>
<? if ($CPUTime !== false) { ?>
<td align="left"><?=number_format($CPUTime / 1000, 3)?> ms</td>
<? } ?>
<td align="left"><?=Format::get_size($Memory)?></td>
</tr>
<?
@ -461,7 +475,7 @@ public function cache_table($CacheKeys=false) {
<table id="debug_cache" class="debug_table hidden" width="100%">
<? foreach($CacheKeys as $Key) { ?>
<tr>
<td align="left">
<td align="left" class="debug_info debug_cache_key">
<a href="#" onclick="$('#debug_cache_<?=$Key?>').toggle(); return false;"><?=display_str($Key)?></a>
</td>
<td align="left" class="debug_data debug_cache_data">
@ -492,9 +506,15 @@ public function error_table($Errors=false) {
list($Error,$Location,$Call,$Args) = $Error;
?>
<tr valign="top">
<td align="left"><?=display_str($Call)?>(<?=display_str($Args)?>)</td>
<td class="debug_data debug_error_data" align="left"><?=display_str($Error)?></td>
<td align="left"><?=display_str($Location)?></td>
<td align="left" class="debug_info debug_error_call">
<?=display_str($Call)?>(<?=display_str($Args)?>)
</td>
<td class="debug_data debug_error_data" align="left">
<?=display_str($Error)?>
</td>
<td align="left">
<?=display_str($Location)?>
</td>
</tr>
<?
}
@ -526,7 +546,7 @@ public function query_table($Queries=false) {
?>
<tr valign="top">
<td class="debug_data debug_query_data"><div><?=str_replace("\t", '&nbsp;&nbsp;', nl2br(display_str($SQL)))?></div></td>
<td class="rowa" style="width:130px;" align="left"><?=number_format($Time, 5)?> ms</td>
<td class="rowa debug_info debug_query_time" style="width:130px;" align="left"><?=number_format($Time, 5)?> ms</td>
</tr>
<?
}
@ -561,7 +581,7 @@ public function sphinx_table($Queries=false) {
?>
<tr valign="top">
<td class="debug_data debug_sphinx_data"><pre><?=str_replace("\t", ' ', $Params)?></pre></td>
<td class="rowa" style="width:130px;" align="left"><?=number_format($Time, 5)?> ms</td>
<td class="rowa debug_info debug_sphinx_time" style="width:130px;" align="left"><?=number_format($Time, 5)?> ms</td>
</tr>
<?
}
@ -593,7 +613,7 @@ public function vars_table($Vars=false) {
$Size = count($Data['data']);
?>
<tr>
<td align="left">
<td align="left" class="debug_info debug_loggedvars_name">
<a href="#" onclick="$('#debug_loggedvars_<?=$ID?>').toggle(); return false;"><?=display_str($Key)?></a> (<?=$Size . ($Size == 1 ? ' element' : ' elements')?>)
<div><?=$Data['bt']['path'].':'.$Data['bt']['line'];?></div>
</td>

View File

@ -355,11 +355,31 @@ public static function update_hash($GroupID) {
GROUP BY t.GroupID)
WHERE ID='$GroupID'");
// Fetch album vote score
$DB->query("SELECT Score FROM torrents_votes WHERE GroupID=$GroupID");
if ($DB->record_count()) {
list($VoteScore) = $DB->next_record();
} else {
$VoteScore = 0;
}
// Fetch album artists
$DB->query("SELECT GROUP_CONCAT(aa.Name separator ' ')
FROM torrents_artists AS ta
JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
WHERE ta.GroupID=$GroupID AND ta.Importance IN ('1', '4', '5', '6')
GROUP BY ta.GroupID");
if ($DB->record_count()) {
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
} else {
$ArtistName = '';
}
$DB->query("REPLACE INTO sphinx_delta
(ID, GroupID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel,
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore,
Scene, HasLog, HasCue, FreeTorrent, Media, Format, Encoding, RemasterYear,
RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, FileList)
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore, Scene,
HasLog, HasCue, FreeTorrent, Media, Format, Encoding, RemasterYear, RemasterTitle,
RemasterRecordLabel, RemasterCatalogueNumber, FileList, VoteScore, ArtistName)
SELECT
t.ID, g.ID, Name, TagList, Year, CategoryID, UNIX_TIMESTAMP(t.Time), ReleaseType,
RecordLabel, CatalogueNumber, VanityHouse, Size >> 10 AS Size, Snatched, Seeders,
@ -371,12 +391,12 @@ public static function update_hash($GroupID) {
'.mp3', ' .mp3'),
'|||', '\n '),
'_', ' ')
AS FileList
AS FileList, $VoteScore, '".db_string($ArtistName)."'
FROM torrents AS t
JOIN torrents_group AS g ON g.ID=t.GroupID
WHERE g.ID=$GroupID");
$DB->query("INSERT INTO sphinx_delta
/* $DB->query("INSERT INTO sphinx_delta
(ID, ArtistName)
SELECT torrents.ID, artists.ArtistName FROM (
SELECT
@ -389,7 +409,7 @@ public static function update_hash($GroupID) {
) AS artists
JOIN torrents USING(GroupID)
ON DUPLICATE KEY UPDATE ArtistName=values(ArtistName)");
*/
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_group_'.$GroupID);

View File

@ -53,7 +53,7 @@
$ScriptStartTime = microtime(true); //To track how long a page takes to create
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
$RUsage = getrusage();
$CPUTimeStart = $RUsage["ru_utime.tv_sec"]*1000000 + $RUsage['ru_utime.tv_usec'];
$CPUTimeStart = $RUsage['ru_utime.tv_sec']*1000000 + $RUsage['ru_utime.tv_usec'];
}
ob_start(); //Start a buffer, mainly in case there is a mysql error

View File

@ -115,8 +115,8 @@
</ul>
<ul id="userinfo_stats">
<li id="stats_seeding"><a href="torrents.php?type=seeding&amp;userid=<?=$LoggedUser['ID']?>">Up</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesUploaded'], 2)?></span></li>
<li id="stats_leeching"><a href="torrents.php?type=leeching&amp;userid=<?=$LoggedUser['ID']?>">Down</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesDownloaded'], 2)?></span></li>
<li id="stats_seeding"><a href="torrents.php?type=seeding&amp;userid=<?=$LoggedUser['ID']?>">Up</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span></li>
<li id="stats_leeching"><a href="torrents.php?type=leeching&amp;userid=<?=$LoggedUser['ID']?>">Down</a>: <span class="stat" title="<?=Format::get_size($LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size($LoggedUser['BytesDownloaded'])?></span></li>
<li id="stats_ratio">Ratio: <span class="stat"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span></li>
<? if(!empty($LoggedUser['RequiredRatio'])) {?>
<li id="stats_required"><a href="rules.php?p=ratio">Required</a>: <span class="stat" title="<?=number_format($LoggedUser['RequiredRatio'], 5)?>"><?=number_format($LoggedUser['RequiredRatio'], 2)?></span></li>

View File

@ -13,7 +13,7 @@ function AddTorrent($CollageID, $GroupID) {
$Sort+=10;
$DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID' AND GroupID='$GroupID'");
if($DB->record_count() == 0) {
if ($DB->record_count() == 0) {
$DB->query("INSERT IGNORE INTO collages_torrents
(CollageID, GroupID, UserID, Sort, AddedOn)
VALUES
@ -34,15 +34,28 @@ function AddTorrent($CollageID, $GroupID) {
}
$CollageID = $_POST['collageid'];
if(!is_number($CollageID)) { error(404); }
if (!is_number($CollageID)) {
error(404);
}
$DB->query("SELECT UserID, CategoryID, Locked, NumTorrents, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
list($UserID, $CategoryID, $Locked, $NumTorrents, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
if($CategoryID == 0 && $UserID!=$LoggedUser['ID'] && !check_perms('site_collages_delete')) { error(403); }
if($Locked) { error(403); }
if($MaxGroups>0 && $NumTorrents>=$MaxGroups) { error(403); }
if($MaxGroupsPerUser>0) {
$DB->query("SELECT COUNT(ID) FROM collages_torrents WHERE CollageID='$CollageID' AND UserID='$LoggedUser[ID]'");
if($DB->record_count()>=$MaxGroupsPerUser) {
if (!check_perms('site_collages_delete')) {
if ($Locked) {
$Err = "This collage is locked";
}
if ($CategoryID == 0 && $UserID != $LoggedUser['ID']) {
$Err = "You cannot edit someone else's personal collage";
}
if ($MaxGroups > 0 && $NumTorrents >= $MaxGroups) {
$Err = "This collage already holds its maximum allowed number of torrents";
}
}
if ($MaxGroupsPerUser > 0) {
$DB->query("SELECT COUNT(*) FROM collages_torrents WHERE CollageID='$CollageID' AND UserID='$LoggedUser[ID]'");
list($GroupsForUser) = $DB->next_record();
if (!check_perms('site_collages_delete') && $GroupsForUser >= $MaxGroupsPerUser) {
error(403);
}
}
@ -52,10 +65,8 @@ function AddTorrent($CollageID, $GroupID) {
$Val->SetFields('url', '1','regex','The URL must be a link to a torrent on the site.',array('regex'=>$URLRegex));
$Err = $Val->ValidateForm($_POST);
if($Err) {
if ($Err) {
error($Err);
header('Location: collages.php?id='.$CollageID);
die();
}
$URL = $_POST['url'];
@ -63,12 +74,14 @@ function AddTorrent($CollageID, $GroupID) {
// Get torrent ID
$URLRegex = '/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i';
preg_match($URLRegex, $URL, $Matches);
$TorrentID=$Matches[2];
if(!$TorrentID || (int)$TorrentID == 0) { error(404); }
$TorrentID = $Matches[2];
if (!$TorrentID || (int)$TorrentID == 0) {
error(404);
}
$DB->query("SELECT ID FROM torrents_group WHERE ID='$TorrentID'");
list($GroupID) = $DB->next_record();
if(!$GroupID) {
if (!$GroupID) {
error('The torrent was not found in the database.');
}
@ -79,11 +92,24 @@ function AddTorrent($CollageID, $GroupID) {
$URLs = explode("\n",$_REQUEST['urls']);
$GroupIDs = array();
$Err = '';
foreach ($URLs as $URL) {
foreach ($URLs as $Key => &$URL) {
$URL = trim($URL);
if ($URL == '') { continue; }
if ($URL == '') {
unset($URLs[$Key]);
}
}
unset($URL);
if (!check_perms('site_collages_delete')) {
if ($MaxGroups > 0 && ($NumTorrents + count($URLs) > $MaxGroups)) {
$Err = "This collage can only hold $MaxGroups torrents.";
}
if ($MaxGroupsPerUser > 0 && ($GroupsForUser + count($URLs) > $MaxGroupsPerUser)) {
$Err = "You may only have $MaxGroupsPerUser torrents in this collage.";
}
}
foreach ($URLs as $URL) {
$Matches = array();
if (preg_match($URLRegex, $URL, $Matches)) {
$GroupIDs[] = $Matches[3];
@ -94,21 +120,18 @@ function AddTorrent($CollageID, $GroupID) {
}
$DB->query("SELECT ID FROM torrents_group WHERE ID='$GroupID'");
if(!$DB->record_count()) {
if (!$DB->record_count()) {
$Err = "One of the entered URLs ($URL) does not correspond to a torrent on the site.";
break;
}
}
if($Err) {
if ($Err) {
error($Err);
header('Location: collages.php?id='.$CollageID);
die();
}
foreach ($GroupIDs as $GroupID) {
AddTorrent($CollageID, $GroupID);
}
}
header('Location: collages.php?id='.$CollageID);

View File

@ -16,7 +16,9 @@ function compare($X, $Y){
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
$CollageID = $_GET['id'];
if(!is_number($CollageID)) { error(0); }
if (!is_number($CollageID)) {
error(0);
}
$Data = $Cache->get_value('collage_'.$CollageID);
@ -42,8 +44,8 @@ function compare($X, $Y){
}
if($CollageCategoryID == 0 && !check_perms('site_collages_delete')) {
if(!check_perms('site_collages_personal') || $CreatorID!=$LoggedUser['ID']) {
$Locked = true;
if(!check_perms('site_collages_personal') || $CreatorID != $LoggedUser['ID']) {
$PreventAdditions = true;
}
}
@ -331,8 +333,8 @@ function compare($X, $Y){
$Collage[]=ob_get_clean();
}
if(($MaxGroups>0 && $NumGroups>=$MaxGroups) || ($MaxGroupsPerUser>0 && $NumGroupsByUser>=$MaxGroupsPerUser)) {
$Locked = true;
if (!check_perms('site_collages_delete') && ($Locked || ($MaxGroups > 0 && $NumGroups >= $MaxGroups) || ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser))) {
$PreventAdditions = true;
}
// Silly hack for people who are on the old setting
@ -370,8 +372,10 @@ function compare($X, $Y){
<? if(check_perms('site_collages_subscribe')) { ?>
<a href="#" onclick="CollageSubscribe(<?=$CollageID?>);return false;" id="subscribelink<?=$CollageID?>">[<?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?>]</a>
<? }
if (check_perms('site_edit_wiki') && !$Locked) { ?>
if (check_perms('site_collages_delete') || (check_perms('site_edit_wiki') && !$Locked)) { ?>
<a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>">[Edit description]</a>
<? } else { ?>
[Locked]
<? }
if(has_bookmarked('collage', $CollageID)) {
?>
@ -463,7 +467,9 @@ function compare($X, $Y){
<div class="head"><strong>Stats</strong></div>
<ul class="stats nobullet">
<li>Torrents: <?=$NumGroups?></li>
<? if(count($Artists) >0) { ?> <li>Artists: <?=count($Artists)?></li> <? } ?>
<? if(count($Artists) >0) { ?>
<li>Artists: <?=count($Artists)?></li>
<? } ?>
<li>Built by <?=count($Users)?> user<?=(count($Users)>1) ? 's' : ''?></li>
</ul>
</div>
@ -524,7 +530,7 @@ function compare($X, $Y){
</div>
</div>
<? if(check_perms('site_collages_manage') && !$Locked) { ?>
<? if(check_perms('site_collages_manage') && !$PreventAdditions) { ?>
<div class="box box_addtorrent">
<div class="head"><strong>Add torrent</strong><span style="float: right"><a href="#" onclick="$('.add_torrent_container').toggle_class('hidden'); this.innerHTML = (this.innerHTML == '[Batch Add]'?'[Individual Add]':'[Batch Add]'); return false;">[Batch Add]</a></span></div>
<div class="pad add_torrent_container">

View File

@ -1,14 +1,28 @@
<?
$CollageID = $_GET['collageid'];
if(!is_number($CollageID)) { error(0); }
if (!empty($_GET['collageid']) && is_number($_GET['collageid'])) {
$CollageID = $_GET['collageid'];
}
if (!is_number($CollageID)) {
error(0);
}
$DB->query("SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured FROM collages WHERE ID='$CollageID'");
list($Name, $Description, $TagList, $UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Featured) = $DB->next_record();
$TagList = implode(', ', explode(' ', $TagList));
if($CategoryID == 0 && $UserID!=$LoggedUser['ID'] && !check_perms('site_collages_delete')) { error(403); }
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403);
}
View::show_header('Edit collage');
if (!empty($Err)) {
if (isset($ErrNoEscape)) {
echo '<div class="save_message error">'.$Err.'</div>';
} else {
echo '<div class="save_message error">'.display_str($Err).'</div>';
}
}
?>
<div class="thin">
<div class="header">
@ -24,16 +38,19 @@
<td class="label">Name</td>
<td><input type="text" name="name" size="60" value="<?=$Name?>" /></td>
</tr>
<? } ?>
<? if($CategoryID>0 || check_perms('site_collages_delete')) { ?>
<? }
if($CategoryID > 0 || check_perms('site_collages_delete')) { ?>
<tr>
<td class="label"><strong>Category</strong></td>
<td>
<select name="category">
<?
foreach($CollageCats as $CatID=>$CatName) {
if (!check_perms('site_collages_delete') && $CatID == 0) { continue; } // Only mod-type get to make things personal ?>
<option value="<?=$CatID?>" <? if($CatID == $CategoryID) { echo ' selected="selected"'; }?>><?=$CatName?></option>
<? foreach ($CollageCats as $CatID => $CatName) {
if (!check_perms('site_collages_delete') && $CatID == 0) {
// Only mod-type get to make things personal
continue;
}
?>
<option value="<?=$CatID?>" <?=$CatID == $CategoryID ? ' selected="selected"' : ''?>><?=$CatName?></option>
<? } ?>
</select>
</td>
@ -49,16 +66,16 @@
<td class="label">Tags</td>
<td><input type="text" name="tags" size="60" value="<?=$TagList?>" /></td>
</tr>
<? if($CategoryID == 0) { // CategoryID==0 is "Personal" collages ?>
<? if ($CategoryID == 0) { // CategoryID==0 is "Personal" collages ?>
<tr>
<td class="label"><span title="A &quot;featured&quot; personal collage will be listed first on your profile.">Featured</span></td>
<td><input type="checkbox" name="featured" <?=($Featured?'checked':'')?> /></td>
</tr>
<? }
if(check_perms('site_collages_delete')) { ?>
if(check_perms('site_collages_delete')) { ?>
<tr>
<td class="label"><span title="This feature has not been implemented yet. It currently does nothing.">Locked</span></td>
<td><input type="checkbox" name="locked" <?if($Locked) { ?>checked="checked" <? }?>/></td>
<td class="label">Locked</td>
<td><input type="checkbox" name="locked" <?=$Locked ? 'checked="checked" ' : ''?>/></td>
</tr>
<tr>
<td class="label">Max groups</td>

View File

@ -2,49 +2,71 @@
authorize();
$CollageID = $_POST['collageid'];
if(!is_number($CollageID)) { error(0); }
if (!is_number($CollageID)) {
error(0);
}
$DB->query("SELECT UserID, CategoryID FROM collages WHERE ID='$CollageID'");
list($UserID, $CategoryID) = $DB->next_record();
if($CategoryID == 0 && $UserID!=$LoggedUser['ID'] && !check_perms('site_collages_delete')) { error(403); }
$DB->query("SELECT UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
list($UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403);
}
$DB->query("SELECT ID,Deleted FROM collages WHERE Name='".db_string($_POST['name'])."' AND ID!='$CollageID' LIMIT 1");
if($DB->record_count()) {
if ($DB->record_count()) {
list($ID, $Deleted) = $DB->next_record();
if($Deleted) {
if ($Deleted) {
$Err = 'A collage with that name already exists but needs to be recovered, please <a href="staffpm.php">contact</a> the staff team!';
} else {
$Err = "A collage with that name already exists: <a href=\"/collages.php?id=$ID\">$ID</a>.";
$Err = "A collage with that name already exists: <a href=\"/collages.php?id=$ID\">$_POST[name]</a>.";
}
$ErrNoEscape = true;
include(SERVER_ROOT.'/sections/collages/edit.php');
die();
}
$TagList = explode(',',$_POST['tags']);
foreach($TagList as $ID=>$Tag) {
foreach ($TagList as $ID=>$Tag) {
$TagList[$ID] = Misc::sanitize_tag($Tag);
}
$TagList = implode(' ',$TagList);
$DB->query("UPDATE collages SET Description='".db_string($_POST['description'])."', TagList='$TagList' WHERE ID='$CollageID'");
$Updates = array("Description='".db_string($_POST['description'])."', TagList='".db_string($TagList)."'");
if (!check_perms('site_collages_delete') && ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) {
if(!stristr($_POST['name'], $LoggedUser['Username'])) {
if (!stristr($_POST['name'], $LoggedUser['Username'])) {
error("Your personal collage's title must include your username.");
}
}
if (isset($_POST['featured']) && $CategoryID == 0 && (($LoggedUser['ID'] == $UserID && check_perms('site_collages_personal')) || check_perms('site_collages_delete'))) {
$DB->query("UPDATE collages SET Featured=0 WHERE CategoryID=0 and UserID=$UserID");
$DB->query("UPDATE collages SET Featured=1 WHERE ID=$CollageID");
$Updates[] = 'Featured=1';
}
if (check_perms('site_collages_delete') || ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) {
$DB->query("UPDATE collages SET Name='".db_string($_POST['name'])."' WHERE ID='$CollageID'");
$Updates[] = "Name='".db_string($_POST['name'])."'";
}
if(isset($_POST['category']) && !empty($CollageCats[$_POST['category']]) && $_POST['category']!=$CategoryID && ($_POST['category']!=0 || check_perms('site_collages_delete'))) {
$DB->query("UPDATE collages SET CategoryID='".db_string($_POST['category'])."' WHERE ID='$CollageID'");
if (isset($_POST['category']) && !empty($CollageCats[$_POST['category']]) && $_POST['category'] != $CategoryID && ($_POST['category'] != 0 || check_perms('site_collages_delete'))) {
$Updates[] = 'CategoryID='.$_POST['category'];
}
if (check_perms('site_collages_delete')) {
if (isset($_POST['locked']) != $Locked) {
$Updates[] = 'Locked=' . ($Locked ? "'0'" : "'1'");
}
if (isset($_POST['maxgroups']) && ($_POST['maxgroups'] == 0 || is_number($_POST['maxgroups'])) && $_POST['maxgroups'] != $MaxGroups) {
$Updates[] = 'MaxGroups=' . $_POST['maxgroups'];
}
if (isset($_POST['maxgroups']) && ($_POST['maxgroupsperuser'] == 0 || is_number($_POST['maxgroupsperuser'])) && $_POST['maxgroupsperuser'] != $MaxGroupsPerUser) {
$Updates[] = 'MaxGroupsPerUser=' . $_POST['maxgroupsperuser'];
}
}
if (!empty($Updates)) {
$DB->query("UPDATE collages SET ".implode(', ', $Updates)." WHERE ID=$CollageID");
}
$Cache->delete_value('collage_'.$CollageID);
header('Location: collages.php?id='.$CollageID);
?>

View File

@ -462,7 +462,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
<div title="<?=ucfirst(str_replace('.',' ',$TagList[0]))?>" class="cats_<?=strtolower(str_replace(array('-',' '),array('',''),$Categories[$CategoryID-1]))?> tags_<?=str_replace('.','_',$TagList[0])?>"></div>
</td>
<td>
<span style="float: right;">
<span class="torrent_links_block">
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" title="Report">RP</a> ]
</span>

View File

@ -226,10 +226,10 @@ function check_paranoia_here($Setting) {
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?>>Last seen: <?=$LastAccess?></li>
<? } ?>
<? if (($Override=check_paranoia_here('uploaded'))) { ?>
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?> title="<?=Format::get_size($Uploaded, 5)?>">Uploaded: <?=Format::get_size($Uploaded, 2)?></li>
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?> title="<?=Format::get_size($Uploaded, 5)?>">Uploaded: <?=Format::get_size($Uploaded)?></li>
<? } ?>
<? if (($Override=check_paranoia_here('downloaded'))) { ?>
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?> title="<?=Format::get_size($Downloaded, 5)?>">Downloaded: <?=Format::get_size($Downloaded, 2)?></li>
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?> title="<?=Format::get_size($Downloaded, 5)?>">Downloaded: <?=Format::get_size($Downloaded)?></li>
<? } ?>
<? if (($Override=check_paranoia_here('ratio'))) { ?>
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?>>Ratio: <?=Format::get_ratio_html($Uploaded, $Downloaded)?></li>