diff --git a/classes/class_file_checker.php b/classes/class_file_checker.php index 3cd50547..adeb9793 100644 --- a/classes/class_file_checker.php +++ b/classes/class_file_checker.php @@ -2,18 +2,14 @@ $music_extensions = array("mp3","flac","mp4","m4a","m3u","m4b","pls","m3u8","log","txt", "cue","jpg","jpeg","png","gif","dts","ac3","nfo", - "sfv","md5","accurip","ffp","pdf"); - -$ebooks_extensions = array("pdf", "nfo", "sfv", "mobi", "epub", "txt", "htm", "html", "lit", - "chm", "rtf", "doc", "djv", "djvu", "jpg","jpeg","png","gif"); + "sfv","md5","accurip","ffp","pdf", "mobi", "epub", "htm", "html", "lit", + "chm", "rtf", "doc", "djv", "djvu"); $comics_extensions = array("cbr", "cbz", "pdf", "jpg","jpeg","png","gif"); $keywords = array("scc.nfo", "torrentday", "demonoid.com", "demonoid.me", "djtunes.com", "mixesdb.com", "housexclusive.net", "plixid.com", "h33t", "reggaeme.com" ,"ThePirateBay.org", "Limetorrents.com", "AhaShare.com", "MixFiend.blogstop", "MixtapeTorrent.blogspot"); - - function check_file($Type, $Name) { check_name(strtolower($Name)); check_extensions($Type, strtolower($Name)); @@ -40,20 +36,14 @@ function check_name($Name) { function check_extensions($Type, $Name) { -global $music_extensions, $ebooks_extensions, $comics_extensions; +global $music_extensions, $comics_extensions; -if($Type == 'Music' || $Type == 'Audiobooks' || $Type == 'Comedy') { +if($Type == 'Music' || $Type == 'Audiobooks' || $Type == 'Comedy' || $Type == 'E-Books') { if(!in_array(get_file_extension($Name), $music_extensions)) { invalid_error($Name); } } -if($Type == 'E-Books') { - if(!in_array(get_file_extension($Name), $ebooks_extensions)) { - invalid_error($Name); - } - } - if($Type == 'Comics') { if(!in_array(get_file_extension($Name), $comics_extensions)) { invalid_error($Name); diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 55d11225..dff1ea20 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -98,6 +98,9 @@ case 'similar_artists': require(SERVER_ROOT.'/sections/ajax/similar_artists.php'); break; + case 'userhistory': + require(SERVER_ROOT.'/sections/ajax/userhistory/index.php'); + break; default: // If they're screwing around with the query string print json_encode(array('status' => 'failure')); diff --git a/sections/ajax/userhistory/index.php b/sections/ajax/userhistory/index.php new file mode 100644 index 00000000..6b3106c0 --- /dev/null +++ b/sections/ajax/userhistory/index.php @@ -0,0 +1,21 @@ + 'failure') + ); + } +} +else { + print json_encode( + array('status' => 'failure') + ); +} + +?> \ No newline at end of file diff --git a/sections/ajax/userhistory/post_history.php b/sections/ajax/userhistory/post_history.php new file mode 100644 index 00000000..ef3fdc7d --- /dev/null +++ b/sections/ajax/userhistory/post_history.php @@ -0,0 +1,220 @@ + 'failure'); + if ($reason != "") + $error['reason'] = $reason; + print $error; + die(); +} + +if(!empty($LoggedUser['DisableForums'])) { + error_out("You do not have access to the forums!"); +} + + +include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class +$Text = new TEXT; + + +$UserID = empty($_GET['userid']) ? $LoggedUser['ID'] : $_GET['userid']; +if(!is_number($UserID)){ + error_out("User does not exist!"); +} + +if (isset($LoggedUser['PostsPerPage'])) { + $PerPage = $LoggedUser['PostsPerPage']; +} else { + $PerPage = POSTS_PER_PAGE; +} + +list($Page,$Limit) = page_limit($PerPage); + +if(($UserInfo = $Cache->get_value('user_info_'.$UserID)) === FALSE) { + $DB->query("SELECT + m.Username, + m.Enabled, + m.Title, + i.Avatar, + i.Donor, + i.Warned + FROM users_main AS m + JOIN users_info AS i ON i.UserID = m.ID + WHERE m.ID = $UserID"); + + if($DB->record_count() == 0){ // If user doesn't exist + error_out("User does not exist!"); + } + list($Username, $Enabled, $Title, $Avatar, $Donor, $Warned) = $DB->next_record(); +} else { + extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned')))); +} + +if(check_perms('site_proxy_images') && !empty($Avatar)) { + $Avatar = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&i='.urlencode($Avatar); +} + +if($LoggedUser['CustomForums']) { + unset($LoggedUser['CustomForums']['']); + $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); +} +$ViewingOwn = ($UserID == $LoggedUser['ID']); +$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread'])); +$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group'])); +if($ShowGrouped) { + $sql = 'SELECT + SQL_CALC_FOUND_ROWS + MAX(p.ID) AS ID + FROM forums_posts AS p + LEFT JOIN forums_topics AS t ON t.ID = p.TopicID'; + if($ShowUnread) { + $sql.=' + LEFT JOIN forums_last_read_topics AS l ON l.TopicID = t.ID AND l.UserID = '.$LoggedUser['ID']; + } + $sql .= ' + LEFT JOIN forums AS f ON f.ID = t.ForumID + WHERE p.AuthorID = '.$UserID.' + AND ((f.MinClassRead <= '.$LoggedUser['EffectiveClass']; + if(!empty($RestrictedForums)) { + $sql.=' + AND f.ID NOT IN (\''.$RestrictedForums.'\')'; + } + $sql .= ')'; + if(!empty($PermittedForums)) { + $sql.=' + OR f.ID IN (\''.$PermittedForums.'\')'; + } + $sql .= ')'; + if($ShowUnread) { + $sql .= ' + AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') + AND (l.PostIDquery($sql); + $DB->query("SELECT FOUND_ROWS()"); + list($Results) = $DB->next_record(); + + if($Results > $PerPage*($Page-1)) { + $DB->set_query_id($PostIDs); + $PostIDs = $DB->collect('ID'); + $sql = 'SELECT + p.ID, + p.AddedTime, + p.Body, + p.EditedUserID, + p.EditedTime, + ed.Username, + p.TopicID, + t.Title, + t.LastPostID, + l.PostID AS LastRead, + t.IsLocked, + t.IsSticky + FROM forums_posts as p + LEFT JOIN users_main AS um ON um.ID = p.AuthorID + LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID + LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID + JOIN forums_topics AS t ON t.ID = p.TopicID + JOIN forums AS f ON f.ID = t.ForumID + LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID + WHERE p.ID IN ('.implode(',',$PostIDs).') + ORDER BY p.ID DESC'; + $Posts = $DB->query($sql); + } +} else { + $sql = 'SELECT + SQL_CALC_FOUND_ROWS'; + if($ShowGrouped) { + $sql.=' * FROM (SELECT'; + } + $sql .= ' + p.ID, + p.AddedTime, + p.Body, + p.EditedUserID, + p.EditedTime, + ed.Username, + p.TopicID, + t.Title, + t.LastPostID,'; + if($UserID == $LoggedUser['ID']) { + $sql .= ' + l.PostID AS LastRead,'; + } + $sql .= ' + t.IsLocked, + t.IsSticky + FROM forums_posts as p + LEFT JOIN users_main AS um ON um.ID = p.AuthorID + LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID + LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID + JOIN forums_topics AS t ON t.ID = p.TopicID + JOIN forums AS f ON f.ID = t.ForumID + LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID + WHERE p.AuthorID = '.$UserID.' + AND f.MinClassRead <= '.$LoggedUser['EffectiveClass']; + + if(!empty($RestrictedForums)) { + $sql.=' + AND f.ID NOT IN (\''.$RestrictedForums.'\')'; + } + + if($ShowUnread) { + $sql.=' + AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND (l.PostIDquery($sql); + + $DB->query("SELECT FOUND_ROWS()"); + list($Results) = $DB->next_record(); + + $DB->set_query_id($Posts); +} + +$JsonResults = array(); +while(list($PostID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername, $TopicID, $ThreadTitle, $LastPostID, $LastRead, $Locked, $Sticky) = $DB->next_record()){ + $JsonResults[] = array( + 'postId' => (int) $PostID, + 'topicId' => (int) $TopicID, + 'threadTitle' => $ThreadTitle, + 'lastPostId' => (int) $LastPostID, + 'lastRead' => (int) $LastRead, + 'locked' => $Locked == 1, + 'sticky' => $Sticky == 1, + 'addedTime' => $AddedTime, + 'body' => $Text->full_format($Body), + 'bbbody' => $Body, + 'editedUserId' => (int) $EditedUserID, + 'editedTime' => $EditedTime, + 'editedUsername' => $EditedUsername + ); +} + +print json_encode( + array( + 'status' => 'success', + 'response' => array( + 'currentPage' => (int) $Page, + 'pages' => ceil($Results/$PerPage), + 'threads' => $JsonResults + ) + ) + ); diff --git a/sections/upload/upload.php b/sections/upload/upload.php index a0d62ec7..458da9d9 100644 --- a/sections/upload/upload.php +++ b/sections/upload/upload.php @@ -91,9 +91,9 @@ d.Comment, d.Time FROM do_not_upload as d - ORDER BY d.Time"); + ORDER BY d.Time DESC"); $DNU = $DB->to_array(); -list($Name,$Comment,$Updated) = end($DNU); +list($Name,$Comment,$Updated) = reset($DNU); reset($DNU); $DB->query("SELECT IF(MAX(t.Time) < '$Updated' OR MAX(t.Time) IS NULL,1,0) FROM torrents AS t WHERE UserID = ".$LoggedUser['ID']); @@ -113,11 +113,16 @@ Name Comment - - full_format($Name)?> + full_format($Name)?> + + (New!) + + full_format($Comment)?>