Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, January 16, 2007

How to recognize google visit

do you want to know if this visit is a google visit??
here is a simple asp code to do that:
< % robot=request.ServerVariables("HTTP_USER_AGENT") if (Instr(robot,"Googlebot")<>0) then
...
end if
% >

and this is how to do it with php script

< ? define("SYSTEM_FROM_NAME","Your name"); define("SYSTEM_FROM_EMAIL","Your email"); //---this script will send email to webmaster when google visit your pages. if(isset($_SERVER['HTTP_USER_AGENT']) && eregi("googlebot",$_SERVER['HTTP_USER_AGENT'])) { if ($QUERY_STRING != "") { $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].'?'.$QUERY_STRING; } else { $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; } $today = date("F j, Y, g:i a"); $headers = "From: ".SYSTEM_FROM_NAME." <".SYSTEM_FROM_EMAIL.">";
$message="";
$message.="Googlebot is crawling your site:\n";
$message.="Page: $url\n";
$message.="Date: $today \n";
$message.="IP: ".$_SERVER['REMOTE_ADDR']." \n";
mail(SYSTEM_FROM_EMAIL, "googlebot crawle - $url", "$message",$headers);}
? >

Friday, July 14, 2006

SELECT random records from a database

asp script:
randomize
sql="select max (ID) as maxid from table"rs.open sql,cn
max=rs("maxid")
rs.close

for i=0 to 100
rndNum=int(rnd()*max)+1
idstr=idstr&rndNum&","
next
idstr=idstr+"0"

sql="select top 25 ID, * from table where ID in ("+idstr+")"
rs.open sql,cn



<% randomize sql="select max (ID) as maxid from table" rs.open sql,cn max=rs("maxid") rs.close for i=0 to 100 rndNum=int(rnd()*max)+1 idstr=idstr&rndNum&"," next idstr=idstr+"0" sql="select top 25 ID, * from table where ID in ("+idstr+")" rs.open sql,cn %>

Sunday, July 02, 2006

asp smartupload subscript out of range

you are using smart upload for uploading a file to the server and you get this ugly erro message "asp smartupload subscript out of range" and i'm sure that you didn't write the uploading script.. well, i spent one whole day with this error, and a got angry when i knew that it's a stupid mistake. just look at the html form the the data sent from, you shoud set the enctype to multipart/form-data

that's all!!