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


PHP send_header函数代码示例

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


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

示例1: redirect

function redirect($uri, $status_code = 302)
{
    send_header($status_code);
    // Again, why are we doing this? :)
    session_write_close();
    session_regenerate_id(true);
    header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    header('Location: ' . $uri);
    exit(0);
}
开发者ID:pettam,项目名称:FribergVSPasha,代码行数:10,代码来源:backend.php

示例2: fatal

/**
 * Generate a fatal error, printing the $error and sending the header
 * associated with the $code. By default, this function renders the
 * error message with the error template. If you provide an ErrorController
 * that responds to an action called _$code, it will use that instead.
 * This lets you use the default error handling while developing an app
 * and switch to a more polished solution later.
 * This method can also be handy for testing - call it without args to see
 * all the data associated with a request.
 *
 * @see send_header()
 * @param string $error
 * @param integer $code
 * @return void
 *
 */
function fatal($error = 'Fatal error.', $code = 500)
{
    send_header($code);
    error_log($error);
    // do a mock request to see if we can handle this error with a controller
    $manager = new PathManager(WEB_ROOT . "/error/_{$code}");
    $route = $manager->build_route();
    $instance = $manager->controller_instance($route->controller);
    if ($instance !== FALSE && method_exists($instance, $route->action) !== FALSE) {
        $route->params = array('error' => $error, 'code' => $code);
        $action = $route->action;
        $instance->{$action}($route->params);
    } else {
        template('error');
        sys()->data->error = $error;
        sys()->data->code = $code;
    }
    render($route);
    exit;
}
开发者ID:allynbauer,项目名称:Condor,代码行数:36,代码来源:system_functions.php

示例3: redirect_to

/**
 * Http redirection
 * 
 * Same use as {@link url_for()}
 * By default HTTP status code is 302, but a different code can be specified
 * with a status key in array parameter.
 * 
 * <code>
 * redirecto('new','url'); # 302 HTTP_MOVED_TEMPORARILY by default
 * redirecto('new','url', array('status' => HTTP_MOVED_PERMANENTLY));
 * </code>
 * 
 * @param string or array $param1, $param2... 
 * @return void
 */
function redirect_to($params)
{
    # [NOTE]: (from php.net) HTTP/1.1 requires an absolute URI as argument to » Location:
    # including the scheme, hostname and absolute path, but some clients accept
    # relative URIs. You can usually use $_SERVER['HTTP_HOST'],
    # $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative
    # one yourself.
    # TODO make absolute uri
    if (!headers_sent()) {
        $status = HTTP_MOVED_TEMPORARILY;
        # default for a redirection in PHP
        $params = func_get_args();
        $n_params = array();
        # extract status param if exists
        foreach ($params as $param) {
            if (is_array($param)) {
                if (array_key_exists('status', $param)) {
                    $status = $param['status'];
                    unset($param['status']);
                }
            }
            $n_params[] = $param;
        }
        $uri = call_user_func_array('url_for', $n_params);
        $uri = htmlspecialchars_decode($uri, ENT_NOQUOTES);
        stop_and_exit(false);
        send_header('Location: ' . $uri, true, $status);
        exit;
    }
}
开发者ID:soitun,项目名称:CRMx,代码行数:45,代码来源:limonade.php

示例4: send_header

<?php

send_header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title><?php 
echo $page['title'];
?>
</title>

    <!-- Bootstrap -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/v-order.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript">
      var VK_APP_ID = <?php 
echo $page['VK_APP_ID'];
?>
;
开发者ID:enikesha,项目名称:v_order,代码行数:31,代码来源:_layout.php

示例5: define

<?php

define('ROOT', './');
session_start();
require_once ROOT . '../private_html/config.php';
require_once ROOT . '../private_html/includes/database.php';
require_once ROOT . '../private_html/includes/func.php';
cacheCurrentPage();
/// Templating
$page_title = 'MCStats :: Donate to MCStats';
$breadcrumbs = '<a href="/donate/" class="current">Donate</a>';
send_header();
echo '

