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,216,480
Bugtracker (Github) 0 2,468,925
Srpski (Serbian) 0 2,406,945
Bosanski (Bosnian) 0 2,325,239
Hrvatski (Croatian) 0 2,319,536
SMF 1.1.x Support New 82,792 519,863
SMF 2.0.x Support New 46,923 348,342
Modifications and Packages New 2,646 331,471
Arşiv New 31,575 228,763
Español (Spanish) New 29,322 175,013

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 ZoeWoodbur, 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: 419,721
Total Posts: 3,792,121
Total Topics: 452,942
Total Categories: 13
Total Boards: 223

News Function

Shows random forum news.

Code

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

Result

Check out the SMF Function DB!

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 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
146 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

xx SMF 2.0.15 Released

November 19, 2017, 07:47:44 PM by Colin
Dear Members,

Simple Machines Forum has released a new patch to the 2.0.x line, bringing our latest release version to 2.0.15.

This patch adds both important security and general maintenance fixes to your forum, so it is imperative that you install this patch quickly.
You can view the changelog for this release, per usual, on the downloads page.

The quick summary of changes is as follows:
  • A security issue reported by Daniel Le Gall from SCRT SA
  • Various bug fix with Proxy handler
  • Login fixes for SSI and Maintenance mode
  • Various Search fixes
  • Email handling issue fixed when using SendTopic
  • Fixed SM Stat collection and added opt in/out functionality to the Admin Panel

Please see the changelog for more information.

If you are running version 2.0.14, you can update your forum to the latest version by using the package manager. As usual, 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 > Fetch Simple Machines Files (check the "Run Now" checkbox and click the "Run Now" button)).

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 "full upgrade" archive from the downloads 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 full upgrade.

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.


If you are having problems downloading the patch from the admin panel, you can download the patch package from the upgrade patches 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:

Thank you for using SMF!

Regards,
Simple Machines Forum Team
53 comments

xx SMF 2.1 Beta 3 Released

May 31, 2017, 09:21:59 PM by Colin
Dear Users,

Simple Machines is proud to announce the release of the 3rd Beta of SMF 2.1. This version contains many improvements over Beta 2 and also fixes many bugs that were discovered following its release.

Among the notable improvements:

  • Added reCAPTCHA as core feature to keep spammers away.
  • Upgrade.php code clean-up. Now the upgrade process should be more consistent.
  • RSS general improvements.
  • Added support for jQuery 3.x.
  • Modified Curve2 to improve the responsiveness of the design.
  • General bug fixes, code improvements, and clean-up.
  • Default codification will now be UTF-8.

For full details of what has changed, please see our GitHub repo.


The general installation/upgrade procedure of this Beta release remains the same, however, once you upgrade from an older version to 2.1 you cannot go back, so please take careful consideration before upgrading any live site. Have a look at Installing and Upgrading SMF in the Online Manual to find out more. You cannot upgrade to 2.1 Beta 3 via the package manager; instead you will need to carry out the Large Upgrade process. SMF 2.1 can be obtained from the download section.

Please note that because this is a beta release, translations and language strings other than English have not been finalized and may not yet be complete.

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

Finally, thanks to all of the team and development contributors who have brought us one step closer to a release candidate. On behalf of the project, we appreciate the time, energy and contributions you have made.

Thank you for using SMF

Kind regards,
Simple Machines Forum Team
367 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