
capral
Postitusi: 3
Tase: 1
Olek: Offline
Hinnang:    
|
Miks tuleb ainult sönum sisuga: ? <<< küsimärgiga ?
[PHP]<?php
// check that the request comes from Fortumo server
if(!in_array($_SERVER['REMOTE_ADDR'],
array('81.20.151.38', '81.20.148.122', '209.20.83.207'))) {
die("Error: Unknown IP");
}
// check the signature
$secret = ''; // insert your secret between ''
if(!empty($secret) && !check_signature($_GET, $secret)) {
die("Error: Invalid signature");
}
$sender = $_GET['sender'];
$message1 = $_GET['message1'];
$message = $_GET['message'];
$sonad = explode(' ', strtoupper($message));
if($sonad[0]=='TXT' && $sonad[1]=='JOULUVANA1' && $sonad[2] == 'SALM')
{
$random_fail = "salmid.txt";
srand((double)microtime()*1000000);
}
if($sonad[0]=='TXT' && $sonad[1]=='JOULUVANA1' && $sonad[2] == 'NALI')
{
$random_fail = "nali.txt";
srand((double)microtime()*1000000);
}
if($sonad[0]=='TXT' && $sonad[1]=='JOULUVANA1' && $sonad[2] == 'TEST')
{
$random_fail = "testime.txt";
srand((double)microtime()*1000000);
}
if (file_exists($random_fail)) {
$arry_txt = preg_split("/RIDA/", join('', file($random_fail)));
echo $arry_txt[rand(0, sizeof($arry_txt) -1)];
}
// do something with $sender and $message
$reply = "$arry_txt";
// print out the reply
echo($reply);
function check_signature($params_array, $secret) {
ksort($params_array);
$str = '';
foreach ($params_array as $k=>$v) {
if($k != 'sig') {
$str .= "$k=$v";
}
}
$str .= $secret;
$signature = md5($str);
return ($params_array['sig'] == $signature);
}
?>[PHP]
|