Ejemplo n.º 1
0
function zip_up_lang($language)
{
    global $tp;
    $ret = array();
    $ret['file'] = "";
    if ($_SESSION['lancheck'][$language]['total'] > 0 && !E107_DEBUG_LEVEL) {
        $ret = array();
        $ret['error'] = TRUE;
        $message = defined('LANG_LAN_34') ? LANG_LAN_34 : LANG_LAN_115;
        $ret['message'] = str_replace("[x]", $_SESSION['lancheck'][$language]['total'], $message);
        return $ret;
    }
    if (!isset($_SESSION['lancheck'][$language])) {
        $ret = array();
        $ret['error'] = TRUE;
        $ret['message'] = defined('LANG_LAN_27') ? LANG_LAN_27 : LANG_LAN_116;
        return $ret;
    }
    if (varset($_POST['contribute_pack']) && varset($_SESSION['lancheck'][$language]['total']) != '0') {
        $ret['error'] = TRUE;
        $ret['message'] = defined("LANG_LAN_29") ? LANG_LAN_29 : LANG_LAN_117;
        $ret['message'] .= "<br />";
        $ret['message'] .= defined('LANG_LAN_27') ? LANG_LAN_27 : LANG_LAN_116;
        return $ret;
    }
    if (!is_writable(e_FILE . "public")) {
        $ret['error'] = TRUE;
        $ret['message'] = LAN_UPLOAD_777 . " " . e_FILE . "public";
        return $ret;
    }
    if (is_readable(e_ADMIN . "ver.php")) {
        include e_ADMIN . "ver.php";
    }
    $core_plugins = array("alt_auth", "banner", "blogcalendar_menu", "calendar_menu", "chatbox_menu", "clock_menu", "comment_menu", "download", "faqs", "featurebox", "forum", "gallery", "gsitemap", "import", "links_page", "linkwords", "list_new", "log", "login_menu", "newforumposts_main", "newsfeed", "news", "newsletter", "online", "page", "pm", "poll", "rss_menu", "search_menu", "siteinfo", "tagwords", "tinymce", "trackback", "tree_menu", "user_menu");
    $core_themes = array("bootstrap");
    require_once e_HANDLER . 'pclzip.lib.php';
    list($ver, $tmp) = explode(" ", $e107info['e107_version']);
    if (!($locale = find_locale($language))) {
        $ret['error'] = TRUE;
        $file = "e107_languages/{$language}/{$language}.php";
        $def = defined('LANG_LAN_25') ? LANG_LAN_25 : LANG_LAN_119;
        $ret['message'] = str_replace("[x]", $file, $def);
        //
        return $ret;
    }
    global $THEMES_DIRECTORY, $PLUGINS_DIRECTORY, $LANGUAGES_DIRECTORY, $HANDLERS_DIRECTORY, $HELP_DIRECTORY;
    if ($HANDLERS_DIRECTORY != "e107_handlers/" || $LANGUAGES_DIRECTORY != "e107_languages/" || $THEMES_DIRECTORY != "e107_themes/" || $HELP_DIRECTORY != "e107_docs/help/" || $PLUGINS_DIRECTORY != "e107_plugins/") {
        $ret['error'] = TRUE;
        $ret['message'] = defined('LANG_LAN_26') ? LANG_LAN_26 : LANG_LAN_120;
        return $ret;
    }
    $newfile = e_MEDIA_FILE . "e107_" . $ver . "_" . $language . "_" . $locale . "-utf8.zip";
    $archive = new PclZip($newfile);
    $core = grab_lans(e_LANGUAGEDIR . $language . "/", $language, '', 0);
    $core_admin = grab_lans(e_BASE . $LANGUAGES_DIRECTORY . $language . "/admin/", $language, '', 2);
    $plugs = grab_lans(e_BASE . $PLUGINS_DIRECTORY, $language, $core_plugins);
    // standardized path.
    $theme = grab_lans(e_BASE . $THEMES_DIRECTORY, $language, $core_themes);
    $docs = grab_lans(e_BASE . $HELP_DIRECTORY, $language);
    $handlers = grab_lans(e_BASE . $HANDLERS_DIRECTORY, $language);
    // standardized path.
    $file = array_merge($core, $core_admin, $plugs, $theme, $docs, $handlers);
    $data = implode(",", $file);
    if ($archive->create($data, PCLZIP_OPT_REMOVE_PATH, e_BASE) == 0) {
        $ret['error'] = TRUE;
        $ret['message'] = $archive->errorInfo(true);
        return $ret;
    } else {
        $fileName = e_FILE . "public/" . $language . ".xml";
        if (is_readable($fileName)) {
            @unlink($fileName);
        }
        $fileData = '<?xml version="1.0" encoding="utf-8"?>
<e107Language name="' . $language . '" compatibility="' . $ver . '" date="' . date("Y-m-d") . '" >
<author name ="' . USERNAME . '" email="' . USEREMAIL . '" url="' . SITEURL . '" />
</e107Language>';
        if (file_put_contents($fileName, $fileData)) {
            $addTag = $archive->add($fileName, PCLZIP_OPT_ADD_PATH, 'e107_languages/' . $language, PCLZIP_OPT_REMOVE_PATH, e_FILE . 'public/');
            $_SESSION['lancheck'][$language]['xml'] = "Yes";
        } else {
            $_SESSION['lancheck'][$language]['xml'] = "No";
        }
        @unlink($fileName);
        $ret['file'] = $newfile;
        $ret['message'] = str_replace("../", "", e_MEDIA_FILE) . "<a href='" . $newfile . "' >" . basename($newfile) . "</a>";
        $ret['error'] = FALSE;
        return $ret;
    }
}
Ejemplo n.º 2
0
function zip_up_lang($language)
{
    if (is_readable(e_ADMIN . "ver.php")) {
        include e_ADMIN . "ver.php";
    }
    $tp = e107::getParser();
    /*
    $core_plugins = array(
    "alt_auth","banner_menu","blogcalendar_menu","calendar_menu","chatbox_menu",
    "clock_menu","comment_menu","content","featurebox","forum","gsitemap",
    "links_page","linkwords","list_new","log","login_menu",
    "newforumposts_main","newsfeed","newsletter","online",
    "other_news_menu","pdf","pm","poll","rss_menu",
    "search_menu","siteinfo","trackback","tree_menu","user_menu","userlanguage_menu",
    "usertheme_menu"
    );
    $core_themes = array("crahan","e107v4a","human_condition","interfectus","jayya",
    "khatru","kubrick","lamb","leaf","newsroom","reline","sebes","vekna_blue");
    */
    require_once e_HANDLER . 'pclzip.lib.php';
    list($ver, $tmp) = explode(" ", $e107info['e107_version']);
    $newfile = e_UPLOAD . "e107_" . $ver . "_" . $language . "_utf8.zip";
    $archive = new PclZip($newfile);
    $core = grab_lans(e_LANGUAGEDIR . $language . "/", $language);
    $plugs = grab_lans(e_PLUGIN, $language);
    $theme = grab_lans(e_THEME, $language);
    $file = array_merge($core, $plugs, $theme);
    $data = implode(",", $file);
    if ($archive->create($data) == 0) {
        return $archive->errorInfo(true);
    } else {
        if ($_POST['contribute_pack']) {
            $full_link = $tp->createConstants($newfile);
            $email_message = "Site: " . SITENAME . "\n\t\t\tUser: "******"\n\n\t\t\tIP:" . USERIP . "\n\t\t\t...would like to contribute the following language pack for e107 v" . $e107info['e107_version'] . ".\n\t\t\tPlease see attachment.";
            $subject = basename($newfile);
            //TODO - send email to languagepack@e107.org with attachment.
        }
        return LANG_LAN_22 . " (" . str_replace("../", "", e_UPLOAD) . "<a href='" . $newfile . "' >" . basename($newfile) . "</a>).";
    }
}