Exemple #1
0
if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
    $OrderBy = 'time';
} else {
    $OrderBy = $_GET['order_by'];
}
$GroupResults = !isset($_GET['group_results']) || $_GET['group_results'] != '0';
$Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
$Results = $Search->query($_GET);
$Groups = $Search->get_groups();
$NumResults = $Search->record_count();
if ($Results === false) {
    json_die('error', 'Search returned an error. Make sure all parameters are valid and of the expected types.');
}
if ($NumResults == 0) {
    json_die('success', array('results' => array(), 'youMightLike' => array()));
}
$Bookmarks = Bookmarks::all_bookmarks('torrent');
$JsonGroups = array();
foreach ($Results as $Key => $GroupID) {
    $GroupInfo = $Groups[$GroupID];
    if (empty($GroupInfo['Torrents'])) {
        continue;
    }
    $CategoryID = $GroupInfo['CategoryID'];
    $GroupYear = $GroupInfo['Year'];
    $ExtendedArtists = $GroupInfo['ExtendedArtists'];
    $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
    $GroupName = $GroupInfo['Name'];
    $GroupRecordLabel = $GroupInfo['RecordLabel'];
    $ReleaseType = $GroupInfo['ReleaseType'];
Exemple #2
0
    $Artists = Artists::get_artists($DB->collect('ID'));
    foreach ($RecentSnatches as $Key => $SnatchInfo) {
        $RecentSnatches[$Key]['artists'][] = $Artists[$SnatchInfo['ID']];
        $RecentSnatches[$Key]['ID'] = (int) $RecentSnatches[$Key]['ID'];
    }
    $Results['snatches'] = $RecentSnatches;
} else {
    $Results['snatches'] = "hidden";
}
if (check_paranoia_here('uploads')) {
    $DB->query("\n\t\tSELECT\n\t\t\tg.ID,\n\t\t\tg.Name,\n\t\t\tg.WikiImage\n\t\tFROM torrents_group AS g\n\t\t\tINNER JOIN torrents AS t ON t.GroupID = g.ID\n\t\tWHERE t.UserID = '{$UserID}'\n\t\t\tAND g.CategoryID = '1'\n\t\t\tAND g.WikiImage != ''\n\t\tGROUP BY g.ID\n\t\tORDER BY t.Time DESC\n\t\tLIMIT {$Limit}");
    $RecentUploads = $DB->to_array(false, MYSQLI_ASSOC);
    $Artists = Artists::get_artists($DB->collect('ID'));
    foreach ($RecentUploads as $Key => $UploadInfo) {
        $RecentUploads[$Key]['artists'][] = $Artists[$UploadInfo['ID']];
        $RecentUploads[$Key]['ID'] = (int) $RecentUploads[$Key]['ID'];
    }
    $Results['uploads'] = $RecentUploads;
} else {
    $Results['uploads'] = "hidden";
}
json_die("success", $Results);
function check_paranoia_here($Setting)
{
    global $Paranoia, $Class, $UserID, $Preview;
    if ($Preview == 1) {
        return check_paranoia($Setting, $Paranoia, $Class);
    } else {
        return check_paranoia($Setting, $Paranoia, $Class, $UserID);
    }
}
<?php

