Файл: adultscript-2.0.3-pro/files/admin/modules/language/components/export.php
Строк: 59
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_language_export extends VModule_Admin_language
{
public function __construct()
{
}
public function render()
{
$db = VF::factory('database');
$errors = array();
$messages = array();
$code = (isset($_GET['code'])) ? trim($_GET['code']) : NULL;
$db->query("SELECT * FROM #__language WHERE code = '".$db->escape($code)."' LIMIT 1");
if (!$db->affected_rows()) {
$_SESSION['error'] = 'Invalid language code! Are you sure this language exists!';
VF::redirect(ADMIN_URL.'/index.php?q=language/manage');
}
$language = $db->fetch_assoc();
$db->query("SELECT name, description, type, file
FROM #__language_files
WHERE code = '".$db->escape($code)."'
ORDER BY name ASC");
$files = $db->fetch_rows();
$xml = array();
$xml[] = '<?xml version="1.0" encoding="utf8"?>';
$xml[] = '<language>';
$xml[] = ' <name>'.$language['name'].'</name>';
$xml[] = ' <code>'.$language['code'].'</code>';
$xml[] = ' <flag>'.$language['flag'].'</flag>';
$xml[] = ' <files>';
foreach ($files as $file) {
$xml[] = ' <file>';
$xml[] = ' <name>'.$file['name'].'</name>';
$xml[] = ' <description>'.$file['description'].'</description>';
$xml[] = ' <type>'.$file['type'].'</type>';
$xml[] = ' <translation>';
$translation = unserialize($file['file']);
foreach ($translation as $key => $value) {
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$xml[] = ' <string key="'.$key.'" value="'.$value.'"/>';
}
$xml[] = ' </translation>';
$xml[] = ' </file>';
};
$xml[] = ' </files>';
$xml[] = '</language>';
$xml = implode("n", $xml);
$path = TMP_DIR.'/downloads/'.$code.'.export.xml';
file_put_contents($path, $xml);
VDownload::force($path);
}
}