| 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, |
|---|
| 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."); |
|---|
| | 155 | |
|---|
| | 156 | // Various Functions below here.. |
|---|
| | 157 | function 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. |
|---|
| | 187 | function 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 | |
|---|