PHP: How to modify a downloaded JavaScript code and partly change the code within it?

Status
Not open for further replies.

LincolnX

Baseband Member
Messages
25
I would like to download a JS file which could run from my (local) server. With the following code I can download and run the "filmtotaal javascript code". However there is a link in the JavaScript code: "http://www.filmtotaal.nl/images/fotvDetails/covers/25954.jpg" which I would like to automatically download and run from my own webserver. The code changes _every_ day so the links and filenames within the JavaScript will change.

How can I find and download the 25954.jpg to my server and modify the JavaScript code so it will run from my server?


FilmTotaal.php
Code:
<?PHP
 $dateToday = date("D");
 $fileName = 'filmtotaal.js';
 $feed = 'http://www.filmtotaal.nl/trackers/filmsoptv/filmsoptv_1.js';

if (file_exists($fileName)) {
	$releaseDate = (date("D", filemtime($fileName)));
}
 
if ($releaseDate != $dateToday) {
$info = file_get_contents($feed);
		file_put_contents($fileName,$info);
		echo 'parsed';
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="3600" content="text/html; charset=iso-8859-1" />
<title>FilmTotaal</title>
<link href="../../CSS/template_css.css" rel="stylesheet" type="text/css" />
<base target="filmiframe">
</head>

<body>
<script language="JavaScript" src="filmtotaal.js"></script>
</body>
</html>


FilmTotaal.js
Code:
document.write('<table width="350"><tr><td><h3>Bin-jip</h3>(21:25-22:55\, Canvas)</td></tr><tr><td valign="top"><br><br><img align="left" src="http://www.filmtotaal.nl/images/fotvDetails/covers/25954.jpg">Tae-suk zoekt op zijn motor naar leegstaande huizen waarin hij een tijdje kan verblijven. Hij steelt niets\, maar gebruikt wat uit de koelkast\, repareert kapotte spullen en doet zo nodig de was. Hij legt zijn bezoeken vast door zichzelf in andermans interieur te fotograferen. Dit eigenaardige maar kalme leven wordt onderbroken wanneer hij op een dag insluipt in een luxueus huis\, waar de jonge vrouw Sun-hwa zich in het donker verschuilt. Zij zit gevangen in een ellendig huwelijk met een man die haar mishandelt... <a href="http://www.filmtotaal.nl" target="_blank"><u>(www.filmtotaal.nl)</u></a></td></tr><tr><td><br><b>Alle films vandaag</b><br><br></td></tr></table>   <table width="350"><tr><td valign="top">13:00-15:00</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25945" target="_blank"><u>Things change</u></a></td><td valign="top">(RTL7)</td></tr><tr><td valign="top">13:20-14:50</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25946" target="_blank"><u>Surviving love</u></a></td><td valign="top">(RTL4)</td></tr><tr><td valign="top">14:00-15:20</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25947" target="_blank"><u>Homeward Bound II: Lost in San Francisco</u></a></td><td valign="top">(BBC1)</td></tr><tr><td valign="top">14:30-16:05</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25948" target="_blank"><u>Millions</u></a></td><td valign="top">(TV1)</td></tr><tr><td valign="top">15:00-16:30</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25949" target="_blank"><u>Poika ja ilves</u></a></td><td valign="top">(NED3)</td></tr><tr><td valign="top">18:50-20:30</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25950" target="_blank"><u>Carpool</u></a></td><td valign="top">(Veronica)</td></tr><tr><td valign="top">20:30-22:10</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25951" target="_blank"><u>Charlie\'s Angels</u></a></td><td valign="top">(RTL5)</td></tr><tr><td valign="top">20:30-22:25</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25952" target="_blank"><u>Striking Distance</u></a></td><td valign="top">(Veronica)</td></tr><tr><td valign="top">20:30-23:50</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25953" target="_blank"><u>Meet Joe Black</u></a></td><td valign="top">(NET5)</td></tr><tr><td valign="top">21:25-22:55</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25954" target="_blank"><u>Bin-jip</u></a></td><td valign="top">(Canvas)</td></tr><tr><td valign="top">22:25-00:00</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25955" target="_blank"><u>Domestic Disturbance</u></a></td><td valign="top">(Veronica)</td></tr><tr><td valign="top">22:30-00:10</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25956" target="_blank"><u>Lighthouse</u></a></td><td valign="top">(RTL8)</td></tr><tr><td valign="top">00:00-01:45</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25957" target="_blank"><u>Simpatico</u></a></td><td valign="top">(BBC2)</td></tr><tr><td valign="top">00:10-01:50</td><td width="200" valign="top"><a href="http://www.filmtotaal.nl/module.php?section=fotvDetails\&movieID=25958" target="_blank"><u>The Whistle Blower</u></a></td><td valign="top">(BBC1)</td></tr></table>');
 
Re: PHP: How to modify a downloaded JavaScript code and partly change the code within

Folks?
 
Re: PHP: How to modify a downloaded JavaScript code and partly change the code within

I would make the dynamic filename a variable in Javascript, then just transfer the variable to PHP and then do what you want with it.
 
Re: PHP: How to modify a downloaded JavaScript code and partly change the code within

Could you help me with that? (I don't know javascript)
 
Re: PHP: How to modify a downloaded JavaScript code and partly change the code within

I'm not real hot with it either.

Something like...
Code:
<script type="text/javascript">var filmToTaal = 'blah blah';</script>
<?php

$filmToTaal = '<script type="text/javascript">document.write (filmToTaal);</script>';

?>

That will assign $filmToTaal to the Javascript variable filmToTaal. Then you can do whatever you want with it in PHP.
 
Status
Not open for further replies.
Back
Top Bottom