Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Перевод звонка
- * phone - номер оператора, от которого нужно "забрать" звонок
- * exten - куда перевести звонок
- *
- */
- $action_id = 1;
- stream_set_blocking($fp, TRUE);
- stream_set_timeout($fp, 30);
- if(!isset($_REQUEST['phone'])){
- $_REQUEST['phone'] = $_SESSION['agent_telephone'];
- }
- $info = stream_get_meta_data($fp);
- fprintf($fp, "Action: Login\r\n");
- fprintf($fp, "ActionID: " . $action_id++ . "\r\n");
- fprintf($fp, "Username: %s\r\n", $login);
- fprintf($fp, "Secret: %s\r\n", $password);
- fprintf($fp, "\r\n");
- fprintf($fp, "Action: CoreShowChannels\r\n");
- fprintf($fp, "ActionID: " . $action_id++ . "\r\n");
- fprintf($fp, "\r\n");
- $request = array();
- $channels = array();
- while (!feof($fp) && (!$info['timed_out']))
- {
- $s = trim(fgets($fp));
- if (strlen($s) == 0 && (!$info['timed_out']))
- {
- if (!isset($request['Event']))
- $request['Event'] = 'None';
- switch($request['Event']){
- case 'None':
- break;
- case 'CoreShowChannel':
- if($request['ConnectedLineNum']==""||strlen($request['ConnectedLineNum'])!=3) break;
- $channels[$request['ConnectedLineNum']][] = $request;
- break;
- case 'CoreShowChannelsComplete':
- break 2;
- }
- $request = array();
- }
- else
- {
- $se = explode(':', $s, 2);
- if (count($se) == 2)
- $request[trim($se[0])] = trim($se[1]);
- }
- }
- if(isset($channels[$_REQUEST['phone']][0]['Channel'])){
- fprintf($fp, "Action: Redirect\r\n");
- fprintf($fp, "ActionID: " . $action_id++ . "\r\n");
- fprintf($fp, "Channel: %s\r\n",$channels[$_REQUEST['phone']][0]['Channel']);
- fprintf($fp, "Context: from-internal\r\n");
- fprintf($fp, "Priority: 1\r\n");
- fprintf($fp, "Exten: %s\r\n",$_REQUEST['exten']);
- fprintf($fp, "\r\n");
- }
- sleep(2);
- fclose($fp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement