Jump to content
php.lv forumi

fortumo


letslearn

Recommended Posts

Sveicināti!Šeit ir automātiskais kods,ko piedāvā fortumo,bet es nesaprotu kas ir jāliek pie secret??

<?php

 

//set true if you want to use script for billing reports

//first you need to enable them in your account

$billing_reports_enabled = false;

 

// check that the request comes from Fortumo server

if(!in_array($_SERVER['REMOTE_ADDR'],

array('81.20.151.38', '81.20.148.122', '79.125.125.1', '209.20.83.207'))) {

die("Error: Unknown IP");

}

 

// check the signature <-šito galīgi nesaprotu

$secret = ''; // insert your secret between ''

if(empty($secret) || !check_signature($_GET, $secret)) {

die("Error: Invalid signature");

}

 

$sender = $_GET['sender'];

$message = $_GET['message'];

 

// do something with $sender and $message

$reply = "Thank you $sender for sending $message";

 

// print out the reply

echo($reply);

 

//customize this according to your needs

if($billing_reports_enabled

&& preg_match("/Failed/i", $_GET['status'])

&& preg_match("/MT/i", $_GET['billing_type'])) {

// find message by $_GET['message_id'] and suspend it

}

 

 

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);

}

?>

Varat pateikt kas tur jāliek?

Link to comment
Share on other sites

Lūdzu ieliec kodu attiecīgi koda tagos, lai var saprast kodu!

Pie secret jānorāda visticamāk ir kāds slepenais kods, bet izkatās, ka tas varētu būt kaut kas no profila, jo

 

die("Error: Invalid signature");

Raisa, pēc kaut kāda paraksta vai ko tādu, t.i saistību ar drošību.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...