SMF SSI.php Functions

Current Version: 2.0

This file is used to demonstrate the capabilities of SSI.php using PHP include functions. The examples show the include tag, then the results of it.

Include Code

To use SSI.php in your page add at the very top of your page before the <html> tag on line 1 of your php file:

Code: [Select]
<?php require("SSI.php"); ?>

Some notes on usage

All the functions have an output method parameter. This can either be "echo" (the default) or "array"

If it is "echo", the function will act normally - otherwise, it will return an array containing information about the requested task. For example, it might return a list of topics for ssi_recentTopics.

This functionality can be used to allow you to present the information in any way you wish.

Additional Guides & FAQ

Need more information on using SSI.php? Check out Using SSI.php article or the SSI FAQ.

Recent Topics Function

Code (simple mode)

Code: [Select]
<?php ssi_recentTopics(); ?>

Code (advanced mode)

Code: [Select]
<?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo'); ?>

Result

Recent Poll Function

Code

Code: [Select]
<?php ssi_recentPoll(); ?>

Result

Top Boards Function

Shows top boards by the number of posts.

Code

Code: [Select]
<?php ssi_topBoards(); ?>

Result

Board Topics Posts
SMF Online Manual 0 5,376,619
Srpski (Serbian) 0 2,644,127
Bugtracker (Github) 0 2,621,456
Bosanski (Bosnian) 0 2,618,137
Hrvatski (Croatian) 0 2,603,681
SMF 1.1.x Support New 82,816 520,132
SMF 2.0.x Support New 47,941 357,737
Modifications and Packages New 2,665 334,432
Arşiv New 31,575 228,763
Español (Spanish) New 29,431 175,852

Top Topics

Shows top topics by the number of replies or views.

Code (show by number of views)

Code: [Select]
<?php ssi_topTopicsViews(); ?>

Result

Code (show by number of replies)

Code: [Select]
<?php ssi_topTopicsReplies(); ?>

Result

Top Poll Function

Shows the most-voted-in poll.

Code

Code: [Select]
<?php ssi_topPoll(); ?>

Result

Top Poster Function

Shows the top poster's name and profile link.

Code

Code: [Select]
<?php ssi_topPoster(); ?>

Result

Latest Member Function

Shows the latest member's name and profile link.

Code

Code: [Select]
<?php ssi_latestMember(); ?>

Result

Please welcome badjujudazzle, our newest member.

Member of the Day

Shows one random member of the day. This changes once a day.

Code

Code: [Select]
<?php ssi_randomMember('day'); ?>

Result

Who's Online Function

This function shows who are online inside the forum.

Code

Code: [Select]
<?php ssi_whosOnline(); ?>

Result

Log Online Presence

This function logs the SSI page's visitor, then shows the Who's Online list. In other words, this function shows who are online inside and outside the forum.

Code

Code: [Select]
<?php ssi_logOnline(); ?>

Result

Login Function

Shows a login box only when user is not logged in.

Code

Code: [Select]
<?php ssi_login(); ?>

Result

 
 

Logout Function

Shows a logout link only when user is logged in.

Code

Code: [Select]
<?php ssi_logout(); ?>

Result

Welcome Function

Greets users or guests, also shows user's messages if logged in.

Code

Code: [Select]
<?php ssi_welcome(); ?>

Result

Welcome, Guest. Please login or register.
Did you miss your activation email?

Today's Calendar Function

Code

Code: [Select]
<?php ssi_todaysCalendar(); ?>

Result

Today's Birthdays Function

Code

Code: [Select]
<?php ssi_todaysBirthdays(); ?>

Result

Today's Holidays Function

Code

Code: [Select]
<?php ssi_todaysHolidays(); ?>

Result

Today's Events Function

Code

Code: [Select]
<?php ssi_todaysEvents(); ?>

Result

Recent Calendar Events Function

Code

Code: [Select]
<?php ssi_recentEvents(); ?>

Result

Forum Stats

Shows some basic forum stats: total members, posts, topics, boards, etc.

Code

Code: [Select]
<?php ssi_boardStats(); ?>

Result

