Skip to content

Commit

Permalink
Work in progress 1.8.33 (PHP7) (#42)
Browse files Browse the repository at this point in the history
* Update for PHP 8

* Rewrite the ACP module

Use templates for the ACP

* Fix WOL feature and complete UserCP priority setting

Also simplifies the logic for loading pages as it was overcomplicated

* Update example files

* Update templates

* Update language files

* Complete Menu Builder feature

- Complete navigation (previous/next) feature
- Remove legacy code
- Rework Database migration
- Reduces query calls on favor of the cache system
- Canonical URL addition and attempt to enforce unified URL
- Delete category's pages when deleting it

* Remove discarded methods

* Fix memory overload

* Downgrade for PHP 7.4 support

- Add helper for core cache rebuild
- Update `allowedGroups` from empty to -1 when updating from legacy version
- Rebuild cache on plugin activation
- Add required mark back

* Add missing checks for database insertions during install

- Update example pages to sync with documentation
- Update language strings to sync with documentation
- Remove echoing at `initExecute()`
- Update init EXECUTION_HOOK_GLOBAL_END logic
- Update hooks to sync with documentation

* Removed legacy code

- Remove hardcoded HTML for link building

* Fix page deletion

- Fix hooks handling
- Fix getSetting()

* Add screenshots

* Update README.md for documentation (#45)

* Update documentation

* Add friendly urls information

- Describe category and page form fields

* Update emojis

Remove leftovers

* Fix grammar and links

* Fix small buggies

* Update documentation to sync with develop

* Document link building templates (front-end)

* Fix page loading when no using friendly urls

Thanks to @laird
https://community.mybb.com/thread-159249-post-1385980.html#pid1385980

* Remove legacy data base object

* Update sample pages for PHP8+

* Code cleanup

Additionally fix some identical comparison operations

* Remove unwanted code

Mistake

* Update namespac

* Update shoutbox example page

Replace potential invalid key

* Update pagination code

Used by the Sticky Threads sample page

* Change `disable_eval` setting by `enableEval`

* Update documentation

Update folder structure references

* Update directory structure

* Fix List Profile Fields sample file default settings

Update some descriptions

* Fix navigation not being built

* Cache templates

Revert `enableEval` to `false`
  • Loading branch information
Sama34 committed Nov 26, 2023
1 parent 1362ebf commit b7c96b1
Show file tree
Hide file tree
Showing 63 changed files with 6,259 additions and 3,848 deletions.
75 changes: 35 additions & 40 deletions Examples/OUGC_Pages_Banned_List.xml
Original file line number Diff line number Diff line change
@@ -1,74 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- MyBB PluginLibrary XML-Export :: 2020-04-29T00:30:20+00:00 -->
<!-- MyBB PluginLibrary XML-Export :: 2023-05-29T05:48:46+00:00 -->
<array>
<element>
<key>name</key>
<value>Banned List</value>
</element>
<element>
<key>description</key>
<value>Lists all banned accounts.</value>
<value>Displays a list of banned accounts.</value>
</element>
<element>
<key>url</key>
<value>banned-list</value>
</element>
<element>
<key>groups</key>
<value></value>
<key>allowedGroups</key>
<value>-1</value>
</element>
<element>
<key>php</key>
<value>1</value>
<value type="INT">1</value>
</element>
<element>
<key>wol</key>
<value>1</value>
<value type="INT">1</value>
</element>
<element>
<key>visible</key>
<value>1</value>
<value type="INT">1</value>
</element>
<element>
<key>wrapper</key>
<value>0</value>
<value type="INT">0</value>
</element>
<element>
<key>init</key>
<value>0</value>
<value type="INT">4</value>
</element>
<element>
<key>template</key>
<value><![CDATA[<?php
$mybb->user['uid'] or error_no_permission();
$lang->load('modcp');
require_once MYBB_ROOT.'inc/class_parser.php';
require_once MYBB_ROOT . 'inc/class_parser.php';
$parser = new postParser;
$templates->cache('ougcpages_banned_ban, ougcpages_banned_nobanned, ougcpages_banned');
$templates->cache['ougcpages_banned_ban'] or $templates->cache['ougcpages_banned_ban'] = '<tr>
isset($templates->cache['ougcpages_banned_ban']) or $templates->cache['ougcpages_banned_ban'] = '<tr>
<td class="{$trow}">{$profile_link}</td>
<td class="{$trow}">{$banned[\'reason\']}</td>
<td class="{$trow}" align="center">{$banlength}<br /><span class="smalltext">{$timeremaining}</span></td>
<td class="{$trow}" align="center">{$admin_profile}</td>
</tr>';
$templates->cache['ougcpages_banned_nobanned'] or $templates->cache['ougcpages_banned_nobanned'] = '<tr>
isset($templates->cache['ougcpages_banned_nobanned']) or $templates->cache['ougcpages_banned_nobanned'] = '<tr>
<td class="trow1" align="center" colspan="4">{$lang->no_banned}</td>
</tr>';
$templates->cache['ougcpages_banned'] or $templates->cache['ougcpages_banned'] = '<html>
isset($templates->cache['ougcpages_banned']) or $templates->cache['ougcpages_banned'] = '<html>
<head>
<title>{$mybb->settings[\'bbname\']} - {$page[\'name\']}</title>
<title>{$mybb->settings[\'bbname\']} - {$pageData[\'name\']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" border="0" align="center">
<tr>
{$modcp_nav}
<td valign="top">
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
Expand All @@ -94,15 +91,15 @@ $templates->cache['ougcpages_banned'] or $templates->cache['ougcpages_banned'] =
// Set up the array of ban times.
$bantimes = fetch_ban_times();
$category['name'] = htmlspecialchars_uni($category['name']);
$categoryData['name'] = htmlspecialchars_uni($categoryData['name']);
if ($category['breadcrumb']) {
add_breadcrumb($category['name'], $ougc_pages->get_category_link($category['cid']));
if ($categoryData['breadcrumb']) {
\add_breadcrumb($categoryData['name'], \ougc\Pages\Core\categoryGetLink($categoryID));
}
$page['name'] = htmlspecialchars_uni($page['name']);
$pageData['name'] = htmlspecialchars_uni($pageData['name']);
add_breadcrumb($page['name'], $ougc_pages->get_page_link($page['pid']));
\add_breadcrumb($pageData['name'], \ougc\Pages\Core\pageGetLink($pageID));
if ($mybb->settings['threadsperpage'] < 1) {
$mybb->settings['threadsperpage'] = 20;
Expand Down Expand Up @@ -132,9 +129,11 @@ if ($pagenum) {
$upper = $start + $perpage;
$multipage = multipage($postcount, $perpage, $pagenum, '?PLACE_HOLDER');
$multipage = str_replace(array('page=', '?PLACE_HOLDER'),
array('pagination=', $ougc_pages->get_page_link($page['pid'])),
$multipage);
$multipage = str_replace(
['page=', '?PLACE_HOLDER'],
['pagination=', \ougc\Pages\Core\pageGetLink($pageID)],
$multipage
);
switch ($mybb->get_input('sort')) {
case 'username':
Expand All @@ -160,16 +159,12 @@ switch ($mybb->get_input('order')) {
break;
}
$query = $db->query(
"
SELECT b.*, a.username AS adminuser, u.username
FROM ".TABLE_PREFIX."banned b
LEFT JOIN ".TABLE_PREFIX."users u ON (b.uid=u.uid)
LEFT JOIN ".TABLE_PREFIX."users a ON (b.admin=a.uid)
ORDER BY {$sort} {$order}
LIMIT {$start}, {$perpage}
"
);
$query = $db->query("SELECT b.*, a.username AS adminuser, u.username
FROM " . TABLE_PREFIX . "banned b
LEFT JOIN " . TABLE_PREFIX . "users u ON (b.uid=u.uid)
LEFT JOIN " . TABLE_PREFIX . "users a ON (b.admin=a.uid)
ORDER BY {$sort} {$order}
LIMIT {$start}, {$perpage}");
// Get the banned users
$bannedusers = '';
Expand All @@ -194,7 +189,7 @@ while ($banned = $db->fetch_array($query)) {
$banlength = $bantimes[$banned['bantime']];
$remaining = $banned['lifted'] - TIME_NOW;
$timeremaining = nice_time($remaining, array('short' => 1, 'seconds' => false))."";
$timeremaining = nice_time($remaining, ['short' => 1, 'seconds' => false]) . "";
if ($remaining < 3600) {
$timeremaining = "<span style=\"color: red;\">({$timeremaining} {$lang->ban_remaining})</span>";
Expand All @@ -211,20 +206,20 @@ while ($banned = $db->fetch_array($query)) {
}
}
eval('$bannedusers .= "'.$templates->get('ougcpages_banned_ban').'";');
eval('$bannedusers .= "' . $templates->get('ougcpages_banned_ban') . '";');
}
if (!$bannedusers) {
eval('$bannedusers = "'.$templates->get('ougcpages_banned_nobanned').'";');
eval('$bannedusers = "' . $templates->get('ougcpages_banned_nobanned') . '";');
}
eval('$page = "'.$templates->get('ougcpages_banned').'";');
eval('$page = "' . $templates->get('ougcpages_banned') . '";');
output_page($page);
exit;]]></value>
</element>
<element>
<key>versioncode</key>
<value type="INT">1820</value>
<value type="INT">1833</value>
</element>
</array>
<!-- End of file. -->
20 changes: 10 additions & 10 deletions Examples/OUGC_Pages_HTML_Test_Page.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- MyBB PluginLibrary XML-Export :: 2019-01-13T11:40:29+01:00 -->
<!-- MyBB PluginLibrary XML-Export :: 2023-05-29T05:46:43+00:00 -->
<array>
<element>
<key>name</key>
<value>HTML Test Page</value>
</element>
<element>
<key>description</key>
<value>Shows how to create a simple HTML page.</value>
<value>Plain HTML page meant to serve as reference.</value>
</element>
<element>
<key>url</key>
<value>html-test-page</value>
</element>
<element>
<key>groups</key>
<value></value>
<key>allowedGroups</key>
<value>-1</value>
</element>
<element>
<key>php</key>
<value>0</value>
<value type="INT">0</value>
</element>
<element>
<key>wol</key>
<value>1</value>
<value type="INT">1</value>
</element>
<element>
<key>visible</key>
<value>1</value>
<value type="INT">1</value>
</element>
<element>
<key>wrapper</key>
<value>1</value>
<value type="INT">1</value>
</element>
<element>
<key>init</key>
<value>0</value>
<value type="INT">4</value>
</element>
<element>
<key>template</key>
Expand All @@ -57,7 +57,7 @@
</element>
<element>
<key>versioncode</key>
<value type="INT">1819</value>
<value type="INT">1833</value>
</element>
</array>
<!-- End of file. -->

0 comments on commit b7c96b1

Please sign in to comment.