* @copyright 2007-2010 Prestashop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registred Trademark & Property of PrestaShop SA
*/
if ((basename(__FILE__) == 'fianetfraud.php'))
require_once dirname(__FILE__) . '/fianet/lib/includes/includes.inc.php';
class Fianetfraud extends Module
{
const CERTISSIM_TABLE_NAME = 'fianet_certissim';
const INSTALL_SQL_FILE = 'install.sql';
static private $token;
private $_html;
private $_product_type = array(
'1' => 'Alimentation & gastronomie',
'2' => 'Auto & moto',
'3' => 'Culture & divertissements',
'4' => 'Maison & jardin',
'5' => 'Electroménager',
'6' => 'Enchères et achats groupés',
'7' => 'Fleurs & cadeaux',
'8' => 'Informatique & logiciels',
'9' => 'Santé & beauté',
'10' => 'Services aux particuliers',
'11' => 'Services aux professionnels',
'12' => 'Sport',
'13' => 'Vêtements & accessoires',
'14' => 'Voyage & tourisme',
'15' => 'Hifi, photo & videos',
'16' => 'Téléphonie & communication',
'17' => 'Bijoux & Métaux précieux',
'18' => 'Articles et Accessoires pour bébé',
'19' => 'Sonorisation & Lumière',
);
private $_carrier_type = array(
'1' => 'Retrait de la marchandise chez le marchand',
'2' => 'Utilisation d\'un réseau de points-retrait tiers (type kiala, alveol, etc.)',
'3' => 'Retrait dans un aéroport, une gare ou une agence de voyage',
'4' => 'Transporteur (La Poste, Colissimo, UPS, DHL... ou tout transporteur privé)',
'5' => 'Emission d\'un billet électronique, téléchargements',
);
private $_payement_type = array(
1 => 'carte',
2 => 'cheque',
3 => 'contre-remboursement',
4 => 'virement',
5 => 'cb en n fois',
6 => 'paypal',
7 => '1euro.com',
8 => 'buyster',
9 => 'bybox',
);
public function __construct()
{
$this->name = 'fianetfraud';
$this->tab = 'payment_security';
$this->version = '2.2';
$this->limited_countries = array('fr');
parent::__construct();
$this->author = 'PrestaShop';
$this->displayName = 'FIA-NET - Certissim';
$this->description = "Protégez vous contre la fraude à la carte bancaire sans perturber l'acte d'achat";
self::$token = sha1('fianetfraud' . _COOKIE_KEY_ . 'token');
}
public function install()
{
insertLog(__METHOD__ . " : " . __LINE__, "Installation du module");
if (!parent::install())
return false;
if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))
return false;
elseif (!$sql = file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))
return false;
$sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
$sql = preg_split("/;\s*[\r\n]+/", $sql);
foreach ($sql as $query)
if ($query and sizeof($query) and !Db::getInstance()->Execute(trim($query)))
return false;
$langs = Language::getLanguages();
$sac = new Sac();
$sac->setStatus('test');
$sac->saveParamInFile();
//nettoyage des orderState de l'ancien module
$orderStateFraud = new OrderState((int) Configuration::get('SAC_ID_FRAUD'), (int) Configuration::get('PS_LANG_DEFAULT'));
$orderStateValid = new OrderState((int) Configuration::get('SAC_ID_VALID'), (int) Configuration::get('PS_LANG_DEFAULT'));
$orderStateWaiting = new OrderState((int) Configuration::get('SAC_ID_WAITING'), (int) Configuration::get('PS_LANG_DEFAULT'));
$orderStateTest = new OrderState((int) Configuration::get('SAC_ID_UNKNOWN'), (int) Configuration::get('PS_LANG_DEFAULT'));
$orderStateFraud->delete();
$orderStateValid->delete();
$orderStateWaiting->delete();
$orderStateTest->delete();
//test de connexion à la BDD
$bddwritable = Db::getInstance()->Execute("
INSERT INTO `" . _DB_PREFIX_ . self::CERTISSIM_TABLE_NAME . "` (`id_order`, `ip_address`, `date`)
VALUES ('0', '" . pSQL($_SERVER['REMOTE_ADDR']) . "','" . pSQL(date('Y-m-d H:i:s')) . "')");
//log
insertLog(__METHOD__ . " : " . __LINE__, (bool) $bddwritable ? "Database is writable" : "Database is not writable");
//nettoyage du test si test réussi
if ($bddwritable)
{
Db::getInstance()->Execute("
DELETE FROM `" . _DB_PREFIX_ . self::CERTISSIM_TABLE_NAME . "`
WHERE `id_order`='0'");
}
//test de connexion SSL par un envoi stacking vide
$emptystack = new XMLElement('
' : ''
);
$this->_html .= '