<div class="row-fluid">
    <div class="widget-box span8 offset2">
        <div class="widget-title"><span><i></i></span><h4 style="float: left; margin-left: 35%;">Serving you rock solid stats.</h4></div>
        <div class="widget-content">
            <p style="font-size: 16px;">
                MCStats serves over <span style="font-weight:bold; font-size: 20px;">550 requests per second</span> 24 hours a day, 7 days a week
            </p>
            <p style="font-size: 16px;">
                That is over <b><span style="font-size: 20px;">1.5 billion</span> requests per month</b> and over <b><span style="font-size: 20px;">50 million</span> requests each day</b> and it will only continue to rise.
            </p>
            <p>
                Every single server is tracked. To get useful data for plugins, every server needs to be identified and from there
                data is stored such as the plugins the server is using (that support MCStats), the amount of players online,
                and even the Minecraft version the server is on.
            </p>
            <p>
                This is no simple task. It requires a lot of power and it also needs room for growth. Right now the service
开发者ID:willies952002,项目名称:mcstats.org,代码行数:31,代码来源:donate.php

示例6: get_redirect_key

<?php

require 'config.php';
require 'functions.php';
require config::redirect_file;
$redirect_key = get_redirect_key();
$redirect_key_formatted = format_redirect_key($redirect_key);
$redirect_target = get_redirect_target($redirect_key_formatted);
$redirect_url = build_url($redirect_target);
send_header($redirect_url);
开发者ID:MoritzLost,项目名称:php-redirect,代码行数:10,代码来源:index.php

示例7: switch

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $snoopy->submit($url, $_POST);
} else {
    $snoopy->fetch($url);
}
//---------------处理返回信息------------
//设置cookie
switch ($config['cookies']) {
    case 1:
        //全局cookies
        $snoopy->cookies = set_cache('cookies');
        break;
    default:
        break;
}
$contentType = send_header($snoopy->headers);
$charset = empty($contentType[1]) ? 'utf-8' : $contentType[1];
$charset = trim($charset, "\n\r");
//替换域名 relativeHTML relativeCSS
if (empty($config['replaceDomain'])) {
    if (in_array($thisExt, array('', 'php', 'html'))) {
        //替换域名
        $snoopy->results = str_replace($config['host'], $rootUrl, $snoopy->results);
    }
}
//替换相对地址relativeHTML
if (empty($config['replaceDomain'])) {
    if (in_array($thisExt, array('', 'php', 'html'))) {
        $snoopy->results = str_replace('="/', '="' . siteUri(), $snoopy->results);
        $snoopy->results = str_replace('=\'/', '=\'' . siteUri(), $snoopy->results);
        $snoopy->results = preg_replace('/<base href=.*?\\/>/', '', $snoopy->results);
开发者ID:a4m,项目名称:openshift,代码行数:31,代码来源:index.php

示例8: content_type

function content_type($type)
{
    send_header('Content-Type: ' . $type);
}
开发者ID:karupanerura,项目名称:isucon4,代码行数:4,代码来源:index.php

示例9: dispatch_post

});
dispatch_post('/admin', function () {
    $db = option('db_conn');
    $fh = fopen(realpath(__DIR__ . '/../config/database/initial_data.sql'), 'r');
    while ($sql = fgets($fh)) {
        $sql = rtrim($sql);
        if (!empty($sql)) {
            $db->exec($sql);
        }
    }
    fclose($fh);
    redirect_to('/admin');
});
dispatch('/admin/order.csv', function () {
    $db = option('db_conn');
    $stmt = $db->query(<<<SQL
SELECT order_request.*, stock.seat_id, stock.variation_id, stock.updated_at
FROM order_request JOIN stock ON order_request.id = stock.order_id
ORDER BY order_request.id ASC
SQL
);
    $body = '';
    $orders = $stmt->fetchAll(PDO::FETCH_ASSOC);
    foreach ($orders as &$order) {
        $body .= join(',', array($order['id'], $order['member_id'], $order['seat_id'], $order['variation_id'], $order['updated_at']));
        $body .= "\n";
    }
    send_header('Content-Type: text/csv');
    return $body;
});
run();
开发者ID:n0bisuke,项目名称:isucon2,代码行数:31,代码来源:index.php

