當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Header函數代碼示例

本文整理匯總了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);
}
開發者ID:nikssardana,項目名稱:bloodmanagementphp,代碼行數:7,代碼來源:req.php

示例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>";
     }
 }
開發者ID:xupp,項目名稱:ThinkPHP,代碼行數:32,代碼來源:download.class.php

示例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);
}
開發者ID:hanpc,項目名稱:chushen,代碼行數:35,代碼來源:code_char.php

示例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;
}
開發者ID:podstawski,項目名稱:appengine,代碼行數:26,代碼來源:google.php

示例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\" />&nbsp;" . _("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);
     }
 }
開發者ID:unki,項目名稱:MasterShaper,代碼行數:35,代碼來源:shaper_page.php

示例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("&amp;","&",urldecode($redirect)));
}
開發者ID:rhertzog,項目名稱:lcs,代碼行數:34,代碼來源:snippet_exporte.php

示例7: registerWithFacebook

 public function registerWithFacebook()
 {
     if ($this->registration->registerWithFacebook()) {
         Header('Location:' . URL);
     } else {
     }
 }
開發者ID:thish1991,項目名稱:Ambula,代碼行數:7,代碼來源:registration.php

示例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'];
 }
開發者ID:h4rdc0m,項目名稱:spotweb,代碼行數:35,代碼來源:SpotPage_statics.php

示例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
 }
開發者ID:NZBtje,項目名稱:spotweb-1,代碼行數:32,代碼來源:SpotPage_getimage.php

示例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');
		}
	}
開發者ID:eltonsarmento,項目名稱:CursosIAG,代碼行數:26,代碼來源:class.coordenadorchecklogin.php

示例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;
 }
開發者ID:BackupTheBerlios,項目名稱:serweb,代碼行數:29,代碼來源:method.get_vm.php

示例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);
}
開發者ID:313801120,項目名稱:AspPhpCms,代碼行數:33,代碼來源:YZM_7.php

示例13: logon

function logon()
{
    Header("WWW-Authenticate: Basic Realm=\"phpOracleAdmin\"");
    Header("HTTP/1.0 401 Unauthorized");
    echo "Access Denied!";
    exit;
}
開發者ID:BackupTheBerlios,項目名稱:phporacleadmin,代碼行數:7,代碼來源:auth.inc.php

示例14: Output

 public function Output($name = 'mescontacts.pdf', $dest = 'I')
 {
     Header('Pragma: public');
     error_reporting(0);
     parent::Output($name, $dest);
     error_reporting($this->report);
 }
開發者ID:Ekleog,項目名稱:platal,代碼行數:7,代碼來源:contacts.pdf.inc.php

示例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
 }
開發者ID:niel,項目名稱:spotweb,代碼行數:27,代碼來源:SpotPage_Abs.php


注:本文中的Header函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。