Modify data brought in via <?php include
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Modify data brought in via <?php include
Or post the URL you are trying to connect to. And when I said code, I mean the PHP you are using to fetch the contents of that URL. Including the URL. Please.
Re: Modify data brought in via <?php include
As you can see below the html file if you look at it directly by typing the URL into browser you will get the the images/maps src link..Burrito wrote:if it's outputting something but not changing it, then file_get_contents() is NOT your problem. Post a small snippet it of what it returns in here that you'd like replaced and I'll take a look at it.
When i use the php include it presents the exact same code into my page..
I attempted to use iframe however if people went to click on the links (in map) it would open the link within the iframe which wasn't enough room to display the page..
Everything obviously works fine with the iframe but not being able to open the links in a seperate tab/window is a pain..
That is why i am trying the include as then i will be able to have the font run from my page also..
My absolute ideal outcome would be to have it display with the include..
Thanks again for looking into this for me..
Code: Select all
<p><strong>Today Mon, 19 Jan 2009 is not a Day of Total Fire Ban.</strong>
</p>
<p><img src="images/maps/tfb_0.gif" width="250" height="185" border="0" alt="Total Fire Ban Districts" usemap="#Map"></p>
<map name="Map" id="Map">
<area shape="poly" coords="1,5" href="#" />
<area shape="poly" coords="2,121,1,4,19,8,35,10,45,30,56,26,63,28,71,44,78,52,93,66,94,88,107,105,85,117,68,105,44,116,34,110,16,116" href="images/maps/north_western_tfb_district.gif" target="_blank" alt="North Western District" title="Click to view a map of the North Western District"/>
<area shape="poly" coords="2,125,2,146,17,157,24,152,36,155,47,158,62,166,74,171,80,158,80,147,68,139,74,126,69,108,61,112,46,120,30,115,15,122" href="images/maps/south_western_tfb_district.gif" target="_blank" alt="South Western District" title="Click to view a map of the South Western District" />
<area shape="poly" coords="77,122,83,117,93,116,104,115,108,121,110,127,116,124,125,129,135,129,143,128,143,134,135,138,133,147,132,154,133,161,130,166,125,160,126,150,119,151,111,159,116,145,113,138,105,141,98,145,95,149,104,149,84,160,82,149,71,139" href="images/maps/central_tfb_district.gif" target="_blank" alt="Central District" title="Click to view a map of the Central District" />
<area shape="poly" coords="97,72,108,77,114,70,126,69,140,74,157,73,170,77,181,73,191,73,194,82,196,87,198,94,183,96,175,97,174,105,175,113,165,113,156,111,155,118,153,123,149,127,140,123,130,126,123,124,118,120,113,121,107,112,110,104,108,97,103,94,105,86,97,84" href="images/maps/north_eastern_tfb_district.gif" target="_blank" alt="North Eastern" title="Click to view a map of the North Eastern District" />
<area shape="poly" coords="138,171,134,160,136,148,140,136,151,130,159,115,171,118,180,116,178,102,189,98,198,100,206,104,232,117,247,126,243,128,235,135,215,135,195,138,181,147,171,158,161,166,155,169,149,166,147,171,153,181" href="images/maps/eastern_tfb_district.gif" target="_blank" alt="Eastern District" title="Click to view a map of the Eastern District" />
</map>
Re: Modify data brought in via <?php include
now I'm confused: are you generating that html string with file_get_contents() as you said you were before or are you getting that using include() or from an iframe?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Modify data brought in via <?php include
Use file_get_contents() and manipulate the string once you have it.
Re: Modify data brought in via <?php include
Sorry for the confusion..
The iframe was just something i was trialling but don't like at all.. there's no flexibility..
---------------------------------------------------------------------------------------
The below is what most are stating should work..
If i use:
the end result from running it in a test page is: (note: the str_replace hasn't worked)
However i get the same result using both file_get_contents() and include()..Burrito wrote:now I'm confused: are you generating that html string with file_get_contents() as you said you were before or are you getting that using include() or from an iframe?
The iframe was just something i was trialling but don't like at all.. there's no flexibility..
---------------------------------------------------------------------------------------
How would i manipulate it..Everah wrote:Use file_get_contents() and manipulate the string once you have it.
The below is what most are stating should work..
If i use:
Code: Select all
<?php
$input = file_get_contents('http://www.somesite.com/page.htm');
$output = str_replace('images/maps', 'http://www.somesite.com/images/maps', $input);
echo $output
?>
Code: Select all
<p><strong>Today Mon, 19 Jan 2009 is not a Day of Total Fire Ban.</strong>
</p>
<p><img src="images/maps/tfb_0.gif" width="250" height="185" border="0" alt="Total Fire Ban Districts" usemap="#Map"></p>
<map name="Map" id="Map">
<area shape="poly" coords="1,5" href="#" />
<area shape="poly" coords="2,121,1,4,19,8,35,10,45,30,56,26,63,28,71,44,78,52,93,66,94,88,107,105,85,117,68,105,44,116,34,110,16,116" href="images/maps/north_western_tfb_district.gif" target="_blank" alt="North Western District" title="Click to view a map of the North Western District"/>
<area shape="poly" coords="2,125,2,146,17,157,24,152,36,155,47,158,62,166,74,171,80,158,80,147,68,139,74,126,69,108,61,112,46,120,30,115,15,122" href="images/maps/south_western_tfb_district.gif" target="_blank" alt="South Western District" title="Click to view a map of the South Western District" />
<area shape="poly" coords="77,122,83,117,93,116,104,115,108,121,110,127,116,124,125,129,135,129,143,128,143,134,135,138,133,147,132,154,133,161,130,166,125,160,126,150,119,151,111,159,116,145,113,138,105,141,98,145,95,149,104,149,84,160,82,149,71,139" href="images/maps/central_tfb_district.gif" target="_blank" alt="Central District" title="Click to view a map of the Central District" />
<area shape="poly" coords="97,72,108,77,114,70,126,69,140,74,157,73,170,77,181,73,191,73,194,82,196,87,198,94,183,96,175,97,174,105,175,113,165,113,156,111,155,118,153,123,149,127,140,123,130,126,123,124,118,120,113,121,107,112,110,104,108,97,103,94,105,86,97,84" href="images/maps/north_eastern_tfb_district.gif" target="_blank" alt="North Eastern" title="Click to view a map of the North Eastern District" />
<area shape="poly" coords="138,171,134,160,136,148,140,136,151,130,159,115,171,118,180,116,178,102,189,98,198,100,206,104,232,117,247,126,243,128,235,135,215,135,195,138,181,147,171,158,161,166,155,169,149,166,147,171,153,181" href="images/maps/eastern_tfb_district.gif" target="_blank" alt="Eastern District" title="Click to view a map of the Eastern District" />
</map>
Re: Modify data brought in via <?php include
Code: Select all
$input = "<img src=\"images/maps/someimage.jpg\">";
$output = str_replace('images/maps', 'http://www.somesite.com/images/maps', $input);
echo htmlentities($output);
-
thinsoldier
- Forum Contributor
- Posts: 367
- Joined: Fri Jul 20, 2007 11:29 am
- Contact:
Re: Modify data brought in via <?php include
Do you have error reporting and display errors turned on?
If file_get_contents isn't working for you with urls it should be giving you an error of some sort saying your server wont allow http streams or something with it.
if you just do
<?
echo file_get_contents('http://www.google.com');
?>
And that doesn't return google's home page or some sort of error then you'll know.
If file_get_contents isn't working for you with urls it should be giving you an error of some sort saying your server wont allow http streams or something with it.
if you just do
<?
echo file_get_contents('http://www.google.com');
?>
And that doesn't return google's home page or some sort of error then you'll know.
Warning: I have no idea what I'm talking about.
Re: Modify data brought in via <?php include
After alot ofBurrito wrote:does exactly what it's supposed to for me....I"m guessing file_get_contents() isn't returning what you think it is for whatever reason. Try running it through htmlentities().Code: Select all
$input = "<img src=\"images/maps/someimage.jpg\">"; $output = str_replace('images/maps', 'http://www.somesite.com/images/maps', $input); echo htmlentities($output);
Thanks all so very much for your help.. It has worked on the test page..
I have just trialled it within my CMS site but for some reason it doesn't like being within a table
as it makes sure it is the only thing in the table on that row.
However that shouldn't matter hopefully as i may be able to work around that..
Does php not like being in a table??
Code: Select all
<!-- START TFB STATUS -->
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td>
<p align="center"><font size="4" color="#000000"><b>TOTAL FIRE BAN STATUS</b></font>
<br />
<br />
<font size="2" color="#000000">
<b>Fire Restrictions NOW In Force
<br />
<img src="/images/tfbfr.gif" alt="Fire Restrictions" />
<br />
Our Fire Brigade is located within the
<br />
Central Total Fire Ban District
</b></font></p>
</td>
<td style="width: 5px">
</td>
<td>
<font size="1">
<!-- TFB INPUT -->
<?php
$input = file_get_contents('http://www.somesite.com/tfb.htm');
$output = str_replace('images/maps', 'http://www.somesite.com/images/maps', $input);
echo htmlentities($output);
?>
<!-- END TFB INPUT -->
</font>
</td>
</tr>
</tbody>
</table>
<!-- END TFB STATUS -->
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Modify data brought in via <?php include
PHP only cares about syntax. After that it's all pretty much HTML. If the markup you were generating with the PHP is not clean you could have some issues.