Page 2 of 4
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:02 pm
by RobertGonzalez
f-g-c meaning file_get_contents? Can you post the URI that you are getting the contents from? If it is something private you can PM me. I would like to see the contents that you are fetching so I can see where to move to next.
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:05 pm
by dragonsmistress
No problem at all! I appreciate your help by the way (:
http://dragcave.net/user/dragonsmistress
The name would be whatever the user enters into the form but for purpose sakes we can use my username
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:07 pm
by RobertGonzalez
I get it. So you are actually taking the HTML of that file and scanning it for images (only GIF images it looks like). Once you have those images you are going to list them and compare them to something right? Or is that wrong?
So basically you are going to take the images from that site and list them on your site for your users to check off?
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:09 pm
by dragonsmistress
You've got it!!! lol not comparing them to anything just letting the users see what eggs and hatchlings they have and then they can click the ones they would like to have displayed on my site
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:17 pm
by RobertGonzalez
Ok. Hang tight and let me see if I can whip something up really quick.
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:18 pm
by dragonsmistress
you are my new best friend (;
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 3:50 pm
by RobertGonzalez
So with the help of another forum moderator here (*cough* Pickle *cough*) I was able to get a listing of images for your from the site:
Code: Select all
<?php
$string = file_get_contents('http://dragcave.net/user/dragonsmistress');
$pattern = ":/image/(.*?).gif:m";
preg_match_all($pattern, $string, $matches);
$list = $matches[0];
$limit = count($list);
for ($i = 0; $i < $limit; $i++) {
echo "http://dragcave.net$list[$i]<br />";
}
Replace the url with the url of the user you are doing this for. Also, you may want, for testing anyway, to var_dump the $matches array after you have it to see what it is really composed of. The 0th member of the matches array is the "/image/XXXX.gif" string. The 1th array are the image names only. I added the dragoncave URI to the output so you could feasibly render those images on your site as they are coming out.
I gotta head out. Hopefully this puts you on the right track. If not, you can always post back. Good luck with your project.
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 4:20 pm
by dragonsmistress
this works great (: only thing i need now is a form so the user can enter the scrollname and have the eggs and hatchlings pulled up... any thoughts?
i also need to know how to ONLY list the eggs and hatchlings... not the adults (:
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 8:40 pm
by Chris Corbyn
In ~Everah's code he gets the contents from a URL that has your username hard-coded into it:
Code: Select all
$string = file_get_contents('http://dragcave.net/user/dragonsmistress');
If you had a form with a field called "scrollname" that points to this page, then you'd access the scrollname variable via $_POST['scrollname'] or $_GET['scrollname'] depending upon what method=" ... " you have in your form.
So you need to replace that hard-coded username with the data from the form:
Code: Select all
//Assuming you've done some pre-requisite isset() for $_POST['scrollname']
$scrollname = $_POST['scrollname'];
$string = file_get_contents('http://dragcave.net/user/' . $scrollname);
That should give you a head-start on making things more dynamic so a user can specify their scrollname.
Ok, where's my lovin' ?

Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 9:40 pm
by dragonsmistress
Just got home from a Canes game!!! Goooo Canes (: Anyways.....
Here is my form
Code: Select all
<form action="test.php" method="post">
<div style='margin: 0px auto; text-align: center;'> Scrollname: <input name="scrollname"/> <input type="submit" value="Add"/></div>
</form>
And here is the script
Code: Select all
<?php
$scroll = $_POST[scrollname];
if (isset($_POST['submit'])) {
$string = file_get_contents('http://dragcave.net/user/' . $scroll);
$pattern = ":/image/(.*?).gif:m";
preg_match_all($pattern, $string, $matches);
$list = $matches[0];
$limit = count($list);
for ($i = 0; $i < $limit; $i++) {
echo "<img src=http://dragcave.net$list[$i]><br />";
}
}
?>
I get a blank page ):
Re: Please help... I may pull out my hair....
Posted: Thu Dec 18, 2008 9:44 pm
by dragonsmistress
Ok..... I got that to work (: NOW (: Loving will come if you can help me figure out how to ONLY list the eggs and hatchlings!!
Re: Please help... I may pull out my hair....
Posted: Fri Dec 19, 2008 9:24 am
by RobertGonzalez
On the page you are scraping, what identifies the image as an egg as opposed to a hatchling as opposed to a dragon?
Re: Please help... I may pull out my hair....
Posted: Fri Dec 19, 2008 11:10 am
by dragonsmistress
The source code on the site for the eggs is:
<tr><td><img src="/image/g3Jn.gif" alt='x'/></td><td> </td><td>Egg</td>
Source code for hatchling:
<tr><td><img src="/image/MYZX.gif" alt='x'/></td><td><i>Unnamed</i></td><td>Hatchling</td>
Source code for adult:
<tr><td><img src="/image/v4Jo.gif" alt='x'/></td><td>Mistress's Rutilus</td><td>Adult</td>
Re: Please help... I may pull out my hair....
Posted: Fri Dec 19, 2008 1:19 pm
by RobertGonzalez
Ok, that will take a bit of mesaging the regular expression, but it should be easy enough. Let me see if I can figure out the regular expression (not one of my strong suits).
Re: Please help... I may pull out my hair....
Posted: Fri Dec 19, 2008 5:46 pm
by dragonsmistress
*waits ever so patiently*
