mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-14 03:16:25 +00:00
Empty commit
This commit is contained in:
parent
b45bc4775d
commit
1537e69d8c
@ -45,14 +45,9 @@ public function profile($Automatic='') {
|
|||||||
$Reason[] = 'Requested by '.$LoggedUser['Username'];
|
$Reason[] = 'Requested by '.$LoggedUser['Username'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Perf['Memory usage'] = (($Ram>>10)/1024)." MB";
|
$this->Perf['Memory usage'] = (($Ram>>10)/1024).' MB';
|
||||||
$this->Perf['Page process time'] = (round($Micro)/1000)." s";
|
$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 (!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";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($Reason[0])) {
|
if (isset($Reason[0])) {
|
||||||
$this->analysis(implode(', ', $Reason));
|
$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']);
|
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) {
|
public function log_var($Var, $VarName = FALSE) {
|
||||||
$BackTrace = debug_backtrace();
|
$BackTrace = debug_backtrace();
|
||||||
$ID = uniqid();
|
$ID = uniqid();
|
||||||
@ -98,7 +103,7 @@ public function log_var($Var, $VarName = FALSE) {
|
|||||||
|
|
||||||
public function set_flag($Event) {
|
public function set_flag($Event) {
|
||||||
global $ScriptStartTime;
|
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
|
//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)) {
|
if (empty($this->Perf)) {
|
||||||
global $ScriptStartTime;
|
global $ScriptStartTime;
|
||||||
$PageTime = (microtime(true) - $ScriptStartTime);
|
$PageTime = (microtime(true) - $ScriptStartTime);
|
||||||
$Perf = array();
|
$CPUTime = $this->get_cpu_time();
|
||||||
$Perf['Memory usage'] = Format::get_size(memory_get_usage(true));
|
$Perf = array(
|
||||||
$Perf['Page process time'] = number_format($PageTime, 3).' s';
|
'Memory usage' => Format::get_size(memory_get_usage(true)),
|
||||||
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
'Page process time' => number_format($PageTime, 3).' s');
|
||||||
global $CPUTimeStart;
|
if ($CPUTime) {
|
||||||
$RUsage = getrusage();
|
$Perf['CPU time'] = number_format($CPUTime / 1000000, 3).' s';
|
||||||
$CPUTime = ($RUsage["ru_utime.tv_sec"]*1000000 + $RUsage['ru_utime.tv_usec'] - $CPUTimeStart) / 1000000;
|
|
||||||
$Perf['CPU time'] = number_format($CPUTime, 3)." s";
|
|
||||||
}
|
}
|
||||||
return $Perf;
|
return $Perf;
|
||||||
}
|
}
|
||||||
@ -404,13 +407,24 @@ public function flag_table($Flags=false) {
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<table id="debug_flags" class="debug_table hidden" width="100%">
|
<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) {
|
foreach ($Flags as $Flag) {
|
||||||
list($Event,$MicroTime,$Memory) = $Flag;
|
list($Event, $MicroTime, $Memory, $CPUTime) = $Flag;
|
||||||
?>
|
?>
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
<td align="left"><?=$Event?></td>
|
<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>
|
<td align="left"><?=Format::get_size($Memory)?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
@ -461,7 +475,7 @@ public function cache_table($CacheKeys=false) {
|
|||||||
<table id="debug_cache" class="debug_table hidden" width="100%">
|
<table id="debug_cache" class="debug_table hidden" width="100%">
|
||||||
<? foreach($CacheKeys as $Key) { ?>
|
<? foreach($CacheKeys as $Key) { ?>
|
||||||
<tr>
|
<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>
|
<a href="#" onclick="$('#debug_cache_<?=$Key?>').toggle(); return false;"><?=display_str($Key)?></a>
|
||||||
</td>
|
</td>
|
||||||
<td align="left" class="debug_data debug_cache_data">
|
<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;
|
list($Error,$Location,$Call,$Args) = $Error;
|
||||||
?>
|
?>
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
<td align="left"><?=display_str($Call)?>(<?=display_str($Args)?>)</td>
|
<td align="left" class="debug_info debug_error_call">
|
||||||
<td class="debug_data debug_error_data" align="left"><?=display_str($Error)?></td>
|
<?=display_str($Call)?>(<?=display_str($Args)?>)
|
||||||
<td align="left"><?=display_str($Location)?></td>
|
</td>
|
||||||
|
<td class="debug_data debug_error_data" align="left">
|
||||||
|
<?=display_str($Error)?>
|
||||||
|
</td>
|
||||||
|
<td align="left">
|
||||||
|
<?=display_str($Location)?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -526,7 +546,7 @@ public function query_table($Queries=false) {
|
|||||||
?>
|
?>
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
<td class="debug_data debug_query_data"><div><?=str_replace("\t", ' ', nl2br(display_str($SQL)))?></div></td>
|
<td class="debug_data debug_query_data"><div><?=str_replace("\t", ' ', 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>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -561,7 +581,7 @@ public function sphinx_table($Queries=false) {
|
|||||||
?>
|
?>
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
<td class="debug_data debug_sphinx_data"><pre><?=str_replace("\t", ' ', $Params)?></pre></td>
|
<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>
|
</tr>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -593,7 +613,7 @@ public function vars_table($Vars=false) {
|
|||||||
$Size = count($Data['data']);
|
$Size = count($Data['data']);
|
||||||
?>
|
?>
|
||||||
<tr>
|
<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')?>)
|
<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>
|
<div><?=$Data['bt']['path'].':'.$Data['bt']['line'];?></div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -355,11 +355,31 @@ public static function update_hash($GroupID) {
|
|||||||
GROUP BY t.GroupID)
|
GROUP BY t.GroupID)
|
||||||
WHERE ID='$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
|
$DB->query("REPLACE INTO sphinx_delta
|
||||||
(ID, GroupID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel,
|
(ID, GroupID, GroupName, TagList, Year, CategoryID, Time, ReleaseType, RecordLabel,
|
||||||
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore,
|
CatalogueNumber, VanityHouse, Size, Snatched, Seeders, Leechers, LogScore, Scene,
|
||||||
Scene, HasLog, HasCue, FreeTorrent, Media, Format, Encoding, RemasterYear,
|
HasLog, HasCue, FreeTorrent, Media, Format, Encoding, RemasterYear, RemasterTitle,
|
||||||
RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, FileList)
|
RemasterRecordLabel, RemasterCatalogueNumber, FileList, VoteScore, ArtistName)
|
||||||
SELECT
|
SELECT
|
||||||
t.ID, g.ID, Name, TagList, Year, CategoryID, UNIX_TIMESTAMP(t.Time), ReleaseType,
|
t.ID, g.ID, Name, TagList, Year, CategoryID, UNIX_TIMESTAMP(t.Time), ReleaseType,
|
||||||
RecordLabel, CatalogueNumber, VanityHouse, Size >> 10 AS Size, Snatched, Seeders,
|
RecordLabel, CatalogueNumber, VanityHouse, Size >> 10 AS Size, Snatched, Seeders,
|
||||||
@ -371,12 +391,12 @@ public static function update_hash($GroupID) {
|
|||||||
'.mp3', ' .mp3'),
|
'.mp3', ' .mp3'),
|
||||||
'|||', '\n '),
|
'|||', '\n '),
|
||||||
'_', ' ')
|
'_', ' ')
|
||||||
AS FileList
|
AS FileList, $VoteScore, '".db_string($ArtistName)."'
|
||||||
FROM torrents AS t
|
FROM torrents AS t
|
||||||
JOIN torrents_group AS g ON g.ID=t.GroupID
|
JOIN torrents_group AS g ON g.ID=t.GroupID
|
||||||
WHERE g.ID=$GroupID");
|
WHERE g.ID=$GroupID");
|
||||||
|
|
||||||
$DB->query("INSERT INTO sphinx_delta
|
/* $DB->query("INSERT INTO sphinx_delta
|
||||||
(ID, ArtistName)
|
(ID, ArtistName)
|
||||||
SELECT torrents.ID, artists.ArtistName FROM (
|
SELECT torrents.ID, artists.ArtistName FROM (
|
||||||
SELECT
|
SELECT
|
||||||
@ -389,7 +409,7 @@ public static function update_hash($GroupID) {
|
|||||||
) AS artists
|
) AS artists
|
||||||
JOIN torrents USING(GroupID)
|
JOIN torrents USING(GroupID)
|
||||||
ON DUPLICATE KEY UPDATE ArtistName=values(ArtistName)");
|
ON DUPLICATE KEY UPDATE ArtistName=values(ArtistName)");
|
||||||
|
*/
|
||||||
$Cache->delete_value('torrents_details_'.$GroupID);
|
$Cache->delete_value('torrents_details_'.$GroupID);
|
||||||
$Cache->delete_value('torrent_group_'.$GroupID);
|
$Cache->delete_value('torrent_group_'.$GroupID);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
$ScriptStartTime = microtime(true); //To track how long a page takes to create
|
$ScriptStartTime = microtime(true); //To track how long a page takes to create
|
||||||
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||||
$RUsage = getrusage();
|
$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
|
ob_start(); //Start a buffer, mainly in case there is a mysql error
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@
|
|||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="userinfo_stats">
|
<ul id="userinfo_stats">
|
||||||
<li id="stats_seeding"><a href="torrents.php?type=seeding&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_seeding"><a href="torrents.php?type=seeding&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&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_leeching"><a href="torrents.php?type=leeching&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>
|
<li id="stats_ratio">Ratio: <span class="stat"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span></li>
|
||||||
<? if(!empty($LoggedUser['RequiredRatio'])) {?>
|
<? 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>
|
<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>
|
||||||
|
@ -34,15 +34,28 @@ function AddTorrent($CollageID, $GroupID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$CollageID = $_POST['collageid'];
|
$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'");
|
$DB->query("SELECT UserID, CategoryID, Locked, NumTorrents, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
|
||||||
list($UserID, $CategoryID, $Locked, $NumTorrents, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
|
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 (!check_perms('site_collages_delete')) {
|
||||||
if($MaxGroups>0 && $NumTorrents>=$MaxGroups) { error(403); }
|
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) {
|
if ($MaxGroupsPerUser > 0) {
|
||||||
$DB->query("SELECT COUNT(ID) FROM collages_torrents WHERE CollageID='$CollageID' AND UserID='$LoggedUser[ID]'");
|
$DB->query("SELECT COUNT(*) FROM collages_torrents WHERE CollageID='$CollageID' AND UserID='$LoggedUser[ID]'");
|
||||||
if($DB->record_count()>=$MaxGroupsPerUser) {
|
list($GroupsForUser) = $DB->next_record();
|
||||||
|
if (!check_perms('site_collages_delete') && $GroupsForUser >= $MaxGroupsPerUser) {
|
||||||
error(403);
|
error(403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,8 +67,6 @@ function AddTorrent($CollageID, $GroupID) {
|
|||||||
|
|
||||||
if ($Err) {
|
if ($Err) {
|
||||||
error($Err);
|
error($Err);
|
||||||
header('Location: collages.php?id='.$CollageID);
|
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$URL = $_POST['url'];
|
$URL = $_POST['url'];
|
||||||
@ -64,7 +75,9 @@ function AddTorrent($CollageID, $GroupID) {
|
|||||||
$URLRegex = '/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i';
|
$URLRegex = '/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i';
|
||||||
preg_match($URLRegex, $URL, $Matches);
|
preg_match($URLRegex, $URL, $Matches);
|
||||||
$TorrentID = $Matches[2];
|
$TorrentID = $Matches[2];
|
||||||
if(!$TorrentID || (int)$TorrentID == 0) { error(404); }
|
if (!$TorrentID || (int)$TorrentID == 0) {
|
||||||
|
error(404);
|
||||||
|
}
|
||||||
|
|
||||||
$DB->query("SELECT ID FROM torrents_group WHERE ID='$TorrentID'");
|
$DB->query("SELECT ID FROM torrents_group WHERE ID='$TorrentID'");
|
||||||
list($GroupID) = $DB->next_record();
|
list($GroupID) = $DB->next_record();
|
||||||
@ -79,11 +92,24 @@ function AddTorrent($CollageID, $GroupID) {
|
|||||||
$URLs = explode("\n",$_REQUEST['urls']);
|
$URLs = explode("\n",$_REQUEST['urls']);
|
||||||
$GroupIDs = array();
|
$GroupIDs = array();
|
||||||
$Err = '';
|
$Err = '';
|
||||||
|
foreach ($URLs as $Key => &$URL) {
|
||||||
|
$URL = trim($URL);
|
||||||
|
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) {
|
foreach ($URLs as $URL) {
|
||||||
$URL = trim($URL);
|
|
||||||
if ($URL == '') { continue; }
|
|
||||||
|
|
||||||
$Matches = array();
|
$Matches = array();
|
||||||
if (preg_match($URLRegex, $URL, $Matches)) {
|
if (preg_match($URLRegex, $URL, $Matches)) {
|
||||||
$GroupIDs[] = $Matches[3];
|
$GroupIDs[] = $Matches[3];
|
||||||
@ -102,13 +128,10 @@ function AddTorrent($CollageID, $GroupID) {
|
|||||||
|
|
||||||
if ($Err) {
|
if ($Err) {
|
||||||
error($Err);
|
error($Err);
|
||||||
header('Location: collages.php?id='.$CollageID);
|
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($GroupIDs as $GroupID) {
|
foreach ($GroupIDs as $GroupID) {
|
||||||
AddTorrent($CollageID, $GroupID);
|
AddTorrent($CollageID, $GroupID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: collages.php?id='.$CollageID);
|
header('Location: collages.php?id='.$CollageID);
|
@ -16,7 +16,9 @@ function compare($X, $Y){
|
|||||||
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
|
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
|
||||||
|
|
||||||
$CollageID = $_GET['id'];
|
$CollageID = $_GET['id'];
|
||||||
if(!is_number($CollageID)) { error(0); }
|
if (!is_number($CollageID)) {
|
||||||
|
error(0);
|
||||||
|
}
|
||||||
|
|
||||||
$Data = $Cache->get_value('collage_'.$CollageID);
|
$Data = $Cache->get_value('collage_'.$CollageID);
|
||||||
|
|
||||||
@ -43,7 +45,7 @@ function compare($X, $Y){
|
|||||||
|
|
||||||
if($CollageCategoryID == 0 && !check_perms('site_collages_delete')) {
|
if($CollageCategoryID == 0 && !check_perms('site_collages_delete')) {
|
||||||
if(!check_perms('site_collages_personal') || $CreatorID != $LoggedUser['ID']) {
|
if(!check_perms('site_collages_personal') || $CreatorID != $LoggedUser['ID']) {
|
||||||
$Locked = true;
|
$PreventAdditions = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,8 +333,8 @@ function compare($X, $Y){
|
|||||||
$Collage[]=ob_get_clean();
|
$Collage[]=ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($MaxGroups>0 && $NumGroups>=$MaxGroups) || ($MaxGroupsPerUser>0 && $NumGroupsByUser>=$MaxGroupsPerUser)) {
|
if (!check_perms('site_collages_delete') && ($Locked || ($MaxGroups > 0 && $NumGroups >= $MaxGroups) || ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser))) {
|
||||||
$Locked = true;
|
$PreventAdditions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Silly hack for people who are on the old setting
|
// Silly hack for people who are on the old setting
|
||||||
@ -370,8 +372,10 @@ function compare($X, $Y){
|
|||||||
<? if(check_perms('site_collages_subscribe')) { ?>
|
<? if(check_perms('site_collages_subscribe')) { ?>
|
||||||
<a href="#" onclick="CollageSubscribe(<?=$CollageID?>);return false;" id="subscribelink<?=$CollageID?>">[<?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?>]</a>
|
<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&collageid=<?=$CollageID?>">[Edit description]</a>
|
<a href="collages.php?action=edit&collageid=<?=$CollageID?>">[Edit description]</a>
|
||||||
|
<? } else { ?>
|
||||||
|
[Locked]
|
||||||
<? }
|
<? }
|
||||||
if(has_bookmarked('collage', $CollageID)) {
|
if(has_bookmarked('collage', $CollageID)) {
|
||||||
?>
|
?>
|
||||||
@ -463,7 +467,9 @@ function compare($X, $Y){
|
|||||||
<div class="head"><strong>Stats</strong></div>
|
<div class="head"><strong>Stats</strong></div>
|
||||||
<ul class="stats nobullet">
|
<ul class="stats nobullet">
|
||||||
<li>Torrents: <?=$NumGroups?></li>
|
<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>
|
<li>Built by <?=count($Users)?> user<?=(count($Users)>1) ? 's' : ''?></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -524,7 +530,7 @@ function compare($X, $Y){
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<? if(check_perms('site_collages_manage') && !$Locked) { ?>
|
<? if(check_perms('site_collages_manage') && !$PreventAdditions) { ?>
|
||||||
<div class="box box_addtorrent">
|
<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="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">
|
<div class="pad add_torrent_container">
|
||||||
|
@ -1,14 +1,28 @@
|
|||||||
<?
|
<?
|
||||||
|
if (!empty($_GET['collageid']) && is_number($_GET['collageid'])) {
|
||||||
$CollageID = $_GET['collageid'];
|
$CollageID = $_GET['collageid'];
|
||||||
if(!is_number($CollageID)) { error(0); }
|
}
|
||||||
|
if (!is_number($CollageID)) {
|
||||||
|
error(0);
|
||||||
|
}
|
||||||
|
|
||||||
$DB->query("SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured FROM collages WHERE ID='$CollageID'");
|
$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();
|
list($Name, $Description, $TagList, $UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Featured) = $DB->next_record();
|
||||||
$TagList = implode(', ', explode(' ', $TagList));
|
$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');
|
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="thin">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -24,16 +38,19 @@
|
|||||||
<td class="label">Name</td>
|
<td class="label">Name</td>
|
||||||
<td><input type="text" name="name" size="60" value="<?=$Name?>" /></td>
|
<td><input type="text" name="name" size="60" value="<?=$Name?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<? } ?>
|
<? }
|
||||||
<? if($CategoryID>0 || check_perms('site_collages_delete')) { ?>
|
if($CategoryID > 0 || check_perms('site_collages_delete')) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><strong>Category</strong></td>
|
<td class="label"><strong>Category</strong></td>
|
||||||
<td>
|
<td>
|
||||||
<select name="category">
|
<select name="category">
|
||||||
<?
|
<? foreach ($CollageCats as $CatID => $CatName) {
|
||||||
foreach($CollageCats as $CatID=>$CatName) {
|
if (!check_perms('site_collages_delete') && $CatID == 0) {
|
||||||
if (!check_perms('site_collages_delete') && $CatID == 0) { continue; } // Only mod-type get to make things personal ?>
|
// Only mod-type get to make things personal
|
||||||
<option value="<?=$CatID?>" <? if($CatID == $CategoryID) { echo ' selected="selected"'; }?>><?=$CatName?></option>
|
continue;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<option value="<?=$CatID?>" <?=$CatID == $CategoryID ? ' selected="selected"' : ''?>><?=$CatName?></option>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@ -57,8 +74,8 @@
|
|||||||
<? }
|
<? }
|
||||||
if(check_perms('site_collages_delete')) { ?>
|
if(check_perms('site_collages_delete')) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><span title="This feature has not been implemented yet. It currently does nothing.">Locked</span></td>
|
<td class="label">Locked</td>
|
||||||
<td><input type="checkbox" name="locked" <?if($Locked) { ?>checked="checked" <? }?>/></td>
|
<td><input type="checkbox" name="locked" <?=$Locked ? 'checked="checked" ' : ''?>/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label">Max groups</td>
|
<td class="label">Max groups</td>
|
||||||
|
@ -2,11 +2,15 @@
|
|||||||
authorize();
|
authorize();
|
||||||
|
|
||||||
$CollageID = $_POST['collageid'];
|
$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'");
|
$DB->query("SELECT UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
|
||||||
list($UserID, $CategoryID) = $DB->next_record();
|
list($UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
$DB->query("SELECT ID,Deleted FROM collages WHERE Name='".db_string($_POST['name'])."' AND ID!='$CollageID' LIMIT 1");
|
$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()) {
|
||||||
@ -14,8 +18,11 @@
|
|||||||
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!';
|
$Err = 'A collage with that name already exists but needs to be recovered, please <a href="staffpm.php">contact</a> the staff team!';
|
||||||
} else {
|
} 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']);
|
$TagList = explode(',',$_POST['tags']);
|
||||||
@ -24,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
$TagList = implode(' ',$TagList);
|
$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 (!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'])) {
|
||||||
@ -34,17 +41,32 @@
|
|||||||
|
|
||||||
if (isset($_POST['featured']) && $CategoryID == 0 && (($LoggedUser['ID'] == $UserID && check_perms('site_collages_personal')) || check_perms('site_collages_delete'))) {
|
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=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'))) {
|
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'))) {
|
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'");
|
$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);
|
$Cache->delete_value('collage_'.$CollageID);
|
||||||
header('Location: collages.php?id='.$CollageID);
|
header('Location: collages.php?id='.$CollageID);
|
||||||
?>
|
?>
|
||||||
|
@ -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>
|
<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>
|
||||||
<td>
|
<td>
|
||||||
<span style="float: right;">
|
<span class="torrent_links_block">
|
||||||
[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
[ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
|
||||||
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a> ]
|
| <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" title="Report">RP</a> ]
|
||||||
</span>
|
</span>
|
||||||
|
@ -226,10 +226,10 @@ function check_paranoia_here($Setting) {
|
|||||||
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?>>Last seen: <?=$LastAccess?></li>
|
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?>>Last seen: <?=$LastAccess?></li>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? if (($Override=check_paranoia_here('uploaded'))) { ?>
|
<? 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'))) { ?>
|
<? 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'))) { ?>
|
<? if (($Override=check_paranoia_here('ratio'))) { ?>
|
||||||
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?>>Ratio: <?=Format::get_ratio_html($Uploaded, $Downloaded)?></li>
|
<li <?= $Override===2 ? 'class="paranoia_override"' : ''?>>Ratio: <?=Format::get_ratio_html($Uploaded, $Downloaded)?></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user