SMF SSI.php Functions

Current Version: 2.1.2

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.

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,575,161
Bosanski (Bosnian) 0 2,876,628
Hrvatski (Croatian) 0 2,858,014
Srpski (Serbian) 0 2,803,035
Bugtracker (Github) 0 2,785,182
SMF 1.1.x Support New 82,871 520,638
SMF 2.0.x Support New 49,522 371,591
Modifications and Packages New 2,734 342,167
Arşiv New 31,575 228,763
Español (Spanish) New 29,661 177,107

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 Giuseppesss, 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

419 Guests, 6 Users (2 Hidden)
Danielㅤ, gorbi, Kindred, Giuseppesss
[]

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

419 Guests, 6 Users (2 Hidden)
Danielㅤ, gorbi, Kindred, Giuseppesss
[]

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 to Simple Machines Community Forum. Please log in or sign up.

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: 447,697
Total Posts: 3,891,652
Total Topics: 462,202
Total Categories: 13
Total Boards: 224

News Function

Shows random forum news.

Code

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

Result

SMF 2.1.2 has been released! Take it for a spin! Read more.

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.1.2 Released

May 09, 2022, 12:33:55 PM by Sesquipedalian
Dear Members,

Simple Machines is pleased to announce a new patch for the 2.1.x line of SMF, which pushes the version number to 2.1.2.

We consider this patch to be of crucial importance, as it includes security updates.

Notable changes in SMF 2.1.2

  • Fixes errors when attempting to view the profile of a non-existent user.
  • Fixes minor issues with the editor toolbar when certain BBCodes are disabled.
  • Fixes a bug where the admin panel incorrectly showed the image proxy settings as editable when Settings.php was read-only.
  • Correctly formats the gender string in profile exports.
  • Correctly formats the custom profile field names and values in the Buddies list.
  • Fixes a minor bug when displaying size limits in the attachments restrictions information.
  • Large image thumbnails now display with the the correct aspect ratio when viewed on small devices.
  • Video attachments no longer overflow the window on small devices.
  • Fixes errors about undefined variables when switching between different cache accelerator options.
  • Fixes an error about invalid dates when a comma was used under certain circumstances while creating a calendar event.
  • Correctly handles uppercase non-ASCII characters in the answers to verification questions.
  • Fixes a bug that could allow a topic to be moved into a redirection board under certain circumstances.
  • Fixes a error that could be generated when sending notifications about guest posts.
  • Fixes a bug where certain pages could fail to load if the set_time_limit() function was disabled on PHP 8+.
  • Fixes a bug where attachments might not download correctly if the "Enable compressed output" setting was enabled on PHP 8.0.17+ and 8.1.4+.
  • Fixes some rare Unicode character handling issues.
  • Security improvements.

Please see the change list on GitHub for more information.

How to update to 2.1.2

If you are currently using version 2.1.1 you can perform the update using the Package Manager (Administration Center > Package Manager). There you should see a notification about 2.1.2, including a "update your forum" link. If you do not see this notification in the Package Manager, please run "Fetch Simple Machines files" from the Scheduled Tasks page (Administration Center > Maintenance > Scheduled Tasks), and then try again.

If you are currently using version 2.1.0, you can use the process described above to apply previous update patches successively until you reach version 2.1.2.

If you are currently using any older version of SMF (including SMF 1.x, SMF 2.0.x, or one of the SMF 2.1 Betas or RCs), you can upgrade directly to 2.1.2 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 SMF 2.1.0 or higher, 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.


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.1.x Support Board.

Thank you for using SMF!

Regards,
Simple Machines
43 comments | Write Comment

xx SMF 2.1.1 Released

February 11, 2022, 08:21:50 PM by Sesquipedalian
Dear Members,

Simple Machines has released our first patch to the 2.1.x line of SMF, bringing our latest release version to 2.1.1.

  • Restores support for PHP 7.0–7.2
  • Fixes a minor bug in the Package Manager

How to update to 2.1.1

If you are running version 2.1.0, 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).

For other install and upgrade options, please see below.


Since SMF 2.1.1 comes soon after SMF 2.1.0, which was released only a few days ago, we are including a copy the SMF 2.1.0 release announcement for your convenience:


Simple Machines is pleased to announce the official release of the long awaited SMF 2.1.

This release marks the transition of SMF 2.1 into the current stable release of SMF. This means that:

  • SMF 2.1 is now the recommended version for use on live production forums. We encourage everyone to start planning for an upgrade to SMF 2.1.
  • SMF 2.0 remains supported and will continue to receive security updates for the foreseeable future, but this release officially marks the end of further 2.0 development. We will release a separate announcement for any future changes to SMF 2.0's status.


Notable changes in 2.1

The changes between SMF 2.0.x and SMF 2.1 are too many to count, but here are a few highlights:

  • New features for users
    • A new WYSIWYG editor, SCEditor
    • Real-time alerts in addition to email notifications
    • A new default theme with full support for mobile devices
    • Draft messages (you can save & resume later)
    • Mentions using @name syntax
    • Drag & drop attachments
    • Attachments can be embedded directly into post text
  • New features for moderators and administrators
    • An improved Administrator Control Panel
    • Support for moderator groups, not just individuals
    • Many security enhancements, including support for optional Two Factor Authentication.
    • IPv6 support
    • Designed with GDPR support
  • New features for modification and theme authors
    • A massive expansion of the number of integration hooks available
    • More powerful BBCode possibilities
    • Background tasks
    • New capabilities in the Package SDK

You can learn more about the many new features and changes in SMF 2.1 here.


How to install a new SMF 2.1 forum

You can install SMF 2.1 using the "Full Install" package from the Download page.

Please refer to the Online Manual for more details about installing.


How to upgrade to SMF 2.1

You can upgrade to SMF 2.1 from any previous version using the "Large Upgrade" package from the Download page.

Be aware that upgrading to SMF 2.1 will remove any modifications you may have installed on your existing SMF forum, and that SMF 2.1 is incompatible with custom themes designed for earlier versions of SMF. You will need to install new versions of those modifications and/or themes after upgrading. Many modifications and themes have already been updated by their authors to support SMF 2.1, but you may wish to check the status of individual modifications or themes before proceeding.

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


With this release we'd like to take the opportunity to recognize the effort and dedication of all the people who have volunteered their time to help the SMF project. We would like to thank everyone, past and present, who has contributed to the development of SMF over the past years.

Finally, as always, please do not use this topic for support requests. You will receive a much quicker and better response by asking for help in the SMF 2.1.x Support board.

Thank you for using SMF!

Regards,
Simple Machines
55 comments

xx SMF 2.1.0 Released

February 09, 2022, 12:42:51 PM by Sesquipedalian
Dear Members,

Simple Machines is pleased to announce the official release of the long awaited SMF 2.1.

This release marks the transition of SMF 2.1 into the current stable release of SMF. This means that:

  • SMF 2.1 is now the recommended version for use on live production forums. We encourage everyone to start planning for an upgrade to SMF 2.1.
  • SMF 2.0 remains supported and will continue to receive security updates for the foreseeable future, but this release officially marks the end of further 2.0 development. We will release a separate announcement for any future changes to SMF 2.0's status.


Notable changes in 2.1

The changes between SMF 2.0.x and SMF 2.1 are too many to count, but here are a few highlights:

  • New features for users
    • A new WYSIWYG editor, SCEditor
    • Real-time alerts in addition to email notifications
    • A new default theme with full support for mobile devices
    • Draft messages (you can save & resume later)
    • Mentions using @name syntax
    • Drag & drop attachments
    • Attachments can be embedded directly into post text
  • New features for moderators and administrators
    • An improved Administrator Control Panel
    • Support for moderator groups, not just individuals
    • Many security enhancements, including support for optional Two Factor Authentication
    • IPv6 support
    • Designed with GDPR support
  • New features for modification and theme authors
    • A massive expansion of the number of integration hooks available
    • More powerful BBCode possibilities
    • Background tasks
    • New capabilities in the Package SDK

You can learn more about the many new features and changes in SMF 2.1 here.


How to install a new SMF 2.1 forum

You can install SMF 2.1 using the "Full Install" package from the Download page.

Please refer to the Online Manual for more details about installing.