$Skip = array();
$Skip[] = db_string($_GET['skip']);
$NotificationsManager = new NotificationsManager($LoggedUser['ID'], $Skip);
json_die("success", $NotificationsManager->get_notifications());
//echo '{"status":"success","response":[[{"message":"1st notification","url":"https:\/\/www.google.com\/","importance":"alert","AutoExpire":false},{"message":"2nd notification","url":"","importance":"alert","AutoExpire":true}]]}';
$JsonNotifications = array();
$NumNew = 0;
$FilterGroups = array();
while ($Result = $DB->next_record(MYSQLI_ASSOC)) {
    if (!$Result['FilterID']) {
        $Result['FilterID'] = 0;
    }
    if (!isset($FilterGroups[$Result['FilterID']])) {
        $FilterGroups[$Result['FilterID']] = array();
        $FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false;
    }
    array_push($FilterGroups[$Result['FilterID']], $Result);
}
unset($Result);
foreach ($FilterGroups as $FilterID => $FilterResults) {
    unset($FilterResults['FilterLabel']);
    foreach ($FilterResults as $Result) {
        $TorrentID = $Result['TorrentID'];
        //		$GroupID = $Result['GroupID'];
        $GroupInfo = $TorrentGroups[$Result['GroupID']];
        extract(Torrents::array_group($GroupInfo));
        // all group data
        $TorrentInfo = $GroupInfo['Torrents'][$TorrentID];
        if ($Result['UnRead'] == 1) {
            $NumNew++;
        }
        $JsonNotifications[] = array('torrentId' => (int) $TorrentID, 'groupId' => (int) $GroupID, 'groupName' => $GroupName, 'groupCategoryId' => (int) $GroupCategoryID, 'wikiImage' => $WikiImage, 'torrentTags' => $TagList, 'size' => (double) $TorrentInfo['Size'], 'fileCount' => (int) $TorrentInfo['FileCount'], 'format' => $TorrentInfo['Format'], 'encoding' => $TorrentInfo['Encoding'], 'media' => $TorrentInfo['Media'], 'scene' => $TorrentInfo['Scene'] == 1, 'groupYear' => (int) $GroupYear, 'remasterYear' => (int) $TorrentInfo['RemasterYear'], 'remasterTitle' => $TorrentInfo['RemasterTitle'], 'snatched' => (int) $TorrentInfo['Snatched'], 'seeders' => (int) $TorrentInfo['Seeders'], 'leechers' => (int) $TorrentInfo['Leechers'], 'notificationTime' => $TorrentInfo['Time'], 'hasLog' => $TorrentInfo['HasLog'] == 1, 'hasCue' => $TorrentInfo['HasCue'] == 1, 'logScore' => (double) $TorrentInfo['LogScore'], 'freeTorrent' => $TorrentInfo['FreeTorrent'] == 1, 'logInDb' => $TorrentInfo['HasLog'] == 1, 'unread' => $Result['UnRead'] == 1);
    }
}
json_die("success", array('currentPages' => intval($Page), 'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE), 'numNew' => $NumNew, 'results' => $JsonNotifications));
Exemple #5
0
            // Get a list of all torrent ids that match the search query
            $SphQLTor->where('id', $TorrentIDs)->limit(0, $TorrentCount, $TorrentCount);
            $SphQLResultTor = $SphQLTor->query();
            $TorrentIDs = $SphQLResultTor->to_pair('id', 'id');
            // Because isset() is faster than in_array()
        }
    }
}
/** End run search query and collect results **/
if ($NumResults == 0) {
    $DB->query("\n\tSELECT\n\t\ttags.Name,\n\t\t((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score\n\tFROM xbt_snatched AS s\n\t\tINNER JOIN torrents AS t ON t.ID = s.fid\n\t\tINNER JOIN torrents_group AS g ON t.GroupID = g.ID\n\t\tINNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID\n\t\tINNER JOIN tags ON tags.ID = tt.TagID\n\tWHERE s.uid = '{$LoggedUser['ID']}'\n\t\tAND tt.TagID != '13679'\n\t\tAND tt.TagID != '4820'\n\t\tAND tt.TagID != '2838'\n\t\tAND g.CategoryID = '1'\n\t\tAND tags.Uses > '10'\n\tGROUP BY tt.TagID\n\tORDER BY Score DESC\n\tLIMIT 8");
    $JsonYouMightLike = array();
    while (list($Tag) = $DB->next_record()) {
        $JsonYouMightLike[] = $Tag;
    }
    json_die("success", array('results' => array(), 'youMightLike' => $JsonYouMightLike));
}
$Bookmarks = Bookmarks::all_bookmarks('torrent');
$JsonGroups = array();
foreach ($Results as $Result) {
    $GroupID = $Result['groupid'];
    $GroupInfo = $Groups[$GroupID];
    if (empty($GroupInfo['Torrents'])) {
        continue;
    }
    $CategoryID = $Result['categoryid'];
    $GroupYear = $GroupInfo['Year'];
    $ExtendedArtists = $GroupInfo['ExtendedArtists'];
    $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
    $GroupName = $GroupInfo['Name'];
    $GroupRecordLabel = $GroupInfo['RecordLabel'];
<?php

require SERVER_ROOT . '/sections/torrents/functions.php';
$GroupID = (int) $_GET['id'];
if ($GroupID === 0) {
    error('bad id parameter', true);
}
$TorrentDetails = get_group_info($GroupID, true, 0, false);
$TorrentDetails = $TorrentDetails[0];
$Image = $TorrentDetails['WikiImage'];
if (!$Image) {
    // handle no artwork
    $Image = STATIC_SERVER . 'common/noartwork/' . $CategoryIcons[$TorrentDetails['CategoryID'] - 1];
}
json_die("success", array('wikiImage' => $Image));
Exemple #7
0
        $TorrentID = (int) torrenthash_to_torrentid($TorrentHash);
        if (!$TorrentID) {
            json_die("failure", "bad hash parameter");
        }
    }
}
if ($TorrentID <= 0) {
    json_die("failure", "bad id parameter");
}
$TorrentCache = get_torrent_info($TorrentID, true, 0, true, true);
if (!$TorrentCache) {
    json_die("failure", "bad id parameter");
}
list($TorrentDetails, $TorrentList) = $TorrentCache;
if (!isset($TorrentList[$TorrentID])) {
    json_die("failure", "bad id parameter");
}
$GroupID = $TorrentDetails['ID'];
$ArtistForm = Artists::get_artist($GroupID);
if ($TorrentDetails['CategoryID'] == 0) {
    $CategoryName = "Unknown";
} else {
    $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1];
}
$JsonMusicInfo = array();
if ($CategoryName == "Music") {
    $JsonMusicInfo = array('composers' => $ArtistForm[4] == null ? array() : pullmediainfo($ArtistForm[4]), 'dj' => $ArtistForm[6] == null ? array() : pullmediainfo($ArtistForm[6]), 'artists' => $ArtistForm[1] == null ? array() : pullmediainfo($ArtistForm[1]), 'with' => $ArtistForm[2] == null ? array() : pullmediainfo($ArtistForm[2]), 'conductor' => $ArtistForm[5] == null ? array() : pullmediainfo($ArtistForm[5]), 'remixedBy' => $ArtistForm[3] == null ? array() : pullmediainfo($ArtistForm[3]), 'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7]));
} else {
    $JsonMusicInfo = null;
}
$TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
Exemple #8
0
<?php

$PostID = (int) $_POST['postid'];
if (empty($PostID)) {
    json_die("error", "empty postid");
}
$DB->query("\n\tSELECT t.ForumID, p.Body\n\tFROM forums_posts AS p\n\t\tJOIN forums_topics AS t ON p.TopicID = t.ID\n\tWHERE p.ID = '{$PostID}'");
if (!$DB->has_results()) {
    json_die("error", "no results");
}
list($ForumID, $Body) = $DB->next_record();
if (!Forums::check_forumperm($ForumID)) {
    json_die("error", "assholes");
}
json_die("success", array("body" => nl2br($Body)));
Exemple #9
0
<?php

if (!empty($_GET['id']) && is_number($_GET['id'])) {
    //Visiting article via ID
    $ArticleID = $_GET['id'];
} elseif ($_GET['name'] != '') {
    //Retrieve article ID via alias.
    $ArticleID = Wiki::alias_to_id($_GET['name']);
} else {
    json_die("failure");
}
if (!$ArticleID) {
    //No article found
    json_die("failure", "article not found");
}
$Article = Wiki::get_article($ArticleID, false);
if (!$Article) {
    json_die("failure", "article not found");
}
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article);
if ($Read > $LoggedUser['EffectiveClass']) {
    json_die("failure", "higher user class required to view article");
}
Text::$TOC = true;
$TextBody = Text::full_format($Body, false);
json_die("success", array('title' => $Title, 'bbBody' => $Body, 'body' => $TextBody, 'aliases' => $Aliases, 'authorID' => (int) $AuthorID, 'authorName' => $AuthorName, 'date' => $Date, 'revision' => (int) $Revision));
Exemple #10
0
<?php

if (!empty($_GET['id']) && is_number($_GET['id'])) {
    //Visiting article via ID
    $ArticleID = $_GET['id'];
} elseif ($_GET['name'] != '') {
    //Retrieve article ID via alias.
    $ArticleID = Wiki::alias_to_id($_GET['name']);
} else {
    json_die("failure");
}
if (!$ArticleID) {
    //No article found
    json_die("failure", "article not found");
}
$Article = Wiki::get_article($ArticleID, false);
if (!$Article) {
    json_die("failure", "article not found");
}
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article);
if ($Read > $LoggedUser['EffectiveClass']) {
    json_die("failure", "higher user class required to view article");
}
Text::$TOC = true;
$TextBody = Text::full_format($Body, false);
json_print("success", array('title' => $Title, 'bbBody' => $Body, 'body' => $TextBody, 'aliases' => $Aliases, 'authorID' => (int) $AuthorID, 'authorName' => $AuthorName, 'date' => $Date, 'revision' => (int) $Revision));
<?php

