From: Andrew DeFaria Date: Fri, 9 Feb 2018 00:01:34 +0000 (-0800) Subject: Added hit counting X-Git-Url: https://defaria.com/gitweb/?a=commitdiff_plain;h=a7665f383d2389d4297dd5e8ce1205d113f26709;p=clearscm.git Added hit counting --- diff --git a/web/Resumes/Andrew/ResumeLong.php b/web/Resumes/Andrew/ResumeLong.php index 580ab68..eeaec35 100644 --- a/web/Resumes/Andrew/ResumeLong.php +++ b/web/Resumes/Andrew/ResumeLong.php @@ -41,6 +41,57 @@ function stoptimer () { '; + $msg .= '

Somebody just visited your resume.

'; + $msg .= "

Here's what I know about them:

"; + + foreach ($_SERVER as $key => $value) { + if (preg_match("/^REMOTE/", $key)) { + $msg .= "$key: $value
"; + + if ($key == 'REMOTE_ADDR') { + exec("whois $value", $output, $result); + + foreach ($output as $line) { + $msg .= "$line
"; + } // foreach + } // if + } // if + } // foreach + + $msg .= ''; + $headers = "MIME-Version: 1.0\r\n"; + $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; + $headers .= "From: Andrew DeFaria "; + + mail("andrew@defaria.com", "Somebody visited your resume", $msg, $headers); ?> diff --git a/web/Resumes/Andrew/ResumeShort.php b/web/Resumes/Andrew/ResumeShort.php index 3278087..e76dc22 100644 --- a/web/Resumes/Andrew/ResumeShort.php +++ b/web/Resumes/Andrew/ResumeShort.php @@ -42,6 +42,32 @@ function stoptimer () { include "clearscm.php"; menu_css (); + // Record hit + $dir = dirname(__FILE__); + + if (file_exists("$dir/.resumehits")) { + $resumeHit = fopen("$dir/.resumehits", 'r'); + + fscanf($resumeHit, "%d\n", $count); + } else { + $count = 0; + } // if + + $count++; + + fclose($resumeHit); + + $resumeHit = fopen ('.resumehits', 'w'); + + fwrite($resumeHit, $count); + fclose($resumeHit); + + $resumeHist = fopen('.resume.hist', 'a'); + $date = date(DATE_RFC822); + + fwrite($resumeHist, "$_SERVER[REMOTE_ADDR] read resume at $date\n"); + fclose($resumeHist); + $msg = ''; $msg .= '

Somebody just visited your resume.

'; $msg .= "

Here's what I know about them:

";