Changeset 7163

Show
Ignore:
Timestamp:
10/27/08 21:18:29 (5 years ago)
Author:
xrobau
Message:

First couple of stages of the AGI written.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/cidroute/agi-bin/cidoverride.agi

    r7150 r7163  
    8787require_once($amp_conf['AMPWEBROOT']."/admin/common/db_connect.php"); 
    8888 
    89 // Just incase something insane goes wrong wtih any of the sql queres, we grab the die_freepbx  
    90 // function and redirect it to agi->debug.. This SHOULDN'T exist here, unless for some insane  
    91 // reason that function has been moved into db_connect.php.  I really don't expect it to be,  
     89// Just incase something insane goes wrong wtih any of the sql queries, we grab the die_freepbx  
     90// function and redirect it to agi->debug.. This SHOULDN'T exist before here, unless for some  
     91// insane reason that function has been moved into db_connect.php.  I really don't expect it to be,  
    9292// but hey. Better safe than sorry. 
    9393 
     
    112112  $tmp = str_split($res['state']); 
    113113  foreach ($tmp as $char) { $saystr .= $char." "; } 
    114   $saystr .= ", and the region of ".$res['region'].",, with the local area called "; 
     114  $saystr .= ". The region is ".$res['region'].".  The local area is called "; 
    115115  $saystr .= $res['localarea']."</prosody>"; 
    116   say($saystr); 
    117   $res = check("If you would like me to repeat that, press one. If you would like me to spell that, press 2. To continue, press hash"); 
     116  $saystr .= ". If you would like me to repeat that, press star. If you would like me to spell that, press 1. "; 
     117  $saystr .= "To continue, press hash. Press any other key to hang up."; 
     118  $check = say($saystr); 
     119  if ($check == null) { 
     120    $readkey=$AGI->wait_for_digit(5000); 
     121    if ($readkey['result'] == 0) { 
     122      $check = null; 
     123    } else { 
     124      $check = chr($readkey['result']); 
     125    } 
     126  }  
     127  if ($check == "1") { 
     128    say_regions($res['state'], $res['region'], $res['localarea']); 
     129    $check = "#"; 
     130  } 
     131  if ($check != "#") { 
     132    exit; 
     133  } 
     134   
     135  say("OK, we're off and running then."); 
    118136} 
    119137 
     
    135153exit; 
    136154   
     155 
     156// Various Functions below here.. 
     157function say_regions($state, $region, $area) { 
     158  global $AGI; 
     159  $repeat = true; 
     160  while ($repeat == true) { 
     161    $repeat = false; 
     162    say("The state is..."); 
     163    $AGI->say_phonetic($state, "#"); 
     164    say("The region is..."); 
     165    $AGI->say_phonetic($region, "#"); 
     166    say("The area is..."); 
     167    $AGI->say_phonetic($area, "#"); 
     168    $check = say("Press 1 to repeat, or hash to continue"); 
     169    if ($check == null) { 
     170      $readkey=$AGI->wait_for_digit(5000); 
     171      if ($readkey['result'] == 0) { 
     172        $repeat = true; 
     173      } else { 
     174        $check = chr($readkey['result']); 
     175      } 
     176    }  
     177    if ($check != "#") { 
     178      $repeat = true; 
     179    } 
     180  } 
     181} 
     182     
     183 
     184 
     185// 'say' takes a string and says it! If you push '*' it will repeat. If you push anything else, 
     186// it will return what you push. If you don't push anything, it will return null. 
     187function say($str) { 
     188  global $AGI; 
     189 
     190  // I hate PHP. This could be done with a GOTO, but oh no, they don't WANT to implement 
     191  // a goto, because there was once a document written about GOTO's and how MOST OF THE TIME 
     192  // they make code unreadable. MOST OF THE TIME. You bastards. You think THIS is readable? 
     193  // Geez. This loops if a * has been pushed, basically.  
     194  $repeat = true; 
     195  while ($repeat == true) { 
     196    $repeat = false; 
     197    $AGI->set_variable("SWIFT_DTMF", "unset"); 
     198    $AGI->exec("swift", '"'.$str.'"'); 
     199    $ret = $AGI->get_variable("SWIFT_DTMF"); 
     200    if (isset($ret['data']) && $ret['data'] != "unset" && $ret['data'] !== "" ) { 
     201      if ($ret['data'] == "*")  { 
     202        $repeat = true; 
     203      } else { 
     204        return $ret['data']; 
     205      } 
     206    } 
     207  } 
     208  return null; 
     209} 
     210 
    137211 
    138212// All the useful tools here.. 
     
    181255} 
    182256 
    183 function say($str) { 
    184   global $AGI; 
    185   $AGI->exec("swift", '"'.$str.'"'); 
    186 } 
    187  
    188 function check($str) { 
    189   global $AGI; 
    190   say("If you would like me to repeat that, press one. If you would like me to spell that, press 2. To continue, press hash"); 
    191   $res=$AGI->wait_for_digit(5000); 
    192 } 
    193    
    194    
    195257?>