This repository was archived by the owner on Oct 11, 2023. It is now read-only.
forked from BeehiveForum/BeehiveForum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbh_x7chat_auth.php
113 lines (80 loc) · 3.46 KB
/
bh_x7chat_auth.php
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
<?php
/*======================================================================
Copyright Project Beehive Forum 2002
This file is part of Beehive Forum.
Beehive Forum is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Beehive Forum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Beehive; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
======================================================================*/
// Set the default timezone
date_default_timezone_set('UTC');
// Constant to define where the include files are
define("BH_INCLUDE_PATH", "../forum/include/");
// Server checking functions
include_once(BH_INCLUDE_PATH. "server.inc.php");
// Installation checking functions
include_once(BH_INCLUDE_PATH. "install.inc.php");
// Check that Beehive is installed correctly
check_install();
// Multiple forum support
include_once(BH_INCLUDE_PATH. "forum.inc.php");
// Fetch Forum Settings
$forum_settings = forum_get_settings();
// Fetch Global Forum Settings
$forum_global_settings = forum_get_global_settings();
include_once(BH_INCLUDE_PATH. "db.inc.php");
include_once(BH_INCLUDE_PATH. "logon.inc.php");
include_once(BH_INCLUDE_PATH. "session.inc.php");
// X7Chat Username Cookie
$auth_ucookie = "X7C2U";
// X7Chat Password Cookie
$auth_pcookie = "X7C2P";
// Registration link
$auth_register_link = "../register.php";
// Disable Guest access to X7Chat
$auth_disable_guest = true;
// Check the session is active
if (($user_sess = session_check())) {
if ($user_data = user_get(session_get_value('UID'))) {
$_COOKIE[$auth_ucookie] = db_escape_string($user_data['LOGON']);
$_COOKIE[$auth_pcookie] = db_escape_string($user_data['PASSWD']);
$query = $db->DoQuery("SELECT * FROM {$prefix}users WHERE username='$_COOKIE[$auth_ucookie]'");
$row = $db->Do_Fetch_Row($query);
if ($row[0] == '') {
$time = time();
$ip = db_escape_string($_SERVER['REMOTE_ADDR']);
$activated = session_user_approved() ? '1' : '0';
$email = db_escape_string($user_data['EMAIL']);
$db->DoQuery("INSERT INTO {$prefix}users (username,password,email,user_group,time,settings,hideemail,ip,activated) VALUES('$_COOKIE[$auth_ucookie]','$_COOKIE[$auth_pcookie]','{$email}', '{$x7c->settings['usergroup_default']}','$time','{$g_default_settings}','1','$ip','$activated')");
}
}
}
// Authentication Encryption.
function auth_encrypt($data)
{
return md5($data);
}
// Get password hash
function auth_getpass($auth_ucookie)
{
if ($user_data = user_get_by_logon($_COOKIE[$auth_ucookie])) {
return $user_data['PASSWD'];
}
}
// Change password
function change_pass($user, $newpass)
{
if ($user_data = user_get_by_logon($user)) {
user_change_password($user_data['UID'], $newpass, $user_data['PASSWD']);
}
}
?>