template_ssi_below()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 15
rs 10
c 0
b 0
f 0
nc 1
1
<?php
2
3
/**
4
 * Simple Machines Forum (SMF)
5
 *
6
 * @package SMF
7
 * @author Simple Machines http://www.simplemachines.org
8
 * @copyright 2019 Simple Machines and individual contributors
9
 * @license http://www.simplemachines.org/about/smf/license.php BSD
10
 *
11
 * @version 2.1 RC2
12
 */
13
14
// Special thanks to Spaceman-Spiff for his contributions to this page.
15
16
/* Define $ssi_guest_access variable just before including SSI.php to handle guest access to your script.
17
	false: (default) fallback to forum setting
18
	true: allow guest access to the script regardless
19
*/
20
$ssi_guest_access = false;
21
22
// Include the SSI file.
23
require(dirname(__FILE__) . '/SSI.php');
24
25
// Viewing the homepage sample?
26
if (isset($_GET['view']) && $_GET['view'] == 'home1')
27
{
28
	template_homepage_sample1('output');
29
	exit;
30
}
31
32
// Load the main template.
33
template_ssi_above();
34
?>
35
			<h2>SMF SSI.php Functions</h2>
36
			<p><strong>Current Version:</strong> <?php echo SMF_VERSION; ?></p>
37
			<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>
38
39
			<h2>Include Code</h2>
40
			<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>
41
			<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>
42
43
			<h2>Some notes on usage</h2>
44
			<p>All the functions have an output method parameter.  This can either be &quot;echo&quot; (the default) or &quot;array&quot;</p>
45
			<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>
46
			<p onclick="if (getInnerHTML(this).indexOf('Bird') == -1) setInnerHTML(this, getInnerHTML(this) + '<br><img src=&quot;https://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>
47
48
			<h2>Additional Guides &amp; FAQ</h2>
49
			<p>Need more information on using SSI.php? Check out <a href="https://wiki.simplemachines.org/smf/Category:SSI">Using SSI.php article</a>.</p>
50
51
			<div id="sidenav" class="windowbg">
52
				<span class="topslice"><span></span></span>
53
				<div class="content">
54
					<h2 id="functionlist">Function List</h2>
55
					<h3>Recent Items</h3>
56
					<ul>
57
						<li><a href="#" onclick="showSSIBlock('ssi_recentTopics'); return false;">Recent Topics</a></li>
58
						<li><a href="#" onclick="showSSIBlock('ssi_recentPosts'); return false;">Recent Posts</a></li>
59
						<li><a href="#" onclick="showSSIBlock('ssi_recentPoll'); return false;">Recent Poll</a></li>
60
					</ul>
61
					<h3>Top Items</h3>
62
					<ul>
63
						<li><a href="#" onclick="showSSIBlock('ssi_topBoards'); return false;">Top Boards</a></li>
64
						<li><a href="#" onclick="showSSIBlock('ssi_topTopicsViews'); return false;">Top Topics</a></li>
65
						<li><a href="#" onclick="showSSIBlock('ssi_topPoll'); return false;">Top Poll</a></li>
66
						<li><a href="#" onclick="showSSIBlock('ssi_topPoster'); return false;">Top Poster</a></li>
67
					</ul>
68
					<h3>Members</h3>
69
					<ul>
70
						<li><a href="#" onclick="showSSIBlock('ssi_latestMember'); return false;">Latest Member Function</a></li>
71
						<li><a href="#" onclick="showSSIBlock('ssi_randomMember'); return false;">Member of the Day</a></li>
72
						<li><a href="#" onclick="showSSIBlock('ssi_whosOnline'); return false;">Who's Online</a></li>
73
					</ul>
74
					<h3>Authentication</h3>
75
					<ul>
76
						<li><a href="#" onclick="showSSIBlock('ssi_login'); return false;">Welcome, Login &amp; Logout</a></li>
77
					</ul>
78
					<h3>Calendar</h3>
79
					<ul>
80
						<li><a href="#" onclick="showSSIBlock('ssi_todaysCalendar'); return false;">Today's Events</a></li>
81
						<li><a href="#" onclick="showSSIBlock('ssi_recentEvents'); return false;">Recent Events</a></li>
82
					</ul>
83
					<h3>Miscellaneous</h3>
84
					<ul>
