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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
4 | |||
5 | global $modversion; |
||
6 | if (!empty($_POST['fct']) && !empty($_POST['op']) && $_POST['fct'] === 'modulesadmin' && $_POST['op'] === 'update_ok' && $_POST['dirname'] == $modversion['dirname']) { |
||
7 | // referer check |
||
8 | $ref = xoops_getenv('HTTP_REFERER'); |
||
9 | if ($ref == '' || strpos($ref, XOOPS_URL . '/modules/system/admin.php') === 0) { |
||
10 | /* module specific part */ |
||
11 | |||
12 | /* General part */ |
||
13 | |||
14 | // Keep the values of block's options when module is updated (by nobunobu) |
||
15 | include __DIR__ . '/updateblock.inc.php'; |
||
16 | } |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * @param $module |
||
21 | * @return bool |
||
22 | */ |
||
23 | function xoops_module_update_smartpartner($module) |
||
24 | { |
||
25 | include_once(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/include/functions.php'); |
||
26 | include_once(XOOPS_ROOT_PATH . '/modules/smartobject/class/smartdbupdater.php'); |
||
27 | |||
28 | $dbupdater = new SmartobjectDbupdater(); |
||
29 | |||
30 | ob_start(); |
||
31 | |||
32 | $dbVersion = smartpartner_GetMeta('version'); |
||
33 | |||
34 | $dbupdater = new SmartobjectDbupdater(); |
||
35 | |||
36 | echo '<code>' . _SDU_UPDATE_UPDATING_DATABASE . '<br>'; |
||
37 | |||
38 | //smartpartner_create_upload_folders(); |
||
39 | |||
40 | // db migrate version = 3 |
||
41 | $newDbVersion = 3; |
||
42 | if ($dbVersion < $newDbVersion) { |
||
43 | echo 'Database migrate to version ' . $newDbVersion . '<br>'; |
||
44 | |||
45 | $table = new SmartDbTable('smartpartner_partner'); |
||
46 | $table->addNewField('email_priv', " tinyint(1) NOT NULL default '0'"); |
||
47 | $table->addNewField('phone_priv', " tinyint(1) NOT NULL default '0'"); |
||
48 | $table->addNewField('adress_priv', " tinyint(1) NOT NULL default '0'"); |
||
49 | |||
50 | if (!$dbupdater->updateTable($table)) { |
||
51 | /** |
||
52 | * @todo trap the errors |
||
53 | */ |
||
54 | } |
||
55 | unset($table); |
||
56 | } |
||
57 | // db migrate version =4 |
||
58 | $newDbVersion = 4; |
||
59 | if ($dbVersion < $newDbVersion) { |
||
60 | echo 'Database migrate to version ' . $newDbVersion . '<br>'; |
||
61 | //create new tables |
||
62 | // Create table smartpartner_categories |
||
63 | $table = new SmartDbTable('smartpartner_categories'); |
||
64 | if (!$table->exists()) { |
||
65 | $table->setStructure(" |
||
66 | `categoryid` int(11) NOT NULL auto_increment, |
||
67 | `parentid` int(11) NOT NULL default '0', |
||
68 | `name` varchar(100) NOT NULL default '', |
||
69 | `description` text NOT NULL, |
||
70 | `image` varchar(255) NOT NULL default '', |
||
71 | `total` int(11) NOT NULL default '0', |
||
72 | `weight` int(11) NOT NULL default '1', |
||
73 | `created` int(11) NOT NULL default '0', |
||
74 | PRIMARY KEY (`categoryid`) |
||
75 | "); |
||
76 | |||
77 | if (!$dbupdater->updateTable($table)) { |
||
78 | /** |
||
79 | * @todo trap the errors |
||
80 | */ |
||
81 | } |
||
82 | } |
||
83 | // Create table smartpartner_partner_cat_link |
||
84 | $table = new SmartDbTable('smartpartner_partner_cat_link'); |
||
85 | if (!$table->exists()) { |
||
86 | $table->setStructure(" |
||
87 | `partner_cat_linkid` int(11) NOT NULL auto_increment, |
||
88 | `categoryid` int(11) NOT NULL default '0', |
||
89 | `partnerid` int(11) NOT NULL default '0', |
||
90 | PRIMARY KEY (`partner_cat_linkid`) |
||
91 | "); |
||
92 | |||
93 | if (!$dbupdater->updateTable($table)) { |
||
94 | /** |
||
95 | * @todo trap the errors |
||
96 | */ |
||
97 | } |
||
98 | } |
||
99 | |||
100 | // Create table smartpartner_offer |
||
101 | $table = new SmartDbTable('smartpartner_offer'); |
||
102 | if (!$table->exists()) { |
||
103 | $table->setStructure(" |
||
104 | `offerid` int(11) NOT NULL auto_increment, |
||
105 | `partnerid` int(11) NOT NULL default '0', |
||
106 | `title` varchar(255) NOT NULL default '', |
||
107 | `description` TEXT NOT NULL, |
||
108 | `url` varchar(150) default '', |
||
109 | `image` varchar(150) NOT NULL default '', |
||
110 | `date_sub` int(11) NOT NULL default '0', |
||
111 | `date_pub` int(11) NOT NULL default '0', |
||
112 | `date_end` int(11) NOT NULL default '0', |
||
113 | `status` int(10) NOT NULL default '-1', |
||
114 | `weight` int(1) NOT NULL default '0', |
||
115 | `dohtml` int(1) NOT NULL default '1', |
||
116 | PRIMARY KEY (`offerid`) |
||
117 | "); |
||
118 | |||
119 | if (!$dbupdater->updateTable($table)) { |
||
120 | /** |
||
121 | * @todo trap the errors |
||
122 | */ |
||
123 | } |
||
124 | } |
||
125 | |||
126 | // Create table smartpartner_offer |
||
127 | $table = new SmartDbTable('smartpartner_files'); |
||
128 | if (!$table->exists()) { |
||
129 | $table->setStructure(" |
||
130 | `fileid` int(11) NOT NULL auto_increment, |
||
131 | `id` int(11) NOT NULL default '0', |
||
132 | `name` varchar(255) NOT NULL default '', |
||
133 | `description` TEXT NOT NULL, |
||
134 | `filename` varchar(255) NOT NULL default '', |
||
135 | `mimetype` varchar(64) NOT NULL default '', |
||
136 | `uid` int(6) default '0', |
||
137 | `datesub` int(11) NOT NULL default '0', |
||
138 | `status` int(1) NOT NULL default '-1', |
||
139 | `notifypub` tinyint(1) NOT NULL default '1', |
||
140 | `counter` int(8) unsigned NOT NULL default '0', |
||
141 | PRIMARY KEY (`fileid`) |
||
142 | "); |
||
143 | |||
144 | if (!$dbupdater->updateTable($table)) { |
||
145 | /** |
||
146 | * @todo trap the errors |
||
147 | */ |
||
148 | } |
||
149 | } |
||
150 | //loop in partners to insert cat_links in partner_cat_link table |
||
151 | $smartpartnerPartnerHandler = xoops_getModuleHandler('partner', 'smartpartner'); |
||
152 | // $smartpartnerPartnerCatLinkHandler = xoops_getModuleHandler('partner_cat_link', 'smartpartner'); |
||
153 | $smartpartnerPartnerCatLinkHandler = xoops_getModuleHandler('partner_cat_link', 'smartpartner'); |
||
154 | |||
155 | $modulepermHandler = xoops_getHandler('groupperm'); |
||
156 | $moduleHandler = xoops_getHandler('module'); |
||
157 | $module = $moduleHandler->getByDirname('smartpartner'); |
||
158 | $groupsArray = $modulepermHandler->getGroupIds('module_read', $module->mid(), 1); |
||
159 | |||
160 | $sql = 'SELECT id, categoryid from ' . $smartpartnerPartnerHandler->table; |
||
161 | $records = $smartpartnerPartnerHandler->query($sql); |
||
162 | foreach ($records as $record) { |
||
163 | if ($record['categoryid'] != 0) { |
||
164 | $new_link = $smartpartnerPartnerCatLinkHandler->create(); |
||
165 | $new_link->setVar('partnerid', $record['id']); |
||
166 | $new_link->setVar('categoryid', $record['categoryid']); |
||
167 | $smartpartnerPartnerCatLinkHandler->insert($new_link); |
||
168 | unset($new_link); |
||
169 | } |
||
170 | foreach ($groupsArray as $group) { |
||
171 | $modulepermHandler->addRight('full_view', $record['id'], $group, $module->mid()); |
||
172 | } |
||
173 | } |
||
174 | //drop cat_id in partner table |
||
175 | $table = new SmartDbTable('smartpartner_partner'); |
||
176 | $table->addNewField('last_update', " int(11) NOT NULL default '0'"); |
||
177 | $table->addNewField('showsummary', " tinyint(1) NOT NULL default '0'"); |
||
178 | $table->addDroppedField('categoryid'); |
||
179 | if (!$dbupdater->updateTable($table)) { |
||
180 | /** |
||
181 | * @todo trap the errors |
||
182 | */ |
||
183 | } |
||
184 | unset($table); |
||
185 | } |
||
186 | echo '</code>'; |
||
187 | |||
188 | $feedback = ob_get_clean(); |
||
189 | if (method_exists($module, 'setMessage')) { |
||
190 | $module->setMessage($feedback); |
||
191 | } else { |
||
192 | echo $feedback; |
||
193 | } |
||
194 | smartpartner_SetMeta('version', isset($newDbVersion) ? $newDbVersion : 0); //Set meta version to current |
||
195 | |||
196 | return true; |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * @param $module |
||
201 | * @return bool |
||
202 | */ |
||
203 | function xoops_module_install_smartpartner($module) |
||
204 | { |
||
205 | ob_start(); |
||
206 | |||
207 | include_once(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/include/functions.php'); |
||
208 | |||
209 | smartpartner_create_upload_folders(); |
||
210 | |||
211 | $feedback = ob_get_clean(); |
||
212 | if (method_exists($module, 'setMessage')) { |
||
213 | $module->setMessage($feedback); |
||
214 | } else { |
||
215 | echo $feedback; |
||
216 | } |
||
217 | |||
218 | return true; |
||
219 | } |
||
220 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.