SHARE
TWEET

Untitled

Baoulettes Jun 30th, 2020 1,082 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void CheckNewSQL() {
  2.     using namespace std::string_view_literals;
  3.     using json = nlohmann::json;
  4.     bool Need_to_update =   true;
  5.     int Local_version = 0;
  6.     int Network_version = 0;
  7.     std::string Network_file = "0.0.0";
  8.     UD_LOGI("CheckNewSQL : INIT . . .");
  9.     if (!kHookLib->patchData->exists("Translation_fr_version")) {
  10.         UD_LOGI("CheckNewSQL : Translation_fr_version not found so creating");
  11.         kHookLib->patchData->putInt32("Translation_fr_version", 0);
  12.         Need_to_update = true;
  13.     } else {
  14.         UD_LOGI("CheckNewSQL : Translation_fr_version found so loading");
  15.         Local_version = kHookLib->patchData->getInt32("Translation_fr_version", 0);
  16.     }
  17.     auto Check_new_sql = RestClient::get("https://baoulettes.fr/download/Updater.json");
  18.     if (Check_new_sql.code == 200) {
  19.         UD_LOGI("CheckNewSQL : Json Found . . .");
  20.         auto Updater_Json = json::parse(Check_new_sql.body);
  21.         Network_version     =   Updater_Json["Updater"]["Version"].get<int>();
  22.         Network_file        =   Updater_Json["Updater"]["File"].get<std::string>();
  23.         UD_LOGI("CheckNewSQL : Local version %d | Network verison %d ",Local_version,Network_version);
  24.         if (Network_version > Local_version) {
  25.             Need_to_update = true;
  26.             UD_LOGI("CheckNewSQL : Update is required");
  27.         } else {
  28.             Need_to_update = false;
  29.             UD_LOGI("CheckNewSQL : Update is not required");
  30.         }
  31.     } else {
  32.         UD_LOGI("CheckNewSQL : Json Not found . . .");
  33.         Need_to_update = false;
  34.     }
  35.    
  36.     if (Need_to_update == true) {
  37.         std::string file_fetch = "https://baoulettes.fr/download/"+Network_file+".sql";
  38.         auto update_sql = RestClient::get(file_fetch);
  39.         if (update_sql.code == 200) {
  40.             auto link_url_not_found = "https://baoulettes.fr/download/"+Network_file+".sql is found";
  41.             UD_LOGI(link_url_not_found.c_str());
  42.             UD_LOGI("Trying : kHookLib->patchData->putString(\"Translation_fr_sql\", update_sql.body);");
  43.             kHookLib->patchData->putString("Translation_fr_sql", update_sql.body);
  44.             UD_LOGI("Trying : kHookLib->patchData->putInt32(\"Translation_fr_version\", Network_version");
  45.             kHookLib->patchData->putInt32("Translation_fr_version", Network_version);
  46.         } else {
  47.             UD_LOGI("file_fetch not found : %s",file_fetch.c_str());
  48.         }
  49.     }
  50.     auto Translation_fr_sql = kHookLib->patchData->getString("Translation_fr_sql", "");
  51.     UD_LOGI("Inserting Translation_fr_sql");
  52.     UniDokkan::Database::exec(Translation_fr_sql.c_str());
  53.     UD_LOGI("inserted Translation_fr_sql");
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top