1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @package ElkArte Forum |
||
5 | * @copyright ElkArte Forum contributors |
||
6 | * @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
||
7 | * |
||
8 | * This file contains code covered by: |
||
9 | * copyright: 2011 Simple Machines (http://www.simplemachines.org) |
||
10 | * |
||
11 | * @version 2.0 dev |
||
12 | */ |
||
13 | |||
14 | use ElkArte\User; |
||
15 | |||
16 | // Special thanks to Spaceman-Spiff for his contributions to this page. |
||
17 | |||
18 | /** |
||
19 | * Define $ssi_guest_access variable just before including SSI.php to handle guest access to your script. |
||
20 | * false: (default) fallback to forum setting |
||
21 | * true: allow guest access to the script regardless |
||
22 | */ |
||
23 | $ssi_guest_access = false; |
||
24 | |||
25 | global $settings, $user_info, $context, $modsettings; |
||
26 | |||
27 | // Include the SSI file. |
||
28 | require(__DIR__ . '/SSI.php'); |
||
29 | |||
30 | // Viewing the homepage sample? |
||
31 | if (isset($_GET['view']) && $_GET['view'] === 'home1') |
||
32 | { |
||
33 | template_homepage_sample1('output'); |
||
34 | exit; |
||
35 | } |
||
36 | |||
37 | // Load the main template. |
||
38 | template_ssi_above(); |
||
39 | ?> |
||
40 | |||
41 | <h2>SSI.php Functions</h2> |
||
42 | <p><strong>Current Version:</strong> 2.0 dev</p> |
||
43 | <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> |
||
44 | |||
45 | <h2>Include Code</h2> |
||
46 | <p>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:</p> |
||
47 | <div class="codeheader"> |
||
48 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
49 | </div> |
||
50 | <pre class="bbc_code"><?php require("<?php echo addslashes(User::$info->is_admin ? realpath(BOARDDIR . '/SSI.php') : 'SSI.php'); ?>");</pre> |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
51 | |||
52 | <h2>Some notes on usage</h2> |
||
53 | <p>All the functions have an output method parameter. This can either be "echo" (the default) or "array"</p> |
||
54 | <p>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.</p> |
||
55 | <p>This functionality can be used to allow you to present the information in any way you wish.</p> |
||
56 | |||
57 | <h2>Additional Guides & FAQ</h2> |
||
58 | <p>Need more information on using SSI.php? Check out <a href="https://github.com/elkarte/Elkarte/wiki/SSI">Using SSI.php article</a> or <a href="https://www.elkarte.net/index.php">ask on the forum</a>.</p> |
||
59 | |||
60 | <div id="sidenav" class="content"> |
||
61 | <h2 id="functionlist">Function List</h2> |
||
62 | <h3>Recent Items</h3> |
||
63 | <ul> |
||
64 | <li> |
||
65 | <a href="#" onclick="showSSIBlock('ssi_recentTopics');return false;">Recent Topics</a> |
||
66 | </li> |
||
67 | <li> |
||
68 | <a href="#" onclick="showSSIBlock('ssi_recentPosts');return false;">Recent Posts</a> |
||
69 | </li> |
||
70 | <li> |
||
71 | <a href="#" onclick="showSSIBlock('ssi_recentPoll');return false;">Recent Poll</a> |
||
72 | </li> |
||
73 | </ul> |
||
74 | <h3>Top Items</h3> |
||
75 | <ul> |
||
76 | <li> |
||
77 | <a href="#" onclick="showSSIBlock('ssi_topBoards');return false;">Top Boards</a> |
||
78 | </li> |
||
79 | <li> |
||
80 | <a href="#" onclick="showSSIBlock('ssi_topTopicsViews');return false;">Top Topics</a> |
||
81 | </li> |
||
82 | <li> |
||
83 | <a href="#" onclick="showSSIBlock('ssi_topPoll');return false;">Top Poll</a> |
||
84 | </li> |
||
85 | <li> |
||
86 | <a href="#" onclick="showSSIBlock('ssi_topPoster');return false;">Top Poster</a> |
||
87 | </li> |
||
88 | </ul> |
||
89 | <h3>Members</h3> |
||
90 | <ul> |
||
91 | <li> |
||
92 | <a href="#" onclick="showSSIBlock('ssi_latestMember');return false;">Latest Member Function</a> |
||
93 | </li> |
||
94 | <li> |
||
95 | <a href="#" onclick="showSSIBlock('ssi_randomMember');return false;">Member of the Day</a> |
||
96 | </li> |
||
97 | <li> |
||
98 | <a href="#" onclick="showSSIBlock('ssi_whosOnline');return false;">Who's Online</a> |
||
99 | </li> |
||
100 | </ul> |
||
101 | <h3>Authentication</h3> |
||
102 | <ul> |
||
103 | <li> |
||
104 | <a href="#" onclick="showSSIBlock('ssi_login');return false;">Welcome, Login & Logout</a> |
||
105 | </li> |
||
106 | </ul> |
||
107 | <h3>Calendar</h3> |
||
108 | <ul> |
||
109 | <li> |
||
110 | <a href="#" onclick="showSSIBlock('ssi_todaysCalendar');return false;">Today's Events</a> |
||
111 | </li> |
||
112 | <li> |
||
113 | <a href="#" onclick="showSSIBlock('ssi_recentEvents');return false;">Recent Events</a> |
||
114 | </li> |
||
115 | </ul> |
||
116 | <h3>Miscellaneous</h3> |
||
117 | <ul> |
||
118 | <li> |
||
119 | <a href="#" onclick="showSSIBlock('ssi_boardStats');return false;">Forum Stats</a> |
||
120 | </li> |
||
121 | <li> |
||
122 | <a href="#" onclick="showSSIBlock('ssi_news');return false;">News</a> |
||
123 | </li> |
||
124 | <li> |
||
125 | <a href="#" onclick="showSSIBlock('ssi_boardNews');return false;">Board News</a> |
||
126 | </li> |
||
127 | <li> |
||
128 | <a href="#" onclick="showSSIBlock('ssi_menubar');return false;">Menubar</a> |
||
129 | </li> |
||
130 | <li> |
||
131 | <a href="#" onclick="showSSIBlock('ssi_quickSearch');return false;">Quick Search Box</a> |
||
132 | </li> |
||
133 | <li> |
||
134 | <a href="#" onclick="showSSIBlock('ssi_recentAttachments');return false;">Recent Attachments</a> |
||
135 | </li> |
||
136 | </ul> |
||
137 | <?php if (User::$info->is_admin) |
||
138 | { |
||
139 | ?> |
||
140 | <h3>Advanced Functions <i class="helpicon i-help" title="Functions that require additional tweaking, not just copy and paste."></i></h3> |
||
141 | <ul> |
||
142 | <li> |
||
143 | <a href="#" onclick="showSSIBlock('ssi_showPoll');return false;">Show Single Poll</a> |
||
144 | </li> |
||
145 | <li> |
||
146 | <a href="#" onclick="showSSIBlock('ssi_fetchPosts');return false;">Show Single Post</a> |
||
147 | </li> |
||
148 | <li> |
||
149 | <a href="#" onclick="showSSIBlock('ssi_fetchMember');return false;">Show Single Member</a> |
||
150 | </li> |
||
151 | <li> |
||
152 | <a href="#" onclick="showSSIBlock('ssi_fetchGroupMembers');return false;">Show Group Members</a> |
||
153 | </li> |
||
154 | </ul> |
||
155 | <?php } ?> |
||
156 | <h3>Website Samples</h3> |
||
157 | <ul> |
||
158 | <li> |
||
159 | <a href="#" onclick="showSSIBlock('htmlhome');">Sample 1</a> |
||
160 | </li> |
||
161 | </ul> |
||
162 | <h2 id="other">Other</h2> |
||
163 | <ul> |
||
164 | <li> |
||
165 | <a href="#" onclick="toggleVisibleByClass('ssi_preview', false);return false;">Show all examples</a> |
||
166 | </li> |
||
167 | <li> |
||
168 | <a href="#" onclick="toggleVisibleByClass('ssi_preview', true);return false;">Hide all examples</a> |
||
169 | </li> |
||
170 | </ul> |
||
171 | </div> |
||
172 | |||
173 | <div id="preview" class="content"> |
||
174 | <!-- RECENT ITEMS --> |
||
175 | <div class="ssi_preview" id="ssi_recentTopics"> |
||
176 | <h2>Recent Topics Function</h2> |
||
177 | <h3>Code (simple mode)</h3> |
||
178 | <div class="codeheader"> |
||
179 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
180 | </div> |
||
181 | <pre class="bbc_code"><?php ssi_recentTopics();</pre> |
||
182 | <h3>Code (advanced mode)</h3> |
||
183 | <div class="codeheader"> |
||
184 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
185 | </div> |
||
186 | <pre class="bbc_code"><?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo');</pre> |
||
187 | <h3>Result</h3> |
||
188 | <div class="ssi_result"><?php |
||
189 | ssi_recentTopics(); |
||
190 | flush(); |
||
191 | ?> |
||
192 | </div> |
||
193 | </div> |
||
194 | |||
195 | <div class="ssi_preview" id="ssi_recentPosts"> |
||
196 | <h2>Recent Posts Function</h2> |
||
197 | <h3>Code</h3> |
||
198 | <div class="codeheader"> |
||
199 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
200 | </div> |
||
201 | <pre class="bbc_code"><?php ssi_recentPosts();</pre> |
||
202 | <h3>Result</h3> |
||
203 | <div class="ssi_result"><?php |
||
204 | ssi_recentPosts(); |
||
205 | flush(); |
||
206 | ?> |
||
207 | </div> |
||
208 | </div> |
||
209 | |||
210 | <div class="ssi_preview" id="ssi_recentPoll"> |
||
211 | <h2>Recent Poll Function</h2> |
||
212 | <h3>Code</h3> |
||
213 | <div class="codeheader"> |
||
214 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
215 | </div> |
||
216 | <pre class="bbc_code"><?php ssi_recentPoll();</pre> |
||
217 | <h3>Result</h3> |
||
218 | <div class="ssi_result"><?php |
||
219 | ssi_recentPoll(); |
||
220 | flush(); |
||
221 | ?> |
||
222 | </div> |
||
223 | </div> |
||
224 | |||
225 | <!-- TOP ITEMS --> |
||
226 | <div class="ssi_preview" id="ssi_topBoards"> |
||
227 | <h2>Top Boards Function</h2> |
||
228 | <p>Shows top boards by the number of posts.</p> |
||
229 | <h3>Code</h3> |
||
230 | <div class="codeheader"> |
||
231 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
232 | </div> |
||
233 | <pre class="bbc_code"><?php ssi_topBoards();</pre> |
||
234 | <h3>Result</h3> |
||
235 | <div class="ssi_result"><?php |
||
236 | ssi_topBoards(); |
||
237 | flush(); |
||
238 | ?> |
||
239 | </div> |
||
240 | </div> |
||
241 | |||
242 | <div class="ssi_preview" id="ssi_topTopicsViews"> |
||
243 | <h2>Top Topics</h2> |
||
244 | <p>Shows top topics by the number of replies or views.</p> |
||
245 | |||
246 | <h3>Code (show by number of views)</h3> |
||
247 | <div class="codeheader"> |
||
248 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
249 | </div> |
||
250 | <pre class="bbc_code"><?php ssi_topTopicsViews();</pre> |
||
251 | <h3>Result</h3> |
||
252 | <div class="ssi_result"><?php |
||
253 | ssi_topTopicsViews(); |
||
254 | flush(); |
||
255 | ?> |
||
256 | </div> |
||
257 | |||
258 | <h3>Code (show by number of replies)</h3> |
||
259 | <div class="codeheader"> |
||
260 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
261 | </div> |
||
262 | <pre class="bbc_code"><?php ssi_topTopicsReplies();</pre> |
||
263 | <h3>Result</h3> |
||
264 | <div class="ssi_result"><?php |
||
265 | ssi_topTopicsReplies(); |
||
266 | flush(); |
||
267 | ?> |
||
268 | </div> |
||
269 | </div> |
||
270 | |||
271 | <div class="ssi_preview" id="ssi_topPoll"> |
||
272 | <h2>Top Poll Function</h2> |
||
273 | <p>Shows the most-voted-in poll.</p> |
||
274 | <h3>Code</h3> |
||
275 | <div class="codeheader"> |
||
276 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
277 | </div> |
||
278 | <pre class="bbc_code"><?php ssi_topPoll();</pre> |
||
279 | <h3>Result</h3> |
||
280 | <div class="ssi_result"><?php |
||
281 | ssi_topPoll(); |
||
282 | flush(); |
||
283 | ?> |
||
284 | </div> |
||
285 | </div> |
||
286 | |||
287 | <div class="ssi_preview" id="ssi_topPoster"> |
||
288 | <h2>Top Poster Function</h2> |
||
289 | Shows the top poster's name and profile link. |
||
290 | <h3>Code</h3> |
||
291 | <div class="codeheader"> |
||
292 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
293 | </div> |
||
294 | <pre class="bbc_code"><?php ssi_topPoster();</pre> |
||
295 | <h3>Result</h3> |
||
296 | <div class="ssi_result"><?php |
||
297 | ssi_topPoster(); |
||
298 | flush(); |
||
299 | ?> |
||
300 | </div> |
||
301 | </div> |
||
302 | |||
303 | <!-- MEMBERS --> |
||
304 | <div class="ssi_preview" id="ssi_latestMember"> |
||
305 | <h2>Latest Member Function</h2> |
||
306 | <p>Shows the latest member's name and profile link.</p> |
||
307 | <h3>Code</h3> |
||
308 | <div class="codeheader"> |
||
309 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
310 | </div> |
||
311 | <pre class="bbc_code"><?php ssi_latestMember();</pre> |
||
312 | <h3>Result</h3> |
||
313 | <div class="ssi_result"><?php |
||
314 | ssi_latestMember(); |
||
315 | flush(); |
||
316 | ?> |
||
317 | </div> |
||
318 | </div> |
||
319 | |||
320 | <div class="ssi_preview" id="ssi_randomMember"> |
||
321 | <h2>Member of the Day</h2> |
||
322 | <p>Shows one random member of the day. This changes once a day.</p> |
||
323 | <h3>Code</h3> |
||
324 | <div class="codeheader"> |
||
325 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
326 | </div> |
||
327 | <pre class="bbc_code"><?php ssi_randomMember('day');</pre> |
||
328 | <h3>Result</h3> |
||
329 | <div class="ssi_result"><?php |
||
330 | ssi_randomMember('day'); |
||
331 | flush(); |
||
332 | ?> |
||
333 | </div> |
||
334 | </div> |
||
335 | |||
336 | <div class="ssi_preview" id="ssi_whosOnline"> |
||
337 | <h2>Who's Online Function</h2> |
||
338 | <p>This function shows who are online inside the forum.</p> |
||
339 | <h3>Code</h3> |
||
340 | <div class="codeheader"> |
||
341 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
342 | </div> |
||
343 | <pre class="bbc_code"><?php ssi_whosOnline();</pre> |
||
344 | <h3>Result</h3> |
||
345 | <div class="ssi_result"><?php |
||
346 | ssi_whosOnline(); |
||
347 | flush(); |
||
348 | ?> |
||
349 | </div> |
||
350 | |||
351 | <h2>Log Online Presence</h2> |
||
352 | <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> |
||
353 | <h3>Code</h3> |
||
354 | <div class="codeheader"> |
||
355 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
356 | </div> |
||
357 | <pre class="bbc_code"><?php ssi_logOnline();</pre> |
||
358 | <h3>Result</h3> |
||
359 | <div class="ssi_result"><?php |
||
360 | ssi_logOnline(); |
||
361 | flush(); |
||
362 | ?> |
||
363 | </div> |
||
364 | </div> |
||
365 | |||
366 | <!-- WELCOME, LOGIN AND LOGOUT --> |
||
367 | <div class="ssi_preview" id="ssi_login"> |
||
368 | <h2>Login Function</h2> |
||
369 | <p>Shows a login box <strong>only</strong> when user is not logged in.</p> |
||
370 | <h3>Code</h3> |
||
371 | <div class="codeheader"> |
||
372 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
373 | </div> |
||
374 | <pre class="bbc_code"><?php ssi_login();</pre> |
||
375 | <h3>Result</h3> |
||
376 | <div class="ssi_result"><?php |
||
377 | ssi_login(); |
||
378 | flush(); |
||
379 | ?> |
||
380 | </div> |
||
381 | |||
382 | <h2>Logout Function</h2> |
||
383 | <p>Shows a logout link <strong>only</strong> when user is logged in.</p> |
||
384 | <h3>Code</h3> |
||
385 | <div class="codeheader"> |
||
386 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
387 | </div> |
||
388 | <pre class="bbc_code"><?php ssi_logout();</pre> |
||
389 | <h3>Result</h3> |
||
390 | <div class="ssi_result"><?php |
||
391 | ssi_logout(); |
||
392 | flush(); |
||
393 | ?> |
||
394 | </div> |
||
395 | |||
396 | <h2>Welcome Function</h2> |
||
397 | <p>Greets users or guests, also shows user's messages if logged in.</p> |
||
398 | <h3>Code</h3> |
||
399 | <div class="codeheader"> |
||
400 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
401 | </div> |
||
402 | <pre class="bbc_code"><?php ssi_welcome();</pre> |
||
403 | <h3>Result</h3> |
||
404 | <div class="ssi_result"><?php |
||
405 | ssi_welcome(); |
||
406 | flush(); |
||
407 | ?> |
||
408 | </div> |
||
409 | </div> |
||
410 | |||
411 | <!-- CALENDAR --> |
||
412 | <div class="ssi_preview" id="ssi_todaysCalendar"> |
||
413 | <h2>Today's Calendar Function</h2> |
||
414 | <h3>Code</h3> |
||
415 | <div class="codeheader"> |
||
416 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
417 | </div> |
||
418 | <pre class="bbc_code"><?php ssi_todaysCalendar();</pre> |
||
419 | <h3>Result</h3> |
||
420 | <div class="ssi_result"><?php |
||
421 | ssi_todaysCalendar(); |
||
422 | flush(); |
||
423 | ?> |
||
424 | </div> |
||
425 | |||
426 | <h2>Today's Birthdays Function</h2> |
||
427 | <h3>Code</h3> |
||
428 | <div class="codeheader"> |
||
429 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
430 | </div> |
||
431 | <pre class="bbc_code"><?php ssi_todaysBirthdays();</pre> |
||
432 | <h3>Result</h3> |
||
433 | <div class="ssi_result"><?php |
||
434 | ssi_todaysBirthdays(); |
||
435 | flush(); |
||
436 | ?> |
||
437 | </div> |
||
438 | |||
439 | <h2>Today's Holidays Function</h2> |
||
440 | <h3>Code</h3> |
||
441 | <div class="codeheader"> |
||
442 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
443 | </div> |
||
444 | <pre class="bbc_code"><?php ssi_todaysHolidays();</pre> |
||
445 | <h3>Result</h3> |
||
446 | <div class="ssi_result"><?php |
||
447 | ssi_todaysHolidays(); |
||
448 | flush(); |
||
449 | ?> |
||
450 | </div> |
||
451 | |||
452 | <h2>Today's Events Function</h2> |
||
453 | <h3>Code</h3> |
||
454 | <div class="codeheader"> |
||
455 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
456 | </div> |
||
457 | <pre class="bbc_code"><?php ssi_todaysEvents();</pre> |
||
458 | <h3>Result</h3> |
||
459 | <div class="ssi_result"><?php |
||
460 | ssi_todaysEvents(); |
||
461 | flush(); |
||
462 | ?> |
||
463 | </div> |
||
464 | </div> |
||
465 | |||
466 | <div class="ssi_preview" id="ssi_recentEvents"> |
||
467 | <h2>Recent Calendar Events Function</h2> |
||
468 | <h3>Code</h3> |
||
469 | <div class="codeheader"> |
||
470 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
471 | </div> |
||
472 | <pre class="bbc_code"><?php ssi_recentEvents();</pre> |
||
473 | <h3>Result</h3> |
||
474 | <div class="ssi_result"><?php |
||
475 | ssi_recentEvents(); |
||
476 | flush(); |
||
477 | ?> |
||
478 | </div> |
||
479 | </div> |
||
480 | |||
481 | <!-- MISCELLANEOUS --> |
||
482 | <div class="ssi_preview" id="ssi_boardStats"> |
||
483 | <h2>Forum Stats</h2> |
||
484 | <p>Shows some basic forum stats: total members, posts, topics, boards, etc.</p> |
||
485 | <h3>Code</h3> |
||
486 | <div class="codeheader"> |
||
487 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
488 | </div> |
||
489 | <pre class="bbc_code"><?php ssi_boardStats();</pre> |
||
490 | <h3>Result</h3> |
||
491 | <div class="ssi_result"><?php |
||
492 | ssi_boardStats(); |
||
493 | flush(); |
||
494 | ?> |
||
495 | </div> |
||
496 | </div> |
||
497 | |||
498 | <div class="ssi_preview" id="ssi_news"> |
||
499 | <h2>News Function</h2> |
||
500 | <p>Shows random forum news.</p> |
||
501 | <h3>Code</h3> |
||
502 | <div class="codeheader"> |
||
503 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
504 | </div> |
||
505 | <pre class="bbc_code"><?php ssi_news();</pre> |
||
506 | <h3>Result</h3> |
||
507 | <div class="ssi_result"><?php |
||
508 | ssi_news(); |
||
509 | flush(); |
||
510 | ?> |
||
511 | </div> |
||
512 | </div> |
||
513 | |||
514 | <div class="ssi_preview" id="ssi_boardNews"> |
||
515 | <h2>Board News Function</h2> |
||
516 | <p>Shows the latest posts from read only boards, or a specific board.</p> |
||
517 | <h3>Code</h3> |
||
518 | <div class="codeheader"> |
||
519 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
520 | </div> |
||
521 | <pre class="bbc_code"><?php ssi_boardNews();</pre> |
||
522 | <h3>Result</h3> |
||
523 | <div class="ssi_result"><?php |
||
524 | ssi_boardNews(); |
||
525 | flush(); |
||
526 | ?> |
||
527 | </div> |
||
528 | </div> |
||
529 | |||
530 | <div class="ssi_preview" id="ssi_menubar"> |
||
531 | <h2>Menubar Function</h2> |
||
532 | <p>Displays a menu bar, like one displayed at the top of the forum.</p> |
||
533 | <h3>Code</h3> |
||
534 | <div class="codeheader"> |
||
535 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
536 | </div> |
||
537 | <pre class="bbc_code"><?php ssi_menubar();</pre> |
||
538 | <h3>Result</h3> |
||
539 | <div class="ssi_result"><?php |
||
540 | ssi_menubar(); |
||
541 | flush(); |
||
542 | ?> |
||
543 | </div> |
||
544 | </div> |
||
545 | |||
546 | <div class="ssi_preview" id="ssi_quickSearch"> |
||
547 | <h2>Quick Search Function</h2> |
||
548 | <h3>Code</h3> |
||
549 | <div class="codeheader"> |
||
550 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
551 | </div> |
||
552 | <pre class="bbc_code"><?php ssi_quickSearch();</pre> |
||
553 | <h3>Result</h3> |
||
554 | <div class="ssi_result"><?php |
||
555 | ssi_quickSearch(); |
||
556 | flush(); |
||
557 | ?> |
||
558 | </div> |
||
559 | </div> |
||
560 | |||
561 | <div class="ssi_preview" id="ssi_recentAttachments"> |
||
562 | <h2>Recent Attachments Function</h2> |
||
563 | <h3>Code</h3> |
||
564 | <div class="codeheader"> |
||
565 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
566 | </div> |
||
567 | <pre class="bbc_code"><?php ssi_recentAttachments();</pre> |
||
568 | <h3>Result</h3> |
||
569 | <div class="ssi_result"><?php |
||
570 | ssi_recentAttachments(); |
||
571 | flush(); |
||
572 | ?> |
||
573 | </div> |
||
574 | </div> |
||
575 | |||
576 | <!-- ADVANCED FUNCTIONS --> |
||
577 | <div class="ssi_preview" id="ssi_showPoll"> |
||
578 | <h2>Show Single Poll</h2> |
||
579 | <p>Shows a poll in the specified topic.</p> |
||
580 | <h3>Code</h3> |
||
581 | <div class="codeheader"> |
||
582 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
583 | </div> |
||
584 | <pre class="bbc_code"><?php ssi_showPoll($topicID);</pre> |
||
585 | <h3>Result</h3> |
||
586 | <div class="ssi_result"> |
||
587 | <i>Not shown because it needs specific topic ID that contains a poll.</i> |
||
588 | </div> |
||
589 | </div> |
||
590 | |||
591 | <div class="ssi_preview" id="ssi_fetchPosts"> |
||
592 | <h2>Show Single Post</h2> |
||
593 | <p>Fetches a post with a particular IDs. By default will only show if you have permission to the see |
||
594 | the board in question. This can be overriden by passing the 2nd parameter as <span class="tt">true</span>.</p> |
||
595 | <h3>Code</h3> |
||
596 | <div class="codeheader"> |
||
597 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
598 | </div> |
||
599 | <pre class="bbc_code"><?php ssi_fetchPosts($postIDs, $isOverride);</pre> |
||
600 | <h3>Result</h3> |
||
601 | <div class="ssi_result"> |
||
602 | <i>Not shown because it needs a specific post ID.</i> |
||
603 | </div> |
||
604 | </div> |
||
605 | |||
606 | <div class="ssi_preview" id="ssi_fetchMember"> |
||
607 | <h2>Show Single Member</h2> |
||
608 | <p>Shows the specified member's name and profile link.</p> |
||
609 | <h3>Code</h3> |
||
610 | <div class="codeheader"> |
||
611 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
612 | </div> |
||
613 | <pre class="bbc_code"><?php ssi_fetchMember($memberIDs);</pre> |
||
614 | <h3>Result</h3> |
||
615 | <div class="ssi_result"> |
||
616 | <i>Not shown because it needs a specific member ID.</i> |
||
617 | </div> |
||
618 | </div> |
||
619 | |||
620 | <div class="ssi_preview" id="ssi_fetchGroupMembers"> |
||
621 | <h2>Show Group Members</h2> |
||
622 | <p>Shows all members in a specified group.</p> |
||
623 | <h3>Code</h3> |
||
624 | <div class="codeheader"> |
||
625 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
626 | </div> |
||
627 | <pre class="bbc_code"><?php ssi_fetchGroupMembers($groupIDs);</pre> |
||
628 | <h3>Result</h3> |
||
629 | <div class="ssi_result"> |
||
630 | <i>Not shown because it needs specific membergroup IDs.</i> |
||
631 | </div> |
||
632 | </div> |
||
633 | |||
634 | <div class="ssi_preview" id="htmlhome"> |
||
635 | <h2>Home Page Sample</h2> |
||
636 | This sample uses the following features: ssi_recentTopics(), ssi_logOnline(), ssi_welcome(), and ssi_boardNews(). |
||
637 | ssi_recentTopics() is fetched using the array method, to allow further customizations on the output. |
||
638 | <h3>Code</h3> |
||
639 | <div class="codeheader"> |
||
640 | <a href="javascript:void(0);" onclick="return elkSelectText(this);" class="codeoperation">[Select]</a> |
||
641 | </div> |
||
642 | <pre class="bbc_code"><?php |
||
643 | echo \ElkArte\Helper\Util::htmlspecialchars(template_homepage_sample1('source'), ENT_COMPAT, 'UTF-8'); ?> |
||
644 | </pre> |
||
645 | <h3>Result</h3> |
||
646 | <iframe src="?view=home1" style="width: 100%; height: 450px;"></iframe> |
||
647 | </div> |
||
648 | </div> |
||
649 | |||
650 | <?php |
||
651 | template_ssi_below(); |
||
652 | |||
653 | function template_ssi_above() |
||
654 | { |
||
655 | global $settings, $context, $scripturl; |
||
656 | |||
657 | echo '<!DOCTYPE html> |
||
658 | <html> |
||
659 | <head> |
||
660 | <title>ElkArte SSI Examples</title> |
||
661 | <link rel="stylesheet" href="', $settings['default_theme_url'], '/css/index.css', CACHE_STALE, '" /> |
||
662 | <link rel="stylesheet" href="', $settings['default_theme_url'], '/css/icons_svg.css', CACHE_STALE, '" /> |
||
663 | <link rel="stylesheet" href="', $settings['default_theme_url'], '/css/_light/index_light.css', CACHE_STALE, '" /> |
||
664 | <script src="', $settings['default_theme_url'], '/scripts/script.js"></script> |
||
665 | <style> |
||
666 | #wrapper { |
||
667 | padding: 2px 2px 12px; |
||
668 | } |
||
669 | #content_section { |
||
670 | position: relative; |
||
671 | top: -20px; |
||
672 | } |
||
673 | #main_content_section h2 { |
||
674 | font-size: 1.5em; |
||
675 | border-bottom: solid 1px #D05800; |
||
676 | line-height: 1.5em; |
||
677 | margin: 0.5em 0; |
||
678 | color: #D05800; |
||
679 | } |
||
680 | #liftup { |
||
681 | position: relative; |
||
682 | top: -30px; |
||
683 | padding: 1em 2em 1em 1em; |
||
684 | line-height: 1.6em; |
||
685 | } |
||
686 | #footer_section { |
||
687 | position: relative; |
||
688 | top: 0; |
||
689 | min-height: 40px; |
||
690 | } |
||
691 | #sidenav { |
||
692 | width: 210px; |
||
693 | float: left; |
||
694 | margin-right: 20px; |
||
695 | } |
||
696 | #sidenav ul { |
||
697 | margin: 0 0 0 1em; |
||
698 | padding: 0; |
||
699 | list-style: none; |
||
700 | font-size: 95%; |
||
701 | } |
||
702 | #preview { |
||
703 | margin-left: 230px; |
||
704 | } |
||
705 | .ssi_preview { |
||
706 | margin-bottom: 1.5em; |
||
707 | } |
||
708 | .ssi_preview h3 { |
||
709 | margin: 1em 0 0.5em 0; |
||
710 | } |
||
711 | .ssi_result { |
||
712 | background: #FFFFFF; |
||
713 | border: 1px solid #9999AA; |
||
714 | padding: .8em; |
||
715 | overflow: hidden; |
||
716 | } |
||
717 | .bbc_code { |
||
718 | height: auto; |
||
719 | } |
||
720 | .ssi_table { |
||
721 | margin: 0; |
||
722 | width: 100%; |
||
723 | border-spacing: 0; |
||
724 | border-collapse: collapse; |
||
725 | border: none; |
||
726 | } |
||
727 | .ssi_table th { |
||
728 | padding: 5px 8px 5px 0; |
||
729 | border-top: 2px solid #DDDDDD; |
||
730 | border-bottom: 2px solid #DDDDDD; |
||
731 | background: #FFFFFF; |
||
732 | color: #555555; |
||
733 | font-size: 1em; |
||
734 | font-weight: 600; |
||
735 | } |
||
736 | .ssi_table td, .ssi_table th { |
||
737 | text-align: left; |
||
738 | white-space: nowrap; |
||
739 | } |
||
740 | .ssi_table td.top { |
||
741 | vertical-align: top; |
||
742 | } |
||
743 | .ssi_table th.righttext, .ssi_table td.righttext { |
||
744 | text-align: right; |
||
745 | } |
||
746 | .ssi_table th.centertext, .ssi_table td.centertext { |
||
747 | text-align: center; |
||
748 | } |
||
749 | .top_topic .link { |
||
750 | text-align: left; |
||
751 | } |
||
752 | .top_topic .views, .top_topic .num_replies { |
||
753 | text-align: right; |
||
754 | } |
||
755 | .codeheader:before { |
||
756 | content: "Code:\20"; |
||
757 | } |
||
758 | h3 { |
||
759 | font-weight: 600; |
||
760 | } |
||
761 | </style> |
||
762 | <script> |
||
763 | var elk_scripturl = "', $scripturl, '", |
||
764 | elk_charset = "UTF-8", |
||
765 | elk_theme_url = "', $settings['theme_url'], '", |
||
766 | elk_default_theme_url = "', $settings['default_theme_url'], '", |
||
767 | elk_session_id = "', $context['session_id'], '", |
||
768 | elk_session_var = "', $context['session_var'], '", |
||
769 | elk_member_id = ', $context['user']['id'], '; |
||
770 | |||
771 | // Sets all ssi_preview class to hidden, then shows the one requested. |
||
772 | function showSSIBlock(elementID) |
||
773 | { |
||
774 | toggleVisibleByClass("ssi_preview", true); |
||
775 | document.getElementById(elementID).style.display = "block"; |
||
776 | if (elementID !== "ssi_recentTopics") |
||
777 | { |
||
778 | document.getElementById(elementID).scrollIntoView(); |
||
779 | } |
||
780 | } |
||
781 | |||
782 | // Toggle visibility of all sections. |
||
783 | function toggleVisibleByClass(sClassName, bHide) |
||
784 | { |
||
785 | var oSections = document.getElementsByTagName("div"); |
||
786 | for (var i = 0; i < oSections.length; i++) |
||
787 | { |
||
788 | if (oSections[i].className === null || oSections[i].className.indexOf(sClassName) == -1) |
||
789 | continue; |
||
790 | |||
791 | oSections[i].style.display = bHide ? "none" : "block"; |
||
792 | } |
||
793 | } |
||
794 | </script> |
||
795 | </head> |
||
796 | <body> |
||
797 | <div id="top_section"> |
||
798 | <div id="header" class="wrapper"> |
||
799 | <h1 id="forumtitle">ElkArte SSI (Server Side Includes) Examples |
||
800 | <span id="logobox"> |
||
801 | <img id="logo" src="themes/default/images/logo.png" alt="ElkArte Logo" title="ElkArte Community" /> |
||
802 | </span> |
||
803 | </h1> |
||
804 | </div> |
||
805 | </div> |
||
806 | <div id="wrapper" class="wrapper"> |
||
807 | <div id="upper_section"> |
||
808 | <div id="inner_section"> |
||
809 | <div id="inner_wrap"> |
||
810 | <div class="frame"> |
||
811 | <div id="main_content_section"> |
||
812 | <div id="liftup" class="flow_auto">'; |
||
813 | } |
||
814 | |||
815 | function template_ssi_below() |
||
816 | { |
||
817 | echo ' |
||
818 | <script> |
||
819 | showSSIBlock("ssi_recentTopics"); |
||
820 | </script> |
||
821 | </div> |
||
822 | </div> |
||
823 | </div> |
||
824 | </div> |
||
825 | </div> |
||
826 | </div> |
||
827 | </div> |
||
828 | <div id="footer_section"> |
||
829 | <div class="frame"> |
||
830 | <div class="smalltext"><a href="https://www.elkarte.net/">ElkArte Community</a> |
||
831 | </div> |
||
832 | </div> |
||
833 | </body> |
||
834 | </html>'; |
||
835 | } |
||
836 | |||
837 | function template_homepage_sample1($method = 'source') |
||
838 | { |
||
839 | $header = '<!DOCTYPE html> |
||
840 | <html> |
||
841 | <head> |
||
842 | <title>SSI.php example for home page</title> |
||
843 | <style> |
||
844 | html { |
||
845 | width: 99%; |
||
846 | } |
||
847 | body { |
||
848 | font: 87.5%/150% "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Droid Sans", "Helvetica Neue", "Trebuchet MS", Arial, sans-serif; |
||
849 | background: #DFDFDF; |
||
850 | color: #FFFFFF; |
||
851 | margin: 0; |
||
852 | } |
||
853 | ul, ol { |
||
854 | padding-left: 1.25em; |
||
855 | margin: 0; |
||
856 | } |
||
857 | li { |
||
858 | font-size: 1em; |
||
859 | } |
||
860 | h1, h2, h3 { |
||
861 | margin: 0; |
||
862 | padding: 0; |
||
863 | } |
||
864 | h3 { |
||
865 | font-size: 1em; |
||
866 | } |
||
867 | a:link,a:visited { |
||
868 | color: #FF9000; |
||
869 | text-decoration: none; |
||
870 | } |
||
871 | a:hover { |
||
872 | text-decoration: underline; |
||
873 | } |
||
874 | #container { |
||
875 | background: #52514E; |
||
876 | width: 100%; |
||
877 | border: 1px solid midnightblue; |
||
878 | line-height: 150%; |
||
879 | margin: 0; |
||
880 | } |
||
881 | #header, #footer { |
||
882 | color: lightgray; |
||
883 | background: #2A2825; |
||
884 | clear: both; |
||
885 | padding: .5em; |
||
886 | } |
||
887 | #leftbar { |
||
888 | background: #DF7E00; |
||
889 | float: left; |
||
890 | width: 160px; |
||
891 | margin: 0; |
||
892 | padding: 1em; |
||
893 | } |
||
894 | #leftbar a { |
||
895 | color: #000; |
||
896 | text-decoration: underline; |
||
897 | } |
||
898 | #content { |
||
899 | margin-left: 190px; |
||
900 | padding: 1em; |
||
901 | } |
||
902 | #navigation { |
||
903 | float: right; |
||
904 | } |
||
905 | #navigation a:link, #navigation a:visited { |
||
906 | color: #FF9000; |
||
907 | } |
||
908 | </style> |
||
909 | </head> |
||
910 | <body> |
||
911 | <div id="container"> |
||
912 | <div id="header"> |
||
913 | <div id="navigation"> |
||
914 | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> | <a href="#">Link</a> |
||
915 | </div> |
||
916 | <h1 class="header">YourWebsite.com</h1> |
||
917 | </div> |
||
918 | <div id="leftbar"> |
||
919 | <h3>Recent Forum Topics</h3> |
||
920 | <ul>'; |
||
921 | |||
922 | $footer = ' |
||
923 | <div id="footer"> |
||
924 | <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/"><img alt="Creative Commons License" style="border:0;" src="http://i.creativecommons.org/l/publicdomain/88x31.png" /></a> |
||
925 | This sample website layout is dedicated to the <a target="_blank" rel="license" href="http://creativecommons.org/licenses/publicdomain/">Public Domain</a>. |
||
926 | </div> |
||
927 | </div> |
||
928 | </body> |
||
929 | </html>'; |
||
930 | |||
931 | if ($method === 'source') |
||
932 | { |
||
933 | $header = '<?php require("' . (User::$info->is_admin ? addslashes(realpath(BOARDDIR . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header; |
||
0 ignored issues
–
show
The property
is_admin does not exist on ElkArte\Helper\ValuesContainer . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
934 | return $header . template_homepage_sample1_html() . $footer; |
||
935 | } |
||
936 | echo $header; |
||
937 | template_homepage_sample1_php(); |
||
938 | echo $footer; |
||
939 | } |
||
940 | |||
941 | function template_homepage_sample1_php() |
||
942 | { |
||
943 | global $txt; |
||
944 | |||
945 | $topics = ssi_recentTopics(8, null, null, 'array'); |
||
946 | |||
947 | foreach ($topics as $topic) |
||
948 | echo ' |
||
949 | <li> |
||
950 | <a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], ' |
||
951 | </li>'; |
||
952 | |||
953 | unset($topics); |
||
954 | |||
955 | echo ' |
||
956 | </ul> |
||
957 | <br /> |
||
958 | <h3>Online Users</h3>'; |
||
959 | ssi_logOnline(); |
||
960 | |||
961 | echo ' |
||
962 | </div> |
||
963 | |||
964 | <div id="content">'; |
||
965 | |||
966 | ssi_welcome(); |
||
967 | echo ' |
||
968 | <br /><br /> |
||
969 | <h2>News</h2>'; |
||
970 | |||
971 | ssi_boardNews(); |
||
972 | |||
973 | echo ' |
||
974 | </div>'; |
||
975 | } |
||
976 | |||
977 | function template_homepage_sample1_html() |
||
978 | { |
||
979 | $result = ' |
||
980 | <?php |
||
981 | // Using array method to show shorter display style. |
||
982 | $topics = ssi_recentTopics(8, null, null, \'array\'); |
||
983 | |||
984 | foreach ($topics as $topic) |
||
985 | { |
||
986 | // Uncomment the following code to get a listing of array elements that the system provides for this function. |
||
987 | // echo \'<pre>\', print_r($topic), \'</pre>\'; |
||
988 | |||
989 | echo \' |
||
990 | <li> |
||
991 | <a href=\"\', $topic[\'href\'], \'\">\', $topic[\'subject\'], \'</a> \', $txt[\'by\'], \' \', $topics[$i][\'poster\'][\'link\'], \'</li>\'; |
||
992 | } |
||
993 | |||
994 | unset($topics); |
||
995 | ?> |
||
996 | </ul><br /> |
||
997 | <h3>Online Users</h3> |
||
998 | <?php ssi_logOnline(); ?> |
||
999 | </div> |
||
1000 | <div id="content"> |
||
1001 | <?php |
||
1002 | ssi_welcome(); ?><br /><br /> |
||
1003 | <h2>News</h2> |
||
1004 | <?php ssi_boardNews(); ?> |
||
1005 | </div>'; |
||
1006 | |||
1007 | return $result; |
||
1008 | } |
||
1009 |