counter-met-gd
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
#---------------------------#
#-- counter.php --#
#---------------------------#
session_start();
mysql_connect("localhost", "...", "...");
mysql_select_db("...");
if(!isset($_SESSION['updated'])) {
$sql = "UPDATE `counter` SET `hits` = (hits + 1)";
$res = mysql_query($sql);
if($res == true)
$_SESSION['updated'] = "jup";
}
$sql = "SELECT `hits` FROM `counter`";
$res = mysql_query($sql);
$num = mysql_result($res, 0);
while(strlen($num) < 8 ) {
$num = '0'.$num;
}
echo '<img src="image.php?num='.$num.'" alt="'.$num.' Hits" />';
?>
#---------------------------#
#-- counter.php --#
#---------------------------#
session_start();
mysql_connect("localhost", "...", "...");
mysql_select_db("...");
if(!isset($_SESSION['updated'])) {
$sql = "UPDATE `counter` SET `hits` = (hits + 1)";
$res = mysql_query($sql);
if($res == true)
$_SESSION['updated'] = "jup";
}
$sql = "SELECT `hits` FROM `counter`";
$res = mysql_query($sql);
$num = mysql_result($res, 0);
while(strlen($num) < 8 ) {
$num = '0'.$num;
}
echo '<img src="image.php?num='.$num.'" alt="'.$num.' Hits" />';
?>
================================
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
#-------------------------#
#-- image.php --#
#-------------------------#
$num = isset($_GET['num']) ? $_GET['num'] : '';
$image = imagecreatefromjpeg("counter.jpg");
$color = imagecolorallocate($image, 80, 100, 120);
imagettftext($image, 12, 0, 10, 40, $color, 'verdana.ttf', $num);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
#-------------------------#
#-- image.php --#
#-------------------------#
$num = isset($_GET['num']) ? $_GET['num'] : '';
$image = imagecreatefromjpeg("counter.jpg");
$color = imagecolorallocate($image, 80, 100, 120);
imagettftext($image, 12, 0, 10, 40, $color, 'verdana.ttf', $num);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
================================
SQL:
CREATE TABLE `counter` (
`hits` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`hits`)
) TYPE=MyISAM;
INSERT INTO `counter` VALUES (0);