Alterserv

ThunderCache 3.1.x => Plugins para ThunderCache 3.1.2 => Mensaje publicado por: JOtiniano en Noviembre 04, 2012, 11:55:31 PM

Título: Plugin Sunat
Publicado por: JOtiniano en Noviembre 04, 2012, 11:55:31 PM
Estimado Amigos,Comparto el Plugin para la Sunat, espero les sirva.#include <iostream>
#include <cstring>
#include <vector>
#include "../utils.cpp"

// use this line to compile
// g++ -I. -fPIC -shared -g -o sunat.gob.pe.so sunat.gob.pe.cpp
// regex
// http.*\.sunat\.gob\.pe.*(\.gif|\.jpg|\.png)

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()-1);          
       } else {
           stringexplode(url, "/", &resultado);
           return resultado.at(resultado.size()-1);
       }
}

extern "C" resposta getmatch(const string url) {
   resposta r;  

if ( (url.find(".sunat.gob.pe") != string::npos)
  ) {
   
      r.file = get_filename(url);
     if (!r.file.empty()) {
        r.match = true;        
        r.domain = "Sunat";
     } else {
        r.match = false;
     }
  } else {
     r.match = false;
  }
  return r;
}


SL2.
Título: Re:Plugin Sunat
Publicado por: haroldbb24 en Abril 02, 2013, 09:18:22 PM
perfecto funcionando