Просмотр файла anti_nikotin/nikotine_img.php

Размер файла: 1.75Kb
<?php
function plural($value,$names)
	{
	if($value == 11){return $names[2];}
	$temp = strval($value);
	$temp = $temp[strlen($temp) - 1];
	return(($temp>1 AND $temp<5 AND (intval($value)>19 OR intval($value)<10)) ? $names[1] : ($temp==1 ? $names[0] : $names[2]));
	}
$t = abs(intval($_GET['t']));
$y = abs(intval($_GET['y']));
$m = abs(intval($_GET['m']));
$d = abs(intval($_GET['d']));
$s = abs(intval($_GET['s']));
$r = abs(intval($_GET['r']));
if($t == 1) {$t1 = ' Не курю '; $t2 = ' Не выкурено '; $t3 = ' Сэкономлено ';}
else 							{$t1 = ' Курю '; 			$t2 = ' Выкурено '; 			$t3 = ' Потрачено ';}
$time = intval((time() - mktime(0, 0, 0, $m, $d, $y)) / 86400);
if($time >= 365)
	{
	$day = round($time % 365);
	$year = ceil($time / 365);
	$t1 .= $year.' '.plural($year, array('год','года','лет')).' ';
	if($day != 0) {$t1 .= $day.' дн.';}
	} else {$t1 .= $time.' дн.';}
header("Content-type: image/gif");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
$im = imagecreate (128, 35);
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0, 0, 0);
$border_color = imagecolorallocate ($im, 200, 0, 0);
ImageFilledRectangle($im, 0, 0, 128, 35, $border_color);
ImageFilledRectangle($im, 1, 1, 126, 33, $background_color);
imageTTFText($im, 9, 0, 0, 10, $text_color, "ttf.ttf", $t1);
imageTTFText($im, 9, 0, 0, 21, $text_color, "ttf.ttf", $t2.ceil($time * $s).' сиг.');
imageTTFText($im, 9, 0, 0, 32, $text_color, "ttf.ttf", $t3.ceil($time * $r).' руб.');
imageGIF ($im);
imagedestroy($im);
exit;
?>