Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/languagenew.php
Строк: 98
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_nuevo_languagenew
{
private $db;
private $cache;
private $filter;
public function __construct()
{
$this->db = VF::factory('database');
$this->cache = VF::factory('cache');
$this->filter = VF::factory('filter');
}
public function render()
{
$errors = array();
$messages = array();
$warnings = array();
$filename = '';
$languages=array();
$ldir = BASE_DIR."/misc/nuevo/languages";
if (is_dir($ldir)) {
$ln = opendir($ldir);
while (($file = readdir($ln)) !== false)
{
$fname=strtolower($file);
if (substr($fname, -4)=='.php') {
$lang = str_replace('.php','',$fname);
$languages[] = $lang;
}
}
closedir($ln);
}
include (BASE_DIR."/misc/nuevo/languages/en-US.php");
$deflang=$lng;
if(isset($_POST['create_language'])) {
$filename = $_POST['filename'];
if(strlen($filename)!=5)
$errors[]='Invalid language filename';
if(!$errors) {
if(substr($filename,2,1) !='-')
$errors[]='Invalid language filename';
}
if(!$errors) {
if(in_array($filename,$languages)) {
$errors[] = 'Language file already exists';
}
}
$buffer[] = '<?php';
$data = array();
forEach($_POST as $key => $value) {
if(strlen($key)>3 && $key!= 'create_language' && $key!='filename') {
$data[] = array('key'=>$key,'val'=>$value,'def'=>$lng[$key]);
if(strlen($value)<1) $value= $deflang[$key];
$buffer[] = '$lng['' .$key. ''] = '' .str_replace(''', ''', $value). '';';
}
}
$buffer[] = '?>';
if(!$errors) {
$save = implode("n", $buffer);
$path = BASE_DIR."/misc/nuevo/languages/".$filename.".php";
//file_put_contents($path, $save);
if (!$f = @fopen ($path, 'w'))
$errors[] = "File not opened to write";
if (!is_writable ($path))
@chmod ($path, 0777);
if (!is_writable ($path))
$errors[] = "File not writeable";
if (@fwrite ($f, $save) === false)
$errors[] = "File could not be saved";
clearstatcache();
}
if(!$errors) {
header('Location: '.BASE_URL.'/admin/index.php?q=nuevo/language');
}
}
else {
$data=array();
foreach ($deflang as $key =>$value) {
$data[] = array('key'=>$key,'val'=>'','def'=>$deflang[$key]);
}
}
$tpl = &VF::factory('template');
$tpl->menu = 'nuevo';
$tpl->submenu = 'nuevo_languagenew';
$tpl->meta_title = 'Admin::Nuevo::Languages';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->languages = $languages;
$tpl->datalang = $data;
$tpl->filename = $filename;
$tpl->currlang = $clang;
$tpl->pmenu = 'languagenew';
$tpl->load(array('header', 'nuevo_languagenew', 'footer'));
$tpl->display();
}
}
?>