<?PHP


//FOR ajax language

require '../inc/page.zip.php';
require '../inc/conf.php';
require _Core.'/extender.php';
require _Core.'/template.php';
require _Core.'/engine.php';


$self = new Engine;
$self->__init();
$self->model = $_GET['model'];
$self->page = $_GET['page'];

$replacement = $_GET['replacement'];
if(is_array($replacement)){

	foreach($replacement as $k => $v){

		if(preg_match('/\$/i', $v)) eval('$v = '.$v.';');

		$_GET['replacement'][$k] = $v;
	}
}

if(!is_file(_RootFolder.'/tmp/script/language.js')){

	if(!is_dir(_RootFolder.'/tmp/script')) mkdir(_RootFolder.'/tmp/script');
	file_put_contents(_RootFolder.'/tmp/script/language.js', 'var language = [];');
}

$fcontent = file_get_contents(_RootFolder.'/tmp/script/language.js');

$language = $self->language($_GET['language_key'], $_GET['replacement']);
if(!preg_match("/language\[\'".$_GET['language_key']."\']/i", $fcontent))
	file_put_contents(_RootFolder.'/tmp/script/language.js', file_get_contents(_RootFolder.'/tmp/script/language.js')."\n".'language[\''.$_GET['language_key'].'\'] = \''.addslashes($language).'\';');
echo $language;
$self->end();

?>