Forum Moderators: coopster

Message Too Old, No Replies

Weblog Alert

anyone know how to script this?

         

Neo541

7:03 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



I'm not that good with PHP yet, but was wondering if anyone knows of a script that would alert me (through email), when a certain page has been accessed?
So, essentially, when someone hits www.mysite.com/certainpage.htm, it emails me a report...

This page will NOT have incoming links, so it won't be having much traffic, which I know could get ugly!

Anyone know of an existing script for this? Or can point me to how to build one?

Thanks!

Yidaki

7:15 pm on Nov 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's a php script that takes the requesting IP and UA, sends it to you via email and prints a funny message:

<?php
$mail_path = "/usr/sbin/sendmail -i -t";
$mail_to = "your@email.com";
$mail_subject = "Fell in trap";
ini_set("sendmail_from", $mail_from);
ini_set("sendmail_path", $mail_path);

if(mail($mail_to,$mail_subject, "IP: ".$_SERVER["REMOTE_ADDR"]."\nUA: ".$_SERVER["HTTP_USER_AGENT"], "From: $_POST[email]\r\n". "Reply-To: $_POST[email]\r\n"))
{
echo "haha, got ya!";
}
exit;
?>

Just make this your trap page and the job is done.

Neo541

7:21 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



Yidaki,

You rock! :)

I will try it, any way to make it so they don't know they were trapped?

Yidaki

7:39 pm on Nov 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>any way to make it so they don't know they were trapped

Sure, just change the haha, got ya! to whatever you want.
You can also replace the whole echo line with

include "certainpage.htm"
.

hint: test it before bringing it online. :)

Neo541

7:57 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



Okay, one last question, then I will be forever in your debt, and also leave you alone!

I have it set with an identifier on the end of the url, so when someone falls in, it says www.mysite.com/certainpage.htm?=1

The 1 identifies which thief...er...user, it is...Any way to add that info to the email?

Either way, you're the best, thanks!

Yidaki

8:10 pm on Nov 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>Any way to add that info to the email?

Neo's weblog trap Version 2.0:


<?php
$who = $HTTP_GET_VARS["who"];
$mail_path = "/usr/sbin/sendmail -i -t";
$mail_to = "your@email.com";
$mail_subject = "Fell in trap";
ini_set("sendmail_from", $mail_from);
ini_set("sendmail_path", $mail_path);

if(mail($mail_to,$mail_subject, "IP: ".$_SERVER["REMOTE_ADDR"]."\nUA: ".$_SERVER["HTTP_USER_AGENT"] . "\nWho:" . $who, "From: $_POST[email]\r\n". "Reply-To: $_POST[email]\r\n"))
{
echo "haha, got ya!";
}
exit;
?>

Url is then www.mysite.com/certainpage.htm?who=1
You can change the name of the parameter who to whatever you like.

>Either way, you're the best

Never. But would you please tell this my woman, my mother and my brother pleeeeease. :)

>Okay, one last question

No problem at all with further questions but gimme a break for a bath. :)

celerityfm

8:17 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



Nice code there Yidaki :)

In addition to an email alert there is another fun little service called Instant Gratification that send an instant message to you over AIM telling you when someone accesses a webpage.

unpossible.com/blogtraffic.html will fix you up :). Its very easy to setup as they've got an HTML code snippet generator that you use to build a snippet that you just cut and paste into your webpage to activate the service.

Its very advanced too as you can even have users cookify themselves so that you can identify the user by email address and name and not just ip address. But it should show you the entire URL including the query as well.

[edited by: jatar_k at 8:57 pm (utc) on Nov. 20, 2003]
[edit reason] delinked [/edit]