Example #1
0
/**
 * Update content of a default page.
 * 
 * If $tag parameter is an array, it just passes elements of this array one by one to itself.
 * The value 'HomePage' is a special one: it will be replaced by the configured value $config['root_page'].
 * The content of the page is read at a file named with $tag, located in setup/default_pages.
 * @param mixed $tag	string or array of strings
 * @param resource $dblink
 * @param mixed $config
 * @param string $lang_defaults_path	mandatory: validated directory for language-specific default pages
 * @param string $lang_defaults_fallback_path	mandatory: validated directory for default pages in system default language
 * @access public
 * @return void
 * @todo avoid recursion: make a single tag into an array of one and then just loop over the tags
 */
function update_default_page($tag, $dblink, $config, $lang_defaults_path, $lang_defaults_fallback_path, $note = '')
{
    if (is_array($tag)) {
        foreach ($tag as $v) {
            update_default_page($v, $dblink, $config, $lang_defaults_path, $lang_defaults_fallback_path, $note);
        }
        return;
    }
    $filename = $tag;
    if ($tag == '_rootpage') {
        $tag = $config['root_page'];
        $filename = 'HomePage';
    }
    $admin_users = explode(',', $config['admin_users']);
    $admin_main_user = trim($admin_users[0]);
    //$txt_filepath = $lang_defaults_path.$filename.'.txt';
    $php_filepath = $lang_defaults_path . $filename . '.php';
    if (!file_exists($php_filepath) || !is_readable($php_filepath)) {
        $php_filepath = $lang_defaults_fallback_path . $filename . '.php';
    }
    if (file_exists($php_filepath) && is_readable($php_filepath)) {
        ob_start();
        include_once $php_filepath;
        $body = ob_get_contents();
        ob_end_clean();
        //$body = implode('', file($txt_filepath));
        mysql_query('update ' . $config['table_prefix'] . 'pages set latest = "N" where tag = \'' . $tag . '\'', $dblink);
        test(sprintf(__('Adding/Updating default page %s' . '...'), $tag), @mysql_query('insert into ' . $config['table_prefix'] . 'pages set tag=\'' . $tag . '\', body = \'' . mysql_real_escape_string($body) . '\', user=\'WikkaInstaller\', owner = \'' . $admin_main_user . '\', time=now(), latest =\'Y\', note = \'' . mysql_real_escape_string($note) . '\'', $dblink), '', 0);
        // @@@ pick up any page-specific ACL here (look in both $lang_defaults_path and $lang_defaults_fallback_path)
    } else {
        test(sprintf(__('Adding/Updating default page %s' . '...'), $tag), false, sprintf(__('Default page not found or file not readable (%s, %s, %s)'), $tag, $php_filepath, $lang_defaults_path), 0);
    }
}
Example #2
0
     if (file_exists("config/main_menu.user.inc")) {
         brute_copy("config/main_menu.user.inc", "config/main_menu.user.inc.prev");
     }
     if (file_exists("config/options_menu.admin.inc")) {
         brute_copy("config/options_menu.admin.inc", "config/options_menu.admin.inc.prev");
     }
     if (file_exists("config/options_menu.inc")) {
         brute_copy("config/options_menu.inc", "config/options_menu.inc.prev");
     }
     if (file_exists("config/options_menu.user.inc")) {
         brute_copy("config/options_menu.user.inc", "config/options_menu.user.inc.prev");
     }
 case "1.3":
 case "1.3.1":
     print "<strong>1.3.1 to 1.3.2 changes:</strong><br />\n";
     update_default_page(array('AdminBadWords', 'AdminSpamLog', 'WikkaMenulets'), $dblink, $config, $lang_defaults_path, $lang_defaults_fallback_path);
     test("Setting default ACL...", 1);
     mysql_query("insert into " . $config['table_prefix'] . "acls set page_tag = 'WikkaMenulets', read_acl = '!*', write_acl = '!*', comment_read_acl = '!*', comment_post_acl = '!*'", $dblink);
     mysql_query("insert into " . $config['table_prefix'] . "acls set page_tag = 'AdminBadWords', read_acl = '!*', write_acl = '!*', comment_read_acl = '!*', comment_post_acl = '!*'", $dblink);
     mysql_query("insert into " . $config['table_prefix'] . "acls set page_tag = 'AdminSpamLog', read_acl = '!*', write_acl = '!*', comment_read_acl = '!*', comment_post_acl = '!*'", $dblink);
     // Converting DB UTF-8 (but data remains
     // unchanged -- this is handled by a standalone script)
     test("Setting up database for UTF-8...", true);
     @mysql_query("ALTER DATABASE " . $config['mysql_database'] . " DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci", $dblink);
     // Converting pages table and fields to UTF-8
     test("Setting up pages table and fields for UTF-8...", true);
     @mysql_query("ALTER TABLE " . $config['table_prefix'] . "pages DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci", $dblink);
     @mysql_query("ALTER TABLE " . $config['table_prefix'] . "pages CHANGE `tag` `tag` VARCHAR( 75 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL default ''", $dblink);
     @mysql_query("ALTER TABLE " . $config['table_prefix'] . "pages CHANGE `body` `body` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL", $dblink);
     @mysql_query("ALTER TABLE " . $config['table_prefix'] . "pages CHANGE `owner` `owner` VARCHAR( 75 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL default ''", $dblink);
     @mysql_query("ALTER TABLE " . $config['table_prefix'] . "pages CHANGE `user` `user` VARCHAR( 75 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL default ''", $dblink);