85
						<li><a href="#" onclick="showSSIBlock('ssi_boardStats'); return false;">Forum Stats</a></li>
86
						<li><a href="#" onclick="showSSIBlock('ssi_news'); return false;">News</a></li>
87
						<li><a href="#" onclick="showSSIBlock('ssi_boardNews'); return false;">Board News</a></li>
88
						<li><a href="#" onclick="showSSIBlock('ssi_menubar'); return false;">Menubar</a></li>
89
						<li><a href="#" onclick="showSSIBlock('ssi_quickSearch'); return false;">Quick Search Box</a></li>
90
						<li><a href="#" onclick="showSSIBlock('ssi_recentAttachments'); return false;">Recent Attachments</a></li>
91
					</ul>
92
					<?php if ($user_info['is_admin']) { ?>
93
					<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>
94
					<ul>
95
						<li><a href="#" onclick="showSSIBlock('ssi_showPoll'); return false;">Show Single Poll</a></li>
96
						<li><a href="#" onclick="showSSIBlock('ssi_fetchPosts'); return false;">Show Single Post</a></li>
97
						<li><a href="#" onclick="showSSIBlock('ssi_fetchMember'); return false;">Show Single Member</a></li>
98
						<li><a href="#" onclick="showSSIBlock('ssi_fetchGroupMembers'); return false;">Show Group Members</a></li>
99
					</ul>
100
					<?php } ?>
101
					<h3>Website Samples</h3>
102
					<ul>
103
						<li><a href="#" onclick="showSSIBlock('htmlhome')">Sample 1</a></li>
104
					</ul>
105
					<h2 id="other">Other</h2>
106
					<ul>
107
						<li><a href="#" onclick="toggleVisibleByClass('ssi_preview', false); return false;">Show all examples</a></li>
108
						<li><a href="#" onclick="toggleVisibleByClass('ssi_preview', true); return false;">Hide all examples</a></li>
109
					</ul>
110
				</div>
111
				<span class="botslice"><span></span></span>
112
			</div>
113
114
	<div id="preview" class="windowbg">
115
		<span class="topslice"><span></span></span>
116
		<div class="content">
117
118
<!-- RECENT ITEMS -->
119
			<div class="ssi_preview" id="ssi_recentTopics">
120
				<h2>Recent Topics Function</h2>
121
				<h3>Code (simple mode)</h3>
122
				<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>
123
				<h3>Code (advanced mode)</h3>
124
				<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>
125
				<h3>Result</h3>
126
				<div class="ssi_result"><?php ssi_recentTopics(); flush(); ?></div>
127
			</div>
128
129
			<div class="ssi_preview" id="ssi_recentPosts">
130
				<h2>Recent Posts Function</h2>
131
				<h3>Code</h3>
132
				<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>
133
				<h3>Result</h3>
134
				<div class="ssi_result"><?php ssi_recentPosts(); flush(); ?></div>
135
			</div>
136
137
			<div class="ssi_preview" id="ssi_recentPoll">
138
				<h2>Recent Poll Function</h2>
139
				<h3>Code</h3>
140
				<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>
141
				<h3>Result</h3>
142
				<div class="ssi_result"><?php ssi_recentPoll(); flush(); ?></div>
143
			</div>
144
145
<!-- TOP ITEMS -->
146
			<div class="ssi_preview" id="ssi_topBoards">
147
				<h2>Top Boards Function</h2>
148
				<p>Shows top boards by the number of posts.</p>
149
150
				<h3>Code</h3>
151
				<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>
152
				<h3>Result</h3>
153
				<div class="ssi_result"><?php ssi_topBoards(); flush(); ?></div>
154
			</div>
155
156
			<div class="ssi_preview" id="ssi_topTopicsViews">
157
				<h2>Top Topics</h2>
158
				<p>Shows top topics by the number of replies or views.</p>
159
160
				<h3>Code (show by number of views)</h3>
161
				<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>
162
				<h3>Result</h3>
163
				<div class="ssi_result"><?php ssi_topTopicsViews(); flush(); ?></div>
164
165
				<h3>Code (show by number of replies)</h3>
166
				<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>
167
				<h3>Result</h3>
168
				<div class="ssi_result"><?php ssi_topTopicsReplies(); flush(); ?></div>
