-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
27 lines (21 loc) · 819 Bytes
/
send.php
File metadata and controls
27 lines (21 loc) · 819 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
<?php
ob_start();
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
if(!$_SESSION['valid'])
header('Location: index.php');
if(file_exists('passwd'))
$dict = json_decode(file_get_contents('passwd'), true);
else
$dict = array();
if ($_POST['from_user'] !== $_SESSION['username'] || !array_key_exists($_POST['to_user'], $dict))
return;
if(strcmp($_POST['from_user'], $_POST['to_user']) < 0)
$chat_file_path = 'chat/'.$_POST['from_user'].'|'.$_POST['to_user'];
else
$chat_file_path = 'chat/'.$_POST['to_user'].'|'.$_POST['from_user'];
file_put_contents($chat_file_path, $_POST['from_user'].' '.bin2hex(htmlspecialchars($_POST['message']))."\n", FILE_APPEND);
file_put_contents('new_message/'.$_POST['to_user'].'/'.$_POST['from_user'], '');
echo '';
?>