| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
class extensions { |
|---|
| 4 |
/** The config |
|---|
| 5 |
* array(section=>array(extension=>array( array('basetag'=>basetag,'tag'=>tag,'addpri'=>addpri,'cmd'=>cmd) ))) |
|---|
| 6 |
* ( $_exts[$section][$extension][$priority] ) |
|---|
| 7 |
*/ |
|---|
| 8 |
var $_exts; |
|---|
| 9 |
|
|---|
| 10 |
/** Hints |
|---|
| 11 |
* special cases of priorities |
|---|
| 12 |
*/ |
|---|
| 13 |
var $_hints; |
|---|
| 14 |
|
|---|
| 15 |
var $_sorted; |
|---|
| 16 |
|
|---|
| 17 |
/** The filename to write this configuration to |
|---|
| 18 |
*/ |
|---|
| 19 |
function get_filename() { |
|---|
| 20 |
return "extensions_additional.conf"; |
|---|
| 21 |
} |
|---|
| 22 |
|
|---|
| 23 |
/** Add an entry to the extensions file |
|---|
| 24 |
* @param $section The section to be added to |
|---|
| 25 |
* @param $extension The extension used |
|---|
| 26 |
* @param $tag A tag to use (to reference with basetag), use false or '' if none |
|---|
| 27 |
* @param $command The command to execute |
|---|
| 28 |
* @param $basetag The tag to base this on. Only used in conjunction with $addpriority |
|---|
| 29 |
* priority. Defaults to false. |
|---|
| 30 |
* @param $addpriority Finds the priority of the tag called $basetag, and adds this |
|---|
| 31 |
* value to it to use as the priority for this command. |
|---|
| 32 |
* @return |
|---|
| 33 |
*/ |
|---|
| 34 |
function add($section, $extension, $tag, $command, $basetag = false, $addpriority = false) { |
|---|
| 35 |
|
|---|
| 36 |
if ($basetag || $addpriority) { |
|---|
| 37 |
if (!is_int($addpriority) || ($addpriority < 1)) { |
|---|
| 38 |
trigger_error("\$addpriority must be an integer >= 1 in extensions::add()"); |
|---|
| 39 |
return false; |
|---|
| 40 |
} |
|---|
| 41 |
if (empty($basetag)) { |
|---|
| 42 |
trigger_error("\$basetag is required with \$addpriority in extensions::add()"); |
|---|
| 43 |
return false; |
|---|
| 44 |
} |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
if (empty($basetag)) { |
|---|
| 48 |
// no basetag, we need to make one |
|---|
| 49 |
|
|---|
| 50 |
if (!isset($this->_exts[$section][$extension])) { |
|---|
| 51 |
// first entry, use 1 |
|---|
| 52 |
$basetag = '1'; |
|---|
| 53 |
} else { |
|---|
| 54 |
// anything else just n |
|---|
| 55 |
$basetag = 'n'; |
|---|
| 56 |
} |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
$new = array( |
|---|
| 60 |
'basetag' => $basetag, |
|---|
| 61 |
'tag' => $tag, |
|---|
| 62 |
'addpri' => $addpriority, |
|---|
| 63 |
'cmd' => $command, |
|---|
| 64 |
); |
|---|
| 65 |
|
|---|
| 66 |
$this->_exts[$section][$extension][] = $new; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
/** Sort sections, extensions and priorities alphabetically |
|---|
| 70 |
*/ |
|---|
| 71 |
function sort() { |
|---|
| 72 |
foreach (array_keys($this->_exts) as $section) { |
|---|
| 73 |
foreach (array_keys($this->_exts[$section]) as $extension) { |
|---|
| 74 |
// sort priorities |
|---|
| 75 |
ksort($this->_exts[$section][$extension]); |
|---|
| 76 |
} |
|---|
| 77 |
// sort extensions |
|---|
| 78 |
ksort($this->_exts[$section]); |
|---|
| 79 |
} |
|---|
| 80 |
// sort sections |
|---|
| 81 |
ksort($this->_exts); |
|---|
| 82 |
|
|---|
| 83 |
$this->_sorted = true; |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
function addHint($section, $extension, $hintvalue) { |
|---|
| 87 |
$this->_hints[$section][$extension][] = $hintvalue; |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
function addGlobal($globvar, $globval) { |
|---|
| 91 |
$this->_globals[$globvar] = $globval; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
function addInclude($section, $incsection) { |
|---|
| 95 |
$this->_includes[$section][] = $incsection; |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
/* This function allows new priorities to be injected into already generated dialplan |
|---|
| 99 |
* usage: $ext->splice($context, $exten, $priority_number, new ext_goto('1','s','ext-did')); |
|---|
| 100 |
*/ |
|---|
| 101 |
function splice($section, $extension, $priority, $command) { |
|---|
| 102 |
if($priority == 0) { |
|---|
| 103 |
$basetag = '1'; |
|---|
| 104 |
// we'll be defining a new pri "1", so change existing "1" to "n" |
|---|
| 105 |
$this->_exts[$section][$extension][0]['basetag'] = 'n'; |
|---|
| 106 |
} else { |
|---|
| 107 |
$basetag = 'n'; |
|---|
| 108 |
} |
|---|
| 109 |
$newcommand = array( |
|---|
| 110 |
'basetag' => $basetag, |
|---|
| 111 |
'tag' => '', |
|---|
| 112 |
'addpri' => '', |
|---|
| 113 |
'cmd' => $command |
|---|
| 114 |
); |
|---|
| 115 |
|
|---|
| 116 |
/* This little routine from http://ca.php.net/array_splice overcomes |
|---|
| 117 |
* problems that array_splice has with multidmentional arrays |
|---|
| 118 |
*/ |
|---|
| 119 |
$array = $this->_exts[$section][$extension]; |
|---|
| 120 |
$ky = $priority; |
|---|
| 121 |
$val = $newcommand; |
|---|
| 122 |
$n = $ky; |
|---|
| 123 |
foreach($array as $key => $value) |
|---|
| 124 |
{ |
|---|
| 125 |
$backup_array[$key] = $array[$key]; |
|---|
| 126 |
} |
|---|
| 127 |
$upper_limit = count($array); |
|---|
| 128 |
while($n <= $upper_limit) |
|---|
| 129 |
{ |
|---|
| 130 |
if($n == $ky) |
|---|
| 131 |
{ |
|---|
| 132 |
$array[$n] = $val; |
|---|
| 133 |
// echo $n; |
|---|
| 134 |
} |
|---|
| 135 |
else |
|---|
| 136 |
{ |
|---|
| 137 |
$i = $n - "1"; |
|---|
| 138 |
$array[$n] = $backup_array[$i]; |
|---|
| 139 |
} |
|---|
| 140 |
$n++; |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
// apply our newly modified array |
|---|
| 144 |
//echo "Splicing [$section] $extension\n"; |
|---|
| 145 |
$this->_exts[$section][$extension] = $array; |
|---|
| 146 |
|
|---|
| 147 |
//print_r($this->_exts[$section][$extension]); |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
/** Generate the file |
|---|
| 151 |
* @return A string containing the extensions.conf file |
|---|
| 152 |
*/ |
|---|
| 153 |
function generateConf() { |
|---|
| 154 |
$output = ""; |
|---|
| 155 |
|
|---|
| 156 |
/* sorting is not necessary anymore |
|---|
| 157 |
if (!$this->_sorted) { |
|---|
| 158 |
$this->sort(); |
|---|
| 159 |
} |
|---|
| 160 |
*/ |
|---|
| 161 |
|
|---|
| 162 |
//var_dump($this->_exts); |
|---|
| 163 |
|
|---|
| 164 |
//take care of globals first |
|---|
| 165 |
if(isset($this->_globals) && is_array($this->_globals)){ |
|---|
| 166 |
$output .= "[globals]\n"; |
|---|
| 167 |
$output .= "#include globals_custom.conf\n"; |
|---|
| 168 |
foreach (array_keys($this->_globals) as $global) { |
|---|
| 169 |
$output .= $global." = ".$this->_globals[$global]."\n"; |
|---|
| 170 |
} |
|---|
| 171 |
$output .= "\n\n;end of [globals]\n\n\n"; |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
//now the rest of the contexts |
|---|
| 175 |
if(is_array($this->_exts)){ |
|---|
| 176 |
foreach (array_keys($this->_exts) as $section) { |
|---|
| 177 |
$output .= "[".$section."]\n"; |
|---|
| 178 |
|
|---|
| 179 |
//automatically include a -custom context |
|---|
| 180 |
$output .= "include => {$section}-custom\n"; |
|---|
| 181 |
//add requested includes for this context |
|---|
| 182 |
if (isset($this->_includes[$section])) { |
|---|
| 183 |
foreach ($this->_includes[$section] as $include) { |
|---|
| 184 |
$output .= "include => ".$include."\n"; |
|---|
| 185 |
} |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
foreach (array_keys($this->_exts[$section]) as $extension) { |
|---|
| 189 |
foreach (array_keys($this->_exts[$section][$extension]) as $idx) { |
|---|
| 190 |
|
|---|
| 191 |
$ext = $this->_exts[$section][$extension][$idx]; |
|---|
| 192 |
|
|---|
| 193 |
//echo "[$section] $extension $idx\n"; |
|---|
| 194 |
//var_dump($ext); |
|---|
| 195 |
|
|---|
| 196 |
$output .= "exten => ".$extension.",". |
|---|
| 197 |
$ext['basetag']. |
|---|
| 198 |
($ext['addpri'] ? '+'.$ext['addpri'] : ''). |
|---|
| 199 |
($ext['tag'] ? '('.$ext['tag'].')' : ''). |
|---|
| 200 |
",".$ext['cmd']->output()."\n"; |
|---|
| 201 |
} |
|---|
| 202 |
if (isset($this->_hints[$section][$extension])) { |
|---|
| 203 |
foreach ($this->_hints[$section][$extension] as $hint) { |
|---|
| 204 |
$output .= "exten => ".$extension.",hint,".$hint."\n"; |
|---|
| 205 |
} |
|---|
| 206 |
} |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
$output .= "\n; end of [".$section."]\n\n\n"; |
|---|
| 210 |
} |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
return $output; |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
/** Generate the file |
|---|
| 217 |
* @return A string containing the extensions.conf file |
|---|
| 218 |
*/ |
|---|
| 219 |
function generateOldConf() { |
|---|
| 220 |
$output = ""; |
|---|
| 221 |
|
|---|
| 222 |
/* sorting is not necessary anymore |
|---|
| 223 |
if (!$this->_sorted) { |
|---|
| 224 |
$this->sort(); |
|---|
| 225 |
} |
|---|
| 226 |
*/ |
|---|
| 227 |
|
|---|
| 228 |
var_dump($this->_exts); |
|---|
| 229 |
|
|---|
| 230 |
foreach (array_keys($this->_exts) as $section) { |
|---|
| 231 |
$output .= "[".$section."]\n"; |
|---|
| 232 |
|
|---|
| 233 |
foreach (array_keys($this->_exts[$section]) as $extension) { |
|---|
| 234 |
$priority = 0; |
|---|
| 235 |
$prioritytable = array(); |
|---|
| 236 |
|
|---|
| 237 |
foreach (array_keys($this->_exts[$section][$extension]) as $idx) { |
|---|
| 238 |
|
|---|
| 239 |
$ext = $this->_exts[$section][$extension][$idx]; |
|---|
| 240 |
|
|---|
| 241 |
//var_dump($ext); |
|---|
| 242 |
switch ($ext['basetag']) { |
|---|
| 243 |
case '1': $priority = 1; break; |
|---|
| 244 |
case 'n': $priority += 1; break; |
|---|
| 245 |
default: |
|---|
| 246 |
if (isset($prioritytable[$ext['basetag']])) { |
|---|
| 247 |
$priority = $prioritytable[$ext['basetag']]; |
|---|
| 248 |
} else { |
|---|
| 249 |
$priority = 'unknown!!!'; |
|---|
| 250 |
} |
|---|
| 251 |
break; |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
if ($ext['addpri']) { |
|---|
| 255 |
$priority += $ext['addpri']; |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
if ($ext['tag']) { |
|---|
| 259 |
$prioritytable[$ext['tag']] = $priority; |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
$output .= "exten => ".$extension.",".$priority. |
|---|
| 263 |
",".$ext['cmd']->output()."\n"; |
|---|
| 264 |
|
|---|
| 265 |
} |
|---|
| 266 |
|
|---|
| 267 |
if (isset($this->_hints[$section][$extension])) { |
|---|
| 268 |
foreach ($this->_hints[$section][$extension] as $hint) { |
|---|
| 269 |
$output .= "exten => ".$extension.",hint,".$hint; |
|---|
| 270 |
} |
|---|
| 271 |
} |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
$output .= "\n; end of [".$section."]\n\n\n"; |
|---|
| 275 |
} |
|---|
| 276 |
|
|---|
| 277 |
return $output; |
|---|
| 278 |
} |
|---|
| 279 |
} |
|---|
| 280 |
|
|---|
| 281 |
class extension { |
|---|
| 282 |
var $data; |
|---|
| 283 |
|
|---|
| 284 |
function extension($data = '') { |
|---|
| 285 |
$this->data = $data; |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
function incrementContents($value) { |
|---|
| 289 |
return true; |
|---|
| 290 |
} |
|---|
| 291 |
|
|---|
| 292 |
function output() { |
|---|
| 293 |
return $data; |
|---|
| 294 |
} |
|---|
| 295 |
} |
|---|
| 296 |
|
|---|
| 297 |
class ext_gosub extends extension { |
|---|
| 298 |
var $pri; |
|---|
| 299 |
var $ext; |
|---|
| 300 |
var $context; |
|---|
| 301 |
|
|---|
| 302 |
function ext_gosub($pri, $ext = false, $context = false) { |
|---|
| 303 |
if ($context !== false && $ext === false) { |
|---|
| 304 |
trigger_error("\$ext is required when passing \$context in ext_gosub::ext_gosub()"); |
|---|
| 305 |
} |
|---|
| 306 |
|
|---|
| 307 |
$this->pri = $pri; |
|---|
| 308 |
$this->ext = $ext; |
|---|
| 309 |
$this->context = $context; |
|---|
| 310 |
} |
|---|
| 311 |
|
|---|
| 312 |
function incrementContents($value) { |
|---|
| 313 |
$this->pri += $value; |
|---|
| 314 |
} |
|---|
| 315 |
|
|---|
| 316 |
function output() { |
|---|
| 317 |
return 'Gosub('.($this->context ? $this->context.',' : '').($this->ext ? $this->ext.',' : '').$this->pri.')' ; |
|---|
| 318 |
} |
|---|
| 319 |
} |
|---|
| 320 |
|
|---|
| 321 |
class ext_return extends extension { |
|---|
| 322 |
function output() { |
|---|
| 323 |
return "Return()"; |
|---|
| 324 |
} |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
class ext_gosubif extends extension { |
|---|
| 328 |
var $true_priority; |
|---|
| 329 |
var $false_priority; |
|---|
| 330 |
var $condition; |
|---|
| 331 |
function ext_gosubif($condition, $true_priority, $false_priority = false) { |
|---|
| 332 |
$this->true_priority = $true_priority; |
|---|
| 333 |
$this->false_priority = $false_priority; |
|---|
| 334 |
$this->condition = $condition; |
|---|
| 335 |
} |
|---|
| 336 |
function output() { |
|---|
| 337 |
return 'GosubIf(' .$this->condition. '?' .$this->true_priority.($this->false_priority ? ':' .$this->false_priority : '' ). ')' ; |
|---|
| 338 |
} |
|---|
| 339 |
function incrementContents($value) { |
|---|
| 340 |
$this->true_priority += $value; |
|---|
| 341 |
$this->false_priority += $value; |
|---|
| 342 |
} |
|---|
| 343 |
} |
|---|
| 344 |
|
|---|
| 345 |
class ext_goto extends extension { |
|---|
| 346 |
var $pri; |
|---|
| 347 |
var $ext; |
|---|
| 348 |
var $context; |
|---|
| 349 |
|
|---|
| 350 |
function ext_goto($pri, $ext = false, $context = false) { |
|---|
| 351 |
if ($context !== false && $ext === false) { |
|---|
| 352 |
trigger_error("\$ext is required when passing \$context in ext_goto::ext_goto()"); |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
$this->pri = $pri; |
|---|
| 356 |
$this->ext = $ext; |
|---|
| 357 |
$this->context = $context; |
|---|
| 358 |
} |
|---|
| 359 |
|
|---|
| 360 |
function incrementContents($value) { |
|---|
| 361 |
$this->pri += $value; |
|---|
| 362 |
} |
|---|
| 363 |
|
|---|
| 364 |
function output() { |
|---|
| 365 |
return 'Goto('.($this->context ? $this->context.',' : '').($this->ext ? $this->ext.',' : '').$this->pri.')' ; |
|---|
| 366 |
} |
|---|
| 367 |
} |
|---|
| 368 |
|
|---|
| 369 |
class ext_gotoif extends extension { |
|---|
| 370 |
var $true_priority; |
|---|
| 371 |
var $false_priority; |
|---|
| 372 |
var $condition; |
|---|
| 373 |
function ext_gotoif($condition, $true_priority, $false_priority = false) { |
|---|
| 374 |
$this->true_priority = $true_priority; |
|---|
| 375 |
$this->false_priority = $false_priority; |
|---|
| 376 |
$this->condition = $condition; |
|---|
| 377 |
} |
|---|
| 378 |
function output() { |
|---|
| 379 |
return 'GotoIf(' .$this->condition. '?' .$this->true_priority.($this->false_priority ? ':' .$this->false_priority : '' ). ')' ; |
|---|
| 380 |
} |
|---|
| 381 |
function incrementContents($value) { |
|---|
| 382 |
$this->true_priority += $value; |
|---|
| 383 |
$this->false_priority += $value; |
|---|
| 384 |
} |
|---|
| 385 |
} |
|---|
| 386 |
|
|---|
| 387 |
class ext_gotoiftime extends extension { |
|---|
| 388 |
var $true_priority; |
|---|
| 389 |
var $condition; |
|---|
| 390 |
function ext_gotoiftime($condition, $true_priority) { |
|---|
| 391 |
$this->true_priority = $true_priority; |
|---|
| 392 |
$this->condition = $condition; |
|---|
| 393 |
} |
|---|
| 394 |
function output() { |
|---|
| 395 |
return 'GotoIfTime(' .$this->condition. '?' .$this->true_priority. ')' ; |
|---|
| 396 |
} |
|---|
| 397 |
function incrementContents($value) { |
|---|
| 398 |
$this->true_priority += $value; |
|---|
| 399 |
} |
|---|
| 400 |
} |
|---|
| 401 |
|
|---|
| 402 |
class ext_noop extends extension { |
|---|
| 403 |
function output() { |
|---|
| 404 |
return "Noop(".$this->data.")"; |
|---|
| 405 |
} |
|---|
| 406 |
} |
|---|
| 407 |
|
|---|
| 408 |
class ext_dial extends extension { |
|---|
| 409 |
var $number; |
|---|
| 410 |
var $options; |
|---|
| 411 |
|
|---|
| 412 |
function ext_dial($number, $options = "tr") { |
|---|
| 413 |
$this->number = $number; |
|---|
| 414 |
$this->options = $options; |
|---|
| 415 |
} |
|---|
| 416 |
|
|---|
| 417 |
function output() { |
|---|
| 418 |
return "Dial(".$this->number.",".$this->options.")"; |
|---|
| 419 |
} |
|---|
| 420 |
} |
|---|
| 421 |
|
|---|
| 422 |
class ext_setvar { |
|---|
| 423 |
var $var; |
|---|
| 424 |
var $value; |
|---|
| 425 |
|
|---|
| 426 |
function ext_setvar($var, $value) { |
|---|
| 427 |
$this->var = $var; |
|---|
| 428 |
$this->value = $value; |
|---|
| 429 |
} |
|---|
| 430 |
|
|---|
| 431 |
function output() { |
|---|
| 432 |
return "Set(".$this->var."=".$this->value.")"; |
|---|
| 433 |
} |
|---|
| 434 |
} |
|---|
| 435 |
class ext_set extends ext_setvar {} // alias, SetVar was renamed to Set in ast 1.2 |
|---|
| 436 |
|
|---|
| 437 |
class ext_wait extends extension { |
|---|
| 438 |
function output() { |
|---|
| 439 |
return "Wait(".$this->data.")"; |
|---|
| 440 |
} |
|---|
| 441 |
} |
|---|
| 442 |
|
|---|
| 443 |
class ext_answer extends extension { |
|---|
| 444 |
function output() { |
|---|
| 445 |
return "Answer"; |
|---|
| 446 |
} |
|---|
| 447 |
} |
|---|
| 448 |
|
|---|
| 449 |
class ext_privacymanager extends extension { |
|---|
| 450 |
function output() { |
|---|
| 451 |
return "PrivacyManager(".$this->data.")"; |
|---|
| 452 |
} |
|---|
| 453 |
} |
|---|
| 454 |
|
|---|
| 455 |
class ext_macro { |
|---|
| 456 |
var $macro; |
|---|
| 457 |
var $args; |
|---|
| 458 |
|
|---|
| 459 |
function ext_macro($macro, $args='') { |
|---|
| 460 |
$this->macro = $macro; |
|---|
| 461 |
$this->args = $args; |
|---|
| 462 |
} |
|---|
| 463 |
|
|---|
| 464 |
function output() { |
|---|
| 465 |
return "Macro(".$this->macro.",".$this->args.")"; |
|---|
| 466 |
} |
|---|
| 467 |
} |
|---|
| 468 |
|
|---|
| 469 |
class ext_setcidname extends extension { |
|---|
| 470 |
function output() { |
|---|
| 471 |
return "Set(CALLERID(name)=".$this->data.")"; |
|---|
| 472 |
} |
|---|
| 473 |
} |
|---|
| 474 |
|
|---|
| 475 |
class ext_record extends extension { |
|---|
| 476 |
function output() { |
|---|
| 477 |
return "Record(".$this->data.")"; |
|---|
| 478 |
} |
|---|
| 479 |
} |
|---|
| 480 |
|
|---|
| 481 |
class ext_playback extends extension { |
|---|
| 482 |
function output() { |
|---|
| 483 |
return "Playback(".$this->data.")"; |
|---|
| 484 |
} |
|---|
| 485 |
} |
|---|
| 486 |
|
|---|
| 487 |
class ext_queue { |
|---|
| 488 |
var $var; |
|---|
| 489 |
var $value; |
|---|
| 490 |
|
|---|
| 491 |
function ext_queue($queuename, $options, $optionalurl, $announceoverride, $timeout) { |
|---|
| 492 |
$this->queuename = $queuename; |
|---|
| 493 |
$this->options = $options; |
|---|
| 494 |
$this->optionalurl = $optionalurl; |
|---|
| 495 |
$this->announceoverride = $announceoverride; |
|---|
| 496 |
$this->timeout = $timeout; |
|---|
| 497 |
} |
|---|
| 498 |
|
|---|
| 499 |
function output() { |
|---|
| 500 |
// for some reason the Queue cmd takes an empty last param (timeout) as being 0 |
|---|
| 501 |
// when really we want unlimited |
|---|
| 502 |
if ($this->timeout != "") |
|---|
| 503 |
return "Queue(".$this->queuename."|".$this->options."|".$this->optionalurl."|".$this->announceoverride."|".$this->timeout.")"; |
|---|
| 504 |
else |
|---|
| 505 |
return "Queue(".$this->queuename."|".$this->options."|".$this->optionalurl."|".$this->announceoverride.")"; |
|---|
| 506 |
} |
|---|
| 507 |
} |
|---|
| 508 |
|
|---|
| 509 |
class ext_hangup extends extension { |
|---|
| 510 |
function output() { |
|---|
| 511 |
return "Hangup"; |
|---|
| 512 |
} |
|---|
| 513 |
} |
|---|
| 514 |
|
|---|
| 515 |
class ext_digittimeout extends extension { |
|---|
| 516 |
function output() { |
|---|
| 517 |
return "Set(TIMEOUT(digit)=".$this->data.")"; |
|---|
| 518 |
} |
|---|
| 519 |
} |
|---|
| 520 |
|
|---|
| 521 |
class ext_responsetimeout extends extension { |
|---|
| 522 |
function output() { |
|---|
| 523 |
return "Set(TIMEOUT(response)=".$this->data.")"; |
|---|
| 524 |
} |
|---|
| 525 |
} |
|---|
| 526 |
|
|---|
| 527 |
class ext_background extends extension { |
|---|
| 528 |
function output() { |
|---|
| 529 |
return "Background(".$this->data.")"; |
|---|
| 530 |
} |
|---|
| 531 |
} |
|---|
| 532 |
|
|---|
| 533 |
class ext_read { |
|---|
| 534 |
var $astvar; |
|---|
| 535 |
var $filename; |
|---|
| 536 |
var $maxdigits; |
|---|
| 537 |
var $option; |
|---|
| 538 |
var $attempts; // added in ast 1.2 |
|---|
| 539 |
var $timeout; // added in ast 1.2 |
|---|
| 540 |
|
|---|
| 541 |
function ext_read($astvar, $filename='', $maxdigits='', $option='', $attempts ='', $timeout ='') { |
|---|
| 542 |
$this->astvar = $astvar; |
|---|
| 543 |
$this->filename = $filename; |
|---|
| 544 |
$this->maxdigits = $maxdigits; |
|---|
| 545 |
$this->option = $option; |
|---|
| 546 |
$this->attempts = $attempts; |
|---|
| 547 |
$this->timeout = $timeout; |
|---|
| 548 |
} |
|---|
| 549 |
|
|---|
| 550 |
function output() { |
|---|
| 551 |
return "Read(".$this->astvar.",".$this->filename.",".$this->maxdigits.",".$this->option.",".$this->attempts.",".$this->timeout.")"; |
|---|
| 552 |
} |
|---|
| 553 |
} |
|---|
| 554 |
|
|---|
| 555 |
class ext_meetme { |
|---|
| 556 |
var $confno; |
|---|
| 557 |
var $options; |
|---|
| 558 |
var $pin; |
|---|
| 559 |
|
|---|
| 560 |
function ext_meetme($confno, $options='', $pin='') { |
|---|
| 561 |
$this->confno = $confno; |
|---|
| 562 |
$this->options = $options; |
|---|
| 563 |
$this->pin = $pin; |
|---|
| 564 |
} |
|---|
| 565 |
|
|---|
| 566 |
function output() { |
|---|
| 567 |
return "MeetMe(".$this->confno.",".$this->options.",".$this->pin.")"; |
|---|
| 568 |
} |
|---|
| 569 |
} |
|---|
| 570 |
|
|---|
| 571 |
class ext_authenticate { |
|---|
| 572 |
var $pass; |
|---|
| 573 |
var $options; |
|---|
| 574 |
|
|---|
| 575 |
function ext_authenticate($pass, $options='') { |
|---|
| 576 |
$this->pass = $pass; |
|---|
| 577 |
$this->options = $options; |
|---|
| 578 |
} |
|---|
| 579 |
|
|---|
| 580 |
function output() { |
|---|
| 581 |
return "Authenticate(".$this->pass.",".$this->options.")"; |
|---|
| 582 |
} |
|---|
| 583 |
} |
|---|
| 584 |
|
|---|
| 585 |
class ext_page extends extension { |
|---|
| 586 |
function output() { |
|---|
| 587 |
return "Page(".$this->data.")"; |
|---|
| 588 |
} |
|---|
| 589 |
} |
|---|
| 590 |
|
|---|
| 591 |
class ext_disa extends extension { |
|---|
| 592 |
function output() { |
|---|
| 593 |
return "DISA(".$this->data.")"; |
|---|
| 594 |
} |
|---|
| 595 |
} |
|---|
| 596 |
class ext_agi extends extension { |
|---|
| 597 |
function output() { |
|---|
| 598 |
return "AGI(".$this->data.")"; |
|---|
| 599 |
} |
|---|
| 600 |
} |
|---|
| 601 |
class ext_dbdel extends extension { |
|---|
| 602 |
function output() { |
|---|
| 603 |
return "dbDel(".$this->data.")"; |
|---|
| 604 |
} |
|---|
| 605 |
} |
|---|
| 606 |
class ext_dbdeltree extends extension { |
|---|
| 607 |
function output() { |
|---|
| 608 |
return "dbDeltree(".$this->data.")"; |
|---|
| 609 |
} |
|---|
| 610 |
} |
|---|
| 611 |
class ext_dbget extends extension { |
|---|
| 612 |
var $varname; |
|---|
| 613 |
var $key; |
|---|
| 614 |
function ext_dbget($varname, $key) { |
|---|
| 615 |
$this->varname = $varname; |
|---|
| 616 |
$this->key = $key; |
|---|
| 617 |
} |
|---|
| 618 |
function output() { |
|---|
| 619 |
return "dbGet(".$this->varname."=".$this->key.")"; |
|---|
| 620 |
} |
|---|
| 621 |
} |
|---|
| 622 |
class ext_dbput extends extension { |
|---|
| 623 |
var $key; |
|---|
| 624 |
function ext_dbput($key, $data) { |
|---|
| 625 |
$this->key = $key; |
|---|
| 626 |
$this->data = $data; |
|---|
| 627 |
} |
|---|
| 628 |
function output() { |
|---|
| 629 |
return "dbPut(".$this->key."=".$this->data.")"; |
|---|
| 630 |
} |
|---|
| 631 |
} |
|---|
| 632 |
class ext_vmmain extends extension { |
|---|
| 633 |
function output() { |
|---|
| 634 |
return "VoiceMailMain(".$this->data.")"; |
|---|
| 635 |
} |
|---|
| 636 |
} |
|---|
| 637 |
class ext_vm extends extension { |
|---|
| 638 |
function output() { |
|---|
| 639 |
return "VoiceMail(".$this->data.")"; |
|---|
| 640 |
} |
|---|
| 641 |
} |
|---|
| 642 |
class ext_saydigits extends extension { |
|---|
| 643 |
function output() { |
|---|
| 644 |
return "SayDigits(".$this->data.")"; |
|---|
| 645 |
} |
|---|
| 646 |
} |
|---|
| 647 |
class ext_sayunixtime extends extension { |
|---|
| 648 |
function output() { |
|---|
| 649 |
return "SayUnixTime(".$this->data.")"; |
|---|
| 650 |
} |
|---|
| 651 |
} |
|---|
| 652 |
class ext_echo extends extension { |
|---|
| 653 |
function output() { |
|---|
| 654 |
return "Echo(".$this->data.")"; |
|---|
| 655 |
} |
|---|
| 656 |
} |
|---|
| 657 |
// Thanks to agillis for the suggestion of the nvfaxdetect option |
|---|
| 658 |
class ext_nvfaxdetect extends extension { |
|---|
| 659 |
function output() { |
|---|
| 660 |
return "NVFaxDetect(".$this->data.")"; |
|---|
| 661 |
} |
|---|
| 662 |
} |
|---|
| 663 |
class ext_playtones extends extension { |
|---|
| 664 |
function output() { |
|---|
| 665 |
return "Playtones(".$this->data.")"; |
|---|
| 666 |
} |
|---|
| 667 |
} |
|---|
| 668 |
class ext_zapbarge extends extension { |
|---|
| 669 |
function output() { |
|---|
| 670 |
return "ZapBarge(".$this->data.")"; |
|---|
| 671 |
} |
|---|
| 672 |
} |
|---|
| 673 |
class ext_sayalpha extends extension { |
|---|
| 674 |
function output() { |
|---|
| 675 |
return "SayAlpha(".$this->data.")"; |
|---|
| 676 |
} |
|---|
| 677 |
} |
|---|
| 678 |
class ext_saynumber extends extension { |
|---|
| 679 |
var $gender; |
|---|
| 680 |
function ext_saynumber($data, $gender = 'f') { |
|---|
| 681 |
parent::extension($data); |
|---|
| 682 |
$this->gender = $gender; |
|---|
| 683 |
} |
|---|
| 684 |
function output() { |
|---|
| 685 |
return "SayNumber(".$this->data.",".$this->gender.")"; |
|---|
| 686 |
} |
|---|
| 687 |
} |
|---|
| 688 |
class ext_sayphonetic extends extension { |
|---|
| 689 |
function output() { |
|---|
| 690 |
return "SayPhonetic(".$this->data.")"; |
|---|
| 691 |
} |
|---|
| 692 |
} |
|---|
| 693 |
class ext_system extends extension { |
|---|
| 694 |
function output() { |
|---|
| 695 |
return "System(".$this->data.")"; |
|---|
| 696 |
} |
|---|
| 697 |
} |
|---|
| 698 |
class ext_festival extends extension { |
|---|
| 699 |
function output() { |
|---|
| 700 |
return "Festival(".$this->data.")"; |
|---|
| 701 |
} |
|---|
| 702 |
} |
|---|
| 703 |
class ext_pickup extends extension { |
|---|
| 704 |
function output() { |
|---|
| 705 |
return "Pickup(".$this->data.")"; |
|---|
| 706 |
} |
|---|
| 707 |
} |
|---|
| 708 |
class ext_dpickup extends extension { |
|---|
| 709 |
function output() { |
|---|
| 710 |
return "DPickup(".$this->data.")"; |
|---|
| 711 |
} |
|---|
| 712 |
} |
|---|
| 713 |
class ext_lookupcidname extends extension { |
|---|
| 714 |
function output() { |
|---|
| 715 |
return "LookupCIDName"; |
|---|
| 716 |
} |
|---|
| 717 |
} |
|---|
| 718 |
|
|---|
| 719 |
class ext_txtcidname extends extension { |
|---|
| 720 |
var $cidnum; |
|---|
| 721 |
|
|---|
| 722 |
function ext_txtcidname($cidnum) { |
|---|
| 723 |
$this->cidnum = $cidnum; |
|---|
| 724 |
} |
|---|
| 725 |
|
|---|
| 726 |
function output() { |
|---|
| 727 |
return "TXTCIDName(".$this->cidnum.")"; |
|---|
| 728 |
} |
|---|
| 729 |
} |
|---|
| 730 |
|
|---|
| 731 |
class ext_mysql_connect extends extension { |
|---|
| 732 |
var $connid; |
|---|
| 733 |
var $dbhost; |
|---|
| 734 |
var $dbuser; |
|---|
| 735 |
var $dbpass; |
|---|
| 736 |
var $dbname; |
|---|
| 737 |
|
|---|
| 738 |
function ext_mysql_connect($connid, $dbhost, $dbuser, $dbpass, $dbname) { |
|---|
| 739 |
$this->connid = $connid; |
|---|
| 740 |
$this->dbhost = $dbhost; |
|---|
| 741 |
$this->dbuser = $dbuser; |
|---|
| 742 |
$this->dbpass = $dbpass; |
|---|
| 743 |
$this->dbname = $dbname; |
|---|
| 744 |
} |
|---|
| 745 |
|
|---|
| 746 |
function output() { |
|---|
| 747 |
return "MYSQL(Connect ".$this->connid." ".$this->dbhost." ".$this->dbuser." ".$this->dbpass." ".$this->dbname.")"; |
|---|
| 748 |
} |
|---|
| 749 |
} |
|---|
| 750 |
|
|---|
| 751 |
class ext_mysql_query extends extension { |
|---|
| 752 |
var $resultid; |
|---|
| 753 |
var $connid; |
|---|
| 754 |
var $query; |
|---|
| 755 |
|
|---|
| 756 |
function ext_mysql_query($resultid, $connid, $query) { |
|---|
| 757 |
$this->resultid = $resultid; |
|---|
| 758 |
$this->connid = $connid; |
|---|
| 759 |
$this->query = $query; |
|---|
| 760 |
// Not escaping mysql query here, you may want to insert asterisk variables in it |
|---|
| 761 |
} |
|---|
| 762 |
|
|---|
| 763 |
function output() { |
|---|
| 764 |
return 'MYSQL(Query '.$this->resultid.' ${'.$this->connid.'} '.$this->query.')'; |
|---|
| 765 |
} |
|---|
| 766 |
} |
|---|
| 767 |
|
|---|
| 768 |
class ext_mysql_fetch extends extension { |
|---|
| 769 |
var $fetchid; |
|---|
| 770 |
var $resultid; |
|---|
| 771 |
var $fars; |
|---|
| 772 |
|
|---|
| 773 |
function ext_mysql_fetch($fetchid, $resultid, $vars) { |
|---|
| 774 |
$this->fetchid = $fetchid; |
|---|
| 775 |
$this->resultid = $resultid; |
|---|
| 776 |
$this->vars = $vars; |
|---|
| 777 |
} |
|---|
| 778 |
|
|---|
| 779 |
function output() { |
|---|
| 780 |
return 'MYSQL(Fetch '.$this->fetchid.' ${'.$this->resultid.'} '.$this->vars.')'; |
|---|
| 781 |
} |
|---|
| 782 |
} |
|---|
| 783 |
|
|---|
| 784 |
class ext_mysql_clear extends extension { |
|---|
| 785 |
var $resultid; |
|---|
| 786 |
|
|---|
| 787 |
function ext_mysql_clear($resultid) { |
|---|
| 788 |
$this->resultid = $resultid; |
|---|
| 789 |
} |
|---|
| 790 |
|
|---|
| 791 |
function output() { |
|---|
| 792 |
return 'MYSQL(Clear ${'.$this->resultid.'})'; |
|---|
| 793 |
} |
|---|
| 794 |
} |
|---|
| 795 |
|
|---|
| 796 |
class ext_mysql_disconnect extends extension { |
|---|
| 797 |
var $connid; |
|---|
| 798 |
|
|---|
| 799 |
function ext_mysql_disconnect($connid) { |
|---|
| 800 |
$this->connid = $connid; |
|---|
| 801 |
} |
|---|
| 802 |
|
|---|
| 803 |
function output() { |
|---|
| 804 |
return 'MYSQL(Disconnect ${'.$this->connid.'})'; |
|---|
| 805 |
} |
|---|
| 806 |
} |
|---|
| 807 |
|
|---|
| 808 |
class ext_ringing extends extension { |
|---|
| 809 |
function output() { |
|---|
| 810 |
return "Ringing()"; |
|---|
| 811 |
} |
|---|
| 812 |
} |
|---|
| 813 |
|
|---|
| 814 |
class ext_db_put extends extension { |
|---|
| 815 |
var $family; |
|---|
| 816 |
var $key; |
|---|
| 817 |
var $value; |
|---|
| 818 |
|
|---|
| 819 |
function ext_db_put($family, $key, $value) { |
|---|
| 820 |
$this->family = $family; |
|---|
| 821 |
$this->key = $key; |
|---|
| 822 |
$this->value = $value; |
|---|
| 823 |
} |
|---|
| 824 |
|
|---|
| 825 |
function output() { |
|---|
| 826 |
return 'Set(DB('.$this->family.'/'.$this->key.')='.$this->value.')'; |
|---|
| 827 |
} |
|---|
| 828 |
} |
|---|
| 829 |
|
|---|
| 830 |
class ext_zapateller extends extension { |
|---|
| 831 |
function output() { |
|---|
| 832 |
return "Zapateller(".$this->data.")"; |
|---|
| 833 |
} |
|---|
| 834 |
} |
|---|
| 835 |
|
|---|
| 836 |
class ext_musiconhold extends extension { |
|---|
| 837 |
function output() { |
|---|
| 838 |
return "MusicOnHold(".$this->data.")"; |
|---|
| 839 |
} |
|---|
| 840 |
} |
|---|
| 841 |
|
|---|
| 842 |
class ext_setmusiconhold extends extension { |
|---|
| 843 |
function output() { |
|---|
| 844 |
return "SetMusicOnHold(".$this->data.")"; |
|---|
| 845 |
} |
|---|
| 846 |
} |
|---|
| 847 |
|
|---|
| 848 |
class ext_congestion extends extension { |
|---|
| 849 |
function output() { |
|---|
| 850 |
return "Congestion"; |
|---|
| 851 |
} |
|---|
| 852 |
} |
|---|
| 853 |
|
|---|
| 854 |
class ext_busy extends extension { |
|---|
| 855 |
function output() { |
|---|
| 856 |
return "Busy"; |
|---|
| 857 |
} |
|---|
| 858 |
} |
|---|
| 859 |
|
|---|
| 860 |
class ext_flite extends extension { |
|---|
| 861 |
function output() { |
|---|
| 862 |
return "Flite('".$this->data."')"; |
|---|
| 863 |
} |
|---|
| 864 |
} |
|---|
| 865 |
class ext_chanspy extends extension { |
|---|
| 866 |
var $prefix; |
|---|
| 867 |
var $options; |
|---|
| 868 |
function ext_chanspy($prefix = '', $options = '') { |
|---|
| 869 |
$this->prefix = $prefix; |
|---|
| 870 |
$this->options = $options; |
|---|
| 871 |
} |
|---|
| 872 |
function output() { |
|---|
| 873 |
return "ChanSpy(".$this->prefix.($this->options?'|'.$this->options:'').")"; |
|---|
| 874 |
} |
|---|
| 875 |
} |
|---|
| 876 |
|
|---|
| 877 |
class ext_lookupblacklist extends extension { |
|---|
| 878 |
function output() { |
|---|
| 879 |
return "LookupBlacklist(".$this->data.")"; |
|---|
| 880 |
} |
|---|
| 881 |
} |
|---|
| 882 |
|
|---|
| 883 |
class ext_dictate extends extension { |
|---|
| 884 |
function output() { |
|---|
| 885 |
return "Dictate(".$this->data.")"; |
|---|
| 886 |
} |
|---|
| 887 |
} |
|---|
| 888 |
|
|---|
| 889 |
/* example usage |
|---|
| 890 |
$ext = new extensions; |
|---|
| 891 |
|
|---|
| 892 |
|
|---|
| 893 |
$ext->add('default','123', 'dial1', new ext_dial('ZAP/1234')); |
|---|
| 894 |
$ext->add('default','123', '', new ext_noop('test1')); |
|---|
| 895 |
$ext->add('default','123', '', new ext_noop('test2')); |
|---|
| 896 |
$ext->add('default','123', '', new ext_noop('test at +101'), 'dial1', 101); |
|---|
| 897 |
$ext->add('default','123', '', new ext_noop('test at +102')); |
|---|
| 898 |
echo "<pre>"; |
|---|
| 899 |
echo $ext->generateConf(); |
|---|
| 900 |
echo $ext->generateOldConf(); |
|---|
| 901 |
exit; |
|---|
| 902 |
*/ |
|---|
| 903 |
|
|---|
| 904 |
/* |
|---|
| 905 |
exten => 123,1(dial1),Dial(ZAP/1234) |
|---|
| 906 |
exten => 123,n,noop(test1) |
|---|
| 907 |
exten => 123,n,noop(test2) |
|---|
| 908 |
exten => 123,dial1+101,noop(test at 101) |
|---|
| 909 |
exten => 123,n,noop(test at 102) |
|---|
| 910 |
*/ |
|---|
| 911 |
|
|---|
| 912 |
?> |
|---|