Changeset 1349

Show
Ignore:
Timestamp:
12/04/07 11:15:14 (1 year ago)
Author:
rho
Message:

improved installer

  • try to create htaccess
  • try to set RewriteBase? based on wwwroot

Signed-off: Rolando Espinoza La fuente <rho@prosoftpeople.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/install.php

    r1327 r1349  
    384384    if (config_submitted() && config_validate()) { 
    385385        if (config_write_file()) { 
     386            config_copy_htaccess(); 
    386387?> 
    387388            <p><?=t('Your configuration file has been saved, you can now proceed with the installation.') ?></p> 
     
    768769 
    769770/** 
     771 * Try to copy htaccess-dist to .htaccess 
     772 * @return bool 
     773 */ 
     774function config_copy_htaccess() { 
     775    $path = dirname(__FILE__) . '/'; 
     776    $src = $path . 'htaccess-dist'; 
     777    $dst = $path . '.htaccess'; 
     778    $result = false; 
     779 
     780    if (!file_exists($dst) && is_readable($src) && is_writable($path)) { 
     781        $htaccess = file_get_contents($src); 
     782        // Try to set RewriteBase 
     783        include($path.'config.php'); 
     784        if (!empty($CFG->wwwroot)) { 
     785            $webpath = preg_replace("#^https?://[\w\.:-]+(/[\w-_\./]*)$#i", "$1", $CFG->wwwroot); 
     786            if (!empty($webpath) && strpos($webpath, '://') === false && $webpath != '/') { 
     787                $htaccess = preg_replace("|#RewriteBase /[^\w]|", "RewriteBase $webpath\n", $htaccess); 
     788            } 
     789        } 
     790 
     791        $f = @fopen($dst, 'w'); 
     792        if ($f) { 
     793            @fwrite($f, $htaccess); 
     794            @fclose($f); 
     795            $result = true; 
     796        } 
     797    } 
     798 
     799    return $result; 
     800} 
     801 
     802/** 
    770803 * Configuration template file 
    771804 * @return string