Skip to content

Commit 21dc26b

Browse files
authored
Merge branch 'develop' into ticket-redaction
2 parents 6a8d2cf + b803ba4 commit 21dc26b

File tree

185 files changed

+4207
-2980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+4207
-2980
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
This file documents all notable changes made to ITFlow.
44

5+
## [25.02.4]
6+
7+
### Fixed
8+
- Resolved issue preventing the addition or editing of licenses when no vendor was selected.
9+
- Fixed several undeclared variables in AJAX contact details.
10+
- Corrected the contact ticket count display.
11+
- Addressed an issue where clicking "More Details" in AJAX contact/asset details failed to include the `client_id` in the URL.
12+
- Fixed an issue with recurring invoices in the client URL: clicking "Inactive" or "Active" would unexpectedly navigate away from the client section.
13+
- Added new php function getFieldById() to return a record using just an id and sanitized as well.
14+
515
## [25.02.3]
616

717
### Fixed

admin_role.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
// Default Column Sortby Filter
4-
$sort = "user_role_is_admin";
4+
$sort = "role_is_admin";
55
$order = "DESC";
66

77
require_once "includes/inc_all_admin.php";
@@ -13,8 +13,8 @@
1313
$sql = mysqli_query(
1414
$mysqli,
1515
"SELECT SQL_CALC_FOUND_ROWS * FROM user_roles
16-
WHERE (user_roles.user_role_name LIKE '%$q%' OR user_roles.user_role_description LIKE '%$q%')
17-
AND user_roles.user_role_archived_at IS NULL
16+
WHERE (role_name LIKE '%$q%' OR role_description LIKE '%$q%')
17+
AND role_archived_at IS NULL
1818
ORDER BY $sort $order LIMIT $record_from, $record_to"
1919
);
2020

@@ -53,14 +53,14 @@
5353
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
5454
<tr>
5555
<th>
56-
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_role_name&order=<?php echo $disp; ?>">
57-
Role <?php if ($sort == 'user_role_name') { echo $order_icon; } ?>
56+
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=role_name&order=<?php echo $disp; ?>">
57+
Role <?php if ($sort == 'role_name') { echo $order_icon; } ?>
5858
</a>
5959
</th>
6060
<th>Members</th>
6161
<th>
62-
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_role_is_admin&order=<?php echo $disp; ?>">
63-
Admin <?php if ($sort == 'user_role_is_admin') { echo $order_icon; } ?>
62+
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=role_is_admin&order=<?php echo $disp; ?>">
63+
Admin <?php if ($sort == 'role_is_admin') { echo $order_icon; } ?>
6464
</a>
6565
</th>
6666
<th class="text-center">Action</th>
@@ -70,17 +70,17 @@
7070
<?php
7171

7272
while ($row = mysqli_fetch_array($sql)) {
73-
$role_id = intval($row['user_role_id']);
74-
$role_name = nullable_htmlentities($row['user_role_name']);
75-
$role_description = nullable_htmlentities($row['user_role_description']);
76-
$role_admin = intval($row['user_role_is_admin']);
77-
$role_archived_at = nullable_htmlentities($row['user_role_archived_at']);
73+
$role_id = intval($row['role_id']);
74+
$role_name = nullable_htmlentities($row['role_name']);
75+
$role_description = nullable_htmlentities($row['role_description']);
76+
$role_admin = intval($row['role_is_admin']);
77+
$role_archived_at = nullable_htmlentities($row['role_archived_at']);
7878

7979
// Count number of users that have each role
80-
$sql_role_user_count = mysqli_query($mysqli, "SELECT COUNT(users.user_id) FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_role = $role_id AND user_archived_at IS NULL");
80+
$sql_role_user_count = mysqli_query($mysqli, "SELECT COUNT(user_id) FROM users WHERE user_role_id = $role_id AND user_archived_at IS NULL");
8181
$role_user_count = mysqli_fetch_row($sql_role_user_count)[0];
8282

83-
$sql_users = mysqli_query($mysqli, "SELECT * FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_role = $role_id AND user_archived_at IS NULL");
83+
$sql_users = mysqli_query($mysqli, "SELECT * FROM users WHERE user_role_id = $role_id AND user_archived_at IS NULL");
8484
// Initialize an empty array to hold user names
8585
$user_names = [];
8686

@@ -90,7 +90,7 @@
9090
}
9191

