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


PHP json_headers函数代码示例

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


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

示例1: json_reply

/**
 * This function sends a JSON message, and ends the script.
 *
 * Scripts receiving replies will recieve a JSON array with two fields:
 *
 *  - error: True or false depending on whether the request was successful
 *  - message: JSON data representing a message sent back from the script
 *
 * @param boolean $error   Whether the script ended in an error or not
 * @param string  $message A message to pass back to the user, can be an
 *                         array of JSON data
 */
function json_reply($error, $message, $returncode = 0)
{
    json_headers();
    echo json_encode(array('error' => $error, 'message' => $message, 'returnCode' => $returncode));
    perf_to_log();
    exit;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:19,代码来源:web.php

示例2: define

 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(__FILE__)) . '/init.php';
json_headers();
$data = new StdClass();
$data->view = param_integer('view');
$data->artefact = param_integer('artefact', null);
$data->message = param_variable('message');
$data->public = param_boolean('public') ? 1 : 0;
$data->attachment = param_integer('attachment', null);
$data->author = $USER->get('id');
$data->ctime = db_format_timestamp(time());
if ($data->artefact) {
    $table = 'artefact_feedback';
} else {
    $table = 'view_feedback';
}
if (!insert_record($table, $data, 'id', true)) {
    json_reply('local', get_string('addfeedbackfailed', 'view'));
开发者ID:Br3nda,项目名称:mahara,代码行数:31,代码来源:addfeedback.json.php

示例3: jsonHeaders

 /**
  * Outputs json headers
  */
 public function jsonHeaders()
 {
     \json_headers();
 }
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:7,代码来源:Response.php

示例4: select

 public function select()
 {
     $value = $this->input->get_post('selected', TRUE);
     $filter = rawurldecode($this->input->get_post('filter', TRUE));
     // Convert wild-cards to RegEx
     $filter = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $filter));
     $this->js_controller_params['method'] = 'select';
     $this->load->helper('array');
     $this->load->helper('form');
     $this->load->library('form_builder');
     $pages = $this->fuel->pages->options_list();
     $pdfs = $this->fuel->assets->dir_files('pdf', TRUE);
     if (!empty($pdfs) and !empty($_GET['pdfs'])) {
         $options[lang('page_select_pages')] = array_combine($pages, $pages);
         $options[lang('page_select_pdfs')] = array_combine($pdfs, $pdfs);
     } else {
         $options = array_combine($pages, $pages);
     }
     // apply filter
     if (!empty($filter)) {
         $filter_callback = create_function('$a', 'return preg_match(\'#^' . $filter . '$#\', $a);');
         $options = array_filter($options, $filter_callback);
     }
     // just return the options as json
     $fields['General'] = array('type' => 'fieldset', 'class' => 'tab');
     if (isset($_GET['options'])) {
         if (isset($_GET['format']) and strtolower($_GET['format']) == 'json') {
             json_headers();
             echo json_encode($options);
             return;
         } else {
             $str = '';
             if (isset($_GET['first_option'])) {
                 $first_option = $this->input->get('first_option', TRUE);
                 $str .= "<option value=\"\" label=\"" . Form::prep($first_option, FALSE) . "\">" . Form::prep($first_option, FALSE) . "</option>\n";
             }
             foreach ($options as $key => $val) {
                 $str .= "<option value=\"" . Form::prep($key, FALSE) . "\" label=\"" . Form::prep($val, FALSE) . "\">" . Form::prep($val, FALSE) . "</option>\n";
             }
             echo $str;
             return;
         }
     }
     $select_label = lang('form_label_page');
     $display_label_select = FALSE;
     if (isset($_GET['input'])) {
         $fields['input'] = array('value' => $this->input->get_post('input', TRUE), 'label' => lang('form_label_url'), 'size' => 100);
         $select_label = lang('form_label_or_select');
         $display_label_select = TRUE;
     }
     $fields['url_select'] = array('value' => $this->input->get_post('url_select', TRUE), 'label' => $select_label, 'type' => 'select', 'options' => $options, 'first_option' => lang('label_select_one'), 'display_label' => $display_label_select);
     $fields['Advanced'] = array('type' => 'fieldset', 'class' => 'tab');
     if (isset($_GET['target'])) {
         $target_options = array('' => '', '_blank' => '_blank', '_parent' => '_parent', '_top' => '_top');
         $fields['target'] = array('value' => $this->input->get_post('target', TRUE), 'label' => lang('form_label_target'), 'type' => 'select', 'options' => array('' => '', '_blank' => '_blank'));
         $fields['url_select']['display_label'] = TRUE;
     }
     if (isset($_GET['title'])) {
         $fields['title'] = array('value' => $this->input->get_post('title', TRUE), 'label' => lang('form_label_title'));
         $fields['url_select']['display_label'] = TRUE;
     }
     if (isset($_GET['class'])) {
         $fields['class'] = array('value' => $this->input->get_post('class', TRUE), 'label' => lang('form_label_class'));
         $fields['url_select']['display_label'] = TRUE;
     }
     $fields['selected'] = array('type' => 'hidden', 'value' => $this->input->get_post('selected', TRUE));
     $this->form_builder->submit_value = NULL;
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_fields($fields);
     $this->form_builder->display_errors = FALSE;
     $vars['form'] = $this->form_builder->render();
     $this->fuel->admin->set_inline(TRUE);
     $crumbs = array('' => $this->module_name, lang('pages_select_action'));
     $this->fuel->admin->set_panel_display('notification', FALSE);
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->render('modal_select', $vars, '', FUEL_FOLDER);
 }
