예제 #1
0
파일: user.php 프로젝트: Kufirc/Gazelle
    $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_print("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' => $NumComments == null ? null : (int) $NumComments, 'artistComments' => $NumArtistComments == null ? null : (int) $NumArtistComments, 'collageComments' => $NumCollageComments == null ? null : (int) $NumCollageComments, 'requestComments' => $NumRequestComments == null ? null : (int) $NumRequestComments, 'collagesStarted' => $NumCollages == null ? null : (int) $NumCollages, 'collagesContrib' => $NumCollageContribs == null ? null : (int) $NumCollageContribs, 'requestsFilled' => $RequestsFilled == null ? null : (int) $RequestsFilled, 'bountyEarned' => $TotalBounty == null ? null : (int) $TotalBounty, 'requestsVoted' => $RequestsVoted == null ? null : (int) $RequestsVoted, 'bountySpent' => $TotalSpent == null ? null : (int) $TotalSpent, '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, 'artistsAdded' => $ArtistsAdded == null ? null : (int) $ArtistsAdded)));
예제 #2
0
function webcommandline_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    ob_start();
    $opt = $_REQUEST;
    if ($opt['login-class'] !== 'client' && $opt['login-class'] !== 'auxiliary') {
        json_print("error", $opt, "__error_only_clients_and_auxiliary_allowed_to_login");
        log_log("web_command", "__error_only_clients_and_auxiliary_allowed_to_login");
        exit;
    }
    log_log("web_command", var_export($opt, true));
    //initProgram('admin');
    if (!check_raw_password($opt['login-class'], $opt['login-name'], $opt['login-password'])) {
        json_print("error", $opt, "_error_login_error");
        log_log("web_command", "__error_login_error");
        exit;
    }
    if (check_disable_admin($opt['login-name'])) {
        json_print("error", $opt, "_error_login_error");
        log_log("web_command", "__error_admin_is_disabled");
        exit;
    }
    $classname = $opt['login-class'];
    $lobject = new $classname(null, 'localhost', $opt['login-name']);
    $lobject->get();
    if ($lobject->dbaction === 'add') {
        json_print("error", $opt, "__error_login_error\n");
        log_log("web_command", "__error_login_error");
        exit;
    }
    if ($classname === 'auxiliary') {
        $login = $lobject->getParentO();
        $login->__auxiliary_object = $lobject;
    } else {
        $login = $lobject;
    }
    if ($opt['action'] === 'simplelist') {
        $must = array('action', 'resource');
    } else {
        if ($opt['action'] === 'getproperty') {
            $must = array('action');
        } else {
            $must = array('action', 'class');
        }
    }
    $pk = array_keys($opt);
    foreach ($must as $m) {
        if (!array_search_bool($m, $pk)) {
            $string = implode("_", $must);
            json_print("error", $opt, "__error_need_{$string}\n");
            log_log("web_command", "__error_need_{$string}");
            exit;
        }
    }
    $func = "__cmd_desc_{$opt['action']}";
    try {
        $list = $func($opt);
    } catch (exception $e) {
        while (@ob_end_clean()) {
        }
        json_print("error", $opt, "__error_{$e->getMessage()}");
        log_log("web_command", "__error_{$e->getMessage()}");
        exit;
    }
    if ($opt['action'] === 'simplelist') {
        json_print_result($opt, $list);
    } else {
        if ($opt['action'] === 'getproperty') {
            json_print_result($opt, $list);
        } else {
            $out = "__success_{$opt['action']}_successful_on_{$opt['class']}_{$opt['name']}";
            json_print("success", $opt, $out);
        }
    }
    log_log("web_command", "__success_{$opt['action']}");
    exit;
}
예제 #3
0
파일: info.php 프로젝트: Kufirc/Gazelle
        $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_print("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'])));
예제 #4
0
<?php

ini_set('display_errors', 1);
require_once "job_fun.php";
require_once "email_function.php";
$jobid = $_GET['jobid'];
$key = create_unique_key();
$link = job_edit_link($key);
$email = "*****@*****.**";
//$email_body = edit_job($link);
$conn = connect_db();
if (mysqli_connect_errno($conn)) {
    $msg = "database_connect error";
    json_print($msg, 'error');
    exit;
}
// $email_status = queue_job_email($conn, $email, $email_body);
// 	if ( ! $email_status ) {
// 		$msg = "edit_job_error";
// 		json_print($msg, 'error');
// 		exit();
// 	}
$jobid = sanitize_fieldname($conn, $jobid);
$result = job_details($conn, $jobid);
if (count($result) < 1) {
    $msg = "job_empty_error";
    json_print($msg, 'error');
    exit;
}
json_print($result, "success");
예제 #5
0
<?php

ini_set('display_errors', 1);
require_once "job_fun.php";
$postdata = file_get_contents("php://input");
$val_stdobj = json_decode($postdata);
$newval = (array) $val_stdobj;
$conndb = connect_db();
if (mysqli_connect_errno($conndb)) {
    $msg = "database_connect error";
    json_print($msg, 'error');
    exit;
}
$val = extract_job($conndb, $newval);
if (!insert_jobs($conndb, $val)) {
    $msg = "insert_job_error";
    json_print($msg, 'error');
    exit;
}
json_print("successfully created job", "success");
예제 #6
0
파일: torrent.php 프로젝트: Kufirc/Gazelle
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 \'|\')']);
$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, 'tags' => $TagList);
$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_print("success", array('group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)));
예제 #7
0
 function get()
 {
     $queryString = $this->queryString();
     $result = $this->orm_db->query($queryString);
     if ($result === false) {
         echo 'SQL ERROR <br/>';
         echo $queryString . '<br/>';
         echo $this->orm_db->lastError() . '<br/>';
         json_print($this->queryArray);
     }
     return $result;
 }
예제 #8
0
			f.Name AS ForumName,
			p.TopicID,
			t.Title,
			p.Body,
			t.LastPostID,
			t.IsLocked,
			t.IsSticky,
			p.ID,
			um.ID,
			um.Username,
			ui.Avatar,
			p.EditedUserID,
			p.EditedTime,
			ed.Username AS EditedUsername
		FROM forums_posts AS p
			LEFT JOIN forums_topics AS t ON t.ID = p.TopicID
			LEFT JOIN forums AS f ON f.ID = t.ForumID
			LEFT JOIN users_main AS um ON um.ID = p.AuthorID
			LEFT JOIN users_info AS ui ON ui.UserID = um.ID
			LEFT JOIN users_main AS ed ON ed.ID = um.ID
		WHERE p.ID IN (' . implode(',', $PostIDs) . ')
		ORDER BY f.Name ASC, t.LastPostID DESC';
    $DB->query($sql);
}
$JsonPosts = array();
while (list($ForumID, $ForumName, $TopicID, $ThreadTitle, $Body, $LastPostID, $Locked, $Sticky, $PostID, $AuthorID, $AuthorName, $AuthorAvatar, $EditedUserID, $EditedTime, $EditedUsername) = $DB->next_record()) {
    $JsonPost = array('forumId' => (int) $ForumID, 'forumName' => $ForumName, 'threadId' => (int) $TopicID, 'threadTitle' => $ThreadTitle, 'postId' => (int) $PostID, 'lastPostId' => (int) $LastPostID, 'locked' => $Locked == 1, 'new' => $PostID < $LastPostID && !$Locked);
    $JsonPosts[] = $JsonPost;
}
json_print('success', array('threads' => $JsonPosts));
예제 #9
0
파일: request.php 프로젝트: Kufirc/Gazelle
$RequestVotes = Requests::get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
$ProjectCanEdit = check_perms('project_team') && !$IsFilled && ($CategoryID == 0 || $CategoryName == 'Music' && $Request['Year'] == 0);
$UserCanEdit = !$IsFilled && $LoggedUser['ID'] == $Request['UserID'] && $VoteCount < 2;
$CanEdit = $UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests');
if ($CategoryName == "Music") {
    $JsonMusicInfo = array('composers' => isset($ArtistForm[4]) ? pullmediainfo($ArtistForm[4]) : array(), 'dj' => isset($ArtistForm[6]) ? pullmediainfo($ArtistForm[6]) : array(), 'artists' => isset($ArtistForm[1]) ? pullmediainfo($ArtistForm[1]) : array(), 'with' => isset($ArtistForm[2]) ? pullmediainfo($ArtistForm[2]) : array(), 'conductor' => isset($ArtistForm[5]) ? pullmediainfo($ArtistForm[5]) : array(), 'remixedBy' => isset($ArtistForm[3]) ? pullmediainfo($ArtistForm[3]) : array(), 'producer' => isset($ArtistForm[7]) ? pullmediainfo($ArtistForm[7]) : array());
} else {
    $JsonMusicInfo = new stdClass();
    //json_encodes into an empty object: {}
}
$JsonTopContributors = array();
$VoteMax = $VoteCount < 5 ? $VoteCount : 5;
for ($i = 0; $i < $VoteMax; $i++) {
    $User = array_shift($RequestVotes['Voters']);
    $JsonTopContributors[] = array('userId' => (int) $User['UserID'], 'userName' => $User['Username'], 'bounty' => (int) $User['Bounty']);
}
reset($RequestVotes['Voters']);
list($NumComments, $Page, $Thread) = Comments::load('requests', $RequestID, false);
$JsonRequestComments = 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));
    $JsonRequestComments[] = array('postId' => (int) $PostID, 'authorId' => (int) $AuthorID, 'name' => $Username, 'donor' => $Donor == 1, 'warned' => $Warned != '0000-00-00 00:00:00', 'enabled' => $Enabled == 2 ? false : true, 'class' => Users::make_class_string($PermissionID), 'addedTime' => $AddedTime, 'avatar' => $Avatar, 'comment' => Text::full_format($Body), 'editedUserId' => (int) $EditedUserID, 'editedUsername' => $EditedUsername, 'editedTime' => $EditedTime);
}
$JsonTags = array();
foreach ($Request['Tags'] as $Tag) {
    $JsonTags[] = $Tag;
}
json_print('success', array('requestId' => (int) $RequestID, 'requestorId' => (int) $Request['UserID'], 'requestorName' => $Requestor['Username'], 'isBookmarked' => Bookmarks::has_bookmarked('request', $RequestID), 'requestTax' => $RequestTax, 'timeAdded' => $Request['TimeAdded'], 'canEdit' => $CanEdit, 'canVote' => $CanVote, 'minimumVote' => $MinimumVote, 'voteCount' => $VoteCount, 'lastVote' => $Request['LastVote'], 'topContributors' => $JsonTopContributors, 'totalBounty' => (int) $RequestVotes['TotalBounty'], 'categoryId' => (int) $CategoryID, 'categoryName' => $CategoryName, 'title' => $Request['Title'], 'year' => (int) $Request['Year'], 'image' => $Request['Image'], 'bbDescription' => $Request['Description'], 'description' => Text::full_format($Request['Description']), 'musicInfo' => $JsonMusicInfo, 'catalogueNumber' => $Request['CatalogueNumber'], 'releaseType' => (int) $Request['ReleaseType'], 'releaseName' => $ReleaseName, 'bitrateList' => preg_split('/\\|/', $Request['BitrateList'], null, PREG_SPLIT_NO_EMPTY), 'formatList' => preg_split('/\\|/', $Request['FormatList'], null, PREG_SPLIT_NO_EMPTY), 'mediaList' => preg_split('/\\|/', $Request['MediaList'], null, PREG_SPLIT_NO_EMPTY), 'logCue' => html_entity_decode($Request['LogCue']), 'isFilled' => $IsFilled, 'fillerId' => (int) $Request['FillerID'], 'fillerName' => $Filler ? $Filler['Username'] : '', 'torrentId' => (int) $Request['TorrentID'], 'timeFilled' => $Request['TimeFilled'], 'tags' => $JsonTags, 'comments' => $JsonRequestComments, 'commentPage' => (int) $Page, 'commentPages' => (int) ceil($NumComments / TORRENT_COMMENTS_PER_PAGE), 'recordLabel' => $Request['RecordLabel'], 'oclc' => $Request['OCLC']));
예제 #10
0
파일: wiki.php 프로젝트: Kufirc/Gazelle
<?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));
예제 #11
0
function __cmd_desc_simplelist($p)
{
    global $gbl, $sgbl, $login, $ghtml;
    ob_start();
    $resource = $p['resource'];
    $parent = null;
    if (!$parent) {
        if (isset($p['parent-class']) && isset($p['parent-name'])) {
            $parent = new $p['parent-class'](null, 'localhost', $p['parent-name']);
            dprint($parent->nname);
            $parent->get();
            if ($parent->dbaction === 'add') {
                throw new lxException("parent_doesnt_exist", "nname", $p['parent-name']);
            }
            if (!$parent->checkIfSomeParent($login->getClName())) {
                throw new lxException("you_are_not_the_owner_of_parent", "", $p['parent-name']);
            }
        } else {
            $parent = $login;
        }
    }
    $list = $parent->getCommandResource($resource);
    if (!$list) {
        // Fix for WHMCS needing pserver in client.
        if (!$parent->isAdmin() && $sgbl->isKloxo() && $resource === 'pserver') {
            $list['localhost'] = 'localhost';
            return $list;
        }
        $list = $parent->getList($resource);
        if (isset($p['v-filter'])) {
            list($var, $val) = explode(":", $p['v-filter']);
            foreach ($list as $k => $l) {
                if ($l->{$var} !== $val) {
                    unset($list[$k]);
                }
            }
        }
        if (!$list) {
            json_print("error", $p, "__error_no_resource_for_{$resource}");
            exit;
        }
        $list = get_namelist_from_objectlist($list, "nname", "nname");
    }
    ob_end_clean();
    return $list;
}
예제 #12
0
파일: collage.php 프로젝트: Kufirc/Gazelle
        if (!empty($GroupList[$GroupID])) {
            $GroupDetails = Torrents::array_group($GroupList[$GroupID]);
            if ($GroupDetails['GroupCategoryID'] > 0 && $Categories[$GroupDetails['GroupCategoryID'] - 1] == 'Music') {
                $ArtistForm = $GroupDetails['ExtendedArtists'];
                $JsonMusicInfo = array('composers' => isset($ArtistForm[4]) ? pullmediainfo($ArtistForm[4]) : array(), 'dj' => isset($ArtistForm[6]) ? pullmediainfo($ArtistForm[6]) : array(), 'artists' => isset($ArtistForm[1]) ? pullmediainfo($ArtistForm[1]) : array(), 'with' => isset($ArtistForm[2]) ? pullmediainfo($ArtistForm[2]) : array(), 'conductor' => isset($ArtistForm[5]) ? pullmediainfo($ArtistForm[5]) : array(), 'remixedBy' => isset($ArtistForm[3]) ? pullmediainfo($ArtistForm[3]) : array(), 'producer' => isset($ArtistForm[7]) ? pullmediainfo($ArtistForm[7]) : array());
            } else {
                $JsonMusicInfo = null;
            }
            $TorrentList = array();
            foreach ($GroupDetails['Torrents'] as $Torrent) {
                $TorrentList[] = array('torrentid' => (int) $Torrent['ID'], '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' => count(Torrents::get_reports((int) $Torrent['ID'])) > 0, 'time' => $Torrent['Time']);
            }
            $TorrentGroups[] = array('id' => $GroupDetails['GroupID'], 'name' => $GroupDetails['GroupName'], 'year' => $GroupDetails['GroupYear'], 'categoryId' => $GroupDetails['GroupCategoryID'], 'recordLabel' => $GroupDetails['GroupRecordLabel'], 'catalogueNumber' => $GroupDetails['GroupCatalogueNumber'], 'vanityHouse' => $GroupDetails['GroupVanityHouse'], 'tagList' => $GroupDetails['TagList'], 'releaseType' => $GroupDetails['ReleaseType'], 'wikiImage' => $GroupDetails['WikiImage'], 'musicInfo' => $JsonMusicInfo, 'torrents' => $TorrentList);
        }
    }
    $JSON['torrentgroups'] = $TorrentGroups;
} else {
    // artist collage
    $DB->query("\n\t\tSELECT\n\t\t\tca.ArtistID,\n\t\t\tag.Name,\n\t\t\taw.Image\n\t\tFROM collages_artists AS ca\n\t\t\tJOIN artists_group AS ag ON ag.ArtistID=ca.ArtistID\n\t\t\tLEFT JOIN wiki_artists AS aw ON aw.RevisionID = ag.RevisionID\n\t\tWHERE ca.CollageID='{$CollageID}'\n\t\tORDER BY ca.Sort");
    $Artists = array();
    while (list($ArtistID, $ArtistName, $ArtistImage) = $DB->next_record()) {
        $Artists[] = array('id' => (int) $ArtistID, 'name' => $ArtistName, 'image' => $ArtistImage);
    }
    $JSON['artists'] = $Artists;
}
if (isset($SetCache)) {
    $CollageData = array($Name, $Description, $CommentList, (bool) $Deleted, (int) $CollageCategoryID, (int) $CreatorID, (bool) $Locked, (int) $MaxGroups, (int) $MaxGroupsPerUser, $Updated, (int) $Subscribers);
    $Cache->cache_value($CacheKey, $CollageData, 3600);
}
json_print("success", $JSON);
예제 #13
0
파일: browse.php 프로젝트: Kufirc/Gazelle
                        $MasterName = 'Original Release';
                        if ($GroupRecordLabel) {
                            $MasterName .= $AddExtra . $GroupRecordLabel;
                            $AddExtra = ' / ';
                        }
                        if ($GroupCatalogueNumber) {
                            $MasterName .= $AddExtra . $GroupCatalogueNumber;
                            $AddExtra = ' / ';
                        }
                    } else {
                        $MasterName = 'Unknown Release(s)';
                    }
                    $MasterName .= $AddExtra . display_str($Data['Media']);
                }
            }
            $LastRemasterTitle = $Data['RemasterTitle'];
            $LastRemasterYear = $Data['RemasterYear'];
            $LastRemasterRecordLabel = $Data['RemasterRecordLabel'];
            $LastRemasterCatalogueNumber = $Data['RemasterCatalogueNumber'];
            $LastMedia = $Data['Media'];
            $JsonTorrents[] = array('torrentId' => (int) $TorrentID, 'editionId' => (int) $EditionID, 'artists' => $JsonArtists, 'remastered' => $Data['Remastered'] == '1', 'remasterYear' => (int) $Data['RemasterYear'], 'remasterCatalogueNumber' => $Data['RemasterCatalogueNumber'], 'remasterTitle' => $Data['RemasterTitle'], 'media' => $Data['Media'], 'encoding' => $Data['Encoding'], 'format' => $Data['Format'], 'hasLog' => $Data['HasLog'] == '1', 'logScore' => (int) $Data['LogScore'], 'hasCue' => $Data['HasCue'] == '1', 'scene' => $Data['Scene'] == '1', 'vanityHouse' => $GroupInfo['VanityHouse'] == '1', 'fileCount' => (int) $Data['FileCount'], 'time' => $Data['Time'], 'size' => (int) $Data['Size'], 'snatches' => (int) $Data['Snatched'], 'seeders' => (int) $Data['Seeders'], 'leechers' => (int) $Data['Leechers'], 'isFreeleech' => $Data['FreeTorrent'] == '1', 'isNeutralLeech' => $Data['FreeTorrent'] == '2', 'isPersonalFreeleech' => $Data['PersonalFL'], 'canUseToken' => Torrents::can_use_token($Data), 'hasSnatched' => $Data['IsSnatched']);
        }
        $JsonGroups[] = array('groupId' => (int) $GroupID, 'groupName' => $GroupName, 'artist' => $DisplayName, 'cover' => $GroupInfo['WikiImage'], 'tags' => $TagList, 'bookmarked' => in_array($GroupID, $Bookmarks), 'vanityHouse' => $GroupInfo['VanityHouse'] == '1', 'groupYear' => (int) $GroupYear, 'releaseType' => $ReleaseTypes[$ReleaseType], 'groupTime' => (string) $GroupTime, 'maxSize' => (int) $MaxSize, 'totalSnatched' => (int) $TotalSnatched, 'totalSeeders' => (int) $TotalSeeders, 'totalLeechers' => (int) $TotalLeechers, 'torrents' => $JsonTorrents);
    } else {
        // Viewing a type that does not require grouping
        list($TorrentID, $Data) = each($Torrents);
        $JsonGroups[] = array('groupId' => (int) $GroupID, 'groupName' => $GroupName, 'torrentId' => (int) $TorrentID, 'tags' => $TagList, 'category' => $Categories[$CategoryID - 1], 'fileCount' => (int) $Data['FileCount'], 'groupTime' => (string) strtotime($Data['Time']), 'size' => (int) $Data['Size'], 'snatches' => (int) $Data['Snatched'], 'seeders' => (int) $Data['Seeders'], 'leechers' => (int) $Data['Leechers'], 'isFreeleech' => $Data['FreeTorrent'] == '1', 'isNeutralLeech' => $Data['FreeTorrent'] == '2', 'isPersonalFreeleech' => $Data['PersonalFL'], 'canUseToken' => Torrents::can_use_token($Data), 'hasSnatched' => $Data['IsSnatched']);
    }
}
json_print('success', array('currentPage' => intval($Page), 'pages' => ceil($NumResults / TORRENTS_PER_PAGE), 'results' => $JsonGroups));
예제 #14
0
파일: requests.php 프로젝트: Kufirc/Gazelle
    }
}
if ($NumResults == 0) {
    json_print("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_print("success", array('currentPage' => intval($Page), 'pages' => ceil($NumResults / REQUESTS_PER_PAGE), 'results' => $JsonResults));
}
예제 #15
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_print("success", array('page' => (int) $Page, 'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE), 'comments' => $JsonComments));
예제 #16
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_print("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);
    }
}
예제 #17
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));
예제 #18
0
echo '########### Create, Update, Delete ########### <br/>';
$q = $db->insert('alerts');
$q->value('touser', 'me');
$q->execute();
echo $q->queryString . '<br/>';
$q = $db->update('alerts');
$q->value('message', 'hello');
$q->where('touser', '=', 'me');
$q->execute();
echo $q->queryString . '<br/>';
$q = $db->delete('alerts');
$q->where('touser', '=', 'me');
$q->execute();
echo $q->queryString . '<br/>';
echo '<br/><br/><br/>  ########### Simple Query ########### <br/>';
$q = $db->select("job");
$q->where('job_no', '=', '369012 ');
$job = $q->first();
json_print($q->queryArray);
json_print($job);
echo '<br/><br/><br/> ########### Complex Query ########### <br/>';
$q = $db->select("job");
$q->join('customer', 'customer_no');
$q->columns(array('job_no', 'customer_postcode'));
$q->union('job_archieve');
$q->limit(10);
$table = $q->all();
json_print($q->queryArray);
// this usually won't get accessed, just for demo purposes
json_print($table);
예제 #19
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_print("success", array('announcements' => $JsonAnnouncements, 'blogPosts' => $JsonBlog));
예제 #20
0
파일: artist.php 프로젝트: Kufirc/Gazelle
        $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_print("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));
예제 #21
0
파일: util.php 프로젝트: Kufirc/Gazelle
/**
 * Print JSON status result with an optional message and die.
 * DO NOT USE THIS FUNCTION!
 */
function json_die($Status, $Message)
{
    json_print($Status, $Message);
    die;
}
예제 #22
0
파일: stats.php 프로젝트: Kufirc/Gazelle
    // staggered 1 week cache
}
// Begin request stats
if (($RequestStats = $Cache->get_value('stats_requests')) === false) {
    $DB->query("\n\t\tSELECT COUNT(ID)\n\t\tFROM requests");
    list($RequestCount) = $DB->next_record();
    $DB->query("\n\t\tSELECT COUNT(ID)\n\t\tFROM requests\n\t\tWHERE FillerID > 0");
    list($FilledCount) = $DB->next_record();
    $Cache->cache_value('stats_requests', array($RequestCount, $FilledCount), 11280);
} else {
    list($RequestCount, $FilledCount) = $RequestStats;
}
// Begin swarm stats
if (($PeerStats = $Cache->get_value('stats_peers')) === false) {
    //Cache lock!
    if ($Cache->get_query_lock('peer_stats')) {
        $DB->query("\n\t\t\tSELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(uid)\n\t\t\tFROM xbt_files_users\n\t\t\tWHERE active = 1\n\t\t\tGROUP BY Type");
        $PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
        $LeecherCount = isset($PeerCount['Leeching']) ? $PeerCount['Leeching'][1] : 0;
        $SeederCount = isset($PeerCount['Seeding']) ? $PeerCount['Seeding'][1] : 0;
        $Cache->cache_value('stats_peers', array($LeecherCount, $SeederCount), 1209600);
        // 2 week cache
        $Cache->clear_query_lock('peer_stats');
    } else {
        $LeecherCount = $SeederCount = 0;
    }
} else {
    list($LeecherCount, $SeederCount) = $PeerStats;
}
json_print("success", array('maxUsers' => USER_LIMIT, 'enabledUsers' => (int) $UserCount, 'usersActiveThisDay' => (int) $UserStats['Day'], 'usersActiveThisWeek' => (int) $UserStats['Week'], 'usersActiveThisMonth' => (int) $UserStats['Month'], 'torrentCount' => (int) $TorrentCount, 'releaseCount' => (int) $AlbumCount, 'artistCount' => (int) $ArtistCount, 'perfectFlacCount' => (int) $PerfectCount, 'requestCount' => (int) $RequestCount, 'filledRequestCount' => (int) $FilledCount, 'seederCount' => (int) $SeederCount, 'leecherCount' => (int) $LeecherCount));
예제 #23
0
$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_print("success", array('currentPages' => intval($Page), 'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE), 'numNew' => $NumNew, 'results' => $JsonNotifications));
예제 #24
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_print('success', json_encode($NewsResponse));