1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Copyright (C) 2024 Rafael San José <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This program is free software; you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU General Public License as published by |
7
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
8
|
|
|
* any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Dolibarr\Core\Base; |
20
|
|
|
|
21
|
|
|
use Illuminate\Database\Eloquent\Model as EloquentModel; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* This class implements an Eloquent Model |
25
|
|
|
* |
26
|
|
|
* This class is only needed for compatibility with Dolibarr. |
27
|
|
|
* |
28
|
|
|
* @package DoliCore\Base |
29
|
|
|
*/ |
30
|
|
|
abstract class Model extends EloquentModel |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Name of the field containing the record creation date, by default 'created_at'. |
34
|
|
|
*/ |
35
|
|
|
public const CREATED_AT = 'date_creat'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Name of the field that contains the date of the last update of the record, by default 'updated_at'. |
39
|
|
|
*/ |
40
|
|
|
public const UPDATED_AT = 'tms'; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Primary key name, default is 'id'. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $primaryKey = 'rowid'; |
48
|
|
|
|
49
|
|
|
public static function decrypt($value) |
50
|
|
|
{ |
51
|
|
|
global $conf; |
52
|
|
|
|
53
|
|
|
// Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) |
54
|
|
|
$cryptType = (!empty($conf->db->dolibarr_main_db_encryption) ? $conf->db->dolibarr_main_db_encryption : 0); |
55
|
|
|
|
56
|
|
|
//Encryption key |
57
|
|
|
$cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey) ? $conf->db->dolibarr_main_db_cryptkey : ''); |
58
|
|
|
|
59
|
|
|
$return = $value; |
60
|
|
|
|
61
|
|
|
if ($cryptType && !empty($cryptKey)) { |
62
|
|
|
if ($cryptType == 2) { |
63
|
|
|
$return = 'AES_DECRYPT(' . $value . ',\'' . $cryptKey . '\')'; |
64
|
|
|
} elseif ($cryptType == 1) { |
65
|
|
|
$return = 'DES_DECRYPT(' . $value . ',\'' . $cryptKey . '\')'; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $return; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|