/* * Localwebfaker - Web sites faker for LAN * Copyright (C) 2007-2009 Lucas J. González * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see append(comun->AppName()); return *tmp; } QString Comun::webServErrFile(QString serverName) { Comun *comun = new Comun() ; QString *tmp = new QString() ; tmp->append(comun->LogsDir()) ; tmp->append(serverName); tmp->append(".error"); return *tmp ; } QString Comun::webServAccFile(QString serverName) { Comun *comun = new Comun() ; QString *tmp = new QString() ; tmp->append(comun->LogsDir()) ; tmp->append(serverName); tmp->append(".access"); return *tmp ; } // RUTAS QString Comun::hostsFile() { return QString("/etc/hosts") ; } QString Comun::restHostsFile() { QString( tmp ) ; tmp.append(userConfDir()) ; tmp.append("hosts.old") ; return tmp ; } QString Comun::resolvFile() { return QString("/etc/resolv.conf") ; } QString Comun::restResolvFile() { QString( tmp ) ; tmp.append(userConfDir()) ; tmp.append("resolv.old") ; return tmp ; } QString Comun::sysResolvFile() { return QString("/etc/resolvconf/run/resolv.conf"); } QString Comun::AppName() { return QString("localwebfaker") ; } QString Comun::LogsDir() { Comun *comun = new Comun() ; QString *tmp = new QString() ; tmp->append(comun->userAppDir()) ; tmp->append("/Logs/") ; return *tmp ; } QString Comun::userHomeDir() { QDir home = QDir::homePath(); return home.absolutePath() ; } QString Comun::userAppDir() { Comun *config = new Comun(); QString tmpQStr = config->userHomeDir() ; tmpQStr.append("/."); tmpQStr.append(config->AppName()); return tmpQStr; } QString Comun::userConfDir() { Comun *config = new Comun(); QString tmpQStr = config->userAppDir() ; tmpQStr.append("/config/"); return tmpQStr; } QString Comun::sysIpfwd() { return QString("/proc/sys/net/ipv4/ip_forward"); } QString Comun::restIpfwd() { Comun *config = new Comun(); QString tmpQStr = config->userConfDir() ; tmpQStr.append("/ip_forward.old") ; return tmpQStr ; } QString Comun::restIptables() { Comun *config = new Comun(); QString tmpQStr = config->userConfDir() ; tmpQStr.append("/iptables.old") ; return tmpQStr ; } QString Comun::restApacheStatus() { Comun *config = new Comun(); QString tmpQStr = config->userConfDir() ; tmpQStr.append("/apache_status.old") ; return tmpQStr ; } QString Comun::limpiaDominio( QString dominio ) { if( dominio.startsWith("http://") ) dominio.remove( 0, 7 ) ; return dominio ; } // EXPRESIONES REGULARES QString Comun::rxDomain() { return QString("(http://)?[a-zA-Z0-9\\-\\.]+\\.(com|es|org|net|mil|edu|COM|ES|ORG|NET|MIL|EDU)"); } QString Comun::rxIP() { return QString("(?:(?:1\\d?\\d|[1-9]?\\d|2[0-4]\\d|25[0-5])\\.){3}(?:1\\d?\\d|[1-9]?\\d|2[0-4]\\d|25[0-5])"); }