当前位置: 首页>>代码示例>>PHP>>正文


PHP json_die函数代码示例

本文整理汇总了PHP中json_die函数的典型用法代码示例。如果您正苦于以下问题:PHP json_die函数的具体用法?PHP json_die怎么用?PHP json_die使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了json_die函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: TorrentSearch

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'];
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:browse.php

示例2: foreach

    $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);
    }
}
开发者ID:karamanolev,项目名称:Gazelle,代码行数:31,代码来源:user_recents.php

示例3: array

<?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}]]}';
开发者ID:Kufirc,项目名称:Gazelle,代码行数:7,代码来源:get_user_notifications.php

示例4: array

$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));
开发者ID:karamanolev,项目名称:Gazelle,代码行数:30,代码来源:notifications.php

示例5: SUM

            // 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'];
开发者ID:karamanolev,项目名称:Gazelle,代码行数:31,代码来源:browse.php

示例6: error

<?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));
开发者ID:Kufirc,项目名称:Gazelle,代码行数:15,代码来源:torrentgroupalbumart.php

示例7: torrenthash_to_torrentid

        $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 \'|\')']);
开发者ID:Kufirc,项目名称:Gazelle,代码行数:31,代码来源:torrent.php

示例8: json_die

<?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)));
开发者ID:Kufirc,项目名称:Gazelle,代码行数:15,代码来源:raw_bbcode.php

示例9: elseif

<?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));
开发者ID:karamanolev,项目名称:Gazelle,代码行数:26,代码来源:wiki.php

示例10: elseif

<?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));
开发者ID:Kufirc,项目名称:Gazelle,代码行数:26,代码来源:wiki.php

示例11: removeCellFormat

<?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);
}
开发者ID:dave-jay,项目名称:twilio-call-text,代码行数:31,代码来源:click_to_call.inc.php

示例12: array

$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)));
开发者ID:karamanolev,项目名称:Gazelle,代码行数:30,代码来源:torrent.php

示例13: array

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));
开发者ID:karamanolev,项目名称:Gazelle,代码行数:30,代码来源:announcements.php

示例14: json_die

<?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));
开发者ID:karamanolev,项目名称:Gazelle,代码行数:19,代码来源:news_ajax.php

示例15: json_die

<?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));
开发者ID:Kufirc,项目名称:Gazelle,代码行数:25,代码来源:usersearch.php


注:本文中的json_die函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。