Total Members: 431,878
Total Posts: 3,823,603
Total Topics: 455,841
Total Categories: 13
Total Boards: 223

News Function

Shows random forum news.

Code

Code: [Select]
<?php ssi_news(); ?>

Result

Board News Function

Shows the latest posts from read only boards, or a specific board.

Code

Code: [Select]
<?php ssi_boardNews(); ?>

Result

xx SMF 2.0.17 Released

December 30, 2019, 07:57:44 PM by Sesquipedalian
Dear Members,

Simple Machines has released a new patch to the 2.0.x line of SMF, bringing our latest release version to 2.0.17.

We consider this patch to be of crucial importance, as it includes an important fix for a critical bug that was introduced in SMF 2.0.16.
  • Fixes a bug that could cause SMF 2.0.16 to start consuming significant amounts of CPU-resources when the RSS function was used.
  • Eliminates some deprecated function warnings when using SSI.php on PHP 7.2+.

Please see the changelog for more information.

Since SMF 2.0.17 is essentially what 2.0.16 was intended to be and 2.0.16 was released only a few days ago, we are including a (slightly updated) version of the SMF 2.0.16 announcement for your convenience:

SMF 2.0.16 contained important security and bug fixes, as well as support for the European Union's General Data Protection Regulation (GDPR) requirements. We recommend updating as soon as possible.

Notable changes in 2.0.16 & 2.0.17
  • Support for privacy policy in addition to registration agreement
  • GDPR Compliance toggle in Core Features
       Enabling this configures multiple settings and new features to comply with the GDPR, including:
    • Requiring members to accept the current privacy policy in order to use the forum
    • Asking during registration whether the new member wants to receive announcements via email
    • Enabling token-based unsubscribe links in emails so members can unsubscribe without logging in
    • Allowing members to download a copy of their profile information
    • Adjusting the behaviour of a number of other features in minor ways as necessary
  • PHP 7.2 support
  • Improved security hashes for the image proxy
  • Improved security for the login cookie
  • Assorted other security improvements
  • Various improvements for both the installer and upgrader
Please see the changelog for more information.


IMPORTANT NOTES:
  • If you are using the GDPR Helper mod, you should follow these steps:
    • Back up your existing privacy policy text to a file somewhere
    • Update the GDPR Helper mod to its latest version
    • Uninstall the GDPR Helper mod
    • Install the SMF 2.0.16 patch
    • Install the SMF 2.0.17 patch

  • All users, including the admin, will need to log in again after 2.0.16 has been installed. After logging in, the admin can proceed to install 2.0.17.

How to update to 2.0.17

If you are running version 2.0.16, you can update your forum to the latest version by using the package manager. You should see the update notification in the admin panel notifications and in the package manager, which will allow you to download and install the patch seamlessly.  If you do not see the notification about the patch, please run the scheduled task "Fetch Simple Machines files" from the Scheduled Tasks page (Admin > Maintenance > Scheduled Tasks).

If you are still running version 2.0.15, you can first patch to 2.0.16 and then patch to 2.0.17 immediately afterwards. We apologise for the inconvenience.

If you use an older version of SMF, you can upgrade directly to 2.0.17 from whichever version you are currently using by using the "Large Upgrade" package from the Download page. Be aware that using this upgrade method will require you to reinstall any customizations that you have added to your forum, so if you are running a version of the 2.0.x series, it is recommended that you apply the successive patches instead of using the Large Upgrade.

If you are having problems downloading the patch from the admin panel, you can download the patch package from the Package Manager Updates page and install it via the Package Manager, as you would any other mod package.

Please refer to the Online Manual for more details about patching and upgrading.


Language packages for 2.0.16/2.0.17 - Translators wanted!

Adding GDPR support required changes to several of SMF's language files in 2.0.16 (and higher). Updates to SMF's supported language packages will become available as the translations of those changes are completed.

If you can help translate these changes into your language, we would love to hear from you!


Finally, as always, please do not use this topic for support requests. You will receive a much quicker and better response by posting in the 2.0.x Support Board.

Thank you for using SMF!

Regards,
Simple Machines
56 comments | Write Comment

xx SMF 2.0.16 Released

