357
357
$this->session_gc();
360
// Shared secret between IVLE and the Forum
361
$ivle_secret = 'VERYSECRET';
364
$ivle_cookie = $_COOKIE['ivlecookie'];
366
// Decode and unescape the Cookie contents
367
$cookie = explode(':',$ivle_cookie);
368
$ivle_uid = preg_replace('/\\\(.)/','$1',$cookie[0]);
369
$ivle_nick = preg_replace('/\\\(.)/','$1',$cookie[1]);
370
$ivle_email = preg_replace('/\\\(.)/','$1',$cookie[2]);
371
$ivle_hash = preg_replace('/\\\(.)/','$1',$cookie[3]);
373
// Check if uid + nick + email + secret is the same as the hash
374
$ivle_auth = False; // Flag just incase anything else need to know
375
if (md5($ivle_uid.$ivle_nick.$ivle_email.$ivle_secret) == $ivle_hash) {
378
// Check if the user exists in the database
379
$sql = 'SELECT user_id
380
FROM ' . USERS_TABLE . '
381
WHERE username = "' . $db->sql_escape($ivle_uid) . '";';
382
$result = $db->sql_query($sql);
383
$row = $db->sql_fetchrow($result);
384
$user_id = $row['user_id'];
385
$db->sql_freeresult($result);
387
// If no user_id is found for the username, create a new user
389
// Needed for IVLE auth overide
390
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
392
// Get the default group
393
$sql = 'SELECT group_id
394
FROM ' . GROUPS_TABLE . "
395
WHERE group_name = '" . $db->sql_escape('REGISTERED') . "'
396
AND group_type = " . GROUP_SPECIAL;
397
$result = $db->sql_query($sql);
398
$row = $db->sql_fetchrow($result);
399
$db->sql_freeresult($result);
402
trigger_error('NO_GROUP');
405
$group_id = $row['group_id'];
407
// Get the Time and Timezone
408
$timezone = date('Z') / 3600;
410
$timezone = ($is_dst) ? $timezone - 1 : $timezone;
413
'username' => $ivle_uid,
414
'user_password' => '', # Not a valid hash
415
'user_email' => $ivle_email,
416
'group_id' => (int) $group_id,
417
'user_timezone' => (float) $timezone,
418
'user_dst' => $is_dst,
420
'user_type' => USER_NORMAL,
422
'user_ip' => $this->ip,
423
'user_regdate' => time(),
424
'user_inactive_reason' => 0,
425
'user_inactive_time' => 0,
429
$user_id = user_add($user_row);
432
/* IVLE: End of IVLE Code */
435
360
// Do we allow autologin on this board? No? Then override anything
436
361
// that may be requested here