-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathedit_chat.php
More file actions
29 lines (23 loc) · 892 Bytes
/
edit_chat.php
File metadata and controls
29 lines (23 loc) · 892 Bytes
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
<?php
// Include the database connection file
require_once 'bootstrap.php';
require_once 'db.php';
if (empty($_SESSION['user_data']['userid']) || empty($_SESSION['authorized'])) {
http_response_code(401);
exit('User not authenticated');
}
$user = $_SESSION['user_data']['userid'];
// Check if the 'chat_id' and 'title' variables are set in the $_POST array
if(isset($_POST['chat_id']) && isset($_POST['title'])) {
$chat_id = filter_input(INPUT_POST, 'chat_id', FILTER_SANITIZE_STRING);
$new_title = filter_input(INPUT_POST, 'title', FILTER_SANITIZE_STRING);
if (!$chat_id || !$new_title) {
die("invalid input");
}
if (!verify_user_chat($user, $chat_id)) {
http_response_code(403);
exit('Not authorized to edit this chat');
}
// Use the existing update_chat_title function
update_chat_title($user, $chat_id, $new_title);
}