December 27, 2019, 10:09:33 PM by shawnb61
Dear Members,

Simple Machines has released a new patch to the 2.0.x line of SMF, bringing our latest release version to 2.0.16.

We consider this patch to be of crucial importance, as it includes important security and bug fixes, as well as support for the European Union's General Data Protection Regulation (GDPR) requirements. We recommend updating as soon as possible.

Notable changes in 2.0.16
  • Support for privacy policy in addition to registration agreement
  • GDPR Compliance toggle in Core Features
       Enabling this configures multiple settings and new features to comply with the GDPR, including:
    • Requiring members to accept the current privacy policy in order to use the forum
    • Asking during registration whether the new member wants to receive announcements via email
    • Enabling token-based unsubscribe links in emails so members can unsubscribe without logging in
    • Allowing members to download a copy of their profile information
    • Adjusting the behaviour of a number of other features in minor ways as necessary
  • PHP 7.2 support
  • Improved security hashes for the image proxy
  • Improved security for the login cookie
  • Assorted other security improvements
  • Various improvements for both the installer and upgrader
Please see the changelog for more information.


IMPORTANT NOTES:
  • If you are using the GDPR Helper mod, you should follow these steps:
    • Back up your existing privacy policy text to a file somewhere
    • Update the GDPR Helper mod to its latest version
    • Uninstall the GDPR Helper mod
    • Install the SMF 2.0.16 patch

  • All users, including the admin, will need to log in again after 2.0.16 has been installed.

How to update to 2.0.16

If you are running version 2.0.15, you can update your forum to the latest version by using the package manager. You should see the update notification in the admin panel notifications and in the package manager, which will allow you to download and install the patch seamlessly.  If you do not see the notification about the patch, please run the scheduled task "Fetch Simple Machines files" from the Scheduled Tasks page (Admin > Maintenance > Scheduled Tasks).

If you use older versions of SMF, you can upgrade directly to 2.0.15 from whichever version you are currently using by using the "Large Upgrade" package from the Download page. Be aware that using this upgrade method will require you to reinstall any customizations that you have added to your forum, so if you are running a version of the 2.0.x series, it is recommended that you apply the successive patches instead of using the Large Upgrade.

If you are having problems downloading the patch from the admin panel, you can download the patch package from the Package Manager Updates page and install it via the Package Manager, as you would any other mod package.

Please refer to the Online Manual for more details about patching and upgrading.


Language packages for 2.0.16 - Translators wanted!

Adding GDPR support required changes to several of SMF's language files in 2.0.16. Updates to SMF's supported language packages will become available as the translations of those changes are completed.

If you can help translate these changes into your language, we would love to hear from you!


Finally, as always, please do not use this topic for support requests. You will receive a much quicker and better response by posting in the 2.0.x Support Board.

Thank you for using SMF!

Regards,
Simple Machines
35 comments

xx SMF 2.1 RC2 Released

March 30, 2019, 12:32:25 PM by Sesquipedalian
Simple Machines is pleased to announce the release of SMF 2.1 RC2. This second release candidate includes a number of bug fixes and improvements to security, stability, and performance. Notable improvements since RC1 include:
  • A fix for a bug that prevented background tasks, including sending notifications and alerts, from completing.
  • Improvements to the theme templates.
  • Database query improvements and optimizations.
  • Improvements to the upgrader, including more graceful recovery if corrupted data is encountered.
  • Efficiency improvements to the image proxy.
  • Security improvements for PHP 5.x.
  • 4-byte Unicode characters are handled correctly even on databases that do not support them.
  • SMF's Like button will not be hidden by ad blockers.
  • The obsolete Yahoo Messenger profile field has been dropped.
  • The default list of holidays now extends until 2030.
  • Sizes of uploaded files are calculated correctly.
  • Implements permissions system for BBCodes. (Mostly useful for custom BBCodes.)
  • Some bugs in the editor have been fixed.
  • Ampersands no longer break the post preview function.
  • Desktop alert counter always reports the correct number.
You can read about these and many other improvements in the list of changes on GitHub.

