compute_signature($full_url, $_POST, $correct_password);
//error_log("Correct signature: '$correct_signature'");
return $signature === $correct_signature;
}
function compute_signature($url, $data, $password)
{
ksort($data);
$input = $url;
foreach($data as $key => $value)
$input .= ",$key=$value";
$input .= ",$password";
//error_log("Signed data: '$input'");
return base64_encode(sha1($input, true));
}
}
class KalSMS_OutgoingMessage
{
public $id = '';
public $to;
public $message;
}
class KalSMS_Action
{
public $type;
public $kalsms;
function __construct($kalsms)
{
$this->kalsms = $kalsms;
}
}
class KalSMS_Action_Test extends KalSMS_Action
{
function __construct($kalsms)
{
parent::__construct($kalsms);
$this->type = KalSMS::ACTION_TEST;
}
}
class KalSMS_Action_Incoming extends KalSMS_Action
{
public $from;
public $message;
function __construct($kalsms)
{
parent::__construct($kalsms);
$this->type = KalSMS::ACTION_INCOMING;
$this->from = $_POST['from'];
$this->message = $_POST['message'];
}
function get_response_xml($messages)
{
ob_start();
echo "\n";
echo "";
foreach ($messages as $message)
{
echo "".KalSMS::escape($message->message)."";
}
echo "";
return ob_get_clean();
}
}
class KalSMS_Action_Outgoing extends KalSMS_Action
{
function __construct($kalsms)
{
parent::__construct($kalsms);
$this->type = KalSMS::ACTION_OUTGOING;
}
function get_response_xml($messages)
{
ob_start();
echo "\n";
echo "";
foreach ($messages as $message)
{
echo "".
KalSMS::escape($message->message)."";
}
echo "";
return ob_get_clean();
}
}
class KalSMS_Action_SendStatus extends KalSMS_Action
{
public $status;
public $id;
function __construct($type)
{
$this->type = KalSMS::ACTION_SEND_STATUS;
$this->status = (int)$_POST['status'];
$this->id = $_POST['id'];
}
}