-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmf_2_integration_hooks.php
More file actions
708 lines (655 loc) · 27.9 KB
/
smf_2_integration_hooks.php
File metadata and controls
708 lines (655 loc) · 27.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
<?php
/**
* Simple Machines Forum(SMF) Integration Hooks for SMF 2.0
*
* Use this to integrate your SMF version 2.0 forum with 3rd party software
* If you need help using this script or integrating your forum with other
* software, feel free to email andre@r2bconcepts.com
*
* @package SMF 2.0 Integration Hooks
* @author Simple Machines http://www.simplemachines.org
* @author Andre Nickatina <andre@r2bconcepts.com>
* @copyright 2011 Simple Machines
* @link http://www.simplemachines.org Simple Machines
* @link http://www.r2bconcepts.com Red2Black Concepts
* @license http://www.simplemachines.org/about/smf/license.php BSD
* @version 0.1.1
*
* NOTICE OF LICENSE
***********************************************************************************
* This file, and ONLY this file is released under the terms of the BSD License. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are met: *
* *
* Redistributions of source code must retain the above copyright notice, this *
* list of conditions and the following disclaimer. *
* Redistributions in binary form must reproduce the above copyright notice, this *
* list of conditions and the following disclaimer in the documentation and/or *
* other materials provided with the distribution. *
* Neither the name of Simple Machines LLC nor the names of its contributors may *
* be used to endorse or promote products derived from this software without *
* specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" *
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE *
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE *
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**********************************************************************************/
/*
This file includes functions that may help integration with other scripts
and programs. It defines several functions that are called
during SMF runtime. These functions are:
void smf_pre_load_function()
- This hook is started immediately after the integrate_pre_include hook
void smf_activate_function(string $username)
- This hook is started in two instances. Whenever the administrator approves
members, each of those members' usernames is passed to the hook function
for activation in the integrated system as well. The first instance is in
the SMF admin panel, and the second is in the user profile
void smf_change_member_data_function(array $memberNames, string $var, string $data)
- This hook is started just before any changes are made to users profiles.
It is started when an admin is changing multiple users in the admin panel,
and also when a user is changing his own profile
void smf_create_topic_function(array $msgOptions, array $topicOptions, array $posterOptions)
- This hook is started right after a new topic post is entered into the SMF
database. It passes all relevant posting information out to the integration
hook function
void smf_delete_member_function(int $id_member)
- This hook is started just before a user is deleted from SMF
void smf_exit_function(bool $do_footer && !WIRELESS)
- This hook is started just before SMF exits. This hook is extremely important
for true bridges, because in certain circumstances, the forum can becomes
unwrapped from the integrated context without this hook. It will execute
whatever code is in the hook function before exiting PHP
string smf_fix_url_function(string $current_url)
- This hook is started only in XML feeds. It expects a URL, and is expected
to return an alternative URL based on the one passed to it
void smf_load_theme_function()
- This hook is started after SMF has defined its template layers, but before
the template layers are used. It gives the integration a chance to alter
the template layers before they are used
void smf_login_function(string $user_settings['memberName'], string $_REQUEST['hash_passwrd'], int $modsettings['cookieTime'])
- This hook is started after authentication in SMF, but before setting the SMF
cookie. It's main use is setting the login cookie of an alternative system.
Because the user is already authenticated in SMF at this point, there is
very little need for further authentication checks
void smf_logout_function(string $user_settings['memberName'])
- This hook is started before the user entry is deleted from the SMF log
online table, and the SMF cookie is dropped
bool smf_outgoing_email_function(string $subject, string $message, string $headers)
- This hook is started just before the output of the email is modified for sending.
The message body is still plain text at this point
void smf_output_error_function(string $message, string $error_type, int $error_level, string $file, int $line)
- This hook is started after an error message is generated in SMF, but before
SMF displays it
void smf_personal_message_function(array $recipients, string $from['username'], string $subject, string $message)
- This hook is started just before an SMF Personal Message is sent. It passes
an array of recipients, the username of the sender, the subject, and the
message body
void smf_redirect_function(string $setLocation, bool $refresh)
- This hook is started just before SMF redirects after a form submission.
To avoid resubmission of form data, SMF uses its own redirect system. The
$setLocation variable will be the URL to which to redirect, and the $refresh
variable is a boolean determining whether a page refresh should be done
after loading
void smf_register_function(array $regOptions, array $theme_vars)
- This hook is started just before a user is entered into SMF. It is one of the
more powerful integration hooks, passing all necessary variables in an array
for use in the integrated system
void smf_reset_pass_function(string $old_username, string $new_username, string $password)
- This hook is started only when a username or password is changed in SMF
bool smf_validate_login_function(string $_REQUEST['user'], string $_REQUEST['hash_passwrd'], int $modsettings['cookieTime'])
- This hook is started before checking for a valid SMF user on login. This
gives the integrated application a chance to use the login credentials
before SMF does. Something to keep in mind is that SMF hashes the password
in SHA1 on the client side, so an unhashed password is not available to
this function. A value of true or false returned from the function will
continue as normal, and a value of 'retry' will redisplay the login form,
with the message "Password security has recently been upgraded. Please login again."
bool smf_verify_password_function(string $username, string $password)
- This hook is started only when sensitive information may be getting changed.
It is called when a user is changing his email address, and when an admin is
using the SMF admin panel. It validates the username and password against
the integrated system before proceeding. SMF expects a value of true if the
authentication passes, and false if it fails
int smf_verify_user_function()
- This hook is started before checking the SMF cookie for a valid user.
A valid SMF $ID_MEMBER is expected back from the hook function, or SMF
will assume it should check the SMF cookie instead
array smf_whos_online_function(array $actions)
- This hook is started during the process of figuring out what each user is
doing for the Whos online list. It expects text back depending on the
variables in the query string of the page the user is viewing, which should
all be passed in the $actions array
array smf_session_save_function()
- Not a hook, just a function to save your SMF session data and shut down the
SMF session
void smf_session_restore_function()
- Not a hook. Use to reopen an SMF session (if you ended it) before your function ends.
I just restores the $_SESSION variables and calls loadSession; might be unneccessary
*/
//define the integration functions, comment out the ones you don't need
define('SMF_INTEGRATION_SETTINGS',
serialize( array(
/*
This is the very first integration hook encountered in the workflow.
It is started immediately after the loading of the SMF settings.
So, if you need to include some scripting at the beginning of SMF,
this can be done with this hook in a separate file, without any need
for modifying the SMF code
*/
// 'integrate_pre_include' => 'somefile.php',
//
// Hook Name Function Name (defined below)
'integrate_pre_load' => 'smf_pre_load_function',
'integrate_activate' => 'smf_activate_function',
'integrate_change_member_data' => 'smf_change_member_data_function',
'integrate_create_topic' => 'smf_create_topic_function',
'integrate_delete_member' => 'smf_delete_member_function',
'integrate_exit' => 'smf_exit_function',
'integrate_fix_url' => 'smf_fix_url_function',
'integrate_load_theme' => 'smf_load_theme_function',
'integrate_login' => 'smf_login_function',
'integrate_logout' => 'smf_logout_function',
'integrate_outgoing_email' => 'smf_outgoing_email_function',
'integrate_personal_message' => 'smf_personal_message_function',
'integrate_redirect' => 'smf_redirect_function',
'integrate_register' => 'smf_register_function',
'integrate_reset_pass' => 'smf_reset_pass_function',
'integrate_validate_login' => 'smf_validate_login_function',
'integrate_verify_password' => 'smf_verify_password_function',
'integrate_verify_user' => 'smf_verify_user_function',
'integrate_whos_online' => 'smf_whos_online_function',
))
);
/**
* Pre load
*
* This hook is started immediately after the integrate_pre_include hook.
* It serves much of the same type of purpose, but it calls a function rather
* than including a file.
*
* Example of use: Modifying SMF settings to match those of an integrated system.
*
* @access public
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_pre_load_function()
{
}
/**
* Activate new member
*
* This hook is started in two instances. Whenever the administrator approves
* members, each of those members' usernames is passed to the hook function for
* activation in the integrated system as well. The first instance is in the
* SMF admin panel, and the second is in the user profile.
*
* Example of use: A user has registered, and is awaiting admin approval of his
* account to use both SMF and the integrated application.
*
* @access public
* @param string $username the username of the member to activate
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_activate_function($username)
{
}
/**
* Change member data
*
* This hook is started just before any changes are made to users profiles.
* It is started when an admin is changing multiple users in the admin panel,
* and also when a user is changing his own profile.
* The $var array is similar to the $regOptions array in the integrate_register
* hook. It contains all of the key names for the fields to be changed. The $data
* array will contain the associated values for those keys.
*
* Example of use: A user changes his profile information, and that information
* needs to be passed to the integrated system.
*
* @access public
* @param int || int array $memberNames the member id(s) to be updated
* @param string $var the member data column to be updated ex. 'gender'
* @param string $data the data to be changed
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_change_member_data_function($memberNames, $var, $data)
{
}
/**
* Create topic
*
* This hook is started right after a new topic post is entered into the SMF
* database. It passes all relevant posting information out to the integration
* hook function.
*
* Example of use: The forum has a "News" board, and all new topics posted in
* that board are also news articles on the front page of a CMS.
*
* @access public
* @param array $msgOptions
* @param array $topicOptions
* @param array $posterOptions
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_create_topic_function($msgOptions, $topicOptions, $posterOptions)
{
}
/**
* Delete member
*
* This hook is started just before a user is deleted from SMF.
*
* Example of use: A user has deleted his account, or the admin has deleted a
* user's account, and the account needs to be deleted in the integrated system
* as well.
*
* @access public
* @param int $id_member the member id
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_delete_member_function($id_member)
{
}
/**
* Exit SMF
*
* This hook is started just before SMF exits. This hook is extremely important
* for true bridges, because in certain circumstances, the forum can becomes
* unwrapped from the integrated context without this hook. It will execute
* whatever code is in the hook function before exiting PHP.
*
* Example of use: SMF is wrapped in a CMS, and the CMS needs to finish off its
* execution before exit.
*
* @access public
* @param bool $do_footer && !WIRELESS
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_exit_function($do_footer)
{
}
/**
* Fix url
*
* This hook is started only in XML feeds. It expects a URL, and is expected to
* return an alternative URL based on the one passed to it.
*
* Example of use: SMF is wrapped in a CMS, and the URL of the wrapped CMS needs
* to appear in outgoing RSS feeds.
*
* @access public
* @param string $currentUrl the current url
* @return string the modified url
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_fix_url_function($currentUrl)
{
}
/**
* Load theme
*
* This hook is started after SMF has defined its template layers, but before
* the template layers are used. It gives the integration a chance to alter the
* template layers before they are used.
*
* Example of use: The forum is wrapped in a CMS, so the HTML headers need to
* be omitted to remain W3C compliant.
*
* @access public
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_load_theme_function()
{
}
/**
* Login member
*
* This hook is started after authentication in SMF, but before setting the SMF
* cookie. It's main use is setting the login cookie of an alternative system.
* Because the user is already authenticated in SMF at this point, there is very
* little need for further authentication checks.
*
* Example of use: A user has logged into SMF, and should also be logged into
* the integrated system at the same time.
*
* @access public
* @param string $memberName the members' SMF username
* @param string $hash_password the password already hashed
* @param string $cookieTime ($modsettings['cookieTime'])
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_login_function($memberName, $hash_password, $cookieTime)
{
}
/**
* Logout member
*
* This hook is started before the user entry is deleted from the SMF log online
* table, and the SMF cookie is dropped.
*
* Example of use: A user has logged out of SMF, and should also be logged out
* of the integrated system at the same time.
*
* @access public
* @param string $memberName the members' SMF username
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_logout_function($memberName)
{
}
/**
* Outgoing email
*
* This hook is started just before the output of the email is modified for
* sending. The message body is still plain text at this point.
*
* Example of use: The forum is wrapped in a CMS, so all of the URLs in outgoing
* emails need to be rewritten to point to the CMS.
*
* @access public
* @param string $subject the message subject
* @param string $message the message body (plain text)
* @param string $headers the email headers
* @return bool (false will cancel sending)
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_outgoing_email_function($subject, $message, $headers)
{
}
/**
* Personal message
*
* This hook is started just before an SMF Personal Message is sent. It passes
* an array of recipients, the username of the sender, the subject, and the
* message body.
*
* Example of use: A user sends a PM, and that PM should appear in the integrated
* system as well as SMF's PM system.
*
* @access public
* @param array $recipients the usernames of the recipients
* @param string $from the username of the sender
* @param string $subject the personal message subject
* @param string $message the personal message
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_personal_message_function($recipients, $from, $subject, $message)
{
}
/**
* Redirect
*
* This hook is started just before SMF redirects after a form submission. To
* avoid resubmission of form data, SMF uses its own redirect system. The
* $setLocation variable will be the URL to which to redirect, and the $refresh
* variable is a boolean determining whether a page refresh should be done after
* loading.
*
* Example of use: Similarly to the integrate_outgoing_email function above,
* this can be used to rewrite redirection URLs back to a wrapped CMS page.
*
* @access public
* @param string $setLocation the url to redirect to
* @param bool $refresh whether a page refresh should be done after loading
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_redirect_function($setLocation, $refresh)
{
}
/**
* Register new member
*
* This hook is started just before a user is entered into SMF. It is one of the
* more powerful integration hooks, passing all necessary variables in an array
* for use in the integrated system.
*
* The $regOptions array by default will contain the following keys:
* memberName
* emailAddress
* passwd (SHA1 hash)
* passwordSalt
* posts
* dateRegistered
* memberIP
* memberIP2
* validation_code
* realName
* personalText
* pm_email_notify
* ID_THEME
* ID_POST_GROUP
*
* It is important to note that all text values will already be enclosed in single
* quotes for ease of use in queries. More fields are available, and more are
* added with the addition of mods like the Custom Profile Fields mod.
*
* Example of use: A user has registered in SMF, or an admin has created a user
* in the SMF admin panel, and the user needs to be created in the integrated
* system as well.
*
* @access public
* @param array $regOptions the registration options (shown above)
* @param array $theme_vars the theme variables
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_register_function($regOptions, $theme_vars)
{
}
/**
* Change username or password
*
* This hook is started only when a username or password is changed in SMF.
*
* Example of use: A user changes his password, so the password also needs to
* change in the integrated system.
*
* @access public
* @param type [$varname] description
* @return type description
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_reset_pass_function($oldUsername, $newUsername, $password)
{
}
/**
* Validate login
*
* This hook is started before checking for a valid SMF user on login. This gives
* the integrated application a chance to use the login credentials before SMF
* does. Something to keep in mind is that SMF hashes the password in SHA1 on
* the client side, so an unhashed password is not available to this function.
*
* A value of true or false returned from the function will continue as normal,
* and a value of 'retry' will redisplay the login form, with the message
* "Password security has recently been upgraded. Please login again."
*
* Example of use: A user that exists in the integrated application but not in
* SMF is attempting to login, so needs to be migrated to SMF before SMF has
* a chance to authenticate. Something to keep in mind here is that SMF can
* authenticate with many other types of hashes, so the hashed passwords of
* other systems can typically be written directly to the SMF members table,
* with the hook returning 'retry', which will automatically invoke SMF to
* rewrite to its own hash on the second login attempt.
*
* @access public
* @param string $username ($_REQUEST['user']) the members' username
* @param string $hash_password ($_REQUEST['hash_passwrd'])
* @param int $cookieTime ($modsettings['cookieTime'])
* @return bool || string 'retry'
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_validate_login_function($username, $hash_password, $cookieTime)
{
}
/**
* Verify password in integrated system
*
* This hook is started only when sensitive information may be getting changed.
* It is called when a user is changing his email address, and when an admin is
* using the SMF admin panel. It validates the username and password against the
* integrated system before proceeding. SMF expects a value of true if the
* authentication passes, and false if it fails.
*
* Example of use: You want an added layer of security to authenticate user
* changes and SMF admin panel access.
*
* @access public
* @param string $username the members' username
* @param string $password this might be plain text OR SHA1 hashed depending
* on where it's called from. Use strlen($password) == 40 to check I guess
* @return bool whether the login passes the integrated systems' authentication
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_verify_password_function()
{
}
/**
* Verify user
*
* This hook is started before checking the SMF cookie for a valid user. A valid
* SMF $ID_MEMBER is expected back from the hook function, or SMF will assume
* it should check the SMF cookie instead.
*
* Example of use: User is logged into a CMS, but not into SMF, so we want to
* auto-login to SMF without the SMF cookie.
*
* @access public
* @return int $id_member a valid SMF member id
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_verify_user_function()
{
}
/**
* Who's online
*
* This hook is started during the process of figuring out what each user is doing
* for the Whos Online list. It expects text back depending on the variables in
* the query string of the page the user is viewing, which should all be passed
* in the $actions array.
*
* Example of use: A user is accessing a page in an integrated system, and that
* page should be reported correctly in the Whos online.
*
* @access public
* @param array $actions the actions being performed
* @return array $data the corresponding results to display in Who's Online list
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_whos_online_function($actions)
{
}
/**
* Session save and close
*
* This function was designed to save your SMF session data and end the session.
* It will store the saved session information in an array it returns. This way
* you can stop your session and use your integrated system, which might require
* it's own session, or mess with the SMF session. You can use the session restore
* function afterwards to restore the saved session data.
*
* Example of use: Your integrated system requires a session and you don't want
* your SMF session to screw it up or vice versa. You use this function to save
* your SMF session and restore it after you finish manipulating the other system.
*
* @access public
* @return array $data the session data
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_session_save_function()
{
$data = array();
$data['SESSION'] = $_SESSION;
//just in case
$sessionId = session_id();
$sessionName = session_name();
$cookieParams = session_get_cookie_params();
$sessionSavePath = session_save_path();
$data['sessionId'] = $sessionId;
$data['sessionName'] = $sessionName;
$data['cookieParams'] = $cookieParams;
$data['sessionSavePath'] = $sessionSavePath;
//kill it
if ('' != session_id()) {
session_write_close();
}
$_SESSION = array();
unset($_SESSION);
return $data;
}
/**
* Session restore
*
* This function was designed to restore your SMF session data.
*
* Example of use: You're done manipulating your integrated system and now you
* want to restore SMF's session and get back to business as usual without any
* session verification errors or dropped session/lost data
*
* @access public
* @param array $data the session data to restore
* @return void
* @link http://www.r2bconcepts.com Red2Black Concepts
* @since 0.1.0
*/
function smf_session_restore_function($data=array())
{
//make sure our other session is closed now
if ('' != session_id()) {
session_write_close();
}
//put everything back where we found it
session_set_cookie_params($data['cookieParams']['lifetime'], $data['cookieParams']['path'], $data['cookieParams']['domain'], $data['cookieParams']['secure'], $data['cookieParams']['httponly']);
session_save_path($data['sessionSavePath']);
session_name($data['sessionName']);
session_id($data['sessionId']);
session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
//resume the session
session_start();
//put the session variables back
$_SESSION = $data['SESSION'];
//restore php.ini settings and hopefully fix anything we missed
loadSession();
}
?>