The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Autotomatically resolve base/root path for Formtools
Just a suggestion:

In the Formtools main config.php file, use the following(?) to define $g_root_url and $g_root_dir:

PHP Code:
$g_root_url  = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" "http");
$g_root_url .= "://".$_SERVER['HTTP_HOST'];
$g_root_url .= str_replace("/global/".basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$g_root_dir  $_SERVER['DOCUMENT_ROOT'];
$g_root_dir .= str_replace("/global/".basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 

I can't remember how these are defined by default but the above snippet will automatically calculate both the base and root paths for FormTools (you could even go as far as excluding it from the config file altogether and place it in the core).

I've used something similar before on Codeigniter and thought it may prove useful for future releases, Ben.
Hi Crunchers,

Yeah, I had the same thought! In fact, I did something like that on another script of mine for a while. But I got burned by it: the SCRIPT_NAME and some other commonly available $_SERVER contents weren't being doled up on a particular the server. According to the PHP specs, technically they may not be available. Chances are it was just an anomaly, but it's made me nervous about relying on it.

Eventually, what I'll do is examine the way other popular PHP scripts (like Wordpress, Drupal etc) are doing it these days. If I *can* do away with having those variables set, that would be terrific.

- Ben
PITA problem you ran into there. One way round it, I suppose, is to check for this anomaly during installation and fall back on prompting the user to adjust it manually if the condition fails. I guess the flip-side is you'd be creating more work re:logic. Time better spent elsewhere etc.

Just thinking out loud really...

Thanks, Ben.
But very welcome! I appreciate the ideas - it's good to get reminders of these things. There's always things that can be improved.

- Ben

Forum Jump:

Users browsing this thread: 1 Guest(s)