#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include "../utils.cpp"
using namespace std;
// g++ -I. -fPIC -shared -g -o axeso5.com.so axeso5.com.cpp
// regex
// http.*\.axeso5\.com.*(\.zip|\.cmp|\.cdt|\.bmp|\.exe|\.acv|\.BIN|\.mp3|\.dds|\.wav|\.WAV|\.png|\.jpg|\.swf|\.Xtp|\.cab|\.tbm|\.loc|\.7z|\.stg|\.kom)
bool in_array(const string &needle, const vector< string > &haystack) {
int max = haystack.size();
if (max == 0) return false;
for (int iii = 0; iii < max; iii++) {
if (regex_match(haystack[iii], needle) != "") {
return true;
}
}
return false;
}
string dominiotxt="Axexo5_Juegos_Online";
string get_filename(string url) {
vector<string> resultado;
if (url.find("?") != string::npos) {
stringexplode(url, "?", &resultado);
stringexplode(resultado.at(resultado.size()-2), "/", &resultado);
return resultado.at(resultado.size()-3)+"_"+resultado.at(resultado.size()-2)+"_"+resultado.at(resultado.size()-1);
} else {
stringexplode(url, "/", &resultado);
return resultado.at(resultado.size()-3)+"_"+resultado.at(resultado.size()-2)+"_"+resultado.at(resultado.size()-1);
}
}
extern "C" resposta getmatch(const string url) {
resposta r;
vector<string> black_list;
black_list.push_back ("content.json.zip");
black_list.push_back ("XDataV1.Xtp");
black_list.push_back ("XDataFM0.Xtp");
if ( (url.find("/operation7/") != string::npos) and (url.find("/DICs/") != string::npos) and (in_array(url, black_list) == false)
) {
dominiotxt="Operation7_Online";
}
if ( (url.find("/content/") != string::npos) and (in_array(url, black_list) == false)
) {
dominiotxt="Audition-Online";
}
if ( (url.find("/sa_patch/") != string::npos)
) {
dominiotxt="Suddent-Attack/Axeso5";
}
if ( (url.find("/KarosES/") != string::npos)
) {
dominiotxt="Karos-Online/Axeso5";
}
if ( (url.find("/GrandChaseLIN/") != string::npos)
) {
dominiotxt="GrandChase/Axeso5";
}
if ( (url.find(".axeso5.com/") != string::npos) and (in_array(url, black_list) == false)
{
r.file = get_filename(url);
if (!r.file.empty()) {
r.match = true;
r.domain = dominiotxt;
} else {
r.match = false;
}
} else {
r.match = false;
}
return r;
}