The term "Release Candidate" means that the developers believe this version of the software is reliable enough to be installed and used on production websites. Nevertheless, you should still expect to encounter some bugs in SMF 2.1 RC2. We encourage you to report any bugs you find.

You can install SMF 2.1 RC2 as a brand new forum, or upgrade to it from SMF 2.1 RC1, SMF 2.0.15, or any prior version. You can obtain an install or upgrade package from the download page. You can read Installing and Upgrading SMF in the Online Manual to learn more.

Modification and theme authors are encouraged to check the roadmap for our upcoming development milestones when deciding how to update their modifications and themes for SMF 2.1.

Finally, as always, this announcement topic is not for support. Discussion and support for SMF 2.1 can be found in the SMF 2.1 support board.

Special thanks are due to all of the team members and code contributors whose fantastic work has made this possible. We greatly appreciate the time, energy, and contributions that they have given to the SMF project.

Thank you for using SMF!

Kind regards,
Simple Machines
258 comments | Write Comment

xx SMF 2.1 RC1 released

February 04, 2019, 07:31:40 PM by Sesquipedalian
Simple Machines is pleased to announce the release of SMF 2.1 RC1. This first Release Candidate for SMF 2.1 brings the beta development phase to an end and is one of last steps toward the official release of SMF 2.1. Numerous bugs that were reported after the release of Beta 3 have been fixed and improvements have been made to security, stability, and performance. Notable improvements since Beta 3 include:
  • Many database query improvements and optimizations.
  • Updates to SCEditor, jQuery, and several other plugins and libraries.
  • Image proxy improvements and support for external image proxies.
  • Faster and more robust BBCode parsing.
  • Full support for IRIs (International URLs).
  • Localization support for reCaptcha.
  • The ability for time zone descriptions to be localized.
  • Rewrites of various language strings to make them clearer.
  • An overhaul of the built-in language editor.
  • More flexibility and options for custom profile fields.
  • Improvments to two-factor authentication.
  • An enhanced error log, including backtrace information.
  • Bug fixes for alerts and email notifications.
  • Support for decimal values in paid subscriptions.
  • Smiley sets can now use many different image file formats.
  • A multitude of template and CSS improvements and fixes.
  • More intelligent CSS and JavaScript minimization.
  • Even more new integration hooks to support edit-free modding.
You can read about these and many other improvements in the list of changes on GitHub.

The term "Release Candidate" means that the developers believe this version of the software is reliable enough to be installed and used on production websites. Nevertheless, you should still expect to encounter minor bugs in SMF 2.1 RC1. We encourage you to report any bugs you find.

You can install SMF 2.1 RC1 as a brand new forum, or upgrade to it from SMF 2.0.15 or any prior version. You can obtain an install or upgrade package from the download page. You can look at Installing and Upgrading SMF in the Online Manual to learn more. Please note that upgrading from any beta version to RC1 is not supported.

Modification and theme authors are encouraged to check the roadmap for our upcoming development milestones when deciding how to update their modifications and themes for SMF 2.1. In general, most mod authors should be able to start their work now, while theme authors may wish to wait for RC2.

Finally, as always, this announcement topic is not for support. Discussion and support for SMF 2.1 can be found in the SMF 2.1 support board.

Special thanks are due to all of the team members and code contributors whose fantastic work has made this possible. We greatly appreciate the time, energy, and contributions that they have given to the SMF project.

Thank you for using SMF!

Kind regards,
Simple Machines



Update:

A significant bug has been found in RC1 that prevents alerts and notification messages from being sent. A fix for this has already been included in the code on GitHub and will be available in RC2.

In the meantime, users can fix this issue themselves by following these instructions.
190 comments

xx SMF 1.1.* status update

March 23, 2018, 02:24:45 PM by Illori
In order to provide enhanced support and focus development on upcoming releases, the Simple Machines Forum Team is announcing that version 1.1 of our software will no longer be receiving updates.

SMF 1.1 is outdated in many ways, including in relation to a number of security issues. We suggest that anyone who is still using SMF 1.1 should migrate to SMF 2.0 as soon as possible.  The support board for SMF 1.1 will remain open for the time being to allow anyone who has questions about how to upgrade their forum or encounters any problems in doing so to request assistance from our support team.

