A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

Little PHP code to check photo owner on Facebook

871 views · started by imbaimba ·
#1
Little PHP code to check photo owner on Facebook
Hi guys!

I have made some little PHP code that check the owner of a photo on Facebook that the user inputs.
I'm not sure that it works, but I can't see it a reason why it shouldn't haha. I have no option to run it at the moment, so feel free to test it and fix it in case it doesn't work (will be mainly dumb mistakes :P).
I commented everything, so I hope it helps someone who tries to study PHP. It's VERY basic, but cute.

Here is the HTML front page:
<html>
<body>

<form action="data.php" method="post">
http://www.<input type="text" name="address">
<input type="submit">
</form>

</body>
</html>


And here is the data.php
<html>
<body>
<?php
$address = $_POST["address"]; //getting the address
$start = strrpos($address,"."); //last dot in the address, the ID starts there
$start = $start++; //we don't need the dot, so we are moving forward
if(!strpos($address,"&type=1&theater")) //sometimes the user will put it too, so if he didn't do it (and the output will be FALSE), this will run
{
$id = substr($address,$start); //the substring starts where the $start is, and goes until the end
}
else //in case he didn't put the whole type and theater thing
{
$end = strpos($address,"&type=1&theater"); //this will be the end of the id
$id = substr($address,$start,$end - $start); //starts in $start and the length equals the position of the end minus the position of the start
}
$url = "http://www.facebook.com/profile.php?id=" . $id; //putting up the url
$str = file_get_contents($url); //getting the page source
$name_start = strpos($str,'<title id="pageTitle">'); //name starts here
$name_end = strpos($str,'</title>'); //name ends here
$name = substr($str,$name_start,$name_end-$name_start); //this will be the name
$name = str_replace('<title id="pageTitle">',"",$name); //we don't need the tag in the name, so we are deleting it
?>
The photo belongs to the user/page named <?php echo $name; ?>.<br>
The url to his profile is <?php echo $url; ?>
</body>
</html>
#2
A while back I actually rigged up a little web app to do just this.
You should expand on it a bit more.

Good work though. Just keep in mind it doesn't work for all URLs

Also, not proficient in PHP but wouldn't using a split function on the string be more reliable?
#3
If you mean exploding it into an array, it's possible too.
Just
explode(".",$address)
and we will get an array. and the index will be 5 (6 dots overall in the address, we need the last one). If the user will input the "&type=1&theater" as well, we will need to check and cut it as well.
#4
When did you make this? I know Facebook used to have a lot of complaints from people being able to harvest a user's profile page from their picture URLs and had fixed it. Dunno if this attempts to use the same system. But that was like a year ago or so.
#5
I made it in the same day I posted it, so it should work.