@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $moduleDir = PbxExtensionUtils::getModuleDir($module['uniqid']); |
71 | 71 | |
72 | 72 | $moduleJson = "{$moduleDir}/module.json"; |
73 | - if ( ! file_exists($moduleJson)) { |
|
73 | + if (!file_exists($moduleJson)) { |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | $jsonString = file_get_contents($moduleJson); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | $moduleModelsDir = "{$moduleDir}/Models"; |
84 | - $results = glob($moduleModelsDir . '/*.php', GLOB_NOSORT); |
|
84 | + $results = glob($moduleModelsDir.'/*.php', GLOB_NOSORT); |
|
85 | 85 | foreach ($results as $file) { |
86 | 86 | $className = pathinfo($file)['filename']; |
87 | 87 | $moduleModelClass = "\\Modules\\{$module['uniqid']}\\Models\\{$className}"; |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | $newErrorMessage = $this->t('ConstraintViolation'); |
117 | 117 | $newErrorMessage .= "<ul class='list'>"; |
118 | 118 | if ($relatedRecords === false) { |
119 | - throw new Model\Exception('Error on models relationship ' . $errorMessage); |
|
119 | + throw new Model\Exception('Error on models relationship '.$errorMessage); |
|
120 | 120 | } |
121 | 121 | if ($relatedRecords instanceof Resultset) { |
122 | 122 | foreach ($relatedRecords as $item) { |
123 | 123 | if ($item instanceof ModelsBase) { |
124 | - $newErrorMessage .= '<li>' . $item->getRepresent(true) . '</li>'; |
|
124 | + $newErrorMessage .= '<li>'.$item->getRepresent(true).'</li>'; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } elseif ($relatedRecords instanceof ModelsBase) { |
128 | - $newErrorMessage .= '<li>' . $relatedRecords->getRepresent(true) . '</li>'; |
|
128 | + $newErrorMessage .= '<li>'.$relatedRecords->getRepresent(true).'</li>'; |
|
129 | 129 | } else { |
130 | 130 | $newErrorMessage .= '<li>Unknown object</li>'; |
131 | 131 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if (empty($this->id)) { |
177 | 177 | $name .= $this->t('mo_NewElementCallQueues'); |
178 | 178 | } else { |
179 | - $name .= $this->t('mo_CallQueueShort4Dropdown') . ': ' . $this->name; |
|
179 | + $name .= $this->t('mo_CallQueueShort4Dropdown').': '.$this->name; |
|
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case ConferenceRooms::class: |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if (empty($this->id)) { |
185 | 185 | $name .= $this->t('mo_NewElementConferenceRooms'); |
186 | 186 | } else { |
187 | - $name .= $this->t('mo_ConferenceRoomsShort4Dropdown') . ': ' . $this->name; |
|
187 | + $name .= $this->t('mo_ConferenceRoomsShort4Dropdown').': '.$this->name; |
|
188 | 188 | } |
189 | 189 | break; |
190 | 190 | case CustomFiles::class: |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if (empty($this->id)) { |
196 | 196 | $name .= $this->t('mo_NewElementDialplanApplications'); |
197 | 197 | } else { |
198 | - $name .= $this->t('mo_ApplicationShort4Dropdown') . ': ' . $this->name; |
|
198 | + $name .= $this->t('mo_ApplicationShort4Dropdown').': '.$this->name; |
|
199 | 199 | } |
200 | 200 | break; |
201 | 201 | case ExtensionForwardingRights::class: |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | if (empty($this->id)) { |
258 | 258 | $name .= $this->t('mo_NewElementIax'); |
259 | 259 | } elseif ($this->disabled === '1') { |
260 | - $name .= "{$this->description} ({$this->t( 'mo_Disabled' )})"; |
|
260 | + $name .= "{$this->description} ({$this->t('mo_Disabled')})"; |
|
261 | 261 | } else { |
262 | 262 | $name .= $this->description; |
263 | 263 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | if (empty($this->id)) { |
268 | 268 | $name .= $this->t('mo_NewElementIvrMenu'); |
269 | 269 | } else { |
270 | - $name .= $this->t('mo_IVRMenuShort4Dropdown') . ': ' . $this->name; |
|
270 | + $name .= $this->t('mo_IVRMenuShort4Dropdown').': '.$this->name; |
|
271 | 271 | } |
272 | 272 | break; |
273 | 273 | case IvrMenuActions::class: |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $name = '<i class="map signs icon"></i> '; |
281 | 281 | if (empty($this->id)) { |
282 | 282 | $name .= $this->t('mo_NewElementIncomingRoutingTable'); |
283 | - } elseif ( ! empty($this->note)) { |
|
283 | + } elseif (!empty($this->note)) { |
|
284 | 284 | $name .= $this->t('repIncomingRoutingTable', ['represent' => $this->note]); |
285 | 285 | } else { |
286 | 286 | $name .= $this->t('repIncomingRoutingTableNumber', ['represent' => $this->id]); |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | if (empty($this->id)) { |
296 | 296 | $name .= $this->t('mo_NewElementNetworkFilters'); |
297 | 297 | } else { |
298 | - $name .= $this->description . '(' |
|
299 | - . $this->t('fw_PermitNetwork') . ': ' . $this->permit |
|
298 | + $name .= $this->description.'(' |
|
299 | + . $this->t('fw_PermitNetwork').': '.$this->permit |
|
300 | 300 | . ')'; |
301 | 301 | } |
302 | 302 | break; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $name = '<i class="random icon"></i> '; |
305 | 305 | if (empty($this->id)) { |
306 | 306 | $name .= $this->t('mo_NewElementOutgoingRoutingTable'); |
307 | - } elseif ( ! empty($this->rulename)) { |
|
307 | + } elseif (!empty($this->rulename)) { |
|
308 | 308 | $name .= $this->t('repOutgoingRoutingTable', ['represent' => $this->rulename]); |
309 | 309 | } else { |
310 | 310 | $name .= $this->t('repOutgoingRoutingTableNumber', ['represent' => $this->id]); |
@@ -314,24 +314,24 @@ discard block |
||
314 | 314 | $name = '<i class="time icon"></i> '; |
315 | 315 | if (empty($this->id)) { |
316 | 316 | $name .= $this->t('mo_NewElementOutWorkTimes'); |
317 | - } elseif ( ! empty($this->description)) { |
|
317 | + } elseif (!empty($this->description)) { |
|
318 | 318 | $name .= $this->t('repOutWorkTimes', ['represent' => $this->description]); |
319 | 319 | } else { |
320 | 320 | $represent = ''; |
321 | 321 | if (is_numeric($this->date_from)) { |
322 | - $represent .= date("d/m/Y", $this->date_from) . '-'; |
|
322 | + $represent .= date("d/m/Y", $this->date_from).'-'; |
|
323 | 323 | } |
324 | 324 | if (is_numeric($this->date_to)) { |
325 | - $represent .= date("d/m/Y", $this->date_to) . ' '; |
|
325 | + $represent .= date("d/m/Y", $this->date_to).' '; |
|
326 | 326 | } |
327 | 327 | if (isset($this->weekday_from)) { |
328 | - $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_from} days"))) . '-'; |
|
328 | + $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_from} days"))).'-'; |
|
329 | 329 | } |
330 | 330 | if (isset($this->weekday_to)) { |
331 | - $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_to} days"))) . ' '; |
|
331 | + $represent .= $this->t(date('D', strtotime("Sunday +{$this->weekday_to} days"))).' '; |
|
332 | 332 | } |
333 | 333 | if (isset($this->time_from) || isset($this->time_to)) { |
334 | - $represent .= $this->time_from . ' - ' . $this->time_to . ' '; |
|
334 | + $represent .= $this->time_from.' - '.$this->time_to.' '; |
|
335 | 335 | } |
336 | 336 | $name .= $this->t('repOutWorkTimes', ['represent' => $represent]); |
337 | 337 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | break; |
349 | 349 | case PbxExtensionModules::class: |
350 | 350 | $name = '<i class="puzzle piece icon"></i> ' |
351 | - . $this->t('mo_ModuleShort4Dropdown') . ': ' |
|
351 | + . $this->t('mo_ModuleShort4Dropdown').': ' |
|
352 | 352 | . $this->name; |
353 | 353 | break; |
354 | 354 | case Sip::class: |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | if (empty($this->id)) { |
357 | 357 | $name .= $this->t('mo_NewElementSip'); |
358 | 358 | } elseif ($this->disabled === '1') { |
359 | - $name .= "{$this->description} ({$this->t( 'mo_Disabled' )})"; |
|
359 | + $name .= "{$this->description} ({$this->t('mo_Disabled')})"; |
|
360 | 360 | } else { |
361 | 361 | $name .= $this->description; |
362 | 362 | } |
363 | 363 | |
364 | 364 | break; |
365 | 365 | case Users::class: |
366 | - $name = '<i class="user outline icon"></i> ' . $this->username; |
|
366 | + $name = '<i class="user outline icon"></i> '.$this->username; |
|
367 | 367 | break; |
368 | 368 | case SoundFiles::class: |
369 | 369 | $name = '<i class="file audio outline icon"></i> '; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $link = $this->getWebInterfaceLink(); |
383 | 383 | $category = explode('\\', static::class)[3]; |
384 | 384 | $result = $this->t( |
385 | - 'rep' . $category, |
|
385 | + 'rep'.$category, |
|
386 | 386 | [ |
387 | 387 | 'represent' => "<a href='{$link}'>{$name}</a>", |
388 | 388 | ] |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | |
408 | 408 | if (strlen($s) > $max_length) { |
409 | 409 | $offset = ($max_length - 3) - strlen($s); |
410 | - $s = substr($s, 0, strrpos($s, ' ', $offset)) . '...'; |
|
410 | + $s = substr($s, 0, strrpos($s, ' ', $offset)).'...'; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | return $s; |
@@ -426,80 +426,80 @@ discard block |
||
426 | 426 | $link = '#'; |
427 | 427 | switch (static::class) { |
428 | 428 | case AsteriskManagerUsers::class: |
429 | - $link = $url->get('asterisk-managers/modify/' . $this->id, null, null, $baseUri); |
|
429 | + $link = $url->get('asterisk-managers/modify/'.$this->id, null, null, $baseUri); |
|
430 | 430 | break; |
431 | 431 | case CallQueueMembers::class: |
432 | - $link = $url->get('call-queues/modify/' . $this->CallQueues->uniqid, null, null, $baseUri); |
|
432 | + $link = $url->get('call-queues/modify/'.$this->CallQueues->uniqid, null, null, $baseUri); |
|
433 | 433 | break; |
434 | 434 | case CallQueues::class: |
435 | - $link = $url->get('call-queues/modify/' . $this->uniqid, null, null, $baseUri); |
|
435 | + $link = $url->get('call-queues/modify/'.$this->uniqid, null, null, $baseUri); |
|
436 | 436 | break; |
437 | 437 | case ConferenceRooms::class: |
438 | - $link = $url->get('conference-rooms/modify/' . $this->uniqid, null, null, $baseUri); |
|
438 | + $link = $url->get('conference-rooms/modify/'.$this->uniqid, null, null, $baseUri); |
|
439 | 439 | break; |
440 | 440 | case CustomFiles::class: |
441 | - $link = $url->get('custom-files/modify/' . $this->id, null, null, $baseUri); |
|
441 | + $link = $url->get('custom-files/modify/'.$this->id, null, null, $baseUri); |
|
442 | 442 | break; |
443 | 443 | case DialplanApplications::class: |
444 | - $link = $url->get('dialplan-applications/modify/' . $this->uniqid, null, null, $baseUri); |
|
444 | + $link = $url->get('dialplan-applications/modify/'.$this->uniqid, null, null, $baseUri); |
|
445 | 445 | break; |
446 | 446 | case ExtensionForwardingRights::class: |
447 | 447 | |
448 | 448 | break; |
449 | 449 | case Extensions::class: |
450 | - $link = $url->get('extensions/modify/' . $this->id, null, null, $baseUri); |
|
450 | + $link = $url->get('extensions/modify/'.$this->id, null, null, $baseUri); |
|
451 | 451 | break; |
452 | 452 | case ExternalPhones::class: |
453 | 453 | if ($this->Extensions->is_general_user_number === "1") { |
454 | - $parameters = [ |
|
455 | - 'conditions' => 'is_general_user_number="1" AND type="' . Extensions::TYPE_EXTERNAL . '" AND userid=:userid:', |
|
454 | + $parameters = [ |
|
455 | + 'conditions' => 'is_general_user_number="1" AND type="'.Extensions::TYPE_EXTERNAL.'" AND userid=:userid:', |
|
456 | 456 | 'bind' => [ |
457 | 457 | 'userid' => $this->Extensions->userid, |
458 | 458 | ], |
459 | 459 | ]; |
460 | 460 | $needExtension = Extensions::findFirst($parameters); |
461 | - $link = $url->get('extensions/modify/' . $needExtension->id, null, null, $baseUri); |
|
461 | + $link = $url->get('extensions/modify/'.$needExtension->id, null, null, $baseUri); |
|
462 | 462 | } else { |
463 | - $link = '#';//TODO сделать если будет раздел для допоплнинельных номеров пользователя |
|
463 | + $link = '#'; //TODO сделать если будет раздел для допоплнинельных номеров пользователя |
|
464 | 464 | } |
465 | 465 | break; |
466 | 466 | case Fail2BanRules::class: |
467 | - $link = '#';//TODO сделать если будет fail2ban |
|
467 | + $link = '#'; //TODO сделать если будет fail2ban |
|
468 | 468 | break; |
469 | 469 | case FirewallRules::class: |
470 | - $link = $url->get('firewall/modify/' . $this->NetworkFilters->id, null, null, $baseUri); |
|
470 | + $link = $url->get('firewall/modify/'.$this->NetworkFilters->id, null, null, $baseUri); |
|
471 | 471 | break; |
472 | 472 | case Iax::class: |
473 | - $link = $url->get('providers/modifyiax/' . $this->Providers->id, null, null, $baseUri); |
|
473 | + $link = $url->get('providers/modifyiax/'.$this->Providers->id, null, null, $baseUri); |
|
474 | 474 | break; |
475 | 475 | case IvrMenu::class: |
476 | - $link = $url->get('ivr-menu/modify/' . $this->uniqid, null, null, $baseUri); |
|
476 | + $link = $url->get('ivr-menu/modify/'.$this->uniqid, null, null, $baseUri); |
|
477 | 477 | break; |
478 | 478 | case IvrMenuActions::class: |
479 | - $link = $url->get('ivr-menu/modify/' . $this->IvrMenu->uniqid, null, null, $baseUri); |
|
479 | + $link = $url->get('ivr-menu/modify/'.$this->IvrMenu->uniqid, null, null, $baseUri); |
|
480 | 480 | break; |
481 | 481 | case Codecs::class: |
482 | 482 | break; |
483 | 483 | case IncomingRoutingTable::class: |
484 | - $link = $url->get('incoming-routes/modify/' . $this->id, null, null, $baseUri); |
|
484 | + $link = $url->get('incoming-routes/modify/'.$this->id, null, null, $baseUri); |
|
485 | 485 | break; |
486 | 486 | case LanInterfaces::class: |
487 | 487 | $link = $url->get('network/index/', null, null, $baseUri); |
488 | 488 | break; |
489 | 489 | case NetworkFilters::class: |
490 | - $link = $url->get('firewall/modify/' . $this->id, null, null, $baseUri); |
|
490 | + $link = $url->get('firewall/modify/'.$this->id, null, null, $baseUri); |
|
491 | 491 | break; |
492 | 492 | case OutgoingRoutingTable::class: |
493 | - $link = $url->get('outbound-routes/modify/' . $this->id, null, null, $baseUri); |
|
493 | + $link = $url->get('outbound-routes/modify/'.$this->id, null, null, $baseUri); |
|
494 | 494 | break; |
495 | 495 | case OutWorkTimes::class: |
496 | - $link = $url->get('out-off-work-time/modify/' . $this->id, null, null, $baseUri); |
|
496 | + $link = $url->get('out-off-work-time/modify/'.$this->id, null, null, $baseUri); |
|
497 | 497 | break; |
498 | 498 | case Providers::class: |
499 | 499 | if ($this->type === "IAX") { |
500 | - $link = $url->get('providers/modifyiax/' . $this->uniqid, null, null, $baseUri); |
|
500 | + $link = $url->get('providers/modifyiax/'.$this->uniqid, null, null, $baseUri); |
|
501 | 501 | } else { |
502 | - $link = $url->get('providers/modifysip/' . $this->uniqid, null, null, $baseUri); |
|
502 | + $link = $url->get('providers/modifysip/'.$this->uniqid, null, null, $baseUri); |
|
503 | 503 | } |
504 | 504 | break; |
505 | 505 | case PbxSettings::class: |
@@ -511,26 +511,26 @@ discard block |
||
511 | 511 | case Sip::class: |
512 | 512 | if ($this->Extensions) { // Это внутренний номер? |
513 | 513 | if ($this->Extensions->is_general_user_number === "1") { |
514 | - $link = $url->get('extensions/modify/' . $this->Extensions->id, null, null, $baseUri); |
|
514 | + $link = $url->get('extensions/modify/'.$this->Extensions->id, null, null, $baseUri); |
|
515 | 515 | } else { |
516 | - $link = '#';//TODO сделать если будет раздел для допоплнинельных номеров пользователя |
|
516 | + $link = '#'; //TODO сделать если будет раздел для допоплнинельных номеров пользователя |
|
517 | 517 | } |
518 | 518 | } elseif ($this->Providers) { // Это провайдер |
519 | - $link = $url->get('providers/modifysip/' . $this->Providers->id, null, null, $baseUri); |
|
519 | + $link = $url->get('providers/modifysip/'.$this->Providers->id, null, null, $baseUri); |
|
520 | 520 | } |
521 | 521 | break; |
522 | 522 | case Users::class: |
523 | - $parameters = [ |
|
523 | + $parameters = [ |
|
524 | 524 | 'conditions' => 'userid=:userid:', |
525 | 525 | 'bind' => [ |
526 | 526 | 'userid' => $this->id, |
527 | 527 | ], |
528 | 528 | ]; |
529 | 529 | $needExtension = Extensions::findFirst($parameters); |
530 | - $link = $url->get('extensions/modify/' . $needExtension->id, null, null, $baseUri); |
|
530 | + $link = $url->get('extensions/modify/'.$needExtension->id, null, null, $baseUri); |
|
531 | 531 | break; |
532 | 532 | case SoundFiles::class: |
533 | - $link = $url->get('sound-files/modify/' . $this->id, null, null, $baseUri); |
|
533 | + $link = $url->get('sound-files/modify/'.$this->id, null, null, $baseUri); |
|
534 | 534 | break; |
535 | 535 | default: |
536 | 536 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | $metaData = $this->di->get('modelsMetadata'); |
547 | 547 | $defaultValues = $metaData->getDefaultValues($this); |
548 | 548 | foreach ($defaultValues as $field => $value) { |
549 | - if ( ! isset($this->{$field})) { |
|
549 | + if (!isset($this->{$field})) { |
|
550 | 550 | $this->{$field} = $value; |
551 | 551 | } |
552 | 552 | } |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | = $currentDeleteRecord->_modelsManager->getRelations(get_class($currentDeleteRecord)); |
681 | 681 | foreach ($relations as $relation) { |
682 | 682 | $foreignKey = $relation->getOption('foreignKey'); |
683 | - if ( ! array_key_exists('action', $foreignKey)) { |
|
683 | + if (!array_key_exists('action', $foreignKey)) { |
|
684 | 684 | continue; |
685 | 685 | } |
686 | 686 | // Check if there are some record which restrict delete current record |
@@ -698,10 +698,10 @@ discard block |
||
698 | 698 | ? ' OR ' : ''; |
699 | 699 | $parameters['conditions'] .= $referencedField |
700 | 700 | . '= :field' |
701 | - . $index . ':'; |
|
701 | + . $index.':'; |
|
702 | 702 | $bindField |
703 | 703 | = $mappedFields[$index]; |
704 | - $parameters['bind']['field' . $index] = $currentDeleteRecord->$bindField; |
|
704 | + $parameters['bind']['field'.$index] = $currentDeleteRecord->$bindField; |
|
705 | 705 | } |
706 | 706 | $relatedRecords = $relatedModel::find($parameters); |
707 | 707 | switch ($foreignKey['action']) { |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | if (php_sapi_name() === 'cli') { |
776 | 776 | return; |
777 | 777 | } |
778 | - if ( ! $this->hasSnapshotData()) { |
|
778 | + if (!$this->hasSnapshotData()) { |
|
779 | 779 | return; |
780 | 780 | } // nothing changed |
781 | 781 | |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | { |
798 | 798 | // Add changed fields set to Beanstalkd queue |
799 | 799 | $queue = $this->di->getShared('beanstalkConnectionModels'); |
800 | - if ($queue===null){ |
|
800 | + if ($queue === null) { |
|
801 | 801 | return; |
802 | 802 | } |
803 | 803 | if ($this instanceof PbxSettings) { |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | // Вызов будет отвечен сразу конференцией. |
576 | 576 | $dial_command = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Goto(internal,{$rout['extension']},1));"; |
577 | 577 | $rout_data_dial[$rout_number] .= ""; |
578 | - }else{ |
|
578 | + } else{ |
|
579 | 579 | $dial_command = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));"; |
580 | 580 | $rout_data_dial[$rout_number] .= " \n\t" . "same => n,Set(M_TIMEOUT={$timeout})"; |
581 | 581 | } |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | if ($add_login_pattern && array_key_exists('X!', $rout_data_dial) && isset($dialplan['X!'])) { |
617 | 617 | $dialplan[$login] = str_replace('_X!,1', "{$login},1", $dialplan['X!']); |
618 | 618 | $rout_data_dial[$login] = $rout_data_dial['X!']; |
619 | - }elseif($add_login_pattern === true && $need_def_rout === true && count($data) === 1){ |
|
619 | + } elseif($add_login_pattern === true && $need_def_rout === true && count($data) === 1){ |
|
620 | 620 | // Только маршрут "По умолчанию". |
621 | 621 | $dialplan[$login] = str_replace('_X!,1', "{$login},1", $dialplan['X!']); |
622 | 622 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | // Это конференция. Тут не требуется обработка таймаута ответа. |
651 | 651 | // Вызов будет отвечен сразу конференцией. |
652 | 652 | $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Goto(internal,{$default_action->extension},1)); default action" . "\n"; |
653 | - }else { |
|
653 | + } else { |
|
654 | 654 | $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action" . "\n"; |
655 | 655 | } |
656 | 656 | foreach ($additionalModules as $appClass) { |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | $additionalModules = $this->di->getShared('pbxConfModules'); |
27 | 27 | $conf = "[globals] \n". |
28 | 28 | "TRANSFER_CONTEXT=internal-transfer; \n"; |
29 | - if($this->generalSettings['PBXRecordCalls'] === '1'){ |
|
30 | - $conf.="MONITOR_DIR=".Storage::getMonitorDir()." \n"; |
|
31 | - $conf.="MONITOR_STEREO=".$this->generalSettings['PBXSplitAudioThread']." \n"; |
|
29 | + if ($this->generalSettings['PBXRecordCalls'] === '1') { |
|
30 | + $conf .= "MONITOR_DIR=".Storage::getMonitorDir()." \n"; |
|
31 | + $conf .= "MONITOR_STEREO=".$this->generalSettings['PBXSplitAudioThread']." \n"; |
|
32 | 32 | } |
33 | 33 | foreach ($additionalModules as $appClass) { |
34 | 34 | $addition = $appClass->extensionGlobals(); |
35 | - if (!empty($addition)){ |
|
36 | - $conf .=$appClass->confBlockWithComments($addition); |
|
35 | + if (!empty($addition)) { |
|
36 | + $conf .= $appClass->confBlockWithComments($addition); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | $conf .= "\n"; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | // Переключатель по времени. |
57 | 57 | $this->generateOutWorkTimes($conf); |
58 | 58 | |
59 | - Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/extensions.conf', $conf); |
|
59 | + Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/extensions.conf', $conf); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -68,68 +68,68 @@ discard block |
||
68 | 68 | { |
69 | 69 | $extension = 'X!'; |
70 | 70 | // Контекст для AMI originate. Без него отображается не корректный CallerID. |
71 | - $conf .= '[sipregistrations]' . "\n\n"; |
|
71 | + $conf .= '[sipregistrations]'."\n\n"; |
|
72 | 72 | |
73 | - $conf .= '[messages]' . "\n" . |
|
74 | - 'exten => _' . $extension . ',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})' . "\n\n"; |
|
73 | + $conf .= '[messages]'."\n". |
|
74 | + 'exten => _'.$extension.',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})'."\n\n"; |
|
75 | 75 | |
76 | - $conf .= '[internal-originate]' . " \n"; |
|
77 | - $conf .= 'exten => _' . $extension . ',1,NoOP(Hint ${HINT} exten ${EXTEN} )' . " \n"; |
|
78 | - $conf .= '; Если это originate, то скроем один CDR.' . " \n\t"; |
|
79 | - $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))' . " \n\t"; |
|
76 | + $conf .= '[internal-originate]'." \n"; |
|
77 | + $conf .= 'exten => _'.$extension.',1,NoOP(Hint ${HINT} exten ${EXTEN} )'." \n"; |
|
78 | + $conf .= '; Если это originate, то скроем один CDR.'." \n\t"; |
|
79 | + $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))'." \n\t"; |
|
80 | 80 | |
81 | - $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))' . " \n\t"; |
|
82 | - $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))' . " \n\t"; |
|
81 | + $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))'." \n\t"; |
|
82 | + $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))'." \n\t"; |
|
83 | 83 | |
84 | 84 | // Описываем возможность прыжка в пользовательский sub контекст. |
85 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t"; |
|
86 | - $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,cTteKkHhb(originate_create_chan,s,1))' . " \n\n"; |
|
87 | - |
|
88 | - $conf .= '[originate_create_chan]' . " \n"; |
|
89 | - $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t"; |
|
90 | - $conf .= 'same => n,return' . " \n\n"; |
|
91 | - |
|
92 | - $conf .= '[dial_create_chan]' . " \n"; |
|
93 | - $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)' . "\n\t"; |
|
94 | - $conf .= 'same => n,Set(pt1c_is_dst=1)' . " \n\t"; |
|
95 | - $conf .= 'same => n,ExecIf($["${PT1C_SIP_HEADER}x" != "x"]?Set(PJSIP_HEADER(add,${CUT(PT1C_SIP_HEADER,:,1)})=${CUT(PT1C_SIP_HEADER,:,2)}))' . " \n\t"; |
|
96 | - $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})' . " \n\t"; |
|
97 | - $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t"; |
|
98 | - $conf .= 'same => n,return' . " \n\n"; |
|
99 | - |
|
100 | - $conf .= '[hangup_handler]' . "\n"; |
|
101 | - $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)' . "\n\t"; |
|
102 | - $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)' . "\n\t"; |
|
103 | - |
|
104 | - $conf .= 'same => n,return' . "\n\n"; |
|
105 | - |
|
106 | - $conf .= '[set_orign_chan]' . "\n"; |
|
107 | - $conf .= 'exten => s,1,Wait(0.2)' . "\n\t"; |
|
108 | - $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})' . "\n\t"; |
|
109 | - $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})' . "\n\t"; |
|
110 | - $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))' . "\n\t"; |
|
111 | - $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))' . "\n\t"; |
|
112 | - $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))' . "\n\t"; |
|
113 | - $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))' . "\n\t"; |
|
114 | - $conf .= 'same => n,return' . "\n\n"; |
|
115 | - |
|
116 | - $conf .= '[playback]' . "\n"; |
|
117 | - $conf .= 'exten => s,1,Playback(hello_demo,noanswer)' . "\n\t"; |
|
118 | - $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))' . "\n\t"; |
|
119 | - $conf .= 'same => n,Wait(0.3)' . "\n\t"; |
|
120 | - $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)' . "\n\n"; |
|
121 | - |
|
122 | - $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n"; |
|
85 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t"; |
|
86 | + $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,cTteKkHhb(originate_create_chan,s,1))'." \n\n"; |
|
87 | + |
|
88 | + $conf .= '[originate_create_chan]'." \n"; |
|
89 | + $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t"; |
|
90 | + $conf .= 'same => n,return'." \n\n"; |
|
91 | + |
|
92 | + $conf .= '[dial_create_chan]'." \n"; |
|
93 | + $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)'."\n\t"; |
|
94 | + $conf .= 'same => n,Set(pt1c_is_dst=1)'." \n\t"; |
|
95 | + $conf .= 'same => n,ExecIf($["${PT1C_SIP_HEADER}x" != "x"]?Set(PJSIP_HEADER(add,${CUT(PT1C_SIP_HEADER,:,1)})=${CUT(PT1C_SIP_HEADER,:,2)}))'." \n\t"; |
|
96 | + $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})'." \n\t"; |
|
97 | + $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t"; |
|
98 | + $conf .= 'same => n,return'." \n\n"; |
|
99 | + |
|
100 | + $conf .= '[hangup_handler]'."\n"; |
|
101 | + $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)'."\n\t"; |
|
102 | + $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)'."\n\t"; |
|
103 | + |
|
104 | + $conf .= 'same => n,return'."\n\n"; |
|
105 | + |
|
106 | + $conf .= '[set_orign_chan]'."\n"; |
|
107 | + $conf .= 'exten => s,1,Wait(0.2)'."\n\t"; |
|
108 | + $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})'."\n\t"; |
|
109 | + $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})'."\n\t"; |
|
110 | + $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))'."\n\t"; |
|
111 | + $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))'."\n\t"; |
|
112 | + $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))'."\n\t"; |
|
113 | + $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))'."\n\t"; |
|
114 | + $conf .= 'same => n,return'."\n\n"; |
|
115 | + |
|
116 | + $conf .= '[playback]'."\n"; |
|
117 | + $conf .= 'exten => s,1,Playback(hello_demo,noanswer)'."\n\t"; |
|
118 | + $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))'."\n\t"; |
|
119 | + $conf .= 'same => n,Wait(0.3)'."\n\t"; |
|
120 | + $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)'."\n\n"; |
|
121 | + |
|
122 | + $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n"; |
|
123 | 123 | |
124 | 124 | // TODO / Добавление / удаление префиксов на входящий callerid. |
125 | - $conf .= '[add-trim-prefix-clid]' . "\n"; |
|
126 | - $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)' . "\n\t"; |
|
127 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t"; |
|
125 | + $conf .= '[add-trim-prefix-clid]'."\n"; |
|
126 | + $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)'."\n\t"; |
|
127 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t"; |
|
128 | 128 | // Отсекаем "+". |
129 | 129 | // $conf.= 'same => n,ExecIf( $["${CALLERID(num):0:1}" == "+"]?Set(CALLERID(num)=${CALLERID(num):1}))'."\n\t"; |
130 | 130 | // Отсекаем "7" и добавляем "8". |
131 | 131 | // $conf.= 'same => n,ExecIf( $["${REGEX("^7[0-9]+" ${CALLERID(num)})}" == "1"]?Set(CALLERID(num)=8${CALLERID(num):1}))'."\n\t"; |
132 | - $conf .= 'same => n,return' . "\n\n"; |
|
132 | + $conf .= 'same => n,return'."\n\n"; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -145,136 +145,136 @@ discard block |
||
145 | 145 | $additionalModules = $this->di->getShared('pbxConfModules'); |
146 | 146 | foreach ($additionalModules as $appClass) { |
147 | 147 | $addition = $appClass->extensionGenContexts(); |
148 | - if (!empty($addition)){ |
|
149 | - $conf .=$appClass->confBlockWithComments($addition); |
|
148 | + if (!empty($addition)) { |
|
149 | + $conf .= $appClass->confBlockWithComments($addition); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | $conf .= "\n"; |
153 | 153 | $conf .= "[internal-num-undefined] \n"; |
154 | - $conf .= 'exten => _' . $extension . ',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t"; |
|
155 | - $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t"; |
|
154 | + $conf .= 'exten => _'.$extension.',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t"; |
|
155 | + $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t"; |
|
156 | 156 | $conf .= "same => n,Playback(pbx-invalid,noanswer) \n\n"; |
157 | 157 | |
158 | 158 | $conf .= "[internal-fw]\n"; |
159 | - $conf .= 'exten => _' . $extension . ',1,NoOp(DIALSTATUS - ${DIALSTATUS})' . "\n\t"; |
|
159 | + $conf .= 'exten => _'.$extension.',1,NoOp(DIALSTATUS - ${DIALSTATUS})'."\n\t"; |
|
160 | 160 | // CANCEL - вызов был отменен, к примеру *0, не нужно дальше искать адресат. |
161 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())' . "\n\t"; |
|
161 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())'."\n\t"; |
|
162 | 162 | // BUSY - занято. К примру абонент завершил вызов или DND. |
163 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))' . "\n\t"; |
|
163 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))'."\n\t"; |
|
164 | 164 | // CHANUNAVAIL - канал не доступен. К примеру телефон не зарегистрирован или не отвечает. |
165 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))' . "\n\t"; |
|
165 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))'."\n\t"; |
|
166 | 166 | // NOANSWER - не ответили по таймауту. |
167 | - $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))' . "\n\t"; |
|
168 | - $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})' . "\n\t"; |
|
169 | - $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})' . "\n\t"; |
|
170 | - $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))' . "\n\t"; |
|
171 | - $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t"; |
|
172 | - $conf .= 'same => n,Hangup() ' . "\n\n"; |
|
167 | + $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))'."\n\t"; |
|
168 | + $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})'."\n\t"; |
|
169 | + $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})'."\n\t"; |
|
170 | + $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))'."\n\t"; |
|
171 | + $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t"; |
|
172 | + $conf .= 'same => n,Hangup() '."\n\n"; |
|
173 | 173 | |
174 | 174 | $conf .= "[all_peers]\n"; |
175 | - $conf .= 'include => internal-hints' . "\n"; |
|
176 | - $conf .= 'exten => failed,1,Hangup()' . "\n"; |
|
175 | + $conf .= 'include => internal-hints'."\n"; |
|
176 | + $conf .= 'exten => failed,1,Hangup()'."\n"; |
|
177 | 177 | |
178 | - $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())' . "\n\t"; |
|
178 | + $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())'."\n\t"; |
|
179 | 179 | // Фильтр спецсимволов. Разершаем только цифры. |
180 | - $conf .= 'same => n,Set(cleanNumber=${FILTER(\*\#1234567890,${EXTEN})})' . "\n\t"; |
|
181 | - $conf .= 'same => n,ExecIf($["${EXTEN}" != "${cleanNumber}"]?Goto(${CONTEXT},${cleanNumber},$[${PRIORITY} + 1]))' . "\n\t"; |
|
180 | + $conf .= 'same => n,Set(cleanNumber=${FILTER(\*\#1234567890,${EXTEN})})'."\n\t"; |
|
181 | + $conf .= 'same => n,ExecIf($["${EXTEN}" != "${cleanNumber}"]?Goto(${CONTEXT},${cleanNumber},$[${PRIORITY} + 1]))'."\n\t"; |
|
182 | 182 | |
183 | - $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t"; |
|
184 | - $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CHANNEL(linkedid)}))' . "\n\t"; |
|
185 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t"; |
|
186 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . "\n\t"; |
|
183 | + $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t"; |
|
184 | + $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CHANNEL(linkedid)}))'."\n\t"; |
|
185 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t"; |
|
186 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'."\n\t"; |
|
187 | 187 | |
188 | - $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))' . "\n\t"; |
|
189 | - $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))' . "\n\t"; |
|
188 | + $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))'."\n\t"; |
|
189 | + $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))'."\n\t"; |
|
190 | 190 | |
191 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t"; |
|
192 | - $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t"; |
|
193 | - $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t"; |
|
191 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t"; |
|
192 | + $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t"; |
|
193 | + $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t"; |
|
194 | 194 | |
195 | 195 | // Описываем возможность прыжка в пользовательский sub контекст. |
196 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t"; |
|
196 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t"; |
|
197 | 197 | |
198 | - $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)' . "\n\n"; |
|
198 | + $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)'."\n\n"; |
|
199 | 199 | |
200 | - $pickupexten = $this->generalSettings['PBXFeaturePickupExten']; |
|
201 | - $conf .= 'exten => _' . $pickupexten . $extension . ',1,Set(PICKUPEER=' . $technology . '/${FILTER(0-9,${EXTEN:2})})' . "\n\t"; |
|
202 | - $conf .= 'same => n,Set(pt1c_dnid=${EXTEN})' . "\n\t"; |
|
203 | - $conf .= 'same => n,PickupChan(${PICKUPEER})' . "\n\t"; |
|
204 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
200 | + $pickupexten = $this->generalSettings['PBXFeaturePickupExten']; |
|
201 | + $conf .= 'exten => _'.$pickupexten.$extension.',1,Set(PICKUPEER='.$technology.'/${FILTER(0-9,${EXTEN:2})})'."\n\t"; |
|
202 | + $conf .= 'same => n,Set(pt1c_dnid=${EXTEN})'."\n\t"; |
|
203 | + $conf .= 'same => n,PickupChan(${PICKUPEER})'."\n\t"; |
|
204 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
205 | 205 | |
206 | 206 | $voicemail_exten = $this->generalSettings['VoicemailExten']; |
207 | - $conf .= 'exten => ' . $voicemail_exten . ',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)' . "\n\t"; |
|
208 | - $conf .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)' . "\n\t"; |
|
209 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
207 | + $conf .= 'exten => '.$voicemail_exten.',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)'."\n\t"; |
|
208 | + $conf .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)'."\n\t"; |
|
209 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
210 | 210 | |
211 | 211 | $conf .= "[voice_mail_peer] \n"; |
212 | - $conf .= 'exten => voicemail,1,Answer()' . "\n\t"; |
|
213 | - $conf .= 'same => n,VoiceMail(admin@voicemailcontext)' . "\n\t"; |
|
214 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
212 | + $conf .= 'exten => voicemail,1,Answer()'."\n\t"; |
|
213 | + $conf .= 'same => n,VoiceMail(admin@voicemailcontext)'."\n\t"; |
|
214 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
215 | 215 | |
216 | 216 | // Контекст для внутренних вызовов. |
217 | 217 | $conf .= "[internal] \n"; |
218 | 218 | |
219 | 219 | foreach ($additionalModules as $appClass) { |
220 | 220 | $addition = $appClass->getIncludeInternal(); |
221 | - if (!empty($addition)){ |
|
222 | - $conf .=$appClass->confBlockWithComments($addition); |
|
221 | + if (!empty($addition)) { |
|
222 | + $conf .= $appClass->confBlockWithComments($addition); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | 226 | foreach ($additionalModules as $appClass) { |
227 | 227 | $addition = $appClass->extensionGenInternal(); |
228 | - if (!empty($addition)){ |
|
229 | - $conf .=$appClass->confBlockWithComments($addition); |
|
228 | + if (!empty($addition)) { |
|
229 | + $conf .= $appClass->confBlockWithComments($addition); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | - $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)' . "\n\t"; |
|
234 | - $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)' . "\n\t"; |
|
235 | - $conf .= 'same => n,Playback(privacy-incorrect,noanswer)' . "\n\t"; |
|
236 | - $conf .= 'same => n,Hangup()' . "\n"; |
|
233 | + $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)'."\n\t"; |
|
234 | + $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)'."\n\t"; |
|
235 | + $conf .= 'same => n,Playback(privacy-incorrect,noanswer)'."\n\t"; |
|
236 | + $conf .= 'same => n,Hangup()'."\n"; |
|
237 | 237 | |
238 | - $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n"; |
|
238 | + $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n"; |
|
239 | 239 | |
240 | 240 | $conf .= "[internal-incoming]\n"; |
241 | - $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))' . " \n\t"; |
|
242 | - $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})' . " \n\t"; |
|
243 | - $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})' . " \n\t"; |
|
244 | - $conf .= 'same => n,Goto(internal,${EXTEN},1)' . " \n\n"; |
|
241 | + $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))'." \n\t"; |
|
242 | + $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})'." \n\t"; |
|
243 | + $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})'." \n\t"; |
|
244 | + $conf .= 'same => n,Goto(internal,${EXTEN},1)'." \n\n"; |
|
245 | 245 | |
246 | 246 | $conf .= "[internal-users] \n"; |
247 | - $conf .= 'exten => _' . $extension . ',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t"; |
|
248 | - $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})' . " \n\t"; |
|
249 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . " \n\t"; |
|
247 | + $conf .= 'exten => _'.$extension.',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t"; |
|
248 | + $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})'." \n\t"; |
|
249 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'." \n\t"; |
|
250 | 250 | |
251 | - $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t"; |
|
251 | + $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t"; |
|
252 | 252 | // Проверим, существует ли такой пир. |
253 | 253 | |
254 | - $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))' . " \n\t"; |
|
255 | - $conf .= 'same => n,ExecIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))' . " \n\t"; |
|
256 | - $conf .= 'same => n,GotoIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?fw_start)' . " \n\t"; |
|
254 | + $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))'." \n\t"; |
|
255 | + $conf .= 'same => n,ExecIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))'." \n\t"; |
|
256 | + $conf .= 'same => n,GotoIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?fw_start)'." \n\t"; |
|
257 | 257 | |
258 | 258 | // Как долго звонить пиру. |
259 | - $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})' . " \n\t"; |
|
260 | - $conf .= 'same => n,ExecIf($["${ringlength}x" == "x"]?Set(ringlength=600))' . " \n\t"; |
|
261 | - $conf .= 'same => n,ExecIf($["${QUEUE_SRC_CHAN}x" != "x" && "${ISTRANSFER}x" == "x"]?Set(ringlength=600))' . " \n\t"; |
|
259 | + $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})'." \n\t"; |
|
260 | + $conf .= 'same => n,ExecIf($["${ringlength}x" == "x"]?Set(ringlength=600))'." \n\t"; |
|
261 | + $conf .= 'same => n,ExecIf($["${QUEUE_SRC_CHAN}x" != "x" && "${ISTRANSFER}x" == "x"]?Set(ringlength=600))'." \n\t"; |
|
262 | 262 | |
263 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) ' . " \n\t"; |
|
263 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) '." \n\t"; |
|
264 | 264 | // Совершаем вызов пира. |
265 | - $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})' . " \n\t"; |
|
266 | - $conf .= 'same => n,ExecIf($["${FIELDQTY(DST_CONTACT,&)}" != "1"]?Set(__PT1C_SIP_HEADER=${EMPTY_VAR}))' . " \n\t"; |
|
267 | - $conf .= 'same => n,ExecIf($["${DST_CONTACT}x" != "x"]?Dial(${DST_CONTACT},${ringlength},cTtekKHhU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1)):Set(DIALSTATUS=CHANUNAVAIL))' . " \n\t"; |
|
268 | - $conf .= 'same => n(fw_start),NoOp(dial_hangup)' . " \n\t"; |
|
265 | + $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})'." \n\t"; |
|
266 | + $conf .= 'same => n,ExecIf($["${FIELDQTY(DST_CONTACT,&)}" != "1"]?Set(__PT1C_SIP_HEADER=${EMPTY_VAR}))'." \n\t"; |
|
267 | + $conf .= 'same => n,ExecIf($["${DST_CONTACT}x" != "x"]?Dial(${DST_CONTACT},${ringlength},cTtekKHhU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1)):Set(DIALSTATUS=CHANUNAVAIL))'." \n\t"; |
|
268 | + $conf .= 'same => n(fw_start),NoOp(dial_hangup)'." \n\t"; |
|
269 | 269 | |
270 | 270 | // QUEUE_SRC_CHAN - установлена, если вызов сервершен агенту очереди. |
271 | 271 | // Проверяем нужна ли переадресация |
272 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${ISTRANSFER}x" != "x"]?Goto(internal-fw,${EXTEN},1))' . " \n\t"; |
|
273 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]?Goto(internal-fw,${EXTEN},1))' . " \n\t"; |
|
274 | - $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t"; |
|
275 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
272 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${ISTRANSFER}x" != "x"]?Goto(internal-fw,${EXTEN},1))'." \n\t"; |
|
273 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]?Goto(internal-fw,${EXTEN},1))'." \n\t"; |
|
274 | + $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t"; |
|
275 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
276 | 276 | |
277 | - $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n"; |
|
277 | + $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n"; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | private function generateInternalTransfer(&$conf): void |
286 | 286 | { |
287 | 287 | $additionalModules = $this->di->getShared('pbxConfModules'); |
288 | - $conf .= "[internal-transfer] \n"; |
|
288 | + $conf .= "[internal-transfer] \n"; |
|
289 | 289 | |
290 | 290 | foreach ($additionalModules as $appClass) { |
291 | - $addition= $appClass->getIncludeInternalTransfer(); |
|
292 | - if (!empty($addition)){ |
|
293 | - $conf .=$appClass->confBlockWithComments($addition); |
|
291 | + $addition = $appClass->getIncludeInternalTransfer(); |
|
292 | + if (!empty($addition)) { |
|
293 | + $conf .= $appClass->confBlockWithComments($addition); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
297 | 297 | foreach ($additionalModules as $appClass) { |
298 | - $addition= $appClass->extensionGenInternalTransfer(); |
|
299 | - if (!empty($addition)){ |
|
300 | - $conf .=$appClass->confBlockWithComments($addition); |
|
298 | + $addition = $appClass->extensionGenInternalTransfer(); |
|
299 | + if (!empty($addition)) { |
|
300 | + $conf .= $appClass->confBlockWithComments($addition); |
|
301 | 301 | } |
302 | 302 | } |
303 | - $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)' . "\n\n"; |
|
303 | + $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)'."\n\n"; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | private function generateSipHints(&$conf): void |
312 | 312 | { |
313 | 313 | $additionalModules = $this->di->getShared('pbxConfModules'); |
314 | - $conf .= "[internal-hints] \n"; |
|
314 | + $conf .= "[internal-hints] \n"; |
|
315 | 315 | foreach ($additionalModules as $appClass) { |
316 | 316 | $addition = $appClass->extensionGenHints(); |
317 | - if (!empty($addition)){ |
|
318 | - $conf .=$appClass->confBlockWithComments($addition); |
|
317 | + if (!empty($addition)) { |
|
318 | + $conf .= $appClass->confBlockWithComments($addition); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | $conf .= "\n\n"; |
@@ -329,16 +329,16 @@ discard block |
||
329 | 329 | private function generateOutContextPeers(&$conf): void |
330 | 330 | { |
331 | 331 | $additionalModules = $this->di->getShared('pbxConfModules'); |
332 | - $conf .= "[outgoing] \n"; |
|
332 | + $conf .= "[outgoing] \n"; |
|
333 | 333 | |
334 | - $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to +)' . " \n\t"; |
|
335 | - $conf .= 'same => n,Set(ADDPLUS=+);' . " \n\t"; |
|
336 | - $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);' . " \n\n"; |
|
337 | - $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)' . " \n\t"; |
|
338 | - $conf .= 'same => n,Ringing()' . " \n\t"; |
|
334 | + $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to +)'." \n\t"; |
|
335 | + $conf .= 'same => n,Set(ADDPLUS=+);'." \n\t"; |
|
336 | + $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);'." \n\n"; |
|
337 | + $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)'." \n\t"; |
|
338 | + $conf .= 'same => n,Ringing()'." \n\t"; |
|
339 | 339 | |
340 | 340 | // Описываем возможность прыжка в пользовательский sub контекст. |
341 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t"; |
|
341 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t"; |
|
342 | 342 | |
343 | 343 | /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $routs */ |
344 | 344 | /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */ |
@@ -350,66 +350,66 @@ discard block |
||
350 | 350 | if ($technology !== '') { |
351 | 351 | $rout_data = $rout->toArray(); |
352 | 352 | $rout_data['technology'] = $technology; |
353 | - $id_dialplan = $rout_data['providerid'] . '-' . $rout_data['id'] . '-outgoing'; |
|
353 | + $id_dialplan = $rout_data['providerid'].'-'.$rout_data['id'].'-outgoing'; |
|
354 | 354 | $provider_contexts[$id_dialplan] = $rout_data; |
355 | - $conf .= $this->generateOutgoingRegexPattern($rout_data); |
|
355 | + $conf .= $this->generateOutgoingRegexPattern($rout_data); |
|
356 | 356 | continue; |
357 | 357 | } |
358 | 358 | } |
359 | - $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())' . " \n\t"; |
|
360 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t"; |
|
361 | - $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t"; |
|
362 | - $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))' . "\n\t"; |
|
359 | + $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())'." \n\t"; |
|
360 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t"; |
|
361 | + $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t"; |
|
362 | + $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))'."\n\t"; |
|
363 | 363 | |
364 | - $conf .= 'same => n,Playback(silence/2,noanswer)' . " \n\t"; |
|
365 | - $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))' . " \n\t"; |
|
366 | - $conf .= 'same => n,Hangup()' . " \n\n"; |
|
367 | - $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t"; |
|
364 | + $conf .= 'same => n,Playback(silence/2,noanswer)'." \n\t"; |
|
365 | + $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))'." \n\t"; |
|
366 | + $conf .= 'same => n,Hangup()'." \n\n"; |
|
367 | + $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t"; |
|
368 | 368 | |
369 | 369 | foreach ($provider_contexts as $id_dialplan => $rout) { |
370 | 370 | $conf .= "\n[{$id_dialplan}]\n"; |
371 | 371 | if (isset($rout['trimfrombegin']) && $rout['trimfrombegin'] > 0) { |
372 | 372 | // $exten_var = '${ADDPLUS}${EXTEN:'.$rout['trimfrombegin'].'}'; |
373 | - $exten_var = '${EXTEN:' . $rout['trimfrombegin'] . '}'; |
|
374 | - $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))' . "\n\t"; |
|
373 | + $exten_var = '${EXTEN:'.$rout['trimfrombegin'].'}'; |
|
374 | + $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))'."\n\t"; |
|
375 | 375 | } else { |
376 | 376 | $exten_var = '${ADDPLUS}${EXTEN}'; |
377 | 377 | $change_exten = ''; |
378 | 378 | } |
379 | - $conf .= 'exten => _X!,1,Set(number=' . $rout['prepend'] . $exten_var . ')' . "\n\t"; |
|
379 | + $conf .= 'exten => _X!,1,Set(number='.$rout['prepend'].$exten_var.')'."\n\t"; |
|
380 | 380 | $conf .= $change_exten; |
381 | 381 | foreach ($additionalModules as $appClass) { |
382 | 382 | $addition = $appClass->generateOutRoutContext($rout); |
383 | - if (!empty($addition)){ |
|
384 | - $conf .=$appClass->confBlockWithComments($addition); |
|
383 | + if (!empty($addition)) { |
|
384 | + $conf .= $appClass->confBlockWithComments($addition); |
|
385 | 385 | } |
386 | 386 | } |
387 | - $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())' . "\n\t"; |
|
388 | - $conf .= 'same => n,Set(ROUTFOUND=1)' . "\n\t"; |
|
389 | - $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t"; |
|
387 | + $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())'."\n\t"; |
|
388 | + $conf .= 'same => n,Set(ROUTFOUND=1)'."\n\t"; |
|
389 | + $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t"; |
|
390 | 390 | |
391 | - $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))' . "\n\t"; |
|
391 | + $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))'."\n\t"; |
|
392 | 392 | |
393 | 393 | // Описываем возможность прыжка в пользовательский sub контекст. |
394 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)}" == "1"]?' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)' . "\n\t"; |
|
394 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS('.$rout['providerid'].'-outgoing-custom,${EXTEN},1)}" == "1"]?'.$rout['providerid'].'-outgoing-custom,${EXTEN},1)'."\n\t"; |
|
395 | 395 | |
396 | 396 | if ($rout['technology'] === IAXConf::TYPE_IAX2) { |
397 | - $conf .= 'same => n,Dial(' . $rout['technology'] . '/' . $rout['providerid'] . '/${number},600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))' . "\n\t"; |
|
397 | + $conf .= 'same => n,Dial('.$rout['technology'].'/'.$rout['providerid'].'/${number},600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))'."\n\t"; |
|
398 | 398 | } else { |
399 | - $conf .= 'same => n,Dial(' . $rout['technology'] . '/${number}@' . $rout['providerid'] . ',600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))' . "\n\t"; |
|
399 | + $conf .= 'same => n,Dial('.$rout['technology'].'/${number}@'.$rout['providerid'].',600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))'."\n\t"; |
|
400 | 400 | } |
401 | 401 | foreach ($additionalModules as $appClass) { |
402 | 402 | $addition = $appClass->generateOutRoutAfterDialContext($rout); |
403 | - if (!empty($addition)){ |
|
404 | - $conf .=$appClass->confBlockWithComments($addition); |
|
403 | + if (!empty($addition)) { |
|
404 | + $conf .= $appClass->confBlockWithComments($addition); |
|
405 | 405 | } |
406 | 406 | } |
407 | - $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(' . $rout['providerid'] . '-outgoing-after-dial-custom,${EXTEN}),1}" == "1"]?' . $rout['providerid'] . '-outgoing-after-dial-custom,${EXTEN},1)' . "\n\t"; |
|
407 | + $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS('.$rout['providerid'].'-outgoing-after-dial-custom,${EXTEN}),1}" == "1"]?'.$rout['providerid'].'-outgoing-after-dial-custom,${EXTEN},1)'."\n\t"; |
|
408 | 408 | |
409 | - $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t"; |
|
410 | - $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())' . "\n\t"; |
|
411 | - $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})' . "\n\t"; |
|
412 | - $conf .= 'same => n,return' . "\n"; |
|
409 | + $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t"; |
|
410 | + $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())'."\n\t"; |
|
411 | + $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})'."\n\t"; |
|
412 | + $conf .= 'same => n,return'."\n"; |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | $conf = ''; |
426 | 426 | $restnumbers = ''; |
427 | 427 | if (isset($rout['restnumbers']) && $rout['restnumbers'] > 0) { |
428 | - $restnumbers = "[0-9]{" . $rout['restnumbers'] . "}$"; |
|
428 | + $restnumbers = "[0-9]{".$rout['restnumbers']."}$"; |
|
429 | 429 | } elseif ($rout['restnumbers'] == 0) { |
430 | 430 | $restnumbers = "$"; |
431 | 431 | } elseif ($rout['restnumbers'] == -1) { |
432 | 432 | $restnumbers = ""; |
433 | 433 | } |
434 | 434 | $numberbeginswith = $rout['numberbeginswith']; |
435 | - $conf .= 'same => n,ExecIf($["${REGEX("^' . $numberbeginswith . $restnumbers . '" ${EXTEN})}" == "1"]?Gosub(' . $rout['providerid'] . '-' . $rout['id'] . '-outgoing,${EXTEN},1))' . " \n\t"; |
|
435 | + $conf .= 'same => n,ExecIf($["${REGEX("^'.$numberbeginswith.$restnumbers.'" ${EXTEN})}" == "1"]?Gosub('.$rout['providerid'].'-'.$rout['id'].'-outgoing,${EXTEN},1))'." \n\t"; |
|
436 | 436 | |
437 | 437 | return $conf; |
438 | 438 | } |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $conf .= self::generateIncomingContextPeers('none', '', ''); |
450 | 450 | $conf .= "[public-direct-dial] \n"; |
451 | 451 | foreach ($additionalModules as $appClass) { |
452 | - if ($appClass instanceof $this){ |
|
452 | + if ($appClass instanceof $this) { |
|
453 | 453 | continue; |
454 | 454 | } |
455 | 455 | $appClass->generatePublicContext($conf); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | $conf = ''; |
480 | 480 | $dialplan = []; |
481 | 481 | $di = Di::getDefault(); |
482 | - if ($di===null){ |
|
482 | + if ($di === null) { |
|
483 | 483 | return ''; |
484 | 484 | } |
485 | 485 | $additionalModules = $di->getShared('pbxConfModules'); |
@@ -535,55 +535,55 @@ discard block |
||
535 | 535 | if (empty($rout_data)) { |
536 | 536 | $ext_prefix = ('none' === $provider) ? '' : '_'; |
537 | 537 | $rout_data .= "exten => {$ext_prefix}{$rout_number},1,NoOp(--- Incoming call ---)\n\t"; |
538 | - $rout_data .= 'same => n,Set(CHANNEL(language)=' . $lang . ')' . "\n\t"; |
|
539 | - $rout_data .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t"; |
|
540 | - $rout_data .= 'same => n,Set(__FROM_DID=${EXTEN})' . "\n\t"; |
|
541 | - $rout_data .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t"; |
|
538 | + $rout_data .= 'same => n,Set(CHANNEL(language)='.$lang.')'."\n\t"; |
|
539 | + $rout_data .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t"; |
|
540 | + $rout_data .= 'same => n,Set(__FROM_DID=${EXTEN})'."\n\t"; |
|
541 | + $rout_data .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t"; |
|
542 | 542 | |
543 | 543 | // Установка имени пира. |
544 | - $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t"; |
|
545 | - $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t"; |
|
544 | + $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t"; |
|
545 | + $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t"; |
|
546 | 546 | |
547 | 547 | // TODO / Подмена входящего callerid. |
548 | - $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)' . "\n\t"; |
|
548 | + $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)'."\n\t"; |
|
549 | 549 | |
550 | 550 | foreach ($additionalModules as $appClass) { |
551 | 551 | $addition = $appClass->generateIncomingRoutBeforeDial($rout_number); |
552 | - if (!empty($addition)){ |
|
553 | - $rout_data .=$appClass->confBlockWithComments($addition); |
|
552 | + if (!empty($addition)) { |
|
553 | + $rout_data .= $appClass->confBlockWithComments($addition); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
557 | 557 | // Перехват на ответственного. |
558 | - $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})' . "\n\t"; |
|
558 | + $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})'."\n\t"; |
|
559 | 559 | // Проверим распискние для входящих внешних звонков. |
560 | 560 | $rout_data .= 'same => n,Gosub(check-out-work-time,${EXTEN},1)'; |
561 | 561 | // Описываем возможность прыжка в пользовательский sub контекст. |
562 | - $rout_data .= " \n\t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'; |
|
562 | + $rout_data .= " \n\t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'; |
|
563 | 563 | } |
564 | 564 | |
565 | - if ( ! empty($rout['extension'])) { |
|
565 | + if (!empty($rout['extension'])) { |
|
566 | 566 | $rout_data = rtrim($rout_data); |
567 | 567 | // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо. |
568 | 568 | // При ответе может отработать следующий приоритет. |
569 | - if ( ! isset($rout_data_dial[$rout_number])) { |
|
569 | + if (!isset($rout_data_dial[$rout_number])) { |
|
570 | 570 | $rout_data_dial[$rout_number] = ''; |
571 | 571 | } |
572 | 572 | |
573 | - if(in_array($rout['extension'], $confExtensions, true)){ |
|
573 | + if (in_array($rout['extension'], $confExtensions, true)) { |
|
574 | 574 | // Это конференция. Тут не требуется обработка таймаута ответа. |
575 | 575 | // Вызов будет отвечен сразу конференцией. |
576 | - $dial_command = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Goto(internal,{$rout['extension']},1));"; |
|
576 | + $dial_command = " \n\t".'same => n,'.'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Goto(internal,{$rout['extension']},1));"; |
|
577 | 577 | $rout_data_dial[$rout_number] .= ""; |
578 | - }else{ |
|
579 | - $dial_command = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));"; |
|
580 | - $rout_data_dial[$rout_number] .= " \n\t" . "same => n,Set(M_TIMEOUT={$timeout})"; |
|
578 | + } else { |
|
579 | + $dial_command = " \n\t".'same => n,'.'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));"; |
|
580 | + $rout_data_dial[$rout_number] .= " \n\t"."same => n,Set(M_TIMEOUT={$timeout})"; |
|
581 | 581 | } |
582 | 582 | $rout_data_dial[$rout_number] .= $dial_command; |
583 | 583 | |
584 | 584 | if (is_array($provider)) { |
585 | 585 | $key = $provider[$rout['provider']] ?? ''; |
586 | - if ( ! isset($rout_data_dial[$key])) { |
|
586 | + if (!isset($rout_data_dial[$key])) { |
|
587 | 587 | $rout_data_dial[$key] = ''; |
588 | 588 | } |
589 | 589 | if (empty($number)) { |
@@ -594,9 +594,9 @@ discard block |
||
594 | 594 | } |
595 | 595 | |
596 | 596 | if (is_string($login)) { |
597 | - $add_login_pattern = ! empty($login); |
|
597 | + $add_login_pattern = !empty($login); |
|
598 | 598 | foreach ($data as $rout) { |
599 | - if ( ! $add_login_pattern) { |
|
599 | + if (!$add_login_pattern) { |
|
600 | 600 | break; |
601 | 601 | } // Логин не заполнен, обработка не требуется. |
602 | 602 | $is_num = preg_match_all('/^\d+$/m', $login, $matches, PREG_SET_ORDER, 0); |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | if ($add_login_pattern && array_key_exists('X!', $rout_data_dial) && isset($dialplan['X!'])) { |
617 | 617 | $dialplan[$login] = str_replace('_X!,1', "{$login},1", $dialplan['X!']); |
618 | 618 | $rout_data_dial[$login] = $rout_data_dial['X!']; |
619 | - }elseif($add_login_pattern === true && $need_def_rout === true && count($data) === 1){ |
|
619 | + }elseif ($add_login_pattern === true && $need_def_rout === true && count($data) === 1) { |
|
620 | 620 | // Только маршрут "По умолчанию". |
621 | 621 | $dialplan[$login] = str_replace('_X!,1', "{$login},1", $dialplan['X!']); |
622 | 622 | } |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | foreach ($dialplan as $key => &$dpln) { |
630 | - if ( ! array_key_exists($key, $rout_data_dial)) { |
|
630 | + if (!array_key_exists($key, $rout_data_dial)) { |
|
631 | 631 | continue; |
632 | 632 | } |
633 | 633 | $dpln = rtrim($dpln); |
@@ -636,34 +636,34 @@ discard block |
||
636 | 636 | unset($dpln); |
637 | 637 | |
638 | 638 | $uniqid = is_string($provider) ? $provider : $uniqid; |
639 | - $conf .= "\n" . "[{$uniqid}-incoming]\n"; |
|
639 | + $conf .= "\n"."[{$uniqid}-incoming]\n"; |
|
640 | 640 | foreach ($dialplan as $dpln) { |
641 | - $conf .= $dpln . "\n"; |
|
641 | + $conf .= $dpln."\n"; |
|
642 | 642 | if (null === $default_action && 'none' !== $provider) { |
643 | 643 | continue; |
644 | 644 | } |
645 | 645 | if ('extension' === $default_action->action) { |
646 | 646 | // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо. |
647 | 647 | // При ответе может отработать следующий приоритет. |
648 | - $conf .= "\t" . 'same => n,Set(M_TIMEOUT=0)' . "\n"; |
|
649 | - if(in_array($default_action->extension, $confExtensions, true)){ |
|
648 | + $conf .= "\t".'same => n,Set(M_TIMEOUT=0)'."\n"; |
|
649 | + if (in_array($default_action->extension, $confExtensions, true)) { |
|
650 | 650 | // Это конференция. Тут не требуется обработка таймаута ответа. |
651 | 651 | // Вызов будет отвечен сразу конференцией. |
652 | - $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Goto(internal,{$default_action->extension},1)); default action" . "\n"; |
|
653 | - }else { |
|
654 | - $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action" . "\n"; |
|
652 | + $conf .= "\t"."same => n,".'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Goto(internal,{$default_action->extension},1)); default action"."\n"; |
|
653 | + } else { |
|
654 | + $conf .= "\t"."same => n,".'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action"."\n"; |
|
655 | 655 | } |
656 | 656 | foreach ($additionalModules as $appClass) { |
657 | 657 | $addition = $appClass->generateIncomingRoutAfterDialContext($uniqid); |
658 | - if (!empty($addition)){ |
|
659 | - $conf .=$appClass->confBlockWithComments($addition); |
|
658 | + if (!empty($addition)) { |
|
659 | + $conf .= $appClass->confBlockWithComments($addition); |
|
660 | 660 | } |
661 | 661 | } |
662 | - $conf .= " \t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)' . "\n"; |
|
662 | + $conf .= " \t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)'."\n"; |
|
663 | 663 | } elseif ('busy' === $default_action->action) { |
664 | - $conf .= "\t" . "same => n,Busy()" . "\n"; |
|
664 | + $conf .= "\t"."same => n,Busy()"."\n"; |
|
665 | 665 | } |
666 | - $conf .= "\t" . "same => n,Hangup()" . "\n"; |
|
666 | + $conf .= "\t"."same => n,Hangup()"."\n"; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | return $conf; |
@@ -679,10 +679,10 @@ discard block |
||
679 | 679 | private function generateOutWorkTimes(&$conf): string |
680 | 680 | { |
681 | 681 | $conf .= "\n\n[playback-exit]\n"; |
682 | - $conf .= 'exten => _.!,1,NoOp(check time)' . "\n\t"; |
|
683 | - $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)' . "\n\t"; |
|
684 | - $conf .= 'same => n,Playback(${filename})' . "\n\t"; |
|
685 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
682 | + $conf .= 'exten => _.!,1,NoOp(check time)'."\n\t"; |
|
683 | + $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)'."\n\t"; |
|
684 | + $conf .= 'same => n,Playback(${filename})'."\n\t"; |
|
685 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
686 | 686 | |
687 | 687 | $conf .= "[check-out-work-time]\n"; |
688 | 688 | $conf .= "exten => _.!,1,NoOp(check time)\n\t"; |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | $now_year = 1 * date('Y', time()); |
695 | 695 | foreach ($data as $out_data) { |
696 | 696 | /** @var \MikoPBX\Common\Models\OutWorkTimes $out_data */ |
697 | - if ( ! empty($out_data->date_from) && ! empty($out_data->date_to)) { |
|
698 | - $year_from = 1 * date('Y', (int)$out_data->date_from); |
|
699 | - $year_to = 1 * date('Y', (int)$out_data->date_to); |
|
697 | + if (!empty($out_data->date_from) && !empty($out_data->date_to)) { |
|
698 | + $year_from = 1 * date('Y', (int) $out_data->date_from); |
|
699 | + $year_to = 1 * date('Y', (int) $out_data->date_to); |
|
700 | 700 | if ($now_year < $year_from || $now_year > $year_to) { |
701 | 701 | // Правило не актуально для текущего года. |
702 | 702 | continue; |
@@ -733,11 +733,11 @@ discard block |
||
733 | 733 | $mdays = '*'; |
734 | 734 | $months = '*'; |
735 | 735 | } else { |
736 | - $mdays = strtolower(date("j", (int)$date_from)); |
|
737 | - $months = strtolower(date("M", (int)$date_from)); |
|
738 | - if ( ! empty($date_to)) { |
|
739 | - $mdays .= "-" . strtolower(date("j", (int)$date_to)); |
|
740 | - $months .= "-" . strtolower(date("M", (int)$date_to)); |
|
736 | + $mdays = strtolower(date("j", (int) $date_from)); |
|
737 | + $months = strtolower(date("M", (int) $date_from)); |
|
738 | + if (!empty($date_to)) { |
|
739 | + $mdays .= "-".strtolower(date("j", (int) $date_to)); |
|
740 | + $months .= "-".strtolower(date("M", (int) $date_to)); |
|
741 | 741 | } |
742 | 742 | } |
743 | 743 | |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | $res = SoundFiles::findFirst($out_data->audio_message_id); |
751 | 751 | $audio_message = ($res === null) ? '' : Util::trimExtensionForFile($res->path); |
752 | 752 | |
753 | - $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n" . |
|
754 | - 'exten => _.!,1,Set(filename=' . $audio_message . ')' . "\n\t" . |
|
755 | - 'same => n,Goto(playback-exit,${EXTEN},1)' . "\n\n"; |
|
753 | + $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n". |
|
754 | + 'exten => _.!,1,Set(filename='.$audio_message.')'."\n\t". |
|
755 | + 'same => n,Goto(playback-exit,${EXTEN},1)'."\n\n"; |
|
756 | 756 | |
757 | 757 | $appname = 'ExecIfTime'; |
758 | - $appdata = 'Goto(work-time-set-var-' . $out_data->id . ',${EXTEN},1)'; |
|
758 | + $appdata = 'Goto(work-time-set-var-'.$out_data->id.',${EXTEN},1)'; |
|
759 | 759 | } |
760 | 760 | $conf .= "same => n,{$appname}($times,$weekdays,$mdays,$months?{$appdata})\n\t"; |
761 | 761 | } |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | if ($provider !== null) { |
782 | 782 | if ($provider->type === 'SIP') { |
783 | 783 | $account = Sip::findFirst('disabled="0" AND uniqid = "'.$uniqueID.'"'); |
784 | - $technology = ($account === null)?'':SIPConf::getTechnology(); |
|
784 | + $technology = ($account === null) ? '' : SIPConf::getTechnology(); |
|
785 | 785 | } elseif ($provider->type === 'IAX') { |
786 | 786 | $account = Iax::findFirst('disabled="0" AND uniqid = "'.$uniqueID.'"'); |
787 | - $technology = ($account === null)?'':'IAX2'; |
|
787 | + $technology = ($account === null) ? '' : 'IAX2'; |
|
788 | 788 | } |
789 | 789 | } |
790 | 790 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected function generateConfigProtected(): void |
20 | 20 | { |
21 | 21 | $conf = ""; |
22 | - file_put_contents($this->config->path('asterisk.astetcdir') . '/confbridge.conf', $conf); |
|
22 | + file_put_contents($this->config->path('asterisk.astetcdir').'/confbridge.conf', $conf); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $conf = ''; |
33 | 33 | $data = self::getConferenceExtensions(); |
34 | 34 | foreach ($data as $conference) { |
35 | - $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)" . "\n"; |
|
35 | + $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)"."\n"; |
|
36 | 36 | } |
37 | 37 | $conf .= "\n"; |
38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $conf = ''; |
48 | 48 | $data = self::getConferenceExtensions(); |
49 | 49 | foreach ($data as $conference) { |
50 | - $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)" . "\n"; |
|
50 | + $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)"."\n"; |
|
51 | 51 | } |
52 | 52 | $conf .= "\n"; |
53 | 53 | |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $conf .= "[conference-rooms] \n"; |
73 | 73 | $data = self::getConferenceExtensions(); |
74 | 74 | foreach ($data as $conference) { |
75 | - $conf .= 'exten => ' . $conference . ',1,NoOp(---)' . "\n\t"; |
|
76 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())' . "\n\t"; |
|
77 | - $conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)' . "\n\t"; |
|
78 | - $conf .= 'same => n,Answer()' . "\n\t"; |
|
79 | - $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)' . "\n\t"; |
|
80 | - $conf .= 'same => n,Meetme(${EXTEN},qdMT' . $rec_options . ')' . "\n\t"; |
|
81 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
75 | + $conf .= 'exten => '.$conference.',1,NoOp(---)'."\n\t"; |
|
76 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())'."\n\t"; |
|
77 | + $conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)'."\n\t"; |
|
78 | + $conf .= 'same => n,Answer()'."\n\t"; |
|
79 | + $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)'."\n\t"; |
|
80 | + $conf .= 'same => n,Meetme(${EXTEN},qdMT'.$rec_options.')'."\n\t"; |
|
81 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $conf; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | public static function getConferenceExtensions():array{ |
108 | 108 | $confExtensions = []; |
109 | 109 | $conferences = ConferenceRooms::find(['order' => 'extension', 'columns' => 'extension'])->toArray(); |
110 | - foreach ($conferences as $conference){ |
|
110 | + foreach ($conferences as $conference) { |
|
111 | 111 | $confExtensions[] = $conference['extension']; |
112 | 112 | } |
113 | 113 | return $confExtensions; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | if (false === $result) { |
167 | 167 | Processes::processPHPWorker($workerClassName); |
168 | - Util::sysLogMsg(__CLASS__, "Service {$workerClassName} started."); |
|
168 | + Util::sysLogMsg(__CLASS__, "service {$workerClassName} started."); |
|
169 | 169 | } |
170 | 170 | $time_elapsed_secs = microtime(true) - $start; |
171 | 171 | if ($time_elapsed_secs > 10) { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | if ($res_ping === false && $level < 10) { |
235 | 235 | Processes::processPHPWorker($workerClassName); |
236 | - Util::sysLogMsg(__CLASS__, "Service {$workerClassName} started."); |
|
236 | + Util::sysLogMsg(__CLASS__, "service {$workerClassName} started."); |
|
237 | 237 | // Wait 1 second while service will be ready to listen requests |
238 | 238 | sleep(1); |
239 | 239 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $arrWorkers = $this->prepareWorkersList(); |
46 | 46 | ReactKernel::start( |
47 | - function () use ($arrWorkers) { |
|
47 | + function() use ($arrWorkers) { |
|
48 | 48 | // Parallel execution https://github.com/recoilphp/recoil |
49 | 49 | foreach ($arrWorkers as $workersWithCurrentType) { |
50 | 50 | foreach ($workersWithCurrentType as $worker) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function prepareWorkersList(): array |
65 | 65 | { |
66 | - $arrWorkers = [ |
|
66 | + $arrWorkers = [ |
|
67 | 67 | self::CHECK_BY_AMI => |
68 | 68 | [ |
69 | 69 | WorkerAmiListener::class, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function restartWorker($workerClassName): ?Generator |
112 | 112 | { |
113 | - Processes::processPHPWorker($workerClassName, 'start','restart'); |
|
113 | + Processes::processPHPWorker($workerClassName, 'start', 'restart'); |
|
114 | 114 | yield; |
115 | 115 | } |
116 | 116 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | PBX::waitFullyBooted(); |
127 | 127 | $arrWorkers = $this->prepareWorkersList(); |
128 | 128 | ReactKernel::start( |
129 | - function () use ($arrWorkers) { |
|
129 | + function() use ($arrWorkers) { |
|
130 | 130 | // Parallel execution https://github.com/recoilphp/recoil |
131 | 131 | foreach ($arrWorkers as $workerType => $workersWithCurrentType) { |
132 | 132 | foreach ($workersWithCurrentType as $worker) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | } catch (Throwable $e) { |
178 | 178 | global $errorLogger; |
179 | 179 | $errorLogger->captureException($e); |
180 | - Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage()); |
|
180 | + Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage()); |
|
181 | 181 | } |
182 | 182 | yield; |
183 | 183 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } catch (Throwable $e) { |
251 | 251 | global $errorLogger; |
252 | 252 | $errorLogger->captureException($e); |
253 | - Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage()); |
|
253 | + Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage()); |
|
254 | 254 | } |
255 | 255 | yield; |
256 | 256 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | Processes::killByName('pcapsipdump'); |
32 | - $log_dir = System::getLogDir() . '/pcapsipdump'; |
|
32 | + $log_dir = System::getLogDir().'/pcapsipdump'; |
|
33 | 33 | Util::mwMkdir($log_dir); |
34 | 34 | |
35 | 35 | $network = new Network(); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | foreach ($arr_eth as $eth) { |
39 | 39 | $pid_file = "/var/run/pcapsipdump_{$eth}.pid"; |
40 | 40 | Processes::mwExecBg( |
41 | - $pcapsipdumpPath . ' -T 120 -P ' . $pid_file . ' -i ' . $eth . ' -m \'^(INVITE|REGISTER)$\' -L ' . $log_dir . '/dump.db' |
|
41 | + $pcapsipdumpPath.' -T 120 -P '.$pid_file.' -i '.$eth.' -m \'^(INVITE|REGISTER)$\' -L '.$log_dir.'/dump.db' |
|
42 | 42 | ); |
43 | 43 | } |
44 | 44 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | /** @var \MikoPBX\Common\Models\LanInterfaces $res */ |
147 | 147 | $res = LanInterfaces::findFirst("internet = '1'"); |
148 | 148 | if (null !== $res) { |
149 | - if ( ! empty($res->primarydns) && '127.0.0.1' != $res->primarydns) { |
|
149 | + if (!empty($res->primarydns) && '127.0.0.1' != $res->primarydns) { |
|
150 | 150 | $dns[] = $res->primarydns; |
151 | 151 | } |
152 | - if ( ! empty($res->secondarydns) && '127.0.0.1' != $res->secondarydns) { |
|
152 | + if (!empty($res->secondarydns) && '127.0.0.1' != $res->secondarydns) { |
|
153 | 153 | $dns[] = $res->secondarydns; |
154 | 154 | } |
155 | 155 | } |
@@ -165,39 +165,39 @@ discard block |
||
165 | 165 | public function generatePdnsdConfig($named_dns): void |
166 | 166 | { |
167 | 167 | $tempDir = $this->di->getShared('config')->path('core.tempDir'); |
168 | - $cache_dir = $tempDir . '/pdnsd/cache'; |
|
168 | + $cache_dir = $tempDir.'/pdnsd/cache'; |
|
169 | 169 | Util::mwMkdir($cache_dir); |
170 | 170 | |
171 | - $conf = 'global {' . "\n" . |
|
172 | - ' perm_cache=10240;' . "\n" . |
|
173 | - ' cache_dir="' . $cache_dir . '";' . "\n" . |
|
174 | - ' pid_file = /var/run/pdnsd.pid;' . "\n" . |
|
175 | - ' run_as="nobody";' . "\n" . |
|
176 | - ' server_ip = 127.0.0.1;' . "\n" . |
|
177 | - ' status_ctl = on;' . "\n" . |
|
178 | - ' query_method=udp_tcp;' . "\n" . |
|
179 | - ' min_ttl=15m;' . "\n" . |
|
180 | - ' max_ttl=1w;' . "\n" . |
|
181 | - ' timeout=10;' . "\n" . |
|
182 | - ' neg_domain_pol=on;' . "\n" . |
|
183 | - ' run_as=root;' . "\n" . |
|
184 | - ' daemon=on;' . "\n" . |
|
185 | - '}' . "\n" . |
|
186 | - 'server {' . "\n" . |
|
187 | - ' label = "main";' . "\n" . |
|
188 | - ' ip = ' . implode(', ', $named_dns) . ';' . "\n" . |
|
189 | - ' interface=lo;' . "\n" . |
|
190 | - ' uptest=if;' . "\n" . |
|
191 | - ' interval=10m;' . "\n" . |
|
192 | - ' purge_cache=off;' . "\n" . |
|
171 | + $conf = 'global {'."\n". |
|
172 | + ' perm_cache=10240;'."\n". |
|
173 | + ' cache_dir="'.$cache_dir.'";'."\n". |
|
174 | + ' pid_file = /var/run/pdnsd.pid;'."\n". |
|
175 | + ' run_as="nobody";'."\n". |
|
176 | + ' server_ip = 127.0.0.1;'."\n". |
|
177 | + ' status_ctl = on;'."\n". |
|
178 | + ' query_method=udp_tcp;'."\n". |
|
179 | + ' min_ttl=15m;'."\n". |
|
180 | + ' max_ttl=1w;'."\n". |
|
181 | + ' timeout=10;'."\n". |
|
182 | + ' neg_domain_pol=on;'."\n". |
|
183 | + ' run_as=root;'."\n". |
|
184 | + ' daemon=on;'."\n". |
|
185 | + '}'."\n". |
|
186 | + 'server {'."\n". |
|
187 | + ' label = "main";'."\n". |
|
188 | + ' ip = '.implode(', ', $named_dns).';'."\n". |
|
189 | + ' interface=lo;'."\n". |
|
190 | + ' uptest=if;'."\n". |
|
191 | + ' interval=10m;'."\n". |
|
192 | + ' purge_cache=off;'."\n". |
|
193 | 193 | '}'; |
194 | 194 | |
195 | - $pdnsdConfFile = '/etc/pdnsd.conf'; |
|
195 | + $pdnsdConfFile = '/etc/pdnsd.conf'; |
|
196 | 196 | $savedConf = ''; |
197 | - if(file_exists($pdnsdConfFile)){ |
|
197 | + if (file_exists($pdnsdConfFile)) { |
|
198 | 198 | $savedConf = file_get_contents($pdnsdConfFile); |
199 | 199 | } |
200 | - if($savedConf != $conf){ |
|
200 | + if ($savedConf != $conf) { |
|
201 | 201 | file_put_contents($pdnsdConfFile, $conf); |
202 | 202 | } |
203 | 203 | $pdnsdPath = Util::which('pdnsd'); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | if (!empty($pid) && $savedConf === $conf) { |
206 | 206 | // Выполним дополнительную проверку, работает ли сервер. |
207 | 207 | $resultResolve = gethostbynamel('lic.miko.ru'); |
208 | - if($resultResolve !== false){ |
|
208 | + if ($resultResolve !== false) { |
|
209 | 209 | // Ничего делать не нужно. Конфиг не изменился. Рестарт не требуется. |
210 | 210 | return; |
211 | 211 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | $pid_file = "/var/run/udhcpc_{$if_name}"; |
284 | 284 | $pid_pcc = Processes::getPidOfProcess($pid_file); |
285 | - if ( ! empty($pid_pcc) && file_exists($pid_file)) { |
|
285 | + if (!empty($pid_pcc) && file_exists($pid_file)) { |
|
286 | 286 | // Завершаем старый процесс. |
287 | 287 | $killPath = Util::which('kill'); |
288 | 288 | $catPath = Util::which('cat'); |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | |
412 | 412 | $result = ['']; |
413 | 413 | if (file_exists('/etc/static-routes')) { |
414 | - $command = "{$catPath} /etc/static-routes " . |
|
415 | - "| {$grepPath} '^rout' " . |
|
416 | - "| {$busyboxPath} awk -F ';' '{print $1}' " . |
|
417 | - "| {$grepPath} '{$if_name}\$' " . |
|
414 | + $command = "{$catPath} /etc/static-routes ". |
|
415 | + "| {$grepPath} '^rout' ". |
|
416 | + "| {$busyboxPath} awk -F ';' '{print $1}' ". |
|
417 | + "| {$grepPath} '{$if_name}\$' ". |
|
418 | 418 | "| {$awkPath} -F 'dev {$if_name}' '{ print $1 }'"; |
419 | 419 | Processes::mwExec($command, $result); |
420 | 420 | } |
@@ -424,19 +424,19 @@ discard block |
||
424 | 424 | |
425 | 425 | if ($if_data['vlanid'] > 0) { |
426 | 426 | // Пока только статика. |
427 | - $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n" . |
|
428 | - "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n" . |
|
429 | - "address {$ipaddr}\n" . |
|
430 | - "netmask {$subnet}\n" . |
|
431 | - "gateway {$gateway}\n" . |
|
432 | - "dns-nameservers 127.0.0.1\n" . |
|
433 | - "vlan_raw_device {$if_data['interface_orign']}\n" . |
|
434 | - "{$routs_add}\n" . |
|
427 | + $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n". |
|
428 | + "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n". |
|
429 | + "address {$ipaddr}\n". |
|
430 | + "netmask {$subnet}\n". |
|
431 | + "gateway {$gateway}\n". |
|
432 | + "dns-nameservers 127.0.0.1\n". |
|
433 | + "vlan_raw_device {$if_data['interface_orign']}\n". |
|
434 | + "{$routs_add}\n". |
|
435 | 435 | "{$routs_rem}\n"; |
436 | 436 | } elseif (trim($if_data['dhcp']) === '1') { |
437 | - $lan_config = "auto {$if_name}\n" . |
|
438 | - "iface {$if_name} inet dhcp\n" . |
|
439 | - "{$routs_add}\n" . |
|
437 | + $lan_config = "auto {$if_name}\n". |
|
438 | + "iface {$if_name} inet dhcp\n". |
|
439 | + "{$routs_add}\n". |
|
440 | 440 | "{$routs_rem}\n"; |
441 | 441 | } else { |
442 | 442 | if (empty($ipaddr)) { |
@@ -449,13 +449,13 @@ discard block |
||
449 | 449 | echo "Caught exception: $ipaddr $subnet", $e->getMessage(), "\n"; |
450 | 450 | continue; |
451 | 451 | } |
452 | - $lan_config = "auto {$if_name}\n" . |
|
453 | - "iface {$if_name} inet static\n" . |
|
454 | - "address {$ipaddr}\n" . |
|
455 | - "netmask {$subnet}\n" . |
|
456 | - "gateway {$gateway}\n" . |
|
457 | - "dns-nameservers 127.0.0.1\n" . |
|
458 | - "{$routs_add}\n" . |
|
452 | + $lan_config = "auto {$if_name}\n". |
|
453 | + "iface {$if_name} inet static\n". |
|
454 | + "address {$ipaddr}\n". |
|
455 | + "netmask {$subnet}\n". |
|
456 | + "gateway {$gateway}\n". |
|
457 | + "dns-nameservers 127.0.0.1\n". |
|
458 | + "{$routs_add}\n". |
|
459 | 459 | "{$routs_rem}\n"; |
460 | 460 | } |
461 | 461 | file_put_contents("/etc/network/interfaces.d/{$if_name}", $lan_config); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | $net_mask = explode(".", $net_mask); |
547 | 547 | |
548 | 548 | foreach ($net_mask as $oct_ect) { |
549 | - $bits += strlen(str_replace("0", "", decbin((int)$oct_ect))); |
|
549 | + $bits += strlen(str_replace("0", "", decbin((int) $oct_ect))); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | return $bits; |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $data->hostname = 'mikopbx'; |
610 | 610 | $data->domain = ''; |
611 | 611 | $data->topology = 'private'; |
612 | - $data->primarydns= ''; |
|
612 | + $data->primarydns = ''; |
|
613 | 613 | $data->save(); |
614 | 614 | |
615 | 615 | return $data->toArray(); |
@@ -630,15 +630,15 @@ discard block |
||
630 | 630 | public function hostnameConfigure(): void |
631 | 631 | { |
632 | 632 | $data = Network::getHostName(); |
633 | - $hosts_conf = "127.0.0.1 localhost\n" . |
|
633 | + $hosts_conf = "127.0.0.1 localhost\n". |
|
634 | 634 | "127.0.0.1 {$data['hostname']}\n"; |
635 | - if ( ! empty($data['domain'])) { |
|
635 | + if (!empty($data['domain'])) { |
|
636 | 636 | $hosts_conf .= "127.0.0.1 {$data['hostname']}.{$data['domain']}\n"; |
637 | 637 | } |
638 | 638 | Util::fileWriteContent('/etc/hosts', $hosts_conf); |
639 | 639 | |
640 | 640 | $hostnamePath = Util::which('hostname'); |
641 | - Processes::mwExec($hostnamePath . ' ' . escapeshellarg("{$data['hostname']}")); |
|
641 | + Processes::mwExec($hostnamePath.' '.escapeshellarg("{$data['hostname']}")); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -652,12 +652,12 @@ discard block |
||
652 | 652 | |
653 | 653 | $pidFile = '/var/run/openvpn.pid'; |
654 | 654 | $pid = Processes::getPidOfProcess('openvpn'); |
655 | - if ( ! empty($pid)) { |
|
655 | + if (!empty($pid)) { |
|
656 | 656 | // Завершаем процесс. |
657 | 657 | $busyboxPath = Util::which('busybox'); |
658 | 658 | Processes::mwExec("{$busyboxPath} kill '$pid'"); |
659 | 659 | } |
660 | - if ( ! empty($data)) { |
|
660 | + if (!empty($data)) { |
|
661 | 661 | $openvpnPath = Util::which('openvpn'); |
662 | 662 | Processes::mwExecBg("{$openvpnPath} --config /etc/openvpn.ovpn --writepid {$pidFile}", '/dev/null', 5); |
663 | 663 | } |
@@ -867,12 +867,12 @@ discard block |
||
867 | 867 | if ($res === null) { |
868 | 868 | return; |
869 | 869 | } |
870 | - if (empty($res->primarydns) && ! empty($data['primarydns'])) { |
|
870 | + if (empty($res->primarydns) && !empty($data['primarydns'])) { |
|
871 | 871 | $res->writeAttribute('primarydns', $data['primarydns']); |
872 | 872 | } elseif (empty($res->secondarydns) && $res->primarydns !== $data['primarydns']) { |
873 | 873 | $res->writeAttribute('secondarydns', $data['primarydns']); |
874 | 874 | } |
875 | - if (empty($res->secondarydns) && ! empty($data['secondarydns'])) { |
|
875 | + if (empty($res->secondarydns) && !empty($data['secondarydns'])) { |
|
876 | 876 | $res->writeAttribute('secondarydns', $data['secondarydns']); |
877 | 877 | } |
878 | 878 | $res->save(); |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | { |
916 | 916 | // Настройка по умолчанию. |
917 | 917 | $interface = trim(getenv('interface')); |
918 | - if ( ! Util::isSystemctl()) { |
|
918 | + if (!Util::isSystemctl()) { |
|
919 | 919 | // Для MIKO LFS Edition. |
920 | 920 | $busyboxPath = Util::which('busybox'); |
921 | 921 | Processes::mwExec("{$busyboxPath} ifconfig $interface 192.168.2.1 netmask 255.255.255.0"); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $config = $this->di->get('config')->beanstalk; |
50 | 50 | $port = $config->port; |
51 | - if ( ! empty($this->port) && is_numeric($this->port)) { |
|
51 | + if (!empty($this->port) && is_numeric($this->port)) { |
|
52 | 52 | $port = $this->port; |
53 | 53 | } |
54 | 54 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $this->queue->delete($job); |
103 | 103 | } |
104 | 104 | } catch (Throwable $exception) { |
105 | - Util::sysLogMsg(__METHOD__, 'Exception: ' . $exception->getMessage()); |
|
105 | + Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
|
106 | 106 | if ($job !== null) { |
107 | 107 | $this->queue->bury($job); |
108 | 108 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ): Job { |
135 | 135 | $tube = str_replace("\\", '-', $tube); |
136 | 136 | // Change tube |
137 | - if ( ! empty($tube) && $this->tube !== $tube) { |
|
137 | + if (!empty($tube) && $this->tube !== $tube) { |
|
138 | 138 | $this->queue->useTube($tube); |
139 | 139 | } |
140 | 140 | $job_data = serialize($job_data); |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | $queueStats = $this->queue->stats()->getArrayCopy(); |
160 | 160 | |
161 | 161 | // Delete buried jobs |
162 | - $countBuried=$queueStats['current-jobs-buried']; |
|
162 | + $countBuried = $queueStats['current-jobs-buried']; |
|
163 | 163 | while ($job = $this->queue->peekBuried()) { |
164 | 164 | $countBuried--; |
165 | - if ($countBuried<0){ |
|
165 | + if ($countBuried < 0) { |
|
166 | 166 | break; |
167 | 167 | } |
168 | 168 | $id = $job->getId(); |
@@ -171,23 +171,23 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | // Delete outdated jobs |
174 | - $countReady=$queueStats['current-jobs-ready']; |
|
174 | + $countReady = $queueStats['current-jobs-ready']; |
|
175 | 175 | while ($job = $this->queue->peekReady()) { |
176 | 176 | $countReady--; |
177 | - if ($countReady<0){ |
|
177 | + if ($countReady < 0) { |
|
178 | 178 | break; |
179 | 179 | } |
180 | 180 | $id = $job->getId(); |
181 | 181 | $jobStats = $this->queue->statsJob($job)->getArrayCopy(); |
182 | - $age = (int)$jobStats['age']; |
|
183 | - $expectedTimeToExecute = (int)$jobStats['ttr'] * 2; |
|
182 | + $age = (int) $jobStats['age']; |
|
183 | + $expectedTimeToExecute = (int) $jobStats['ttr'] * 2; |
|
184 | 184 | if ($age > $expectedTimeToExecute) { |
185 | 185 | $this->queue->delete($job); |
186 | 186 | Util::sysLogMsg(__METHOD__, "Deleted outdated job with ID {$id} from {$tube}"); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | } catch (Throwable $exception) { |
190 | - Util::sysLogMsg(__METHOD__, 'Exception: ' . $exception->getMessage()); |
|
190 | + Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | try { |
221 | 221 | $job = $this->queue->reserveWithTimeout($timeout); |
222 | 222 | } catch (Throwable $exception) { |
223 | - Util::sysLogMsg(__METHOD__, 'Exception: ' . $exception->getMessage()); |
|
223 | + Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | if ($job === null) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return; |
91 | 91 | } |
92 | 92 | $max_size = 2; |
93 | - $log_dir = System::getLogDir() . '/asterisk/'; |
|
93 | + $log_dir = System::getLogDir().'/asterisk/'; |
|
94 | 94 | $text_config = "{$log_dir}{$f_name} { |
95 | 95 | nocreate |
96 | 96 | nocopytruncate |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | {$asteriskPath} -rx 'logger reload' > /dev/null 2> /dev/null |
106 | 106 | endscript |
107 | 107 | }"; |
108 | - $varEtcDir = $di->getShared('config')->path('core.varEtcDir'); |
|
109 | - $path_conf = $varEtcDir . '/asterisk_logrotate_' . $f_name . '.conf'; |
|
108 | + $varEtcDir = $di->getShared('config')->path('core.varEtcDir'); |
|
109 | + $path_conf = $varEtcDir.'/asterisk_logrotate_'.$f_name.'.conf'; |
|
110 | 110 | file_put_contents($path_conf, $text_config); |
111 | 111 | $mb10 = $max_size * 1024 * 1024; |
112 | 112 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | public static function checkCodec($name, $desc, $type): void |
205 | 205 | { |
206 | - $codec = Codecs::findFirst('name="' . $name . '"'); |
|
206 | + $codec = Codecs::findFirst('name="'.$name.'"'); |
|
207 | 207 | if ($codec === null) { |
208 | 208 | /** @var \MikoPBX\Common\Models\Codecs $codec_g722 */ |
209 | 209 | $codec = new Codecs(); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function sipReload():void |
221 | 221 | { |
222 | - $di = Di::getDefault(); |
|
222 | + $di = Di::getDefault(); |
|
223 | 223 | if ($di === null) { |
224 | 224 | return; |
225 | 225 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | Processes::mwExec("{$asteriskPath} -rx 'module reload acl'"); |
236 | 236 | Processes::mwExec("{$asteriskPath} -rx 'core reload'"); |
237 | 237 | } else { |
238 | - Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk',LOG_INFO, LOG_INFO); |
|
238 | + Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk', LOG_INFO, LOG_INFO); |
|
239 | 239 | // Завершаем каналы. |
240 | 240 | Processes::mwExec("{$asteriskPath} -rx 'channel request hangup all'"); |
241 | 241 | usleep(500000); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public static function iaxReload(): void |
250 | 250 | { |
251 | - $iax = new IAXConf(); |
|
251 | + $iax = new IAXConf(); |
|
252 | 252 | $iax->generateConfig(); |
253 | 253 | $asteriskPath = Util::which('asterisk'); |
254 | 254 | Processes::mwExec("{$asteriskPath} -rx 'iax2 reload'"); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | 'result' => 'ERROR', |
306 | 306 | ]; |
307 | 307 | |
308 | - if ( ! $this->di->getShared('registry')->booting) { |
|
308 | + if (!$this->di->getShared('registry')->booting) { |
|
309 | 309 | $this->stop(); |
310 | 310 | } |
311 | 311 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | // Создание базы данных истории звонков. |
322 | 322 | /** @var \Phalcon\Db\Adapter\Pdo\Sqlite $connection */ |
323 | 323 | $connection = $this->di->get('dbCDR'); |
324 | - if ( ! $connection->tableExists('cdr')) { |
|
324 | + if (!$connection->tableExists('cdr')) { |
|
325 | 325 | RegisterDIServices::recreateDBConnections(); |
326 | 326 | } else { |
327 | 327 | CdrDb::checkDb(); |
@@ -460,17 +460,17 @@ |
||
460 | 460 | $test_alert = ''; |
461 | 461 | if ($free < 5) { |
462 | 462 | $need_alert = true; |
463 | - $test_alert = "The {$disk['id']} has less than 5% of free space available."; |
|
463 | + $test_alert = "the {$disk['id']} has less than 5% of free space available."; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | if ($disk['free_space'] < 500) { |
467 | 467 | $need_alert = true; |
468 | - $test_alert = "The {$disk['id']} has less than 500MB of free space available."; |
|
468 | + $test_alert = "the {$disk['id']} has less than 500MB of free space available."; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | if ($disk['free_space'] < 100) { |
472 | 472 | $need_alert = true; |
473 | - $test_alert = "The {$disk['id']} has less than 100MB of free space available. Old call records will be deleted."; |
|
473 | + $test_alert = "the {$disk['id']} has less than 100MB of free space available. Old call records will be deleted."; |
|
474 | 474 | Processes::processPHPWorker(WorkerRemoveOldRecords::class); |
475 | 475 | } |
476 | 476 |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | public static function isStorageDisk($device): bool |
74 | 74 | { |
75 | 75 | $result = false; |
76 | - if ( ! file_exists("{$device}")) { |
|
76 | + if (!file_exists("{$device}")) { |
|
77 | 77 | return $result; |
78 | 78 | } |
79 | 79 | |
80 | - $tmp_dir = '/tmp/mnt_' . time(); |
|
80 | + $tmp_dir = '/tmp/mnt_'.time(); |
|
81 | 81 | Util::mwMkdir($tmp_dir); |
82 | 82 | $out = []; |
83 | 83 | |
84 | 84 | $storage = new Storage(); |
85 | - $uid_part = 'UUID=' . $storage->getUuid($device) . ''; |
|
85 | + $uid_part = 'UUID='.$storage->getUuid($device).''; |
|
86 | 86 | $format = $storage->getFsType($device); |
87 | 87 | if ($format === '') { |
88 | 88 | return false; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | Processes::mwExec("{$umountPath} {$device}"); |
102 | 102 | } |
103 | 103 | |
104 | - if ( ! self::isStorageDiskMounted($device)) { |
|
104 | + if (!self::isStorageDiskMounted($device)) { |
|
105 | 105 | Processes::mwExec("{$rmPath} -rf '{$tmp_dir}'"); |
106 | 106 | } |
107 | 107 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | $timeoutPath = Util::which('timeout'); |
232 | 232 | $sshfsPath = Util::which('sshfs'); |
233 | 233 | |
234 | - $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' " . |
|
235 | - "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n" . |
|
236 | - "{$pass}\n" . |
|
234 | + $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' ". |
|
235 | + "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n". |
|
236 | + "{$pass}\n". |
|
237 | 237 | "EOF\n"; |
238 | 238 | // file_put_contents('/tmp/sshfs_'.$host, $command); |
239 | 239 | Processes::mwExec($command, $out); |
@@ -265,19 +265,19 @@ discard block |
||
265 | 265 | |
266 | 266 | // Собираем строку подключения к ftp. |
267 | 267 | $auth_line = ''; |
268 | - if ( ! empty($user)) { |
|
269 | - $auth_line .= 'user="' . $user; |
|
270 | - if ( ! empty($pass)) { |
|
268 | + if (!empty($user)) { |
|
269 | + $auth_line .= 'user="'.$user; |
|
270 | + if (!empty($pass)) { |
|
271 | 271 | $auth_line .= ":{$pass}"; |
272 | 272 | } |
273 | 273 | $auth_line .= '",'; |
274 | 274 | } |
275 | 275 | |
276 | - $connect_line = 'ftp://' . $host; |
|
277 | - if ( ! empty($port)) { |
|
276 | + $connect_line = 'ftp://'.$host; |
|
277 | + if (!empty($port)) { |
|
278 | 278 | $connect_line .= ":{$port}"; |
279 | 279 | } |
280 | - if ( ! empty($remout_dir)) { |
|
280 | + if (!empty($remout_dir)) { |
|
281 | 281 | $connect_line .= "$remout_dir"; |
282 | 282 | } |
283 | 283 | |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public static function mkfs_disk($dev) |
305 | 305 | { |
306 | - if ( ! file_exists($dev)) { |
|
306 | + if (!file_exists($dev)) { |
|
307 | 307 | $dev = "/dev/{$dev}"; |
308 | 308 | } |
309 | - if ( ! file_exists($dev)) { |
|
309 | + if (!file_exists($dev)) { |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | $dir = ''; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | Processes::mwExec("/sbin/shell_functions.sh 'killprocesses' '$dir' -TERM 0"); |
342 | 342 | Processes::mwExec("{$umountPath} {$dir}"); |
343 | 343 | } |
344 | - $result = ! self::isStorageDiskMounted($dir); |
|
344 | + $result = !self::isStorageDiskMounted($dir); |
|
345 | 345 | if ($result && file_exists($dir)) { |
346 | 346 | // Если диск не смонтирован, то удаляем каталог. |
347 | 347 | Processes::mwExec("{$rmPath} -rf '{$dir}'"); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | */ |
412 | 412 | public static function statusMkfs($dev): string |
413 | 413 | { |
414 | - if ( ! file_exists($dev)) { |
|
414 | + if (!file_exists($dev)) { |
|
415 | 415 | $dev = "/dev/{$dev}"; |
416 | 416 | } |
417 | 417 | $out = []; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | } |
435 | 435 | $config = $di->getShared('config'); |
436 | 436 | $phpSessionDir = $config->path('www.phpSessionDir'); |
437 | - if ( ! empty($phpSessionDir)) { |
|
437 | + if (!empty($phpSessionDir)) { |
|
438 | 438 | $rmPath = Util::which('rm'); |
439 | 439 | Processes::mwExec("{$rmPath} -rf {$phpSessionDir}/*"); |
440 | 440 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | // Создание больщого файла для тестов. |
451 | 451 | // head -c 1500MB /dev/urandom > /storage/usbdisk1/big_file.mp3 |
452 | 452 | foreach ($hdd as $disk) { |
453 | - if ($disk['sys_disk'] === true && ! self::isStorageDiskMounted("{$disk['id']}4")) { |
|
453 | + if ($disk['sys_disk'] === true && !self::isStorageDiskMounted("{$disk['id']}4")) { |
|
454 | 454 | // Это системный диск (4ый раздел). Он не смонтирован. |
455 | 455 | continue; |
456 | 456 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | Processes::processPHPWorker(WorkerRemoveOldRecords::class); |
475 | 475 | } |
476 | 476 | |
477 | - if ( ! $need_alert) { |
|
477 | + if (!$need_alert) { |
|
478 | 478 | continue; |
479 | 479 | } |
480 | 480 | |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | $m_size = round(($disk_data[1] + $disk_data[2]) / 1024, 1); |
515 | 515 | $res_disks[] = [ |
516 | 516 | 'id' => $disk_data[0], |
517 | - 'size' => "" . $m_size, |
|
518 | - 'size_text' => "" . $m_size . " Mb", |
|
517 | + 'size' => "".$m_size, |
|
518 | + 'size_text' => "".$m_size." Mb", |
|
519 | 519 | 'vendor' => 'Debian', |
520 | 520 | 'mounted' => '/storage/usbdisk1', |
521 | 521 | 'free_space' => round($disk_data[2] / 1024, 1), |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | |
538 | 538 | $cf_disk = ''; |
539 | 539 | $varEtcDir = $this->config->path('core.varEtcDir'); |
540 | - if (file_exists($varEtcDir . '/cfdevice')) { |
|
541 | - $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice')); |
|
540 | + if (file_exists($varEtcDir.'/cfdevice')) { |
|
541 | + $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice')); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | foreach ($disks as $disk) { |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | $sys_disk = ($cf_disk == $disk); |
555 | 555 | |
556 | 556 | $mb_size = 0; |
557 | - if (is_file("/sys/block/" . $disk . "/size")) { |
|
558 | - $original_size = trim(file_get_contents("/sys/block/" . $disk . "/size")); |
|
557 | + if (is_file("/sys/block/".$disk."/size")) { |
|
558 | + $original_size = trim(file_get_contents("/sys/block/".$disk."/size")); |
|
559 | 559 | $original_size = ($original_size * 512 / 1024 / 1024); |
560 | 560 | $mb_size = $original_size; |
561 | 561 | } |
@@ -662,14 +662,14 @@ discard block |
||
662 | 662 | private function getVendorDisk($disk): string |
663 | 663 | { |
664 | 664 | $temp_vendor = []; |
665 | - if (is_file("/sys/block/" . $disk . "/device/vendor")) { |
|
666 | - $data = trim(file_get_contents("/sys/block/" . $disk . "/device/vendor")); |
|
665 | + if (is_file("/sys/block/".$disk."/device/vendor")) { |
|
666 | + $data = trim(file_get_contents("/sys/block/".$disk."/device/vendor")); |
|
667 | 667 | if ($data != '') { |
668 | 668 | $temp_vendor[] = trim(str_replace(',', ' ', $data)); |
669 | 669 | } |
670 | 670 | } |
671 | - if (is_file("/sys/block/" . $disk . "/device/model")) { |
|
672 | - $data = trim(file_get_contents("/sys/block/" . $disk . "/device/model")); |
|
671 | + if (is_file("/sys/block/".$disk."/device/model")) { |
|
672 | + $data = trim(file_get_contents("/sys/block/".$disk."/device/model")); |
|
673 | 673 | if ($data != '') { |
674 | 674 | $temp_vendor[] = trim(str_replace(',', ' ', $data)); |
675 | 675 | } |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | if (count($temp_vendor) == 0) { |
678 | 678 | $temp_vendor[] = $disk; |
679 | 679 | } |
680 | - if (is_file("/sys/block/" . $disk . "/device/type")) { |
|
681 | - $data = trim(file_get_contents("/sys/block/" . $disk . "/device/type")); |
|
680 | + if (is_file("/sys/block/".$disk."/device/type")) { |
|
681 | + $data = trim(file_get_contents("/sys/block/".$disk."/device/type")); |
|
682 | 682 | if ($data != '') { |
683 | 683 | $temp_vendor[] = trim(str_replace(',', ' ', $data)); |
684 | 684 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | Processes::mwExec("{$dfPath} -m | {$grepPath} {$hdd} | {$awkPath} '{print $4}'", $out); |
705 | 705 | $result = 0; |
706 | 706 | foreach ($out as $res) { |
707 | - if ( ! is_numeric($res)) { |
|
707 | + if (!is_numeric($res)) { |
|
708 | 708 | continue; |
709 | 709 | } |
710 | 710 | $result += (1 * $res); |
@@ -741,19 +741,19 @@ discard block |
||
741 | 741 | $path_size_info = $tmp_path; |
742 | 742 | } |
743 | 743 | if (empty($path_size_info)) { |
744 | - $tmp_path = "/sys/block/" . substr($dev, 0, 3) . "/{$dev}/size"; |
|
744 | + $tmp_path = "/sys/block/".substr($dev, 0, 3)."/{$dev}/size"; |
|
745 | 745 | if (file_exists($tmp_path)) { |
746 | 746 | $path_size_info = $tmp_path; |
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | - if ( ! empty($path_size_info)) { |
|
750 | + if (!empty($path_size_info)) { |
|
751 | 751 | $original_size = trim(file_get_contents($path_size_info)); |
752 | 752 | $original_size = ($original_size * 512 / 1024 / 1024); |
753 | 753 | $mb_size = $original_size; |
754 | 754 | } |
755 | 755 | |
756 | - $tmp_dir = "/tmp/{$dev}_" . time(); |
|
756 | + $tmp_dir = "/tmp/{$dev}_".time(); |
|
757 | 757 | $out = []; |
758 | 758 | |
759 | 759 | $fs = null; |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | Util::mwMkdir($dir); |
812 | 812 | |
813 | - if ( ! file_exists($dir)) { |
|
813 | + if (!file_exists($dir)) { |
|
814 | 814 | Util::sysLogMsg('Storage', "Unable mount $dev $format to $dir. Unable create dir."); |
815 | 815 | |
816 | 816 | return false; |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | Processes::mwExec("{$mountNtfs3gPath} /dev/{$dev} {$dir}", $out); |
822 | 822 | } else { |
823 | 823 | $storage = new Storage(); |
824 | - $uid_part = 'UUID=' . $storage->getUuid("/dev/{$dev}") . ''; |
|
824 | + $uid_part = 'UUID='.$storage->getUuid("/dev/{$dev}").''; |
|
825 | 825 | $mountPath = Util::which('mount'); |
826 | 826 | Processes::mwExec("{$mountPath} -t {$format} {$uid_part} {$dir}", $out); |
827 | 827 | } |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | unlink($storage_dev_file); |
842 | 842 | } |
843 | 843 | |
844 | - if (file_exists($varEtcDir . '/cfdevice')) { |
|
845 | - $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice')); |
|
844 | + if (file_exists($varEtcDir.'/cfdevice')) { |
|
845 | + $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice')); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | $disks = $this->getDiskSettings(); |
@@ -856,18 +856,18 @@ discard block |
||
856 | 856 | // Если это системный диск, то пытаемся подключить раздел 4. |
857 | 857 | $dev = "{$disk['device']}4"; |
858 | 858 | } |
859 | - if ( ! $this->hddExists($dev)) { |
|
859 | + if (!$this->hddExists($dev)) { |
|
860 | 860 | // Диск не существует. |
861 | 861 | continue; |
862 | 862 | } |
863 | - if ($disk['media'] === '1' || ! file_exists($storage_dev_file)) { |
|
863 | + if ($disk['media'] === '1' || !file_exists($storage_dev_file)) { |
|
864 | 864 | file_put_contents($storage_dev_file, "/storage/usbdisk{$disk['id']}"); |
865 | 865 | $this->updateConfigWithNewMountPoint("/storage/usbdisk{$disk['id']}"); |
866 | 866 | } |
867 | 867 | |
868 | - $str_uid = 'UUID=' . $this->getUuid($dev) . ''; |
|
868 | + $str_uid = 'UUID='.$this->getUuid($dev).''; |
|
869 | 869 | $format_p4 = $this->getFsType($dev); |
870 | - $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n"; |
|
870 | + $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n"; |
|
871 | 871 | $mount_point = "/storage/usbdisk{$disk['id']}"; |
872 | 872 | Util::mwMkdir($mount_point); |
873 | 873 | } |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | Util::mwMkdir('/storage'); |
980 | 980 | $chmodPath = Util::which('chmod'); |
981 | 981 | Processes::mwExec("{$chmodPath} 755 /storage"); |
982 | - if ( ! file_exists($varEtcDir . '/cfdevice')) { |
|
982 | + if (!file_exists($varEtcDir.'/cfdevice')) { |
|
983 | 983 | return; |
984 | 984 | } |
985 | 985 | $fstab = ''; |
986 | - $file_data = file_get_contents($varEtcDir . '/cfdevice'); |
|
986 | + $file_data = file_get_contents($varEtcDir.'/cfdevice'); |
|
987 | 987 | $cf_disk = trim($file_data); |
988 | 988 | if ('' == $cf_disk) { |
989 | 989 | return; |
@@ -993,9 +993,9 @@ discard block |
||
993 | 993 | $part3 = (strpos($cf_disk, 'mmcblk') !== false) ? "{$cf_disk}p3" : "{$cf_disk}3"; // Conf |
994 | 994 | |
995 | 995 | |
996 | - $uid_part2 = 'UUID=' . $this->getUuid("/dev/{$part2}") . ''; |
|
996 | + $uid_part2 = 'UUID='.$this->getUuid("/dev/{$part2}").''; |
|
997 | 997 | $format_p2 = $this->getFsType($part2); |
998 | - $uid_part3 = 'UUID=' . $this->getUuid("/dev/{$part3}") . ''; |
|
998 | + $uid_part3 = 'UUID='.$this->getUuid("/dev/{$part3}").''; |
|
999 | 999 | $format_p3 = $this->getFsType($part3); |
1000 | 1000 | |
1001 | 1001 | // $fstab .= "/dev/{$part1} /cf msdos ro 1 1\n"; // НЕ МОНТИРУЕМ! |
@@ -1040,12 +1040,12 @@ discard block |
||
1040 | 1040 | } |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - if ( ! empty($path)) { |
|
1043 | + if (!empty($path)) { |
|
1044 | 1044 | Util::mwMkdir($path); |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | $downloadCacheDir = appPath('sites/pbxcore/files/cache'); |
1048 | - if ( ! $isLiveCd) { |
|
1048 | + if (!$isLiveCd) { |
|
1049 | 1049 | Util::mwMkdir($downloadCacheDir); |
1050 | 1050 | Util::createUpdateSymlink($this->config->path('www.downloadCacheDir'), $downloadCacheDir); |
1051 | 1051 | } |
@@ -1083,13 +1083,13 @@ discard block |
||
1083 | 1083 | public function createAssetsSymlinks(): void |
1084 | 1084 | { |
1085 | 1085 | $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache'); |
1086 | - Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/js', $jsCacheDir); |
|
1086 | + Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/js', $jsCacheDir); |
|
1087 | 1087 | |
1088 | 1088 | $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache'); |
1089 | - Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/css', $cssCacheDir); |
|
1089 | + Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/css', $cssCacheDir); |
|
1090 | 1090 | |
1091 | 1091 | $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache'); |
1092 | - Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/img', $imgCacheDir); |
|
1092 | + Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/img', $imgCacheDir); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
@@ -1102,13 +1102,13 @@ discard block |
||
1102 | 1102 | $cacheDirs[] = $this->config->path('www.downloadCacheDir'); |
1103 | 1103 | $cacheDirs[] = $this->config->path('www.managedCacheDir'); |
1104 | 1104 | $cacheDirs[] = $this->config->path('www.modelsCacheDir'); |
1105 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/js'; |
|
1106 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/css'; |
|
1107 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/img'; |
|
1105 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/js'; |
|
1106 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/css'; |
|
1107 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/img'; |
|
1108 | 1108 | $cacheDirs[] = $this->config->path('adminApplication.voltCacheDir'); |
1109 | 1109 | $rmPath = Util::which('rm'); |
1110 | 1110 | foreach ($cacheDirs as $cacheDir) { |
1111 | - if ( ! empty($cacheDir)) { |
|
1111 | + if (!empty($cacheDir)) { |
|
1112 | 1112 | Processes::mwExec("{$rmPath} -rf {$cacheDir}/*"); |
1113 | 1113 | } |
1114 | 1114 | } |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | $countBlock = $swapSize * $bs; |
1219 | 1219 | $ddCmd = Util::which('dd'); |
1220 | 1220 | |
1221 | - Util::sysLogMsg('Swap', 'make swap ' . $swapFile, LOG_INFO, LOG_INFO); |
|
1221 | + Util::sysLogMsg('Swap', 'make swap '.$swapFile, LOG_INFO, LOG_INFO); |
|
1222 | 1222 | Processes::mwExec("{$ddCmd} if=/dev/zero of={$swapFile} bs={$bs} count={$countBlock}"); |
1223 | 1223 | |
1224 | 1224 | $mkSwapCmd = Util::which('mkswap'); |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | $swapOnCmd = Util::which('swapon'); |
1228 | 1228 | $result = Processes::mwExec("{$swapOnCmd} {$swapFile}"); |
1229 | - Util::sysLogMsg('Swap', 'connect swap result: ' . $result, LOG_INFO, LOG_INFO); |
|
1229 | + Util::sysLogMsg('Swap', 'connect swap result: '.$result, LOG_INFO, LOG_INFO); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | $size = 0; |
1240 | 1240 | $mntDir = ''; |
1241 | 1241 | $mounted = self::isStorageDiskMounted('', $mntDir); |
1242 | - if ( ! $mounted) { |
|
1242 | + if (!$mounted) { |
|
1243 | 1243 | return 0; |
1244 | 1244 | } |
1245 | 1245 | $hd = $this->getAllHdd(true); |
@@ -1260,12 +1260,12 @@ discard block |
||
1260 | 1260 | */ |
1261 | 1261 | public function saveDiskSettings($data, $id = '1'): void |
1262 | 1262 | { |
1263 | - if ( ! is_array($data)) { |
|
1263 | + if (!is_array($data)) { |
|
1264 | 1264 | return; |
1265 | 1265 | } |
1266 | 1266 | $disk_data = $this->getDiskSettings($id); |
1267 | 1267 | if (count($disk_data) === 0) { |
1268 | - $uniqid = strtoupper('STORAGE-DISK-' . md5(time())); |
|
1268 | + $uniqid = strtoupper('STORAGE-DISK-'.md5(time())); |
|
1269 | 1269 | $storage_settings = new StorageModel(); |
1270 | 1270 | foreach ($data as $key => $val) { |
1271 | 1271 | $storage_settings->writeAttribute($key, $val); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | if (is_array($value)) { |
49 | 49 | array_unshift($value, ' '); |
50 | - $result_config .= trim(implode("\n{$key} = ", $value)) . "\n"; |
|
50 | + $result_config .= trim(implode("\n{$key} = ", $value))."\n"; |
|
51 | 51 | } else { |
52 | 52 | $result_config .= "{$key} = {$value}\n"; |
53 | 53 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public static function amiOriginate($peer_number, $peer_mobile, $dest_number): array |
70 | 70 | { |
71 | 71 | $am = self::getAstManager('off'); |
72 | - $channel = 'Local/' . $peer_number . '@internal-originate'; |
|
72 | + $channel = 'Local/'.$peer_number.'@internal-originate'; |
|
73 | 73 | $context = 'all_peers'; |
74 | 74 | $IS_ORGNT = self::generateRandomString(); |
75 | 75 | $variable = "_IS_ORGNT={$IS_ORGNT},pt1c_cid={$dest_number},_extenfrom1c={$peer_number},__peer_mobile={$peer_mobile},_FROM_PEER={$peer_number}"; |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | public static function trimExtensionForFile($filename, $delimiter = '.'): string |
337 | 337 | { |
338 | 338 | // Отсечем расширение файла. |
339 | - $tmp_arr = explode((string)$delimiter, $filename); |
|
339 | + $tmp_arr = explode((string) $delimiter, $filename); |
|
340 | 340 | if (count($tmp_arr) > 1) { |
341 | 341 | unset($tmp_arr[count($tmp_arr) - 1]); |
342 | - $filename = implode((string)$delimiter, $tmp_arr); |
|
342 | + $filename = implode((string) $delimiter, $tmp_arr); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $filename; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public static function mwExec($command, &$outArr = null, &$retVal = null): int |
420 | 420 | { |
421 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
421 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
422 | 422 | |
423 | 423 | return Processes::mwExec($command, $outArr, $retVal); |
424 | 424 | } |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | $objects = scandir($dir); |
464 | 464 | foreach ($objects as $object) { |
465 | 465 | if ($object != "." && $object != "..") { |
466 | - if (filetype($dir . "/" . $object) == "dir") { |
|
467 | - self::rRmDir($dir . "/" . $object); |
|
466 | + if (filetype($dir."/".$object) == "dir") { |
|
467 | + self::rRmDir($dir."/".$object); |
|
468 | 468 | } else { |
469 | - unlink($dir . "/" . $object); |
|
469 | + unlink($dir."/".$object); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | public static function generateSslCert($options = null, $config_args_pkey = null, $config_args_csr = null): array |
490 | 490 | { |
491 | 491 | // Инициализация настроек. |
492 | - if ( ! $options) { |
|
492 | + if (!$options) { |
|
493 | 493 | $options = [ |
494 | 494 | "countryName" => 'RU', |
495 | 495 | "stateOrProvinceName" => 'Moscow', |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | ]; |
502 | 502 | } |
503 | 503 | |
504 | - if ( ! $config_args_csr) { |
|
504 | + if (!$config_args_csr) { |
|
505 | 505 | $config_args_csr = ['digest_alg' => 'sha256']; |
506 | 506 | } |
507 | 507 | |
508 | - if ( ! $config_args_pkey) { |
|
508 | + if (!$config_args_pkey) { |
|
509 | 509 | $config_args_pkey = [ |
510 | 510 | "private_key_bits" => 2048, |
511 | 511 | "private_key_type" => OPENSSL_KEYTYPE_RSA, |
@@ -593,12 +593,12 @@ discard block |
||
593 | 593 | $arrPaths = explode(' ', $parameters); |
594 | 594 | if (count($arrPaths) > 0) { |
595 | 595 | foreach ($arrPaths as $path) { |
596 | - if ( ! empty($path) |
|
597 | - && ! file_exists($path) |
|
598 | - && ! mkdir($path, 0755, true) |
|
599 | - && ! is_dir($path)) { |
|
596 | + if (!empty($path) |
|
597 | + && !file_exists($path) |
|
598 | + && !mkdir($path, 0755, true) |
|
599 | + && !is_dir($path)) { |
|
600 | 600 | $result = false; |
601 | - self::sysLogMsg('Util', 'Error on create folder ' . $path); |
|
601 | + self::sysLogMsg('Util', 'Error on create folder '.$path); |
|
602 | 602 | } |
603 | 603 | if ($addWWWRights) { |
604 | 604 | self::addRegularWWWRights($path); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | $row = trim($row); |
673 | 673 | $pos = strpos($row, ']'); |
674 | 674 | if ($pos !== false && strpos($row, '[') === 0) { |
675 | - $row = "\n" . substr($row, 0, $pos); |
|
675 | + $row = "\n".substr($row, 0, $pos); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | unset($row); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | foreach ($sections as $section) { |
685 | 685 | $data_rows = explode("\n", trim($section)); |
686 | 686 | $section_name = trim($data_rows[0] ?? ''); |
687 | - if ( ! empty($section_name)) { |
|
687 | + if (!empty($section_name)) { |
|
688 | 688 | unset($data_rows[0]); |
689 | 689 | $manual_data[$section_name] = []; |
690 | 690 | foreach ($data_rows as $row) { |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $reflection = new ReflectionClass($className); |
745 | 745 | $filename = $reflection->getFileName(); |
746 | 746 | } catch (ReflectionException $exception) { |
747 | - self::sysLogMsg('Util', 'Error ' . $exception->getMessage()); |
|
747 | + self::sysLogMsg('Util', 'Error '.$exception->getMessage()); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | return $filename; |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public static function getPidOfProcess($name, $exclude = ''): string |
763 | 763 | { |
764 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
764 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
765 | 765 | |
766 | 766 | return Processes::getPidOfProcess($name, $exclude); |
767 | 767 | } |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | */ |
782 | 782 | public static function processWorker($cmd, $param, $proc_name, $action, $out_file = '/dev/null') |
783 | 783 | { |
784 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
784 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
785 | 785 | |
786 | 786 | return Processes::processWorker($cmd, $param, $proc_name, $action, $out_file); |
787 | 787 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | string $param = 'start', |
800 | 800 | string $action = 'restart' |
801 | 801 | ): void { |
802 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
802 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
803 | 803 | Processes::processPHPWorker($className, $param, $action); |
804 | 804 | } |
805 | 805 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | */ |
814 | 814 | public static function killByName($procName): ?int |
815 | 815 | { |
816 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
816 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
817 | 817 | |
818 | 818 | return Processes::killByName($procName); |
819 | 819 | } |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | */ |
829 | 829 | public static function mwExecBg($command, $out_file = '/dev/null', $sleep_time = 0): void |
830 | 830 | { |
831 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
831 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
832 | 832 | Processes::mwExecBg($command, $out_file, $sleep_time); |
833 | 833 | } |
834 | 834 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public static function mwExecBgWithTimeout($command, $timeout = 4, $logname = '/dev/null'): void |
844 | 844 | { |
845 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
845 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
846 | 846 | Processes::mwExecBgWithTimeout($command, $timeout, $logname); |
847 | 847 | } |
848 | 848 | |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | */ |
857 | 857 | public static function mwExecCommands($arr_cmds, &$out = [], $logname = ''): void |
858 | 858 | { |
859 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
859 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
860 | 860 | Processes::mwExecCommands($arr_cmds, $out, $logname); |
861 | 861 | } |
862 | 862 |