Exemple #1
0
    }
}
@set_time_limit(600);
if ($HTTP_VARS['op'] == 'previewsql') {
    echo "<html>";
    echo "\n<head>";
    echo "\n<title>" . get_opendb_config_var('site', 'title') . " " . get_opendb_version() . " - " . $HTTP_VARS['title'] . "</title>";
    if (file_exists('./theme/default/style.css')) {
        echo "\n<link rel=stylesheet type=\"text/css\" href=\"./theme/default/style.css\">";
    }
    echo "\n<style type=\"text/css\">";
    echo "\n.code { color: black; font-family: courier; font-size:small }";
    echo "\n</style>";
    echo "\n</head><body>";
    if (($file = validate_sql_script($HTTP_VARS['patchdir'], $HTTP_VARS['sqlfile'])) !== FALSE) {
        echo_install_sql_file($file);
    }
    echo "\n</body></html>";
} else {
    if ($HTTP_VARS['op'] == 'installsql') {
        if (($file = validate_sql_script($HTTP_VARS['patchdir'], $HTTP_VARS['sqlfile'])) !== FALSE) {
            if (exec_install_sql_file($file, $error)) {
                echo "<div class=\"smsuccess\">SQL script executed successfully.</div>";
            } else {
                echo format_error_block($error);
            }
        }
    }
    display_patch_list('Customise for Country', 'country');
    display_patch_list('Miscellaneous Updates', 'extras');
}
Exemple #2
0
function execute_sql_install($ADMIN_TYPE, $sqlfile, &$errors)
{
    $sqlfile = basename($sqlfile);
    $sqlfile = './admin/' . $ADMIN_TYPE . '/sql/' . $sqlfile;
    if (file_exists($sqlfile)) {
        if (exec_install_sql_file($sqlfile, $errors)) {
            return TRUE;
        } else {
            //$errors[] = $error;
            return FALSE;
        }
    } else {
        $errors[] = array('error' => 'SQL file not found');
        return FALSE;
    }
}
Exemple #3
0
function install_opendb_new_install($HTTP_VARS, &$errors)
{
    global $PHP_SELF;
    if ($HTTP_VARS['confirmed'] === 'true') {
        if (exec_install_sql_file("./install/new/tables.sql", $errors)) {
            if (exec_install_sql_file("./install/new/systemdata.sql", $errors) && exec_install_sql_file("./admin/s_language/sql/english.sql", $errors)) {
                exec_install_sql_file("./admin/s_status_type/sql/A-Available.sql", $errors);
                exec_install_sql_file("./admin/s_status_type/sql/N-Inactive.sql", $errors);
                exec_install_sql_file("./admin/s_status_type/sql/H-Hidden.sql", $errors);
                exec_install_sql_file("./admin/s_status_type/sql/X-External.sql", $errors);
                exec_install_sql_file("./admin/s_status_type/sql/W-Wishlist.sql", $errors);
                exec_install_sql_file("./admin/s_status_type/sql/R-Related.sql", $errors);
                exec_install_sql_file("./install/new/adminuser.sql", $errors);
                // no steps to complete, its all in one, so we can insert release record with
                // NULL step (indicating complete) straight away.
                if (insert_opendb_release(get_opendb_version(), 'New Installation', NULL) !== FALSE) {
                    return TRUE;
                } else {
                    $errors[] = 'Failed to insert OpenDb release record (Version ' . get_opendb_version() . ')';
                    return FALSE;
                }
            }
        }
        //else
        return FALSE;
    } else {
        if ($HTTP_VARS['confirmed'] !== 'false') {
            echo "<p>The database tables, system data and admin user need to be installed to the OpenDb database.</p>";
            echo "<form action=\"{$PHP_SELF}\" method=\"GET\">" . "<input type=\"hidden\" name=\"step\" value=\"install\">" . "<input type=\"hidden\" name=\"confirmed\" value=\"true\">" . "<input type=\"button\" class=\"button\" value=\"Install\" onclick=\"this.value='Working...'; this.disabled=true; this.form.submit(); return true;\">" . "</form>";
            return FALSE;
        }
    }
}
 /**
 	Execute the given step.  
 
 	Returns TRUE, if step completed without incident.   If step is only partially complete, return how many iterations remaining to complete it,
 	this relates to the stepPart.
 	Return FALSE, if at least one error occured.
 */
 function executeStep($index, $stepPart = NULL)
 {
     $this->_step_remainder_count = NULL;
     $this->_error_rs = NULL;
     if ($index <= $this->getNoOfSteps()) {
         $stepFuncName = 'executeStep' . $index;
         if (method_exists($this, $stepFuncName)) {
             return $this->{$stepFuncName}($stepPart);
         } else {
             if (file_exists($this->getUpgraderDir() . '/step' . $index . '.sql')) {
                 $errors = NULL;
                 if (exec_install_sql_file($this->getUpgraderDir() . '/step' . $index . '.sql', $errors)) {
                     return TRUE;
                 } else {
                     $this->addErrors($errors);
                     return FALSE;
                 }
             } else {
                 $this->addError($stepFuncName . ' does not exist');
                 return FALSE;
             }
         }
     } else {
         $this->addError('Invalid Step');
         return FALSE;
     }
 }