_server_error('Failed to convert file.'); } } elseif ($fmt === 'wav-pcm') { # signed linear PCM in WAVE container $cmd = $sox . ' -q -t al ' . qsa($origfile) . ' -r 8000 -c 1 -s -b 16 -t wav ' . qsa($outfile) . ' 1>>/dev/null'; $err = 0; $out = array(); @exec($cmd, $out, $err); if ($err != 0) { gs_log(GS_LOG_WARNING, 'Failed to convert voicemail file to ' . $fmt . '. (' . trim(implode(' - ', $out)) . ')'); _server_error('Failed to convert file.'); } } if (!file_exists($outfile)) { gs_log(GS_LOG_WARNING, 'Failed to convert voicemail file.'); _server_error('Failed to convert file.'); } @header('Content-Type: ' . $formats[$fmt]['mime']); $fake_filename = preg_replace('/[^0-9a-z\\-_.]/i', '', 'vm_' . $ext . '_' . date('Ymd_Hi', $info['orig_time']) . '_' . subStr(md5(date('s', $info['orig_time']) . $info['cidnum']), 0, 4) . '.' . $formats[$fmt]['ext']); @header('Content-Disposition: ' . ($attach ? 'attachment' : 'inline') . '; filename="' . $fake_filename . '"'); @header('ETag: ' . $etag); # set Content-Length to prevent Apache(/PHP?) from using # "Transfer-Encoding: chunked" which makes the sound file appear too # short in QuickTime and maybe other players @header('Transfer-Encoding: identity'); if ($fmt === 'wav-pcma') { @header('Content-Length: ' . ((int) strLen($wav_alaw_header) + (int) @fileSize($origfile))); echo $wav_alaw_header; @readFile($origfile); } else { @header('Content-Length: ' . (int) @fileSize($outfile));
_not_allowed(); } if ($_SESSION['real_user']['name'] !== 'sysadmin' && !gs_user_is_admin(@$_SESSION['real_user']['name'])) { _not_allowed(); } if (!array_key_exists('u', $_REQUEST)) { _not_found('Username not specified.'); } $user = $_REQUEST['u']; include_once GS_DIR . 'inc/gs-fns/gs_ldap_user_search.php'; $user_info = gs_ldap_user_search($user); if (isGsError($user_info)) { _server_error($user_info->getMsg()); } if (!is_array($user_info)) { _server_error('Failed to look up user "' . $user . '" in LDAP.'); } require_once GS_DIR . 'lib/utf8-normalize/gs_utf_normal.php'; @header('Content-Type: application/json'); # RFC 4627 ob_start(); echo "{\n"; $i = 0; foreach ($user_info as $k => $v) { if ($i > 0) { echo ",\n"; } echo '"', $k, '": '; if ($v === null) { echo 'null'; } else {