75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to a commercial license from Common-Services Co., Ltd.
|
|
* Use, copy, modification or distribution of this source file without written
|
|
* license agreement from the SARL SMC is strictly forbidden.
|
|
* In order to obtain a license, please contact us: contact@common-services.com
|
|
* ...........................................................................
|
|
* INFORMATION SUR LA LICENCE D'UTILISATION
|
|
*
|
|
* L'utilisation de ce fichier source est soumise a une licence commerciale
|
|
* concedee par la societe Common-Services Co., Ltd.
|
|
* Toute utilisation, reproduction, modification ou distribution du present
|
|
* fichier source sans contrat de licence ecrit de la part de la Common-Services Co. Ltd. est
|
|
* expressement interdite.
|
|
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
|
|
* ...........................................................................
|
|
*
|
|
* @package SoNice Retour
|
|
* @author Alexandre D.
|
|
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
|
|
* @license Commercial license
|
|
* Support by mail : support.sonice@common-services.com
|
|
*/
|
|
|
|
class SoNiceRetourTools
|
|
{
|
|
|
|
public static function cleanup()
|
|
{
|
|
$now = time();
|
|
|
|
$output_dir = _PS_MODULE_DIR_.'sonice_retour/download/';
|
|
|
|
if (!is_dir($output_dir)) {
|
|
return null;
|
|
}
|
|
|
|
$files_pdf = glob($output_dir.'*.pdf');
|
|
$files_prn = glob($output_dir.'*.prn');
|
|
$files = array_merge($files_pdf, $files_prn);
|
|
|
|
if (!is_array($files) || !count($files)) {
|
|
return null;
|
|
}
|
|
|
|
// Sort by date
|
|
foreach ($files as $file) {
|
|
if (filemtime($file) < $now - (86400 * 31)) {
|
|
unlink($file);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function moduleIsInstalled($module_name)
|
|
{
|
|
if (method_exists('Module', 'isInstalled')) {
|
|
return (Module::isInstalled($module_name));
|
|
} else {
|
|
Db::getInstance()->executeS(
|
|
'SELECT `id_module`
|
|
FROM `'._DB_PREFIX_.'module`
|
|
WHERE `name` = \''.pSQL($module_name).'\''
|
|
);
|
|
return (bool)Db::getInstance()->numRows();
|
|
}
|
|
}
|
|
|
|
public static function arrayMapCastInteger($value)
|
|
{
|
|
return (int)$value;
|
|
}
|
|
}
|