if (isset($_REQUEST['click_to_call']) && $_REQUEST['click_to_call'] == 1) {
    $fields['deal_id'] = $_REQUEST['dealId'];
    $fields['agent_phone'] = removeCellFormat($_REQUEST['agent_phone']);
    $fields['agent_name'] = $_REQUEST['agent_name'];
    $fields['customer_phone'] = removeCellFormat($_REQUEST['customer_phone']);
    $click_to_call_id = qi("click_to_call", $fields);
    $callWebhook = new callWebhook();
    $sid = $callWebhook->click_to_call($click_to_call_id);
    $data = array("id" => $click_to_call_id, "sid" => $sid);
    json_die(true, $data);
}
$dealId = $_REQUEST['dealId'];
$phone_count = $_REQUEST['phone_count'];
$contact_list = array();
$is_cust_number = 0;
for ($index = 1; $index <= $phone_count; $index++) {
    $is_cust_number = 1;
    $contact_list[] = removeCellFormat($_REQUEST['phone_' . $index]);
}
$conversation_list = q("select * from text_conversation where deal_id='{$dealId}' order by messageTime asc");
$agent_name = $_REQUEST['agent_name'];
$agent = qs("select * from pd_users where name='{$agent_name}'");
if (empty($agent) || $agent['phone'] == '' && $agent['cell'] == '') {
    $is_agent_number = 0;
} else {
    $is_agent_number = 1;
    $agent_no = $agent['phone'] == '' ? $agent['cell'] : $agent['phone'];
    $agent_no = formatCellDash($agent_no);
}
Exemple #12
0
$ArtistForm = Artists::get_artist($GroupID);
if ($TorrentDetails['CategoryID'] == 0) {
    $CategoryName = "Unknown";
} else {
    $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1];
}
$JsonMusicInfo = array();
if ($CategoryName == "Music") {
    $JsonMusicInfo = array('composers' => $ArtistForm[4] == null ? array() : pullmediainfo($ArtistForm[4]), 'dj' => $ArtistForm[6] == null ? array() : pullmediainfo($ArtistForm[6]), 'artists' => $ArtistForm[1] == null ? array() : pullmediainfo($ArtistForm[1]), 'with' => $ArtistForm[2] == null ? array() : pullmediainfo($ArtistForm[2]), 'conductor' => $ArtistForm[5] == null ? array() : pullmediainfo($ArtistForm[5]), 'remixedBy' => $ArtistForm[3] == null ? array() : pullmediainfo($ArtistForm[3]), 'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7]));
} else {
    $JsonMusicInfo = null;
}
$JsonTorrentDetails = array('wikiBody' => Text::full_format($TorrentDetails['WikiBody']), 'wikiImage' => $TorrentDetails['WikiImage'], 'id' => (int) $TorrentDetails['ID'], 'name' => $TorrentDetails['Name'], 'year' => (int) $TorrentDetails['Year'], 'recordLabel' => $TorrentDetails['RecordLabel'], 'catalogueNumber' => $TorrentDetails['CatalogueNumber'], 'releaseType' => (int) $TorrentDetails['ReleaseType'], 'categoryId' => (int) $TorrentDetails['CategoryID'], 'categoryName' => $CategoryName, 'time' => $TorrentDetails['Time'], 'vanityHouse' => $TorrentDetails['VanityHouse'] == 1, 'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID), 'musicInfo' => $JsonMusicInfo);
$Torrent = $TorrentList[$TorrentID];
$Reports = Torrents::get_reports($TorrentID);
if (count($Reports) > 0) {
    $Torrent['Reported'] = true;
} else {
    $Torrent['Reported'] = false;
}
// Convert file list back to the old format
$FileList = explode("\n", $Torrent['FileList']);
foreach ($FileList as &$File) {
    $File = Torrents::filelist_old_format($File);
}
unset($File);
$FileList = implode('|||', $FileList);
$Userinfo = Users::user_info($Torrent['UserID']);
$JsonTorrentList[] = array('id' => (int) $Torrent['ID'], 'infoHash' => $Torrent['InfoHash'], 'media' => $Torrent['Media'], 'format' => $Torrent['Format'], 'encoding' => $Torrent['Encoding'], 'remastered' => $Torrent['Remastered'] == 1, 'remasterYear' => (int) $Torrent['RemasterYear'], 'remasterTitle' => $Torrent['RemasterTitle'], 'remasterRecordLabel' => $Torrent['RemasterRecordLabel'], 'remasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'], 'scene' => $Torrent['Scene'] == 1, 'hasLog' => $Torrent['HasLog'] == 1, 'hasCue' => $Torrent['HasCue'] == 1, 'logScore' => (int) $Torrent['LogScore'], 'fileCount' => (int) $Torrent['FileCount'], 'size' => (int) $Torrent['Size'], 'seeders' => (int) $Torrent['Seeders'], 'leechers' => (int) $Torrent['Leechers'], 'snatched' => (int) $Torrent['Snatched'], 'freeTorrent' => $Torrent['FreeTorrent'] == 1, 'reported' => $Torrent['Reported'], 'time' => $Torrent['Time'], 'description' => $Torrent['Description'], 'fileList' => $FileList, 'filePath' => $Torrent['FilePath'], 'userId' => (int) $Torrent['UserID'], 'username' => $Userinfo['Username']);
json_die("success", array('group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)));
Exemple #13
0
if ($LoggedUser['LastReadNews'] != $News[0][0]) {
    $Cache->begin_transaction("user_info_heavy_{$UserID}");
    $Cache->update_row(false, array('LastReadNews' => $News[0][0]));
    $Cache->commit_transaction(0);
    $DB->query("\n\t\tUPDATE users_info\n\t\tSET LastReadNews = '" . $News[0][0] . "'\n\t\tWHERE UserID = {$UserID}");
    $LoggedUser['LastReadNews'] = $News[0][0];
}
if (($Blog = $Cache->get_value('blog')) === false) {
    $DB->query("\n\t\tSELECT\n\t\t\tb.ID,\n\t\t\tum.Username,\n\t\t\tb.UserID,\n\t\t\tb.Title,\n\t\t\tb.Body,\n\t\t\tb.Time,\n\t\t\tb.ThreadID\n\t\tFROM blog AS b\n\t\t\tLEFT JOIN users_main AS um ON b.UserID = um.ID\n\t\tORDER BY Time DESC\n\t\tLIMIT 20");
    $Blog = $DB->to_array();
    $Cache->cache_value('blog', $Blog, 1209600);
}
$JsonBlog = array();
for ($i = 0; $i < 5; $i++) {
    list($BlogID, $Author, $AuthorID, $Title, $Body, $BlogTime, $ThreadID) = $Blog[$i];
    $JsonBlog[] = array('blogId' => (int) $BlogID, 'author' => $Author, 'title' => $Title, 'bbBody' => $Body, 'body' => Text::full_format($Body), 'blogTime' => $BlogTime, 'threadId' => (int) $ThreadID);
}
$JsonAnnouncements = array();
$Count = 0;
foreach ($News as $NewsItem) {
    list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
    if (strtotime($NewsTime) > time()) {
        continue;
    }
    $JsonAnnouncements[] = array('newsId' => (int) $NewsID, 'title' => $Title, 'bbBody' => $Body, 'body' => Text::full_format($Body), 'newsTime' => $NewsTime);
    if (++$Count > 4) {
        break;
    }
}
json_die("success", array('announcements' => $JsonAnnouncements, 'blogPosts' => $JsonBlog));
Exemple #14
0
<?php

//Don't allow bigger queries than specified below regardless of called function
$SizeLimit = 10;
$Count = (int) $_GET['count'];
$Offset = (int) $_GET['offset'];
if (!isset($_GET['count']) || !isset($_GET['offset']) || $Count <= 0 || $Offset < 0 || $Count > $SizeLimit) {
    json_die('failure');
}
Text::$TOC = true;
global $DB;
$DB->query("\n\t\tSELECT\n\t\t\tID,\n\t\t\tTitle,\n\t\t\tBody,\n\t\t\tTime\n\t\tFROM news\n\t\tORDER BY Time DESC\n\t\tLIMIT {$Offset}, {$Count}");
$News = $DB->to_array(false, MYSQLI_NUM, false);
$NewsResponse = array();
foreach ($News as $NewsItem) {
    list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
    array_push($NewsResponse, array($NewsID, Text::full_format($Title), time_diff($NewsTime), Text::full_format($Body)));
}
json_die('success', json_encode($NewsResponse));
Exemple #15
0
<?php

/**********************************************************************
 *>>>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
 **********************************************************************/
if (empty($_GET['search'])) {
    json_die("failure", "no search terms");
} else {
    $_GET['username'] = $_GET['search'];
}
define('USERS_PER_PAGE', 30);
if (isset($_GET['username'])) {
    $_GET['username'] = trim($_GET['username']);
    list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
    $DB->query("\n\t\tSELECT\n\t\t\tSQL_CALC_FOUND_ROWS\n\t\t\tID,\n\t\t\tUsername,\n\t\t\tEnabled,\n\t\t\tPermissionID,\n\t\t\tDonor,\n\t\t\tWarned,\n\t\t\tAvatar\n\t\tFROM users_main AS um\n\t\t\tJOIN users_info AS ui ON ui.UserID = um.ID\n\t\tWHERE Username LIKE '%" . db_string($_GET['username']) . "%'\n\t\tORDER BY Username\n\t\tLIMIT {$Limit}");
    $Results = $DB->to_array();
    $DB->query('SELECT FOUND_ROWS();');
    list($NumResults) = $DB->next_record();
}
$JsonUsers = array();
foreach ($Results as $Result) {
    list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned, $Avatar) = $Result;
    $JsonUsers[] = array('userId' => (int) $UserID, 'username' => $Username, 'donor' => $Donor == 1, 'warned' => $Warned != '0000-00-00 00:00:00', 'enabled' => $Enabled == 2 ? false : true, 'class' => Users::make_class_string($PermissionID), 'avatar' => $Avatar);
}
json_print("success", array('currentPage' => (int) $Page, 'pages' => ceil($NumResults / USERS_PER_PAGE), 'results' => $JsonUsers));
Exemple #16
0
<?php

/*
User topic subscription page
*/
if (!empty($LoggedUser['DisableForums'])) {
    json_die('failure');
}
if (isset($LoggedUser['PostsPerPage'])) {
    $PerPage = $LoggedUser['PostsPerPage'];
} else {
    $PerPage = POSTS_PER_PAGE;
}
list($Page, $Limit) = Format::page_limit($PerPage);
$ShowUnread = !isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread'];
$ShowCollapsed = !isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse'];
$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
		JOIN users_subscriptions AS s ON s.TopicID = t.ID
		LEFT JOIN forums AS f ON f.ID = t.ForumID
		LEFT JOIN forums_last_read_topics AS l ON p.TopicID = l.TopicID AND l.UserID = s.UserID
	WHERE s.UserID = ' . $LoggedUser['ID'] . '
		AND p.ID <= IFNULL(l.PostID, t.LastPostID)
		AND ' . Forums::user_forums_sql();
if ($ShowUnread) {
    $sql .= '
		AND IF(l.PostID IS NULL OR (t.IsLocked = \'1\' && t.IsSticky = \'0\'), t.LastPostID, l.PostID) < t.LastPostID';
 * 
 */
$urlArgs = _cg("url_vars");
if (isset($_REQUEST['edit_agent']) && trim($_REQUEST['edit_agent']) == '1') {
    $deal_nm_arr = array();
    $deal_nm = '';
    $deal_nm_arr = qs("SELECT * FROM pd_sources WHERE id = '" . $_REQUEST["deal_id"] . "'");
    $deal_nm = $deal_nm_arr["source_name"];
    $res_arr = array();
    $res_arr['deal_nm'] = $deal_nm;
    ob_start();
    include 'call_distribution_select_agent_ui.inc.php';
    $selection_content = ob_get_contents();
    ob_end_clean();
    $res_arr['selection_content'] = $selection_content;
    json_die(true, $res_arr);
    die;
}
if (isset($_REQUEST['update_call']) && $_REQUEST['update_call'] == 1) {
    //$user_list_update = Call_distribution::AllLeadSorceNull(); //First Null the Call List
    $json_user_list = '';
    $user_list = array();
    if (isset($_REQUEST["user_list"]) && $_REQUEST["user_list"] != '') {
        $user_list = $_REQUEST["user_list"];
    }
    // Conver array to json format //
    if (!empty($user_list) && count($user_list) > 0) {
        $json_user_list = json_encode($user_list);
    }
    $source_pk_id = '';
    $source_pk_id = trim($_REQUEST["source_pk_id"]);
Exemple #18
0
        $DB->query("\n\t\t\tSELECT COUNT(ID)\n\t\t\tFROM forums_topics\n\t\t\tWHERE ForumID = '{$ForumID}'\n\t\t\t\tAND IsSticky = '1'");
        list($Stickies) = $DB->next_record();
        $Cache->cache_value("forums_{$ForumID}", array($Forum, '', 0, $Stickies), 0);
    }
}
if (!isset($Forums[$ForumID])) {
    json_die("failure");
}
// Make sure they're allowed to look at the page
if (!check_perms('site_moderate_forums')) {
    if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) {
        json_die("failure", "insufficient permissions to view page");
    }
}
if ($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) {
    json_die("failure", "insufficient permissions to view page");
}
$ForumName = display_str($Forums[$ForumID]['Name']);
$JsonSpecificRules = array();
foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) {
    $Thread = Forums::get_thread_info($ThreadIDs);
    $JsonSpecificRules[] = array('threadId' => (int) $ThreadIDs, 'thread' => display_str($Thread['Title']));
}
$Pages = Format::get_pages($Page, $Forums[$ForumID]['NumTopics'], TOPICS_PER_PAGE, 9);
if (count($Forum) === 0) {
    print json_encode(array('status' => 'success', 'forumName' => $ForumName, 'threads' => array()));
} else {
    // forums_last_read_topics is a record of the last post a user read in a topic, and what page that was on
    $DB->query("\n\t\tSELECT\n\t\t\tl.TopicID,\n\t\t\tl.PostID,\n\t\t\tCEIL(\n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(p.ID)\n\t\t\t\t\tFROM forums_posts AS p\n\t\t\t\t\tWHERE p.TopicID = l.TopicID\n\t\t\t\t\t\tAND p.ID <= l.PostID\n\t\t\t\t) / {$PerPage}\n\t\t\t) AS Page\n\t\tFROM forums_last_read_topics AS l\n\t\tWHERE l.TopicID IN(" . implode(', ', array_keys($Forum)) . ')
			AND l.UserID = \'' . $LoggedUser['ID'] . '\'');
    // Turns the result set into a multi-dimensional array, with
Exemple #19
0
    die(json_encode(array("error" => "you are not in this group")));
}
$body = trim($_POST['body']);
if ($body === "") {
    json_die(400, "empty post");
}
$stmt = $db->prepare("INSERT INTO group_posts (group_id, user_id, body) VALUES (:group_id, :user_id, :body)");
$stmt->bindValue(":group_id", $group['id'], PDO::PARAM_INT);
$stmt->bindValue(":user_id", $user['id'], PDO::PARAM_INT);
$stmt->bindValue(":body", $body);
$stmt->execute();
$post_id = $db->lastInsertId();
// If successful, return the rendered post
$stmt = $db->prepare("SELECT body, created_at FROM group_posts WHERE id = :post_id");
$stmt->bindValue(":post_id", $post_id);
$stmt->execute();
$post = $stmt->fetch();
if ($post === false) {
    // shouldn't happen
    json_die(500, "couldn't fetch post");
}
$date = new DateTime($post['created_at']);
$body = "";
$body .= '<article id="post-' . $post_id . '">';
$body .= '<b>' . htmlspecialchars($user['name']);
$body .= ' on ' . htmlspecialchars($date->format("M j"));
$body .= ' at ' . htmlspecialchars($date->format("H:i"));
$body .= '</b>';
$body .= '<p>' . htmlspecialchars($post['body']) . '</p>';
$body .= '</article>';
echo json_encode(array("id" => $post_id, "post" => $body));
Exemple #20
0
<?php

/**********************************************************************
 *>>>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
 **********************************************************************/
if (empty($_GET['search'])) {
    json_die("failure", "no search terms");
} else {
    $_GET['username'] = $_GET['search'];
}
define('USERS_PER_PAGE', 30);
if (isset($_GET['username'])) {
    $_GET['username'] = trim($_GET['username']);
    list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
    $DB->query("\n\t\tSELECT\n\t\t\tSQL_CALC_FOUND_ROWS\n\t\t\tID,\n\t\t\tUsername,\n\t\t\tEnabled,\n\t\t\tPermissionID,\n\t\t\tDonor,\n\t\t\tWarned,\n\t\t\tAvatar\n\t\tFROM users_main AS um\n\t\t\tJOIN users_info AS ui ON ui.UserID = um.ID\n\t\tWHERE Username LIKE '%" . db_string($_GET['username']) . "%'\n\t\tORDER BY Username\n\t\tLIMIT {$Limit}");
    $Results = $DB->to_array();
    $DB->query('SELECT FOUND_ROWS();');
    list($NumResults) = $DB->next_record();
}
$JsonUsers = array();
foreach ($Results as $Result) {
    list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned, $Avatar) = $Result;
    $JsonUsers[] = array('userId' => (int) $UserID, 'username' => $Username, 'donor' => $Donor == 1, 'warned' => $Warned != '0000-00-00 00:00:00', 'enabled' => $Enabled == 2 ? false : true, 'class' => Users::make_class_string($PermissionID), 'avatar' => $Avatar);
}
json_die("success", array('currentPage' => (int) $Page, 'pages' => ceil($NumResults / USERS_PER_PAGE), 'results' => $JsonUsers));
Exemple #21
0
    }
}
if ($NumResults == 0) {
    json_die("success", array('currentPage' => 1, 'pages' => 1, 'results' => array()));
} else {
    $JsonResults = array();
    $TimeCompare = 1267643718;
    // Requests v2 was implemented 2010-03-03 20:15:18
    $Requests = Requests::get_requests(array_keys($SphRequests));
    foreach ($SphRequests as $RequestID => $SphRequest) {
        $Request = $Requests[$RequestID];
        $VoteCount = $SphRequest['votes'];
        $Bounty = $SphRequest['bounty'] * 1024;
        // Sphinx stores bounty in kB
        $Requestor = Users::user_info($Request['UserID']);
        $Filler = $Request['FillerID'] ? Users::user_info($Request['FillerID']) : null;
        if ($Request['CategoryID'] == 0) {
            $CategoryName = 'Unknown';
        } else {
            $CategoryName = $Categories[$Request['CategoryID'] - 1];
        }
        $JsonArtists = array();
        if ($CategoryName == 'Music') {
            $ArtistForm = Requests::get_artists($RequestID);
            $JsonArtists = array_values($ArtistForm);
        }
        $Tags = $Request['Tags'];
        $JsonResults[] = array('requestId' => (int) $RequestID, 'requestorId' => (int) $Requestor['ID'], 'requestorName' => $Requestor['Username'], 'timeAdded' => $Request['TimeAdded'], 'lastVote' => $Request['LastVote'], 'voteCount' => (int) $VoteCount, 'bounty' => (int) $Bounty, 'categoryId' => (int) $Request['CategoryID'], 'categoryName' => $CategoryName, 'artists' => $JsonArtists, 'title' => $Request['Title'], 'year' => (int) $Request['Year'], 'image' => $Request['Image'], 'description' => $Request['Description'], 'recordLabel' => $Request['RecordLabel'], 'catalogueNumber' => $Request['CatalogueNumber'], 'releaseType' => $ReleaseTypes[$Request['ReleaseType']], 'bitrateList' => $Request['BitrateList'], 'formatList' => $Request['FormatList'], 'mediaList' => $Request['MediaList'], 'logCue' => $Request['LogCue'], 'isFilled' => $Request['TorrentID'] > 0, 'fillerId' => (int) $Request['FillerID'], 'fillerName' => $Filler ? $Filler['Username'] : '', 'torrentId' => (int) $Request['TorrentID'], 'timeFilled' => $Request['TimeFilled'] == 0 ? '' : $Request['TimeFilled']);
    }
    json_die("success", array('currentPage' => intval($Page), 'pages' => ceil($NumResults / REQUESTS_PER_PAGE), 'results' => $JsonResults));
}
Exemple #22
0
<?php

