diff --git a/classes/class_debug.php b/classes/class_debug.php index 94cfb4b7..03c6e20a 100644 --- a/classes/class_debug.php +++ b/classes/class_debug.php @@ -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) {
Event | +Page time | + if ($Flags[0][3] !== false) { ?> +CPU time | + } ?> +Memory | +||
=$Event?> | -=$MicroTime?> ms | +=number_format($MicroTime, 3)?> ms | + if ($CPUTime !== false) { ?> +=number_format($CPUTime / 1000, 3)?> ms | + } ?>=Format::get_size($Memory)?> |
+ | =display_str($Key)?> | @@ -492,9 +506,15 @@ public function error_table($Errors=false) { list($Error,$Location,$Call,$Args) = $Error; ?> | |||
=display_str($Call)?>(=display_str($Args)?>) | -=display_str($Error)?> | -=display_str($Location)?> | ++ =display_str($Call)?>(=display_str($Args)?>) + | ++ =display_str($Error)?> + | ++ =display_str($Location)?> + |
=str_replace("\t", ' ', nl2br(display_str($SQL)))?> |
- =number_format($Time, 5)?> ms | +=number_format($Time, 5)?> ms | |||
=str_replace("\t", ' ', $Params)?> |
- =number_format($Time, 5)?> ms | +=number_format($Time, 5)?> ms | |||
+ |
=display_str($Key)?> (=$Size . ($Size == 1 ? ' element' : ' elements')?>)
=$Data['bt']['path'].':'.$Data['bt']['line'];?>
|
diff --git a/classes/class_torrents.php b/classes/class_torrents.php
index 1c07b364..67dd34b8 100644
--- a/classes/class_torrents.php
+++ b/classes/class_torrents.php
@@ -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);
diff --git a/classes/script_start.php b/classes/script_start.php
index 0b412d81..b59d597b 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -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
diff --git a/design/privateheader.php b/design/privateheader.php
index c6dfdf1f..5902caeb 100644
--- a/design/privateheader.php
+++ b/design/privateheader.php
@@ -115,8 +115,8 @@
Name | |||
Category | @@ -49,16 +66,16 @@ | Tags | |||
Featured | /> | ||||
Locked | -checked="checked" }?>/> | +Locked | +/> | ||
Max groups | diff --git a/sections/collages/edit_handle.php b/sections/collages/edit_handle.php index 27dc2c4a..cc5c41ea 100644 --- a/sections/collages/edit_handle.php +++ b/sections/collages/edit_handle.php @@ -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 contact the staff team!'; } else { - $Err = "A collage with that name already exists: $ID."; + $Err = "A collage with that name already exists: $_POST[name]."; } + $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); ?> diff --git a/sections/torrents/user.php b/sections/torrents/user.php index 1a24cc2a..02ddb541 100644 --- a/sections/torrents/user.php +++ b/sections/torrents/user.php @@ -462,7 +462,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
-
+
[ DL
| RP ]
diff --git a/sections/user/user.php b/sections/user/user.php
index 6fc262ec..594f26d6 100644
--- a/sections/user/user.php
+++ b/sections/user/user.php
@@ -226,10 +226,10 @@ function check_paranoia_here($Setting) {
|