This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||
2 | |||
3 | namespace XoopsModules\Oledrion; |
||
4 | |||
5 | /* |
||
6 | You may not change or alter any portion of this comment or credits |
||
7 | of supporting developers from this source code or any supporting source code |
||
8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
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. |
||
13 | */ |
||
14 | |||
15 | /** |
||
16 | * oledrion |
||
17 | * |
||
18 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
19 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
20 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
21 | */ |
||
22 | |||
23 | /** |
||
24 | * Gestion des fabricants |
||
25 | */ |
||
26 | |||
27 | use XoopsModules\Oledrion; |
||
28 | |||
29 | /** |
||
30 | * Class Manufacturer |
||
31 | */ |
||
32 | class Manufacturer extends OledrionObject |
||
33 | { |
||
34 | /** |
||
35 | * constructor |
||
36 | * |
||
37 | * normally, this is called from child classes only |
||
38 | */ |
||
39 | public function __construct() |
||
40 | { |
||
41 | $this->initVar('manu_id', XOBJ_DTYPE_INT, null, false); |
||
42 | $this->initVar('manu_name', XOBJ_DTYPE_TXTBOX, null, false); |
||
43 | $this->initVar('manu_commercialname', XOBJ_DTYPE_TXTBOX, null, false); |
||
44 | $this->initVar('manu_email', XOBJ_DTYPE_TXTBOX, null, false); |
||
45 | $this->initVar('manu_bio', XOBJ_DTYPE_OTHER, null, false); |
||
46 | $this->initVar('manu_url', XOBJ_DTYPE_TXTBOX, null, false); |
||
47 | $this->initVar('manu_photo1', XOBJ_DTYPE_TXTBOX, null, false); |
||
48 | $this->initVar('manu_photo2', XOBJ_DTYPE_TXTBOX, null, false); |
||
49 | $this->initVar('manu_photo3', XOBJ_DTYPE_TXTBOX, null, false); |
||
50 | $this->initVar('manu_photo4', XOBJ_DTYPE_TXTBOX, null, false); |
||
51 | $this->initVar('manu_photo5', XOBJ_DTYPE_TXTBOX, null, false); |
||
52 | // Pour autoriser le html |
||
53 | $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Retourne l'URL d'une des 5 images du fabricant courant |
||
58 | * |
||
59 | * @param int $pictureNumber Le numéro (de 1 à 5) de l'image que l'on souhaite récupérer |
||
60 | * @return mixed L'URL Soit l'url de l'image soit False si l'indice passé en paramètre n'est pas correct |
||
61 | */ |
||
62 | public function getPictureUrl($pictureNumber) |
||
63 | { |
||
64 | $pictureNumber = (int)$pictureNumber; |
||
65 | if ($pictureNumber > 0 && $pictureNumber < 6) { |
||
66 | return OLEDRION_PICTURES_URL . '/' . $this->getVar('manu_photo' . $pictureNumber); |
||
67 | } |
||
68 | |||
69 | return false; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Retourne le chemin de l'une des 5 images du fabricant courant |
||
74 | * |
||
75 | * @param int $pictureNumber Le numéro (de 1 à 5) de l'image que l'on souhaite récupérer |
||
76 | * @return string Le chemin |
||
77 | */ |
||
78 | public function getPicturePath($pictureNumber) |
||
79 | { |
||
80 | $pictureNumber = (int)$pictureNumber; |
||
81 | if ($pictureNumber > 0 && $pictureNumber < 6) { |
||
82 | return OLEDRION_PICTURES_PATH . '/' . $this->getVar('manu_photo' . $pictureNumber); |
||
83 | } |
||
84 | |||
85 | return false; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Indique si une des 5 images du fabricant existe |
||
90 | * |
||
91 | * @param int $pictureNumber Le numéro (de 1 à 5) de l'image que l'on souhaite récupérer |
||
92 | * @return bool Vrai si l'image existe sinon faux |
||
93 | */ |
||
94 | public function pictureExists($pictureNumber) |
||
95 | { |
||
96 | $pictureNumber = (int)$pictureNumber; |
||
97 | $return = false; |
||
98 | if ($pictureNumber > 0 && $pictureNumber < 6) { |
||
99 | if ('' !== xoops_trim($this->getVar('manu_photo' . $pictureNumber)) && file_exists(OLEDRION_PICTURES_PATH . '/' . $this->getVar('manu_photo' . $pictureNumber))) { |
||
100 | $return = true; |
||
101 | } |
||
102 | } |
||
103 | |||
104 | return $return; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Supprime une des 5 images du fabricant |
||
109 | * |
||
110 | * @param int $pictureNumber Le numéro (de 1 à 5) de l'image que l'on souhaite récupérer |
||
111 | */ |
||
112 | public function deletePicture($pictureNumber) |
||
113 | { |
||
114 | $pictureNumber = (int)$pictureNumber; |
||
115 | if ($pictureNumber > 0 && $pictureNumber < 6) { |
||
116 | if ($this->pictureExists($pictureNumber)) { |
||
117 | if (false === @unlink(OLEDRION_PICTURES_PATH . '/' . $this->getVar('manu_photo' . $pictureNumber))) { |
||
118 | throw new \RuntimeException('The picture ' . OLEDRION_PICTURES_PATH . '/' . $this->getVar('manu_photo' . $pictureNumber) . ' could not be deleted.'); |
||
119 | } |
||
120 | } |
||
121 | $this->setVar('manu_photo' . $pictureNumber, ''); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Supprime toutes les images du fabricant (raccourcis) |
||
127 | */ |
||
128 | public function deletePictures() |
||
129 | { |
||
130 | for ($i = 1; $i <= 5; ++$i) { |
||
131 | $this->deletePicture($i); |
||
132 | } |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Retourne l'url à utiliser pour accéder à la page d'un fabricant |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getLink() |
||
141 | { |
||
142 | $url = ''; |
||
143 | if (1 == Oledrion\Utility::getModuleOption('urlrewriting')) { |
||
144 | // On utilise l'url rewriting |
||
145 | $url = OLEDRION_URL . 'manufacturer-' . $this->getVar('manu_id') . Oledrion\Utility::makeSeoUrl($this->getVar('manu_commercialname', 'n') . ' ' . $this->getVar('manu_name')) . '.html'; |
||
146 | } else { |
||
147 | // Pas d'utilisation de l'url rewriting |
||
148 | $url = OLEDRION_URL . 'manufacturer.php?manu_id=' . $this->getVar('manu_id'); |
||
149 | } |
||
150 | |||
151 | return $url; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * Rentourne la chaine à envoyer dans une balise <a> pour l'attribut href |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getHrefTitle() |
||
160 | { |
||
161 | return Oledrion\Utility::makeHrefTitle($this->getVar('manu_commercialname') . ' ' . $this->getVar('manu_name')); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * Retourne l'initiale du fabricant (à modifier selon le sens de l'écriture !) |
||
166 | * @return string L'initiale |
||
167 | */ |
||
168 | public function getInitial() |
||
169 | { |
||
170 | return mb_strtoupper($this->getVar('manu_name')[0]); |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * Retourne les éléments du fabricant formatés pour affichage |
||
175 | * |
||
176 | * @param string $format Le format à utiliser |
||
177 | * @return array Les informations formatées |
||
178 | */ |
||
179 | public function toArray($format = 's') |
||
180 | { |
||
181 | $ret = []; |
||
0 ignored issues
–
show
|
|||
182 | $ret = parent::toArray($format); |
||
183 | for ($i = 1; $i <= 5; ++$i) { |
||
184 | $ret['manu_photo' . $i . '_url'] = $this->getPictureUrl($i); |
||
185 | } |
||
186 | $ret['manu_url_rewrited'] = $this->getLink(); |
||
187 | $ret['manu_href_title'] = $this->getHrefTitle(); |
||
188 | $ret['manu_initial'] = $this->getInitial(); |
||
189 | |||
190 | return $ret; |
||
191 | } |
||
192 | } |
||
193 |