Results 1 to 10 of 10
  1. #1
    Ugleh's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    House, Where you live?
    Posts
    276
    Reputation
    17
    Thanks
    221
    My Mood
    Blah

    [TUT] Data on Images

    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.

    Code:
    <?php
    
    ?>
    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.

  2. The Following 18 Users Say Thank You to Ugleh For This Useful Post:

    Credi (10-15-2009),Dorado (10-06-2009),Erinador (10-20-2009),Houston (10-04-2009),ImTheShooter (11-10-2009),Jimmy (10-03-2009),MKL (10-03-2009),mnpeep (12-23-2009),monkey32 (10-03-2009),No5cope (10-02-2009),Pixie (10-06-2009),quindo (10-04-2009),tabciogaraj (10-27-2009),the_ca (04-16-2010),trevor206 (10-06-2009),trex (10-03-2009),why06jz (10-03-2009),Zebra (10-08-2009)

  3. #2
    No5cope's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    1,902
    Reputation
    26
    Thanks
    678
    My Mood
    Aggressive
    nice work on this

  4. #3
    Ugleh's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    House, Where you live?
    Posts
    276
    Reputation
    17
    Thanks
    221
    My Mood
    Blah
    np, once you learn this, sooner or later ud be making this:


  5. #4
    why06jz's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    295
    Reputation
    14
    Thanks
    54
    Hey wow this is pretty cool stuff. I'll have to stick around here a little more often.

    Oh and thanks Ugleh.
    Code:
    <?php
    header ("Content-type: image/png");
    $url = "https://www.mpgh.net/forum/198-php-html/84620-tut-data-images.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, 0, 255, 0);
    $txt_color = ImageColorAllocate ($handle, 0, 0, 0);
    ImageString ($handle, 5, 5, 18, "Thanks: $thanks[1]", $txt_color);
    ImagePng ($handle);
    ?>
    Damit html is off D:

    Ok one question:

    How does this make $thanks into an array?
    Code:
    array(2) { [0]=> string(16) "Thanked 43 Times" [1]=> string(2) "43" }
    shouldn't it be something like this:
    Code:
    $thanks(2) { [0]=> string(16) "Thanked 43 Times" [1]=> string(2) "43" }
    I'm just a little confused at the way you assigned it a value. It looks nothing like that in C++. But I am willing to learn please explain

    Could you explain more what all these symbols remove.
    Code:
    $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B","/","(", ")",">","<" );
    If I need to learn some other stuff first point me in the right direction and I will go there.
    Last edited by why06jz; 10-03-2009 at 07:17 AM.

  6. #5
    Ugleh's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    House, Where you live?
    Posts
    276
    Reputation
    17
    Thanks
    221
    My Mood
    Blah
    the Var_dump already calls for $thanks, so it just outputs an array. and it tells you there is 2. the $thanks[0] and $thanks[1].

    $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B","/","(", ")",">","<" );
    This will remove

    \t
    \n
    \r
    \x20\x20

    In some coding (in php too) you use \n or \r to represent a new line.
    I also added
    <>
    ()
    /
    Because with those removed I will not get any errors when grabbing values.

  7. The Following User Says Thank You to Ugleh For This Useful Post:

    why06jz (10-03-2009)

  8. #6
    why06jz's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    295
    Reputation
    14
    Thanks
    54
    Ok. Thanks for the quick reply.

    Now what about all the other words. Because it seems to me you would get a really huge array of words and numbers. How do you narrow it down to the two that you want?

    Oh wait I get it! This finds the right string your looking for:
    $html = '/Thanked (.+?) Times/';
    preg_match($html,$content,$thanks);


    Sweet thanks a lot. Ugleh

  9. #7
    Ugleh's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    House, Where you live?
    Posts
    276
    Reputation
    17
    Thanks
    221
    My Mood
    Blah
    no problem, remember what has been removed though, if you ever need to look at the content remove the // infront of echo $content

    then do Ctrl + F to find the current data, and copy stuff around it, and replace the number or word with (.+?)

    Make sure you have the "/"s like > /Content(.+?) secondcont/

  10. #8
    MKL's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    20
    Reputation
    10
    Thanks
    0
    My Mood
    Amused
    I knew it but thanks !

  11. #9
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    So what do we make this in?? And what do we save it as??

  12. #10
    Ugleh's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    House, Where you live?
    Posts
    276
    Reputation
    17
    Thanks
    221
    My Mood
    Blah
    lol, this is the php forum, so it would be a .php file, using notepad. Then you upload it to a web server.

Similar Threads

  1. Replies: 6
    Last Post: 03-28-2011, 02:09 PM
  2. [Tut]Data Conversions
    By NextGen1 in forum Visual Basic Programming
    Replies: 2
    Last Post: 01-27-2010, 10:04 PM
  3. Warhead glitch *new* not patched IMAGE Tut
    By ximsonoobx in forum Combat Arms Hacks & Cheats
    Replies: 26
    Last Post: 10-07-2008, 06:52 PM
  4. [Tut] (Requires PayPal) Free Maplestory NX Cash [The legal way] {with images}
    By cybershadowX in forum MapleStory Hacks, Cheats & Trainers
    Replies: 18
    Last Post: 09-04-2007, 07:07 PM
  5. [tut] Putting An Image Of Ure Clan
    By ktalin91 in forum WarRock Korea Hacks
    Replies: 9
    Last Post: 05-22-2007, 01:17 PM

Tags for this Thread