$UserID = (int) $_GET['userid'];
$Limit = (int) $_GET['limit'];
if (empty($UserID) || $Limit > 50) {
    json_die("failure", "bad parameters");
}
if (empty($Limit)) {
    $Limit = 15;
}
$Results = array();
if (check_paranoia_here('snatched')) {
    $DB->query("\n\t\tSELECT\n\t\t\tg.ID,\n\t\t\tg.Name,\n\t\t\tg.WikiImage\n\t\tFROM xbt_snatched AS s\n\t\t\tINNER JOIN torrents AS t ON t.ID = s.fid\n\t\t\tINNER JOIN torrents_group AS g ON t.GroupID = g.ID\n\t\tWHERE s.uid = '{$UserID}'\n\t\t\tAND g.CategoryID = '1'\n\t\t\tAND g.WikiImage != ''\n\t\tGROUP BY g.ID\n\t\tORDER BY s.tstamp DESC\n\t\tLIMIT {$Limit}");
    $RecentSnatches = $DB->to_array(false, MYSQLI_ASSOC);
    $Artists = Artists::get_artists($DB->collect('ID'));
    foreach ($RecentSnatches as $Key => $SnatchInfo) {
        $RecentSnatches[$Key]['artists'][] = $Artists[$SnatchInfo['ID']];
        $RecentSnatches[$Key]['ID'] = (int) $RecentSnatches[$Key]['ID'];
    }
    $Results['snatches'] = $RecentSnatches;
} else {
    $Results['snatches'] = "hidden";
}
if (check_paranoia_here('uploads')) {
    $DB->query("\n\t\tSELECT\n\t\t\tg.ID,\n\t\t\tg.Name,\n\t\t\tg.WikiImage\n\t\tFROM torrents_group AS g\n\t\t\tINNER JOIN torrents AS t ON t.GroupID = g.ID\n\t\tWHERE t.UserID = '{$UserID}'\n\t\t\tAND g.CategoryID = '1'\n\t\t\tAND g.WikiImage != ''\n\t\tGROUP BY g.ID\n\t\tORDER BY t.Time DESC\n\t\tLIMIT {$Limit}");
    $RecentUploads = $DB->to_array(false, MYSQLI_ASSOC);
    $Artists = Artists::get_artists($DB->collect('ID'));
    foreach ($RecentUploads as $Key => $UploadInfo) {
        $RecentUploads[$Key]['artists'][] = $Artists[$UploadInfo['ID']];
        $RecentUploads[$Key]['ID'] = (int) $RecentUploads[$Key]['ID'];
    }
Exemple #23
0
        $Cache->cache_value('notifications_new_' . $LoggedUser['ID'], $NewNotifications, 0);
    }
}
// News
$MyNews = $LoggedUser['LastReadNews'];
$CurrentNews = $Cache->get_value('news_latest_id');
if ($CurrentNews === false) {
    $DB->query("\n\t\tSELECT ID\n\t\tFROM news\n\t\tORDER BY Time DESC\n\t\tLIMIT 1");
    if ($DB->record_count() === 1) {
        list($CurrentNews) = $DB->next_record();
    } else {
        $CurrentNews = -1;
    }
    $Cache->cache_value('news_latest_id', $CurrentNews, 0);
}
// Blog
$MyBlog = $LoggedUser['LastReadBlog'];
$CurrentBlog = $Cache->get_value('blog_latest_id');
if ($CurrentBlog === false) {
    $DB->query("\n\t\tSELECT ID\n\t\tFROM blog\n\t\tWHERE Important = 1\n\t\tORDER BY Time DESC\n\t\tLIMIT 1");
    if ($DB->record_count() === 1) {
        list($CurrentBlog) = $DB->next_record();
    } else {
        $CurrentBlog = -1;
    }
    $Cache->cache_value('blog_latest_id', $CurrentBlog, 0);
}
// Subscriptions
$NewSubscriptions = Subscriptions::has_new_subscriptions();
json_die("success", array('username' => $LoggedUser['Username'], 'id' => (int) $LoggedUser['ID'], 'authkey' => $LoggedUser['AuthKey'], 'passkey' => $LoggedUser['torrent_pass'], 'notifications' => array('messages' => (int) $NewMessages, 'notifications' => (int) $NewNotifications, 'newAnnouncement' => $MyNews < $CurrentNews, 'newBlog' => $MyBlog < $CurrentBlog, 'newSubscriptions' => $NewSubscriptions == 1), 'userstats' => array('uploaded' => (int) $LoggedUser['BytesUploaded'], 'downloaded' => (int) $LoggedUser['BytesDownloaded'], 'ratio' => (double) $Ratio, 'requiredratio' => (double) $LoggedUser['RequiredRatio'], 'class' => $ClassLevels[$LoggedUser['Class']]['Name'])));
Exemple #24
0
<?php