169
			</div>
170
171
			<div class="ssi_preview" id="ssi_topPoll">
172
				<h2>Top Poll Function</h2>
173
				<p>Shows the most-voted-in poll.</p>
174
175
				<h3>Code</h3>
176
				<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>
177
				<h3>Result</h3>
178
				<div class="ssi_result"><?php ssi_topPoll(); flush(); ?></div>
179
			</div>
180
181
			<div class="ssi_preview" id="ssi_topPoster">
182
				<h2>Top Poster Function</h2>
183
				Shows the top poster's name and profile link.
184
185
				<h3>Code</h3>
186
				<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>
187
				<h3>Result</h3>
188
				<div class="ssi_result"><?php ssi_topPoster(); flush(); ?></div>
189
			</div>
190
191
<!-- MEMBERS -->
192
			<div class="ssi_preview" id="ssi_latestMember">
193
				<h2>Latest Member Function</h2>
194
				<p>Shows the latest member's name and profile link.</p>
195
196
				<h3>Code</h3>
197
				<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>
198
				<h3>Result</h3>
199
				<div class="ssi_result"><?php ssi_latestMember(); flush(); ?></div>
200
			</div>
201
202
			<div class="ssi_preview" id="ssi_randomMember">
203
				<h2>Member of the Day</h2>
204
				<p>Shows one random member of the day. This changes once a day.</p>
205
206
				<h3>Code</h3>
207
				<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>
208
				<h3>Result</h3>
209
				<div class="ssi_result"><?php ssi_randomMember('day'); flush(); ?></div>
210
			</div>
211
212
			<div class="ssi_preview" id="ssi_whosOnline">
213
				<h2>Who's Online Function</h2>
214
				<p>This function shows who are online inside the forum.</p>
215
216
				<h3>Code</h3>
217
				<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>
218
				<h3>Result</h3>
219
				<div class="ssi_result"><?php ssi_whosOnline(); flush(); ?></div>
220
221
				<h2>Log Online Presence</h2>
222
				<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>
223
224
				<h3>Code</h3>
225
				<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>
226
				<h3>Result</h3>
227
				<div class="ssi_result"><?php ssi_logOnline(); flush(); ?></div>
228
			</div>
229
230
<!-- WELCOME, LOGIN AND LOGOUT -->
231
			<div class="ssi_preview" id="ssi_login">
232
				<h2>Login Function</h2>
233
				<p>Shows a login box only when user is not logged in.</p>
234
235
				<h3>Code</h3>
236
				<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>
237
				<h3>Result</h3>
238
				<div class="ssi_result"><?php ssi_login(); flush(); ?></div>
239
240
				<h2>Logout Function</h2>
241
				<p>Shows a logout link only when user is logged in.</p>
242
243
				<h3>Code</h3>
244
				<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>
245
				<h3>Result</h3>
246
				<div class="ssi_result"><?php ssi_logout(); flush(); ?></div>
247
248
				<h2>Welcome Function</h2>
249
				<p>Greets users or guests, also shows user's messages if logged in.</p>
250
251
				<h3>Code</h3>
252
				<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>
253
				<h3>Result</h3>
254
				<div class="ssi_result"><?php ssi_welcome(); flush(); ?></div>
255
			</div>
256
257
<!-- CALENDAR -->
258
			<div class="ssi_preview" id="ssi_todaysCalendar">
259
				<h2>Today's Calendar Function</h2>
260
				<h3>Code</h3>
261
				<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>
262
				<h3>Result</h3>
263
				<div class="ssi_result"><?php ssi_todaysCalendar(); flush(); ?></div>
264
265
				<h2>Today's Birthdays Function</h2>
266
				<h3>Code</h3>
267
				<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>
268
				<h3>Result</h3>
269
				<div class="ssi_result"><?php ssi_todaysBirthdays(); flush(); ?></div>
270
271
				<h2>Today's Holidays Function</h2>
272
				<h3>Code</h3>
273
				<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>
274
				<h3>Result</h3>
275
				<div class="ssi_result"><?php ssi_todaysHolidays(); flush(); ?></div>
276
277
				<h2>Today's Events Function</h2>
278
				<h3>Code</h3>
279
				<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>
280
				<h3>Result</h3>
281
				<div class="ssi_result"><?php ssi_todaysEvents(); flush(); ?></div>
