-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendsticker.php
82 lines (77 loc) · 2.58 KB
/
sendsticker.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?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();
}
$theme = MP::getSettingInt('theme');
$lng = MP::initLocale1();
$id = null;
if(isset($_POST['c'])) {
$id = $_POST['c'];
} else if(isset($_GET['c'])) {
$id = $_GET['c'];
} else {
die();
}
$reply_to = null;
if(isset($_POST['reply_to'])) {
$reply_to = $_POST['reply_to'];
} else if(isset($_GET['reply_to'])) {
$reply_to = $_GET['reply_to'];
}
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');
include 'themes.php';
Themes::setTheme($theme);
try {
$MP = MP::getMadelineAPI($user);
echo '<head><title>'.MP::x($lng['send_message']).'</title>';
echo Themes::head();
echo '</head>';
echo Themes::bodyStart();
if(isset($_GET['id'])) {
$MP = MP::getMadelineAPI($user);
$params = ['peer' => $id, 'message' => ''];
if($reply_to) {
$params['reply_to_msg_id'] = $reply_to;
}
$params['media'] = ['_' => 'document', 'id' => $_GET['id'], 'access_hash' => $_GET['access_hash'], 'attributes' => []];
$MP->messages->sendMedia($params);
header('Location: chat.php?c='.$id);
die();
} else if(isset($_GET['set'])) {
echo '<div><a href="sendsticker.php?c='.$id.($reply_to?'&reply_to='.$reply_to:'').'">'.MP::x($lng['back']).'</a></div><br>';
$set = $_GET['set'];
$sets = $MP->messages->getAllStickers()['sets'];
$s2 = null;
foreach($sets as $v) {
if(strval($v['id']) == $set) {
$s2 = $v;
break;
}
}
$documents = $MP->messages->getStickerSet(['stickerset' => ['_' => 'inputStickerSetID', 'id' => $s2['id'], 'access_hash' => $s2['access_hash']]])['documents'];
echo '<b>'.MP::dehtml($s2['title']).'</b><br>';
foreach($documents as $v) {
echo '<a href="sendsticker.php?c='.$id.'&id='.$v['id'].'&access_hash='.$v['access_hash'].($reply_to?'&reply_to='.$reply_to:'').'"><img src="file.php?sticker='.$v['id'].'&access_hash='.$v['access_hash'].'&p=rsprev"></a>';
}
} else {
echo '<div><a href="chat.php?c='.$id.'">'.MP::x($lng['back']).'</a></div><br>';
$sets = $MP->messages->getAllStickers()['sets'];
foreach($sets as $v) {
echo '<a href="sendsticker.php?c='.$id.'&set='.$v['id'].($reply_to?'&reply_to='.$reply_to:'').'">'.MP::x($v['title']).'</a><br>';
}
}
echo Themes::bodyEnd();
} catch (Exception $e) {
echo $e;
}