/***********************************************
* Future Ideas *
* (checked off as implemented) *
* [x] admin panel *
* [x] notify on certain count(s) *
* [ ] user logging *
* [ ] user statistics *
***********************************************/
/***********************************************
* DO NOT EDIT ANYTHING IN THIS FILE UNLESS YOU *
* KNOW FOR SURE WHAT YOU ARE CHANGING. *
***********************************************/
require ("config.php");
$fdata = @file($CONFIG['counter_data']);
$count = $fdata[0];
if ((file_exists($CONFIG['counter_data'])) && ($count == "")) {
die ("View Error: If this problem persists, please reset your counter from the control panel.");
}
$count++;
$fp = fopen($CONFIG['counter_data'], "w");
fputs ($fp, $count);
fclose ($fp);
while (strlen($count) < $CONFIG['count_len']) {
$count = "0" . $count;
}
if ($CONFIG['counter_type'] == 2) {
showtext ($count);
} else {
showimage ($count);
}
$notify_array = explode(",", $CONFIG['notify_count']);
foreach ($notify_array as $subcount) {
if (intval($subcount) != 0) {
if (intval($count) == intval($subcount)) {
notify($subcount);
}
}
}
// Functions start here.
function showimage($count) {
global $CONFIG;
$marker = 0;
while ($marker < strlen($count)) {
$digit = substr($count, $marker, 1);
$theme = $CONFIG['color_theme'];
$width = $CONFIG['digit_width'] + 2;
$height = $CONFIG['digit_height'] + 2;
echo '';
$marker++;
}
}
function showtext($count) {
echo $count;
}
function notify($count) {
global $CONFIG;
$mail_to = $CONFIG['notify_email'];
$mail_subject = "phpMyCounter Notification";
$mail_message = "Your site has reached $count hits.";
$mail_headers = "From: phpMyCounter\r\n";
$mail_headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
$mail_sent = @mail($mail_to, $mail_subject, $mail_message, $mail_headers);
}
?>