Changeset 293

Show
Ignore:
Timestamp:
07/26/07 07:30:10 (1 year ago)
Author:
bermiferrer
Message:

Adding some changes for those who unpack the framework and point their browser to the framework folder.
This includes add .htaccess files with rules for preventing access to all directories but public.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/application_controller.php

    r285 r293  
    1616class ApplicationController extends AkActionController  
    1717{ 
     18 
    1819} 
    1920 
  • trunk/app/models/framework_setup.php

    r290 r293  
    329329%AK_FRAMEWORK_DIR 
    330330 
     331%AK_ASSET_URL_PREFIX 
     332 
    331333include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'boot.php'); 
    332334 
     
    360362            $settings['%AK_FRAMEWORK_DIR'] = defined('AK_FRAMEWORK_DIR') ? 
    361363            "defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', '".AK_FRAMEWORK_DIR."');" : ''; 
     364 
     365 
     366            $asset_path = $this->_getAssetBasePath(); 
     367            if(!empty($asset_path)){ 
     368                $settings['%AK_ASSET_URL_PREFIX'] = "define('AK_ASSET_URL_PREFIX','/".trim($this->getUrlSuffix(),'/').'/'.$asset_path."');"; 
     369            }else{ 
     370                $settings['%AK_ASSET_URL_PREFIX'] = ''; 
     371            } 
     372 
    362373        } 
    363374 
     
    409420        $file_2_content = @Ak::file_get_contents($file_2); 
    410421 
    411         empty($file_1_content) ? null : @Ak::file_put_contents($file_1, str_replace('# RewriteBase /framework',' RewriteBase '.$this->getUrlSuffix(), $file_1_content)); 
    412         empty($file_2_content) ? null : @Ak::file_put_contents($file_2, str_replace('# RewriteBase /framework',' RewriteBase '.$this->getUrlSuffix(), $file_2_content)); 
     422        $url_suffix = $this->getUrlSuffix(); 
     423 
     424        $url_suffix = $url_suffix[0] != '/' ? '/'.$url_suffix : $url_suffix; 
     425 
     426        empty($file_1_content) ? null : @Ak::file_put_contents($file_1, str_replace('# RewriteBase /framework',' RewriteBase '.$url_suffix, $file_1_content)); 
     427        empty($file_2_content) ? null : @Ak::file_put_contents($file_2, str_replace('# RewriteBase /framework',' RewriteBase '.$url_suffix, $file_2_content)); 
    413428    } 
    414429 
     
    435450    { 
    436451        $application_name = array_pop(explode('/',AK_SITE_URL_SUFFIX)); 
    437         $application_name = empty($application_name) ? substr(AK_BASE_DIR, strrpos(AK_BASE_DIR, DS)+1) : $application_name;  
     452        $application_name = empty($application_name) ? substr(AK_BASE_DIR, strrpos(AK_BASE_DIR, DS)+1) : $application_name; 
    438453        return empty($application_name) ? 'my_app' : $application_name; 
    439454    } 
     
    698713        if($this->hasUrlSuffix()){ 
    699714            $url_suffix = trim($this->getUrlSuffix(),'/'); 
     715            $asset_path = $this->_getAssetBasePath(); 
     716            if(!empty($asset_path)){ 
     717                $url_suffix = $asset_path.'/'.$url_suffix; 
     718            } 
    700719            foreach ($this->stylesheets as $stylesheet) { 
    701720                $filename = AK_PUBLIC_DIR.DS.'stylesheets'.DS.$stylesheet.'.css'; 
     
    705724        } 
    706725 
     726    } 
     727 
     728    function _getAssetBasePath() 
     729    { 
     730        return file_exists(AK_BASE_DIR.DS.'index.php') ? 'public' : ''; 
    707731    } 
    708732 
  • trunk/index.php

    r2 r293  
    1515 */ 
    1616 
    17 if(!@include('.'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){ 
    18     define('AK_ENVIRONMENT', 'setup'); 
    19         require('app'.DIRECTORY_SEPARATOR.'controllers'.DIRECTORY_SEPARATOR.'framework_setup_controller.php'); 
    20         exit; 
    21 
    22  
    23 include(AK_PUBLIC_DIR.DS.'index.php'); 
     17include('public'.DIRECTORY_SEPARATOR.'index.php'); 
    2418 
    2519?> 
  • trunk/lib/AkActionView/helpers/asset_tag_helper.php

    r285 r293  
    222222        $source = $source[0] != '/' && !strstr($source,':') ? "/$dir/$source" : $source; 
    223223        $source = !strstr($source,'.') ? "$source.$ext" : $source; 
    224         $source = !preg_match('/^[-a-z]+:\/\//',$source) ? '/'.ltrim(dirname(@$_SERVER['SCRIPT_NAME']).$source,'/\\') : $source; 
     224        $source = !preg_match('/^[-a-z]+:\/\//',$source) ? AK_ASSET_URL_PREFIX.$source : $source; 
    225225        $source = strstr($source,':') ? $source : AK_ASSET_HOST.$source; 
    226226        $source = substr($source,0,2) == '//' ? substr($source,1) : $source; 
     227         
    227228        return $source; 
    228229    } 
  • trunk/public/index.php

    r2 r293  
    1515 */ 
    1616 
    17 // defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', '/path/to/the/framework'); 
     17defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', '/Volumes/Files/Projects/akelos_framework/trunk'); 
    1818 
    1919/** 
     
    2121 */ 
    2222if(!defined('AK_CONFIG_INCLUDED')){ 
    23     if(!file_exists('..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){ 
     23    if(!file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php')){ 
    2424        define('AK_ENVIRONMENT', 'setup'); 
    25         require('..'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'controllers'.DIRECTORY_SEPARATOR.'framework_setup_controller.php'); 
     25        error_reporting(E_ALL); 
     26        @ini_set('display_errors', 1); 
     27        require(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR. 
     28        'app'.DIRECTORY_SEPARATOR.'controllers'.DIRECTORY_SEPARATOR.'framework_setup_controller.php'); 
    2629        exit; 
    2730    }else{ 
    28         include_once('..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
     31        include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 
    2932    } 
    3033} 
  • trunk/script/setup

    r281 r293  
    9494            } 
    9595            $this->yield("\n    Could not create a symbolic link of ".$this->options['directory'].DS.'public'.' at '.$this->options['public_html']); 
     96 
     97        }else{ 
     98            $this->_addRootLevelDispatcher(); 
     99            $this->_addHtaccessDirectoryProtection(); 
    96100        } 
    97101        return false; 
     
    111115            } 
    112116        } 
     117    } 
     118 
     119    function _addRootLevelDispatcher() 
     120    { 
     121        $this->_copyFile($this->options['source'].DS.'index.php'); 
     122        $this->_copyFile($this->options['source'].DS.'.htaccess'); 
     123    } 
     124 
     125    function _addHtaccessDirectoryProtection() 
     126    { 
     127        foreach($this->source_tree as $k=>$node){ 
     128            $folder = array_shift(array_keys($node)); 
     129            $path = $this->options['directory'].DS.$folder; 
     130            if(is_dir($path) && !file_exists($path.DS.'.htaccess') && $folder != 'public'){ 
     131                file_put_contents($path.DS.'.htaccess', "order allow,deny\ndeny from all"); 
     132            } 
     133        } 
     134 
    113135    } 
    114136 
  • trunk/test/unit/lib/AkActionView/helpers/_HelpersUnitTester.php

    r2 r293  
    2828    function HelpersUnitTester() 
    2929    { 
    30         $base_url = parse_url(dirname(@$_SERVER['SCRIPT_NAME'])); 
    31         $this->testing_url_path = '/'.ltrim($base_url['path'], '/'); 
     30        $this->testing_url_path = AK_ASSET_URL_PREFIX; 
    3231    } 
    3332}