if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    json_die("failure", "bad id parameter");
}
$UserID = $_GET['id'];
if ($UserID == $LoggedUser['ID']) {
    $OwnProfile = true;
} else {
    $OwnProfile = false;
}
// Always view as a normal user.
$DB->query("\n\tSELECT\n\t\tm.Username,\n\t\tm.Email,\n\t\tm.LastAccess,\n\t\tm.IP,\n\t\tp.Level AS Class,\n\t\tm.Uploaded,\n\t\tm.Downloaded,\n\t\tm.RequiredRatio,\n\t\tm.Enabled,\n\t\tm.Paranoia,\n\t\tm.Invites,\n\t\tm.Title,\n\t\tm.torrent_pass,\n\t\tm.can_leech,\n\t\ti.JoinDate,\n\t\ti.Info,\n\t\ti.Avatar,\n\t\ti.Donor,\n\t\ti.Warned,\n\t\tCOUNT(posts.id) AS ForumPosts,\n\t\ti.Inviter,\n\t\ti.DisableInvites,\n\t\tinviter.username\n\tFROM users_main AS m\n\t\tJOIN users_info AS i ON i.UserID = m.ID\n\t\tLEFT JOIN permissions AS p ON p.ID = m.PermissionID\n\t\tLEFT JOIN users_main AS inviter ON i.Inviter = inviter.ID\n\t\tLEFT JOIN forums_posts AS posts ON posts.AuthorID = m.ID\n\tWHERE m.ID = {$UserID}\n\tGROUP BY AuthorID");
if (!$DB->has_results()) {
    // If user doesn't exist
    json_die("failure", "no such user");
}
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $Enabled, $Paranoia, $Invites, $CustomTitle, $torrent_pass, $DisableLeech, $JoinDate, $Info, $Avatar, $Donor, $Warned, $ForumPosts, $InviterID, $DisableInvites, $InviterName, $RatioWatchEnds, $RatioWatchDownload) = $DB->next_record(MYSQLI_NUM, array(9, 11));
$Paranoia = unserialize($Paranoia);
if (!is_array($Paranoia)) {
    $Paranoia = array();
}
$ParanoiaLevel = 0;
foreach ($Paranoia as $P) {
    $ParanoiaLevel++;
    if (strpos($P, '+') !== false) {
        $ParanoiaLevel++;
    }
}
// Raw time is better for JSON.
//$JoinedDate = time_diff($JoinDate);
Exemple #25
0
    }
} else {
    $ThreadID = $_GET['threadid'];
}
if (isset($_GET['pp'])) {
    $PerPage = $_GET['pp'];
} elseif (isset($LoggedUser['PostsPerPage'])) {
    $PerPage = $LoggedUser['PostsPerPage'];
} else {
    $PerPage = POSTS_PER_PAGE;
}
//---------- Get some data to start processing
// Thread information, constant across all pages
$ThreadInfo = Forums::get_thread_info($ThreadID, true, true);
if ($ThreadInfo === null) {
    json_die('failure', 'no such thread exists');
}
$ForumID = $ThreadInfo['ForumID'];
// Make sure they're allowed to look at the page
if (!Forums::check_forumperm($ForumID)) {
    print json_encode(array('status' => 'failure'));
    die;
}
//Post links utilize the catalogue & key params to prevent issues with custom posts per page
if ($ThreadInfo['Posts'] > $PerPage) {
    if (isset($_GET['post']) && is_number($_GET['post'])) {
        $PostNum = $_GET['post'];
    } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) {
        $DB->query("\n\t\t\tSELECT COUNT(ID)\n\t\t\tFROM forums_posts\n\t\t\tWHERE TopicID = {$ThreadID}\n\t\t\t\tAND ID <= {$_GET['postid']}");
        list($PostNum) = $DB->next_record();
    } else {
Exemple #26
0
}
if (check_paranoia_here('seeding+') || check_paranoia_here('leeching+')) {
    $DB->query("\n\t\tSELECT IF(remaining = 0, 'Seeding', 'Leeching') AS Type, COUNT(x.uid)\n\t\tFROM xbt_files_users AS x\n\t\t\tINNER JOIN torrents AS t ON t.ID = x.fid\n\t\tWHERE x.uid = '{$UserID}'\n\t\t\tAND x.active = 1\n\t\tGROUP BY Type");
    $PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
    if (check_paranoia('seeding+')) {
        $Seeding = isset($PeerCount['Seeding']) ? $PeerCount['Seeding'][1] : 0;
        $CommStats['seeding'] = number_format($Seeding);
    }
    if (check_paranoia('leeching+')) {
        $CommStats['leeching'] = isset($PeerCount['Leeching']) ? number_format($PeerCount['Leeching'][1]) : 0;
    }
}
if (check_paranoia_here('snatched+')) {
    $DB->query("\n\t\tSELECT COUNT(x.uid), COUNT(DISTINCT x.fid)\n\t\tFROM xbt_snatched AS x\n\t\t\tINNER JOIN torrents AS t ON t.ID = x.fid\n\t\tWHERE x.uid = '{$UserID}'");
    list($Snatched, $UniqueSnatched) = $DB->next_record(MYSQLI_NUM, false);
    $CommStats['snatched'] = number_format($Snatched);
    if (check_perms('site_view_torrent_snatchlist', $User['Class'])) {
        $CommStats['usnatched'] = number_format($UniqueSnatched);
    }
    if (check_paranoia_here('seeding+') && check_paranoia_here('snatched+') && $UniqueSnatched > 0) {
        $CommStats['seedingperc'] = 100 * min(1, round($Seeding / $UniqueSnatched, 2));
    }
}
if (check_perms('site_view_torrent_snatchlist', $Class)) {
    $DB->query("\n\t\tSELECT COUNT(ud.UserID), COUNT(DISTINCT ud.TorrentID)\n\t\tFROM users_downloads AS ud\n\t\t\tJOIN torrents AS t ON t.ID = ud.TorrentID\n\t\tWHERE ud.UserID = '{$UserID}'");
    list($NumDownloads, $UniqueDownloads) = $DB->next_record(MYSQLI_NUM, false);
    $CommStats['downloaded'] = number_format($NumDownloads);
    $CommStats['udownloaded'] = number_format($UniqueDownloads);
}
json_die('success', $CommStats);
Exemple #27
0
<?php