282
			</div>
283
284
			<div class="ssi_preview" id="ssi_recentEvents">
285
				<h2>Recent Calendar Events Function</h2>
286
287
				<h3>Code</h3>
288
				<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>
289
				<h3>Result</h3>
290
				<div class="ssi_result"><?php ssi_recentEvents(); flush(); ?></div>
291
			</div>
292
293
<!-- MISCELLANEOUS -->
294
			<div class="ssi_preview" id="ssi_boardStats">
295
				<h2>Forum Stats</h2>
296
				<p>Shows some basic forum stats: total members, posts, topics, boards, etc.</p>
297
298
				<h3>Code</h3>
299
				<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>
300
				<h3>Result</h3>
301
				<div class="ssi_result"><?php ssi_boardStats(); flush(); ?></div>
302
			</div>
303
304
			<div class="ssi_preview" id="ssi_news">
305
				<h2>News Function</h2>
306
				<p>Shows random forum news.</p>
307
308
				<h3>Code</h3>
309
				<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>
310
				<h3>Result</h3>
311
				<div class="ssi_result"><?php ssi_news(); flush(); ?></div>
312
			</div>
313
314
			<div class="ssi_preview" id="ssi_boardNews">
315
				<h2>Board News Function</h2>
316
				<p>Shows the latest posts from read only boards, or a specific board.</p>
317
318
				<h3>Code</h3>
319
				<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>
320
				<h3>Result</h3>
321
				<div class="ssi_result"><?php ssi_boardNews(); flush(); ?></div>
322
			</div>
323
324
			<div class="ssi_preview" id="ssi_menubar">
325
				<h2>Menubar Function</h2>
326
				<p>Displays a menu bar, like one displayed at the top of the forum.</p>
327
328
				<h3>Code</h3>
329
				<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>
330
				<h3>Result</h3>
331
				<div class="ssi_result"><?php ssi_menubar(); flush(); ?></div>
332
			</div>
333
334
			<div class="ssi_preview" id="ssi_quickSearch">
335
				<h2>Quick Search Function</h2>
336
337
				<h3>Code</h3>
338
				<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>
339
				<h3>Result</h3>
340
				<div class="ssi_result"><?php ssi_quickSearch(); flush(); ?></div>
341
			</div>
342
343
			<div class="ssi_preview" id="ssi_recentAttachments">
344
				<h2>Recent Attachments Function</h2>
345
346
				<h3>Code</h3>
347
				<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>
348
				<h3>Result</h3>
349
				<div class="ssi_result"><?php ssi_recentAttachments(); flush(); ?></div>
350
			</div>
351
352
<!-- ADVANCED FUNCTIONS -->
353
			<div class="ssi_preview" id="ssi_showPoll">
354
				<h2>Show Single Poll</h2>
355
				<p>Shows a poll in the specified topic.</p>
356
357
				<h3>Code</h3>
358
				<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>
359
				<h3>Result</h3>
360
				<div class="ssi_result"><i>Not shown because it needs specific topic ID that contains a poll.</i></div>
361
			</div>
362
363
			<div class="ssi_preview" id="ssi_fetchPosts">
364
				<h2>Show Single Post</h2>
365
				<p>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.</p>
366
367
				<h3>Code</h3>
368
				<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>
369
				<h3>Result</h3>
370
				<div class="ssi_result"><i>Not shown because it needs a specific post ID.</i></div>
371
			</div>
372
373
			<div class="ssi_preview" id="ssi_fetchMember">
374
				<h2>Show Single Member</h2>
375
				<p>Shows the specified member's name and profile link.</p>
376
377
				<h3>Code</h3>
378
				<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>
379
				<h3>Result</h3>
380
				<div class="ssi_result"><i>Not shown because it needs a specific member ID.</i></div>
381
			</div>
382
383
			<div class="ssi_preview" id="ssi_fetchGroupMembers">
384
				<h2>Show Group Members</h2>
385
				<p>Shows all members in a specified group.</p>
386
387
				<h3>Code</h3>
388
				<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>
389
				<h3>Result</h3>
390
				<div class="ssi_result"><i>Not shown because it needs specific membergroup IDs.</i></div>
391
			</div>
392
393
			<div class="ssi_preview" id="htmlhome">
