- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
<?php
ob_start();
$dblocation="localhost";
$dbuser="root";
$dbpasswd="qjgndfqe";
$dbname="lab3";
$dbcnx=mysql_connect($dblocation, $dbuser, $dbpasswd);
if(!$dbcnx)
{
echo("Не удалось подключиться к базе данных");
exit();
}
$dbq=mysql_query("select version();");
//echo(mysql_result($dbq,0));
$db_select=mysql_select_db($dbname);
if(!$db_select)
{
echo("cant select table");
exit();
}
$str=strtolower(trim($_SERVER['HTTP_USER_AGENT']));
//echo("\n");
if (strstr($str, 'firefox'))
{
mysql_query("UPDATE counter SET cnt1=cnt1+1");
}
if (strstr($str, 'opera'))
{
mysql_query("UPDATE counter SET cnt2=cnt2+1");
}
if (strstr($str, 'chrome'))
{
mysql_query("UPDATE counter SET cnt3=cnt3+1");
}
$sqltable = mysql_query("SELECT cnt1, cnt2, cnt3 FROM counter");
$row = mysql_fetch_array($sqltable);
$cnt1 = " | "."Firefox ".$row['cnt1']." | ";
$cnt2 = "Opera ".$row['cnt2']." | ";
$cnt3 = "Chrome ".$row['cnt3']." | ";
header("Content-type: image/png");
$im = @imagecreatetruecolor(350, 30)
or die('Cannot Initialize new GD image stream');
$color1=imagecolorallocate($im,0,0,255);
$color2=imagecolorallocate($im,233,14,91);
$color3=imagecolorallocate($im,0,10,0);
$bgcolor=imagecolorallocate($im,192,155,120);
imagefilledrectangle($im, 0,0,349,29, $bgcolor);
imagestring($im,50,0,5,"$cnt1",$color1);
imagestring($im,50,150,5,"$cnt2",$color2);
imagestring($im,50,250,5,"$cnt3",$color3);
imagepng($im);
imagedestroy($im);
?>