Layout Grabber doesnt work quite right....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
darkfreaks
Forum Commoner
Posts: 59
Joined: Sat Sep 09, 2006 3:59 pm

Layout Grabber doesnt work quite right....

Post by darkfreaks »

hello i have coded a valid function for my Layout grabber which currently displays the style code for css layouts. however i only want it to display if the site and username are found and the contents are grabbed then echoed in the box. right now it only displays the google header code for my site? i think i need an if else statement so it only echos upon submit.


heres the code so far :

Code: Select all

[syntax=php]/// grab vf username
$url [url] = 'http://vampirefreaks.com/u/<?php echo $username;?>';
/// Start Grab Layout
$start [start_style] = '<style>';
///End Grab Layout
$end[end_style] = '</style>';
/// Show Html Tags

/// do you want the html tags do be shown?
$show [show_tags] = 0; 
/// get username

$username = $_POST[username];
class grabber
{


var $error = '';
	var $html  = '';

function grabhtml( $url, $start, $end ) 
{

$file = file_get_contents ( $url );
   
if ( $file )
{


if( preg_match_all( "#$start(.*?)$end#s", $file, $match ) )
			{				
				$this->html = $match;
			}
			else
			{
				$this->error = "Tags cannot be found.";
			}
		}
		else
		{
			$this->error = "Site cannot be found!";
		}
	}

function strip( $html, $show, $start, $end )
	{
		if( !$show )
		{
			$html = str_replace( $start, "", $html );
			$html = str_replace( $end, "", $html );
			
			return $html;
		}
		else
		{
			return $html;
		}
	}
}

$grab = new grabber;
$grab->grabhtml( $url[url], $start[start_style], $end[end_style] );

echo $grab->error;
foreach( $grab->html[0] as $html )
{

echo 
'<textarea cols="100" rows="5" name="myname">';
 echo htmlspecialchars( $grab->strip( $html, $show['show_tags'], $start[start_style], $end[end_style] ) ) . "<br>";
}

 '</textarea>' ;
[/syntax]
darkfreaks
Forum Commoner
Posts: 59
Joined: Sat Sep 09, 2006 3:59 pm

Post by darkfreaks »

Update: it now posts the echo on submit but it still needs to be told to grab the style code on a certain site. :?
darkfreaks
Forum Commoner
Posts: 59
Joined: Sat Sep 09, 2006 3:59 pm

Post by darkfreaks »

can someone tell me how i would make the userername field post then add to the end of the url its sposed to grab? right now the adress is set at vampirefreaks.com/u/ but i want ot to add the username after the /u/ part/ then grab that url and username grab the style tag from the profile and echo it in the box.
Post Reply