Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Getting past those pesky POST intercepts some hosts have
Today I encountered a problem with my site, Guntards.net. As I attempted to save a template after making a small change, the screen went blank and I was greeted with a server error. After some noodling about, I determined that everything else about the site worked fine, and that the only problem was in saving this particular template.
With some assistance from the folks here in this forum, I worked out that my host, Dreamhost, who have a reputation for being especially vigilant about uploading insecure code, did not like some curl code I had included in the template page and, detecting this code in the POST query, refused to load the page (ironically, I was using the curl code because Dreamhost won’t allow PHP include()
in templates either).
Several users hinted at a solution, but I was too dense to understand. Then tonight during my walk home I figgered it out and fixed the problem as soon as I got home. I’m posting this in case anyone else finds themselves in a similar situation.
First, for this particular site, I just have all my formatting up there on the one template, since I don’t have many different sections or anything. This meant that if I had offending code in the template, it would be impossible to edit the template in Txp. So the first thing I had to do was move the offending code into a form.
The code I wanted to use looked like this:
<txp:php>
$ch = curl_init('http://guntards.net/forum/extern.php?action=active&show=5');
curl_exec($ch);
curl_close($ch);
</txp:php>
So I created a form called active_forum_topics
and in it I put the following code:
<txp:php>
/* replace this line with curl code in the database */
</txp:php>
Then I inserted the following code into my template:
<txp:output_form form="active_forum_topics" />
After saving the template and reloading my page … nothing happened, which was fine. Everything was working so far.
Then I opened phpMyAdmin and browsed the txp_form
table until I found the record with my /* replace this line with curl code in the database */
code shown above. In phpMyAdmin, I replaced that line with the curl code I wanted. When I did this, Dreamhost again complained, but when I ran an export I noticed the code was inserted correctly. If the web interface didn’t work I simply would have imported the necessary code.
I reloaded my site and everything worked fine.
The beauty of this approach is that so long as active_forum_topics
remains unmolested, I can make any changes I want to the template without ever running into this problem again. And while Dreamhost doesn’t like seeing the code in the POST query, once you get past that the server runs the code just fine.
Offline