示例#1
0
function JBPLUG_merge_english_default_files()
{
    JBPLUG_require_all_plugins();
    global $_JB_PLUGINS;
    $source_label = array();
    // load in the main english_default labels
    include_once jb_get_english_default_dir() . "english_default.php";
    // the master lang/english_default
    $source_label = array_merge($source_label, $label);
    // default english labels
    $label = array();
    $last_mtime = filemtime(jb_get_english_default_dir() . "english_default.php");
    $sql = "SELECT * FROM lang  ";
    $result = JB_mysql_query($sql);
    // Now merge the english_default.php strings with the language files
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "Merging language strings for " . jb_escape_html($row['lang_filename']) . "..<br>";
        /// for each of the plugins, load in the plugin's english default
        foreach ($_JB_PLUGINS as $class => $obj) {
            $plugin_english_default_path = dirname(__FILE__) . "/plugins/{$class}/lang/english_default.php";
            if (!file_exists($plugin_english_default_path)) {
                continue;
                // skip
            }
            include_once $plugin_english_default_path;
            // load the labels from the plugins
            $source_label = array_merge($source_label, $label);
            $label = array();
            $m_time = filemtime($plugin_english_default_path);
            if ($m_time > $last_mtime) {
                $last_mtime = $m_time;
            }
        }
        // now that we have all the source labels, we can merge them with
        // the langauge file. Any key that is present in the source, but
        // not present in the language file then we merge it.
        if (is_writable(jB_get_lang_dir() . $row['lang_filename'])) {
            if ($last_mtime > filemtime(jB_get_lang_dir() . $row['lang_filename'])) {
                // Now merge the english defaults with the langauge file
                include jB_get_lang_dir() . $row['lang_filename'];
                // customized labels
                $dest_label = array_merge($source_label, $label);
                $label = array();
                // write out the new file:
                $out = "<?php\n";
                $out .= "///////////////////////////////////////////////////////////////////////////\n";
                $out .= "// IMPORTANT NOTICE\n";
                $out .= "///////////////////////////////////////////////////////////////////////////\n";
                $out .= "// This file was generated by a script!\n";
                $out .= "// (JBPLUG_merge_english_default_files() function)\n";
                $out .= "// Please do not edit the language files by hand\n";
                $out .= "// - please always use the Language Translation / Editing tool found\n";
                $out .= "// in Admin->Languages\n";
                $out .= "// To add a new phrase for the \$label, please edit english_default.php, and\n";
                $out .= "// then vist Admin->Main Summary where the language files will be\n";
                $out .= "// automatically merged with this file.\n";
                $out .= "///////////////////////////////////////////////////////////////////////////\n";
                foreach ($dest_label as $key => $val) {
                    $val = str_replace("'", "\\'", $val);
                    $out .= "\$label['{$key}']='" . JB_clean_str($val) . "'; \n";
                }
                $out .= "?>\n";
                $handler = fopen(jB_get_lang_dir() . $row['lang_filename'], "w");
                fputs($handler, $out);
                fclose($handler);
            }
        } else {
            echo "<font color='red'><b>- " . jB_get_lang_dir() . $row['lang_filename'] . " file is not writable. Give write permissions (" . decoct(JB_NEW_FILE_CHMOD) . ") to " . jB_get_lang_dir() . $row['lang_filename'] . " file and then disable & re-enable this plugin</b></font><br>";
        }
        echo " Done.<br>";
    }
}
示例#2
0
# You can obtain one at http://mozilla.org/MPL/2.0/.
###########################################################################
define('JB_IGNORE_INPUT_FILTER', true);
require "../config.php";
require dirname(__FILE__) . "/admin_common.php";
JB_admin_header('Admin -> Plugins');
if (JB_PLUGIN_SWITCH != 'YES') {
    echo "<b>This feature is not enabled are not enabled. Please go to <a href='edit_config.php'>Main Config</a> to enable plugins.</b>";
    die;
}
if (JB_DEMO_MODE == 'YES') {
    $JBMarkup->ok_msg('Demo mode is enabled - plugins cannot be enabled or disabled');
} else {
    JB_show_lang_permission_warning();
}
JBPLUG_require_all_plugins();
if (JB_DEMO_MODE != 'YES') {
    if ($_REQUEST['action'] == 'enable') {
        // JB_ENABLED_PLUGINS
        $_JB_PLUGINS[$_REQUEST['plugin']]->enable();
        echo "<p>";
        echo "<b>Plugin Enabled.</b> <a href='plugins.php?plugin=" . jb_escape_html($_REQUEST['plugin']) . "'>Click Here to Continue</a>";
        echo "</p>";
        JB_admin_footer();
        die;
    }
    if ($_REQUEST['action'] == 'disable') {
        $_JB_PLUGINS[$_REQUEST['plugin']]->disable();
        echo "<p>";
        echo "<b>Plugin Disabled.</b> <a href='plugins.php'>Click Here to Continue</a>";
        echo "</p>";