Hey everyone, I thought I would stray from the VB for awhile, and teach something new and cool. Its called Script Scrapping, then adding them to GD Imaging. Very simple, and Ill explain.
We are making this, an image that will show how many Thanks I have. If you thank me, you will see the images number changes:
Since this is PHP we need to start off with our brackets.
Now, adding the code inside it. I will give you the full code then explain each part.
Code:
<?php
$url = "https://www.mpgh.net/forum/33-visual-basics/83177-real-vb-injecter-source-code.html";
$data = file_get_contents($url);
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B","/","(", ")",">","<" );
$content = str_replace($newlines, "", html_entity_decode($data));
$html = '/Thanked (.+?) Times/';
preg_match($html,$content,$thanks);
var_dump($thanks);
echo $thanks[1];
//echo "<br>";
//echo $content;
?>
$url = "https://www.mpgh.net/forum/33-visual-basics/83177-real-vb-injecter-source-code.html";
Here we are making the URL that we are getting the source code from, is a thread I made. I chose a thread because the php is visiting the page as a guest, so I cant make it go to my profile.
$data = file_get_contents($url);
Here I am saying "Hey URL, give me your contents, and then name those contents $data".
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B","/","(", ")",">","<" );
I decided to remove afew stuff I didnt need, and to make it easier for me, so I decided to remove all New Lines, as well as /,(,),<,>.
$content = str_replace($newlines, "", html_entity_decode($data));
Here I am telling the $data to replace everything we put earlier in $newlines, with "", meaning it just removes them. Now $data has turned to $content.
$html = '/Thanked (.+?) Times/';
Here I am making $html = to a string that will be found later. It is required you have the /content/ dashes in there. (.+?) stands for what we want. So it would normally be "Thanked 10 Times", I replace the number with (.+?), because the number is what I want to pull.
preg_match($html,$content,$thanks);
Here we are telling it to match (find) $html, with $content, then name it $thanks.
var_dump($thanks);
Var dump isnt much needed, so what you can do after this test, is change it to
Code:
//var_dump($thanks);
But this is good to see if your data is even there, With this code It will output
array(2) { [0]=> string(16) "Thanked 43 Times" [1]=> string(2) "43" }
And as you can see, you have 2 options. You can use
$thanks[0] for Thanked 43 Times
or
$thanks[1] for 43
SO we want $thanks[1].
Thats where the ending comes in
echo $thanks[1];
This will make the number show, as text.
//echo "<br>";
//echo $content;
This you can leave alone, but if you ever want to see the content then remove the "//" infront of both.
Next Step
Now that we have the variable we are looking for, we need to change up the code abit. We now change it to this.
Code:
<?php
header("Content-type: image/png");
$url = "https://www.mpgh.net/forum/33-visual-basics/83177-real-vb-injecter-source-code.html";
$data = file_get_contents($url);
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B","/","(", ")",">","<" );
$content = str_replace($newlines, "", html_entity_decode($data));
$html = '/Thanked (.+?) Times/';
preg_match($html,$content,$thanks);
?>
And after you change it to this, now we need to add the imaging that needs to be done.
SO now your full code should look like this.
Code:
<?php
header ("Content-type: image/png");
$url = "https://www.mpgh.net/forum/33-visual-basics/83177-real-vb-injecter-source-code.html";
$data = file_get_contents($url);
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B","/","(", ")",">","<" );
$content = str_replace($newlines, "", html_entity_decode($data));
$html = '/Thanked (.+?) Times/';
preg_match($html,$content,$thanks);
$handle = ImageCreate (130, 50) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 255, 0, 0);
$txt_color = ImageColorAllocate ($handle, 0, 0, 0);
ImageString ($handle, 5, 5, 18, "Thanks: $thanks[1]", $txt_color);
ImagePng ($handle);
?>
And this code will produce
For it to work on you, find a thread that was started by yourself, and change the $url to your threads URL.