diff --git a/README.md b/README.md index c80a28e..13d457a 100644 --- a/README.md +++ b/README.md @@ -65,9 +65,19 @@ SQLConnectInfo database@localhost username password SQLUserInfo users userid passwd uid gid homedir shell SQLGroupInfo groups groupname gid members SQLUserWhereClause "disabled != 1" + + # Register login counter and date SQLLog PASS updatecount SQLNamedQuery updatecount UPDATE "login_count=login_count+1, last_login=now() WHERE userid='%u'" users + # Register login history +SQLLog PASS log_sess +SQLNamedQuery log_sess INSERT "'%u', '%a', '%V', '%{protocol}', NOW()" login_history + + # Register file changes +SQLLog STOR,DELE modified +SQLNamedQuery modified UPDATE "modified_file=now() WHERE userid='%u'" users + # Used to track xfer traffic per user (without invoking a quota) SQLLog RETR bytes-out-count SQLNamedQuery bytes-out-count UPDATE "bytes_out_used=bytes_out_used+%b WHERE userid='%u'" users diff --git a/add_group.php b/add_group.php index 334916f..d161886 100644 --- a/add_group.php +++ b/add_group.php @@ -61,7 +61,7 @@ $errormsg = 'Group "'.$_REQUEST[$cfg['field_groupname']].'" creation failed; check log files.'; } } else { - $errormsg = implode($errors, "
\n"); + $errormsg = implode("
\n", $errors); } } diff --git a/add_user.php b/add_user.php index ee890a1..8a8d754 100644 --- a/add_user.php +++ b/add_user.php @@ -100,7 +100,7 @@ $field_disabled => $disabled); if ($ac->add_user($userdata)) { if (isset($_REQUEST[$field_ad_gid])) { - while (list($g_key, $g_gid) = each($_REQUEST[$field_ad_gid])) { + foreach ($_REQUEST[$field_ad_gid] as $g_key => $g_gid) { if (!$ac->is_valid_id($g_gid)) { $warnmsg = 'Adding additional group failed; at least one of the additional groups had an invalid GID.'; continue; @@ -114,7 +114,7 @@ $errormsg = 'User "'.$_REQUEST[$field_userid].'" creation failed; check log files.'; } } else { - $errormsg = implode($errors, "
\n"); + $errormsg = implode("
\n", $errors); } } @@ -195,7 +195,7 @@
@@ -206,7 +206,7 @@
diff --git a/edit_group.php b/edit_group.php index ff42a4b..0d6a635 100644 --- a/edit_group.php +++ b/edit_group.php @@ -79,7 +79,7 @@ $errormsg = 'Group update failed; check log files.'; } } else { - $errormsg = implode($errors, "
\n"); + $errormsg = implode("
\n", $errors); } } @@ -88,6 +88,45 @@ + +
+
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +

Positive integer.

+
+
+ +
+
+ + Remove group + +
+
+
+
+
+
+
@@ -111,7 +150,7 @@ - $u_userid) { $user = $ac->get_user_by_id($u_id); ?> @@ -141,7 +180,7 @@ - $u_userid) { $user = $ac->get_user_by_id($u_id); ?> @@ -162,45 +201,6 @@
- -
-
- -
-
-
- -
- -
- -
-
- -
- -
- -

Positive integer.

-
-
- -
-
- - Remove group - -
-
-
-
-
-
-
diff --git a/edit_user.php b/edit_user.php index b18da80..33da62b 100644 --- a/edit_user.php +++ b/edit_user.php @@ -35,11 +35,17 @@ $field_login_count = $cfg['field_login_count']; $field_last_login = $cfg['field_last_login']; $field_last_modified = $cfg['field_last_modified']; +$field_last_modi_file = $cfg['field_last_modi_file']; $field_bytes_in_used = $cfg['field_bytes_in_used']; $field_bytes_out_used = $cfg['field_bytes_out_used']; $field_files_in_used = $cfg['field_files_in_used']; $field_files_out_used = $cfg['field_files_out_used']; +$field_client_ip = $cfg['field_client_ip']; +$field_server_ip = $cfg['field_server_ip']; +$field_protocol = $cfg['field_protocol']; +$field_acessed = $cfg['field_acessed']; + if (empty($_REQUEST[$field_id])) { header("Location: users.php"); die(); @@ -62,6 +68,7 @@ $warnmsg = 'Main group does not exist; cannot find GID '.$ugid.' in the database.'; } $ad_gid = $ac->parse_groups($userid); + $logins = $ac->get_login_hst_by_userid($userid); } } @@ -113,7 +120,7 @@ /* data validation passed */ if (count($errors) == 0) { /* remove all groups */ - while (list($g_gid, $g_group) = each($groups)) { + foreach ($groups as $g_gid => $g_group) { if (!$ac->remove_user_from_group($userid, $g_gid)) { array_push($errors, 'Cannot remove user "'.$userid.'" from group "'.$g_group.'"; see log files for more information.'); break; @@ -143,12 +150,12 @@ $user = $ac->get_user_by_id($id); } } else { - $errormsg = implode($errors, "
\n"); + $errormsg = implode("
\n", $errors); } if (empty($errormsg)) { /* add all groups */ if (isset($_REQUEST[$field_ad_gid])) { - while (list($g_key, $g_gid) = each($_REQUEST[$field_ad_gid])) { + foreach ($_REQUEST[$field_ad_gid] as $g_key => $g_gid) { if (!$ac->is_valid_id($g_gid)) { $warnmsg = 'Adding additional group failed; at least one of the additional groups had an invalid GID.'; continue; @@ -199,71 +206,7 @@ - -
-
-
-

- User statistics -

-
-
-
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- MB" readonly /> -
-
- -
- -
- MB" readonly /> -
-
- -
- -
- -
-
- -
- -
- -
-
-
-
-
-
-
+
@@ -296,7 +239,7 @@
@@ -307,7 +250,7 @@
@@ -397,6 +340,112 @@
+ +
+
+
+

+ User statistics +

+
+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ MB" readonly /> +
+
+ +
+ +
+ MB" readonly /> +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+
+
+
+ +
+
+
+

+ Login History +

+
+
+
+ +

Currently there are no history login with this user.

+ + + + + + + + + + + + + + + + +
Login DateProtocolIP
+ +
+
+
+
diff --git a/groups.php b/groups.php index fc964ac..ad8e467 100644 --- a/groups.php +++ b/groups.php @@ -65,7 +65,7 @@ - $g_group) { $n_main = $ac->get_user_count_by_gid($g_gid); $n_add = $ac->get_user_add_count_by_gid($g_gid); ?> diff --git a/includes/AdminClass.php b/includes/AdminClass.php index 98b4a4e..d83e99a 100644 --- a/includes/AdminClass.php +++ b/includes/AdminClass.php @@ -61,7 +61,7 @@ class AdminClass { * initialize the database connection via ezSQL_mysql * @param Array $cfg configuration array retrieved from config.php to store in the object */ - function AdminClass($cfg) { + function __construct($cfg) { $this->config = $cfg; // if db_type is not set, default to mysqli if (!isset($cfg['db_type']) || $cfg['db_type'] == "mysqli") { @@ -99,7 +99,7 @@ function parse_groups($userid = false) { foreach ($result as $group) { $names = explode(",", $group->$field_members); reset($names); - while (list($key, $name) = each($names)) { + foreach ($names as $key => $name) { $data[$name][$group->$field_gid] = $group->$field_groupname; } } @@ -143,6 +143,18 @@ function get_users() { return $result; } + /** + * retrieves all login_history from db and populates an associative array + * @return Array an array containing the records or false on failure + */ + function get_login_hst_by_userid($userid) { + $format = 'SELECT * FROM %s WHERE %s = "%s" ORDER BY %s DESC LIMIT %s'; + $query = sprintf( $format, $this->config['table_login_history'], $this->config['field_userid'], $userid, $this->config['field_acessed'], $this->config['max_login_hst']); + $result = $this->dbConn->get_results($query, ARRAY_A); + if (!$result) return false; + return $result; + } + /** * returns either the total number or the number of empty groups in the db * @param Boolean $only_emtpy @@ -513,7 +525,7 @@ function remove_user_from_group($userid, $gid) { if(strpos($result, $userid) === false) { return true; } - $members_array = explode(",", $result); + $members_array = explode(",", (string)$result); $members_new_array = array_diff($members_array, array("$userid", "")); if (is_array($members_new_array)) { $members_new = implode(",", $members_new_array); diff --git a/includes/ez_sql_core.php b/includes/ez_sql_core.php index 720d060..6b37dc9 100644 --- a/includes/ez_sql_core.php +++ b/includes/ez_sql_core.php @@ -51,6 +51,9 @@ class ezSQLcore var $sql_log_file = false; var $do_profile = false; var $profile_times = array(); + var $func_call = null; + var $last_result = null; + var $from_disk_cache = false; // == TJH == default now needed for echo of debug function var $debug_echo_is_on = true; @@ -164,8 +167,11 @@ function get_row($query=null,$output=OBJECT,$y=0) $this->query($query); } + if ( is_null($this->last_result) ){ + return null; + } // If the output is an object then return object using the row offset.. - if ( $output == OBJECT ) + elseif ( $output == OBJECT ) { return $this->last_result[$y]?$this->last_result[$y]:null; } @@ -618,7 +624,7 @@ function get_set($params) } } - return implode( ', ' , $sql ); + return implode(', ' , $sql); } /** diff --git a/includes/ez_sql_mysqli.php b/includes/ez_sql_mysqli.php index 78f4da9..bb8b84b 100644 --- a/includes/ez_sql_mysqli.php +++ b/includes/ez_sql_mysqli.php @@ -33,6 +33,7 @@ class ezSQL_mysqli extends ezSQLcore { + var $dbh = null; var $dbuser = false; var $dbpassword = false; var $dbname = false; @@ -40,6 +41,8 @@ class ezSQL_mysqli extends ezSQLcore var $dbport = false; var $encoding = false; var $rows_affected = false; + var $result = null; + var $num_rows = 0; /********************************************************************** * Constructor - allow the user to perform a quick connect at the