privilegedemarque/controllers/admin/AdminLogsController.php

213 lines
29 KiB
PHP
Raw Normal View History

2016-04-14 16:14:31 +02:00
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminLogsControllerCore extends AdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'log';
$this->className = 'PrestaShopLogger';
$this->lang = false;
$this->noLink = true;
$this->fields_list = array(
'id_log' => array(
'title' => $this->l('ID'),
'align' => 'text-center',
'class' => 'fixed-width-xs'
),
'employee' => array(
'title' => $this->l('Employee'),
'havingFilter' => true,
'callback' => 'displayEmployee',
'callback_object' => $this
),
'severity' => array(
'title' => $this->l('Severity (1-4)'),
'align' => 'text-center',
'class' => 'fixed-width-xs'
),
'message' => array(
'title' => $this->l('Message')
),
'object_type' => array(
'title' => $this->l('Object type'),
'class' => 'fixed-width-sm'
),
'object_id' => array(
'title' => $this->l('Object ID'),
'align' => 'center',
'class' => 'fixed-width-xs'
),
'error_code' => array(
'title' => $this->l('Error code'),
'align' => 'center',
'prefix' => '0x',
'class' => 'fixed-width-xs'
),
'date_add' => array(
'title' => $this->l('Date'),
'align' => 'right',
'type' => 'datetime'
)
);
$this->fields_options = array(
'general' => array(
'title' => $this->l('Logs by email'),
'icon' => 'icon-envelope',
'fields' => array(
'PS_LOGS_BY_EMAIL' => array(
'title' => $this->l('Minimum severity level'),
'hint' => $this->l('Enter "5" if you do not want to receive any emails.').'<br />'.$this->l('Emails will be sent to the shop owner.'),
'cast' => 'intval',
'type' => 'text'
)
),
'submit' => array('title' => $this->l('Save'))
)
);
// if (($handle = fopen(_PS_UPLOAD_DIR_."pros.csv", "r")) !== FALSE)
// {
// $req_email = '';
// $sql = '';
// while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
// {
// $value = explode('|', $data[0]);
// $req_email .= (!empty($req_email) ? ' OR ' : '').' email = "'.$value[0].'"';
// $sql .= 'WHEN "' . $value[0] . '" THEN "' . $value[1] . '"'. "\n";
// }
// $sql = 'UPDATE '._DB_PREFIX_.'customer SET `pro_passwd` = CASE `email` '.$sql.' ELSE `pro_passwd` END, pro = 1 WHERE '.$req_email;
// var_dump(Db::getInstance()->execute($sql));
// var_dump(Db::getInstance()->getMsgError());
// exit;
// fclose($handle);
// }
// if (($handle = fopen(_PS_UPLOAD_DIR_."md5.csv", "r")) !== FALSE)
// {
// $i = 0;
// while (($data = fgetcsv($handle, 1000, "|")) !== FALSE)
// {
// if($i == 0)
// {
// $i++;
// continue;
// }
// file_put_contents(_PS_UPLOAD_DIR_.'md5_finish.csv', $data[4].';'.md5($data[4])."\n", 0775, , FILE_APPEND);
// }
// }
if(Tools::getIsset('test'))
{
$table = 'ps_customer';
if(!Tools::getIsset('month')
|| Tools::getValue('month') == 'fevrier')
{
$md5 = array('022e1e0251fe9b394d6cd12e7fd001b3','a4f279f6ab7a1884b2b911b41d860c6e','b3cf5e70e5ef44a8e03194e43558d317','0ded9c216f755311f819cc44a351dac7','c266dd156345b6e4e5e01c53ab1cf0df','7709c9b299a84948579fff6298d46b0c','9b2342ebc12b1b419a3f8355178e25d3','19c3d29c6a5e649d01a548c3bc1c5c95','33098c5aa789a6eb62641fe6cb21bb38','49f9b6c27f58e3a23737056f27462b67','6246554a74adf17289bf65242282d3da','b0d457b22a55e93ba72718ec45750351','c1f4fbd33beba8d5728a798668b3da2d','32c838230597723b10420eff1563c3f9','9fd153311f4e1fb8239ba0a2e7ab4531','6801d08160585997cb9b81c5cdde8bce','0c8075ee62e728c22e97f4a1f9003216','c444be67befa0df353b66cdd47c270f1','fdda5bc31746e203df3544070ead97a6','bcf63d0668b867d6b26e0b4357f21d90','36aab7a4f7032464336667ace6f16093','f6a6aa6e3ca695ac297ec7e2b6dcc550','7f9f475246e94498c544bc23b238fa20','eec00f8744de6cffea086de6628f6aba','8c855983b493c028c75d9647c8e2ebd1','4d0846e5b78163c08570b1802bfbdb61','b02f3029bccf113ccd69728ec236cdd0','5eafae0c8b6df1012ae7dea72179891f','22938d481572953b0e1504d28ae7c140','381aeb4038a7c707b67ecd2187746a47','5833f98870102abfec5ecaf736ea57b3','a9ffb7aa67430d0498e2e0231fec7eb9','eca88f97a2b0602bf5c86c7d03e56f99','985e973433bd53fb16f459c69dcce57a','73bbbcda1ad184ffc9411e7315cd8a7b','8ab18e482293116cc0300bd1d8e862ee','3587097ba3d63c1fa935c017e7be0ea0','cb4e6c9fa2390aba1eacb2212cca5067','911b949ee5f7202a2040c5e518d5ec87','6d33a837a74701800f1809510771fcdf','120220230301dee0f1f3facd0c49112b','fd8797b10cc4cd658fb01f5f9aa4cd3c','56a9e1ff4792531e2b0c11685667c344','6cdc688b54504e92f7aa9920fc60fcfb','e7efb1fcb5f562ef8d0521a6f195a200','b575f4cace0bed931e3805dc57f31745','7cb5c34025a2de4eec46b85654a5f9b8','0b9e721adf4e350441b27762b0d345a5','8b658b1f155c57c226f72ab88cf41f17','f5c16b9bdb8d9b394d60c686da662673','ffaaae1ca0423c824c38e2f69e774b14','1a55f957922d0eef94112bb1adeb2b48','d35fa811547fcb2f5f32ca56dc6ba11f','0934ba005506ca20a9f78962cc5cf54f','2299e389262f20b336f97dcf3f5943bb','f9cc24625c03d046f70cadbc90c91b00','c1a7900f54a11aee6646e3eb91845391','10a0681035d01d89db49d2b3ca643fb5','98d777e04f5de94d870fff83250ed2ac','1cbfcd4d836640e76f08d388265b068c','448fc84457825b203fcaf34729181048','fcb9c6b1d1d7466b3b4ea4c61b24ce3e','bc46cb11dc887c506a7bba5f2ab1bb37','1f5ea77fcfe5c246ca0cddada70f7529','3e50711d73090f4a80d03391683c4b00','38809ea6c897119ff1197199f166e471','0c00691810b68b874ead0ad86d496c31','283ba21b9e66e4997596805b0d09b88f','9b245a22ba9030daaef5fd65bce250da','3768d60f9f87fc6122726185df3020b7','e0d0286c538c85862e3dda7a1a59af24','84e40719d90d9bdb0231741e97748961','9b565a080ae4fe5795f8c98cd98e75f5','91ae7c4ef177bbb8a27ad7c2ed8b78d4','99d727881d708698b8322acd743ace51','e88442c6115b34a7c98e38b24e62e22f','cec998131d8fecae5b743dd69593ef2a','fb027ae9778515ceaa109d017235fb9e','85ad1d74846bf1e53cd8e15cf97d0c66','3c6f4da0ad0e361915b839a9d54379a5','c31a7af9ca4a6687ce2f11c6569680c3','8c19599b0bbdddd3e4bbd34507cbbf24','d627d6d6e0efae061089ffb7ceb7e071','1ccf3ac64e58b29e3bf78a48078f3fab','d1b661b3c1682059430ab099aa5bcddb','90db918d10a4ed89d14645413576a390','8954d2bef18730a0ab9e8722b471fbea','307d0ab593981b3554779824a8f7b3ae','ce724a2773670866d5b1622612052ed4','a907c494ab350320b1d7761010e98361','c3f24c0b46dbad45320e8f23749b4375','b2027d738ae0a4c2c88f6bf122c094cc','59cf4f8c4ef58ef295f3434544cfe190','24a2ec3bdb780a08421b7dbb609a858c','b642b4217b34b1e8d3bd915fc65c4452','af28829c29e81803a5a796ac8ca540d4','3ebb16be7f1b49721155a697d54d4889','283a4d905567d5b3be99d8604ded84cd','40103fbad09fcb214ab77dbfc7a98240','efcb312a470b3d1db00ddc2b4fbcb639','32bef3a3c82cdc70550396867e8d0a64','f08d0c44ee1c862a996e98abdf19fa74','f52ce16bc2066a290cff303e31ea70fb','769df804252afc718cf7646f52d7f5b5','7b06bf6abfa9c424f8e964b725b0c646','79d6c00261f47fd0c28ac841205427cf','ad3ef812a3e6b0f6cfe12759f6a9814a','6c6f0084cdb6d65b739296e8570fae08','43fb9214b0401589ac1c05dbd7a029d0','a539cbf55837f0071dc9551ddbba3059','edf30fb1cf19684182801ad2c0325b18','aa2fbf3841b8eb74bf6cf338bdbcb986','3c8523416046298e11ad3d7623d37f61','9af9d98837631fa1a03a2f3dbe2d9982','5179e9544281a5170c3eef72c344c716','9272f69d7a96855876128d436eeedd18','0d4c50e097d68c5f6
}
elseif(Tools::getValue('month') == 'janvier')
{
$md5 = array('18a52e3d0e3098c80b5c41637fc51873','261fa3d83674c49111c01c4a4c381bf0','f6a9df42a8ddf8e3a9043dd12a797718','a08ab95633e85b12d20149cf9d6b6224','2358e089e09c579442962af43151f297','d761df5d229b535ddcc8e695615b99e5','53dd6f4d1cc2b67cc77258acb377dd4b','aa4946b0348a00d0b7570482105581ce','007b31559f8436d04760c4edc395e72e','45658e46e704ad1e99f3f4809236cae1','9654f8cae43392bed2c6533c9bef1c39','a4c56f4469bb8b12fd85225c5404780a','b1cc2a9cfe33461de075adda92440cf5','a71824a8501f35e736b812728b1445dc','705a9e9121bcbf52eb878b56dbe965eb','1af03d99a2606d65e0b3224a3848e56d','5eac4dd3335c8b1a4f8c975e031c04de','edfe650908ca915ee5b9604da2259fc3','79886ff674ef5f9b96e7668d06a678d2','37a69eb9de5e66c5995c4a9f2ba42328','8e84844f6cede3ba5bf5b8f222fa951d','37409256a154e5e683992cfbf29bfd33','1b881f29df64b9425ec04d09dbb98b91','e5e2989decb6dfa76d9af4aa52134854','4940e7ba2f7ce3ca6184d782794ac818','692b63ebc32b2c9ca3795644955f21dc','fcb9c6b1d1d7466b3b4ea4c61b24ce3e','448fc84457825b203fcaf34729181048','1cbfcd4d836640e76f08d388265b068c','028231e704d4b9892dc69d046249ee4d','98d777e04f5de94d870fff83250ed2ac','10a0681035d01d89db49d2b3ca643fb5','c1a7900f54a11aee6646e3eb91845391','f9cc24625c03d046f70cadbc90c91b00','2299e389262f20b336f97dcf3f5943bb','0934ba005506ca20a9f78962cc5cf54f','50af38cac03f319a63e060ae2f07a35a','d35fa811547fcb2f5f32ca56dc6ba11f','1a55f957922d0eef94112bb1adeb2b48','ffaaae1ca0423c824c38e2f69e774b14','f5c16b9bdb8d9b394d60c686da662673','8b658b1f155c57c226f72ab88cf41f17','0b9e721adf4e350441b27762b0d345a5','7cb5c34025a2de4eec46b85654a5f9b8','b575f4cace0bed931e3805dc57f31745','e7efb1fcb5f562ef8d0521a6f195a200','6cdc688b54504e92f7aa9920fc60fcfb','56a9e1ff4792531e2b0c11685667c344','fd8797b10cc4cd658fb01f5f9aa4cd3c','120220230301dee0f1f3facd0c49112b','efefb4c13d56db9c3fca7d0bfc71cb9a','f9edc4c6f058f12b87a5b2a2b58bc4f6','6d33a837a74701800f1809510771fcdf','911b949ee5f7202a2040c5e518d5ec87','cb4e6c9fa2390aba1eacb2212cca5067','3587097ba3d63c1fa935c017e7be0ea0','8ab18e482293116cc0300bd1d8e862ee','73bbbcda1ad184ffc9411e7315cd8a7b','985e973433bd53fb16f459c69dcce57a','eca88f97a2b0602bf5c86c7d03e56f99','a9ffb7aa67430d0498e2e0231fec7eb9','5833f98870102abfec5ecaf736ea57b3','381aeb4038a7c707b67ecd2187746a47','770ef37b1cd0956f3388baaf58a99605','22938d481572953b0e1504d28ae7c140','6e5a490c270d2de35831ec7b5fe069e1','dce1581cf40f227ddc1b23453a85208e','5eafae0c8b6df1012ae7dea72179891f','f85b39e1f2bb202705820e3bbed20c19','e261136cbef4f9ba611fa86a6f2fdd31','b02f3029bccf113ccd69728ec236cdd0','4d0846e5b78163c08570b1802bfbdb61','e0fa8e98f0b4cf37a1171db1b691d20c','7e8b92ac45ef84fcd5a97fb2683a0af1','949ea96501a3ca91ca81922a38b22054','1dc665525a0a25cbe25d8b89f108a894','8c855983b493c028c75d9647c8e2ebd1','eec00f8744de6cffea086de6628f6aba','7f9f475246e94498c544bc23b238fa20','f6a6aa6e3ca695ac297ec7e2b6dcc550','19724933e3821ff293dfba6e2580b3e8','36aab7a4f7032464336667ace6f16093','bcf63d0668b867d6b26e0b4357f21d90','fdda5bc31746e203df3544070ead97a6','c444be67befa0df353b66cdd47c270f1','527aed432dd43ee74dc547467ddb5646','0c8075ee62e728c22e97f4a1f9003216','6801d08160585997cb9b81c5cdde8bce','6918b25e92638b12e1670cc6248eedbe','9fd153311f4e1fb8239ba0a2e7ab4531','2a785472345c6288504c216986bec56d','44d07252d5b36941513cf74cf498c0b5','56a78c666740e0ec015c264b30690ff0','3dccc1e9e39e10a40785744cf23a8d2a','66ec9728a25b1978bfcbbcd5c6f6e881','f965cd33374c5fff4dc0dc29da1e34e2','9611ba8966aff03d4400e3bebc2bb059','773e0de1c1f315445a5f0a7ce0d89dd0','32c838230597723b10420eff1563c3f9','c1f4fbd33beba8d5728a798668b3da2d','b0d457b22a55e93ba72718ec45750351','0c103b90d3884718cd0585b649bd9a05','6246554a74adf17289bf65242282d3da','fa2eead5c8e7ba5f3a1981186f7663d9','6010217f940b0a96dd7cec832a0890ca','d3f5b51bd294da44d1cde0678a98a52a','04f5e227116f26a2e601899898de7b38','89272ff1729f5ee69ebe91535f005eef','f6484ca1bdac7616330e27b135ca5d98','48241271e134899f17839d6171fa1948','471313b4de733580b06ff905c2c7a724','153fb2e3409d54eb88d393d7f193a2f5','425f4cd12926c6b3a6e3fb9f32ecd383','49f9b6c27f58e3a23737056f27462b67','206dcab4a81c52a32ba92719f39ce1e7','9e8d6df5146c6e97119e1ca4cb345a79','8cbca99322fca295d
}
$res = Db::getInstance()->executeS('SELECT a.email, md5(a.email) as email_encode, IFNULL(b.id_sponsor, 0), a.date_add FROM ps_customer a LEFT OUTER JOIN ps_referralprogram b ON b.id_customer = a.id_customer');
$arr = array();
foreach($res as $k => $r)
{
$arr[$r['email_encode']] = $r;
unset($res[$k]);
}
$md5_count = count($md5);
$md5_keys = array_keys($arr);
$md5_in = $md5_out = array();
foreach($md5 as $k => $md5_value)
{
if(in_array($md5_value, $md5_keys))
{
$md5_in[$md5_value] = $arr[$md5_value];
}
else
{
$md5_out[$md5_value] = $md5_value;
}
unset($md5[$k]);
}
echo 'liste des md5 n\'étant pas dans la table : '.$table.'<br /> Total : '.count($md5_out).'/'.$md5_count.'<br />';
echo implode('<br />', $md5_out);
echo '<hr ><br /><br />liste des md5 étant dans la table : '.$table.'<br /> Total : '.count($md5_in).'/'.$md5_count.'<br />
email, email encodé, sponsor, date d\'inscription<br /><br />';
echo implode('<br /><br />', array_map(function($elem){ return implode(', ', $elem); }, $md5_in) );
exit;
}
$this->list_no_link = true;
$this->_select .= 'CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) employee';
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'employee e ON (a.id_employee = e.id_employee)';
parent::__construct();
}
public function processDelete()
{
return PrestaShopLogger::eraseAllLogs();
}
public function initToolbar()
{
parent::initToolbar();
$this->toolbar_btn['delete'] = array(
'short' => 'Erase',
'desc' => $this->l('Erase all'),
'js' => 'if (confirm(\''.$this->l('Are you sure?').'\')) document.location = \''.Tools::safeOutput($this->context->link->getAdminLink('AdminLogs')).'&amp;token='.$this->token.'&amp;deletelog=1\';'
);
unset($this->toolbar_btn['new']);
}
public function displayEmployee($value, $tr)
{
$template = $this->context->smarty->createTemplate('controllers/logs/employee_field.tpl', $this->context->smarty);
$employee = new Employee((int)$tr['id_employee']);
$template->assign(array(
'employee_image' => $employee->getImage(),
'employee_name' => $value
));
return $template->fetch();
}
}