XoopsModules25x /
xhelp
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 declare(strict_types=1); |
||||
| 2 | |||||
| 3 | namespace XoopsModules\Xhelp; |
||||
| 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 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
| 17 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
| 18 | * @author Eric Juden <[email protected]> |
||||
| 19 | * @author XOOPS Development Team |
||||
| 20 | */ |
||||
| 21 | |||||
| 22 | if (!\defined('XHELP_CLASS_PATH')) { |
||||
| 23 | exit(); |
||||
| 24 | } |
||||
| 25 | |||||
| 26 | // require_once XHELP_CLASS_PATH . '/BaseObjectHandler.php'; |
||||
| 27 | |||||
| 28 | /** |
||||
| 29 | * StaffReviewHandler class |
||||
| 30 | * |
||||
| 31 | * StaffReview Handler for StaffReview class |
||||
| 32 | * |
||||
| 33 | * @author Eric Juden <[email protected]> & |
||||
| 34 | */ |
||||
| 35 | class StaffReviewHandler extends BaseObjectHandler |
||||
| 36 | { |
||||
| 37 | /** |
||||
| 38 | * Name of child class |
||||
| 39 | * |
||||
| 40 | * @var string |
||||
| 41 | */ |
||||
| 42 | public $classname = StaffReview::class; |
||||
| 43 | /** |
||||
| 44 | * DB table name |
||||
| 45 | * |
||||
| 46 | * @var string |
||||
| 47 | */ |
||||
| 48 | public $dbtable = 'xhelp_staffreview'; |
||||
| 49 | |||||
| 50 | private const TABLE = 'xhelp_staffreview'; |
||||
| 51 | private const ENTITY = StaffReview::class; |
||||
| 52 | private const ENTITYNAME = 'StaffReview'; |
||||
| 53 | private const KEYNAME = 'id'; |
||||
| 54 | private const IDENTIFIER = 'staffid'; |
||||
| 55 | |||||
| 56 | /** |
||||
| 57 | * Constructor |
||||
| 58 | * |
||||
| 59 | * @param \XoopsMySQLDatabase|null $db reference to a xoopsDB object |
||||
| 60 | */ |
||||
| 61 | public function __construct(\XoopsMySQLDatabase $db = null) |
||||
| 62 | { |
||||
| 63 | $this->init($db); |
||||
| 64 | $this->helper = Helper::getInstance(); |
||||
| 65 | parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER); |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | /** |
||||
| 69 | * retrieve a StaffReview object meeting certain criteria |
||||
| 70 | * @param int $ticketid ID of ticket |
||||
| 71 | * @param int $responseid ID of response |
||||
| 72 | * @param int $submittedBy UID of ticket submitter |
||||
| 73 | * @return array|bool (@link StaffReview} |
||||
| 74 | */ |
||||
| 75 | public function getReview(int $ticketid, int $responseid, int $submittedBy) |
||||
| 76 | { |
||||
| 77 | $ticketid = $ticketid; |
||||
| 78 | $responseid = $responseid; |
||||
| 79 | $submittedBy = $submittedBy; |
||||
| 80 | |||||
| 81 | $criteria = new \CriteriaCompo(new \Criteria('ticketid', (string)$ticketid)); |
||||
| 82 | $criteria->add(new \Criteria('submittedBy', (string)$submittedBy)); |
||||
| 83 | $criteria->add(new \Criteria('responseid', (string)$responseid)); |
||||
| 84 | $review = []; |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 85 | if (!$review = $this->getObjects($criteria)) { |
||||
| 86 | return false; |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | return $review; |
||||
| 90 | } |
||||
| 91 | |||||
| 92 | /** |
||||
| 93 | * @param \XoopsObject $object |
||||
| 94 | * @return string |
||||
| 95 | */ |
||||
| 96 | public function insertQuery(\XoopsObject $object): string |
||||
| 97 | { |
||||
| 98 | //TODO mb replace with individual variables |
||||
| 99 | // Copy all object vars into local variables |
||||
| 100 | foreach ($object->cleanVars as $k => $v) { |
||||
| 101 | ${$k} = $v; |
||||
| 102 | } |
||||
| 103 | |||||
| 104 | $sql = \sprintf( |
||||
| 105 | 'INSERT INTO `%s` (id, staffid, rating, ticketid, responseid, comments, submittedBy, userIP) |
||||
| 106 | VALUES (%u, %u, %u, %u, %u, %s, %u, %s)', |
||||
| 107 | $this->db->prefix($this->dbtable), |
||||
| 108 | $id, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 109 | $staffid, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 110 | $rating, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 111 | $ticketid, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 112 | $responseid, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 113 | $this->db->quoteString($comments), |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 114 | $submittedBy, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 115 | $this->db->quoteString($userIP) |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 116 | ); |
||||
| 117 | |||||
| 118 | return $sql; |
||||
| 119 | } |
||||
| 120 | |||||
| 121 | /** |
||||
| 122 | * @param \XoopsObject $object |
||||
| 123 | * @return string |
||||
| 124 | */ |
||||
| 125 | public function updateQuery(\XoopsObject $object): string |
||||
| 126 | { |
||||
| 127 | //TODO mb replace with individual variables |
||||
| 128 | // Copy all object vars into local variables |
||||
| 129 | foreach ($object->cleanVars as $k => $v) { |
||||
| 130 | ${$k} = $v; |
||||
| 131 | } |
||||
| 132 | |||||
| 133 | $sql = \sprintf( |
||||
| 134 | 'UPDATE `%s` SET staffid = %u, rating = %u, ticketid = %u, responseid = %u, comments = %s, submittedBy = %u, userIP = %s |
||||
| 135 | WHERE id = %u', |
||||
| 136 | $this->db->prefix($this->dbtable), |
||||
| 137 | $staffid, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 138 | $rating, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 139 | $ticketid, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 140 | $responseid, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 141 | $this->db->quoteString($comments), |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 142 | $submittedBy, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 143 | $this->db->quoteString($userIP), |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 144 | $id |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 145 | ); |
||||
| 146 | |||||
| 147 | return $sql; |
||||
| 148 | } |
||||
| 149 | |||||
| 150 | /** |
||||
| 151 | * @param \XoopsObject $object |
||||
| 152 | * @return string |
||||
| 153 | */ |
||||
| 154 | public function deleteQuery(\XoopsObject $object): string |
||||
| 155 | { |
||||
| 156 | $sql = \sprintf('DELETE FROM `%s` WHERE id = %u', $this->db->prefix($this->dbtable), $object->getVar('id')); |
||||
|
0 ignored issues
–
show
It seems like
$object->getVar('id') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|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...
|
|||||
| 157 | |||||
| 158 | return $sql; |
||||
| 159 | } |
||||
| 160 | } |
||||
| 161 |