示例10: export_row_items

/**
 * Row Export
 */
function export_row_items(&$exportPlugin, $page_title, $include_header, $export_columns, $s_item_type, $owner_id)
{
    $iiresults = fetch_export_item_instance_rs($s_item_type, $owner_id);
    if ($iiresults) {
        send_header($exportPlugin, $page_title);
        if ($include_header == 'Y') {
            if (method_exists($exportPlugin, 'prompt_header')) {
                $row = get_header_row('prompt', $export_columns, $s_item_type);
                if (is_not_empty_array($row)) {
                    send_data($exportPlugin->prompt_header($row));
                }
            } else {
                if (method_exists($exportPlugin, 'data_header')) {
                    $row = get_header_row('data', $export_columns, $s_item_type);
                    if (is_not_empty_array($row)) {
                        send_data($exportPlugin->data_header());
                    }
                }
            }
        }
        $item_instance_r2 = NULL;
        while ($item_instance_r = db_fetch_assoc($iiresults)) {
            $row = get_item_row($export_columns, strlen($s_item_type) == 0, $item_instance_r['item_id'], $item_instance_r['instance_no'], $item_instance_r['owner_id'], $item_instance_r['s_item_type'], $item_instance_r['title'], $item_instance_r['borrow_duration'], $item_instance_r['s_status_type'], $item_instance_r['status_comment']);
            if (is_not_empty_array($row)) {
                send_data($exportPlugin->item_row($row));
            }
            $item_instance_r2 = $item_instance_r;
        }
        db_free_result($iiresults);
        if (method_exists($exportPlugin, 'close')) {
            send_data($exportPlugin->close());
        }
        send_footer($exportPlugin);
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:horrabin,项目名称:opendb,代码行数:41,代码来源:export.php

示例11: route_post_order_action


//.........这里部分代码省略.........
        status(HTTP_NOT_FOUND);
        exit;
    }
    $response = array();
    $act = $_POST['act'];
    switch ($act) {
        case 'cancel':
            if ($order['uid'] != $member['id']) {
                status(HTTP_FORBIDDEN);
                exit;
            }
            if (($order['flags'] & FLAG_DELETED) == FLAG_DELETED) {
                return json_error('ORDER_CANCELLED');
            }
            if (($order['flags'] & FLAG_REPLIED) == FLAG_REPLIED) {
                return json_error('ORDER_COMMITTED');
            }
            // Start and lock 'reverse-order' transaction
            $temp = start_order_transaction($uid, -$order['amount']);
            if ($temp === FALSE) {
                return json_error('START_TRANS');
            }
            // Set order 'DELETED' flag
            $res = $MC_Text->increment("flags-1_{$local_id}", FLAG_DELETED);
            if ($res === FALSE) {
                // Cancel transaction
                delete_temp_transaction($temp);
                return json_error('CANCEL_ORDER');
            }
            // Commit 'reverse-order' transaction
            commit_transaction($temp);
            $response['ok'] = TRUE;
            // Send to common queue
            enqueue(array('cancel' => $local_id), '');
            // Refresh balance
            $response['balance'] = formatBalance('USR', $uid);
            $response['order_balance'] = formatBalance('ORD', $uid);
            // Send to user's queue
            enqueue(array('cancel' => $local_id, 'balance' => $response['balance']), $uid);
            break;
        case 'commit':
            # Prevent from committing own orders
            #if ($order['uid'] == $member['id']) {
            #    status(HTTP_FORBIDDEN);
            #    exit;
            #}
            if (($order['flags'] & FLAG_DELETED) == FLAG_DELETED) {
                return json_error('ORDER_CANCELLED');
            }
            if (($order['flags'] & FLAG_REPLIED) == FLAG_REPLIED) {
                return json_error('ORDER_COMMITTED');
            }
            // Start and lock 'commit-order' transaction
            $temp = start_commit_order_transaction($uid, $order['uid'], $order['amount']);
            if ($temp === FALSE) {
                return json_error('START_TRANS');
            }
            // Set order 'COMMITTED' flag
            $resp = $MC_Text->increment("flags-1_{$local_id}", FLAG_REPLIED);
            if ($resp === FALSE) {
                // Cancel transaction
                delete_temp_transaction($temp);
                return json_error('COMMIT_ORDER');
            }
            // Commit 'commit-order' transaction
            $resp = commit_transaction($temp);
            # TODO: Store transaction id in the order
            $response['ok'] = TRUE;
            // Refresh balance
            $response['balance'] = formatBalance('USR', $uid);
            $response['order_balance'] = formatBalance('ORD', $uid);
            $author = $order['uid'];
            // Send to user's queue
            if ($uid != $author) {
                enqueue(array('commit' => $local_id, 'balance' => $response['balance']), $uid);
            }
            // Send to common queue
            enqueue(array('commit' => $local_id), '');
            // Render author's html
            global $i;
            global $page;
            $i = get_order($local_id);
            $page = array('member' => array('id' => $author));
            ob_start();
            include 'templates/_order.php';
            $html = ob_get_clean();
            // Send to author's queue
            $data = array('commit' => $local_id, 'order' => $i, 'html' => $html);
            if ($author == $uid) {
                $data['balance'] = $response['balance'];
            }
            enqueue($data, $author);
            break;
        default:
            status(HTTP_BAD_REQUEST);
            exit;
    }
    send_header('Content-Type: application/json; charset=utf-8');
    echo json_encode($response);
}
开发者ID:enikesha,项目名称:v_order,代码行数:101,代码来源:index.php