开发者ID:prgoncalves,项目名称:Beatcrumb-web,代码行数:77,代码来源:pages.php

示例5: exit_json

function exit_json($arr = array())
{
    json_headers();
    exit(@json_encode($arr));
}
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:5,代码来源:functions.inc.php

示例6: process_new_login

                            process_new_login('', 1, $vbulletin->GPC['cssprefs']);
                            cache_permissions($vbulletin->userinfo, true);
                            $vbulletin->session->save();
                        }
                    }
                }
            } else {
                $valid_entries = FALSE;
                $messages['errors'][] = $message = "Please check your username and password.";
                $messages['fields'][] = $error_type = "username-member";
                $messages['errors'][] = $message = "";
                $messages['fields'][] = $error_type = "password-member";
                if ($vbulletin->options['usestrikesystem']) {
                    $strikes = verify_strike_status($vbulletin->GPC['username']);
                    exec_strike_user($vbulletin->GPC['username']);
                    if ($strikes >= 4) {
                        unset($messages);
                        $message = fetch_error('badlogin_strikes', $vbulletin->options['bburl'], $vbulletin->session->vars['sessionurl'], $strikes);
                        $message = rewrite_error($message);
                        $messages['errors'][] = $message;
                        $messages['fields'][] = $error_type = "username-member";
                        $messages['errors'][] = "";
                        $messages['fields'][] = $error_type = "password-member";
                    }
                }
            }
        }
        $arr = array("valid_entries" => $valid_entries, "messages" => $messages, "url" => $url);
        json_headers($arr);
        break;
}
开发者ID:benyamin20,项目名称:vbregistration,代码行数:31,代码来源:index.php

示例7: run

 /**
  * Includes $this->page_path after hooks:
  *     - uri
  *     - run-first
  *     - including script files
  *     - setting constants
  *     - then run-last
  * Uses Page::includePath() to emulate them being executed in the same scope.
  * @return \Sky\Page $this
  */
 public function run()
 {
     try {
         // uri hook
         $vars = $this->includePath('lib/core/hooks/uri/uri.php', $this->vars);
         // set constants
         $this->setConstants();
         // map input stream to $_POST if applicable
         $this->checkInputStream();
         // execute run first
         $vars = $this->includePath('pages/run-first.php', $vars);
         // execute script files
         foreach (array_keys($this->script_files) as $file) {
             $vars = $this->includePath($file, $vars);
         }
         // add page_css/page_js
         $this->setAssetsByPath($this->page_path);
         // see if we're not rendering html but returning JS
         $get_contents = (bool) ($_POST['_json'] || $_GET['_script']);
         if ($get_contents) {
             if ($_GET['_script']) {
                 $this->no_template = true;
             }
             ob_start();
         }
         // run-first / settings / script files need to be executed in the same scope
         $vars = $this->includePath($this->page_path, $vars);
         if ($get_contents) {
             // refreshing a secondary div after an ajax state change
             if (is_array($this->div)) {
                 $this->div['page'] = ob_get_contents();
             } else {
                 $this->div->page = ob_get_contents();
             }
             ob_end_clean();
             $this->sky_end_time = microtime(true);
             if ($_POST['_json']) {
                 \json_headers();
                 echo json_encode($this);
             } else {
                 header('Content-type: text/javascript');
                 echo sprintf("%s(%s,'%s','%s', '%s');", $_GET['_fn'] ?: 'render_page', json_encode($this), $this->uri, $_SERVER['HTTP_HOST'], $_GET['_script_div'] ?: 'page');
             }
         }
         // run-last hook
         $this->includePath('pages/run-last.php', $vars);
     } catch (\Sky\AQL\Exception\Connection $e) {
         $this->includePath('pages/503.php');
         echo '<!--' . $e->getMessage() . '-->';
     }
     return $this;
 }
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:62,代码来源:Page.php


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