php 访问控制
<?php
// An array of allowed users and their passwords
$users = array(
'harryf' => 'secret',
'tom' => 'mypwd'
);
// If there's no Authentication header, exit
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('This page requires authentication');
}
// If the user name doesn't exist, exit
if (!isset($users[$_SERVER['PHP_AUTH_USER']])) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('Unauthorized!');
}
// Is the password doesn't match the username, exit
if ($users[$_SERVER['PHP_AUTH_USER']] != $_SERVER['PHP_AUTH_PW'])
{
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('Unauthorized!');
}
echo 'You\'re in!';
?>
相关文档:
<?php
class DB
{
private $link;
function connectDB($dbhost, $dbuser, $dbpw, $dbname="", $pconnect = 1)
{
if($pconnect)
{
if(!$this->link = mysql_pconnect($dbhost, $dbuser, ......
Memcache函数库是在PECL(PHP Extension Community Library)中,主要作用是搭建大容量的内存数据的临时存放区域,在分布式的时候作用体现的非常明显,否则不建议使用。
memcache函数所有的方法列表如下:
参考http://www.php.net/manual/zh/function.Memcache-add.php
Memcache::add - 添加一个值,如果已经存在,则返回f ......
memcache::debug
bool memcache_debug ( bool $on_off )
说明:
控制调试功能,前提是php在编译的时候使用了-enable-debug选项,否则这个函数不会有作用。
参数:
$on_off:true表示开启调试,false表示关闭调试
返回值:
如果php在编译的时候使用了-enable-debug选项,返回true,否则返回false
Memcache:: ......
1.方法一:
<?
$dir="D:";
static $dir_list =0;
static $file_list =0;
function listfile($dir){
global $dir_list,$file_list;
$d = dir($dir);
while ( $entry = $d->read()) {
$tem_curnt=$dir."/".$entry;
if($entry=="." || $entry=="..") continue;
if ( is_dir( $tem_curnt)) {
......
近日在用自己以前写的http下载器下载某一个php页面以外遭遇403错误.但是ie却能够正确访问. 日志如下: IE: Time At:0005504671
Line:10
send: 192.168.1.2 –> xxx.xxx.xxx.xxx len:351
GET /test.jpg HTTP/1.1
Accept: */*
Accept-Language: en-us
Accept-Enc ......