Skip to content

Commit d03eda5

Browse files
authored
Icms2 fixes db (#18)
* $icmsModule transform to icms::$module * add missing index files * update version info * update readme * add deploy action * no src folder yet * move sourcecode to src folder * moving to src * moving to src, 3 * moving to src. images * github actions now pushes from src folder * icms_version constants added * Create index.html * re-adding admin folder * add block, class * Create index.html * Create index.html * Add default imageset * upload templates * upload include folder * cleanup $icmsModule * cleanup old $icmsModule * cleanup old $icmsModule * cleanup old $icmsModule * cleanup old $icmsModule * Update Crowdin configuration file * replace old xoopsDB global with icms::$db * oops, this should be icms::$xoopsDB instead
1 parent 3804212 commit d03eda5

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/class/online.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,26 @@ function write($uid, $uname, $time, $forum, $ip, $forumtopic)
156156
$uid = (int)$uid;
157157
if ($uid > 0)
158158
{
159-
$sql = "SELECT COUNT(*) FROM " . $GLOBALS["xoopsDB"]->prefix('bb_online') . " WHERE online_uid=" . $uid;
159+
$sql = "SELECT COUNT(*) FROM " . icms::$xoopsDB->prefix('bb_online') . " WHERE online_uid=" . $uid;
160160
}
161161
else
162162
{
163-
$sql = "SELECT COUNT(*) FROM " . $GLOBALS["xoopsDB"]->prefix('bb_online') . " WHERE online_uid=" . $uid . " AND online_ip='" . $ip . "'";
163+
$sql = "SELECT COUNT(*) FROM " . icms::$xoopsDB->prefix('bb_online') . " WHERE online_uid=" . $uid . " AND online_ip='" . $ip . "'";
164164
}
165-
list($count) = $GLOBALS["xoopsDB"]->fetchRow($GLOBALS["xoopsDB"]->queryF($sql));
165+
list($count) = icms::$xoopsDB->fetchRow(icms::$xoopsDB->queryF($sql));
166166
if ($count > 0)
167167
{
168-
$sql = "UPDATE " . $GLOBALS["xoopsDB"]->prefix('bb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum . "', online_topic = '" . $forumtopic . "' WHERE online_uid = " . $uid;
168+
$sql = "UPDATE " . icms::$xoopsDB->prefix('bb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum . "', online_topic = '" . $forumtopic . "' WHERE online_uid = " . $uid;
169169
if ($uid == 0)
170170
{
171171
$sql .= " AND online_ip='" . $ip . "'";
172172
}
173173
}
174174
else
175175
{
176-
$sql = sprintf("INSERT INTO %s (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)", $GLOBALS["xoopsDB"]->prefix('bb_online'), $uid, $GLOBALS["xoopsDB"]->quoteString($uname), $time, $GLOBALS["xoopsDB"]->quoteString($ip), $forum, $forumtopic);
176+
$sql = sprintf("INSERT INTO %s (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)", icms::$xoopsDB->prefix('bb_online'), $uid, icms::$xoopsDB->quoteString($uname), $time, icms::$xoopsDB->quoteString($ip), $forum, $forumtopic);
177177
}
178-
if (!$GLOBALS["xoopsDB"]->queryF($sql))
178+
if (!icms::$xoopsDB->queryF($sql))
179179
{
180180
iforum_message("can not update online info: ".$sql);
181181
return false;
@@ -186,9 +186,9 @@ function write($uid, $uname, $time, $forum, $ip, $forumtopic)
186186
/* for MySQL 4.1+ */
187187
if ($mysql_version >= "4.1"):
188188

189-
$sql = "DELETE FROM ".$GLOBALS["xoopsDB"]->prefix('bb_online'). " WHERE". " ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM ".$GLOBALS["xoopsDB"]->prefix('online')." WHERE online_module =".icms::$module->getVar('mid')." ) )". " OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM ".$GLOBALS["xoopsDB"]->prefix('online')." WHERE online_module =".icms::$module->getVar('mid')." AND online_uid = 0 ) )";
189+
$sql = "DELETE FROM ".icms::$xoopsDB->prefix('bb_online'). " WHERE". " ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM ".icms::$xoopsDB->prefix('online')." WHERE online_module =".icms::$module->getVar('mid')." ) )". " OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM ".icms::$xoopsDB->prefix('online')." WHERE online_module =".icms::$module->getVar('mid')." AND online_uid = 0 ) )";
190190

191-
if ($result = $GLOBALS["xoopsDB"]->queryF($sql))
191+
if ($result = icms::$xoopsDB->queryF($sql))
192192
{
193193
return true;
194194
}
@@ -200,10 +200,10 @@ function write($uid, $uname, $time, $forum, $ip, $forumtopic)
200200

201201

202202
else:
203-
$sql = "DELETE ".$GLOBALS["xoopsDB"]->prefix('bb_online')." FROM ".$GLOBALS["xoopsDB"]->prefix('bb_online'). " LEFT JOIN ".$GLOBALS["xoopsDB"]->prefix('online')." AS aa ". " ON ".$GLOBALS["xoopsDB"]->prefix('bb_online').".online_uid = aa.online_uid WHERE ".$GLOBALS["xoopsDB"]->prefix('bb_online').".online_uid > 0 AND aa.online_uid IS NULL";
204-
$result = $GLOBALS["xoopsDB"]->queryF($sql);
205-
$sql = "DELETE ".$GLOBALS["xoopsDB"]->prefix('bb_online')." FROM ".$GLOBALS["xoopsDB"]->prefix('bb_online'). " LEFT JOIN ".$GLOBALS["xoopsDB"]->prefix('online')." AS aa ". " ON ".$GLOBALS["xoopsDB"]->prefix('bb_online').".online_ip = aa.online_ip WHERE ".$GLOBALS["xoopsDB"]->prefix('bb_online').".online_uid = 0 AND aa.online_ip IS NULL";
206-
$result = $GLOBALS["xoopsDB"]->queryF($sql);
203+
$sql = "DELETE ".icms::$xoopsDB->prefix('bb_online')." FROM ".icms::$xoopsDB->prefix('bb_online'). " LEFT JOIN ".icms::$xoopsDB->prefix('online')." AS aa ". " ON ".icms::$xoopsDB->prefix('bb_online').".online_uid = aa.online_uid WHERE ".icms::$xoopsDB->prefix('bb_online').".online_uid > 0 AND aa.online_uid IS NULL";
204+
$result = icms::$xoopsDB->queryF($sql);
205+
$sql = "DELETE ".icms::$xoopsDB->prefix('bb_online')." FROM ".icms::$xoopsDB->prefix('bb_online'). " LEFT JOIN ".icms::$xoopsDB->prefix('online')." AS aa ". " ON ".icms::$xoopsDB->prefix('bb_online').".online_ip = aa.online_ip WHERE ".icms::$xoopsDB->prefix('bb_online').".online_uid = 0 AND aa.online_ip IS NULL";
206+
$result = icms::$xoopsDB->queryF($sql);
207207
return true;
208208
endif;
209209
}
@@ -217,8 +217,8 @@ function write($uid, $uname, $time, $forum, $ip, $forumtopic)
217217
*/
218218
function gc($expire)
219219
{
220-
$sql = "DELETE FROM ".$GLOBALS["xoopsDB"]->prefix('bb_online')." WHERE online_updated < ".(time() - intval($expire));
221-
$GLOBALS["xoopsDB"]->queryF($sql);
220+
$sql = "DELETE FROM ".icms::$xoopsDB->prefix('bb_online')." WHERE online_updated < ".(time() - intval($expire));
221+
icms::$xoopsDB->queryF($sql);
222222

223223
$online_handler = icms::handler('icms_core_Online');
224224
$online_handler->gc($expire);
@@ -234,19 +234,19 @@ function &getAll($criteria = null)
234234
{
235235
$ret = array();
236236
$limit = $start = 0;
237-
$sql = 'SELECT * FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_online');
237+
$sql = 'SELECT * FROM ' . icms::$xoopsDB->prefix('bb_online');
238238
if (is_object($criteria) && is_subclass_of($criteria, 'icms_db_criteria_Element'))
239239
{
240240
$sql .= ' ' . $criteria->renderWhere();
241241
$limit = $criteria->getLimit();
242242
$start = $criteria->getStart();
243243
}
244-
$result = $GLOBALS["xoopsDB"]->query($sql, $limit, $start);
244+
$result = icms::$xoopsDB->query($sql, $limit, $start);
245245
if (!$result)
246246
{
247247
return false;
248248
}
249-
while ($myrow = $GLOBALS["xoopsDB"]->fetchArray($result))
249+
while ($myrow = icms::$xoopsDB->fetchArray($result))
250250
{
251251
$ret[] = $myrow;
252252
if ($myrow["online_uid"] > 0 )
@@ -269,18 +269,18 @@ function checkStatus($uids)
269269
}
270270
else
271271
{
272-
$sql = 'SELECT online_uid FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_online');
272+
$sql = 'SELECT online_uid FROM ' . icms::$xoopsDB->prefix('bb_online');
273273
if (!empty($uids))
274274
{
275275
$sql .= ' WHERE online_uid IN ('.implode(", ", array_map("intval", $uids)).')';
276276
}
277277

278-
$result = $GLOBALS["xoopsDB"]->query($sql);
278+
$result = icms::$xoopsDB->query($sql);
279279
if (!$result)
280280
{
281281
return false;
282282
}
283-
while (list($uid) = $GLOBALS["xoopsDB"]->fetchRow($result))
283+
while (list($uid) = icms::$xoopsDB->fetchRow($result))
284284
{
285285
$online_users[] = $uid;
286286
}
@@ -302,16 +302,16 @@ function checkStatus($uids)
302302
*/
303303
function getCount($criteria = null)
304304
{
305-
$sql = 'SELECT COUNT(*) FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_online');
305+
$sql = 'SELECT COUNT(*) FROM ' . icms::$xoopsDB->prefix('bb_online');
306306
if (is_object($criteria) && is_subclass_of($criteria, 'icms_db_criteria_Element'))
307307
{
308308
$sql .= ' ' . $criteria->renderWhere();
309309
}
310-
if (!$result = $GLOBALS["xoopsDB"]->query($sql))
310+
if (!$result = icms::$xoopsDB->query($sql))
311311
{
312312
return false;
313313
}
314-
list($ret) = $GLOBALS["xoopsDB"]->fetchRow($result);
314+
list($ret) = icms::$xoopsDB->fetchRow($result);
315315
return $ret;
316316
}
317317
}

src/class/post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ function saveAttachment()
8484
$attachment_save = base64_encode(serialize($this->attachment_array));
8585
else $attachment_save = '';
8686
$this->setVar('attachment', $attachment_save);
87-
$sql = "UPDATE " . $GLOBALS["xoopsDB"]->prefix("bb_posts") . " SET attachment=" . $GLOBALS["xoopsDB"]->quoteString($attachment_save) . " WHERE post_id = " . $this->getVar('post_id');
88-
if (!$result = $GLOBALS["xoopsDB"]->queryF($sql))
87+
$sql = "UPDATE " . icms::$xoopsDB->prefix("bb_posts") . " SET attachment=" . icms::$xoopsDB->quoteString($attachment_save) . " WHERE post_id = " . $this->getVar('post_id');
88+
if (!$result = icms::$xoopsDB->queryF($sql))
8989
{
9090
iforum_message("save attachment error: ". $sql);
9191
return false;

src/class/topic.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function __construct()
5959

6060
function incrementCounter()
6161
{
62-
$sql = 'UPDATE ' . $GLOBALS["xoopsDB"]->prefix('bb_topics') . ' SET topic_views = topic_views + 1 WHERE topic_id =' . $this->getVar('topic_id');
63-
$GLOBALS["xoopsDB"]->queryF($sql);
62+
$sql = 'UPDATE ' . icms::$xoopsDB->prefix('bb_topics') . ' SET topic_views = topic_views + 1 WHERE topic_id =' . $this->getVar('topic_id');
63+
icms::$xoopsDB->queryF($sql);
6464
}
6565
}
6666

0 commit comments

Comments
 (0)