query("INSERT INTO `{$dbprefix}config` (`name` ,`value`) VALUES ('db_version', '')"); } $IN_UPDATE = true; /** * print header */ if (! ip('action_file_do')) { echo gettpl('header.html'); } /** * Navigation .. */ switch (g('step', 'str', 'action_file')) { default: case 'update_now': $complete_update = true; $update_msgs_arr = []; $current_db_version = $config['db_version']; $all_db_updates = array_keys($update_schema); $available_db_updates = array_filter($all_db_updates, function ($v) use ($current_db_version) { return $v > $current_db_version; }); sort($available_db_updates); if (! sizeof($available_db_updates)) { $update_msgs_arr[] = '' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . ''; $complete_update = false; } // //is there any sqls // if ($complete_update) { //loop through available updates foreach ($available_db_updates as $db_update_version) { $SQL->hideErrors(); //sqls if (isset($update_schema[$db_update_version]['sql']) && sizeof($update_schema[$db_update_version]['sql']) > 0) { $err = ''; $complete_update = true; foreach ($update_schema[$db_update_version]['sql'] as $name=>$sql_content) { $err = ''; $SQL->query($sql_content); $err = $SQL->get_error(); if (strpos($err[1], 'Duplicate') !== false || $err[0] == '1062' || $err[0] == '1060') { $complete_update = false; } } } //functions if ($complete_update) { if (isset($update_schema[$db_update_version]['functions']) && sizeof($update_schema[$db_update_version]['functions']) > 0) { foreach ($update_schema[$db_update_version]['functions'] as $n) { if (is_callable($n)) { $n(); } } } } $sql = "UPDATE `{$dbprefix}config` SET `value` = '" . KLEEJA_DB_VERSION . "' WHERE `name` = 'db_version'"; $SQL->query($sql); $update_msgs_arr[] = '' . $lang['INST_UPDATE_IS_FINISH'] . ''; } } delete_cache('', true); echo gettpl('update_end.html'); break; } /** * print footer */ echo gettpl('footer.html');