How to upgrade to SMF 2.1

You can upgrade to SMF 2.1 from any previous version using the "Large Upgrade" package from the Download page.

Be aware that upgrading to SMF 2.1 will remove any modifications you may have installed on your existing SMF forum, and that SMF 2.1 is incompatible with custom themes designed for earlier versions of SMF. You will need to install new versions of those modifications and/or themes after upgrading. Many modifications and themes have already been updated by their authors to support SMF 2.1, but you may wish to check the status of individual modifications or themes before proceeding.

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


With this release we'd like to take the opportunity to recognize the effort and dedication of all the people who have volunteered their time to help the SMF project. We would like to thank everyone, past and present, who has contributed to the development of SMF over the past years.

Finally, as always, please do not use this topic for support requests. You will receive a much quicker and better response by asking for help in the SMF 2.1.x Support board.

Thank you for using SMF!

Regards,
Simple Machines
87 comments

xx SMF 2.0.19 Released

December 21, 2021, 04:44:51 PM by Sesquipedalian
Dear Members,

Simple Machines is pleased to announce a new patch for the 2.0.x line of SMF, which pushes the version number to 2.0.19.

Notable changes in 2.0.19

  • Ensures compatibility with PHP 8.1 MySQLi error mode.
  • Fixes a bug where members could not download their basic profile data if RSS feeds were disabled.
  • Fixes a bug where double encoded entities could appear in RSS feeds and SSI functions
  • Fixes bugs related to birthdates in member profiles.
  • Improves protection against race conditions when saving Settings.php
  • Avoids an issue with certain versions of Chrome and Edge where viewing one page of a multi-page topic could cause unread posts on the next page to be incorrectly marked as read.
  • Security improvements.

Please see the changelog for more information.

How to update to 2.0.19

If you are currently using version 2.0.18 you can perform the update using the Package Manager (Administration Center > Package Manager). There you should see a notification about 2.0.19, including a "click here to install" link. If you do not see this notification in the Package Manager, please run "Fetch Simple Machines files" from the Scheduled Tasks page (Administration Center > Maintenance > Scheduled Tasks), and then try again.

If you are currently using any earlier version of the 2.0.x line, you can use the process described above to apply previous update patches successively until you reach version 2.0.19.

If you are currently using an older version of SMF, you can upgrade directly to 2.0.19 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.


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.1 RC4 Released

July 10, 2021, 11:45:38 AM by Suki
Simple Machines is pleased to announce the release of SMF 2.1 RC4. Bugs reported and labeled for RC4 have been fixed along with improvements to security, stability, and performance. Some of the fixes and improvements are as follows:

Major changes:

  • Raises minimum PHP version to 5.6
  • Updates SCEditor to version 3 and fixes multiple editor bugs
  • Improves numerous database queries
  • Makes numerous improvements to theme templates and CSS
  • Makes numerous corrections and improvements to language strings and documentation
  • Allows CORS requests in SMF

User-facing changes:

  • Uses "Forever" as the default time option when logging in
  • Moves logout button to profile menu (with fallback for non-JS users)
  • Sends HTTP error code 403 (Forbidden) when a banned user tries to log in
  • Handles TFA enable/disable menu items consistently in profile menu
  • Redirects user back to previous URL after changing language
  • Prevents bogus mention notifications
  • Fixes various issues with setting user notification preferences
  • Adds functionality to remove old alerts after they have been read
  • Avoids showing an alert counter with a value of zero
  • Improves the UI for attachment uploads
  • Improves the templates and UI logic for the PM system
  • Fixes an issue with pagination while viewing PM drafts
  • Improves handling of time zones
  • Uses correct time zone when suggesting default times for a new event
  • Fixes issues involving max width of images on different screens
  • Fixes issues with attachment images when printing a topic
  • Always uses correct rotation for attachment thumbnails
  • Fixes several errors while uploading attachments
  • Fixes a permissions issue that never allowed guests to upload images
  • Uses lazy loading for external avatars, BBC images, iframes, etc.
  • Improves BBC parsing in board descriptions
  • Keeps order of poll choices consistent across time
  • Neutralizes evil control characters in preparsecode()
  • Renders quotes with nested url tags correctly
  • Fixes an error when attempting to preview a poll
  • Allows the time picker script to be translated
  • Respects drafts_autosave_enabled user setting
  • Removes obsolete spellcheck feature

