XoopsModules25x /
wfdownloads
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\Wfdownloads; |
||||
| 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 | * Wfdownloads module |
||||
| 16 | * |
||||
| 17 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 18 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||
| 19 | * @package wfdownload |
||||
| 20 | * @since 3.23 |
||||
| 21 | * @author marcan <[email protected]>, Xoops Development Team |
||||
| 22 | */ |
||||
| 23 | |||||
| 24 | /** |
||||
| 25 | * Contains the classes for updating database tables |
||||
| 26 | * |
||||
| 27 | * @license GNU |
||||
| 28 | * @author marcan <[email protected]> |
||||
| 29 | * @link http://www.smartfactory.ca The SmartFactory |
||||
| 30 | * @package Wfdownloads |
||||
| 31 | * @subpackage dbUpdater |
||||
| 32 | */ |
||||
| 33 | |||||
| 34 | use XoopsModules\Wfdownloads; |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * Dbupdater class |
||||
| 38 | * |
||||
| 39 | * Class performing the database update for the module |
||||
| 40 | * |
||||
| 41 | * @package Wfdownloads |
||||
| 42 | * @author marcan <[email protected]> |
||||
| 43 | * @link http://www.smartfactory.ca The SmartFactory |
||||
| 44 | */ |
||||
| 45 | class Dbupdater |
||||
| 46 | { |
||||
| 47 | public function __construct() |
||||
| 48 | { |
||||
| 49 | } |
||||
| 50 | |||||
| 51 | /** |
||||
| 52 | * Use to execute a general query |
||||
| 53 | * |
||||
| 54 | * @param string $query query that will be executed |
||||
| 55 | * @param string $goodmsg message displayed on success |
||||
| 56 | * @param string $badmsg message displayed on error |
||||
| 57 | * |
||||
| 58 | * @return bool true if success, false if an error occured |
||||
| 59 | */ |
||||
| 60 | public function runQuery($query, $goodmsg, $badmsg) |
||||
| 61 | { |
||||
| 62 | $ret = $GLOBALS['xoopsDB']->query($query); |
||||
| 63 | if (!$ret) { |
||||
| 64 | echo "<li class='err'>$badmsg</li>"; |
||||
| 65 | |||||
| 66 | return false; |
||||
| 67 | } |
||||
| 68 | echo "<li class='ok'>$goodmsg</li>"; |
||||
| 69 | |||||
| 70 | return true; |
||||
| 71 | } |
||||
| 72 | |||||
| 73 | /** |
||||
| 74 | * Use to rename a table |
||||
| 75 | * |
||||
| 76 | * @param string $from name of the table to rename |
||||
| 77 | * @param string $to new name of the renamed table |
||||
| 78 | * |
||||
| 79 | * @return bool true if success, false if an error occured |
||||
| 80 | */ |
||||
| 81 | public function renameTable($from, $to) |
||||
| 82 | { |
||||
| 83 | $from = $GLOBALS['xoopsDB']->prefix($from); |
||||
| 84 | $to = $GLOBALS['xoopsDB']->prefix($to); |
||||
| 85 | |||||
| 86 | $query = \sprintf('ALTER TABLE %s RENAME %s', $from, $to); |
||||
| 87 | $ret = $GLOBALS['xoopsDB']->query($query); |
||||
| 88 | if (!$ret) { |
||||
| 89 | echo "<li class='err'>" . \sprintf(\_AM_WFDOWNLOADS_DB_MSG_RENAME_TABLE_ERR, $from) . '</li>'; |
||||
| 90 | |||||
| 91 | return false; |
||||
| 92 | } |
||||
| 93 | echo "<li class='ok'>" . \sprintf(\_AM_WFDOWNLOADS_DB_MSG_RENAME_TABLE, $from, $to) . '</li>'; |
||||
| 94 | |||||
| 95 | return true; |
||||
| 96 | } |
||||
| 97 | |||||
| 98 | /** |
||||
| 99 | * Use to update a table |
||||
| 100 | * |
||||
| 101 | * @param DbupdaterTable $table {@link DbupdaterTable} that will be updated |
||||
| 102 | * |
||||
| 103 | * @return bool true if success, false if an error occured |
||||
| 104 | */ |
||||
| 105 | public function updateTable(DbupdaterTable $table) |
||||
| 106 | { |
||||
| 107 | $ret = true; |
||||
| 108 | echo '<ul>'; |
||||
| 109 | |||||
| 110 | // If table has a structure, create the table |
||||
| 111 | if ($table->getStructure()) { |
||||
| 112 | $ret = $table->createTable() && $ret; |
||||
| 113 | } |
||||
| 114 | |||||
| 115 | // If table is flag for drop, drop it |
||||
| 116 | if ($table->_flagForDrop) { |
||||
|
0 ignored issues
–
show
|
|||||
| 117 | $ret = $table->dropTable() && $ret; |
||||
| 118 | } |
||||
| 119 | |||||
| 120 | // If table has data, insert it |
||||
| 121 | if ($table->getData()) { |
||||
| 122 | $ret = $table->addData() && $ret; |
||||
| 123 | } |
||||
| 124 | |||||
| 125 | // If table has new fields to be added, add them |
||||
| 126 | if ($table->getNewFields()) { |
||||
| 127 | $ret = $table->addNewFields() && $ret; |
||||
| 128 | } |
||||
| 129 | |||||
| 130 | // If table has altered field, alter the table |
||||
| 131 | if ($table->getAlteredFields()) { |
||||
| 132 | $ret = $table->alterTable() && $ret; |
||||
| 133 | } |
||||
| 134 | |||||
| 135 | // If table has updated field values, update the table |
||||
| 136 | if ($table->getUpdatedFields()) { |
||||
| 137 | $ret = $table->updateFieldsValues($table) && $ret; |
||||
|
0 ignored issues
–
show
The call to
XoopsModules\Wfdownloads...e::updateFieldsValues() has too many arguments starting with $table.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||
| 138 | } |
||||
| 139 | |||||
| 140 | // If table has droped field, alter the table |
||||
| 141 | if ($table->getDropedFields()) { |
||||
| 142 | $ret = $table->dropFields($table) && $ret; |
||||
|
0 ignored issues
–
show
The call to
XoopsModules\Wfdownloads...aterTable::dropFields() has too many arguments starting with $table.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||
| 143 | } |
||||
| 144 | //felix |
||||
| 145 | // If table has updated field values, update the table |
||||
| 146 | if ($table->getUpdatedWhere()) { |
||||
| 147 | $ret = $table->updateWhereValues($table) && $ret; |
||||
|
0 ignored issues
–
show
The call to
XoopsModules\Wfdownloads...le::updateWhereValues() has too many arguments starting with $table.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||
| 148 | } |
||||
| 149 | |||||
| 150 | echo '</ul>'; |
||||
| 151 | |||||
| 152 | return $ret; |
||||
| 153 | } |
||||
| 154 | } |
||||
| 155 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.