9292
// Convert the array of user names to a comma-separated string
93-
$user_names_string = implode(",", $user_names) ;
93+
$user_names_string = implode(",", $user_names);
9494

9595
if (empty($user_names_string)) {
9696
$user_names_string = "-";

admin_settings_invoice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<div class="input-group-prepend">
7878
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
7979
</div>
80-
<input type="text" class="form-control" name="config_recurring_prefix" placeholder="Recurring Prefix" value="<?php echo nullable_htmlentities($config_recurring_prefix); ?>" required>
80+
<input type="text" class="form-control" name="config_recurring_invoice_prefix" placeholder="Recurring Invoice Prefix" value="<?php echo nullable_htmlentities($config_recurring_invoice_prefix); ?>" required>
8181
</div>
8282
</div>
8383

@@ -87,7 +87,7 @@
8787
<div class="input-group-prepend">
8888
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
8989
</div>
90-
<input type="number" min="0" class="form-control" name="config_recurring_next_number" placeholder="Next Recurring Number" value="<?php echo intval($config_recurring_next_number); ?>" required>
90+
<input type="number" min="0" class="form-control" name="config_recurring_invoice_next_number" placeholder="Next Recurring Invoice Number" value="<?php echo intval($config_recurring_invoice_next_number); ?>" required>
9191
</div>
9292
</div>
9393

admin_settings_theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
?>
2121

22-
<div class="col-3 text-center mb-3">
22+
<div class="col-4 text-center mb-3">
2323
<div class="form-group">
2424
<div class="custom-control custom-radio">
2525
<input class="custom-control-input" type="radio" onchange="this.form.submit()" id="customRadio<?php echo $theme_color; ?>" name="edit_theme_settings" value="<?php echo $theme_color; ?>" <?php if ($config_theme == $theme_color) { echo "checked"; } ?>>

admin_user.php

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,25 @@
66

77
require_once "includes/inc_all_admin.php";
88

9-
10-
//Rebuild URL
11-
$url_query_strings_sort = http_build_query($get_copy);
9+
// User Type Filter
10+
if (isset($_GET['type']) && $_GET['type'] == "client") {
11+
$type_filter = "client";
12+
$type_query = "AND user_type = 2";
13+
} else {
14+
$type_filter = "user";
15+
$type_query = "AND user_type = 1";
16+
}
1217

1318
$sql = mysqli_query(
1419
$mysqli,
15-
"SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings, user_roles
16-
WHERE users.user_id = user_settings.user_id
17-
AND user_settings.user_role = user_roles.user_role_id
18-
AND (user_name LIKE '%$q%' OR user_email LIKE '%$q%')
20+
"SELECT SQL_CALC_FOUND_ROWS * FROM users
21+
LEFT JOIN user_roles ON user_role_id = role_id
22+
LEFT JOIN user_settings ON users.user_id = user_settings.user_id
23+
LEFT JOIN contacts ON users.user_id = contact_user_id
24+
LEFT JOIN clients ON contact_client_id = client_id
25+
WHERE (user_name LIKE '%$q%' OR user_email LIKE '%$q%')
1926
AND user_archived_at IS NULL
27+
$type_query
2028
ORDER BY $sort $order LIMIT $record_from, $record_to"
2129
);
2230

@@ -36,6 +44,7 @@
3644
<div class="dropdown-menu">
3745
<!--<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#userInviteModal"><i class="fas fa-paper-plane mr-2"></i>Invite User</a>-->
3846
<?php if ($num_rows[0] > 1) { ?>
47+
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportUserModal"><i class="fa fa-fw fa-download mr-2"></i>Export</a>
3948
<div class="dropdown-divider"></div>
4049
<a class="dropdown-item text-danger" href="#" data-toggle="modal" data-target="#resetAllUserPassModal"><i class="fas fa-skull-crossbones mr-2"></i>IR</a>
4150
<?php } ?>
@@ -55,8 +64,11 @@
5564
</div>
5665
</div>
5766
<div class="col-md-8">
58-
<div class="float-right">
59-
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#exportUserModal"><i class="fa fa-fw fa-download mr-2"></i>Export</button>
67+
<div class="btn-toolbar float-right">
68+
<div class="btn-group mr-2">
69+
<a href="?type=user" class="btn btn-<?php if ($type_filter == "user"){ echo "primary"; } else { echo "default"; } ?>"><i class="fa fa-fw fa-user-shield mr-2"></i>User</a>
70+
<a href="?type=client" class="btn btn-<?php if ($type_filter == "client"){ echo "primary"; } else { echo "default"; } ?>"><i class="fa fa-fw fa-user mr-2"></i>Client</a>
71+
</div>
6072
</div>
6173
</div>
6274
</div>
@@ -77,8 +89,8 @@
7789
</a>
7890
</th>
7991
<th>
80-
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_role&order=<?php echo $disp; ?>">
81-
Role <?php if ($sort == 'user_role') { echo $order_icon; } ?>
92+
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=role_name&order=<?php echo $disp; ?>">
93+
Role <?php if ($sort == 'role_name') { echo $order_icon; } ?>
8294
</a>
8395
</th>
8496
<th>
@@ -90,6 +102,13 @@
90102
<th>
91103
Last Login
92104
</th>
105+
<?php if ($type_filter === "client") { ?>
106+
<th>
107+
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
108+
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
109+
</a>
110+
</th>
111+
<?php } ?>
93112
<th class="text-center">Action</th>
94113
</tr>
95114
</thead>
@@ -116,10 +135,14 @@
116135
$mfa_status_display = "<i class='fas fa-fw fa-lock text-success'></i>";
117136
}
118137
$user_config_force_mfa = intval($row['user_config_force_mfa']);
119-
$user_role = $row['user_role'];
120-
$user_role_display = nullable_htmlentities($row['user_role_name']);
138+
$user_role = intval($row['user_role_id']);
139+
$user_role_display = nullable_htmlentities($row['role_name']);
121140
$user_initials = nullable_htmlentities(initials($user_name));
122141