Admin and back-end changes:

  • Fixes issues with reordering custom profile fields
  • Improves email notifications regarding registration approval
  • Fixes an issue where notifications about reported members used "(N/A)" instead of the member's name
  • Improves UI to display the error log
  • Improves package manager UI
  • Improves the smiley editor
  • Fixes issues regarding time zones in admin member search
  • Allows the email field to be disabled for guests
  • Hides random news line from guests who cannot browse the forum
  • Confirms logouts and redirects when necessary (improves interactions with external integrations)
  • Implements new, more robust version of updateSettingsFile()
  • Retires old entries in log_packages table when a package is upgraded
  • Fixes issue logging changes to custom fields when nothing actually changed
  • Prunes log_topics, log_boards & log_mark_boards_read during maintenance
  • Fixes an issue with logging moderation actions
  • Fixes errors when an external avatar URL was too long
  • Fixes "Out of range value for column page_hits" error
  • Fixes issues regarding $user_info in background tasks
  • Shows correct file names in integration hooks list
  • Adds support for more password hashing schemes for converters
  • Fixes a session write fail issue
  • Fixes issues when merging topics
  • Ensures $modSettings['board_manager_groups'] is always defined
  • Ensures trackStats() & AddMailQueue() exist before calling them in obExit()
  • Improves get_proxied_url() and general proxy handling
  • Supports Cloudflare in auto-detection of Reverse Proxy IP headers
  • Avoids a database error on MariaDB during profile export
  • Fixes an undefined index error when board has grandchild boards
  • Fixes autoloading for cache classes
  • Fixes an issue where membergroups were not displayed via SSI Who's Online
  • Removes Afrinic.net WHOIS link, since they no longer support it
  • Adds link to the Read Logs settings from the Scheduled Tasks settings
  • Improves handling of 4-byte UTF-8 in script.js

Installer and upgrader changes:

  • Fixes issues installing SMF on PHP 8.0
  • Fixes typos affecting the installer
  • Fixes upgrader freezes
  • Fixes handling of legacy attachments during upgrade
  • Fixes undefined PHP function error during upgrade
  • Includes karma data in database backup during upgrade
  • Create record for all watched topics and boards during upgrade
  • Improves handling of some HTTPS URLs during upgrade
  • Correctly preserves membergroup properties during upgrade
  • Correctly handles invalid year-only birthdates during upgrade
  • Fixes issues with deleting upgrader files after upgrade is complete
  • Fixes issues with running the upgrader from CLI
  • Fixes various database queries in the upgrader
  • Sets default notification frequency to "Straight Away" instead of "Never"
  • Fixes issues upgrading from SMF 1.x
  • Fixes registration "no access" error after upgrading

This release is considered to be an RC (Release Candidate), which means that it is sufficiently functional, but that it has known and unknown bugs. These bugs do not necessarily prevent a release, rather they need to be addressed before the next dev cycle release.

SMF RC4 can be installed as a brand new installation, or an SMF 2.0.x installation can be upgraded to SMF RC4, however, please do note that there are no updates packages for any RC releases.

We highly encourage testing this version on local or development/QA environments. Testing the release will greatly help us in narrowing down, and focusing on, issues and improvements towards the Final release.  Note, however, that we do not recommend using an RC package on any live installation and/or production forum owing to the very nature of RC packages.

Finally, this announcement topic is not for support. Please use the SMF 2.1 support board instead.

A very special thanks goes to our community, team members, code contributors and beta testers. Without your help, this would not have been possible.

Thank you for using SMF!

Kind regards,
Simple Machines
92 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 overridden 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> <html> <head> <title>SSI.php example for home page</title> <style> 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="noopener" rel="license" href="https://creativecommons.org/licenses/publicdomain/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/publicdomain/88x31.png"></a> This sample website layout is dedicated to the <a target="_blank" rel="noopener" rel="license" href="https://creativecommons.org/licenses/publicdomain/">Public Domain</a>. </div> </div> </body> </html>

Result