1 2 3 4 5 6 7 8 9 10 下一页
Of course, this should be done before any html tag or PHP echo/print.
bosmeew at gmail dot com
18-Feb-2007 10:43
To get the server address, you can use
PHP预定义变量(2)_网学
浏览:
SERVER['SERVER_ADDR']. However, this only works when your PHP process is running on a Webserver, not when running PHP as CLI. Here is a function which will also return the server address when running on Linux (eth0 is hardcoded as the network interface, modify if necessary).<?php function getServerAddress() { if(
PHP预定义变量(2)_网学
浏览:
SERVER['SERVER_ADDR']) { return
PHP预定义变量(2)_网学
浏览:
SERVER['SERVER_ADDR']; } $ifconfig = shell_exec('/sbin/ifconfig eth0'); preg_match('/addr:([d.]+)/',$ifconfig,$match); return $match[1]; } ?>
borg at sven-of-nine dot de
30-Jan-2007 07:22
Simple function to determine if a visitor is an agent or not
function isbot($agent="") { //Handfull of Robots $bot_array =array("jeevesteoma", "MSNbot", "slurp", "jeevestemoa", "gulper", "googlebot", "linkwalker", "validator", "webaltbot", "wget"); //no agent given => read from globals if ($agent=="") { @$agent=
PHP预定义变量(2)_网学
浏览:
SERVER["HTTP_USER_AGENT"]; } //replace all but alpha $agent=strtolower(preg_replace("/[^a-zA-Z _]*/","",$agent)); //check f&uUML;r intersections return((BOOL)count(array_intersect(explode(" ",$agent),$bot_array))); }
(责任编辑:admin)