225 lines
11 KiB
PHP
225 lines
11 KiB
PHP
<?php
|
|
if(!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
include_once(_PS_MODULE_DIR_.'/ant_alerthack/models/Suspect.php');
|
|
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
|
|
|
|
class AdminAntAlertHack extends AdminTab {
|
|
public function postProcess() {
|
|
|
|
if (Tools::getValue('edit_suspect') && Tools::getValue('id_suspect')) {
|
|
$suspect = new Suspect((int)Tools::getValue('id_suspect'));
|
|
if(Tools::getValue('state')){
|
|
$suspect->is_suspect = Tools::getValue('state');
|
|
}
|
|
if($suspect->save()){
|
|
echo HelperFormBootstrap::displaySuccess($this->l('Suspect has been updated'));
|
|
return;
|
|
} else {
|
|
echo HelperFormBootstrap::displayError($this->l('Error occured while updating Suspect'));
|
|
return;
|
|
}
|
|
} elseif (Tools::isSubmit('update_conf')) {
|
|
if(($limit = Tools::getValue('limit')) !== false) {
|
|
Configuration::updateValue('ANT_ALERTHACK_LIMIT', (int) $limit);
|
|
}
|
|
if($time = Tools::getValue('time')) {
|
|
Configuration::updateValue('ANT_ALERTHACK_TIME', (int) $time);
|
|
}
|
|
if($emails = Tools::getValue('emails')) {
|
|
Configuration::updateValue('ANT_ALERTHACK_EMAILS', $emails);
|
|
}
|
|
echo HelperFormBootstrap::displaySuccess($this->l('Configurations has been updated'));
|
|
return;
|
|
}
|
|
}
|
|
|
|
public function display() {
|
|
global $cookie;
|
|
|
|
$helper = new HelperFormBootstrap();
|
|
$helper->_css.= $this->_addCss();
|
|
$html = $helper->renderStyle();
|
|
$html .= '
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2 style="font-size:24px;"><span class="anticon anticon-shield text-rose" style="font-size:24px;"></span> Alert Hack</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="row">
|
|
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
|
<div class="col-sm-4 col-sm-offset-4">';
|
|
$input = array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Emails :'),
|
|
'name' => 'emails',
|
|
'id' => 'emails',
|
|
'required' => true,
|
|
'help' => "Emails à alerter (séparés d'une virgule)",
|
|
'default' => Configuration::get('ANT_ALERTHACK_EMAILS')
|
|
);
|
|
$html.= $helper->generateInput($input);
|
|
$html.= '<div class="clearfix"></div>';
|
|
|
|
$input = array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Temps :'),
|
|
'name' => 'time',
|
|
'id' => 'time',
|
|
'required' => true,
|
|
'help' => "Temps en min ex: 5",
|
|
'default' => Configuration::get('ANT_ALERTHACK_TIME')
|
|
);
|
|
$html.= $helper->generateInput($input);
|
|
$html.= '<div class="clearfix"></div>';
|
|
|
|
$input = array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Limit :'),
|
|
'name' => 'limit',
|
|
'id' => 'limit',
|
|
'required' => true,
|
|
'help' => "Nombres de message envoyés dans le temps renseigné",
|
|
'default' => Configuration::get('ANT_ALERTHACK_LIMIT')
|
|
);
|
|
$html.= $helper->generateInput($input);
|
|
$html.= '<div class="clearfix"></div>';
|
|
|
|
$html .='
|
|
</div>
|
|
<div class="clear"></div>
|
|
<div class="ln_solid-small"></div>
|
|
<div class="text-right">
|
|
<input type="submit" class="btn btn-primary" name="update_conf" value="Enregistrer" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>';
|
|
|
|
$suspects = Suspect::getSuspects();
|
|
$states = Suspect::$states;
|
|
$html .= '
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2 style="font-size:24px;"><span class="anticon anticon-target" style="font-size:24px;"></span> Suspects</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<table class="table table-custombordered" style="width: 100%;">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-left">'.$this->l('ID').'</th>
|
|
<th class="text-left">'.$this->l('email').'</th>
|
|
<th class="text-left">'.$this->l('id_customer').'</th>
|
|
<th class="text-left">'.$this->l('Remote IP').'</th>
|
|
<th class="text-center">'.$this->l('Remote Host').'</th>
|
|
<th class="text-center">'.$this->l('Condition').'</th>
|
|
<th class="text-center">'.$this->l('State').'</th>
|
|
<th class="text-center">'.$this->l('Action').'</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
foreach ($suspects as $suspect) {
|
|
$html .= '
|
|
<tr>
|
|
<td class="text-left">'.$suspect['id_suspect'].'</td>
|
|
<td class="text-left">'.$suspect['email'].'</td>
|
|
<td class="text-left">'.$suspect['id_customer'].'</td>
|
|
<td class="text-left">'.$suspect['remote_ip'].'</td>
|
|
<td class="text-center">'.$suspect['remote_host'].'</td>
|
|
<td class="text-center">'.$suspect['condition'].'</td>
|
|
<td class="text-center"><i class="'.$states[(int)$suspect['is_suspect']]['icon'].'"></i> '.$states[(int)$suspect['is_suspect']]['name'].'</td>
|
|
<td class="text-center">
|
|
<form action="'.$_SERVER['REQUEST_URI'].'&edit_suspect=1" method="post">';
|
|
if($suspect['is_suspect'] == 1){
|
|
$html .= '
|
|
<button type="submit" class="btn btn-sm btn-default">Valider</button>
|
|
<input type="hidden" name="state" value="2">';
|
|
}elseif($suspect['is_suspect'] == 2){
|
|
$html .= '
|
|
<button type="submit" class="btn btn-sm btn-default">Bannir</button>
|
|
<input type="hidden" name="state" value="1">';
|
|
}
|
|
$html .='
|
|
<input type="hidden" name="id_suspect" value="'.$suspect['id_suspect'].'">
|
|
</form>
|
|
</td>
|
|
</tr>';
|
|
}
|
|
$html .= '
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>';
|
|
|
|
$html .= $helper->renderScript();
|
|
|
|
echo $html;
|
|
}
|
|
|
|
protected function _addCss()
|
|
{
|
|
return '
|
|
form sup {
|
|
color: #CC0000;
|
|
font-weight: bold;
|
|
vertical-align: sub;
|
|
}
|
|
#content .bootstrap-datetimepicker-widget tr th {
|
|
border-radius :0px !important;
|
|
}
|
|
.table tr th {
|
|
background: #565485;
|
|
background: rgba(86,84,133,0.9);
|
|
color: #fff;
|
|
font-size: 12px;
|
|
}
|
|
.table tr:nth-child(even) {
|
|
background: #F1F1F1;
|
|
}
|
|
.table>tbody>tr>td,
|
|
.table>tbody>tr>th,
|
|
.table>tfoot>tr>td,
|
|
.table>tfoot>tr>th,
|
|
.table>thead>tr>td,
|
|
.table>thead>tr>th {
|
|
vertical-align: middle;
|
|
}
|
|
.table .input-group-btn .btn {
|
|
padding: 4px 5px;
|
|
color: #504d8b;
|
|
|
|
}
|
|
.table .input-group-btn .btn .anticon{
|
|
font-size: 12px;
|
|
}
|
|
.bg-grey{
|
|
background: #EFEFEF;
|
|
border-radius:4px;
|
|
}
|
|
.bg-grey .div-title {
|
|
border-bottom: 2px solid #504D8B;
|
|
}
|
|
.div-title i.anticon,
|
|
.div-title i.glyphicon,
|
|
ul li a{
|
|
color:#504d8b;
|
|
}
|
|
';
|
|
}
|
|
} |