MyBB Community Forums

Full Version: PHP Coding Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying something out, but can't get it to work.
What I'm trying to do is make a URL turn into its title.
Example:
If you type in http://www.google.com
It doesn't appear as http://www.google.com, but Google (of course, still a hyperlink).
I know I have to open up class_parser.php, but I don't know where to place this code:
$file = fopen ("http://www.example.com/", "r");
if (!$file) {
    echo "<p>Unable to open remote file.\n";
    exit;
}
while (!feof ($file)) {
    $line = fgets ($file, 1024);
    if (eregi ("<title>(.*)</title>", $line, $out)) {
        $title = $out[1];
        break;
    }
}
fclose($file);
I have changed one of the $name to $file just to test it out, but it broke down the forum.
Any help? Thanks.
Why would you put it in class_parser.php? There's no apparent reason to.
Really? Isn't that what runs the replacement of the URLs posted?