View Full Version : php code to display proboards forum in a web page?
alley
April 17th, 2007, 22:35
I want to embed my proboard forum in an html page.
ButyYou can't put your proboard forum in an iframe, since Proboards is designed to break out of them
I guess the only way to get a Proboards forum to display on a different site would be with PHP? Is this possible?
Sam2000
April 18th, 2007, 01:08
Override.
Doug,
> Now the problem is that some websites have "frame breakout" scripts.
> When the iframe loads these pages they automatically takes over the
> entire session
You are quite right, the cross domain resrictions would make this pretty
much impossible to avoid. You cannot load their page into an iframe if they
refuse to allow it.
In theory, you can use an object instead, but IE would almost certainly fail
at this.
> PS. I also thought of redefining the "top" object or overriding its
> properties or methods.
'top' is a property unique to each frame, so you cannot override the child's
'top' from the parent frame. However, since 'top' and 'top.location' are
objects, you may be able to delete them (not sure how successful this might
be):
delete location; //this way, they can't change it.
The most reliable way to do what you need is a url proxy, but this would eat
your bandwidth, and you would need to change the base href of the page to
reflect its original location (so that all the links and images work);
<iframe src="getPage.php?url=http://example.com/"></iframe>
then in getPage.php:
<?
if( preg_match("/^http:\/\//",$_GET['url']) ) {
if( $file = fopen($_GET['url'],'rb') ) {
$contents = '';
$base = '<base href="'.urlencode($_GET['url']).'">';
while( !feof( $file ) ) { $contents .= fread( $file, 8192 ); }
if( stristr( $contents, '</html>' ) ) {
$contents = preg_replace("/<\/html>/i",$base.'</html>',$contents);
} else {
$contents = $base.$contents;
}
//this regexp may have an ugly effect on some pages - you will need to
//tailor the regexp to suit your needs.
$contents = preg_replace("/(=|\s|\()top\b/i","$1".'window',$contents);
print $contents;
}
}
?>
Hope this helps
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
Hope this helps.
alley
April 18th, 2007, 05:09
Thanks darius, but that is a bit confusing actually ..lol
themoose
April 18th, 2007, 15:31
He's saying create a file named getPage.php, and in it put
<?
if( preg_match("/^http:\/\//",$_GET['url']) ) {
if( $file = fopen($_GET['url'],'rb') ) {
$contents = '';
$base = '<base href="'.urlencode($_GET['url']).'">';
while( !feof( $file ) ) { $contents .= fread( $file, 8192 ); }
if( stristr( $contents, '</html>' ) ) {
$contents = preg_replace("/<\/html>/i",$base.'</html>',$contents);
} else {
$contents = $base.$contents;
}
//this regexp may have an ugly effect on some pages - you will need to
//tailor the regexp to suit your needs.
$contents = preg_replace("/(=|\s|\()top\b/i","$1".'window',$contents);
print $contents;
}
}
?>
And then instead of
<iframe src="http://example.com/"></iframe>
put
<iframe src="getPage.php?url=http://example.com/"></iframe>
alley
April 18th, 2007, 17:23
Ah cool ...thanks Colin
Ahhh ..I tried ..still can't get it to work.
themoose
April 19th, 2007, 14:47
Do you have a link to what you tried?
alley
April 19th, 2007, 20:14
No, I deleted it when I couldn't get it working.
Do you have a link to what you tried?
themoose
April 20th, 2007, 19:06
try giving the iframe a name (name="") like "top" or "main" or something.. try and fool proboards. Have a look and see what their javascript looks for to break out of frames.
alley
April 20th, 2007, 20:30
I think it's a little bit beyond my knowledge Colin,. but if you want to try I can PM you the link to my proboard forum?
I would really appreciate it. Thanks for your help on this. :-)
try giving the iframe a name (name="") like "top" or "main" or something.. try and fool proboards. Have a look and see what their javascript looks for to break out of frames.
themoose
April 21st, 2007, 14:39
Go ahead :).
krakjoe
April 21st, 2007, 16:12
I dont mind havin a look see if someone points me in the right direction
alley
April 21st, 2007, 20:38
Colin sent me some code to try out, but I haven't had the time to test it yet. If it don't work I will send you a PM Joe ..thanks
I dont mind havin a look see if someone points me in the right direction
alley
March 12th, 2009, 15:07
time to beat this dead horse again but I still have an interest in seeing if this is possible as I still use a few proboards forums.
Can anybody help with this? ...I seem to have lost Collin's codes.
Thanks
stuffradio
March 12th, 2009, 19:08
Why do you want to embed it so badly?
alley
March 12th, 2009, 20:54
because I want to make it part of my site's layout
GlennBeforeTime
March 13th, 2009, 03:53
because I want to make it part of my site's layout
I'd highly suggest just hosting your forum on your own website.
What you are trying to do is create a proxy to load the proforum page and then convert all links to open in getPage.php?url=http://blablablapage.com/someforum instead of http://blablablapage.com/someforum
It will be resource intensive on the server your PHP file is hosted on, and your account can be banned if it is shared because it contains a proxy.
alley
March 13th, 2009, 15:02
Ok .. no biggy. Just was wondering if it could be done and or was worth it. Sounds pretty much not worth it. Thanks guys!
GlennBeforeTime
March 13th, 2009, 19:05
Ok .. no biggy. Just was wondering if it could be done and or was worth it. Sounds pretty much not worth it. Thanks guys!
No Worries. As I said, the best option would be to host your own forum.
alley
March 14th, 2009, 21:10
I don't like paid web hosting though. I have found them to me more unreliable than free hosts.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.