394
				<h2>Home Page Sample</h2>
395
				This sample uses the following features: ssi_recentTopics(), ssi_logOnline(), ssi_welcome(), and ssi_boardNews().
396
				ssi_recentTopics() is fetched using the array method, to allow further customizations on the output.
397
398
				<h3>Code</h3>
399
				<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>
400
				<h3>Result</h3>
401
				<iframe src="?view=home1" style="width:99%; height:300px;"></iframe>
402
			</div>
403
		</div>
404
		<span class="botslice"><span></span></span>
405
	</div>
406
407
<?php
408
409
template_ssi_below();
410
411
function template_ssi_above()
412
{
413
	global $settings, $context, $scripturl;
414
415
	echo '<!DOCTYPE html>
416
<html>
417
	<head>
418
		<title>', SMF_FULL_VERSION, ' SSI.php Examples</title>
419
		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/index.css">
420
		<script src="', $settings['default_theme_url'], '/scripts/script.js"></script>
421
		<style>
422
			#wrapper {
423
				width: 90%;
424
			}
425
			#upper_section .user {
426
				height: 4em;
427
			}
428
			#upper_section .news {
429
				height: 80px;
430
			}
431
			#content_section {
432
				position: relative;
433
			}
434
			#main_content_section h2 {
435
				font-size: 1.5em;
436
				border-bottom: solid 1px #d05800;
437
				line-height: 1.5em;
438
				margin: 0.5em 0;
439
				color: #d05800;
440
			}
441
			#liftup {
442
				top: -70px;
443
				padding: 1em 2em 1em 1em;
444
				line-height: 1.6em;
445
			}
446
			#footer {
447
				position: relative;
448
			}
449
			#sidenav {
450
				width: 210px;
451
				float: left;
452
				margin-right: 20px;
453
			}
454
			#sidenav ul {
455
				margin: 0 0 0 15px;
456
				padding: 0;
457
				list-style: none;
458
				font-size: 90%;
459
			}
460
			#preview {
461
				margin-left: 230px;
462
			}
463
			.ssi_preview {
464
				margin-bottom: 1.5em;
465
			}
466
			.ssi_preview h3 {
467
				margin: 1em 0 0.5em 0;
468
			}
469
			.ssi_result {
470
				background-color: #fff;
471
				border: 1px solid #99a;
472
				padding: 10px;
473
				overflow: hidden;
474
			}
475
		</style>
476
		<script>
477
			var smf_scripturl = "', $scripturl, '";
478
			var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
479
			var smf_charset = "', $context['character_set'], '";
480
481
			// Sets all ssi_preview class to hidden, then shows the one requested.
482
			function showSSIBlock(elementID)
483
			{
484
				toggleVisibleByClass("ssi_preview", true);
485
				document.getElementById(elementID).style.display = "block";
486
			}
487
488
			// Toggle visibility of all sections.
489
			function toggleVisibleByClass(sClassName, bHide)
490
			{
491
				var oSections = document.getElementsByTagName("div");
492
				for (var i = 0; i < oSections.length; i++)
493
				{
494
					if (oSections[i].className === null || oSections[i].className.indexOf(sClassName) == -1)
495
						continue;
496
497
					oSections[i].style.display = bHide ? "none" : "block";
498
				}
499
			}
500
		</script>
501
	</head>
502
	<body>
503
		<div id="header">
504
			<h1 class="forumtitle">', SMF_FULL_VERSION, ' SSI.php Examples</h1>
505
			<img id="smflogo" src="Themes/default/images/smflogo.svg" alt="Simple Machines Forum" title="Simple Machines Forum">
506
		</div>
507
		<div id="wrapper">
508
			<div id="upper_section"><p><br></p></div>
509
			<div id="content_section">
510
				<div id="main_content_section">
511
					<div id="liftup" class="flow_auto">';
