Location: PHPKode > projects > XennoBB > xennobb/admin/langs.php
<?php
/*

  Copyright (C) 2005-2011 UserDot
  Visit XennoBB at www.userdot.net/projects/xennobb
  Originally based on PunBB www.punbb.org

  XennoBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  XennoBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA 02110-1301 USA

 */
define('IN_FORUM_ADMIN', 1);
require dirname(__FILE__) . '/../include/init.php';
if (!BB_Admin_Functions::Check_Permissions('langs'))
    BB_Functions::Message($lang['No permission']);
$cms_enable_lang = (isset($_GET['enable']) && in_array($_GET['enable'], $cms_languages->All_Elements())) ? $_GET['enable'] : '';
$cms_delete_lang = (isset($_GET['delete']) && in_array($_GET['delete'], $cms_languages->All_Elements())) ? $_GET['delete'] : '';
$cms_pack_lang = (isset($_GET['pack']) && in_array($_GET['pack'], $cms_languages->All_Elements())) ? $_GET['pack'] : '';
$cms_config_lang = (isset($_GET['config']) && in_array($_GET['config'], $cms_languages->All_Elements())) ? $_GET['config'] : '';
$cms_info_lang = (isset($_GET['info']) && in_array($_GET['info'], $cms_languages->All_Elements())) ? $_GET['info'] : '';
$cms_custom_title_page = $lang['Admin'] . $lang['manage_langs'];
if (is_file(FORUM_ROOT . 'include/templates/' . $forum_user['template'] . '/forum_admin.tpl'))
    $cms_main_template = FORUM_ROOT . 'include/templates/' . $forum_user['template'] . '/forum_admin.tpl';
else
    $cms_main_template = FORUM_ROOT . 'include/templates/Default/forum_admin.tpl';
