0

I had this code that I purchased many years ago that was working fine for me:

<?
$theLocation="http://www.ampolinc.com/wycieczki.php";
$baseURL="http://ampolinc.com/"; 

preg_match("/^(https?:\/\/)?([^\/]*)(.*)/i", "$theLocation", $matches);
$theDomain = "http://" . $matches[2];
$page = $matches[3];

$fd = fopen($theDomain.$page, "r");
$value = "";
while(!feof($fd)){
    $value .= fread($fd, 4096); 
}
fclose($fd);

// replace with your unique start point in the source of the HTML page
$start= strpos($value, "<td width=\"694\" bgcolor=\"#FFFFFF\">");  
// replace with the unique finish point in the source of the HTML page 
$finish= strpos($value, "<table width=\"709\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:5px 0px 0px 167px;\"><tr><td>");  
$length= $finish-$start;

$value=substr($value, $start, $length);

$value = eregi_replace( "plan", "print", $value );   .
$value = eregi_replace( "fd9b1a", "ffffff", $value );

$FinalOutput = preg_replace("/(href=\"?)(\/[^\"\/]+)/", "\\1" . $theDomain . "\\2", $value);
echo "<base href=\"$baseURL\">"; // sets the remote site as the base, so that relative links are fixed.
echo "<font style=\"font-size: 9pt\">";
echo $FinalOutput; //prints it to your page
flush (); //force output faster
echo "</font>";

?>

but since the eregi_replace() was deprecated and removed in PHP 7, it doesn't work anymore

I am not a coder so when I was trying to make it work I only got to the point of displaying the content but I can;t replace the strings inside the page.

http://pentiger.com/download.php

to fix the links I need to replace words: "plan" to "print"

This is the code I am now using

<?php
$baseURL="http://www.ampolinc.com/"; 
$curl = curl_init('http://www.ampolinc.com/wycieczki.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$page = curl_exec($curl);

if(curl_errno($curl)) // check for execution errors
{
    echo 'Scraper error: ' . curl_error($curl);
    exit;
}

curl_close($curl);


$regex = '/<td width=\"694\" bgcolor=\"#FFFFFF\">(.*?)<table width=\"709\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:5px 0px 0px 167px;\"><tr><td>/s';


if ( preg_match($regex, $page, $list) ) {    
    echo "<base href=\"$baseURL\">";
    echo "<font style=\"font-size: 9pt\">";
    echo $list[0]; //prints it to your page
    echo "</font>";       
} else 
    print "Not found"; 
?>

Ho can I replace strings within the $list before echo""?

Thanks

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

0 Answers0