ssi_examples.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // Special thanks to Spaceman-Spiff for his contributions to this page.
  13. /* Define $ssi_guest_access variable just before including SSI.php to handle guest access to your script.
  14. false: (default) fallback to forum setting
  15. true: allow guest access to the script regardless
  16. */
  17. $ssi_guest_access = false;
  18. // Include the SSI file.
  19. require(dirname(__FILE__) . '/SSI.php');
  20. // Viewing the homepage sample?
  21. if (isset($_GET['view']) && $_GET['view'] == 'home1')
  22. {
  23. template_homepage_sample1('output');
  24. exit;
  25. }
  26. // Load the main template.
  27. template_ssi_above();
  28. ?>
  29. <h2>SMF SSI.php Functions</h2>
  30. <p><strong>Current Version:</strong> 2.1 Alpha 1</p>
  31. <p>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.</p>
  32. <h2>Include Code</h2>
  33. <p>To use SSI.php in your page add at the very top of your page before the &lt;html&gt; tag on line 1 of your php file:</p>
  34. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php require(&quot;<?php echo addslashes($user_info['is_admin'] ? realpath($boarddir . '/SSI.php') : 'SSI.php'); ?>&quot;); ?&gt;</code>
  35. <h2>Some notes on usage</h2>
  36. <p>All the functions have an output method parameter. This can either be &quot;echo&quot; (the default) or &quot;array&quot;</p>
  37. <p>If it is &quot;echo&quot;, 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.</p>
  38. <p onclick="if (getInnerHTML(this).indexOf('Bird') == -1) setInnerHTML(this, getInnerHTML(this) + '<br /><img src=&quot;http://www.simplemachines.org/images/chocobo.jpg&quot; title=&quot;Bird-san&quot; alt=&quot;Chocobo!&quot; />'); return false;">This functionality can be used to allow you to present the information in any way you wish.</p>
  39. <h2>Additional Guides &amp; FAQ</h2>
  40. <p>Need more information on using SSI.php? Check out <a href="http://docs.simplemachines.org/index.php?topic=400.0">Using SSI.php article</a> or <a href="http://www.simplemachines.org/community/index.php?topic=14906.0">the SSI FAQ</a>.</p>
  41. <div id="sidenav" class="windowbg">
  42. <span class="topslice"><span></span></span>
  43. <div class="content">
  44. <h2 id="functionlist">Function List</h2>
  45. <h3>Recent Items</h3>
  46. <ul>
  47. <li><a href="#" onclick="showSSIBlock('ssi_recentTopics'); return false;">Recent Topics</a></li>
  48. <li><a href="#" onclick="showSSIBlock('ssi_recentPosts'); return false;">Recent Posts</a></li>
  49. <li><a href="#" onclick="showSSIBlock('ssi_recentPoll'); return false;">Recent Poll</a></li>
  50. </ul>
  51. <h3>Top Items</h3>
  52. <ul>
  53. <li><a href="#" onclick="showSSIBlock('ssi_topBoards'); return false;">Top Boards</a></li>
  54. <li><a href="#" onclick="showSSIBlock('ssi_topTopicsViews'); return false;">Top Topics</a></li>
  55. <li><a href="#" onclick="showSSIBlock('ssi_topPoll'); return false;">Top Poll</a></li>
  56. <li><a href="#" onclick="showSSIBlock('ssi_topPoster'); return false;">Top Poster</a></li>
  57. </ul>
  58. <h3>Members</h3>
  59. <ul>
  60. <li><a href="#" onclick="showSSIBlock('ssi_latestMember'); return false;">Latest Member Function</a></li>
  61. <li><a href="#" onclick="showSSIBlock('ssi_randomMember'); return false;">Member of the Day</a></li>
  62. <li><a href="#" onclick="showSSIBlock('ssi_whosOnline'); return false;">Who's Online</a></li>
  63. </ul>
  64. <h3>Authentication</h3>
  65. <ul>
  66. <li><a href="#" onclick="showSSIBlock('ssi_login'); return false;">Welcome, Login &amp; Logout</a></li>
  67. </ul>
  68. <h3>Calendar</h3>
  69. <ul>
  70. <li><a href="#" onclick="showSSIBlock('ssi_todaysCalendar'); return false;">Today's Events</a></li>
  71. <li><a href="#" onclick="showSSIBlock('ssi_recentEvents'); return false;">Recent Events</a></li>
  72. </ul>
  73. <h3>Miscellaneous</h3>
  74. <ul>
  75. <li><a href="#" onclick="showSSIBlock('ssi_boardStats'); return false;">Forum Stats</a></li>
  76. <li><a href="#" onclick="showSSIBlock('ssi_news'); return false;">News</a></li>
  77. <li><a href="#" onclick="showSSIBlock('ssi_boardNews'); return false;">Board News</a></li>
  78. <li><a href="#" onclick="showSSIBlock('ssi_menubar'); return false;">Menubar</a></li>
  79. <li><a href="#" onclick="showSSIBlock('ssi_quickSearch'); return false;">Quick Search Box</a></li>
  80. <li><a href="#" onclick="showSSIBlock('ssi_recentAttachments'); return false;">Recent Attachments</a></li>
  81. </ul>
  82. <?php if ($user_info['is_admin']) { ?>
  83. <h3>Advanced Functions <img class="help" title="Functions that require additional tweaking, not just copy and paste." src="<?php echo $settings['images_url']; ?>/helptopics.png" alt="" /></h3>
  84. <ul>
  85. <li><a href="#" onclick="showSSIBlock('ssi_showPoll'); return false;">Show Single Poll</a></li>
  86. <li><a href="#" onclick="showSSIBlock('ssi_fetchPosts'); return false;">Show Single Post</a></li>
  87. <li><a href="#" onclick="showSSIBlock('ssi_fetchMember'); return false;">Show Single Member</a></li>
  88. <li><a href="#" onclick="showSSIBlock('ssi_fetchGroupMembers'); return false;">Show Group Members</a></li>
  89. </ul>
  90. <?php } ?>
  91. <h3>Website Samples</h3>
  92. <ul>
  93. <li><a href="#" onclick="showSSIBlock('htmlhome')">Sample 1</a></li>
  94. </ul>
  95. <h2 id="other">Other</h2>
  96. <ul>
  97. <li><a href="#" onclick="toggleVisibleByClass('ssi_preview', false); return false;">Show all examples</a></li>
  98. <li><a href="#" onclick="toggleVisibleByClass('ssi_preview', true); return false;">Hide all examples</a></li>
  99. </ul>
  100. </div>
  101. <span class="botslice"><span></span></span>
  102. </div>
  103. <div id="preview" class="windowbg2">
  104. <span class="topslice"><span></span></span>
  105. <div class="content">
  106. <!-- RECENT ITEMS -->
  107. <div class="ssi_preview" id="ssi_recentTopics">
  108. <h2>Recent Topics Function</h2>
  109. <h3>Code (simple mode)</h3>
  110. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_recentTopics(); ?&gt;</code>
  111. <h3>Code (advanced mode)</h3>
  112. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo'); ?&gt;</code>
  113. <h3>Result</h3>
  114. <div class="ssi_result"><?php ssi_recentTopics(); flush(); ?></div>
  115. </div>
  116. <div class="ssi_preview" id="ssi_recentPosts">
  117. <h2>Recent Posts Function</h2>
  118. <h3>Code</h3>
  119. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_recentPosts(); ?&gt;</code>
  120. <h3>Result</h3>
  121. <div class="ssi_result"><?php ssi_recentPosts(); flush(); ?></div>
  122. </div>
  123. <div class="ssi_preview" id="ssi_recentPoll">
  124. <h2>Recent Poll Function</h2>
  125. <h3>Code</h3>
  126. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_recentPoll(); ?&gt;</code>
  127. <h3>Result</h3>
  128. <div class="ssi_result"><?php ssi_recentPoll(); flush(); ?></div>
  129. </div>
  130. <!-- TOP ITEMS -->
  131. <div class="ssi_preview" id="ssi_topBoards">
  132. <h2>Top Boards Function</h2>
  133. <p>Shows top boards by the number of posts.</p>
  134. <h3>Code</h3>
  135. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topBoards(); ?&gt;</code>
  136. <h3>Result</h3>
  137. <div class="ssi_result"><?php ssi_topBoards(); flush(); ?></div>
  138. </div>
  139. <div class="ssi_preview" id="ssi_topTopicsViews">
  140. <h2>Top Topics</h2>
  141. <p>Shows top topics by the number of replies or views.</p>
  142. <h3>Code (show by number of views)</h3>
  143. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topTopicsViews(); ?&gt;</code>
  144. <h3>Result</h3>
  145. <div class="ssi_result"><?php ssi_topTopicsViews(); flush(); ?></div>
  146. <h3>Code (show by number of replies)</h3>
  147. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topTopicsReplies(); ?&gt;</code>
  148. <h3>Result</h3>
  149. <div class="ssi_result"><?php ssi_topTopicsReplies(); flush(); ?></div>
  150. </div>
  151. <div class="ssi_preview" id="ssi_topPoll">
  152. <h2>Top Poll Function</h2>
  153. <p>Shows the most-voted-in poll.</p>
  154. <h3>Code</h3>
  155. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topPoll(); ?&gt;</code>
  156. <h3>Result</h3>
  157. <div class="ssi_result"><?php ssi_topPoll(); flush(); ?></div>
  158. </div>
  159. <div class="ssi_preview" id="ssi_topPoster">
  160. <h2>Top Poster Function</h2>
  161. Shows the top poster's name and profile link.
  162. <h3>Code</h3>
  163. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topPoster(); ?&gt;</code>
  164. <h3>Result</h3>
  165. <div class="ssi_result"><?php ssi_topPoster(); flush(); ?></div>
  166. </div>
  167. <!-- MEMBERS -->
  168. <div class="ssi_preview" id="ssi_latestMember">
  169. <h2>Latest Member Function</h2>
  170. <p>Shows the latest member's name and profile link.</p>
  171. <h3>Code</h3>
  172. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_latestMember(); ?&gt;</code>
  173. <h3>Result</h3>
  174. <div class="ssi_result"><?php ssi_latestMember(); flush(); ?></div>
  175. </div>
  176. <div class="ssi_preview" id="ssi_randomMember">
  177. <h2>Member of the Day</h2>
  178. <p>Shows one random member of the day. This changes once a day.</p>
  179. <h3>Code</h3>
  180. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_randomMember('day'); ?&gt;</code>
  181. <h3>Result</h3>
  182. <div class="ssi_result"><?php ssi_randomMember('day'); flush(); ?></div>
  183. </div>
  184. <div class="ssi_preview" id="ssi_whosOnline">
  185. <h2>Who's Online Function</h2>
  186. <p>This function shows who are online inside the forum.</p>
  187. <h3>Code</h3>
  188. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_whosOnline(); ?&gt;</code>
  189. <h3>Result</h3>
  190. <div class="ssi_result"><?php ssi_whosOnline(); flush(); ?></div>
  191. <h2>Log Online Presence</h2>
  192. <p>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.</p>
  193. <h3>Code</h3>
  194. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_logOnline(); ?&gt;</code>
  195. <h3>Result</h3>
  196. <div class="ssi_result"><?php ssi_logOnline(); flush(); ?></div>
  197. </div>
  198. <!-- WELCOME, LOGIN AND LOGOUT -->
  199. <div class="ssi_preview" id="ssi_login">
  200. <h2>Login Function</h2>
  201. <p>Shows a login box only when user is not logged in.</p>
  202. <h3>Code</h3>
  203. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_login(); ?&gt;</code>
  204. <h3>Result</h3>
  205. <div class="ssi_result"><?php ssi_login(); flush(); ?></div>
  206. <h2>Logout Function</h2>
  207. <p>Shows a logout link only when user is logged in.</p>
  208. <h3>Code</h3>
  209. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_logout(); ?&gt;</code>
  210. <h3>Result</h3>
  211. <div class="ssi_result"><?php ssi_logout(); flush(); ?></div>
  212. <h2>Welcome Function</h2>
  213. <p>Greets users or guests, also shows user's messages if logged in.</p>
  214. <h3>Code</h3>
  215. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_welcome(); ?&gt;</code>
  216. <h3>Result</h3>
  217. <div class="ssi_result"><?php ssi_welcome(); flush(); ?></div>
  218. </div>
  219. <!-- CALENDAR -->
  220. <div class="ssi_preview" id="ssi_todaysCalendar">
  221. <h2>Today's Calendar Function</h2>
  222. <h3>Code</h3>
  223. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_todaysCalendar(); ?&gt;</code>
  224. <h3>Result</h3>
  225. <div class="ssi_result"><?php ssi_todaysCalendar(); flush(); ?></div>
  226. <h2>Today's Birthdays Function</h2>
  227. <h3>Code</h3>
  228. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_todaysBirthdays(); ?&gt;</code>
  229. <h3>Result</h3>
  230. <div class="ssi_result"><?php ssi_todaysBirthdays(); flush(); ?></div>
  231. <h2>Today's Holidays Function</h2>
  232. <h3>Code</h3>
  233. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_todaysHolidays(); ?&gt;</code>
  234. <h3>Result</h3>
  235. <div class="ssi_result"><?php ssi_todaysHolidays(); flush(); ?></div>
  236. <h2>Today's Events Function</h2>
  237. <h3>Code</h3>
  238. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_todaysEvents(); ?&gt;</code>
  239. <h3>Result</h3>
  240. <div class="ssi_result"><?php ssi_todaysEvents(); flush(); ?></div>
  241. </div>
  242. <div class="ssi_preview" id="ssi_recentEvents">
  243. <h2>Recent Calendar Events Function</h2>
  244. <h3>Code</h3>
  245. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_recentEvents(); ?&gt;</code>
  246. <h3>Result</h3>
  247. <div class="ssi_result"><?php ssi_recentEvents(); flush(); ?></div>
  248. </div>
  249. <!-- MISCELLANEOUS -->
  250. <div class="ssi_preview" id="ssi_boardStats">
  251. <h2>Forum Stats</h2>
  252. <p>Shows some basic forum stats: total members, posts, topics, boards, etc.</p>
  253. <h3>Code</h3>
  254. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_boardStats(); ?&gt;</code>
  255. <h3>Result</h3>
  256. <div class="ssi_result"><?php ssi_boardStats(); flush(); ?></div>
  257. </div>
  258. <div class="ssi_preview" id="ssi_news">
  259. <h2>News Function</h2>
  260. <p>Shows random forum news.</p>
  261. <h3>Code</h3>
  262. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_news(); ?&gt;</code>
  263. <h3>Result</h3>
  264. <div class="ssi_result"><?php ssi_news(); flush(); ?></div>
  265. </div>
  266. <div class="ssi_preview" id="ssi_boardNews">
  267. <h2>Board News Function</h2>
  268. <p>Shows the latest posts from read only boards, or a specific board.</p>
  269. <h3>Code</h3>
  270. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_boardNews(); ?&gt;</code>
  271. <h3>Result</h3>
  272. <div class="ssi_result"><?php ssi_boardNews(); flush(); ?></div>
  273. </div>
  274. <div class="ssi_preview" id="ssi_menubar">
  275. <h2>Menubar Function</h2>
  276. <p>Displays a menu bar, like one displayed at the top of the forum.</p>
  277. <h3>Code</h3>
  278. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_menubar(); ?&gt;</code>
  279. <h3>Result</h3>
  280. <div class="ssi_result"><?php ssi_menubar(); flush(); ?></div>
  281. </div>
  282. <div class="ssi_preview" id="ssi_quickSearch">
  283. <h2>Quick Search Function</h2>
  284. <h3>Code</h3>
  285. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_quickSearch(); ?&gt;</code>
  286. <h3>Result</h3>
  287. <div class="ssi_result"><?php ssi_quickSearch(); flush(); ?></div>
  288. </div>
  289. <div class="ssi_preview" id="ssi_recentAttachments">
  290. <h2>Recent Attachments Function</h2>
  291. <h3>Code</h3>
  292. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_recentAttachments(); ?&gt;</code>
  293. <h3>Result</h3>
  294. <div class="ssi_result"><?php ssi_recentAttachments(); flush(); ?></div>
  295. </div>
  296. <!-- ADVANCED FUNCTIONS -->
  297. <div class="ssi_preview" id="ssi_showPoll">
  298. <h2>Show Single Poll</h2>
  299. <p>Shows a poll in the specified topic.</p>
  300. <h3>Code</h3>
  301. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_showPoll($topicID); ?&gt;</code>
  302. <h3>Result</h3>
  303. <div class="ssi_result"><i>Not shown because it needs specific topic ID that contains a poll.</i></div>
  304. </div>
  305. <div class="ssi_preview" id="ssi_fetchPosts">
  306. <h2>Show Single Post</h2>
  307. <p>Fetches a post with a particular IDs. By default will only show if you have permission to the see
  308. the board in question. This can be overriden by passing the 2nd parameter as <tt>true</tt>.</p>
  309. <h3>Code</h3>
  310. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_fetchPosts($postIDs, $isOverride); ?&gt;</code>
  311. <h3>Result</h3>
  312. <div class="ssi_result"><i>Not shown because it needs a specific post ID.</i></div>
  313. </div>
  314. <div class="ssi_preview" id="ssi_fetchMember">
  315. <h2>Show Single Member</h2>
  316. <p>Shows the specified member's name and profile link.</p>
  317. <h3>Code</h3>
  318. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_fetchMember($memberIDs); ?&gt;</code>
  319. <h3>Result</h3>
  320. <div class="ssi_result"><i>Not shown because it needs a specific member ID.</i></div>
  321. </div>
  322. <div class="ssi_preview" id="ssi_fetchGroupMembers">
  323. <h2>Show Group Members</h2>
  324. <p>Shows all members in a specified group.</p>
  325. <h3>Code</h3>
  326. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_fetchGroupMembers($groupIDs); ?&gt;</code>
  327. <h3>Result</h3>
  328. <div class="ssi_result"><i>Not shown because it needs specific membergroup IDs.</i></div>
  329. </div>
  330. <div class="ssi_preview" id="htmlhome">
  331. <h2>Home Page Sample</h2>
  332. This sample uses the following features: ssi_recentTopics(), ssi_logOnline(), ssi_welcome(), and ssi_boardNews().
  333. ssi_recentTopics() is fetched using the array method, to allow further customizations on the output.
  334. <h3>Code</h3>
  335. <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php echo htmlspecialchars(template_homepage_sample1('source')); ?></code>
  336. <h3>Result</h3>
  337. <iframe src="?view=home1" width="99%" height="300"></iframe>
  338. </div>
  339. </div>
  340. <span class="botslice"><span></span></span>
  341. </div>
  342. <?php
  343. template_ssi_below();
  344. function template_ssi_above()
  345. {
  346. global $settings, $context, $scripturl;
  347. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  348. <html xmlns="http://www.w3.org/1999/xhtml">
  349. <head>
  350. <title>SMF 2.1 Alpha 1 SSI.php Examples</title>
  351. <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/index.css?alp21" />
  352. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
  353. <style type="text/css">
  354. #wrapper
  355. {
  356. width: 90%;
  357. }
  358. #upper_section .user
  359. {
  360. height: 4em;
  361. }
  362. #upper_section .news
  363. {
  364. height: 80px;
  365. }
  366. #content_section
  367. {
  368. position: relative;
  369. top: -20px;
  370. }
  371. #main_content_section h2
  372. {
  373. font-size: 1.5em;
  374. border-bottom: solid 1px #d05800;
  375. line-height: 1.5em;
  376. margin: 0.5em 0;
  377. color: #d05800;
  378. }
  379. #liftup
  380. {
  381. position: relative;
  382. top: -70px;
  383. padding: 1em 2em 1em 1em;
  384. line-height: 1.6em;
  385. }
  386. #footer_section
  387. {
  388. position: relative;
  389. top: -20px;
  390. }
  391. #sidenav
  392. {
  393. width: 210px;
  394. float: left;
  395. margin-right: 20px;
  396. }
  397. #sidenav ul
  398. {
  399. margin: 0 0 0 15px;
  400. padding: 0;
  401. list-style: none;
  402. font-size: 90%;
  403. }
  404. #preview
  405. {
  406. margin-left: 230px;
  407. }
  408. .ssi_preview
  409. {
  410. margin-bottom: 1.5em;
  411. }
  412. .ssi_preview h3
  413. {
  414. margin: 1em 0 0.5em 0;
  415. }
  416. .ssi_result
  417. {
  418. background-color: #fff;
  419. border: 1px solid #99a;
  420. padding: 10px;
  421. overflow: hidden;
  422. }
  423. </style>
  424. <script type="text/javascript"><!-- // --><![CDATA[
  425. var smf_scripturl = "', $scripturl, '";
  426. var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
  427. var smf_charset = "', $context['character_set'], '";
  428. // Sets all ssi_preview class to hidden, then shows the one requested.
  429. function showSSIBlock(elementID)
  430. {
  431. toggleVisibleByClass("ssi_preview", true);
  432. document.getElementById(elementID).style.display = "block";
  433. }
  434. // Toggle visibility of all sections.
  435. function toggleVisibleByClass(sClassName, bHide)
  436. {
  437. var oSections = document.getElementsByTagName("div");
  438. for (var i = 0; i < oSections.length; i++)
  439. {
  440. if (oSections[i].className === null || oSections[i].className.indexOf(sClassName) == -1)
  441. continue;
  442. oSections[i].style.display = bHide ? "none" : "block";
  443. }
  444. }
  445. // ]]></script>
  446. </head>
  447. <body>
  448. <div id="wrapper">
  449. <div id="header"><div class="frame">
  450. <div id="top_section">
  451. <h1 class="forumtitle">SMF 2.1 Alpha 1 SSI.php Examples</h1>
  452. <img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />
  453. </div>
  454. <div id="upper_section" class="middletext" style="overflow: hidden;">
  455. <div class="user"></div>
  456. <div class="news normaltext">
  457. </div>
  458. </div>
  459. </div></div>
  460. <div id="content_section"><div class="frame">
  461. <div id="main_content_section">
  462. <div id="liftup" class="flow_auto">';
  463. }
  464. function template_ssi_below()
  465. {
  466. global $time_start;
  467. echo '
  468. <script type="text/javascript"><!-- // --><![CDATA[
  469. showSSIBlock("ssi_recentTopics");
  470. // ]]></script>
  471. </div>
  472. </div>
  473. </div></div>
  474. <div id="footer_section"><div class="frame">
  475. <div class="smalltext"><a href="http://www.simplemachines.org">Simple Machines Forum</a></div>
  476. </div></div>
  477. </div>
  478. </body>
  479. </html>';
  480. }
  481. function template_homepage_sample1($method = 'source')
  482. {
  483. global $user_info, $boarddir;
  484. $header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  485. <html xmlns="http://www.w3.org/1999/xhtml">
  486. <head>
  487. <title>SSI.php example for home page</title>
  488. <style type="text/css">
  489. body { font-family: Arial, Tahoma, sans-serif; font-size: 80%; background: #DFDFDF; color: #FFFFFF; margin: 0 }
  490. ul,ol { padding-left: 19px; margin: 0; }
  491. li { font-size: 11px; }
  492. h1,h2,h3 { margin: 0; padding: 0; }
  493. h3 { font-size: 15px; }
  494. a:link,a:visited { color: #FF9000; text-decoration: none; }
  495. a:hover { text-decoration: underline; }
  496. #container { background: #52514E; width: 100%; border: 1px solid midnightblue; line-height: 150%; margin: 0; }
  497. #header,#footer { color: lightgray; background-color: #2A2825; clear: both; padding: .5em; }
  498. #leftbar { background: #DF7E00; float: left; width: 160px; margin: 0; padding: 1em; }
  499. #leftbar a { color: #000000; text-decoration: underline; }
  500. #content { margin-left: 190px; padding: 1em; }
  501. #navigation { float: right; }
  502. #navigation a:link,#navigation a:visited { color: #FF9000; }
  503. </style>
  504. </head>
  505. <body>
  506. <div id="container">
  507. <div id="header">
  508. <div id="navigation">
  509. <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a>
  510. </div>
  511. <h1 class="header">YourWebsite.com</h1>
  512. </div>
  513. <div id="leftbar">
  514. <h3>Recent Forum Topics</h3>
  515. <ul>';
  516. $footer = '
  517. <div id="footer">
  518. <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>
  519. This sample website layout is dedicated to the <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/">Public Domain</a>.
  520. </div>
  521. </div>
  522. </body>
  523. </html>';
  524. if ($method == 'source')
  525. {
  526. $header = '<?php require("' . ($user_info['is_admin'] ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header;
  527. return $header . template_homepage_sample1_html() . $footer;
  528. }
  529. else
  530. {
  531. echo $header;
  532. template_homepage_sample1_php();
  533. echo $footer;
  534. }
  535. }
  536. function template_homepage_sample1_php()
  537. {
  538. global $txt;
  539. $topics = ssi_recentTopics(8, null, null, 'array');
  540. foreach ($topics as $topic)
  541. echo '
  542. <li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>';
  543. unset($topics);
  544. echo '
  545. </ul><br />
  546. <h3>Online Users</h3>';
  547. ssi_logOnline();
  548. echo '
  549. </div>
  550. <div id="content">';
  551. ssi_welcome();
  552. echo '
  553. <br /><br />
  554. <h2>News</h2>';
  555. ssi_boardNews();
  556. echo '
  557. </div>';
  558. }
  559. function template_homepage_sample1_html()
  560. {
  561. $result = '
  562. <?php
  563. // Using array method to show shorter display style.
  564. $topics = ssi_recentTopics(8, null, null, \'array\');
  565. foreach ($topics as $topic)
  566. {
  567. // Uncomment the following code to get a listing of array elements that SMF provides for this function.
  568. // echo \'<pre>\', print_r($topic), \'</pre>\';
  569. echo \'
  570. <li><a href=\"\', $topic[\'href\'], \'\">\', $topic[\'subject\'], \'</a> \', $txt[\'by\'], \' \', $topics[$i][\'poster\'][\'link\'], \'</li>\';
  571. }
  572. unset($topics);
  573. ?>
  574. </ul><br />
  575. <h3>Online Users</h3>
  576. <?php ssi_logOnline(); ?>
  577. </div>
  578. <div id="content">
  579. <?php ssi_welcome(); ?><br /><br />
  580. <h2>News</h2>
  581. <?php ssi_boardNews(); ?>
  582. </div>';
  583. return $result;
  584. }