Changeset 1446 for trunk/workflow/inc/class.bo_userinterface.inc.php
- Timestamp:
- 09/23/09 17:26:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/workflow/inc/class.bo_userinterface.inc.php
r1277 r1446 1059 1059 return $employees; 1060 1060 } 1061 1062 function callVoipConnect($params) 1063 { 1064 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 1065 $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP); 1066 1067 $entry = $cachedLDAP->getEntryByID( $_SESSION['phpgw_info']['workflow']['account_id'] ); 1068 if ( $entry && ! is_null($entry['telephonenumber']) ) 1069 $fromNumber = $entry['telephonenumber']; 1070 1071 if ( $fromNumber == false ) 1072 return false; 1073 1074 $toNumber = $params['to']; 1075 1076 $voipServer = $_SESSION['phpgw_info']['workflow']['server']['voip_server']; 1077 $voipUrl = $_SESSION['phpgw_info']['workflow']['server']['voip_url']; 1078 $voipPort = $_SESSION['phpgw_info']['workflow']['server']['voip_port']; 1079 1080 if(!$voipServer || !$voipUrl || !$voipPort) 1081 return false; 1082 1083 $url = "http://".$voipServer.":".$voipPort.$voipUrl."?magic=1333&acao=liga&ramal=".$fromNumber."&numero=".$toNumber; 1084 $sMethod = 'GET '; 1085 $crlf = "\r\n"; 1086 $sRequest = " HTTP/1.1" . $crlf; 1087 $sRequest .= "Host: localhost" . $crlf; 1088 $sRequest .= "Accept: */* " . $crlf; 1089 $sRequest .= "Connection: Close" . $crlf . $crlf; 1090 $sRequest = $sMethod . $url . $sRequest; 1091 $sockHttp = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 1092 if (!$sockHttp) { 1093 return false; 1094 } 1095 $resSocketConnect = socket_connect($sockHttp, $voipServer, $voipPort); 1096 if (!$resSocketConnect) { 1097 return false; 1098 } 1099 $resSocketWrite = socket_write($sockHttp, $sRequest, strlen($sRequest)); 1100 if (!$resSocketWrite) { 1101 return false; 1102 } 1103 $sResponse = ''; 1104 while ($sRead = socket_read($sockHttp, 512)) { 1105 $sResponse .= $sRead; 1106 } 1107 1108 socket_close($sockHttp); 1109 $pos = strpos($sResponse, $crlf . $crlf); 1110 return substr($sResponse, $pos + 2 * strlen($crlf)); 1111 } 1061 1112 } 1062 1113 ?>
Note: See TracChangeset
for help on using the changeset viewer.