<?php
class defaultAction extends Action
{
    function execute(&$controller, &$request)
    {
        $lang = mosGetParam( $_REQUEST, 'lang' ); 
        $root = mamboCore::get('rootPath');            
        $fp = fopen("../configuration.php","r");
        $config = "";
        $session =& $request->session();
        
     
        while(!feof($fp)){
            $buffer = fgets($fp,4096);
            if (strstr($buffer,"\$mosConfig_lang =")){
                $config .= "\$mosConfig_lang = \"{$lang}\";\n";
            } else {
                $config .= $buffer;
            }
        }
        fclose($fp);
        if ($fp = fopen("../configuration.php","w")){
            fputs($fp, $config, strlen($config));
            fclose($fp);
            $session['mosmsg'] =  T_('Default Language succesfully updated!');
        } else {
            $session['mosmsg'] =  T_('Error! Make sure that configuration.php is writeable.');
        }                   
        return $controller->redirect();
    }
}
?>