How To Get Remote Iframed Webpage's Title In PHP Parent?

Status
Not open for further replies.

mariojunior

Active Member
45
2011
5
0
Hi...
First of all, sorry my bad english... Well, I'm using a short url script and I'm trying to get title from iframed page to parent frame, as Adf.ly does. I have insert following lines in my frame page:
PHP:
<?php
$url = "***********";
$fp = fopen( $url, 'r' );
$content = "";

while( !feof( $fp ) ) {
$buffer = trim( fgets( $fp, 4096 ) );
$content .= $buffer;
}

$start = '<title>';
$end = '<\/title>';
preg_match( "/$start(.*)$end/s", $content, $match );
$title = $match[ 1 ];

$metatagarray = get_meta_tags( $url );
$keywords = $metatagarray[ "keywords" ];
$description = $metatagarray[ "description" ];
?>

Then:
PHP:
<title><?php echo $title; ?></title>
<meta name="description" content="<?php echo $description ?>" />
<meta name="keywords" content="<?php echo $keywords ?>" />

It works fine if I use a URL value ($url = "http://www.anysite.com";), but I need to get values automatically from submitted urls. Anyone know how to do this? I'm not an expert at PHP. What exact value I need to insert at ($url = "***********";) to get it work? My framed template:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-bz" lang="en-bz">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo $title; ?></title>
    <meta name="description" content="<?php echo $description ?>" />
    <meta name="keywords" content="<?php echo $keywords ?>" />
    <meta name="copyright" content="Copyright &copy; <?php echo date("Y"); ?> - <?php echo SITE_CONFIG_SITE_NAME; ?>">
    <meta name="robots" content="all" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="-1" />
    <meta http-equiv="Pragma" content="no-cache" />
    <link rel="stylesheet" href="<?php echo SITE_CSS_PATH; ?>/screen.css" type="text/css" media="screen" title="Screen" charset="utf-8" />
  </head>
     <frameset cols="100%" frameborder="0">
     <frameset rows="*, <?php echo SITE_CONFIG_TOP_IFRAME_HEIGHT; ?>">
     <frame src="<?php echo $shortUrlObj->fullUrl; ?>" noresize>
     <frame src="framedRedirectTop.php?url=<?php echo $shortUrlObj->shortUrlUID; ?>" class="framedRedirectTopFrame" noresize>
     </frameset>
       <noframes>
        <?php echo t("browser_no_frame_support"); ?>
       </noframes>
     </frameset>
  </html>
 
Status
Not open for further replies.
Back
Top