コード例 #1
0
ファイル: patch.php プロジェクト: cjbayliss/alloc
function apply_patch($f)
{
    global $TPL;
    static $files;
    // Should never attempt to apply the same patch twice.. in case
    // there are function declarations in the .php patches.
    if ($files[$f]) {
        return;
    }
    $files[$f] = true;
    $db = new db_alloc();
    $file = basename($f);
    $failed = false;
    $comments = array();
    // This is an important patch that converts money from 120.34 to 12034.
    // We MUST ensure that the user has a currency set before applying this patch.
    if ($file == "patch-00188-alla.sql") {
        if (!config::get_config_item('currency')) {
            alloc_error("No default currency is set! Login to alloc (ignore any errors, you may need to manually change the url to config/config.php after logging in) go to Setup -> Finance and select a Main Currency. And then click the 'Update Transactions That Have No Currency' button. Then return here and apply this patch (patch-188). IT IS REALLY IMPORTANT THAT YOU FOLLOW THESE INSTRUCTIONS as the storage format for monetary amounts has changed.", true);
        }
    }
    // Try for sql file
    if (strtolower(substr($file, -4)) == ".sql") {
        list($sql, $comments) = parse_sql_file($f);
        foreach ($sql as $query) {
            if (!$db->query($query)) {
                #$TPL["message"][] = "<b style=\"color:red\">Error:</b> ".$f."<br>".$db->get_error();
                $failed = true;
                alloc_error("<b style=\"color:red\">Error:</b> " . $f . "<br>" . $db->get_error());
            }
        }
        if (!$failed) {
            $TPL["message_good"][] = "Successfully Applied: " . $f;
        }
        // Try for php file
    } else {
        if (strtolower(substr($file, -4)) == ".php") {
            $str = execute_php_file("../patches/" . $file);
            if ($str && !defined("FORCE_PATCH_SUCCEED_" . $file)) {
                #$TPL["message"][] = "<b style=\"color:red\">Error:</b> ".$f."<br>".$str;
                $failed = true;
                ob_end_clean();
                alloc_error("<b style=\"color:red\">Error:</b> " . $f . "<br>" . $str);
            } else {
                $TPL["message_good"][] = "Successfully Applied: " . $f;
            }
        }
    }
    if (!$failed) {
        $q = prepare("INSERT INTO patchLog (patchName, patchDesc, patchDate) \n                  VALUES ('%s','%s','%s')", $file, implode(" ", $comments), date("Y-m-d H:i:s"));
        $db->query($q);
    }
}
コード例 #2
0
     $is_version_5 = true;
 }
 $not_is_version_5 = !$is_version_5;
 $olc_charset = array();
 $dummy_array = array();
 $olc_tables = array();
 $olc_array = array();
 $olc_insert_array = array();
 $olc_keys_array = array();
 $error = parse_sql_file($olc_file_name, true, $olc_tables, $olc_array, $olc_insert_array, $dummy_array, $dummy_array, $olc_charset, $olc_default_charset, $olc_struct_lines, $olc_data_lines);
 if ($error === true) {
     $import_charset = array();
     $import_array = array();
     $import_array_search = array();
     $import_keys_array = array();
     $error = parse_sql_file($import_file_name, false, $olc_tables, $import_array, $olc_insert_array, $import_array_search, $import_keys_array, $import_charset, $import_default_charset, $import_struct_lines, $import_data_lines);
     if ($error === true) {
         //Loop thru all fields in the import-database, and check, if it is available in the OL-Commerce-database
         $collate_len = strlen(COLLATE);
         $last_table = EMPTY_STRING;
         $alter_table_add = EMPTY_STRING;
         $create_table = EMPTY_STRING;
         $sql0_create = EMPTY_STRING;
         $sql_drop_tables = NEW_LINE;
         $sql_drop_fields = $sql_drop_tables;
         for ($i = 0, $n = sizeof($import_array_search); $i < $n; $i++) {
             $element = $import_array_search[$i];
             $pos = strrpos($element, TILDE);
             $this_table = substr($element, 0, $pos);
             if ($this_table != $last_table) {
                 if ($last_table) {
コード例 #3
0
ファイル: util.inc.php プロジェクト: cjbayliss/alloc
function parse_patch_file($file)
{
    if (!is_readable($file)) {
        return;
    }
    if (substr($file, -4) == strtolower(".php")) {
        return parse_php_file($file);
    } else {
        if (substr($file, -4) == strtolower(".sql")) {
            return parse_sql_file($file);
        }
    }
}
コード例 #4
0
ファイル: backups.inc.php プロジェクト: cjbayliss/alloc
 function restore($archivename)
 {
     global $TPL;
     $file = ATTACHMENTS_DIR . "backups" . DIRECTORY_SEPARATOR . "0" . DIRECTORY_SEPARATOR . $archivename;
     $archive = new PclZip($file);
     # Clear out the folder list
     foreach ($this->folders as $folder) {
         $this->empty_dir(ATTACHMENTS_DIR . $folder);
     }
     $archive->extract(ATTACHMENTS_DIR);
     list($sql, $commends) = parse_sql_file(ATTACHMENTS_DIR . "database.sql");
     $db = new db_alloc();
     foreach ($sql as $q) {
         if (!$db->query($q)) {
             $errors[] = "Error! (" . $db->get_error() . ").";
         }
     }
     is_array($errors) and alloc_error(implode("<br>", $errors));
     unlink(ATTACHMENTS_DIR . "database.sql");
     if (!count($errors)) {
         return true;
     }
 }