We are aware that some of our community members have created temporary solutions to the incompatibility problems of the 1.1 series with PHP.  We invite those of you who have created these solutions to submit them to our Customization Site. The Customization Team will review the submissions and make them public for the benefit of the entire community. We are open to patches being made, but we need to review them before they are made publicly available to the community.

Development will focus on version 2.1, but we will continue supporting and updating version 2.0.x.

For more information, please see:


Regards,

Simple Machines Forum Team
24 comments

Menubar Function

Displays a menu bar, like one displayed at the top of the forum.

Code

Code: [Select]
<?php ssi_menubar(); ?>

Result

Quick Search Function

Code

Code: [Select]
<?php ssi_quickSearch(); ?>

Result

Recent Attachments Function

Code

Code: [Select]
<?php ssi_recentAttachments(); ?>

Result

Show Single Poll

Shows a poll in the specified topic.

Code

Code: [Select]
<?php ssi_showPoll($topicID); ?>

Result

Not shown because it needs specific topic ID that contains a poll.

Show Single Post

Fetches a post with a particular IDs. By default will only show if you have permission to the see the board in question. This can be overriden by passing the 2nd parameter as true.

Code

Code: [Select]
<?php ssi_fetchPosts($postIDs, $isOverride); ?>

Result

Not shown because it needs a specific post ID.

Show Single Member

Shows the specified member's name and profile link.

Code

Code: [Select]
<?php ssi_fetchMember($memberIDs); ?>

Result

Not shown because it needs a specific member ID.

Show Group Members

Shows all members in a specified group.

Code

Code: [Select]
<?php ssi_fetchGroupMembers($groupIDs); ?>

Result

Not shown because it needs specific membergroup IDs.

Home Page Sample

This sample uses the following features: ssi_recentTopics(), ssi_logOnline(), ssi_welcome(), and ssi_boardNews(). ssi_recentTopics() is fetched using the array method, to allow further customizations on the output.

Code

Code: [Select]
<?php require("SSI.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>SSI.php example for home page</title> <style type="text/css"> body { font-family: Arial, Tahoma, sans-serif; font-size: 80%; background: #DFDFDF; color: #FFFFFF; margin: 0 } ul,ol { padding-left: 19px; margin: 0; } li { font-size: 11px; } h1,h2,h3 { margin: 0; padding: 0; } h3 { font-size: 15px; } a:link,a:visited { color: #FF9000; text-decoration: none; } a:hover { text-decoration: underline; } #container { background: #52514E; width: 100%; border: 1px solid midnightblue; line-height: 150%; margin: 0; } #header,#footer { color: lightgray; background-color: #2A2825; clear: both; padding: .5em; } #leftbar { background: #DF7E00; float: left; width: 160px; margin: 0; padding: 1em; } #leftbar a { color: #000000; text-decoration: underline; } #content { margin-left: 190px; padding: 1em; } #navigation { float: right; } #navigation a:link,#navigation a:visited { color: #FF9000; } </style> </head> <body> <div id="container"> <div id="header"> <div id="navigation"> <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> </div> <h1 class="header">YourWebsite.com</h1> </div> <div id="leftbar"> <h3>Recent Forum Topics</h3> <ul> <?php // Using array method to show shorter display style. $topics = ssi_recentTopics(8, null, null, 'array'); foreach ($topics as $topic) { // Uncomment the following code to get a listing of array elements that SMF provides for this function. // echo '<pre>', print_r($topic), '</pre>'; echo ' <li><a href=\"', $topic['href'], '\">', $topic['subject'], '</a> ', $txt['by'], ' ', $topics[$i]['poster']['link'], '</li>'; } unset($topics); ?> </ul><br /> <h3>Online Users</h3> <?php ssi_logOnline(); ?> </div> <div id="content"> <?php ssi_welcome(); ?><br /><br /> <h2>News</h2> <?php ssi_boardNews(); ?> </div> <div id="footer"> <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/publicdomain/88x31.png" /></a> This sample website layout is dedicated to the <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/">Public Domain</a>. </div> </div> </body> </html>

Result