易截截图软件、单文件、免安装、纯绿色、仅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 数据库的封装类

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

[转载]PHP 计算时间差

我们常常在网站上看到某篇文章发表于“3天前”,“5个月前”,“4年前”。下面这个函数就提供了计算这个时间差的功能。
<?php
/**
* 时间差计算
*
* @param Timestamp $time
* @return String Time Elapsed
* @author Shelley Shyan
* @copyright http://phparch.cn (Professiona ......

PHP缓存技术:memcache函数详解之二

memcache::debug
bool memcache_debug ( bool $on_off )
 
说明:
控制调试功能,前提是php在编译的时候使用了-enable-debug选项,否则这个函数不会有作用。
参数:
$on_off:true表示开启调试,false表示关闭调试
返回值:
如果php在编译的时候使用了-enable-debug选项,返回true,否则返回false
Memcache:: ......

php以root权限执行的解决方案之一

这种问题我想大家可能都遇到过,网友提供的解决方法也很多。我也只是结合自己系统的需求并结合网友的解决方案来总结的一种方法
用来作为解决php以root权限执行一些普通用户不能执行的命令或应用的参考。
其实php里的popen()函数是可以解决这个问题的,但是由于某些版本的linux(如我使用的Centos 5)对系统安全的考虑,
使 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号