//Author: Jozef Nagy //Website: www.jozefnagy.com //Date: 4/11/2008 //Purpose: Send a text message to a mobile phone containing visitor statistics for a Drupal run website. //Daily SMS Reports for jozefnagy.com require_once('DB.php'); //PEAR DB $to = "6175551234@vtext.com"; $subject = "Daily Website Report"; $msg; $sql; $result; //DB Info $user = ""; $pass = ""; $host = ""; $database = ""; $dbtype = "mysql"; $dsn = "$dbtype://$user:$pass@$host/$database"; $db = DB::connect($dsn); if(DB::isError($db)){ mail($to, $subject, "DB Connect Error"); return 1; } //Report 1: unique IPs $sql = "select count(distinct hostname) as total from accesslog where left(FROM_UNIXTIME(timestamp), 10) = subdate(curdate(), interval 1 day) and hostname <> '192.168%'"; $result = $db->getOne($sql); //return scalar value if(DB::isError($result)) $result = "ERROR"; if($result == null) $result = "ERROR"; $msg = "Yesterday's Unique IPs = $result"; mail($to, $subject, $msg);