本文整理汇总了PHP中header函数的典型用法代码示例。如果您正苦于以下问题:PHP header函数的具体用法?PHP header怎么用?PHP header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($limit = 1024)
{
header('Content-Type: application/json');
$dates = json_decode(file_get_contents('hoa://Application/Database/Dates.json'), true);
echo json_encode(array_slice($dates, 0, $limit));
return;
}
示例2: automacuser
function automacuser($json = false)
{
global $Settings;
// TODO MAC is passed in via uam
$mac = DatabaseFunctions::getInstance()->latestMacFromIP(remoteip());
$autoUsername = mactoautousername($mac);
// Attempt to create user
//
$autoCreateGroup = $Settings->getSetting('autocreategroup');
$autoCreatePassword = $Settings->getSetting('autocreatepassword');
$groupSettings = $Settings->getGroup($autoCreateGroup);
/* TODO Set at the group level and not in the radcheck table,
* requires changes to how DB class works
*/
if ($autoCreateGroup && strlen($autoUsername) > 0) {
// Create user
DatabaseFunctions::getInstance()->createUser($autoUsername, $autoCreatePassword, false, false, '--', $groupSettings[$autoCreateGroup]['ExpireAfter'], $autoCreateGroup, "Auto created account for {$mac} at " . date('Ymd H:i:s'));
// Users password may not match the autocreatepassword if it's changed.
// Should we update the users password or get the users password?
DatabaseFunctions::getInstance()->setUserPassword($autoUsername, $autoCreatePassword);
// Create CHAP Challenge/Response token
$challenge = $_GET['challenge'];
$response = chapchallengeresponse($challenge, $autoCreatePassword);
$loginURL = uamloginurl($autoUsername, $response);
if ($json) {
return json_encode(array('username' => $autoUsername, 'challenge' => $challenge, 'response' => $response));
} else {
header("Location: {$loginURL}");
return false;
}
}
return false;
}
示例3: permisos
function permisos($rol, $ruta)
{
session_start();
//Si no hay una sesion iniciada, redirige al login
if (!$_SESSION) {
header('Location:' . $ruta . 'vistas/login.php');
} else {
//Si no existe la variable de sesion del usuario logueado, redirige al login
if (!isset($_SESSION["rol"])) {
header('Location:' . $ruta . 'vistas/login.php');
} else {
if ($_SESSION["rol"] != $rol && $_SESSION["login_usuario"] != 'test') {
header('location:' . $ruta . 'vistas/menu.php');
} else {
include_once '' . $ruta . 'vistas/headers.php';
//Escoge el idioma por defecto si no tiene uno el usuario
if (!$_SESSION["idioma"]) {
$includeIdioma = $ruta . "modelo/esp.php";
return $includeIdioma;
} else {
$includeIdioma = $ruta . "modelo/" . $_SESSION['idioma'] . ".php";
return $includeIdioma;
}
}
}
}
}
示例4: indexAction
public function indexAction()
{
//echo 'Hello Index!';
header('Content-Type: text/plain');
echo $config = Mage::getConfig()->loadModulesConfiguration('system.xml')->getNode()->asXML();
exit;
}
示例5: afficherMessage
/**
* Affiche un message puis redirige le visiteur vers une URL spécifiée
* @param string $message Message à afficher
* @param string $url URL vers laquelle rediriger le visiteur
* @param bool $erreur S'agit-il d'une erreur
* @return void
*/
function afficherMessage($message, $url, $erreur = false)
{
$_SESSION['flash']['message'] = $message;
$_SESSION['flash']['erreur'] = $erreur;
header('Location: ' . $url);
exit;
}
示例6: throwErrorPage
function throwErrorPage($code)
{
if ($code == "404") {
$header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found';
} else {
if ($code == "403") {
$header = $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden';
} else {
$header = $_SERVER['SERVER_PROTOCOL'] . ' ' . $code;
}
}
header($header);
$errorPage = sConfig()->getVar('CONFIG/ERRORPAGES/ERROR_' . $code);
if ($errorPage && $errorPage != '') {
$request_path_string = getRequestPathString(explode('/', 'page' . $errorPage));
$request_path = getRequestPathArray($request_path_string);
$psite = $request_path[1];
if ((int) $psite > 0) {
$sinfo = sSites()->get($psite);
$siteID = (int) $psite;
} else {
$sinfo = sSites()->getByPName($psite);
$siteID = $sinfo['ID'];
}
$pageMgr = new PageMgr($siteID);
$pageID = $pageMgr->getPageIdByPname($request_path[count($request_path) - 1]);
$page = $pageMgr->getPage($pageID);
$pageInfo = $page->get();
$version = $page->getLatestVersion();
renderPage($page, $version, $pageInfo, $pageMgr, $sinfo);
} else {
echo $header;
}
die;
}
示例7: indexOp
/**
* 登录
*/
public function indexOp()
{
if (!$this->isQQLogin()) {
if (empty($_POST['username']) || empty($_POST['password']) || !in_array($_POST['client'], $this->client_type_array)) {
output_error('登录失败');
}
}
$model_member = Model('member');
$array = array();
if ($this->isQQLogin()) {
$array['member_qqopenid'] = $_SESSION['openid'];
} else {
$array['member_name'] = $_POST['username'];
$array['member_passwd'] = md5($_POST['password']);
}
$member_info = $model_member->getMemberInfo($array);
if (!empty($member_info)) {
$token = $this->_get_token($member_info['member_id'], $member_info['member_name'], $_POST['client']);
if ($token) {
if ($this->isQQLogin()) {
setNc2Cookie('username', $member_info['member_name']);
setNc2Cookie('key', $token);
header("location:" . WAP_SITE_URL . '/tmpl/member/member.html?act=member');
} else {
output_data(array('username' => $member_info['member_name'], 'key' => $token));
}
} else {
output_error('登录失败');
}
} else {
output_error('用户名密码错误');
}
}
示例8: aint_connected
function aint_connected()
{
if (!isset($_SESSION['auth'])) {
header('Location:index.php?page=connexion');
exit;
}
}
示例9: throwError
/**
* Throw file upload error, return true if error has been thrown, false if error has been catched
*
* @param int $number
* @param string $text
* @access public
*/
public function throwError($number, $text = false, $exit = true)
{
if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
return false;
}
switch ($number) {
case CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST:
case CKFINDER_CONNECTOR_ERROR_INVALID_NAME:
case CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED:
case CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED:
header("HTTP/1.0 403 Forbidden");
header("X-CKFinder-Error: " . $number);
break;
case CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED:
header("HTTP/1.0 500 Internal Server Error");
header("X-CKFinder-Error: " . $number);
break;
default:
header("HTTP/1.0 404 Not Found");
header("X-CKFinder-Error: " . $number);
break;
}
if ($exit) {
exit;
}
}
示例10: mytheme_add_admin
function mytheme_add_admin()
{
global $themename, $shortname, $options;
if ($_GET['page'] == basename(__FILE__)) {
if ('save' == $_REQUEST['action']) {
foreach ($options as $value) {
if ($value['type'] != 'header') {
update_option($value['id'], $_REQUEST[$value['id']]);
}
}
foreach ($options as $value) {
if (isset($_REQUEST[$value['id']])) {
update_option($value['id'], $_REQUEST[$value['id']]);
} else {
delete_option($value['id']);
}
}
header("Location: themes.php?page=settings.php&saved=true");
die;
} else {
if ('reset' == $_REQUEST['action']) {
foreach ($options as $value) {
delete_option($value['id']);
}
header("Location: themes.php?page=settings.php&reset=true");
die;
}
}
}
add_theme_page($themename . " Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
示例11: buildjs
function buildjs()
{
$t = $_GET["t"];
$time = time();
$MEPOST = 0;
header("content-type: application/x-javascript");
$tpl = new templates();
$page = CurrentPageName();
$array = unserialize(@file_get_contents($GLOBALS["CACHEFILE"]));
$prc = intval($array["POURC"]);
$title = $tpl->javascript_parse_text($array["TEXT"]);
$md5file = trim(md5_file($GLOBALS["LOGSFILES"]));
echo "// CACHE FILE: {$GLOBALS["CACHEFILE"]} {$prc}%\n";
echo "// LOGS FILE: {$GLOBALS["LOGSFILES"]} - {$md5file} " . strlen($md5file) . "\n";
if ($prc == 0) {
if (strlen($md5file) < 32) {
echo "\n\t// PRC = {$prc} ; md5file={$md5file}\n\tfunction Start{$time}(){\n\t\t\tif(!RTMMailOpen()){return;}\n\t\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
return;
}
}
if ($md5file != $_GET["md5file"]) {
echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
return;
}
if ($prc > 100) {
echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
return;
}
if ($prc == 100) {
echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\t\$('#SQUID_ARTICA_QUOTA_RULES').flexReload();\n\t\tRTMMailHide();\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
return;
}
echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
}
示例12: search_ac_init
function search_ac_init(&$a)
{
if (!local_channel()) {
killme();
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
$search = $_REQUEST['query'];
}
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
$results = array();
if ($r) {
foreach ($r as $g) {
$results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
}
}
$r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
if (count($r)) {
foreach ($r as $g) {
$results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
}
}
header("content-type: application/json");
$o = array('start' => $start, 'count' => $count, 'items' => $results);
echo json_encode($o);
logger('search_ac: ' . print_r($x, true));
killme();
}
示例13: form_add_admin
function form_add_admin()
{
global $form_name, $form_shortname, $form;
$form_options = form_options();
if (isset($_GET['page']) && $_GET['page'] == "form") {
if (isset($_REQUEST['action']) && 'install' == $_REQUEST['action']) {
delete_option('form_log');
foreach ($form_options as $value) {
if (isset($_REQUEST[$value['id']])) {
update_option($value['id'], $_REQUEST[$value['id']]);
} else {
delete_option($value['id']);
}
}
header("Location: admin.php?page=form&installed=true");
die;
}
}
add_menu_page($form_name, $form_name, 'manage_options', 'form', 'form_main');
add_submenu_page('form', $form_name . ' - Setup', 'Setup', 'manage_options', 'form', 'form_main');
if (get_option("form_version")) {
if (!isset($form['output']['menus']) && !isset($_SESSION['form']['menus'])) {
form_output('headers');
}
//load menus
if (isset($form['output']['menus']) && is_array($form['output']['menus']) && count($form['output']['menus']) > 0) {
$_SESSION['form']['menus'] = $form['output']['menus'];
}
if (isset($_SESSION['form']['menus'])) {
foreach ($_SESSION['form']['menus'] as $menu) {
add_submenu_page('form', $form_name . ' - ' . $menu[0], $menu[0], 'manage_options', $menu[1], 'form_main');
}
}
}
}
示例14: ajax_carga_capa
/**
*
*/
public function ajax_carga_capa()
{
header('Content-type: application/json');
$this->load->library("visor/capa/visor_capa_elemento");
$params = $this->input->post(null, true);
$data = array("correcto" => true, "capa" => array("zona" => "", "icono" => "", "nombre" => "", "color" => "", "json" => array()));
/*$regiones_usuario = explode(",",$this->session->userdata('session_regiones'));
foreach($regiones_usuario as $region){
$retorno = $this->visor_capa_elemento->cargaCapasRegion($region);
$data["capa"]["nombre"] = $retorno["capa"]["nombre"];
$data["capa"]["icono"] = $retorno["capa"]["icono"];
$data["capa"]["color"] = $retorno["capa"]["color"];
$data["capa"]["zona"] = $retorno["capa"]["zona"];
if(is_array($retorno["capa"]["json"])){
$data["capa"]["json"] = array_merge($retorno["capa"]["json"], $data["capa"]["json"]);
}
}*/
foreach ($params["emergencia"] as $id_emergencia) {
fb($id_emergencia);
$this->visor_capa_elemento->setEmergencia($id_emergencia);
$retorno = $this->visor_capa_elemento->cargaCapa($params["id"]);
$data["capa"]["nombre"] = $retorno["capa"]["nombre"];
$data["capa"]["icono"] = $retorno["capa"]["icono"];
$data["capa"]["color"] = $retorno["capa"]["color"];
$data["capa"]["zona"] = $retorno["capa"]["zona"];
if (is_array($retorno["capa"]["json"])) {
$data["capa"]["json"] = array_merge($retorno["capa"]["json"], $data["capa"]["json"]);
}
}
echo json_encode($data);
}
示例15: data_convert
/**
* データを自動的に加工して返す。
*
* @param mixed $val 加工するデータ
* @return string 加工されたテキストデータ
*/
public function data_convert($val)
{
$data_type = $this->px->req()->get_param('type');
if (!is_string($data_type) || !strlen($data_type)) {
$data_type = 'json';
}
if ($data_type == 'json') {
header('Content-type: application/json; charset=UTF-8');
} elseif ($data_type == 'jsonp') {
header('Content-type: application/javascript; charset=UTF-8');
} elseif ($data_type == 'xml') {
header('Content-type: application/xml; charset=UTF-8');
}
switch ($data_type) {
case 'jsonp':
return $this->data2jsonp($val);
break;
case 'json':
return $this->data2json($val);
break;
case 'xml':
return $this->data2xml($val);
break;
}
// return self::data2jssrc($val);
return $val;
}