-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimg.php
More file actions
150 lines (124 loc) · 4.37 KB
/
img.php
File metadata and controls
150 lines (124 loc) · 4.37 KB
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?
ini_set('error_reporting', E_ALL);
if (isset($_GET['id'])) {
$_GET['id'] = (int)($_GET['id']);
} else {
die();
}
require("config.php");
$hosts = './visits/oldbk' . $_GET['id'] . '.cnt';
function getip()
{
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
return $_SERVER["REMOTE_ADDR"];
}
function dohits()
{
global $a, $b, $c, $date, $daytoday;
mysql_query($a) or die("Îøèáêà ïîäêëþ÷åíèÿ");
mysql_query($b) or die("Îøèáêà ïîäêëþ÷åíèÿ");
if ($date != "$daytoday") {
mysql_query($c) or die("Îøèáêà ïîäêëþ÷åíèÿ");
}
}
//áàçà õîñòîâ íà ñóòêè
function testhost($ip)
{
global $hosts;
if (!file_exists($hosts)) {
$f = fopen($hosts, "w");
fwrite($f, date("d/m/Y H:i:s") . ":[" . $ip . "]:" . $_SERVER["HTTP_REFERER"] . ":\r\n");
fclose($f);
return 1;
} else {
$f = fopen($hosts, "r");
$buf = fread($f, filesize($hosts));
fclose($f);
if (!strpos($buf, "[" . $ip . "]")) {
$f = fopen($hosts, "a");
if (flock($f, LOCK_EX)) {
fwrite($f, date("d/m/Y H:i:s") . ":[" . $ip . "]:" . $_SERVER["HTTP_REFERER"] . ":\r\n");
flock($f, LOCK_UN);
}
fclose($f);
return 1;
} else {
return 0;
}
}
}
$date = date("dmY");
//$date="32052010";
$query = mysql_query("SELECT * FROM $table WHERE memberid = '" . intval($_GET["id"]) . "' LIMIT 1") or die ("Îøèáêà ïîäêëþ÷åíèÿ.1");
$object = mysql_fetch_object($query);
if ($object && $object->memberid) {
$rank = $object->rank;
$today = $object->hitstoday;
$today = explode(" | ", $today);
$datetoday = $today[0];
if (isset($today[1])) {
$hitstoday = $today[1];
} else {
$hitstoday = 0;
}
$days = $object->date;
$days = explode(" | ", $days);
$daytoday = $days[0];
$hoststoday = $object->hoststoday;
$allhosts = $object->allhosts;
if (!isset($_SERVER["HTTP_REFERER"])) $_SERVER["HTTP_REFERER"] = "";
$ref = $_SERVER["HTTP_REFERER"];
if (strpos($ref, $object->url) !== FALSE) {
//next check
$ip = getip();
/////////////////
// Àíòè íàêðóòêà ïðîâåðêà èï ïî áàçå ïåðñîâ çàõîäîâ
mysql_select_db("oldbk");
$check = mysql_fetch_array(mysql_query("SELECT * from iplog where `ip` = '" . $ip . "' LIMIT 1; "));
mysql_select_db("topsites");
///////////////////////////////////////////
if ($check['id'] > 0) {
$addhost = (int)(testhost($ip));
$hoststoday = $hoststoday + $addhost;
$suba = ", hoststoday=hoststoday +" . $addhost . ", allhosts=allhosts +" . $addhost . " ";
$a = "UPDATE $table SET hitsin = hitsin + 1, hitstotal = hitstotal + 1 " . $suba . " WHERE memberid = '" . $_GET["id"] . "'";
if ($date != $datetoday) {
$b = "UPDATE $table SET hitstoday = '$date | 1' , hoststoday=1 , hitsin = 1 WHERE memberid = '" . $_GET["id"] . "'";
$hitstoday = 1;
$hoststoday = 1;
//and make clear hostlist and add last ip
$f = fopen($hosts, 'w');
if (flock($f, LOCK_EX)) {
fwrite($f, date("d/m/Y H:i:s") . ":[" . $ip . "]:" . $_SERVER["HTTP_REFERER"] . ":\r\n");
flock($f, LOCK_UN);
}
fclose($f);
} else {
$hitsplus = $today[1] + 1;
$b = "UPDATE $table SET hitstoday = '$date | $hitsplus' WHERE memberid = '" . $_GET["id"] . "'";
}
if ($date != "$daytoday") {
$dayplus = $days[1] + 1;
$c = "UPDATE $table SET date = '$date | $dayplus' WHERE memberid = '" . $_GET["id"] . "'";
}
dohits();
}
}
// Âûâîäèì êîëè÷åñòâî ïðîñìîòðîâ.
// Ïîäëîæêà äëÿ ñ÷åò÷èêà
$im = ImageCreateFromPNG("b/counter.png");
// Öâåò òåêñòà
$black = imagecolorallocate($im, 0, 0, 0);
// Îòðèñîâêà òåêñòà
imagestring($im, 1, 29, 19, $hitstoday, $black);
imagestring($im, 1, 69, 19, $hoststoday, $black);
Header("Content-type: image/jpeg");
//Âûâîä èçîáðàæåíèÿ
ImageJpeg($im);
//Ðàçðóøàåì èçîáðàæåíèå, ÷òîáû íå çàñîðÿëàñü ïàìÿòü
imagedestroy($im);
} else {
die ("Îøèáêà ID." . $_GET["id"]);
}