Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:gsoc_2008_msg_sms_login [2008/06/07 22:42]
ajay_kumar
dev:gsoc_2008_msg_sms_login [2009/07/06 20:36] (current)
Line 7: Line 7:
 Current login architecture takes into consideration only Sahana Core users, i.e. users who are registered as users in the Sahana system and their record exists in the DB.\\ Current login architecture takes into consideration only Sahana Core users, i.e. users who are registered as users in the Sahana system and their record exists in the DB.\\
 Public usage for potential news alert broadcasts, or public information IVR via SMS can be implemented following the similar approach. The module is being written keeping this in mind. Public usage for potential news alert broadcasts, or public information IVR via SMS can be implemented following the similar approach. The module is being written keeping this in mind.
 +
 +
 +
 +
 +
 +
 +
  
  
 ===== Files to be added: ===== ===== Files to be added: =====
  
-  - **/inc/lib_security/lib_sms_auth.inc**+  - **/mod/msg/lib_sms_main.inc** [Base structure committed to CVS] 
 +     - __Purpose of File:__ Main include file for the SMS System calls other files and performs functions 
 +  - **/mod/msg/lib_sms_handler.inc** [Base structure committed to CVS] 
 +     - __Purpose of File:__ Handles all communication as a result of SMS input. Parse SMS, Check keywords, Trigger corresponding functions as per SMS input 
 +  - **/mod/msg/lib_sms_session.inc** 
 +     - __Purpose of File:__ Provide SMS Based Session management based on caller ID/mobile number 
 +  - **/inc/lib_security/lib_sms_auth.inc** [Base structure committed to CVS] 
 +     - {{dev:june_14_2008-01_24_am_working_code_sms_auth.png|Check Screenshot of working code}}
      - __Purpose of File:__ Provide SMS Based Authorisation as per Sahana Framework draws from lib_auth.inc      - __Purpose of File:__ Provide SMS Based Authorisation as per Sahana Framework draws from lib_auth.inc
   - **/inc/lib_security/lib_sms_acl.inc**   - **/inc/lib_security/lib_sms_acl.inc**
      - __Purpose of File:__ Provide SMS Based Authentication and assigns role to User as per Sahana Framework draws from lib_acl.inc      - __Purpose of File:__ Provide SMS Based Authentication and assigns role to User as per Sahana Framework draws from lib_acl.inc
-  - **/mod/msg/lib_sms_session.inc** +  - **/mod/msg/lib_sms_errors.inc** [Base structure committed to CVS]
-     - __Purpose of File:__ Provide SMS Based Session management based on caller ID/mobile number +
-  - **/mod/msg/lib_sms_errors.inc**+
      - __Purpose of File:__ Errors sent to users as output via SMS on receiving SMS input.      - __Purpose of File:__ Errors sent to users as output via SMS on receiving SMS input.
-  - **/mod/msg/lib_sms_process.inc** 
-     - __Purpose of File:__ Parse SMS, Check keywords, Trigger corresponding functions as per SMS input 
   - **/mod/msg/lib_sms_menu.inc**   - **/mod/msg/lib_sms_menu.inc**
      - __Purpose of File:__ SMS Menu sent to users      - __Purpose of File:__ SMS Menu sent to users
 +
  
  
Line 28: Line 39:
  
   - Add 1 field in table "person_uuid". Field name: mobile_number char(32) NULL UNIQUE. Purpose: Store mobile number of the user in the format "919898989898" without using any special characters.   - Add 1 field in table "person_uuid". Field name: mobile_number char(32) NULL UNIQUE. Purpose: Store mobile number of the user in the format "919898989898" without using any special characters.
-  - Add field in table "users". Field name: "sms_auth_status" varchar(60) NULL DEFAULT active. Purpose: To check if a particular user is authorised to communicate to Sahana Server over SMS.+  - Add field in table "users". Field name: "sms_auth_status" varchar(60) NULL DEFAULT active. Purpose: To check if a particular user is authorised to communicate to Sahana Server over SMS
 + 
 +** This needs to be done in one of the messaging tables. Still to figure out where and how exactly.
  
  
Line 61: Line 74:
 ==== Parser Function: ==== ==== Parser Function: ====
  
-''\\ +<code php> 
-function _shn_msg_parse_short_message($message){\\ +function _shn_msg_parse_short_message($message){ 
-     $parsed_message=array();\\ +     $parsed_message=array(); 
-     $parsed_message = explode(" ", $message);\\ +     $parsed_message = explode(" ", $message); 
-     return $parsed_message;\\ +     return $parsed_message; 
- }''\\+ } 
 +</code>
  
 ==== Small Prototype in PHP Demonstrating the Login via SMS to Sahana DB ==== ==== Small Prototype in PHP Demonstrating the Login via SMS to Sahana DB ====
    
  
-'' +<code php> 
-         <?\\ +         <? 
-         $message=$_GET["msg"];\\+         $message=$_GET["msg"];
  
