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,514,242
Bosanski (Bosnian) 0 2,840,282
Hrvatski (Croatian) 0 2,821,751
Srpski (Serbian) 0 2,766,886
Bugtracker (Github) 0 2,744,644
SMF 1.1.x Support New 82,839 520,306
SMF 2.0.x Support New 48,657 363,540
Modifications and Packages New 2,681 336,868
Arşiv New 31,575 228,763
Español (Spanish) New 29,514 176,347

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 ShehzadJamil, 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: 440,984
Total Posts: 3,845,098
Total Topics: 457,884
Total Categories: 13
Total Boards: 224

News Function

Shows random forum news.

Code

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

Result

Wondering if this will always be free?  See why free is better.

Board News Function

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

Code

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

Result

xx SMF moves to a new translation platform: switching to Crowdin

March 16, 2021, 04:01:20 AM by Dzonny
SMF moves to a new translation platform: switching to Crowdin

As SMF continues to grow, it has adapted to the increasing needs of the community and our translators. Up until this point, we have been using our own translation management tool called 'Language Editor (LE)'.  This has served the community very well for years, however, over time, it has become more difficult for the Team to maintain.  As such, we have decided to change to Crowdin.



Crowdin works smoothly and allows for a more flexible translation process. Furthermore, it provides many useful features, such as global translation memory, machine translations, and online editors. It offers convenient ways to comment on existing texts and to report mistakes or problems. As a result, using Crowdin will make it much easier to discuss, for example, the terminology, meaning, and optimal translation of each and every software string.  We believe that Crowdin will help us to optimize the translation process. It will make the process of translating faster and facilitate problem solving, resulting in higher quality translations


Want to improve SMF in your language? Here is how you can help

If you like SMF and want to contribute by translating it into your language, sign up at Crowdin, go to our page and start translating. We are looking forward to seeing you there.  If you have already registered on our SMF community forum, just use this link to proceed and join our project on Crowdin without the need to additionally sign up on their page.  All you need to do is to log in with your SMF account.

https://dev.simplemachines.org/crowdin.php

We understand that using the new platform may seem quite complicated for users who have not used it before, so we have written this article for current and potential translators, which includes detailed guidelines on how to translate SMF on Crowdin to make it easier for you to work with this software.

Please note that Crowdin will be officially used as the Translation Management Software from branch 2.1 onwards. Older branches of the software will continue to be updated using the LE (Language Editor) until EOL (end of life).


How translation is changing

Nothing has significantly changed in our translation management system on the new platform, but there are some important differences in terminology that Senior Translators, in particular, need to be aware of.  For instance, SMF Senior Translators will become Proofreaders on Crowdin, but their role remains the same.
Proofreaders (Senior Translators) will continue to:
•   Approve/unapprove translations;
•   Be responsbible for overseeing the accuracy of translations;
•   Answer questions and requests in comments;
•   Resolve issues.

Please note that on the SMF community, Senior Translators will still be referred to as such and the change in Crowdin is purely one of terminology, rather than a change of role.  If anything, the new tools available in Crowdin enhance the role of a Senior Translator and make it easier for them to carry out their duties.



22 comments | Write Comment

xx SMF 2.0.18 Released

February 01, 2021, 04:50:07 PM by Suki
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.18.

The patch is focused on PHP 7.4 support as well as other issues encountered on previous versions such as
  • Policy acceptance missing id_member.
  • Addresses PHP parse errors when using SMF file cache
  • Avoids truncating Settings.php until after we have a lock on the file
  • Tighten up security checks, bring in sync with 2.1
  • Brought the UTF16-to-UTF8 logic over from 2.1
  • Always include email address when downloading user's own profile data
  • Fix missing info affecting logging for new registrations
  • Fixes bugs with multi-version jumps (via CLI) where settings weren't refreshed
  • Set utf8 as default going forward



Please see the changelog for more information.


If you are currently using version 2.0.17 you can perform the update using the package manager, once available you will see a notification update within your admin panel. please run the scheduled task "Fetch Simple Machines files" from the Scheduled Tasks page (Admin > Maintenance > Scheduled Tasks). Same logic applies if you want to update your forum from an older version, you can apply each patch successively until you reach out to 2.0.18


If you use an older version of SMF, you can upgrade directly to 2.0.18 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
65 comments | Write Comment

xx SMF Welcomes Lex as The New Project Manager

January 17, 2021, 03:21:38 PM by Irisado
The SMF Team has recently held its annual election for the position of Project Manager.

After a number of years in the position Illori has chosen to step down to focus on providing support and Lex, who had been the Support Team lead up until this point, has won the election to become the new Project Manager for SMF.

The Team thanks Illori for all her hard work as Project Manager and welcomes Lex into the position.  Please join us in thanking Illori for all her hard work and congratulating Lex on his successful election.
32 comments | Write Comment

xx SMF 2.1 RC3 Released

October 15, 2020, 07:16:48 PM by Suki
Simple Machines is pleased to announce the release of SMF 2.1 RC3. Bugs that were reported after the release of RC2 have been fixed and improvements have been made to security, stability, and performance. The many fixes and improvements include the following:


- Enhanced privacy policy support.
- Several important enhancements to PostgreSQL and MySQL.
- Multiple hooks added for handling data and/or presentation.
- Language files now uses sprintf() whenever possible.
- Theme enhancements/fixes.
- Improvements on Admin session checks.
- Enhancements on security: tokens, hashing cookies and better session handling.
- Multiple calendar fixes/enhancements.
- Better hashing system for the image proxy.
- Bug fixes for alert notifications.
- Added unsubscribe links for announcement emails.
- PHP 7.4 support.
- Several misc bug fixes/improvements.
- Download of posts/PMs/profile for GDPR.


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 RC3 can be installed as a brand new installation, or an SMF 2.0.x installation can be upgraded to SMF RC3, 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/improvements towards the Final release... However, we do not recommend using an RC package on any live installation and/or production forum due 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 code contributors, Teamies, and non-Teamies whose reports and pull requests have greatly helped us not only to reach our goals, but also to create/grow/improve our development cycle. 

Thank you for using SMF!

Kind regards,
Simple Machines

103 comments | Write Comment

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