142+
$contact_id = intval($row['contact_id']);
143+
$client_id = intval($row['client_id']);
144+
$client_name = nullable_htmlentities($row['client_name']);
145+
123146
$sql_last_login = mysqli_query(
124147
$mysqli,
125148
"SELECT * FROM logs
@@ -139,7 +162,7 @@
139162
}
140163

141164
// Get User Client Access Permissions
142-
$user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_permissions WHERE user_id = $user_id");
165+
$user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_client_permissions WHERE user_id = $user_id");
143166
$client_access_array = [];
144167
while ($row = mysqli_fetch_assoc($user_client_access_sql)) {
145168
$client_access_array[] = intval($row['client_id']);
@@ -178,6 +201,9 @@
178201
<td><?php echo $user_status_display; ?></td>
179202
<td class="text-center"><?php echo $mfa_status_display; ?></td>
180203
<td><?php echo $last_login; ?></td>
204+
<?php if ($type_filter === "client") { ?>
205+
<td><?php echo $client_name; ?></td>
206+
<?php } ?>
181207
<td>
182208
<?php if ($user_id !== $session_user_id) { // Prevent modifying self ?>
183209
<div class="dropdown dropleft text-center">

ajax.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
require_once "config.php";
1010
require_once "functions.php";
11-
require_once "check_login.php";
11+
require_once "includes/check_login.php";
1212
require_once "plugins/totp/totp.php";
1313

1414
/*
@@ -165,7 +165,7 @@
165165
}
166166

167167
/*
168-
* Generates public/guest links for sharing logins/docs
168+
* Generates public/guest links for sharing credentials/docs
169169
*/
170170
if (isset($_GET['share_generate_link'])) {
171171
enforceUserPermission('module_support', 2);
@@ -207,23 +207,23 @@
207207
$item_name = sanitizeInput($row['file_name']);
208208
}
209209

210-
if ($item_type == "Login") {
211-
$login = mysqli_query($mysqli, "SELECT login_name, login_username, login_password FROM logins WHERE login_id = $item_id AND login_client_id = $client_id LIMIT 1");
212-
$row = mysqli_fetch_array($login);
210+
if ($item_type == "Credential") {
211+
$credential = mysqli_query($mysqli, "SELECT credential_name, credential_username, credential_password FROM credentials WHERE credential_id = $item_id AND credential_client_id = $client_id LIMIT 1");
212+
$row = mysqli_fetch_array($credential);
213213

214-
$item_name = sanitizeInput($row['login_name']);
214+
$item_name = sanitizeInput($row['credential_name']);
215215

216216
// Decrypt & re-encrypt username/password for sharing
217-
$login_encryption_key = randomString();
217+
$credential_encryption_key = randomString();
218218

219-
$login_username_cleartext = decryptLoginEntry($row['login_username']);
219+
$credential_username_cleartext = decryptCredentialEntry($row['credential_username']);
220220
$iv = randomString();
221-
$username_ciphertext = openssl_encrypt($login_username_cleartext, 'aes-128-cbc', $login_encryption_key, 0, $iv);
221+
$username_ciphertext = openssl_encrypt($credential_username_cleartext, 'aes-128-cbc', $credential_encryption_key, 0, $iv);
222222
$item_encrypted_username = $iv . $username_ciphertext;
223223

224-
$login_password_cleartext = decryptLoginEntry($row['login_password']);
224+
$credential_password_cleartext = decryptCredentialEntry($row['credential_password']);
225225
$iv = randomString();
226-
$password_ciphertext = openssl_encrypt($login_password_cleartext, 'aes-128-cbc', $login_encryption_key, 0, $iv);
226+
$password_ciphertext = openssl_encrypt($credential_password_cleartext, 'aes-128-cbc', $credential_encryption_key, 0, $iv);
227227
$item_encrypted_credential = $iv . $password_ciphertext;
228228
}
229229

@@ -232,8 +232,8 @@
232232
$share_id = $mysqli->insert_id;
233233

234234
// Return URL
235-
if ($item_type == "Login") {
236-
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key&ek=$login_encryption_key";
235+
if ($item_type == "Credential") {
236+
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key&ek=$credential_encryption_key";
237237
}
238238
else {
239239
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key";
@@ -333,24 +333,24 @@
333333
if (isset($_GET['get_totp_token_via_id'])) {
334334
enforceUserPermission('module_credential');
335335

336-
$login_id = intval($_GET['login_id']);
336+
$credential_id = intval($_GET['credential_id']);
337337

338-
$sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT login_name, login_otp_secret, login_client_id FROM logins WHERE login_id = $login_id"));
339-
$name = sanitizeInput($sql['login_name']);
340-
$totp_secret = $sql['login_otp_secret'];
341-
$client_id = intval($sql['login_client_id']);
338+
$sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT credential_name, credential_otp_secret, credential_client_id FROM credentials WHERE credential_id = $credential_id"));
339+
$name = sanitizeInput($sql['credential_name']);
340+
$totp_secret = $sql['credential_otp_secret'];
341+
$client_id = intval($sql['credential_client_id']);
342342

343343
$otp = TokenAuth6238::getTokenCode(strtoupper($totp_secret));
344344
echo json_encode($otp);
345345

346346
// Logging
347347
// Only log the TOTP view if the user hasn't already viewed this specific login entry recently, this prevents logs filling if a user hovers across an entry a few times
348-
$check_recent_totp_view_logged_sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(log_id) AS recent_totp_view FROM logs WHERE log_type = 'Login' AND log_action = 'View TOTP' AND log_user_id = $session_user_id AND log_entity_id = $login_id AND log_client_id = $client_id AND log_created_at > (NOW() - INTERVAL 5 MINUTE)"));
348+
$check_recent_totp_view_logged_sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(log_id) AS recent_totp_view FROM logs WHERE log_type = 'Credential' AND log_action = 'View TOTP' AND log_user_id = $session_user_id AND log_entity_id = $credential_id AND log_client_id = $client_id AND log_created_at > (NOW() - INTERVAL 5 MINUTE)"));
349349
$recent_totp_view_logged_count = intval($check_recent_totp_view_logged_sql['recent_totp_view']);
350350

351351
if ($recent_totp_view_logged_count == 0) {
352352
// Logging
353-
logAction("Credential", "View TOTP", "$session_name viewed credential TOTP code for $name", $client_id, $login_id);
353+
logAction("Credential", "View TOTP", "$session_name viewed credential TOTP code for $name", $client_id, $credential_id);
354354

355355
}
356356
}

0 commit comments

Comments
 (0)