Wednesday 28 November 2012

DMASOFTLAB Radius Manager SMS Notification Configuration


DMASOFTLAB Radius Manager have a very nice feature of SMS notification for Account Expiry / New Account Activation Message, New Account Activation Code / Password Recovery and many other cool functions that can be done using this feature, however activating it is a bit complex thing to do. As radius manager supplies clickatell HTTP gateway API with there default installation, and I really didn't wanted to purchase the clickatell account because it would be expensive for any mid-large size network, even a small network wouldn't want to pay extra amount. So I decided to create my own HTTP gateway which is connected with my GSM Modem. Following is the complete guide on how you can create your own SMS HTTP GATEWAY.
> http://aacable.wordpress.com/2012/11/26/howto-configure-your-local-http-gateway-using-kannel-on-ubuntu/ (http://aacable.wordpress.com/2012/11/26/howto-configure-your-local-http-gateway-using-kannel-on-ubuntu/)
Once you have a working HTTP gateway , you can move on to RM configuration section.
Howto configure API to make it work with your Local SMS HTTP gateway.
Login to your RM box using terminal.
Open the api.php file by
nano /var/www/radiusmanager/api/api.php
(Change the path if you have RM installed at some other folder)
Now remove all lines and replace them with the following.
<?php
/*****************************************************************************
**        Name: api_sendsms
**
** Description: This function is used to send a SMS messages to a mobile phone.
**        You can call your SMS gateway to send a message to a mobile phone.
**        The function includes an example code of integrating the
**        clickatell.com HTTP -> SMS gateway.
**
** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
**  Syed Jahanziab > I have changed it to use my local sms gateway running on KANNEL , Configured on same box where RM is installed and connected TELTONIKA GSM MODEM with it in VM.
** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
**
**       Input: $mode - SMSMODE_ACCVERIFY: send verification code
**            SMSMODE_WELCOME: send account data
**            SMSMODE_PSWCODE: send new password activation code
**            SMSMODE_NEWPSW: send new password
**        $username - RADIUS user name
**        $password - RADIUS password
**        $firstname - first name of user
**        $lastname - last name of user
**        $address - postal address of user
**        $city - city of user
**        $zip - zip code of user
**        $country - country of user
**        $state - state of user
**        $phone - phone number of user
**        $mobile - mobile number of user
**        $email - email address of user
**        $srvid - associated service id
**        $verifycode - the verification code to send
**        $errmsg - pointer to error message returned by the gateway
**
**      Output: True if API succeeded or false
*****************************************************************************/
function api_sendsms($mode, $username, $password, $firstname, $lastname, $address, $city, $zip, $country, $state, $phone, $mobile, $email, $srvid, $verifycode, &$errmsg)
{
// enter your local sms http gateway credentials here
$api_user     = "kannel";
$api_password = "kannel";
switch ($mode)
{
case SMSMODE_ACCVERIFY:
$body = "Enter the following verification code in UCP: $verifycode";
break;
case SMSMODE_WELCOME:
$body = "Welcome new user! Your user name is $username, your password is $password";
break;
case SMSMODE_PSWCODE:
$body = "New password activation code: $verifycode";
break;
case SMSMODE_NEWPSW:
$body = "Your new password: $password";
break;
}
// return success (uncomment the following lines in testing environments only)
//  print $body;
//  return true;
// implement your own SMS gateway in the following block
$body = rawurlencode($body);
$ch = curl_init();
// change the IP and id password in the below line to match your local config. syed jahanzaib
curl_setopt($ch, CURLOPT_URL, "http://101.11.11.250:13013/cgi-bin/sendsms?user=$api_user&password=$api_password&api_id=$api_id&to=$mobile&text=$body");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);
// uncomment this to see the result from clickatell.com HTTP->SMS gateway
//  print $res;
if (substr($res, 0 , 4) ==  "ERR:")
{
$errmsg = $res;
return false;
}
// SMS sent successfully
return true;
}
?>
That's It. Your RM is ready to send sms using your local SMS HTTP gateway.
.
Howto send Account Expiry Warning to User
Logon to RM Admin Panel,
Goto System/ System Settings
At the bottom of the page, You will see Notification's section.
At the Expiry warning: Type the number of days you want RM to send account expiry warning before the account expires.
As showed in the image below . . .
http://aacable.files.wordpress.com/2012/11/sms-notifi-when-expir-setting.png&h=410
.
Howto Recover User Password via FORGOT PASSWORD link at user.php (ver 4.x or above)
User can recover his forgotten password using Forgot my password at (http://101.11.11.250/radiusmanager/passwd.php) user.php
For Example
http://aacable.files.wordpress.com/2012/11/forgot-password.png&h=323 .
http://aacable.files.wordpress.com/2012/11/forgot-password-2.png&h=303
After submission the mobile number, user will receive A code on his mobile number (If he have defined valid number while registering the account. Then after entering the code in the below screen, he will receive new password.
As showed in the image below . . .
http://aacable.files.wordpress.com/2012/11/enter-code.png&h=74
http://aacable.files.wordpress.com/2012/11/new-passwoprd-sms.png&h=78
.
.
Regard's
Syed Jahanzaib





































3 comments:

  1. Hello, I am getting an error can you help me out... Where in the reg.newuser.tlp do a put this code? For some reason it tells me that i have an error in the beginning of the code where starts with function.. So could you send me en example where to put that code?
    daniboy1969@gmail.com

    ReplyDelete
  2. Also SMS notifications can be connected in http://www.intistele.com/ . There are personal account for your convenience. Really do a good job.

    ReplyDelete
  3. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Digital Mobile Marketing
    SMS API
    SMS Marketing

    ReplyDelete