Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Programming help needed: how to perform a re-write of the entire page?
DavidK
New
A lot of work places block the URL's of community forums and so I've decided that I want to allow my users to use alternate URL's and domain names.
So, if I have:
http://www.londonfgss.com/
I could also allow my users to reach the site via other friendly domain names:
http://www.fglondon.com/
http://www.londonfgss.co.uk/
And if the worst comes to pass by the IP address:
http://67.19.83.27/
The problem I have is that I want them to be able to stay on the domain that they accessed via. And if someone posts a link to fglondon.com and someone else is viewing on 67.19.83.27 then the viewer using the IP address shouldn't be bounced over to fglondon.com.
I've done this before with vBulletin and had something that looked like this in the piece of code that echoes the entire page out:
<code>
$findArray = array(
'http://bowlie.com/forum',
'http://www.bowlie.com/forum',
'https://bowlie.com/forum',
'https://www.bowlie.com/forum',
'http://bowlie.co.uk/forum',
'http://www.bowlie.co.uk/forum',
'http://indiebabes.com/forum',
'http://www.indiebabes.com/forum',
'https://indiebabes.com/forum',
'https://www.indiebabes.com/forum'
);
$replaceArray = array(
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl'],
$vbulletin->options['bburl']
);
$vartext = str_replace($findArray, $replaceArray, $vartext);
</code>
Where options['bburl'] is the current URL, and $vartext contained the text of the page before it gets sent over the wire (the output buffer).
You'll also note that those who access via SSL get to stay on SSL.
So I know how to do this, but what I don't know and my question is:
Where do I do this?
As in... how can I add this piece of code or the equivalent to the code to allow it to take affect across all pages on the site and re-write the output HTML so that the URL's remain correct for the domain that the site is being accessed over?
0
This discussion has been closed.
Comments
Best place to add this would probably be to edit conf/settings.php.
Near the top of that file, there is a line that looks something like this: $Configuration['BASE_URL'] = 'http://your.base.url/to/vanilla/';
All you would need to do is read what URL the user is using, (I think $_SERVER['HTTP_HOST'] would be useful here) strip off anything that comes after 'forum/' and set it in that field. Another setting that is domain specific is the cookie domain, you might be able to get away with leaving it blank, but test out the sessions on each address you access the site with to make sure that it is possible to login.
Grahack is going to release a caching extension soon that does a lot of work with output buffers, that would be a good one to work from.
I'm about to be ready, but there are still some important questions to be solved, like the general use of this file: themes/page_end.php
I was about to decide to not caching it. I think I'm gonna ask the community...
It's not really true... I just check if a cache file could be used, if not, I let Vanilla execute fully, then grab the buffer to perhaps store it if cache is needed.
What I recently decided is to include in the buffer (and before the closing tags, that's what is tricky), a custom string (benchmark tools).
I found here some much heavier buffer processing!
Create a custom control that would be called after PageEnd.
In this control, you simply grab the buffer and act on it as you need.
This could be done in an extension (that you could share ).
Not tested. In a default.php file that you'll save under extensions/BufferTorture, write:
<?php class BufferTorture extends Control { function BufferTorture(){} function Render() { $content = ob_get_flush(); // here you can torture your $content // ... echo $content; exit; } } $Page->AddRenderControl( $Context->ObjectFactory->NewContextObject( $Context, 'BufferTorture' ), pow(2,20) );
Still the question, is it a clean way to execute as late as possible...