XoopsModules25x /
oledrion
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 | use XoopsModules\Oledrion; |
||||
| 24 | |||||
| 25 | /** |
||||
| 26 | * Product category management |
||||
| 27 | */ |
||||
| 28 | |||||
| 29 | /** |
||||
| 30 | * Class Category |
||||
| 31 | */ |
||||
| 32 | class Category 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('cat_cid', XOBJ_DTYPE_INT, null, false); |
||||
| 42 | $this->initVar('cat_pid', XOBJ_DTYPE_INT, null, false); |
||||
| 43 | $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX, null, false); |
||||
| 44 | $this->initVar('cat_imgurl', XOBJ_DTYPE_TXTBOX, null, false); |
||||
| 45 | $this->initVar('cat_description', XOBJ_DTYPE_OTHER, null, false); |
||||
| 46 | $this->initVar('cat_advertisement', XOBJ_DTYPE_OTHER, null, false); |
||||
| 47 | $this->initVar('cat_metakeywords', XOBJ_DTYPE_TXTBOX, null, false); |
||||
| 48 | $this->initVar('cat_metadescription', XOBJ_DTYPE_TXTBOX, null, false); |
||||
| 49 | $this->initVar('cat_metatitle', XOBJ_DTYPE_TXTBOX, null, false); |
||||
| 50 | $this->initVar('cat_footer', XOBJ_DTYPE_OTHER, null, false); |
||||
| 51 | // Pour autoriser le html |
||||
| 52 | $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
||||
| 53 | } |
||||
| 54 | |||||
| 55 | /** |
||||
| 56 | * Returns the image URL of the current category |
||||
| 57 | * @return string URL |
||||
| 58 | */ |
||||
| 59 | public function getPictureUrl() |
||||
| 60 | { |
||||
| 61 | return OLEDRION_PICTURES_URL . '/' . $this->getVar('cat_imgurl'); |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | /** |
||||
| 65 | * Return the image path of the current category |
||||
| 66 | * @return string The path |
||||
| 67 | */ |
||||
| 68 | public function getPicturePath() |
||||
| 69 | { |
||||
| 70 | return OLEDRION_PICTURES_PATH . '/' . $this->getVar('cat_imgurl'); |
||||
| 71 | } |
||||
| 72 | |||||
| 73 | /** |
||||
| 74 | * Indicates whether the category image exists |
||||
| 75 | * |
||||
| 76 | * @return bool True if the image exists if not false |
||||
| 77 | */ |
||||
| 78 | public function pictureExists() |
||||
| 79 | { |
||||
| 80 | $return = false; |
||||
| 81 | if ('' !== xoops_trim($this->getVar('cat_imgurl')) && file_exists(OLEDRION_PICTURES_PATH . '/' . $this->getVar('cat_imgurl'))) { |
||||
| 82 | $return = true; |
||||
| 83 | } |
||||
| 84 | |||||
| 85 | return $return; |
||||
| 86 | } |
||||
| 87 | |||||
| 88 | /** |
||||
| 89 | * Deletes the image associated with a category |
||||
| 90 | */ |
||||
| 91 | public function deletePicture() |
||||
| 92 | { |
||||
| 93 | if ($this->pictureExists()) { |
||||
| 94 | if (false === @unlink(OLEDRION_PICTURES_PATH . '/' . $this->getVar('cat_imgurl'))) { |
||||
| 95 | throw new \RuntimeException('The picture ' . OLEDRION_PICTURES_PATH . '/' . $this->getVar('cat_imgurl') . ' could not be deleted.'); |
||||
| 96 | } |
||||
| 97 | } |
||||
| 98 | $this->setVar('cat_imgurl', ''); |
||||
| 99 | } |
||||
| 100 | |||||
| 101 | /** |
||||
| 102 | * Returns the url to use to access the category taking into account the preferences of the module |
||||
| 103 | * |
||||
| 104 | * @return string The url to use |
||||
| 105 | */ |
||||
| 106 | public function getLink() |
||||
| 107 | { |
||||
| 108 | require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
||||
| 109 | $url = ''; |
||||
| 110 | if (1 == Oledrion\Utility::getModuleOption('urlrewriting')) { |
||||
| 111 | // On utilise l'url rewriting |
||||
| 112 | $url = OLEDRION_URL . 'category-' . $this->getVar('cat_cid') . Oledrion\Utility::makeSeoUrl($this->getVar('cat_title', 'n')) . '.html'; |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 113 | } else { |
||||
| 114 | // Pas d'utilisation de l'url rewriting |
||||
| 115 | $url = OLEDRION_URL . 'category.php?cat_cid=' . $this->getVar('cat_cid'); |
||||
| 116 | } |
||||
| 117 | |||||
| 118 | return $url; |
||||
| 119 | } |
||||
| 120 | |||||
| 121 | /** |
||||
| 122 | * Gets the string to send in a <a> tag for the href attribute |
||||
| 123 | * |
||||
| 124 | * @return string|array |
||||
| 125 | */ |
||||
| 126 | public function getHrefTitle() |
||||
| 127 | { |
||||
| 128 | return Oledrion\Utility::makeHrefTitle($this->getVar('cat_title')); |
||||
|
0 ignored issues
–
show
It seems like
$this->getVar('cat_title') can also be of type array and array; however, parameter $title of XoopsModules\Oledrion\Utility::makeHrefTitle() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 129 | } |
||||
| 130 | |||||
| 131 | /** |
||||
| 132 | * Returns the elements of the products formatted for display |
||||
| 133 | * |
||||
| 134 | * @param string $format |
||||
| 135 | * @return array |
||||
| 136 | */ |
||||
| 137 | public function toArray($format = 's') |
||||
| 138 | { |
||||
| 139 | $ret = []; |
||||
|
0 ignored issues
–
show
|
|||||
| 140 | $ret = parent::toArray($format); |
||||
| 141 | $ret['cat_full_imgurl'] = $this->getPictureUrl(); |
||||
| 142 | $ret['cat_href_title'] = $this->getHrefTitle(); |
||||
| 143 | $ret['cat_url_rewrited'] = $this->getLink(); |
||||
| 144 | |||||
| 145 | return $ret; |
||||
| 146 | } |
||||
| 147 | } |
||||
| 148 |