v6.3.0: Fix problems with special characters, e.g. '

This commit is contained in:
M4RKUS28 2023-10-03 22:21:18 +02:00
parent b237bf6634
commit b326752b24
7 changed files with 119 additions and 70 deletions

View File

@ -2,17 +2,12 @@
#define LOGGER_H #define LOGGER_H





#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <streambuf> #include <streambuf>
#include <ctime> // std::time, localtime ... #include <ctime> // std::time, localtime ...



#include "parameterManager.h"


class Logger class Logger
{ {
public: public:

View File

@ -1,6 +1,22 @@
#include "pageManager.h" #include "pageManager.h"






#ifdef _WIN32
#include "./../include/curl/curl.h"
#include <windows.h>

//----------------------?????????????????
#define noSLLCheck

#else
#include "curl/curl.h"
#endif




std::string PageManager::torAnmeldeNamen = "no-name"; std::string PageManager::torAnmeldeNamen = "no-name";
bool PageManager::cloudflare_protec = false; bool PageManager::cloudflare_protec = false;
std::mutex PageManager::torAnmeldeNamenMutex; std::mutex PageManager::torAnmeldeNamenMutex;
@ -454,11 +470,16 @@ checkNameRply PageManager::checkName(std::vector<PAGE> &pages, std::string Name,
//für automatisch erste Seite aktiv ist, dann wähl aus, sonst manuel auswahl //für automatisch erste Seite aktiv ist, dann wähl aus, sonst manuel auswahl


int count = 0; int count = 0;
std::string name = replace(Name, " ", "-"); std::string name = replace(replace(Name, "\n", ""), " ", "-");
std::string pagesonExist; std::string pagesonExist;
std::string correct_name = name; std::string correct_name = name;
PAGE Page; PAGE Page;



//entferne sonderzeichen
replaceSZ(name, true);
name = replace(name, "--", "-");

//für jede Seite //für jede Seite
for ( unsigned i = 0; i < pages.size(); i++ ) { for ( unsigned i = 0; i < pages.size(); i++ ) {


@ -495,6 +516,7 @@ checkNameRply PageManager::checkName(std::vector<PAGE> &pages, std::string Name,
if(pos1 != std::string::npos && pos2 != std::string::npos) { if(pos1 != std::string::npos && pos2 != std::string::npos) {
correct_name = tryGetGoodName.substr(pos1 + 6, pos2 - pos1 - 6); correct_name = tryGetGoodName.substr(pos1 + 6, pos2 - pos1 - 6);
} }
replaceSZ(correct_name);
} }


if(useFirstPage) { if(useFirstPage) {
@ -734,6 +756,56 @@ int PageManager::compareVersions(std::string Version1, std::string Version2)


} }


void PageManager::replaceSZ(std::string &str, const bool &remove)
{
struct {
const std::string search;
const std::string replace;
} specialCharacters[] = {
{"&amp;", "&"},
{"&quot;", "\""},
{"&lt;", "<"},
{"&gt;", ">"},
{"&apos;", "'"},
{"&#039;", "'"},
{"&excl;", "!"},
{"&num;", "#"},
{"&dollar;", "$"},
{"&percnt;", "%"},
{"&ast;", "*"},
{"&plus;", "+"},
{"&comma;", ","},
{"&period;", "."},
{"&sol;", "/"},
{"&colon;", ":"},
{"&semi;", ";"},
{"&equals;", "="},
{"&quest;", "?"},
{"&commat;", "@"},
{"&lsqb;", "["},
{"&bsol;", "\\"},
{"&rsqb;", "]"},
{"&Hat;", "^"},
{"&lowbar;", "_"},
{"&grave;", "`"},
{"&lcub;", "{"},
{"&verbar;", "|"},
{"&rcub;", "}"},
{"&tilde;", "~"},
{"&apos;", "'"},
{"<br />", " "}
};

for (const auto& entry : specialCharacters) {
if (str.find(entry.search) != std::string::npos) {
str = replace(str, entry.search, ((remove) ? "" : entry.replace));
}
if(remove && str.find(entry.replace) != std::string::npos) {
str = replace(str, entry.replace, "");
}
}
}

int PageManager::writeToFile(std::vector<std::string> paths, std::string text) int PageManager::writeToFile(std::vector<std::string> paths, std::string text)
{ {
if(paths.size() == 0) if(paths.size() == 0)
@ -758,6 +830,31 @@ std::string PageManager::getCurlVersion()
return data->version; return data->version;
} }


std::string PageManager::generateRandomString(int length) {
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";

std::string randomString;
for (int i = 0; i < length; ++i) {
randomString.push_back(alphanum[std::rand() % (sizeof(alphanum) - 1)]);
}

return randomString;
}

void PageManager::generateNewTorAnmeldeNamen(std::string alterName) {
torAnmeldeNamenMutex.lock();

if(torAnmeldeNamen == alterName) {
torAnmeldeNamen = generateRandomString(10);
std::cout << " -> New Proxy Login Name: " << torAnmeldeNamen << std::flush;
usleep(700000);
}
torAnmeldeNamenMutex.unlock();
}



std::string PageManager::chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg) std::string PageManager::chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg)
{ {

View File

@ -6,17 +6,6 @@
#include "accountManager.h" #include "accountManager.h"
#include "parameterManager.h" // for isNumber #include "parameterManager.h" // for isNumber


#ifdef _WIN32
#include "./../include/curl/curl.h"
#include <windows.h>

//----------------------?????????????????
#define noSLLCheck

#else
#include "curl/curl.h"
#endif

#include <sstream> #include <sstream>
#include <unistd.h> // sleep #include <unistd.h> // sleep
#include <algorithm> #include <algorithm>
@ -24,10 +13,6 @@
#include <mutex> #include <mutex>





#define USER_AGENT "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"


struct Reply { struct Reply {
Reply() {} Reply() {}
Reply(std::string value_both) : html(value_both), url(value_both) {} Reply(std::string value_both) : html(value_both), url(value_both) {}
@ -77,6 +62,8 @@ public:


int compareVersions(std::string Version1, std::string Version2); int compareVersions(std::string Version1, std::string Version2);


void replaceSZ(std::string &str, const bool &remove = false);

int writeToFile(std::vector<std::string> paths, std::string text); int writeToFile(std::vector<std::string> paths, std::string text);


static std::string getCurlVersion(); static std::string getCurlVersion();
@ -86,30 +73,9 @@ public:
static std::string torAnmeldeNamen; static std::string torAnmeldeNamen;
static bool cloudflare_protec; static bool cloudflare_protec;


static std::string generateRandomString(int length) { static std::string generateRandomString(int length);
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";


std::string randomString; static void generateNewTorAnmeldeNamen(std::string alterName);
for (int i = 0; i < length; ++i) {
randomString.push_back(alphanum[std::rand() % (sizeof(alphanum) - 1)]);
}

return randomString;
}

static void generateNewTorAnmeldeNamen(std::string alterName) {
torAnmeldeNamenMutex.lock();

if(torAnmeldeNamen == alterName) {
torAnmeldeNamen = generateRandomString(10);
std::cout << " -> New Proxy Login Name: " << torAnmeldeNamen << std::flush;
usleep(700000);
}
torAnmeldeNamenMutex.unlock();
}


std::string sock5Proxy; std::string sock5Proxy;
private: private:

View File

@ -1,6 +1,11 @@
#include "parameterManager.h" #include "parameterManager.h"




#include "logger.h"
//////Wichtig nach MODUS UND PAGE DECLARATION
#include "pageManager.h"


int setPaths(Settings &settings) int setPaths(Settings &settings)
{ {
//Path settings //Path settings

View File

@ -24,14 +24,12 @@


#define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files=" #define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files="
#define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files=" #define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files="
#define VERSION "6.2.0" #define VERSION "6.3.0"
#define DEFAULT_FILE_VERSION "2.5" #define DEFAULT_FILE_VERSION "2.5"


//default, anime, normal,
//suche: für jede katego. eine
//zu beginn, erst eiunmal serie suchen



// user agent
#define USER_AGENT "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"




enum Modus { enum Modus {
@ -52,18 +50,10 @@ enum Modus {
struct PAGE { struct PAGE {
PAGE() {} PAGE() {}
PAGE( std::string protocol, std::string url, std::string nameID, std::string urlAphabetSerienList, std::string urlDir, std::string popularSerien ) PAGE( std::string protocol, std::string url, std::string nameID, std::string urlAphabetSerienList, std::string urlDir, std::string popularSerien )
: protocol(protocol), name_id(nameID), url(url), urlAlphabetSerienList(urlAphabetSerienList), UrlDir(urlDir), popularSerien(popularSerien) : protocol(protocol), name_id(nameID), url(url), urlAlphabetSerienList(urlAphabetSerienList), UrlDir(urlDir), popularSerien(popularSerien) { }
{

}
std::string protocol, name_id, url, urlAlphabetSerienList, UrlDir, popularSerien; std::string protocol, name_id, url, urlAlphabetSerienList, UrlDir, popularSerien;
}; };


#include "logger.h"

//////Wichtig nach MODUS UND PAGE DECLARATION
#include "pageManager.h"



struct Settings { struct Settings {
const std::string programName = "S_New4"; const std::string programName = "S_New4";

View File

@ -1909,7 +1909,7 @@ int ProgramManager::searchModus_update(Settings *settings)
//darf nicht weniger werden!! //darf nicht weniger werden!!


for ( const auto &page : settings->pagesInUse ) { for ( const auto &page : settings->pagesInUse ) {
std::cout << " -> Updating '" << page.name_id << "'..." << std::endl; std::cout << " -> Updating '" << page.name_id << " <" << page.url << ">'..." << std::endl;


Reply reply = pageManager.getServerRequest( page.protocol, page.url + page.urlAlphabetSerienList); Reply reply = pageManager.getServerRequest( page.protocol, page.url + page.urlAlphabetSerienList);


@ -1962,22 +1962,18 @@ int ProgramManager::searchModus_update(Settings *settings)
line = replace(line, "</a>", ""); line = replace(line, "</a>", "");
//...\n|/serie/ stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null|\n... //...\n|/serie/ stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null|\n...




///Nadia The Secret, Fushigi no Nadia|/nadia-zauberstein|Nadia und Zauberstein|seriento ///Nadia The Secret, Fushigi no Nadia|/nadia-zauberstein|Nadia und Zauberstein|seriento
serienListe += line + "|" + page.url + "\n"; serienListe += line + "|" + page.url + "\n";
} }
if(serienListe.length() > 0) if(serienListe.length() > 0)
serienListe.pop_back(); serienListe.pop_back();


//Entferne Html Sonderzeichen //ersetze html sonderzeichen...
serienListe = replace(serienListe, "&amp;quot;", "\""); // pageManager.replaceSZ(serienListe);
serienListe = replace(serienListe, "--", "-");


serienListe = replace(serienListe, "&amp;", "&"); //
serienListe = replace(serienListe, "&lt;", "<"); //
serienListe = replace(serienListe, "&gt;", ">"); //

serienListe = replace(serienListe, "<br />", " "); //
serienListe = replace(serienListe, "&quot;", "\""); //
serienListe = replace(serienListe, "&apos;", "'"); //


list += serienListe; list += serienListe;



View File

@ -2,9 +2,9 @@
#define MANAGEPROGRAM_H #define MANAGEPROGRAM_H




//#include "pageManager.h"
#include "parameterManager.h" #include "parameterManager.h"
//#include "accountManager.h" #include "accountManager.h"
#include "pageManager.h"


#include <sys/types.h> #include <sys/types.h>
#include <pthread.h> #include <pthread.h>