Re: include html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Nov 2, 2010, at 12:37 AM, Nathan Nobbe wrote:

On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers <karl@xxxxxxxxxxxxxxx> wrote: I need to basically grab the source of the page as text. Then I can do a replace() on the <link> tag. Then insert the text into an Iframe. In theory, this I thought would be handled better server side. Is this possible?

yes, there are a few options, fopen wrappers, curl or raw sockets all come to mind. fopen wrappers sound like they may be easiest for you.

Any examples or urls to make a fopen wrapper? Or is there a simple function for getting the source text from a URL? Thats all I really need, if I can get <html>...</html> in text, I'm good! From that point I can insert the text into a hidden form field and grab the text via javascript if need be (but very hackish) or with php. I think that may be a solution, if I assign an include statement or echo of the url inside a hidden form field. A hidden form field will force the text to be saved and not parsed. I think.


I think the problem I'm having is that the domain I'm requesting from is not the same domain as mine so their may be some security issue.

right, this is why you would setup a server side proxy, to avoid client side cross domain security restrictions, however you'll have to change all the instances of the remote domain to your domain, and ensure that your server actually is able to fulfill requests for those resources.

Server side proxy.. I have heard of this, but do not know exactly what a proxy does to know if it would be a solution. I also have not seen one in action nor made one (that I know of), any beginner tuts you can lend?


I also thought about injecting a link tag into the iframe at the same time I load the HTML.

when you say link tag are you talking about <a> tags? you lost me on this last line here.

IE:  [code]
Get the text from their source, something like:

$htmlTextresult = <html>
<head>
<link href="css/fromtheirsite.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
... their content
</body>
</html>

then do a string replace on the link tag..
$newTextresult = str_replace($htmlTextresult, '<link href="css/ fromtheirsite.css" rel="stylesheet" type="text/css" media="all" />', '<link href="css/frommysite.css" rel="stylesheet" type="text/css" media="all" />');
or
$newTextresult = str_replace($htmlTextresult, 'css/ fromtheirsite.css', 'css/frommysite.css');

insert new text into the iframe..
$newTextresult = <html>
<head>
<link href="css/frommysite.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
... their content/ my style :)
</body>
</html>

Or is there a way to strip the text that is in the <head> , <body> and <script> tags?
I could then insert those into a blank html file?


Browsers load the last style sheet on top of others.

this is true, but i doubt you'll be able to have it load a css file from your domain atop a css file from a remote domain.

Well contrary, I think, only because all css tuts I found warned about using the "!important" in your css as it would override an external css. Imported css has the least priority out of all and their css is imported, maybe if I wrote the css as a <style> inline within the text I received from the source? I know that would work as far as my css beating out theirs. And the idea is to get the source and replace the text that points to their css (the <link> tag) with mine before its parsed.


If I could just get the link tag into the iframes contents right after I get the source text in there, it may work. But there is also the issue of correctly assigning the classes and I'd that are used in the iframe. Like

iframe.holder .someclassusedbythem {}

Or do I do?

iframe#holder .someclassusedbythem {}

Or

#holder .someclassusedbythem {}

Sorry if I'm OT with that.

shrug, no worries, but im too lazy to dig into the details of client side options. :)

Hey thanks for your help Nathan. I was starting to think I needed to scrap.
You have sparked the curiosity again.

Best,


-nathan



Karl DeSaulniers
Design Drumm
http://designdrumm.com


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux