smsgateway/smsSender.php

63 lines
1.7 KiB
PHP
Raw Normal View History

2011-09-29 16:09:59 +00:00
<?php
class smsSender
{
2011-09-29 16:50:21 +00:00
protected $sessionId = null;
protected $backend;
2011-09-29 16:09:59 +00:00
2011-09-29 16:50:21 +00:00
public function __construct($backend, $sessionId)
{
$this->sessionId = $sessionId;
$this->backend = $backend;
}
2011-09-29 16:09:59 +00:00
2011-09-29 16:50:21 +00:00
public function login($username, $password)
{
try
{
$token = $this->backend->getToken($username, $password, $_SERVER['REMOTE_ADDR'], $this->sessionId);
}
catch (Exception $e)
{
throw new Exception('Authentication failed. Reason: ' . $e->getMessage());
}
$this->backend->auditLog($_SERVER['REMOTE_ADDR'], 'login', 'Successful login by ' . $username);
return $token;
}
2011-09-29 16:09:59 +00:00
2011-09-29 16:50:21 +00:00
public function send($token, $recipient, $message, $passwordLocations)
{
/*
if (valid_token($token)
{
if (send_sms($recipient, $message))
{
audit_log('Successful message sending by $token->username at $ip');
message_log('$message successfully sent to $recipient');
}
else
{
audit_log('Message sending failed for $token->username at $ip');
}
}
else
{
audit_log('Message sending attempt from $ip with invalid token');
throw new Exception('Authentication failed. Reason: Invalid Token');
}
*/
/* TODO: implement */
throw new Exception('This feature is not yet implemented');
}
2011-09-29 16:09:59 +00:00
2011-09-29 16:50:21 +00:00
public function logout($token)
{
/*
delete_token($token);
audit_log('$token->username logged out at $ip');
return 'success';
*/
/* TODO: implement */
throw new Exception('This feature is not yet implemented');
}
2011-09-29 16:09:59 +00:00
}