require FORUM_ROOT . 'include/header.php';
if (is_writable(FORUM_ROOT . 'include/languages') && !empty($_GET['lang_url']))
{
    $lang_url = BB_Input::Trim($_GET['lang_url']);
    $parsed_url = parse_url($lang_url);
    if (empty($parsed_url['scheme']) || !preg_match('/^http|ftp$/', $parsed_url['scheme']) || empty($parsed_url['host']) || empty($parsed_url['path']))
        BB_Functions::Message($lang['import_url_wrong']);
    else
    {
        if (($err = $cms_languages->Install($lang_url)) !== true)
            BB_Functions::Message($err);
        else
        {
            BB_Admin_Functions::Log_Action('Import language from ' . $lang_url, 3);
            BB_Functions::Redirect('langs.php', $lang['import_lang_ok']);
        }
    }
}
if ($cms_enable_lang != '')
{
    $cms_settings->Set_Namespace('xennobb');
    $res = $cms_settings->Save('bb_default_lang', $cms_enable_lang);
    $cms_settings->Set_Namespace('');
    if ($res)
    {
        BB_Admin_Functions::Log_Action("Language " . $cms_enable_lang . ' set as default', 1);
        header('location: langs.php');
        exit;
    }
    else
        BB_Functions::Message($lang['unable_update_config']);
}
elseif ($cms_pack_lang != '')
{
    $info_extension = array();
    if (file_exists($cms_languages->path . $cms_pack_lang . '/info.php'))
        require $cms_languages->path . $cms_pack_lang . '/info.php';
    else
        $info_extension['version'] = '';
    $fname = 'lang-' . $cms_pack_lang . '-' . $info_extension['version'];
    $cms_lang_root = FORUM_ROOT . 'include/languages';
    if (($res = BB_Files::Make_Package($cms_pack_lang, $cms_lang_root . '/' . $cms_pack_lang, $cms_lang_root . '/', 1)) !== false)
    {
        if (($fp = fopen(FORUM_ROOT . 'var/export/' . $fname . '.pkg.gz', 'w')) !== false)
        {
            fwrite($fp, $res, BB_Input::Strlen($res));
            fclose($fp);
            BB_Admin_Functions::Log_Action('Export language ' . $cms_pack_lang, 0);
            BB_Functions::Redirect('langs.php', $lang['export_ok']);
        }
        else
            BB_Functions::Message($lang['export_error']);
    }
    else
        BB_Functions::Message($lang['export_error']);
}
elseif ($cms_delete_lang != '' && is_writable($cms_languages->path))
{
    BB_Files::Delete_Tree($cms_languages->path . $cms_delete_lang);
    BB_Admin_Functions::Log_Action('Delete language ' . $cms_delete_lang, 3);
    BB_Functions::Redirect('langs.php', $lang['config_updated']);
}
elseif ($cms_config_lang != '')
{
    ?>
    <div class="blockform">
        <h2><span><?php echo $lang['edit_lang']; ?></span></h2>
        <div class="fakeform">
            <div class="inform">
                <div class="infldset file" style="padding:10px">
                    <table cellspacing="0">
                        <?php
                        while (list($key, $input) = @each($lang))
                        {
                            ?>
                            <tr>
                                <th scope="row" style="width:200px"><?php echo $key; ?></th>
                                <td><input type="text" size="40" class="textbox" value="<?php echo $input; ?>" /></td>
                            </tr>
        <?php
    }
    ?>
                    </table>
                </div>
            </div>
            <div><input type="button" class="b1" onclick="javascript:history.go(-1)" value="<?php echo $lang['Go back']; ?>"></div>
        </div>
    </div>
    <?php
}
elseif ($cms_info_lang != '')
{
    if (file_exists($cms_languages->path . $cms_info_lang . '/info.php'))
    {
        $info_extension = array();
        require $cms_languages->path . $cms_info_lang . '/info.php';
        ?>
        <div class="blockform">
            <h2><span><?php echo $lang['info_lang']; ?></span></h2>
            <div class="fakeform">
                <div class="inform">
                    <div class="infldset file" style="padding:10px">
                        <table cellspacing="0" >
                            <tr>
                                <th style="width:150px" scope="row"><?php echo $lang['Name']; ?></th>
                                <td><strong><?php echo BB_Admin_Functions::Get_Name($cms_info_lang, 'lang'); ?></strong></td>
                            </tr>
                            <tr>
                                <th scope="row"><?php echo $lang['identifier']; ?></th>
                                <td><?php echo $cms_info_lang; ?></td>
                            </tr>
                            <tr>
                                <th scope="row"><?php echo $lang['Version']; ?></th>
                                <td><?php echo $info_extension['version']; ?></td>
                            </tr>
                            <tr>
                                <th scope="row"><?php echo $lang['Author']; ?></th>
                                <td><strong><?php echo $info_extension['author']; ?></strong></td>
                            </tr>
                            <tr>
                                <th scope="row"><?php echo $lang['E-Mail']; ?></th>
                                <td><a href="mailto:<?php echo $info_extension['email']; ?>"><?php echo $info_extension['email']; ?></a></td>
                            </tr>
                            <tr>
                                <th scope="row"><?php echo $lang['Website']; ?></th>
                                <td><a href="<?php echo $info_extension['website']; ?>"><?php echo $info_extension['website']; ?></a></td>
                            </tr>
                            <tr>
                                <th scope="row"><?php echo $lang['Info']; ?></th>
                                <td><?php echo $info_extension['info']; ?></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div><input type="button" class="b1" onclick="javascript:history.go(-1)" value="<?php echo $lang['Go back']; ?>"></div>
            </div>
        </div>
        <?php
    }
    else
        BB_Functions::Message($lang['no_info_file']);
}
else
{
    ?>
    <div class="blockform">
        <h2><span><?php echo $lang['Install']; ?></span></h2>
        <div class="box">
            <form action="langs.php" method="get">
                <div class="inform">
                    <label><?php echo $lang['give_url_lang']; ?> :<br />
                        <input class="textbox" size="50" name="lang_url" id="lang_url" type="text" />
                        <input type="submit" class="b1" value="<?php echo $lang['import']; ?>" /></label>
                    <input type="hidden" name="p" value="toolsmng" />
                </div>
            </form>
        </div>
    </div>
    <div class="blockform">
        <h2><span><?php echo $lang['manage_langs']; ?></span></h2>
        <div class="box">
            <div class="fakeform">
                <div class="infldset file" style="padding:15px">
                    <table cellspacing="0" >
    <?php
    foreach ($cms_languages->All_Elements() as $l)
    {
        $curent_lang_name = BB_Admin_Functions::Get_Name($l, 'lang');
        echo '<tr>' . "\n" . '<th style="width:150px" scope="row">' . $curent_lang_name . '</th>' . "\n";
        echo BB_Admin_Functions::Check_Extension($l, $curent_lang_name, 'lang') . '</tr>';
    }
    ?>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <?php
}
require FORUM_ROOT . 'include/footer.php';
?>
Return current item: XennoBB