mambax7 /
randomquote
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Module: RandomQuote |
||
| 4 | * |
||
| 5 | * You may not change or alter any portion of this comment or credits |
||
| 6 | * of supporting developers from this source code or any supporting source code |
||
| 7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 8 | * |
||
| 9 | * PHP version 5 |
||
| 10 | * |
||
| 11 | * @category Module |
||
| 12 | * @package Randomquote |
||
| 13 | * @author XOOPS Development Team, Mamba, Herve Thouzard |
||
| 14 | * @copyright 2001-2016 XOOPS Project (http://xoops.org), Herve Thouzard |
||
| 15 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
| 16 | * @link http://xoops.org/ |
||
| 17 | * @since 2.0.0 |
||
| 18 | * |
||
| 19 | * @param $tablename |
||
| 20 | * |
||
| 21 | * @return bool |
||
| 22 | */ |
||
| 23 | |||
| 24 | function tableExists($tablename) |
||
| 25 | { |
||
| 26 | global $xoopsDB; |
||
|
0 ignored issues
–
show
|
|||
| 27 | $result = $xoopsDB->queryF("SHOW TABLES LIKE '$tablename'"); |
||
| 28 | |||
| 29 | return ($xoopsDB->getRowsNum($result) > 0); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @return bool |
||
| 34 | */ |
||
| 35 | function xoops_module_update_randomquote() |
||
| 36 | { |
||
| 37 | global $xoopsDB; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 38 | $errors = 0; |
||
| 39 | if (tableExists($xoopsDB->prefix('citas'))) { |
||
| 40 | $sql = sprintf('ALTER TABLE ' . $xoopsDB->prefix('randomquote_quotes') . ' CHANGE `citas` `quote` TEXT'); |
||
| 41 | $result = $xoopsDB->queryF($sql); |
||
| 42 | if (!$result) { |
||
| 43 | echo '<br />' . _AM_RANDOMQUOTE_UPGRADEFAILED0; |
||
| 44 | ++$errors; |
||
| 45 | } |
||
| 46 | |||
| 47 | $sql = sprintf('ALTER TABLE ' . $xoopsDB->prefix('citas') . " ADD COLUMN `quote_status` int (10) NOT NULL default '0', |
||
| 48 | ADD COLUMN `quote_waiting` int (10) NOT NULL default '0', |
||
| 49 | ADD COLUMN `quote_online` int (10) NOT NULL default '0';"); |
||
| 50 | $result = $xoopsDB->queryF($sql); |
||
| 51 | if (!$result) { |
||
| 52 | echo '<br />' . _AM_RANDOMQUOTE_UPGRADEFAILED1; |
||
| 53 | ++$errors; |
||
| 54 | } |
||
| 55 | |||
| 56 | $sql = sprintf('ALTER TABLE ' . $xoopsDB->prefix('citas') . ' RENAME ' . $xoopsDB->prefix('randomquote_quotes')); |
||
| 57 | $result = $xoopsDB->queryF($sql); |
||
| 58 | if (!$result) { |
||
| 59 | echo '<br />' . _AM_RANDOMQUOTE_UPGRADEFAILED2; |
||
| 60 | ++$errors; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | return true; |
||
| 65 | } |
||
| 66 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state