Jump to content

String replace links in echo'd content


windowsdan

Recommended Posts

I'm looking to post links in a 'href=' that are echo'd from a variable, that is gotten from a 'file_get_contents' command, to the next page when they are clicked on. Is this possible??

 

Example:

<?php

$html = file_get_contents('http://www.DOMAIN.com/file.html');

echo $html

//HERE I NEED THE file.html TO HAVE THE href= ADDRESSES INSIDE IT POSTED TO NEXT PAGE WHEN CLICKED ON

//THE HTML MAY CONTAIN: <body>something <a href="/file4.html"</body> AND I WOULD NEED THAT ANCHOR TO POST THE 'href'TO THE NEXT PAGE i.e. POST /file4.html > page.php

?>

I hope this has been explained enough, ask if more info is required :) thanks!

Link to comment
https://forums.phpfreaks.com/topic/283171-string-replace-links-in-echod-content/
Share on other sites

IT HALF WORKS!!

 

Thanks for the response, however, I haven't used that before; I did get somewhere though.

 

I have gotten to this point:

<?php

$link = $_POST['link'];

$link = strtr($link, array(' ' => '+',));

$html = file_get_contents('http://www.DOMAIN.com/results?search='.$link."");

$html = strtr($html, array('href="/' => 'href="http://www.DOMAIN1.com/index.php?incoming=http://www.DOMAIN2.com/',));

echo $html;

?>

But I would like to have the href link (stay clickable as a link) but POST the data instead so it's not show in the URL. 

 

The only problem is that I could only seem to use the GET command because passing a variable through a link click is written to a GET.

 

Any ideas?

Ok I'll explain what it is that's happening. I have built a Proxy within one of my websites that works fine until it comes to YouTube!

 

When it comes to that I  can get the users to search YouTube and have the page echo'd with the right results and change the video links to what I want i.e. a pass through to another php page. The reason I need to do this is because YouTube videos with ads or Vevo etc won't allow the video to stream to a separate WAN IP to the page load.

 

I have achieved this perfectly by using PHP in combination with a command line program called 'Youtube-DL' where by the php calls the commands required to download user selected video to the server and then stream it back to the user in an HTML 5 embedded video (with flash fallback). Everything works great except the problem I have with the links.

 

In order for it to look like the youtube page, I need the page to mostly be echo'd identical but for the user to be able to click the video link and be taken to the embedded player for playback. 

 

BUT .... the idea of a proxy is that none of the URL's that the pages are loading appear in the URL bar. I would just love to get over this last hurdle :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.