As you guys may have noticed my signature now or in the past has the ability to know figure out your SEN name and incorporate into my the image. Ever wondered how I did it? I created this thread as a tutorial I will write over the next fews days explaining how exactly it is done and all the code that goes into it.
First you must know the different elements that are required to pull this off. You need a webserver with PHP 4+ and a mySQL database at your disposal.
A brief description of how the signature works-- When you visit a webpage on SEN your browser first downloads the html which discribes how the page is to be rendered, then for the images your browser contacts all the urls which each image links to. When your browser requests my signature it executes a script on my server which first takes down the page that is requesting my image and also the IP address that is requesting it. Following that, the script actually reads the html of the page links to it-- usually a thread and you'll notice at the bottom of each thread it lists the users that are currently viewing it. The script then takes those names from the thread (may be more than one) and with your IP address it adds it to the my sql database.
After a while the database will have recorded quite a few entries down listing your username with your coresponding IP address. Using the database, tallying up the most hits of a certain IP with each name, the name with the most hits of a certain ip address is quite obviously the ip address that is associated with that name. Using this information and the script takes your IP address and looks up the name that is associated with it.
Finally the script then takes a pre-made image I created and adds text via the GD2 functions. Then once the text is added with your name and all, renders the image and returns to your browser.
-------
In followings days I will begin writing how to setup apache so that it will parse .jpg as php scripts. Then following that, the basics on GD2 functions which are the functions that are built into PHP that allow you to open and modify image files. Finally, about the mySQL backbone of the script.
CODE
<?
// ---------------------------------- //
// Coded by synd][cate aka sammysnake //
// ---------------------------------- //
function array_key($arr, $pos) {
if (!empty($arr)) {
if ($pos===null)
$pos = 0;
$all_keys = array_keys($arr);
$all_values = array_values($arr);
$key = $all_keys[$pos];
if (isset($key))
return $key;
else {
return null;
}
}
}
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("sen");
header("Content-type: image/jpg");
$im = imagecreatefromjpeg("syndsig_small1.jpg");
$color = imagecolorallocate($im, 255, 255, 255);
$referrer = $_SERVER['HTTP_REFERER'];
$refdoc = file($referrer);
$pattern = '/Members:(.+?)<\/div>/';
foreach ($refdoc as $line_num => $line) {
if (preg_match($pattern, $line, $matches, PREG_OFFSET_CAPTURE, 3)) {
$cleanstr = $matches[0][0];
$patterns[0] = '/<.+?>/';
$patterns[1] = '/Members:/';
$patterns[2] = '/, /';
$replacements[0] = '';
$replacements[1] = '';
$replacements[2] = ',';
$users = preg_replace($patterns, $replacements, $cleanstr);
$users = trim($users);
}
}
$ip_addr = $_SERVER["REMOTE_ADDR"];
if ($users != "") {
if (strstr($users, ",")) {
// Do not add multiple users with same ip to the database
} else {
// Single Username
$query = "INSERT INTO referrers (id, username, ip_addr, referrer ) VALUES ('', '$users', '$ip_addr', '$referrer');";
mysql_query($query);
}
}
$member_ip = mysql_query('SELECT * FROM referrers') or die(mysql_error());
while($row = mysql_fetch_array($member_ip, MYSQL_ASSOC)) {
$ip = $row['ip_addr'];
$username = $row['username'];
$sum_ips{$username}{$ip}++;
}
$once = true;
// Check top 5 IP entries for a certain username
for ($i=0; (($i<5) && ($once == true)); $i++) {
foreach ($sum_ips as $key => $top_ips) {
arsort($top_ips);
if ((array_key($top_ips, $i) == $ip_addr) && ( $key != "nil" )) {
// ip address with top hits
if ($once == true) {
$text_str = "hey $key, you're such a cool person that I put your name on my sig.";
imagestring($im, 2, 5, 86, $text_str, $color);
$once = false;
}
}
}
}
if ($once == true) {
// No username found, display generic message
imagestring($im, 2, 5, 86, "Hey unknown user, I'm watching you! ($ip_addr)", $color);
}
// Display Image
imagejpeg($im, "", 75);
imagedestroy($im);
?>
.. here is a print_r of $sum_ips
CODE
Array
(
[synd][cate] => Array
(
[24.71.223.---] => 38
[142.110.227.---] => 53
[142.110.227.---] => 13
[142.110.227.---] => 1
[127.0.0.---] => 1
[68.94.196.---] => 3
[142.110.227.---] => 6
[147.10.152.---] => 2
[68.9.135.---] => 1
[198.53.49.---] => 1
[216.142.39.---] => 2
[64.233.172.---] => 20
[192.168.0.---] => 1
[70.72.227.---] => 14
)
[devilesk] => Array
(
[68.197.146.---] => 4
)
[n2o-PiMpSoNs] => Array
(
[66.30.166.---] => 27
[69.250.117.---] => 3
)
[Dr.Shotgun] => Array
(
[172.167.152.---] => 1
[172.155.127.---] => 1
[172.152.249.---] => 2
[172.209.108.---] => 1
[172.165.18.---] => 2
[172.169.202.---] => 2
[172.170.121.---] => 2
[172.143.30.---] => 1
[172.153.66.---] => 1
[172.132.101.---] => 2
[172.128.179.---] => 1
[172.155.87.---] => 1
[172.132.4.---] => 1
[172.156.64.---] => 1
[172.150.120.---] => 6
[172.136.83.---] => 2
[172.168.73.---] => 1
)
[Kao-kenshin] => Array
(
[66.234.213.---] => 1
)
[SpaceBoy2000] => Array
(
[69.158.11.---] => 1
[69.158.21.---] => 1
[69.158.15.---] => 1
[68.98.141.---] => 1
[69.158.8.---] => 2
)
[KaboomHahahein] => Array
(
[209.161.192.---] => 1
[69.199.251.---] => 19
[192.168.0.---] => 2
)
[Rivalry] => Array
(
[172.155.13.---] => 2
[206.77.0.---] => 5
[24.71.223.---] => 1
[172.134.114.---] => 1
[66.143.179.---] => 2
[63.246.185.---] => 1
)
[lonely_duck] => Array
(
[68.6.144.---] => 22
)
[RexyRex] => Array
(
[67.150.41.---] => 1
[64.136.26.---] => 1
[4.232.102.---] => 2
)
[mr.ex] => Array
(
[67.188.122.---] => 20
)
[Jet_Blast54] => Array
(
[66.215.243.---] => 6
[68.190.247.---] => 11
[66.215.164.---] => 1
)
[«–Yoshi da Sniper–»] => Array
(
[65.48.108.---] => 13
[64.233.173.---] => 3
[72.14.194.---] => 2
)
[Atreyu)] => Array
(
[68.35.159.---] => 28
[68.3.81.---] => 1
[192.168.0.---] => 1
)
[Zombie] => Array
(
[69.92.189.---] => 23
)
[pimpinelephant] => Array
(
[71.112.21.---] => 1
[71.102.98.---] => 2
[71.112.92.---] => 1
[71.112.30.---] => 1
[71.102.97.---] => 3
[71.112.100.---] => 1
[71.112.83.---] => 2
)
[DT_Battlekruser] => Array
(
[67.188.160.---] => 51
)
[IceWarrior98] => Array
(
[64.231.13.---] => 1
[67.71.141.---] => 1
[70.50.54.---] => 2
[67.71.142.---] => 2
)
[saibaman8] => Array
(
[65.120.80.---] => 1
)
[AqoTrooper] => Array
(
[80.230.246.---] => 1
)
[Ultimo] => Array
(
[68.148.187.---] => 27
[24.70.95.---] => 2
[199.185.85.---] => 5
[64.233.172.---] => 2
)
[AOB)Snipe)r(] => Array
(
[68.3.12.---] => 4
)
[Kusion] => Array
(
[68.9.135.---] => 11
)
[Kellimus] => Array
(
[216.142.39.---] => 42
[68.3.81.---] => 25
[24.71.223.---] => 2
[217.44.217.---] => 1
[198.53.49.---] => 1
[24.90.245.---] => 1
)
[@:@] => Array
(
[198.108.21.---] => 1
)
[Busion] => Array
(
[139.168.141.---] => 9
[68.9.135.---] => 1
[60.229.170.---] => 5
)
[Gradius] => Array
(
[72.49.76.---] => 5
[72.49.42.---] => 1
[69.61.145.---] => 1
[72.49.32.---] => 9
[72.49.39.---] => 4
[172.164.24.---] => 1
[172.142.178.---] => 1
)
[XxXFaNtA] => Array
(
[87.122.27.---] => 3
[87.122.0.---] => 1
[87.122.49.---] => 1
[87.122.52.---] => 1
)
[Voyager7456(MM)] => Array
(
[24.184.160.---] => 57
[192.168.0.---] => 1
)
[Goran] => Array
(
[69.250.117.---] => 1
)
[MiLlEnNiUmArMy] => Array
(
[66.69.209.---] => 86
[192.168.0.---] => 1
)
[SiLeNT(U)] => Array
(
[64.231.8.---] => 4
[67.68.35.---] => 5
[64.231.8.---] => 2
[65.92.124.---] => 4
[172.194.179.---] => 1
[192.168.0.---] => 1
[65.92.190.---] => 1
[64.231.201.---] => 5
[24.157.32.---] => 1
)
[ViolentJ] => Array
(
[68.233.54.---] => 20
)
[O)FaRTy1billion] => Array
(
[67.172.227.---] => 2
)
[00cnr] => Array
(
[65.92.22.---] => 1
)
[pekkel_the_duck] => Array
(
[68.122.116.---] => 1
[68.122.73.---] => 2
[68.122.195.---] => 2
[68.122.70.---] => 6
)
[UBCS] => Array
(
[67.128.168.---] => 1
)
[deekay] => Array
(
[66.167.54.---] => 1
)
[Syphon] => Array
(
[24.57.53.---] => 46
)
[SuperToast] => Array
(
[66.41.57.---] => 1
)
[Psi] => Array
(
[69.250.117.---] => 1
)
[LegacyWeapon] => Array
(
[70.179.77.---] => 31
[68.121.145.---] => 1
)
[vegeta] => Array
(
[69.223.2.---] => 1
)
[illusion(SS)] => Array
(
[24.160.230.---] => 2
[216.56.88.---] => 4
[68.94.196.---] => 1
)
[Doodan] => Array
(
[68.12.20.---] => 26
)
[Screwed] => Array
(
[203.173.147.---] => 1
[203.173.154.---] => 1
[220.131.32.---] => 7
)
[Steveman01] => Array
(
[84.57.66.---] => 1
)
[DameDaSnipa.] => Array
(
[68.34.133.---] => 9
)
[Slyence] => Array
(
[66.160.54.---] => 15
[64.12.117.---] => 1
)
[Oo.ZeALoT.oO] => Array
(
[65.92.22.---] => 9
[192.168.0.---] => 1
)
[PCFredZ] => Array
(
[70.16.54.---] => 2
[70.16.61.---] => 1
[129.44.216.---] => 2
[71.240.242.---] => 1
[71.240.250.---] => 2
[68.238.82.---] => 2
[70.16.50.---] => 3
[71.240.251.---] => 1
[71.240.242.---] => 3
[129.44.209.---] => 2
[71.240.245.---] => 1
[129.44.214.---] => 1
)
[LethaL] => Array
(
[69.65.95.---] => 1
)
[Temp] => Array
(
[24.157.88.---] => 6
)
[Felagund] => Array
(
[68.54.178.---] => 9
[192.168.0.---] => 1
)
[chuOS] => Array
(
[68.226.60.---] => 24
[204.26.108.---] => 1
[144.138.84.---] => 1
)
[The Blood Angel] => Array
(
[24.174.118.---] => 1
)
[Imperial] => Array
(
[24.239.177.---] => 3
)
[Shmeeps] => Array
(
[68.94.1.---] => 1
[68.94.12.---] => 1
[68.94.39.---] => 6
[68.94.22.---] => 4
[68.94.29.---] => 1
[68.94.22.---] => 1
[68.94.4.---] => 2
[68.94.17.---] => 1
[68.94.24.---] => 2
[68.94.35.---] => 2
[68.94.53.---] => 3
)
[QuailMan867] => Array
(
[169.139.176.---] => 1
)
[Merrell] => Array
(
[68.126.148.---] => 1
[198.77.43.---] => 2
[12.163.88.---] => 1
[12.163.88.---] => 1
[12.163.89.---] => 2
[198.79.115.---] => 1
[198.79.115.---] => 3
[85.165.212.---] => 1
[198.79.115.---] => 1
[12.163.88.---] => 2
[68.40.183.---] => 1
[12.163.88.---] => 4
[12.163.88.---] => 5
[12.163.88.---] => 1
[198.77.43.---] => 1
[198.79.115.---] => 4
[12.163.89.---] => 1
[198.79.115.---] => 1
[12.163.88.---] => 1
[192.168.0.---] => 2
[198.79.115.---] => 2
[12.163.90.---] => 1
[198.77.44.---] => 4
[68.58.122.---] => 1
[12.163.88.---] => 1
[198.79.115.---] => 3
)
[T-MaStAA] => Array
(
[70.81.81.---] => 3
[205.236.31.---] => 1
[70.81.83.---] => 1
[70.81.84.---] => 2
)
[AsainInvaSION] => Array
(
[71.109.2.---] => 1
)
[IDontChat] => Array
(
[71.108.241.---] => 3
[71.108.160.---] => 5
[71.108.241.---] => 1
)
[Kame da Sniper] => Array
(
[67.177.244.---] => 11
)
[(U)Bolt_Head] => Array
(
[12.215.234.---] => 8
[153.91.178.---] => 12
[172.199.149.---] => 1
)
[x BakaPeter x] => Array
(
[66.27.21.---] => 11
)
[Forsaken] => Array
(
[63.192.124.---] => 1
[63.192.124.---] => 1
[63.192.124.---] => 2
)
[warhammer40000] => Array
(
[68.197.6.---] => 34
[24.157.32.---] => 1
)
[a-Friend] => Array
(
[82.34.153.---] => 18
)
[JohnnyHazardous] => Array
(
[66.27.21.---] => 3
)
[Fierce] => Array
(
[65.188.137.---] => 6
)
[yeow] => Array
(
[66.169.181.---] => 18
[199.185.85.---] => 1
)
[Shatter] => Array
(
[12.202.71.---] => 34
)
[Wilhelm] => Array
(
[69.244.100.---] => 26
)
[Mini Moose 2707] => Array
(
[24.90.245.---] => 14
[192.168.0.---] => 1
)
[Rantent] => Array
(
[209.112.137.---] => 1
[12.12.205.---] => 2
[209.193.57.---] => 3
[66.230.86.---] => 2
[66.230.85.---] => 2
[66.230.112.---] => 4
[12.12.205.---] => 2
)
[Toothfariy] => Array
(
[68.188.37.---] => 9
)
[No_Authority] => Array
(
[69.47.83.---] => 19
[192.168.0.---] => 1
)
[XxPacmaynExX] => Array
(
[69.138.215.---] => 34
)
[iamacow] => Array
(
[69.244.147.---] => 2
)
[SacredElf] => Array
(
[200.120.57.---] => 6
[200.120.57.---] => 9
)
[Hitok1r1] => Array
(
[68.5.50.---] => 6
)
[PsychoTemplar] => Array
(
[24.157.32.---] => 5
[67.64.204.---] => 1
)
[Ninebreaker] => Array
(
[70.70.91.---] => 3
)
[MindArchon] => Array
(
[68.149.119.---] => 9
[68.150.133.---] => 1
)
[Zycorax] => Array
(
[159.81.252.---] => 5
)
[Wing-of-no-Wing] => Array
(
[149.43.252.---] => 34
[149.43.164.---] => 1
[149.43.226.---] => 12
[192.168.0.---] => 1
)
[Kumano] => Array
(
[70.27.6.---] => 11
)
[Buletbutter] => Array
(
[68.107.164.---] => 2
[69.92.159.---] => 1
)
[Fronter] => Array
(
[69.128.205.---] => 1
)
[devilesk-A-dur] => Array
(
[68.197.146.---] => 63
[64.228.72.---] => 1
[68.3.81.---] => 1
[68.94.196.---] => 1
[69.115.187.---] => 3
[24.218.243.---] => 1
[65.48.108.---] => 1
)
[ThunderChaos] => Array
(
[24.83.101.---] => 13
[24.85.161.---] => 3
)
[lazyjoe21] => Array
(
[63.198.190.---] => 1
)
[Lt.Fatso] => Array
(
[70.68.239.---] => 1
)
[humancyborg] => Array
(
[24.22.158.---] => 1
)
[m.r.bob] => Array
(
[24.199.93.---] => 1
)
[CaptainWill] => Array
(
[217.44.217.---] => 2
[217.44.217.---] => 5
[86.140.24.---] => 4
[86.140.26.---] => 2
)
[CheeZe] => Array
(
[66.143.33.---] => 54
[4.238.182.---] => 1
)
[Elvang] => Array
(
[68.3.102.---] => 1
)
[yami(ug)] => Array
(
[69.19.170.---] => 1
)
[Toa5555] => Array
(
[68.101.199.---] => 30
[70.109.133.---] => 1
[211.29.5.---] => 1
[4.228.69.---] => 1
)
[Demaris] => Array
(
[207.224.10.---] => 7
[63.227.143.---] => 1
)
[FatalException] => Array
(
[24.16.151.---] => 3
[192.168.0.---] => 1
)
[rustyknife5] => Array
(
[68.205.158.---] => 1
)
[marxel] => Array
(
[210.1.89.---] => 4
[210.213.77.---] => 1
)
[munney] => Array
(
[220.235.2.---] => 1
)
[Clokr_] => Array
(
[80.58.38.---] => 29
[24.36.77.---] => 1
)
[D)s-202] => Array
(
[24.193.110.---] => 3
)
[BurnedVulcan] => Array
(
[24.195.213.---] => 1
)
[BSTRhino] => Array
(
[138.75.55.---] => 1
[203.173.165.---] => 1
)
[durk-A-dur] => Array
(
[12.42.155.---] => 15
[24.5.248.---] => 1
[65.48.108.---] => 1
)
[Sniper] => Array
(
[24.85.141.---] => 4
[65.48.108.---] => 1
[64.233.172.---] => 2
)
[Kow] => Array
(
[69.250.117.---] => 25
[172.148.143.---] => 1
)
[Razerr789] => Array
(
[71.247.71.---] => 2
[71.247.90.---] => 1
[71.247.31.---] => 1
)
[Shapechanger] => Array
(
[68.42.37.---] => 9
)
[SC_Bonus] => Array
(
[24.86.136.---] => 2
)
[DEAD] => Array
(
[84.237.157.---] => 2
[84.237.162.---] => 2
[84.237.157.---] => 7
[84.237.145.---] => 1
[84.237.155.---] => 2
)
[SI] => Array
(
[84.61.0.---] => 2
[84.61.15.---] => 2
)
[Xenomaniac] => Array
(
[68.98.141.---] => 19
)
[Silver-Dragon] => Array
(
[24.193.110.---] => 10
[24.90.143.---] => 8
[68.94.196.---] => 1
)
[Tmac020304] => Array
(
[70.23.232.---] => 1
[70.23.236.---] => 3
[70.23.120.---] => 1
)
[TheOddAngel] => Array
(
[70.50.210.---] => 1
)
[greenreaper] => Array
(
[71.133.230.---] => 1
[69.233.39.---] => 1
[69.233.36.---] => 1
)
[Derek-Pfister-Mr.P] => Array
(
[64.12.117.---] => 1
)
[Valug] => Array
(
[65.30.110.---] => 5
)
[micro119] => Array
(
[142.59.178.---] => 6
)
[CrazyNinja00] => Array
(
[69.236.136.---] => 2
)
[Teck] => Array
(
[63.24.115.---] => 1
)
[Quabarrick] => Array
(
[216.45.229.---] => 4
)
[OmegaX-] => Array
(
[24.85.143.---] => 2
)
[Devilesk] => Array
(
[12.42.155.---] => 1
[68.3.81.---] => 1
)
[-Hell-] => Array
(
[66.25.182.---] => 1
)
[BeeR_KeG] => Array
(
[64.237.136.---] => 1
[65.23.206.---] => 4
[64.237.133.---] => 1
)
[ThE_tHiNg] => Array
(
[210.49.26.---] => 6
)
[Kept_Wheat] => Array
(
[172.192.70.---] => 1
)
[WoodenFire] => Array
(
[209.102.237.---] => 1
)
[Mp)PeazeL] => Array
(
[144.138.85.---] => 2
[144.138.83.---] => 2
[192.168.0.---] => 1
[172.197.81.---] => 1
[144.138.83.---] => 2
[144.138.85.---] => 1
)
[shadowsniper660] => Array
(
[68.21.38.---] => 5
[67.38.5.---] => 1
)
[Mystical] => Array
(
[66.160.54.---] => 8
)
[Ego] => Array
(
[67.65.10.---] => 1
[206.77.0.---] => 11
[172.171.240.---] => 2
[63.246.185.---] => 7
[172.140.25.---] => 2
[67.65.23.---] => 2
[172.159.37.---] => 1
[192.168.0.---] => 2
[172.157.63.---] => 2
)
[M_s4] => Array
(
[24.12.230.---] => 3
)
[Alpha(MC)] => Array
(
[69.139.53.---] => 17
)
[Suicidale] => Array
(
[24.1.144.---] => 1
)
[Raynor] => Array
(
[24.229.238.---] => 1
)
[Oo.Dynasty.oO] => Array
(
[64.8.144.---] => 2
)
[wesmic da pimp] => Array
(
[68.58.122.---] => 15
)
[SinDude] => Array
(
[24.70.95.---] => 2
)
[corbo] => Array
(
[66.201.161.---] => 1
)
[DevliN] => Array
(
[69.234.43.---] => 5
)
[Caboose] => Array
(
[12.207.203.---] => 7
)
[SA_Max71] => Array
(
[24.86.226.---] => 4
[24.86.39.---] => 2
)
[Tearshed] => Array
(
[147.10.152.---] => 6
)
[«–isolatedpurity–»] => Array
(
[65.31.102.---] => 1
)
[ChaoticS] => Array
(
[221.146.137.---] => 2
[220.117.45.---] => 1
[221.146.137.---] => 1
)
[Rhiom] => Array
(
[24.19.26.---] => 15
)
[EzDay281] => Array
(
[68.166.211.---] => 2
[69.3.54.---] => 11
)
[Shadow-Killa_04] => Array
(
[71.37.4.---] => 8
[71.36.41.---] => 2
)
[devilesk-A-durmbass] => Array
(
[68.197.146.---] => 50
[216.142.39.---] => 1
[192.168.0.---] => 2
)
[Subrosian] => Array
(
[68.94.196.---] => 1
)
[Aikanaro] => Array
(
[67.68.225.---] => 4
[192.168.0.---] => 1
[67.68.226.---] => 1
)
[Revelade] => Array
(
[69.224.182.---] => 1
[192.168.0.---] => 1
)
[ArbitraryViolence] => Array
(
[69.255.20.---] => 17
)
[theta] => Array
(
[68.255.239.---] => 1
)
[Neiji] => Array
(
[24.12.159.---] => 4
)
[Cnl.Fatso] => Array
(
[70.68.239.---] => 1
)
[Oo.Vic.oO] => Array
(
[69.182.28.---] => 9
)
[YaeXirillion] => Array
(
[205.242.230.---] => 25
[216.74.219.---] => 1
[216.74.219.---] => 4
)
[guardien] => Array
(
[192.168.0.---] => 1
)
[Dyce] => Array
(
[63.86.36.---] => 1
)
[eom[Dark_Lord]] => Array
(
[24.211.192.---] => 2
)
[slayer766] => Array
(
[68.255.114.---] => 1
[65.42.243.---] => 1
[204.38.95.---] => 1
[65.43.34.---] => 1
)
[ColdFusion] => Array
(
[24.175.125.---] => 1
)
[rivalry] => Array
(
[206.77.0.---] => 1
)
[BroodKiller] => Array
(
[153.19.123.---] => 4
)
[Stryke] => Array
(
[216.159.104.---] => 1
)
[Snake)Ling] => Array
(
[66.31.125.---] => 12
)
[Chronophobia] => Array
(
[85.224.116.---] => 2
)
[Brand-NewDML] => Array
(
[69.174.151.---] => 3
)