-
Notifications
You must be signed in to change notification settings - Fork 0
/
write.php
64 lines (60 loc) · 1.51 KB
/
write.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
include 'mp.php';
$user = MP::getUser();
if(!$user) {
header('Location: login.php?logout=1');
die();
}
$id = null;
if(isset($_POST['c'])) {
$id = $_POST['c'];
} else if(isset($_GET['c'])) {
$id = $_GET['c'];
} else {
die();
}
header("Content-Type: text/html; charset=utf-8");
header("Cache-Control: private, no-cache, no-store");
function exceptions_error_handler($severity, $message, $filename, $lineno) {
throw new ErrorException($message, 0, $severity, $filename, $lineno);
}
set_error_handler('exceptions_error_handler');
$msg = null;
if(isset($_POST["msg"])) {
$msg = $_POST["msg"];
} else if(isset($_GET["msg"])) {
$msg = $_GET["msg"];
}
if($msg !== null) {
try {
$MP = MP::getMadelineAPI($user);
if(isset($_GET["format"]) || isset($_POST["format"])) {
$MP->messages->sendMessage(['peer' => $id, 'message' => $msg, 'parse_mode' => 'HTML']);
} else {
$MP->messages->sendMessage(['peer' => $id, 'message' => $msg]);
}
header('Location: chat.php?c='.$id);
} catch (Exception $e) {
echo $e->getMessage();
}
die();
}
$name = null;
if(isset($_GET['n'])) {
$name = $_GET['n'];
}
echo '<body>';
echo '<form action="write.php" method="post">';
echo '<input type="hidden" name="c" value="'.$id.'">';
echo '<input type="text" value="" name="msg"><br>';
echo '<input type="submit">';
echo '</form>';
if($name) {
echo '<b>'.$name.'</b><br>';
}
echo '<a href="chat.php?c='.$id.'">Back</a>';
echo '</body>';
?>