1 | <?php |
---|
2 | defined('USER_INFO_TRACKING_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | |
---|
5 | /** |
---|
6 | * Triggered on login_success |
---|
7 | * |
---|
8 | */ |
---|
9 | function ui_successfulLogin() |
---|
10 | { |
---|
11 | global $conf, $user; |
---|
12 | |
---|
13 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
14 | $myIpAddress = $_SERVER['REMOTE_ADDR']; |
---|
15 | |
---|
16 | |
---|
17 | pwg_query("INSERT INTO `". USER_INFO_TRACKING_TABLE2 ."`( |
---|
18 | userID, |
---|
19 | userName, |
---|
20 | ipAddress, |
---|
21 | timeStamp, |
---|
22 | action |
---|
23 | ) |
---|
24 | VALUES( |
---|
25 | '". $user['id'] ."', |
---|
26 | '". $_POST['username'] ."', |
---|
27 | '". $myIpAddress ."', |
---|
28 | '". time() ."', |
---|
29 | 'Successful Login' |
---|
30 | );"); |
---|
31 | |
---|
32 | } |
---|
33 | |
---|
34 | /** |
---|
35 | * Triggered on login_failure |
---|
36 | * |
---|
37 | */ |
---|
38 | function ui_failedLogin() |
---|
39 | { |
---|
40 | |
---|
41 | global $conf; |
---|
42 | |
---|
43 | $myIpAddress = $_SERVER['REMOTE_ADDR']; |
---|
44 | $login = $_POST['username']; |
---|
45 | |
---|
46 | |
---|
47 | $query = " |
---|
48 | SELECT ".$conf['user_fields']['id']." AS id |
---|
49 | FROM ".USERS_TABLE." |
---|
50 | WHERE LOWER(".stripslashes($conf['user_fields']['username']).") = '".strtolower($login)."' |
---|
51 | ;"; |
---|
52 | |
---|
53 | $userNameLookup = mysql_fetch_row(pwg_query($query)); |
---|
54 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
55 | |
---|
56 | if ($count > 0) |
---|
57 | { |
---|
58 | |
---|
59 | pwg_query("INSERT INTO `". USER_INFO_TRACKING_TABLE2 ."`( |
---|
60 | userID, |
---|
61 | userName, |
---|
62 | ipAddress, |
---|
63 | timeStamp, |
---|
64 | action |
---|
65 | ) |
---|
66 | VALUES( |
---|
67 | '". $userNameLookup[0] ."', |
---|
68 | '". $_POST['username'] ."', |
---|
69 | '". $myIpAddress ."', |
---|
70 | '". time() ."', |
---|
71 | 'Failed Login' |
---|
72 | );"); |
---|
73 | |
---|
74 | } else { |
---|
75 | |
---|
76 | pwg_query("INSERT INTO `". USER_INFO_TRACKING_TABLE2 ."`( |
---|
77 | userName, |
---|
78 | ipAddress, |
---|
79 | timeStamp, |
---|
80 | action |
---|
81 | ) |
---|
82 | VALUES( |
---|
83 | '". $_POST['username'] ."', |
---|
84 | '". $myIpAddress ."', |
---|
85 | '". time() ."', |
---|
86 | 'Failed Login' |
---|
87 | );"); |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | /** |
---|
95 | * Triggered on logout |
---|
96 | * |
---|
97 | */ |
---|
98 | function ui_logout() |
---|
99 | { |
---|
100 | global $conf, $user; |
---|
101 | |
---|
102 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
103 | $myIpAddress = $_SERVER['REMOTE_ADDR']; |
---|
104 | |
---|
105 | |
---|
106 | pwg_query("INSERT INTO `". USER_INFO_TRACKING_TABLE2 ."`( |
---|
107 | userID, |
---|
108 | userName, |
---|
109 | ipAddress, |
---|
110 | timeStamp, |
---|
111 | action |
---|
112 | ) |
---|
113 | VALUES( |
---|
114 | '". $user['id'] ."', |
---|
115 | '". $user['username'] ."', |
---|
116 | '". $myIpAddress ."', |
---|
117 | '". time() ."', |
---|
118 | 'Logout' |
---|
119 | );"); |
---|
120 | |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | ?> |
---|