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


PHP json_return_and_die函数代码示例

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


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

示例1: zfinger_init

function zfinger_init(&$a)
{
    require_once 'include/zot.php';
    require_once 'include/crypto.php';
    $x = zotinfo($_REQUEST);
    json_return_and_die($x);
}
开发者ID:kenrestivo,项目名称:hubzilla,代码行数:7,代码来源:zfinger.php

示例2: notes_init

/** @file */
function notes_init(&$a)
{
    if (!local_channel()) {
        return;
    }
    $ret = array('success' => true);
    if (array_key_exists('note_text', $_REQUEST)) {
        $body = escape_tags($_REQUEST['note_text']);
        // I've had my notes vanish into thin air twice in four years.
        // Provide a backup copy if there were contents previously
        // and there are none being saved now.
        if (!$body) {
            $old_text = get_pconfig(local_channel(), 'notes', 'text');
            if ($old_text) {
                set_pconfig(local_channel(), 'notes', 'text.bak', $old_text);
            }
        }
        set_pconfig(local_channel(), 'notes', 'text', $body);
    }
    // push updates to channel clones
    if (argc() > 1 && argv(1) === 'sync') {
        require_once 'include/zot.php';
        build_sync_packet();
    }
    logger('notes saved.', LOGGER_DEBUG);
    json_return_and_die($ret);
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:28,代码来源:notes.php

示例3: export_identity

function export_identity(&$a, $channel_hash)
{
    if ($channel_hash == '') {
        json_error_die(422, 'Unprocessable Entity', 'Must supply channel_hash parameter.');
    }
    json_return_and_die(identity_basic_export(get_channel_id($channel_hash), $_REQUEST['posts'] ? intval($_REQUEST['posts']) : 0));
}
开发者ID:kenrestivo,项目名称:migrator-plugin,代码行数:7,代码来源:migrator_export.php

示例4: init

 function init()
 {
     $result = null;
     $cmd = argc() > 1 ? argv(1) : '';
     // Provide a stored request for somebody desiring a connection
     // when they first need to register someplace. Once they've
     // created a channel, we'll try to revive the connection request
     // and process it.
     if ($_REQUEST['connect']) {
         $_SESSION['connect'] = $_REQUEST['connect'];
     }
     switch ($cmd) {
         case 'invite_check.json':
             $result = check_account_invite($_REQUEST['invite_code']);
             break;
         case 'email_check.json':
             $result = check_account_email($_REQUEST['email']);
             break;
         case 'password_check.json':
             $result = check_account_password($_REQUEST['password']);
             break;
         default:
             break;
     }
     if ($result) {
         json_return_and_die($result);
     }
 }
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:28,代码来源:Register.php

示例5: init

 function init()
 {
     if (argv(1) === 'json') {
         $data = get_site_info();
         json_return_and_die($data);
     }
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:7,代码来源:Siteinfo.php

示例6: dirstats_content

function dirstats_content(&$a)
{
    $hubcount = get_config('dirstats', 'hubcount');
    $zotcount = get_config('dirstats', 'zotcount');
    $friendicacount = get_config('dirstats', 'friendicacount');
    $diasporacount = get_config('dirstats', 'diasporacount');
    $channelcount = get_config('dirstats', 'channelcount');
    $friendicachannelcount = get_config('dirstats', 'friendicachannelcount');
    $diasporachannelcount = get_config('dirstats', 'diasporachannelcount');
    $over35s = get_config('dirstats', 'over35s');
    $under35s = get_config('dirstats', 'under35s');
    $average = get_config('dirstats', 'averageage');
    $chatrooms = get_config('dirstats', 'chatrooms');
    $tags = get_config('dirstats', 'tags');
    $ob = $a->get_observer();
    $observer = $ob['xchan_hash'];
    // Requested by Martin
    $fountainofyouth = get_xconfig($observer, 'dirstats', 'averageage');
    if (intval($fountainofyouth)) {
        $average = $fountainofyouth;
    }
    if (argv(1) == 'json') {
        $dirstats = array('hubcount' => $hubcount, 'zotcount' => $zotcount, 'friendicacount' => $friendicacount, 'diasporacount' => $diasporacount, 'channelcount' => $channelcount, 'friendicachannelcount' => $friendicachannelcount, 'diasporachannelcount' => $diasporachannelcount, 'over35s' => $over35s, 'under35s' => $under35s, 'average' => $average, 'chatrooms' => $chatrooms, 'tags' => $tags);
        echo json_return_and_die($dirstats);
    } elseif (argv(1) == 'genpost' && get_config('dirstats', 'allowfiledump')) {
        $result = '[b]Hub count[/b] : ' . $hubcount . "\n" . '[b]Hubzilla Hubs[/b] : ' . $zotcount . "\n" . '[b]Friendica Hubs[/b] : ' . $friendicacount . "\n" . '[b]Diaspora Pods[/b] : ' . $diasporacount . "\n" . '[b]Hubzilla Channels[/b] : ' . $channelcount . "\n" . '[b]Friendica Profiles[/b] : ' . $friendicachannelcount . "\n" . '[b]Diaspora Profiles[/b] : ' . $diasporachannelcount . "\n" . '[b]People aged 35 and above[/b] : ' . $over35s . "\n" . '[b]People aged 34 and below[/b] : ' . $under35s . "\n" . '[b]Average Age[/b] : ' . $average . "\n" . '[b]Known Chatrooms[/b] : ' . $chatrooms . "\n" . '[b]Unique Profile Tags[/b] : ' . $tags . "\n";
        file_put_contents('genpost', $result);
    } else {
        $tpl = get_markup_template("dirstats.tpl", "addon/dirstats/");
        return replace_macros($tpl, array('$title' => t('Hubzilla Directory Stats'), '$hubtitle' => t('Total Hubs'), '$hubcount' => $hubcount, '$zotlabel' => t('Hubzilla Hubs'), '$zotcount' => $zotcount, '$friendicalabel' => t('Friendica Hubs'), '$friendicacount' => $friendicacount, '$diasporalabel' => t('Diaspora Pods'), '$diasporacount' => $diasporacount, '$zotchanlabel' => t('Hubzilla Channels'), '$channelcount' => $channelcount, '$friendicachanlabel' => t('Friendica Channels'), '$friendicachannelcount' => $friendicachannelcount, '$diasporachanlabel' => t('Diaspora Channels'), '$diasporachannelcount' => $diasporachannelcount, '$over35label' => t('Aged 35 and above'), '$over35s' => $over35s, '$under35label' => t('Aged 34 and under'), '$under35s' => $under35s, '$averageagelabel' => t('Average Age'), '$average' => $average, '$chatlabel' => t('Known Chatrooms'), '$chatrooms' => $chatrooms, '$tagslabel' => t('Known Tags'), '$tags' => $tags, '$disclaimer' => t('Please note Diaspora and Friendica statistics are merely those **this directory** is aware of, and not all those known in the network.  This also applies to chatrooms,')));
    }
}
开发者ID:git-marijus,项目名称:hubzilla-addons,代码行数:32,代码来源:dirstats.php

示例7: zotfeed_init

function zotfeed_init(&$a)
{
    $result = array('success' => false);
    $mindate = $_REQUEST['mindate'] ? datetime_convert('UTC', 'UTC', $_REQUEST['mindate']) : '';
    if (!$mindate) {
        $mindate = datetime_convert('UTC', 'UTC', 'now - 1 month');
    }
    if (get_config('system', 'block_public') && !get_account_id() && !remote_user()) {
        $result['message'] = 'Public access denied';
        json_return_and_die($result);
    }
    $observer = $a->get_observer();
    $channel_address = argc() > 1 ? argv(1) : '';
    if ($channel_address) {
        $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d) limit 1", dbesc(argv(1)), intval(PAGE_REMOVED));
    } else {
        $x = get_sys_channel();
        if ($x) {
            $r = array($x);
        }
    }
    if (!$r) {
        $result['message'] = 'Channel not found.';
        json_return_and_die($result);
    }
    logger('zotfeed request: ' . $r[0]['channel_name'], LOGGER_DEBUG);
    $result['messages'] = zot_feed($r[0]['channel_id'], $observer['xchan_hash'], $mindate);
    $result['success'] = true;
    json_return_and_die($result);
}
开发者ID:Mauru,项目名称:red,代码行数:30,代码来源:zotfeed.php

示例8: init

 function init()
 {
     $result = array('success' => false);
     $mindate = $_REQUEST['mindate'] ? datetime_convert('UTC', 'UTC', $_REQUEST['mindate']) : '';
     if (!$mindate) {
         $mindate = datetime_convert('UTC', 'UTC', 'now - 14 days');
     }
     if (observer_prohibited()) {
         $result['message'] = 'Public access denied';
         json_return_and_die($result);
     }
     $observer = \App::get_observer();
     $channel_address = argc() > 1 ? argv(1) : '';
     if ($channel_address) {
         $r = q("select channel_id, channel_name from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc(argv(1)));
     } else {
         $x = get_sys_channel();
         if ($x) {
             $r = array($x);
         }
         $mindate = datetime_convert('UTC', 'UTC', 'now - 14 days');
     }
     if (!$r) {
         $result['message'] = 'Channel not found.';
         json_return_and_die($result);
     }
     logger('zotfeed request: ' . $r[0]['channel_name'], LOGGER_DEBUG);
     $result['messages'] = zot_feed($r[0]['channel_id'], $observer['xchan_hash'], array('mindate' => $mindate));
     $result['success'] = true;
     json_return_and_die($result);
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:31,代码来源:Zotfeed.php

示例9: migrator_init

function migrator_init(&$a)
{
    $x = argc();
    if ($x > 1) {
        api_login($a);
        switch (argv(1)) {
            case "version":
                json_return_and_die(array("status" => "OK", 'platform' => PLATFORM_NAME, 'platform_version' => RED_VERSION, 'zot_version' => ZOT_REVISION, 'db_version' => DB_UPDATE_VERSION, 'migrator_version' => MIGRATOR_VERSION));
                break;
            case "import":
                if (PLATFORM_NAME == "redmatrix") {
                    json_error_die(400, 'Bad Request', 'Cannot import to Redmatrix, only to Hubzilla.');
                }
                switch (argv(2)) {
                    case 'account':
                        migrator_import_account($a);
                        break;
                    case 'identity':
                        migrator_import_identity($a, argv(3));
                        break;
                    case 'items':
                        migrator_import_items($a, argv(3));
                        break;
                    case 'directory':
                        migrator_update_directory($a, argv(3));
                        break;
                    default:
                        json_error_die(404, 'Not Found', 'No such endpoint');
                        break;
                }
            case "export":
                switch (argv(2)) {
                    case "users":
                        export_users($a);
                        break;
                    case "channel_hashes":
                        export_channel_hashes($a, argv(3));
                        break;
                    case "identity":
                        export_identity($a, argv(3));
                        break;
                    case "first_post":
                        first_post($a, argv(3));
                        break;
                    case "items":
                        export_items($a, argv(3), argv(4), argv(5));
                        break;
                    default:
                        json_error_die(404, 'Not Found', 'No such endpoint');
                        break;
                }
                break;
            default:
                json_error_die(404, 'Not Found', 'No such endpoint');
                break;
        }
    }
}
开发者ID:kenrestivo,项目名称:migrator-plugin,代码行数:58,代码来源:migrator.php

示例10: init

 function init()
 {
     $ret = array('result' => false);
     if (argc() != 2) {
         json_return_and_die($ret);
     }
     $ret = get_online_status(argv(1));
     json_return_and_die($ret);
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:9,代码来源:Online.php

示例11: tasks_post

function tasks_post(&$a)
{
    //	logger('post: ' . print_r($_POST,true));
    if (!local_channel()) {
        return;
    }
    $channel = App::get_channel();
    if (argc() > 2 && argv(1) === 'complete' && intval(argv(2))) {
        $ret = array('success' => false);
        $r = q("select * from event where `type` = 'task' and uid = %d and id = %d limit 1", intval(local_channel()), intval(argv(2)));
        if ($r) {
            $event = $r[0];
            if ($event['event_status'] === 'COMPLETED') {
                $event['event_status'] = 'IN-PROCESS';
                $event['event_status_date'] = NULL_DATE;
                $event['event_percent'] = 0;
                $event['event_sequence'] = $event['event_sequence'] + 1;
                $event['edited'] = datetime_convert();
            } else {
                $event['event_status'] = 'COMPLETED';
                $event['event_status_date'] = datetime_convert();
                $event['event_percent'] = 100;
                $event['event_sequence'] = $event['event_sequence'] + 1;
                $event['edited'] = datetime_convert();
            }
            $x = event_store_event($event);
            if ($x) {
                $ret['success'] = true;
            }
        }
        json_return_and_die($ret);
    }
    if (argc() == 2 && argv(1) === 'new') {
        $text = escape_tags(trim($_REQUEST['summary']));
        if (!$text) {
            return array('success' => false);
        }
        $event = array();
        $event['account'] = $channel['channel_account_id'];
        $event['uid'] = $channel['channel_id'];
        $event['event_xchan'] = $channel['channel_hash'];
        $event['type'] = 'task';
        $event['nofinish'] = true;
        $event['created'] = $event['edited'] = $event['start'] = datetime_convert();
        $event['adjust'] = 1;
        $event['allow_cid'] = '<' . $channel['channel_hash'] . '>';
        $event['summary'] = escape_tags($_REQUEST['summary']);
        $x = event_store_event($event);
        if ($x) {
            $x['success'] = true;
        } else {
            $x = array('success' => false);
        }
        json_return_and_die($x);
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:56,代码来源:tasks.php

示例12: migrator_update_directory

function migrator_update_directory(&$a, $channel_hash)
{
    $channel_id = get_channel_id($channel_hash);
    if (!$channel_id) {
        json_error_die(404, 'Not Found', 'No such channel ' . $channel_hash);
    }
    proc_run('php', 'include/notifier.php', 'location', $channel_id);
    proc_run('php', 'include/directory.php', $channel_id);
    json_return_and_die(array("status" => 'OK', 'channel_hash' => $channel_hash, 'channel_id' => $channel_id));
}
开发者ID:kenrestivo,项目名称:migrator-plugin,代码行数:10,代码来源:migrator_import.php

示例13: get

 function get()
 {
     if (\App::$argv[1] === "json") {
         $tmp = list_smilies();
         $results = array();
         for ($i = 0; $i < count($tmp['texts']); $i++) {
             $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
         }
         json_return_and_die($results);
     } else {
         return smilies('', true);
     }
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:13,代码来源:Smilies.php

示例14: chatsvc_content

function chatsvc_content(&$a)
{
    $status = strip_tags($_REQUEST['status']);
    $room_id = intval($a->data['chat']['room_id']);
    $stopped = x($_REQUEST, 'stopped') && intval($_REQUEST['stopped']) ? true : false;
    if ($status && $room_id) {
        $x = q("select channel_address from channel where channel_id = %d limit 1", intval($a->data['chat']['uid']));
        $r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s' limit 1", dbesc($status), dbesc(datetime_convert()), intval($room_id), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR']));
        goaway(z_root() . '/chat/' . $x[0]['channel_address'] . '/' . $room_id);
    }
    if (!$stopped) {
        $lastseen = intval($_REQUEST['last']);
        $ret = array('success' => false);
        $sql_extra = permissions_sql($a->data['chat']['uid']);
        $r = q("select * from chatroom where cr_uid = %d and cr_id = %d {$sql_extra}", intval($a->data['chat']['uid']), intval($a->data['chat']['room_id']));
        if (!$r) {
            json_return_and_die($ret);
        }
        $inroom = array();
        $r = q("select * from chatpresence left join xchan on xchan_hash = cp_xchan where cp_room = %d order by xchan_name", intval($a->data['chat']['room_id']));
        if ($r) {
            foreach ($r as $rr) {
                switch ($rr['cp_status']) {
                    case 'away':
                        $status = t('Away');
                        break;
                    case 'online':
                    default:
                        $status = t('Online');
                        break;
                }
                $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'], 'name' => $rr['xchan_name'], status => $status);
            }
        }
        $chats = array();
        $r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created", intval($a->data['chat']['room_id']), intval($lastseen));
        if ($r) {
            foreach ($r as $rr) {
                $chats[] = array('id' => $rr['chat_id'], 'img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'], 'name' => $rr['xchan_name'], 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'r'), 'text' => smilies(bbcode($rr['chat_text'])));
            }
        }
    }
    $r = q("update chatpresence set cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s' limit 1", dbesc(datetime_convert()), intval($a->data['chat']['room_id']), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR']));
    $ret['success'] = true;
    if (!$stopped) {
        $ret['inroom'] = $inroom;
        $ret['chats'] = $chats;
    }
    json_return_and_die($ret);
}
开发者ID:Mauru,项目名称:red,代码行数:50,代码来源:chatsvc.php

示例15: ratingsearch_init

function ratingsearch_init(&$a)
{
    $ret = array('success' => false);
    $dirmode = intval(get_config('system', 'directory_mode'));
    if ($dirmode == DIRECTORY_MODE_NORMAL) {
        $ret['message'] = 'This site is not a directory server.';
        json_return_and_die($ret);
    }
    if (argc() > 1) {
        $hash = argv(1);
    }
    if (!$hash) {
        $ret['message'] = 'No channel identifier';
        json_return_and_die($ret);
    }
    if (strpos($hash, '@')) {
        $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", dbesc($hash));
        if ($r) {
            $hash = $r[0]['hubloc_hash'];
        }
    }
    $p = q("select * from xchan where xchan_hash like '%s'", dbesc($hash . '%'));
    if ($p) {
        $target = $p[0]['xchan_hash'];
    } else {
        $p = q("select * from site where site_url like '%s' and site_type = %d ", dbesc('%' . $hash), intval(SITE_TYPE_ZOT));
        if ($p) {
            $target = strtolower($hash);
        } else {
            $ret['message'] = 'Rating target not found';
            json_return_and_die($ret);
        }
    }
    if ($p) {
        $ret['target'] = $p[0];
    }
    $ret['success'] = true;
    $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash \n\t\twhere xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 order by xchan_name asc", dbesc($target));
    if ($r) {
        $ret['ratings'] = $r;
    } else {
        $ret['ratings'] = array();
    }
    json_return_and_die($ret);
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:45,代码来源:ratingsearch.php


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