-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc98bar.php
executable file
·129 lines (123 loc) · 4.4 KB
/
cc98bar.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
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
<?php
require "include/bittorrent.php";
dbconn();
$pattern = "/.*cc98bar\.php\/(nn([0,1]{1}))?(nr([0-9]+))?(ng([0-9]+))?(nb([0-9]+))?(ns([1-5]{1}))?(nx([0-9]+))?(ny([0-9]+))?(nu([0,1]{1}))?(ur([0-9]+))?(ug([0-9]+))?(ub([0-9]+))?(us([1-5]{1}))?(ux([0-9]+))?(uy([0-9]+))?(nd([0,1]{1}))?(dr([0-9]+))?(dg([0-9]+))?(db([0-9]+))?(ds([1-5]{1}))?(dx([0-9]+))?(dy([0-9]+))?(bg([0-9]+))?id([0-9]+)\.png$/i";
if (!preg_match($pattern, $_SERVER['REQUEST_URI'])){
echo "Error! Invalid URL format.";
die;
}
if (!$my_img = $Cache->get_value('userbar_'.$_SERVER['REQUEST_URI'])){
$nn = preg_replace($pattern, "\\2", $_SERVER['REQUEST_URI']);
$nr = preg_replace($pattern, "\\4", $_SERVER['REQUEST_URI']);
$ng = preg_replace($pattern, "\\6", $_SERVER['REQUEST_URI']);
$nb = preg_replace($pattern, "\\8", $_SERVER['REQUEST_URI']);
$ns = preg_replace($pattern, "\\10", $_SERVER['REQUEST_URI']);
$nx = preg_replace($pattern, "\\12", $_SERVER['REQUEST_URI']);
$ny = preg_replace($pattern, "\\14", $_SERVER['REQUEST_URI']);
$nu = preg_replace($pattern, "\\16", $_SERVER['REQUEST_URI']);
$ur = preg_replace($pattern, "\\18", $_SERVER['REQUEST_URI']);
$ug = preg_replace($pattern, "\\20", $_SERVER['REQUEST_URI']);
$ub = preg_replace($pattern, "\\22", $_SERVER['REQUEST_URI']);
$us = preg_replace($pattern, "\\24", $_SERVER['REQUEST_URI']);
$ux = preg_replace($pattern, "\\26", $_SERVER['REQUEST_URI']);
$uy = preg_replace($pattern, "\\28", $_SERVER['REQUEST_URI']);
$nd = preg_replace($pattern, "\\30", $_SERVER['REQUEST_URI']);
$dr = preg_replace($pattern, "\\32", $_SERVER['REQUEST_URI']);
$dg = preg_replace($pattern, "\\34", $_SERVER['REQUEST_URI']);
$db = preg_replace($pattern, "\\36", $_SERVER['REQUEST_URI']);
$ds = preg_replace($pattern, "\\38", $_SERVER['REQUEST_URI']);
$dx = preg_replace($pattern, "\\40", $_SERVER['REQUEST_URI']);
$dy = preg_replace($pattern, "\\42", $_SERVER['REQUEST_URI']);
$bg = 0 + preg_replace($pattern, "\\44", $_SERVER['REQUEST_URI']);
$id = preg_replace($pattern, "\\45", $_SERVER['REQUEST_URI']);
$res = sql_query("SELECT username, uploaded, downloaded, class, privacy FROM users WHERE id=".sqlesc($id)." LIMIT 1");
$row = mysql_fetch_array($res);
if (!$row)
die;
elseif($row['privacy'] == 'strong')
die;
elseif($row['class'] < $userbar_class)
die;
else{
$username = $row['username'];
$uploaded = mksize($row['uploaded']);
$downloaded = mksize($row['downloaded']);
}
$my_img=imagecreatefrompng("pic/userbar/".$bg.".png");
imagealphablending($my_img, false);
if (!$nn)
{
if ($nr != "" && $nr >=0 && $nr <=255)
$namered = $nr;
else $namered=255;
if ($ng != "" && $ng >=0 && $ng <=255)
$namegreen = $ng;
else $namegreen=255;
if ($nb != "" && $nb >=0 && $nb <=255)
$nameblue = $nb;
else $nameblue=255;
if ($ns != "" && $ns >=1 && $ns <=5)
$namesize = $ns;
else $namesize=3;
if ($nx != "" && $nx >=0 && $nx <=350)
$namex = $nx;
else $namex=10;
if ($ny != "" && $ny >=0 && $ny <=19)
$namey = $ny;
else $namey=3;
$name_colour = imagecolorallocate($my_img, $namered, $namegreen, $nameblue);
imagestring($my_img, $namesize, $namex, $namey, $username, $name_colour);
}
if (!$nu)
{
if ($ur != "" && $ur >=0 && $ur <=255)
$upred = $ur;
else $upred=0;
if ($ug != "" && $ug >=0 && $ug <=255)
$upgreen = $ug;
else $upgreen=255;
if ($ub != "" && $ub >=0 && $ub <=255)
$upblue = $ub;
else $upblue=0;
if ($us != "" && $us >=1 && $us <=5)
$upsize = $us;
else $upsize=3;
if ($ux != "" && $ux >=0 && $ux <=350)
$upx = $ux;
else $upx=100;
if ($uy != "" && $uy >=0 && $uy <=19)
$upy = $uy;
else $upy=3;
$up_colour = imagecolorallocate($my_img, $upred, $upgreen, $upblue);
imagestring($my_img, $upsize, $upx, $upy, $uploaded, $up_colour);
}
if (!$nd)
{
if ($dr != "" && $dr >=0 && $dr <=255)
$downred = $dr;
else $downred=255;
if ($dg != "" && $dg >=0 && $dg <=255)
$downgreen = $dg;
else $downgreen=0;
if ($dg != "" && $db >=0 && $db <=255)
$downblue = $db;
else $downblue=0;
if ($ds != "" && $ds >=1 && $ds <=5)
$downsize = $ds;
else $downsize=3;
if ($dx != "" && $dx >=0 && $dx <=350)
$downx = $dx;
else $downx=180;
if ($dy != "" && $dy >=0 && $dy <=19)
$downy = $dy;
else $downy=3;
$down_colour = imagecolorallocate($my_img, $downred, $downgreen, $downblue);
imagestring($my_img, $downsize, $downx, $downy, $downloaded, $down_colour);
}
imagesavealpha($my_img, true);
$Cache->cache_value('userbar_'.$_SERVER['REQUEST_URI'], $my_img, 300);
}
header("Content-type: image/png");
imagepng($my_img);
imagedestroy($my_img);
?>