From Ample Shama, 7 Years ago, written in Plain Text.
- view diff
Embed
  1.  
  2.  
  3. --set default variables
  4.         max_digits = 15;
  5.         digit_timeout = 5000;
  6.         debug["sql"] = true;
  7.  
  8. --connect to the database
  9. --      require "resources.functions.database_handle";
  10. --      dbh = database_handle('system');
  11.  
  12. DBHOST = '127.0.0.1'
  13. DBNAME = 'fusion'
  14. DBUSER = 'dbusername'
  15. DBPASS = 'dbpassword'
  16. DBPORT = 5432
  17.  
  18. local env = assert (luasql.postgres())
  19. local dbcon = env:connect(DBNAME, DBUSER, DBPASS, DBHOST, DBPORT)
  20. --set the api
  21.         api = freeswitch.API();
  22.  
  23. --get the argv values
  24.         action = argv[2];
  25.  
  26. --get the session variables
  27.         if (session:ready()) then
  28.                 session:answer();
  29.         end
  30.  
  31. --get the session variables
  32.         if (session:ready()) then
  33.                 --general variables
  34.                         dnfrom = session:getVariable("dnfrom");
  35.                         rnoroute = session:getVariable("rnoroute");
  36.  
  37.         end
  38.  
  39.  
  40. --get the routing code
  41.         sql = "SELECT rnoroute FROM ported_number ";
  42.         sql = sql .. "WHERE dnfrom = '" .. dnfrom .."' ";
  43.                 --set the variables
  44.  
  45. --show the results
  46.  if (dnfrom) then
  47.                 freeswitch.consoleLog("notice", "routing code " .. dnfrom .. " dnfrom: " .. dnfrom .. "\n");
  48.         end
  49.