php不支持访问控制,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脚本testdb.php,在浏览器中运行:http://localhost/testdb.php,出现错误:Can't connect to MySQL server on '10.60.56.220' (13),但是在本地用php命令行运行:php testdb.php,却正常地连上了数据库并读出了其中的数据。

应用程序环境:本地IP:10.60.56.90,本地电脑上安装Apache 2 ......

class DB

{

private $link;

function connectDB($dbhost, $dbuser, $dbpw, $dbname="", $pconnect = 1)

{

if($pconnect)

{

if(!$this->link = mysql_pconnect($dbhost, $dbuser, ......

这种问题我想大家可能都遇到过,网友提供的解决方法也很多。我也只是结合自己系统的需求并结合网友的解决方案来总结的一种方法

用来作为解决php以root权限执行一些普通用户不能执行的命令或应用的参考。

其实php里的popen()函数是可以解决这个问题的,但是由于某些版本的linux(如我使用的Centos 5)对系统安全的考虑,

使 ......

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)) {

......

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值