当前位置:  编程技术>php
本页文章导读:
    ▪如何使用php判断服务器是否是HTTPS连接       代码如下:if ($_SERVER['HTTPS'] != "on") { echo "This is not HTTPS";}else{ echo "This is HTTPS";}if ($_SERVER['HTTPS'] != "on") { echo "This is not HTTPS";}else{ echo "This is HTTPS";} ......
    ▪使用PHP实现蜘蛛访问日志统计       代码如下:$useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); if (strpos($useragent, 'googlebot')!== false){$bot = 'Google';} elseif (strpos($useragent,'mediapartners-google') !== false){$bot = 'Google Adsense';} elseif (strpos($.........
    ▪PHP系统命令函数使用分析       代码如下:function execute($cmd) {     $res = '';     if ($cmd) {         if(function_exists('system')) {             @ob_start();             @system($cmd);             $res = @ob_get_contents(.........

[1]如何使用php判断服务器是否是HTTPS连接
    来源: 互联网  发布时间: 2013-11-30
代码如下:

if ($_SERVER['HTTPS'] != "on") {
 echo "This is not HTTPS";
}else{
 echo "This is HTTPS";
}if ($_SERVER['HTTPS'] != "on") {
 echo "This is not HTTPS";
}else{
 echo "This is HTTPS";
}


    
[2]使用PHP实现蜘蛛访问日志统计
    来源: 互联网  发布时间: 2013-11-30
代码如下:

$useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT']));

 if (strpos($useragent, 'googlebot')!== false){$bot = 'Google';}
 elseif (strpos($useragent,'mediapartners-google') !== false){$bot = 'Google Adsense';}
 elseif (strpos($useragent,'baiduspider') !== false){$bot = 'Baidu';}
 elseif (strpos($useragent,'sogou spider') !== false){$bot = 'Sogou';}
 elseif (strpos($useragent,'sogou web') !== false){$bot = 'Sogou web';}
 elseif (strpos($useragent,'sosospider') !== false){$bot = 'SOSO';}
 elseif (strpos($useragent,'360spider') !== false){$bot = '360Spider';}
 elseif (strpos($useragent,'yahoo') !== false){$bot = 'Yahoo';}
 elseif (strpos($useragent,'msn') !== false){$bot = 'MSN';}
 elseif (strpos($useragent,'msnbot') !== false){$bot = 'msnbot';}
 elseif (strpos($useragent,'sohu') !== false){$bot = 'Sohu';}
 elseif (strpos($useragent,'yodaoBot') !== false){$bot = 'Yodao';}
 elseif (strpos($useragent,'twiceler') !== false){$bot = 'Twiceler';}
 elseif (strpos($useragent,'ia_archiver') !== false){$bot = 'Alexa_';}
 elseif (strpos($useragent,'iaarchiver') !== false){$bot = 'Alexa';}
 elseif (strpos($useragent,'slurp') !== false){$bot = '雅虎';}
 elseif (strpos($useragent,'bot') !== false){$bot = '其它蜘蛛';}
 if(isset($bot)){
     $fp = @fopen('bot.txt','a');
     fwrite($fp,date('Y-m-d H:i:s')."\t".$_SERVER["REMOTE_ADDR"]."\t".$bot."\t".'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]."\r\n");
     fclose($fp);
 }

    
[3]PHP系统命令函数使用分析
    来源: 互联网  发布时间: 2013-11-30
代码如下:

function execute($cmd) {
     $res = '';
     if ($cmd) {
         if(function_exists('system')) {
             @ob_start();
             @system($cmd);
             $res = @ob_get_contents();
             @ob_end_clean();
         } elseif(function_exists('passthru')) {
             @ob_start();
             @passthru($cmd);
             $res = @ob_get_contents();
             @ob_end_clean();
         } elseif(function_exists('shell_exec')) {
             $res = @shell_exec($cmd);
         } elseif(function_exists('exec')) {
             @exec($cmd,$res);
             $res = join(“\n",$res);
         } elseif(@is_resource($f = @popen($cmd,"r"))) {
             $res = '';
             while(!@feof($f)) {
                 $res .= @fread($f,1024);
             }
             @pclose($f);
         }
     }
     return $res;
 }

    
最新技术文章:
▪PHP函数microtime()时间戳的定义与用法
▪PHP单一入口之apache配置内容
▪PHP数组排序方法总结(收藏)
▪php数组排序方法大全(脚本学堂整理奉献)
▪php数组排序的几个函数(附实例)
▪php二维数组排序(实例)
▪php根据键值对二维数组排序的小例子
▪php验证码(附截图)
▪php数组长度的获取方法(三个实例)
▪php获取数组长度的方法举例
▪判断php数组维度(php数组长度)的方法
▪php获取图片的exif信息的示例代码
▪PHP 数组key长度对性能的影响实例分析
▪php函数指定默认值的方法示例
▪php提交表单到当前页面、提交表单后页面重定...
▪php四舍五入的三种实现方法
▪php获得数组长度(元素个数)的方法
▪php日期函数的简单示例代码
▪php数学函数的简单示例代码
▪php字符串函数的简单示例代码
▪php文件下载代码(多浏览器兼容、支持中文文...
▪php实现文件下载、支持中文文件名的示例代码...
▪php文件下载(防止中文文件名乱码)的示例代码
▪解决PHP文件下载时中文文件名乱码的问题
▪php数组去重(一维、二维数组去重)的简单示例
▪php小数点后取两位的三种实现方法
▪php Redis 队列服务的简单示例
▪PHP导出excel时数字变为科学计数的解决方法
▪PHP数组根据值获取Key的简单示例
▪php数组去重的函数代码示例
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3