FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 05-01-2012, 05:07 PM   Postid: 181348
m1k3ry4n
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: Dec 2010
Location: Ithaca, NY
Posts: 14
xmlhttprequest POST from subdomain 405 error

I'm using OpenLayers to send a POST request to a PHP script within my subdomain and I get the http error 405 Method Not Allowed.

I'm using OpenLayer's Request namespace to do this.

When I create Request namespace it looks something like:

OpenLayers.Request.POST({
url:"/sites/default/files/scripts/print/print.php",
data:OpenLayers.Util.getParameterString({
width:size.w,
height:size.h
}),
headers:{'Content-Type':'application/x-www-form-urlencoded'},
callback: processResults
});

On my local Ubuntu machine within Drupal, it works fine. Now that I'm up on the FQ server, on a subdomain and in Drupal, I'm getting this error. (The main www is also a Drupal installation. This Drupal installation resides in www/example.)

I'm guessing that the subdomain/Drupal is the crux of the problem, and there might be a magic setting somewhere within FQ that I don't know about that would solve this.

Anyone have any ideas?

m1k3ry4n is offline   Reply With Quote
Old 05-01-2012, 05:12 PM   Postid: 181349
 Terra
CTO FutureQuest, Inc.
 
Terra's Avatar
 
Join Date: Jun 1998
Location: Z'ha'dum
Posts: 7,709
Re: xmlhttprequest POST from subdomain 405 error

Please send a message to the service desk stating which domain you are having this '405' status return on...

Most likely you are hitting a blanket security control in place to protect sites from exploitable xmlrpc.php...
__________________
--
Terra
sysAdmin
FutureQuest, Inc.
http://www.FutureQuest.net
Terra is offline   Reply With Quote
Old 05-02-2012, 12:35 PM   Postid: 181350
m1k3ry4n
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: Dec 2010
Location: Ithaca, NY
Posts: 14
Re: xmlhttprequest POST from subdomain 405 error

Will do. Thanks.
m1k3ry4n is offline   Reply With Quote
Old 05-02-2012, 04:17 PM   Postid: 181351
 Terra
CTO FutureQuest, Inc.
 
Terra's Avatar
 
Join Date: Jun 1998
Location: Z'ha'dum
Posts: 7,709
Re: xmlhttprequest POST from subdomain 405 error

For those following this thread, the final conclusion on this was the 405 status code was a result of a Drupal security setting in a .htaccess file...

Specifically:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006

Which in turn disabled the ability for PHP to execute any scripts...

It was no different from trying to send POST data to a static file, for which Apache would respond with, "Hey - why are you sending dynamic data to a static file that can't process it?!? 405 it is for you netizen!!!"
__________________
--
Terra
sysAdmin
FutureQuest, Inc.
http://www.FutureQuest.net
Terra is offline   Reply With Quote
Old 05-04-2012, 11:56 AM   Postid: 181352
m1k3ry4n
Registered User

Forum Notability:
0 pts: Even-handed
[Post Feedback]
 
Join Date: Dec 2010
Location: Ithaca, NY
Posts: 14
Re: xmlhttprequest POST from subdomain 405 error

Thanks, Terra.

As it turns out, I was not doing things The Drupal Way <sup>TM</sup> and I got busted.

I had my script in the sites/default/files directory. This is a location where users can upload content if you allow that sort of thing. There's the potential security risk of someone uploading a malicious script there, so the auto-generated .htaccess file effectively puts the hex on POSTing. When this was implemented, it seemed to upset a few people. But there is a simple way around it, and you don't even need to reconfigure your server or hack apart your core Drupal files.

What you are supposed to do when you want to add things like PHP scripts to Drupal is create a module. As it turns out in the case of wanting to run a script you don't even need to strictly create a module, you can just put the script in the modules directory sites/all/modules. You'd probably want to at least create a directory for it: sites/all/modules/custom/yourscriptdirectory.

Drupal has some documentation on creating modules, but typically their documentation is lacking. I've found the book Learning Drupal 6 Module Development to be much more helpful.

Files in sites/all/modules directory are web accessible and since technically only a user with FTP/SSH access could put something there, I assume Drupal deemed it a safe location, so there's no .htaccess file with the SetHandler line.
m1k3ry4n is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 05:32 PM.


Running on vBulletin®
Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2014 FutureQuest, Inc.
FutureQuest, Inc.