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, ......
最近上网找了一些关于备份mysql数据库的方法,主要就是通过网页的方法导出数据库的sql 文件,找到个不错的代码,但发现中文导出会乱码,于是稍微修改了一下,下面是备份的代码
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml ......
近日在用自己以前写的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 ......
配置还是非常简单的,充分体现了nginx的强大与配置的简单^^下面是大致的服务器结构图:
应用的最前端是一台nginx服务器,所有静态的内容都由nginx来处理,而将所有php的请求都分摊到下游的若干台运行php fastcgi守护进程的服务器中,这样可以以一种廉价的方案来实现对系统负载的分摊,扩展系统的负载能力。
三台php fastc ......
HTML代码
<form action="" method="post">
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="1"/>
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="2"/>
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="3"/>
<input name="ID_D ......