Example #1
0
    lcm_log("lcm_upgrade: meta is misbehaving, searching in DB");
    $query = "SELECT value FROM lcm_meta WHERE name = 'lcm_db_version'";
    $result = lcm_query($query);
    if ($row = lcm_fetch_array($result)) {
        $current_version = $row['value'];
    } else {
        lcm_panic("Could not find lcm_db_version");
    }
}
lcm_log("lcm_upgrade test: current = {$current_version}, should be = {$lcm_db_version}");
// test if upgraded necessary
if ($current_version < $lcm_db_version) {
    include_lcm('inc_db_upgrade');
    lcm_page_start(_T('title_upgrade_database'));
    echo "\n<!-- Upgrading from {$current_version} to {$lcm_db_version} -->\n";
    $log = upgrade_database($current_version);
    // To be honest, in most cases, it will cause a lcm_panic() and this will
    // not show, altough we could (in the future) catch/interpret errors.
    if ($log) {
        echo "<div class='box_error'>\n";
        echo "<p>An error occured while upgrading the database: <br/>{$log}</p>\n";
        // TRAD
        echo "</div>\n";
        lcm_panic("upgrade error ({$log})");
    } else {
        echo "<div class='box_success'>\n";
        echo '<p class="normal_text">' . _T('info_upgrade_database3') . ' <a class="content_link" href="index.php">' . _T('info_upgrade_database5') . "</a></p>\n";
        echo "</div>\n";
    }
    lcm_page_end();
} else {
Example #2
0
function install_step_3()
{
    $db_address = _request('db_address');
    $db_login = _request('db_login');
    $db_password = _request('db_password');
    global $lcm_db_version;
    $install_log = "";
    $upgrade_log = "";
    // Possible errors will get trapped in the output buffer and displayed later,
    // so that they don't mess up with headers/html.
    ob_start();
    if (_request('db_choice') == "__manual__") {
        $sel_db = _request('manual_db');
    } else {
        $sel_db = _request('db_choice');
    }
    $link = lcm_connect_db($db_address, 0, $db_login, $db_password, $sel_db);
    $io_output = ob_get_contents();
    ob_end_clean();
    if (!$link) {
        install_html_start('AUTO', '', 3);
        lcm_panic("connection denied: " . lcm_sql_error());
    }
    //
    // TEMPORARY (used by testing the installer)
    /*
    lcm_query("DROP TABLE lcm_case", true);
    lcm_query("DROP TABLE lcm_case_attachment", true);
    lcm_query("DROP TABLE lcm_stage", true);
    lcm_query("DROP TABLE lcm_followup", true);
    lcm_query("DROP TABLE lcm_author", true);
    lcm_query("DROP TABLE lcm_client", true);
    lcm_query("DROP TABLE lcm_client_attachment", true);
    lcm_query("DROP TABLE lcm_org", true);
    lcm_query("DROP TABLE lcm_org_attachment", true);
    lcm_query("DROP TABLE lcm_contact", true);
    lcm_query("DROP TABLE lcm_keyword", true);
    lcm_query("DROP TABLE lcm_keyword_case", true);
    lcm_query("DROP TABLE lcm_keyword_client", true);
    lcm_query("DROP TABLE lcm_keyword_org", true);
    lcm_query("DROP TABLE lcm_keyword_group", true);
    lcm_query("DROP TABLE lcm_report", true);
    lcm_query("DROP TABLE lcm_fields", true);
    lcm_query("DROP TABLE lcm_filter", true);
    lcm_query("DROP TABLE lcm_app", true);
    lcm_query("DROP TABLE lcm_app_client_org", true);
    lcm_query("DROP TABLE lcm_app_fu", true);
    lcm_query("DROP TABLE lcm_author_app", true);
    lcm_query("DROP TABLE lcm_case_client_org", true);
    lcm_query("DROP TABLE lcm_case_author", true);
    lcm_query("DROP TABLE lcm_client_org", true);
    lcm_query("DROP TABLE lcm_rep_col", true);
    lcm_query("DROP TABLE lcm_rep_line", true);
    lcm_query("DROP TABLE lcm_rep_filters", true);
    lcm_query("DROP TABLE lcm_filter_conds", true);
    lcm_query("DROP TABLE lcm_rep_filter", true);
    lcm_query("DROP TABLE lcm_meta", true);
    */
    // Test if the software was already installed
    $result = lcm_query("SELECT * FROM lcm_meta", true);
    $already_installed = !lcm_sql_errno() && lcm_num_rows($result);
    $old_lcm_version = 'NONE';
    if ($already_installed) {
        lcm_log("LCM already installed", 'install');
        // Find the current database version
        $old_lcm_db_version = 0;
        $query = "SELECT value FROM lcm_meta WHERE name = 'lcm_db_version'";
        $result = lcm_query_db($query);
        while ($row = lcm_fetch_array($result)) {
            $old_lcm_db_version = $row['value'];
        }
        lcm_log("LCM version installed is {$old_lcm_db_version}", 'install');
        // Check if upgrade is needed
        if ($old_lcm_db_version < $lcm_db_version) {
            lcm_log("Calling the upgrade procedure (since < {$lcm_db_version})", 'install');
            include_lcm('inc_db_upgrade');
            $upgrade_log = upgrade_database($old_lcm_db_version);
        } else {
            lcm_log("Upgrade _not_ called, looks OK (= {$lcm_db_version})", 'install');
        }
    } else {
        lcm_log("Creating the database from scratch", 'install');
        include_lcm('inc_db_create');
        $install_log .= create_database();
        lcm_log("DB creation complete", 'install');
    }
    // Create default meta + keywords
    include_lcm('inc_meta');
    include_lcm('inc_keywords_default');
    include_lcm('inc_meta_defaults');
    init_default_config();
    init_languages();
    $skwg = get_default_keywords();
    create_groups($skwg);
    write_metas();
    // regenerate inc/data/inc_meta_cache.php
    // Test DB: not used for now..
    include_lcm('inc_db_test');
    $structure_ok = lcm_structure_test();
    if (!empty($install_log)) {
        install_html_start('AUTO', '', 3);
        echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
        echo "<div class='box_error'>\n";
        echo "<p>";
        echo "<b>" . _T('warning_operation_failed') . "</b> " . _T('install_database_install_failed');
        echo " " . lcm_help("install_connection") . "</p>\n";
        echo "</div>\n";
        // Dump error listing
        echo put_text_in_textbox($install_log);
        install_html_end();
    } else {
        if (!empty($upgrade_log)) {
            install_html_start('AUTO', '', 3);
            echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
            echo "<div class='box_error'>\n";
            echo "<p>" . _T('install_warning_update_impossible', array('old_version' => $old_lcm_version, 'version' => $lcm_version)) . "</p>\n";
            echo "</div>\n";
            // Dump error listing
            echo put_text_in_textbox($upgrade_log);
            install_html_end();
        } else {
            if (!$structure_ok) {
                install_html_start('AUTO', '', 3);
                echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
                echo "<div class='box_error'>\n";
                echo "<p> STRUCTURE PROBLEM </p>\n";
                // TRAD
                echo "</div>\n";
                install_html_end();
            } else {
                // Everything OK
                $conn = '<' . '?php' . "\n";
                $conn .= "if (defined('_CONFIG_INC_CONNECT')) return;\n";
                $conn .= "define('_CONFIG_INC_CONNECT', '1');\n";
                $conn .= "\$GLOBALS['lcm_connect_version'] = 0.1;\n";
                $conn .= "include_lcm('inc_db');\n";
                $conn .= "@lcm_connect_db('{$db_address}','','{$db_login}','{$db_password}','{$sel_db}');\n";
                $conn .= "\$GLOBALS['db_ok'] = !!@lcm_num_rows(@lcm_query_db('SELECT COUNT(*) FROM lcm_meta'));\n";
                $conn .= '?' . '>';
                $lcm_config_prefix = isset($_SERVER['LcmConfigDir']) ? $_SERVER['LcmConfigDir'] : 'inc/config';
                $myFile = fopen($lcm_config_prefix . '/inc_connect_install.php', 'wb');
                fputs($myFile, $conn);
                fclose($myFile);
                install_step_4();
            }
        }
    }
}
Example #3
0
 *
 *  OBBLM 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, see <http://www.gnu.org/licenses/>.
 *   
 */
define('T_NO_STARTUP', true);
require 'header.php';
HTMLOUT::frame_begin(false, false);
title("OBBLM upgrade script");
if (isset($_POST['version'])) {
    $upgradeMsgs = upgrade_database($_POST['version'], array('lrb' => isset($_POST['lrb']) ? $_POST['lrb'] : false));
    echo "<br><b><font color='green'>Finished</font></b>";
    if (!empty($upgradeMsgs)) {
        echo "<br><br><b>IMPORTANT</b>:<br><ul>";
        echo array_strpack('<li>%s</li>', $upgradeMsgs, "\n");
        echo "</ul>";
    }
    echo "<br><hr><br>";
}
?>
Please make sure that the MySQL user and database you have specified in <i>settings.php</i> exist and are valid AND that the rules fields of the old settings file are consistant with the new settings file for those fields which are common.<br><br>
Now, click the appropriate SQL code to run depending on the version upgrade you are doing.<br><br>
<b>Please note:</b>
<ul>
<li><b>ALWAYS</b> make sure you have a backup/dump of your OBBLM database before running the upgrade script.</li>
<li>If upgrading across two or more versions simply run the SQL code for the next version, one after the other until the latest version is reached.</li>
<?php

// do a double control of version here
if (str_replace(".", "", $settings['version']) < "90001") {
    // 90001 for testing purposes
    include LOCALE . LOCALESET . "setup.php";
    // Force the database to UTF-8 because we'll convert to it
    upgrade_database();
    /**
     * 1. Upgrade all Infusions
     */
    upgrade_articles();
    upgrade_weblinks();
    upgrade_downloads();
    upgrade_news();
    upgrade_forum();
    upgrade_gallery();
    upgrade_faq();
    upgrade_poll();
    upgrade_comments();
    //upgrade_eshop(); // doesn't do anything unless you have the old e-shop install and the new, not yet developed eshop infusion for PHP-Fusion 9
    /**
     * 2. Upgrade core
     */
    upgrade_user_table();
    upgrade_private_message();
    upgrade_custom_page();
    upgrade_multilang();
    upgrade_user_fields();
    upgrade_panels();
    install_seo();
Example #5
0
         $old_version = $h->miscdata('hotaru_version');
         upgrade_check($h, $old_version, true);
     } else {
         // Tell user to setup database
         if ($h->cage->get->getAlpha('type') == 'manual') {
             database_setup_manual($h);
         } else {
             database_setup($h, $settings_file_exists);
         }
     }
     break;
 case 2:
     if ($action == 'upgrade') {
         $old_version = $h->miscdata('hotaru_version');
         do_upgrade($h, $old_version);
         upgrade_database($h);
     } else {
         $db = init_database();
         // Create the database tables
         database_tables_creation($h);
     }
     break;
 case 3:
     // Remove any cookies set in a previous installation:
     setcookie("hotaru_user", "", time() - 3600, "/");
     setcookie("hotaru_key", "", time() - 3600, "/");
     // remove cookies from whole domain just in case of 1.4.2 cookies issue
     $parsed = parse_url(BASEURL);
     setcookie("hotaru_user", "", time() - 3600, "/", "." . $parsed['host']);
     setcookie("hotaru_key", "", time() - 3600, "/", "." . $parsed['host']);
     if ($action == 'upgrade') {
Example #6
0
             // Handle errors and include the information form
             if (!empty($ftp_errors)) {
                 echo "\n\n\t\t" . '<ul class="errors" style="background-image: none;">';
                 foreach ($ftp_errors as $value) {
                     echo "\n\t\t\t" . '<li class="margin-5">' . $value . '</li>';
                 }
                 echo "\n\t\t" . '</ul>';
             }
             include PLOGGER_DIR . 'plog-admin/includes/install-form-setup.php';
             break;
         }
     }
     // Step 1 - update the database
 // Step 1 - update the database
 case 1:
     $return = upgrade_database();
     if (!empty($return)) {
         echo "\n\n\t" . '<h2 class="upgrade">' . plog_tr('Updating Database') . '</h2>';
         echo "\n\n\t\t" . '<ul class="info">';
         foreach ($return as $value) {
             echo "\n\t\t\t" . '<li class="margin-5">' . $value . '</li>';
         }
         echo "\n\t\t" . '</ul>';
         echo "\n\n\t" . '<h2 class="upgrade">' . plog_tr('Done with database upgrade!') . '</h2>';
         echo "\n\n\t" . '<form action="_upgrade.php?step=2" method="post">';
         echo "\n\t" . '<p><input class="submit" type="submit" name="next" value="' . plog_tr('Next Step') . ' &raquo;" /></p>';
         echo "\n\t" . '</form>' . "\n";
         break;
     }
     // Step 2 - move images, albums, collections, and uploads to new locations
 // Step 2 - move images, albums, collections, and uploads to new locations
Example #7
0
function upgrade_database_to_version($toVersion, $fromVersion)
{
    global $db_upgrade_options;
    require_once 'lib/class_sqlcore.php';
    require_once 'lib/mysql_upgrade_queries.php';
    $reversedUpgradeSqls = array_reverse($upgradeSQLs, true);
    $upgrading = false;
    foreach ($reversedUpgradeSqls as $versionNumber => $sqlList) {
        if ($versionNumber == $fromVersion || $versionNumber > $fromVersion) {
            $upgrading = true;
        }
        if ($upgrading) {
            echo '<div>Upgrading to version ' . $versionNumber . '.</div>';
            upgrade_database($versionNumber, $db_upgrade_options, $upgradeSQLs);
        }
        if ($versionNumber == $toVersion) {
            $upgrading = false;
        }
    }
}