-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHook.php
32 lines (32 loc) · 1.1 KB
/
Hook.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
<?php
declare(strict_types=1);
$input = file_get_contents("php://input");
if (isset($input)) {
$telegram_ip_ranges = [
['lower' => '149.154.160.0', 'upper' => '149.154.175.255'],
['lower' => '91.108.4.0', 'upper' => '91.108.7.255'],
];
$ip_dec = (float) sprintf("%u", ip2long($_SERVER['REMOTE_ADDR']));
$ok = false;
foreach ($telegram_ip_ranges as $telegram_ip_range) {
$lower_dec = (float) sprintf("%u", ip2long($telegram_ip_range['lower']));
$upper_dec = (float) sprintf("%u", ip2long($telegram_ip_range['upper']));
if ($ip_dec >= $lower_dec and $ip_dec <= $upper_dec) {
$ok = true;
break;
}
}
if ($ok) {
if (function_exists('exec')) {
if (!is_dir('temp')) {
mkdir('temp', 0700);
}
$temp = "temp/.up_" . rand(0, 1000) . "" . time();
file_put_contents($temp, $input);
exec("php main.php $temp > /dev/null &");
} /*not recommended beater way is use exec function */
else {
require_once 'main.php';
}
}
}