Page 1 of 1

PHPTennis: PHP built webpage viewer

Posted: Mon Mar 24, 2003 9:39 pm
by phice
I've been making a small webpage viewer, which will use the server to download the webpage, fix it's links, and show the HTML given.

I'll start it off:

Code: Select all

<?php
if (!$url) { die("You need to set your url. Example: browser.php?url=http://www.yourdomain.com/"); }
$strings = $_SERVER["QUERY_STRING"];
$url = str_replace("url=", "", $strings);

?>
<html>
<base href="<? echo $url; ?>">
<head>
<title>Browser - <? echo $url; ?></title>
</head>
<?
$lines = file($url);
foreach ($lines as $line_num => $line) { 

   $line = eregi_replace("href=/", "hrXef=$PHP_SELF?url=$linkback/", $line);
   $line = eregi_replace("href="/", "hrXef="$PHP_SELF?url=$linkback/", $line);
   $line = eregi_replace("href="", "hrXef="$PHP_SELF?url=", $line);
   $line = eregi_replace("href='/", "hrXef='$PHP_SELF?url=$linkback/", $line);
   $line = eregi_replace("href='", "hrXef='$PHP_SELF?url=", $line);
   $line = eregi_replace("href=", "$PHP_SELF?url=", $line);
   $line = str_replace("hrXef=", "href=", $line);

   echo $line . "\n";
}
?>
Rules
-Add atleast 3 lines
-No external images, php files, etc will be used
-all php coding above shall reside in one php document (browser.php)

Let the games begin!

Posted: Tue Mar 25, 2003 4:28 am
by volka

Code: Select all

<?php
// #1, vk, 020235, n
// #1, all short to full tags
if (!$url) { die("You need to set your url. Example: browser.php?url=http://www.yourdomain.com/"); }
$strings = $_SERVER["QUERY_STRING"];
$url = str_replace("url=", "", $strings);

?>
<html>
<base href="<?php echo $url; ?>">
<head>
<title>Browser - <?php echo $url; ?></title>
</head>
<body><!-- #1, make it a complete document -->
<fieldset><legend><?php echo htmlentities($url) ?></legend><!-- #1, show in fieldset -->
<?php
$lines = file($url)
		or die('File not found'); // #1, added 'File not found'
foreach ($lines as $line_num => $line) {

   $line = eregi_replace("href=/", "hrXef=$PHP_SELF?url=$linkback/", $line);
   $line = eregi_replace("href="/", "hrXef="$PHP_SELF?url=$linkback/", $line);
   $line = eregi_replace("href="", "hrXef="$PHP_SELF?url=", $line);
   $line = eregi_replace("href='/", "hrXef='$PHP_SELF?url=$linkback/", $line);
   $line = eregi_replace("href='", "hrXef='$PHP_SELF?url=", $line);
   $line = eregi_replace("href=", "$PHP_SELF?url=", $line);
   $line = str_replace("hrXef=", "href=", $line);

   echo $line . "\n";
}
?> 
</body></html>

Posted: Tue Mar 25, 2003 1:07 pm
by phice

Code: Select all

<?php 
// #1, vk, 020235, n 
// #1, all short to full tags 
if (!$url) { die("You need to set your url. Example: browser.php?url=http://www.yourdomain.com/"); } 
$strings = $_SERVER["QUERY_STRING"]; 
$url = str_replace("url=", "", $strings); 

?> 
<html> 
<base href="<?php echo $url; ?>"> 
<head> 
<title>Browser - <?php echo $url; ?></title> 
</head> 
<body><!-- #1, make it a complete document --> 
<fieldset><legend><?php echo htmlentities($url) ?></legend><!-- #1, show in fieldset --> 
<?php 
$lines = file($url) 
      or die('File not found'); // #1, added 'File not found' 
foreach ($lines as $line_num => $line) { 

   $line = eregi_replace("(action|href)=/", "(acXtion|hrXef)=$PHP_SELF?url=$linkback/", $line); 
   $line = eregi_replace("(action|href)="/", "(acXtion|hrXef)="$PHP_SELF?url=$linkback/", $line); 
   $line = eregi_replace("(action|href)="", "(acXtion|hrXef)="$PHP_SELF?url=", $line); 
   $line = eregi_replace("(action|href)='/", "(acXtion|hrXef)='$PHP_SELF?url=$linkback/", $line); 
   $line = eregi_replace("(action|href)='", "(acXtion|hrXef)='$PHP_SELF?url=", $line); 
   $line = eregi_replace("href=", "href=$PHP_SELF?url=", $line); 
   $line = str_replace("hrXef=", "href=", $line); 
   $line = str_replace("acXtion=", "action=", $line); 

   echo $line . "\n"; 
} 
?> 
</body></html>
eregi may be messed up with the action/href switch... I'm not too good with eregi ;]