if (empty($_GET['id']) || !is_number($_GET['id'])) {
    json_die("failure");
}
list($NumComments, $Page, $Thread) = Comments::load('torrents', (int) $_GET['id'], false);
//---------- Begin printing
$JsonComments = array();
foreach ($Thread as $Key => $Post) {
    list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
    list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
    $JsonComments[] = array('postId' => (int) $PostID, 'addedTime' => $AddedTime, 'bbBody' => $Body, 'body' => Text::full_format($Body), 'editedUserId' => (int) $EditedUserID, 'editedTime' => $EditedTime, 'editedUsername' => $EditedUsername, 'userinfo' => array('authorId' => (int) $AuthorID, 'authorName' => $Username, 'artist' => $Artist == 1, 'donor' => $Donor == 1, 'warned' => $Warned != '0000-00-00 00:00:00', 'avatar' => $Avatar, 'enabled' => $Enabled == 2 ? false : true, 'userTitle' => $UserTitle));
}
json_die("success", array('page' => (int) $Page, 'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE), 'comments' => $JsonComments));
Exemple #28
0
    $Ratio = Format::get_ratio($Uploaded, $Downloaded, 5);
} else {
    $Ratio = null;
}
if (!check_paranoia_here('uploaded')) {
    $Uploaded = null;
}
if (!check_paranoia_here('downloaded')) {
    $Downloaded = null;
}
if (isset($RequiredRatio) && !check_paranoia_here('requiredratio')) {
    $RequiredRatio = null;
}
if ($ParanoiaLevel == 0) {
    $ParanoiaLevelText = 'Off';
} elseif ($ParanoiaLevel == 1) {
    $ParanoiaLevelText = 'Very Low';
} elseif ($ParanoiaLevel <= 5) {
    $ParanoiaLevelText = 'Low';
} elseif ($ParanoiaLevel <= 20) {
    $ParanoiaLevelText = 'High';
} else {
    $ParanoiaLevelText = 'Very high';
}
//Bugfix for no access time available
if ($LastAccess == '0000-00-00 00:00:00') {
    $LastAccess = '';
}
header('Content-Type: text/plain; charset=utf-8');
json_die("success", array('username' => $Username, 'avatar' => $Avatar, 'isFriend' => $Friend, 'profileText' => Text::full_format($Info), 'stats' => array('joinedDate' => $JoinDate, 'lastAccess' => $LastAccess, 'uploaded' => $Uploaded == null ? null : (int) $Uploaded, 'downloaded' => $Downloaded == null ? null : (int) $Downloaded, 'ratio' => $Ratio, 'requiredRatio' => $RequiredRatio == null ? null : (double) $RequiredRatio), 'ranks' => array('uploaded' => $UploadedRank, 'downloaded' => $DownloadedRank, 'uploads' => $UploadsRank, 'requests' => $RequestRank, 'bounty' => $BountyRank, 'posts' => $PostRank, 'artists' => $ArtistsRank, 'overall' => $OverallRank == null ? 0 : $OverallRank), 'personal' => array('class' => $ClassLevels[$Class]['Name'], 'paranoia' => $ParanoiaLevel, 'paranoiaText' => $ParanoiaLevelText, 'donor' => $Donor == 1, 'warned' => $Warned != '0000-00-00 00:00:00', 'enabled' => $Enabled == '1' || $Enabled == '0' || !$Enabled, 'passkey' => $torrent_pass), 'community' => array('posts' => (int) $ForumPosts, 'torrentComments' => (int) $NumComments, 'collagesStarted' => $NumCollages == null ? null : (int) $NumCollages, 'collagesContrib' => $NumCollageContribs == null ? null : (int) $NumCollageContribs, 'requestsFilled' => $RequestsFilled == null ? null : (int) $RequestsFilled, 'requestsVoted' => $RequestsVoted == null ? null : (int) $RequestsVoted, 'perfectFlacs' => $PerfectFLACs == null ? null : (int) $PerfectFLACs, 'uploaded' => $Uploads == null ? null : (int) $Uploads, 'groups' => $UniqueGroups == null ? null : (int) $UniqueGroups, 'seeding' => $Seeding == null ? null : (int) $Seeding, 'leeching' => $Leeching == null ? null : (int) $Leeching, 'snatched' => $Snatched == null ? null : (int) $Snatched, 'invited' => $Invited == null ? null : (int) $Invited)));
Exemple #29
0
        break;
    case 'user_recents':
        require SERVER_ROOT . '/sections/ajax/user_recents.php';
        break;
    case 'collage':
        require SERVER_ROOT . '/sections/ajax/collage.php';
        break;
    case 'raw_bbcode':
        require SERVER_ROOT . '/sections/ajax/raw_bbcode.php';
        break;
    case 'get_user_notifications':
        require SERVER_ROOT . '/sections/ajax/get_user_notifications.php';
        break;
    case 'clear_user_notification':
        require SERVER_ROOT . '/sections/ajax/clear_user_notification.php';
        break;
    case 'pushbullet_devices':
        require SERVER_ROOT . '/sections/ajax/pushbullet_devices.php';
        break;
    default:
        // If they're screwing around with the query string
        json_die("failure");
}
function pullmediainfo($Array)
{
    $NewArray = array();
    foreach ($Array as $Item) {
        $NewArray[] = array('id' => (int) $Item['id'], 'name' => $Item['name']);
    }
    return $NewArray;
}
Exemple #30
0
        $JsonSimilar[] = array('artistId' => (int) $Similar['ArtistID'], 'name' => $Similar['Name'], 'score' => (int) $Similar['Score'], 'similarId' => (int) $Similar['SimilarID']);
    }
}
$JsonRequests = array();
foreach ($Requests as $RequestID => $Request) {
    $JsonRequests[] = array('requestId' => (int) $RequestID, 'categoryId' => (int) $Request['CategoryID'], 'title' => $Request['Title'], 'year' => (int) $Request['Year'], 'timeAdded' => $Request['TimeAdded'], 'votes' => (int) $Request['Votes'], 'bounty' => (int) $Request['Bounty']);
}
//notifications disabled by default
$notificationsEnabled = false;
if (check_perms('site_torrents_notify')) {
    if (($Notify = $Cache->get_value('notify_artists_' . $LoggedUser['ID'])) === false) {
        $DB->query("\n\t\t\tSELECT ID, Artists\n\t\t\tFROM users_notify_filters\n\t\t\tWHERE UserID = '{$LoggedUser['ID']}'\n\t\t\t\tAND Label = 'Artist notifications'\n\t\t\tLIMIT 1");
        $Notify = $DB->next_record(MYSQLI_ASSOC, false);
        $Cache->cache_value('notify_artists_' . $LoggedUser['ID'], $Notify, 0);
    }
    if (stripos($Notify['Artists'], "|{$Name}|") === false) {
        $notificationsEnabled = false;
    } else {
        $notificationsEnabled = true;
    }
}
// Cache page for later use
if ($RevisionID) {
    $Key = "artist_{$ArtistID}" . "_revision_{$RevisionID}";
} else {
    $Key = "artist_{$ArtistID}";
}
$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, array(), array(), $VanityHouseArtist));
$Cache->cache_value($Key, $Data, 3600);
json_die("success", array('id' => (int) $ArtistID, 'name' => $Name, 'notificationsEnabled' => $notificationsEnabled, 'hasBookmarked' => Bookmarks::has_bookmarked('artist', $ArtistID), 'image' => $Image, 'body' => Text::full_format($Body), 'vanityHouse' => $VanityHouseArtist == 1, 'tags' => array_values($Tags), 'similarArtists' => $JsonSimilar, 'statistics' => array('numGroups' => $NumGroups, 'numTorrents' => $NumTorrents, 'numSeeders' => $NumSeeders, 'numLeechers' => $NumLeechers, 'numSnatches' => $NumSnatches), 'torrentgroup' => $JsonTorrents, 'requests' => $JsonRequests));