-         function _shn_msg_parse_short_message($message){\\ +         function _shn_msg_parse_short_message($message){ 
-             $parsed_message=array();\\ +             $parsed_message=array(); 
-             $parsed_message = explode(" ", $message);\\ +             $parsed_message = explode(" ", $message); 
-             return $parsed_message;\\ +             return $parsed_message; 
-         }\\+         }
  
-         $output = _shn_msg_parse_short_message($message);\\ +         $output = _shn_msg_parse_short_message($message); 
-         $count = count($output);\\ +         $count = count($output); 
-         echo "Count = $count <br \>";\\ +         echo "Count = $count <br \>"; 
-         print_r($output);\\ +         print_r($output); 
-         echo "<br \>Login Part:<br \>";\\ +         echo "<br \>Login Part:<br \>"; 
-         if($output[0]=='login')\\ +         if($output[0]=='login'
-         {\\ +         { 
-         $user = $output[1];\\ +         $user = $output[1]; 
-         echo "User name: ".$user;\\ +         echo "User name: ".$user; 
-         echo "<br \>Password = ";\\ +         echo "<br \>Password = "; 
-         for($i=2; $i<$count; $i++){\\ +         for($i=2; $i<$count; $i++){ 
-           $password .= $output[$i];\\ +           $password .= $output[$i]; 
-           if($i!=$count-1) $password .= " "; // to avoid additional space\\ +           if($i!=$count-1) $password .= " "; // to avoid additional space 
-         }\\+         }
  
-         }\\ +         } 
-         echo "\"".$password."\"";\\ +         echo "\"".$password."\""; 
-         $pass = $password;\\+         $pass = $password;
  
-         //Sahana Login replace DB functions from sysconf.inc and /inc/handler_db.inc\\ +         //Sahana Login replace DB functions from sysconf.inc and /inc/handler_db.inc 
-         mysql_connect("localhost", "root", "") or die(mysql_error());\\ +         mysql_connect("localhost", "root", "") or die(mysql_error()); 
-         mysql_select_db("sahana") or die(mysql_error());\\+         mysql_select_db("sahana") or die(mysql_error());
  
-         //Sahana Password building from lib_auth.inc\\ +         //Sahana Password building from lib_auth.inc 
-          $q = "  SELECT p_uuid,salt  FROM users\\ +          $q = "  SELECT p_uuid,salt  FROM users 
-                             WHERE user_name = '$user'";\\ +                             WHERE user_name = '$user'"; 
-          $res=mysql_query($q) or die(mysql_error());\\ +          $res=mysql_query($q) or die(mysql_error()); 
-          if(mysql_num_rows($res)==0){\\ +          if(mysql_num_rows($res)==0){ 
-          echo "User name does not exists";\\ +          echo "User name does not exists"; 
-                         break;\\ +                         break; 
-          }else{\\ +          }else{ 
-          while($result = mysql_fetch_array($res)){\\ +          while($result = mysql_fetch_array($res)){ 
-          $salt=$result['salt'];\\ +          $salt=$result['salt']; 
-          }\\ +          } 
-          echo "<br \>Salt = ".$salt."<br \>"; \\ +          echo "<br \>Salt = ".$salt."<br \>";  
-         \\+          }
  
-          $pwd=substr($pass, 0, 4).$salt.substr($pass, 4); \\+          $pwd=substr($pass, 0, 4).$salt.substr($pass, 4);
  
-          // Create a digest of the password collected from the challenge \\ +          // Create a digest of the password collected from the challenge  
-          $password_digest = md5(trim($pwd)); \\ +          $password_digest = md5(trim($pwd));  
-          echo "Digest : ".$password_digest; \\ +          echo "Digest : ".$password_digest;  
-          // Formulate the SQL to find the user \\+          // Formulate the SQL to find the user 
           $q = "  SELECT p_uuid  FROM users \\           $q = "  SELECT p_uuid  FROM users \\
-                             WHERE user_name = '$user' \\ +                             WHERE user_name = '$user' 
-                             AND password = '$password_digest' and salt='{$salt}'"; \\ +                             AND password = '$password_digest' and salt='{$salt}'"; 
-          $res=mysql_query($q) or die(mysql_error()); \\ +          $res=mysql_query($q) or die(mysql_error()); 
-          if(mysql_num_rows($res)==0){ \\ +          if(mysql_num_rows($res)==0){  
-          echo "<br \>Login Failed"; \\ +          echo "<br \>Login Failed";  
-          }else{ \\ +          }else{  
-          echo "<br \>Login Success";\\ +          echo "<br \>Login Success"; 
-          }\\ +          } 
-?>''\\+?> 
 +</code>
  
 * --- //[[ajuonline at gmail dot com|Ajay Kumar]] 2008/06/07 05:39// * --- //[[ajuonline at gmail dot com|Ajay Kumar]] 2008/06/07 05:39//

Navigation
QR Code
QR Code dev:gsoc_2008_msg_sms_login (generated for current page)