Last active
June 18, 2020 08:02
-
-
Save kovenko/146cf441c0558de4cb8b113c4414ac9d to your computer and use it in GitHub Desktop.
Goip SMS sender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mock = false; | |
$recepient = "+7987XXXXXXX"; | |
$gateway = "192.168.0.10"; | |
$user = "user"; | |
$password = "password"; | |
$method = "2"; | |
$providers = [ | |
'1' => 'Beeline', | |
'2' => 'Megafon-2', | |
'3' => 'Megafon-3', | |
'6' => 'MTS-6', | |
'7' => 'Tele2-7', | |
'8' => 'MTS-8', | |
]; | |
$selectedProvider = '8'; | |
$message = str_replace(" ", "+", "Тестовое сообщение отправлено через оператора '$providers[$selectedProvider]'"); | |
$url = "http://{$gateway}/en/dosend.php?USERNAME={$user}&PASSWORD={$password}&smsprovider=2&smsnum={$recepient}&method={$method}&Memo=hellotest_1"; | |
echo "Send: $url\n"; | |
if ($mock) { | |
$response = <<<RESPONSE | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<link href="style.css" rel="stylesheet" type="text/css"> | |
<title>Sending Messge</title> | |
</head> | |
<body> | |
sending messageпјљhellotest_1 <br>total will send: 1 <br><script language='javascript'>window.location = 'resend.php?messageid=253021&USERNAME=user&PASSWORD=password'</script> | |
RESPONSE; | |
} else { | |
$response = file_get_contents($url); | |
} | |
echo "Reply: $response\n\n"; | |
echo "Headers:\n"; | |
echo print_r($http_response_header, true); | |
echo "\n\n"; | |
$session = null; | |
foreach ($http_response_header as $hdr) { | |
if (preg_match('/^Set-Cookie:\s*\S*\s*(PHPSESSID=[^; \n]+)/s', $hdr, $matches)) { | |
$session = $matches[1]; | |
echo "{$session}\n"; | |
} | |
} | |
if (preg_match('/messageid=(\d+)/', $response, $matches)) { | |
echo "Message Id: {$matches[1]} sended to '$recepient', provider '$providers[$selectedProvider]'\n\n"; | |
} else { | |
echo "Message can't send '$recepient', provider '$providers[$selectedProvider]'\n\n"; | |
exit; | |
} | |
$url = "http://{$gateway}/en/resend.php?USERNAME={$user}&PASSWORD={$password}&messageid={$matches[1]}&{$session}"; | |
echo "Send: $url\n"; | |
if ($mock) { | |
$response = <<<RESPONSE | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<link href="../style.css" rel="stylesheet" type="text/css"> | |
<title>Resending Messge</title> | |
</head> | |
<body> | |
total: 1 <br>253021 5 584951 <br>len:16 PASSWORD 584951 <br>len:12 SEND 584951 | |
<br>SEND 584951 253040 +79872976220 | |
(020202 megafon-2) <br>len:20 WAIT 584951 253040 | |
<br>WAIT SEND 253040 253040 <br>len:21 OK 584951 253040 23 | |
<br><font color='#00FF00'>SEND: 253040 +79872976220 ok(020202 megafon-2)</font><br>All sendings done!<br><br><a href=sendinfo.php?id=253021 target=main><font size=2'>Click me to check details.</font></a></body> | |
</html> | |
RESPONSE; | |
} else { | |
$response = file_get_contents($url); | |
} | |
echo "Reply: $response\n\n"; | |
echo "Headers:\n"; | |
echo print_r($http_response_header, true); | |
echo "\n\n"; | |
foreach ($http_response_header as $hdr) { | |
if (preg_match('/^Set-Cookie:\s*\S*\s*(PHPSESSID=[^; \n]+)/s', $hdr, $matches)) { | |
$session = $matches[1]; | |
echo "{$session}\n"; | |
} | |
} | |
echo "\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment