Пример #1
0
 public function eslreponse()
 {
     $eslManager = new EslManager();
     $errors = message::render(NULL, array('html' => TRUE, 'htmlTemplate' => '{text}' . "\n", 'growl' => FALSE, 'inline' => FALSE));
     if (!empty($errors['html'])) {
         echo implode('', $errors['html']);
     }
     if (!$eslManager->isConnected()) {
         if (empty($errors['html'])) {
             echo __("Failed to load ESL. Check logs");
         }
         flush();
         die;
     }
     switch ($_POST['type']) {
         case 'status':
             $result = $eslManager->status();
             break;
         case 'version':
             $result = $eslManager->version();
             break;
         case 'reloadacl':
             $result = $eslManager->reloadacl();
             break;
         case 'reloadxml':
             $result = $eslManager->reloadxml();
             break;
         case 'channels':
             $result = $eslManager->channels();
             break;
         case 'calls':
             $result = $eslManager->calls();
             break;
         case 'show_codec':
             $result = $eslManager->show('codec');
             break;
         case 'show_modules':
             $result = $eslManager->show('modules');
             break;
         case 'show_files':
             $result = $eslManager->show('file');
             break;
         case 'nat_status':
             $result = $eslManager->nat('status');
             break;
         case 'nat_reinit':
             $result = $eslManager->nat('reinit');
             break;
         case 'nat_republish':
             $result = $eslManager->nat('republish');
             break;
         case 'reload_sofia':
             $result = $eslManager->reload('mod_sofia');
             break;
         case 'sofia_status':
             $result = $eslManager->sofia('status');
             break;
         case 'sofia_profile':
             $result = $eslManager->sofia('status', 'profile', $_POST['param']);
             break;
         case 'gateway_profile':
             $result = $eslManager->sofia('status', 'gateway', $_POST['param']);
             break;
         case 'recvEvent':
             if (empty($_POST['param'])) {
                 $result = '== HELP ==' . "\n";
                 $result .= __('Please use the text input to enable an event listener that you are interested in.') . "\n";
                 $result .= 'Example: events plain all' . "\n";
                 break;
             }
             $result = $eslManager->sendRecv($_POST['param']);
             $reply = $result->getHeader('Reply-Text');
             if (!strstr($reply, '+OK event listener enabled')) {
                 $result = '== HELP ==' . "\n";
                 $result .= __('The supplied command failed to start an event listener, please ensure you are using the events command.') . "\n";
                 break;
             }
             $result = $eslManager->recvEvent();
             break;
         case 'sendRecv':
             if (empty($_POST['param'])) {
                 $result = '== HELP ==' . "\n";
                 $result .= 'Please use the text input to provide a command to execute.' . "\n";
                 $result .= 'Example: api version' . "\n";
                 break;
             }
             $result = $eslManager->sendRecv($_POST['param']);
             break;
         default:
             $result = $_POST['type'] . __(' command not supported by Bluebox ESL plugin.');
             break;
     }
     $text = $eslManager->getResponse($result);
     echo htmlentities($text);
     flush();
     die;
 }