易截截图软件、单文件、免安装、纯绿色、仅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!';
?>


相关文档:

apache中php连接远程数据库服务器的问题

问题描述:一个连接远程数据库的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 ......

php 通过网页的方式备份和还原mysql数据库

 最近上网找了一些关于备份mysql数据库的方法,主要就是通过网页的方法导出数据库的sql 文件,找到个不错的代码,但发现中文导出会乱码,于是稍微修改了一下,下面是备份的代码
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml ......

php遍历所有文件及文件夹的方法

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

PHP和Javascript的JSON交互(处理一个二维数组)

 
PHP的JSON类库我使用的是Services_JSON
,没什么特别的优点,也没什么明显的缺点,对付用足矣。
建立文件data.php

<?php
include(
"JSON.php"
);
$data
= array(
    
array(
'name'
=>
mb_convert_encoding
(
'老王'
,
'UTF-8'
,
'GBK'
), ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号