forked from shinovon/mpgram-web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
addstickers.php
53 lines (48 loc) · 1.64 KB
/
addstickers.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
<?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::initLocale();
$name = $_POST['n'] ?? $_GET['n'] ?? die;
$stickerset = ['_' => 'inputStickerSetShortName', 'short_name' => $name];
$returnurl = $_POST['u'] ?? $_GET['u'] ?? null;
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);
if(isset($_GET['c'])) {
if(!$returnurl) $returnurl = '/chats.php';
$MP->messages->installStickerSet(['stickerset' => $stickerset, 'archived' => false]);
header("Location: $returnurl");
die;
}
if(!$returnurl) $returnurl = $_SERVER['HTTP_REFERER'] ?? '';
$r = $MP->messages->getStickerSet(['stickerset' => $stickerset]);
echo '<head><title>'.MP::x($r['set']['title']).'</title>';
echo Themes::head();
echo '</head>';
echo Themes::bodyStart();
echo '<b>'.MP::x($r['set']['title']).'</b><br>';
echo '<a href="addstickers.php?n='.$name.'&u='.urlencode($returnurl).'&c">'.MP::x($lng['install_stickerset']).'</a>';
echo '<p>';
foreach($r['documents'] as $d) {
echo '<img src="file.php?sticker='.$d['id'].'&access_hash='.$d['access_hash'].'&p=rsprev">';
}
echo '</p>';
echo Themes::bodyEnd();
} catch (Exception $e) {
echo $e;
}