示例12: get_following

function get_following()
{
    $db = option('db_conn');
    $user = get('user');
    $stmt = $db->prepare('SELECT users.* FROM follow_map JOIN users ON (follow_map.target = users.id) WHERE follow_map.user = :user ORDER BY follow_map.created_at DESC');
    $stmt->bindValue(':user', $user['id']);
    $stmt->execute();
    $followings = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $users = array();
    foreach ($followings as $following) {
        $users[] = array('id' => $following['id'], 'name' => $following['name'], 'icon' => uri_for('/icon/' . $following['icon']));
    }
    send_header('Cache-Control: no-cache');
    echo json(array(users => $users));
}
开发者ID:kentana20,项目名称:isucon3,代码行数:15,代码来源:index.php

示例13: sanitize

/* Include configuration */
require_once './config.php';
/* Get path */
if (isset($_GET['path'])) {
    $dir = sanitize($_GET['path']);
} else {
    $dir = TFTP_FILE_ROOT;
}
/* Download or show files */
if (isset($_GET['download'])) {
    /* Download files */
    $file = sanitize($_GET['download']);
    get_file($file);
} else {
    /* Show files */
    send_header($dir);
    show_files($dir);
    send_footer();
}
function sanitize($path)
{
    /* Don't get back up the directory structure */
    if (preg_match('/\\.\\./', $path) > 0) {
        echo "Illegal path specified";
        exit;
    }
    /* Make sure we are within DIRROOT */
    if (preg_match('!^' . TFTP_FILE_ROOT . '!', $path) == 0) {
        echo "Illegal access";
        exit;
    }
开发者ID:americandigitalservices,项目名称:cisco-config-manager,代码行数:31,代码来源:browse.php


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