512
}
513
514
function template_ssi_below()
515
{
516
	echo '
517
						<script>
518
							showSSIBlock("ssi_recentTopics");
519
						</script>
520
					</div>
521
				</div>
522
			</div>
523
		</div>
524
			<div id="footer">
525
				<a href="#header" id="bot" class="go_up"></a>
526
				<ul>
527
					<li class="copyright">
528
						<span class="smalltext">', ssi_copyright(), '</span>
0 ignored issues
show
Bug introduced by
Are you sure the usage of ssi_copyright() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
529
					</li>
530
				</ul>
531
			</div>
532
	</body>
533
</html>';
534
}
535
536
function template_homepage_sample1($method = 'source')
537
{
538
	global $user_info, $boarddir;
539
540
	$header = '<!DOCTYPE html>
541
<html>
542
<head>
543
	<title>SSI.php example for home page</title>
544
	<style>
545
		body { font-family: Arial, Tahoma, sans-serif; font-size: 80%; background: #DFDFDF; color: #FFFFFF; margin: 0 }
546
		ul,ol { padding-left: 19px; margin: 0; }
547
		li { font-size: 11px; }
548
		h1,h2,h3 { margin: 0; padding: 0; }
549
		h3 { font-size: 15px; }
550
		a:link,a:visited { color: #FF9000; text-decoration: none; }
551
		a:hover { text-decoration: underline; }
552
		#container { background: #52514E; width: 100%; border: 1px solid midnightblue; line-height: 150%; margin: 0; }
553
		#header,#footer { color: lightgray; background-color: #2A2825; clear: both; padding: .5em; }
554
		#leftbar { background: #DF7E00; float: left; width: 160px; margin: 0; padding: 1em; }
555
		#leftbar a { color: #000000; text-decoration: underline; }
556
		#content { margin-left: 190px; padding: 1em; }
557
		#navigation { float: right; }
558
		#navigation a:link,#navigation a:visited { color: #FF9000; }
559
	</style>
560
</head>
561
<body>
562
<div id="container">
563
	<div id="header">
564
		<div id="navigation">
565
			<a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a>
566
		</div>
567
		<h1 class="header">YourWebsite.com</h1>
568
	</div>
569
	<div id="leftbar">
570
		<h3>Recent Forum Topics</h3>
571
		<ul>';
572
573
	$footer = '
574
	<div id="footer">
575
		<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>
576
		This sample website layout is dedicated to the <a target="_blank" rel="noopener" rel="license" href="https://creativecommons.org/licenses/publicdomain/">Public Domain</a>.
577
	</div>
578
</div>
579
</body>
580
</html>';
581
582
	if ($method == 'source')
583
	{
584
		$header = '<?php require("' . ($user_info['is_admin'] ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header;
585
		return $header . template_homepage_sample1_html() . $footer;
586
	}
587
	else
588
	{
589
		echo $header;
590
		template_homepage_sample1_php();
591
		echo $footer;
592
	}
593
594
}
595
596
function template_homepage_sample1_php()
597
{
598
	global $txt;
599
600
	$topics = ssi_recentTopics(8, null, null, 'array');
601
602
	foreach ($topics as $topic)
603
		echo '
604
			<li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>';
605
606
	unset($topics);
607
608
	echo '
609
610
		</ul><br>
611
612
		<h3>Online Users</h3>';
613
		ssi_logOnline();
614
615
	echo '
616
	</div>
617
618
	<div id="content">';
619
620
		ssi_welcome();
621
	echo '
622
		<br><br>
623
624
		<h2>News</h2>';
625
626
		ssi_boardNews();
627
628
	echo '
629
	</div>';
630
631
}
632
633
function template_homepage_sample1_html()
634
{
635
	$result = '
636
<?php
637
// Using array method to show shorter display style.
638
$topics = ssi_recentTopics(8, null, null, \'array\');
639
640
foreach ($topics as $topic)
641
{
642
	// Uncomment the following code to get a listing of array elements that SMF provides for this function.
643
	// echo \'<pre>\', print_r($topic), \'</pre>\';
644
645
	echo \'
646
			<li><a href=\"\', $topic[\'href\'], \'\">\', $topic[\'subject\'], \'</a> \', $txt[\'by\'], \' \', $topics[$i][\'poster\'][\'link\'], \'</li>\';
647
}
648
649
unset($topics);
650
?>
651
		</ul><br>
652
		<h3>Online Users</h3>
653
		<?php ssi_logOnline(); ?>
654
	</div>
655
	<div id="content">
656
		<?php ssi_welcome(); ?><br><br>
657
		<h2>News</h2>
658
		<?php ssi_boardNews(); ?>
659
	</div>';
660
661
	return $result;
662
}
663
664
?>