本文整理汇总了PHP中Header函数的典型用法代码示例。如果您正苦于以下问题:PHP Header函数的具体用法?PHP Header怎么用?PHP Header使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Logout
function Logout()
{
unset($_SESSION['user']);
session_unset();
session_destroy();
Header("Location:Home.php", TRUE);
}
示例2: getfiles
public function getfiles()
{
//检查文件是否存在
if (file_exists($this->_filepath)) {
//打开文件
$file = fopen($this->_filepath, "r");
//返回的文件类型
Header("Content-type: application/octet-stream");
//按照字节大小返回
Header("Accept-Ranges: bytes");
//返回文件的大小
Header("Accept-Length: " . filesize($this->_filepath));
//这里对客户端的弹出对话框,对应的文件名
Header("Content-Disposition: attachment; filename=" . $this->_filename);
//修改之前,一次性将数据传输给客户端
echo fread($file, filesize($this->_filepath));
//修改之后,一次只传输1024个字节的数据给客户端
//向客户端回送数据
$buffer = 1024;
//
//判断文件是否读完
while (!feof($file)) {
//将文件读入内存
$file_data = fread($file, $buffer);
//每次向客户端回送1024个字节的数据
echo $file_data;
}
fclose($file);
} else {
echo "<script>alert('对不起,您要下载的文件不存在');</script>";
}
}
示例3: getCode
function getCode($num, $w, $h)
{
// 去掉了 0 1 O l 等
$str = "23456789abcdefghijkmnpqrstuvwxyz";
$code = '';
for ($i = 0; $i < $num; $i++) {
$code .= $str[mt_rand(0, strlen($str) - 1)];
}
//将生成的验证码写入session,备验证页面使用
$_SESSION["my_checkcode"] = $code;
//创建图片,定义颜色值
Header("Content-type: image/PNG");
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
$gray = imagecolorallocate($im, 118, 151, 199);
$bgcolor = imagecolorallocate($im, 235, 236, 237);
//画背景
imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
//画边框
imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
//imagefill($im, 0, 0, $bgcolor);
//在画布上随机生成大量点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(5, 10);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(1, 6);
imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
$strx += $w / 5;
}
imagepng($im);
imagedestroy($im);
}
示例4: getClient
function getClient()
{
$config = (include __DIR__ . '/ini.php');
$client = new Google_Client();
$client->setApplicationName("Webkameleon");
$client->setClientId($config['oauth2_client_id']);
$client->setClientSecret($config['oauth2_client_secret']);
$client->setRedirectUri($config['oauth2_redirect_uri']);
$client->setScopes($config['oauth2_scopes']);
$client->setState('offline');
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
die($client->getAccessToken());
} elseif (!isset($config['token'])) {
Header('Location: ' . $client->createAuthUrl());
} else {
$client->setAccessToken($config['token']);
if ($client->isAccessTokenExpired()) {
$token = json_decode($config['token'], true);
$client->refreshToken($token['refresh_token']);
}
}
return $client;
}
示例5: handler
public function handler()
{
global $tmpl, $page, $ms;
if (isset($this->rights)) {
/* If authentication is enabled, check permissions */
if ($ms->getOption("authentication") == "Y" && !$ms->checkPermissions($this->rights)) {
$ms->throwError("<img src=\"" . ICON_CHAINS . "\" alt=\"chain icon\" /> " . _("Manage Chains"), _("You do not have enough permissions to access this module!"));
return 0;
}
}
switch ($page->action) {
case 'overview':
case 'chains':
case 'pipes':
case 'bandwidth':
case 'options':
case 'about':
case 'tasklist':
case 'update-iana':
case 'list':
$content = $this->showList();
break;
case 'edit':
case 'new':
$content = $this->showEdit();
break;
}
if ($ms->get_header('Location')) {
Header('Location: ' . $ms->get_header('Location'));
return false;
}
if (isset($content)) {
$tmpl->assign('content', $content);
}
}
示例6: action_snippet_exporte
function action_snippet_exporte(){
global $auteur_session;
$arg = _request('arg');
$args = explode(":",$arg);
$hash = _request('hash');
$id_auteur = $auteur_session['id_auteur'];
$redirect = _request('redirect');
if ($redirect==NULL) $redirect="";
include_spip("inc/securiser_action");
if (verifier_action_auteur("snippet_exporte-$arg",$hash,$id_auteur)==TRUE) {
$table = $args[0];
$id = $args[1];
$f = snippets_fond_exporter($table, false);
if ($f) {
include_spip('public/assembler');
$out = recuperer_fond($f,array('id'=>intval($id)));
//$out = preg_replace(",\n\n[\s]*(?=\n),","",$out);
$filename=str_replace(":","_",$arg);
if (preg_match(",<titre>(.*)</titre>,Uims",$out,$regs))
$filename = preg_replace(',[^-_\w]+,', '_', trim(translitteration(textebrut(typo($regs[1])))));
$extension = "xml";
Header("Content-Type: text/xml; charset=".$GLOBALS['meta']['charset']);
Header("Content-Disposition: attachment; filename=$filename.$extension");
Header("Content-Length: ".strlen($out));
echo $out;
exit();
}
}
redirige_par_entete(str_replace("&","&",urldecode($redirect)));
}
示例7: registerWithFacebook
public function registerWithFacebook()
{
if ($this->registration->registerWithFacebook()) {
Header('Location:' . URL);
} else {
}
}
示例8: render
function render()
{
$tplHelper = $this->getTplHelper(array());
# Controleer de users' rechten
$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_statics, '');
# vraag de content op
$mergedInfo = $this->mergeFiles($tplHelper->getStaticFiles($this->_params['type']));
# Er is een bug met mod_deflate en mod_fastcgi welke ervoor zorgt dat de content-length
# header niet juist geupdate wordt. Als we dus mod_fastcgi detecteren, dan sturen we
# content-length header niet mee
if (isset($_SERVER['REDIRECT_HANDLER']) && $_SERVER['REDIRECT_HANDLER'] != 'php-fastcgi') {
Header("Content-Length: " . strlen($mergedInfo['body']));
}
# if
# en stuur de versie specifieke content
switch ($this->_params['type']) {
case 'css':
Header('Content-Type: text/css');
Header('Vary: Accept-Encoding');
// sta toe dat proxy servers dit cachen
break;
case 'js':
Header('Content-Type: application/javascript; charset=utf-8');
break;
case 'ico':
Header('Content-Type: image/x-icon');
break;
}
# switch
# stuur de expiration headers
$this->sendExpireHeaders(false);
# stuur de last-modified header
Header("Last-Modified: " . gmdate("D, d M Y H:i:s", $tplHelper->getStaticModTime($this->_params['type'])) . " GMT");
echo $mergedInfo['body'];
}
示例9: render
function render()
{
$spotnntp_hdr = new SpotNntp($this->_settings->get('nntp_hdr'));
# Controleer de users' rechten
$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotimage, '');
# Haal de volledige spotinhoud op
$fullSpot = $this->_tplHelper->getFullSpot($this->_messageid, true);
# sluit de connectie voor de header, en open een nieuwe connectie voor de nzb
$spotnntp_hdr->quit();
$spotnntp_img = new SpotNntp($this->_settings->get('nntp_nzb'));
# Images mogen gecached worden op de client
$this->sendExpireHeaders(false);
#
# is het een array met een segment nummer naar de image, of is het
# een string met de URL naar de image?
#
if (is_array($fullSpot['image'])) {
Header("Content-Type: image/jpeg");
echo $spotnntp_img->getImage($fullSpot['image']['segment']);
} else {
$x = file_get_contents($fullSpot['image']);
foreach ($http_response_header as $hdr) {
if (substr($hdr, 0, strlen('Content-Type: ')) == 'Content-Type: ') {
header($hdr);
}
# if
}
# foreach
echo $x;
}
# else
}
示例10: executarLogin
private function executarLogin() {
$this->system->load->dao('login');
$dados = $this->system->login->getLoginDao($this->system->input['usuario'], $this->system->input['senha']);
if ($dados) {
$this->system->session->addItem('session_cod_usuario', $dados->id);
$this->system->session->addItem('session_logged_in', true);
$this->system->session->addItem('session_nome', $dados->nome);
$this->system->session->addItem('session_email', $dados->email);
$this->system->session->addItem('session_senha', $dados->senha);
$this->system->session->addItem('session_nivel', $dados->nivel);
switch($dados->nivel) {
case 1:
$nivel = 'administrador';
break;
case 2:
$nivel = 'coordenador';
break;
}
$this->permitido = true;
$this->system->login->updateEntrada();
Header('location: /lms/' . $nivel . '/dashboard/home');
}
}
示例11: get_VM
function get_VM($user, $mid, &$errors)
{
global $config, $lang_str;
if (!$this->connect_to_db($errors)) {
return false;
}
$q = "select subject, file from " . $config->data_sql->table_voice_silo . " where mid=" . $mid . " and " . $this->get_indexing_sql_where_phrase_uri($user);
$res = $this->db->query($q);
if (DB::isError($res)) {
log_errors($res, $errors);
return false;
}
if (!$res->numRows()) {
$errors[] = $lang_str['err_voice_msg_not_found'];
return false;
}
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
$res->free();
@($fp = fopen($config->voice_silo_dir . $row->file, 'r'));
if (!$fp) {
$errors[] = $lang_str['err_can_not_open_message'];
return false;
}
Header("Content-Disposition: attachment;filename=" . RawURLEncode(($row->subject ? $row->subject : "received message") . ".wav"));
Header("Content-type: audio/wav");
@fpassthru($fp);
@fclose($fp);
return true;
}
示例12: getCode
function getCode($num, $w, $h)
{
$code = "";
for ($i = 0; $i < $num; $i++) {
$code .= rand(0, 9);
}
//4位验证码也可以用rand(1000,9999)直接生成
//将生成的验证码写入session,备验证页面使用
$_SESSION['yzm'] = $code;
//setcookie("mimi", md5($code), time()+1200);
//创建图片,定义颜色值
Header("Content-type: image/PNG");
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, 255, 0, 63);
$gray = imagecolorallocate($im, 200, 200, 200);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bgcolor);
//画边框
//imagerectangle($im, 0, 0, $w-1, $h-1, $black);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 10; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(1, 3);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(2, 6);
imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
$strx += rand(8, 12);
}
imagepng($im);
imagedestroy($im);
}
示例13: logon
function logon()
{
Header("WWW-Authenticate: Basic Realm=\"phpOracleAdmin\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Access Denied!";
exit;
}
示例14: Output
public function Output($name = 'mescontacts.pdf', $dest = 'I')
{
Header('Pragma: public');
error_reporting(0);
parent::Output($name, $dest);
error_reporting($this->report);
}
示例15: sendContentTypeHeader
function sendContentTypeHeader($type)
{
switch ($type) {
case 'xml':
Header("Content-Type: text/xml; charset=utf-8");
break;
case 'rss':
Header("Content-Type: application/rss+xml; charset=utf-8");
break;
case 'json':
Header("Content-Type: application/json; charset=utf-8");
break;
case 'css':
Header("Content-Type: text/css; charset=utf-8");
break;
case 'js':
Header("Content-Type: application/javascript; charset=utf-8");
break;
case 'ico':
Header("Content-Type: image/x-icon");
break;
default:
Header("Content-Type: text/html; charset=utf-8");
break;
}
# switch
}