易截截图软件、单文件、免安装、纯绿色、仅160KB

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批量生成随机用户名

生成6 ~ 16位的用户名若干个,主要是文本操作,但是前提是要有一个字符串包。主要包含三个程序。
程序一:负责从字典中随机提取数据,写入一个新文件。(1.php)
<?php
/* 从字典文件中提取随机值 */
$file1 = "./Words.dic";
$file2 = "./common_pass_mini.dic";
$file3 = "./Sys_Month_Date.Dic";
$rfile = "./ ......

php 数据库的封装类

 <?php
 class DB
 {
  private $link;
  function connectDB($dbhost, $dbuser, $dbpw, $dbname="", $pconnect = 1)
  {
   if($pconnect)
   {
    if(!$this->link = mysql_pconnect($dbhost, $dbuser, ......

在Windows XP下配置PHP和Apache环境

    在windows操作系统配置PHP环境,可以用IIS做应用服务器,也可以使用Apache做应用服务器。本文介绍在Windows XP操作系统下配置PHP和Apache环境。
    准备工作:
    1、在http://windows.php.net/download/下载PHP程序包,因为用Apache做应用服务器,选择用VC6编译的 ......

使用nginx配置多个php fastcgi负载均衡

配置还是非常简单的,充分体现了nginx的强大与配置的简单^^下面是大致的服务器结构图:
应用的最前端是一台nginx服务器,所有静态的内容都由nginx来处理,而将所有php的请求都分摊到下游的若干台运行php fastcgi守护进程的服务器中,这样可以以一种廉价的方案来实现对系统负载的分摊,扩展系统的负载能力。
三台php fastc ......

用PHP如何判断一个文件的编码?

 整理自:http://bbs.phpchina.com/viewthread.php?tid=18006
文件a.txt,用PHP如何判断它的编码是GBK还是UTF-8呢?
1,重新认识一下此问题,当时版主回复的时候我就觉得mb函数里一定有这样的功能,但今日研究了mb库,并没有这样的功能。用mb_detect_encoding总是不准确。
echo mb_detect_encoding(file_get_conten ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号