예제 #1
0
파일: call-init-2.php 프로젝트: rkania/GS3
    $api = gs_host_get_api($user['host_id']);
    switch ($api) {
        case 'm01':
        case 'm02':
            if (!extension_loaded('soap')) {
                gs_log(GS_LOG_NOTICE, 'Failed to initiate call on foreign host (SoapClient not available).');
                die_error('Failed to initiate call on foreign host (SoapClient not available).');
            } else {
                include_once GS_DIR . 'inc/boi-soap/boi-soap.php';
                $ok = gs_boi_call_init($api, $user['host'], $user_code, $to_num_obj->norm, $from_num_effective_obj->norm, $cidnum, $clir, $prv);
                if (!$ok) {
                    gs_log(GS_LOG_NOTICE, 'Failed to initiate call on foreign host (SOAP error).');
                    die_error('Failed to initiate call on foreign host (SOAP error).');
                }
                gs_log(GS_LOG_DEBUG, "OK. Calling " . $to_num_obj->norm . " from " . $from_num_effective_obj->norm . " (user {$user_code}) on host " . $user['host'] . "...");
                die_ok("OK. Calling " . $to_num_obj->norm . " from " . $from_num_effective_obj->norm . " (user {$user_code}) on host " . $user['host'] . "...");
            }
            break;
        case '':
            # host does not provide any API
            gs_log(GS_LOG_WARNING, 'Failed initiate call on foreign host ' . $user['host'] . ' without any API');
            die_error('Failed initiate call on foreign host ' . $user['host'] . ' without any API');
            break;
        default:
            gs_log(GS_LOG_WARNING, 'Failed to initiate call on foreign host ' . $user['host'] . ' - invalid API "' . $api . '"');
            die_error('Failed to initiate call on foreign host ' . $user['host'] . ' - invalid API "' . $api . '"');
    }
}
gs_log(GS_LOG_DEBUG, "OK. Calling {$to_num} from " . $from_num_effective_obj->dial . " ...");
die_ok("OK. Calling {$to_num} from " . $from_num_effective_obj->dial . " ...");
예제 #2
0
파일: send-fax.php 프로젝트: rkania/GS3
$pin = gs_user_pin_get($user);
# use default fax TSI if not provided in http request
#
if ($tsi == '') {
    $fax_tsis_global = explode(',', gs_get_conf('GS_FAX_TSI'));
    if (array_key_exists(0, $fax_tsis_global) && $fax_tsis_global[0] != '') {
        $tsi = $fax_tsis_global[0];
    } else {
        $tsi = '0';
    }
}
# if no local file is specified check if ist's provided in http request
#
if ($local_file == '' && is_array($_FILES) && array_key_exists('file', $_FILES) && $_FILES['file']['error'] == 0 && $_FILES['file']['size'] > 0) {
    $local_file = $_FILES['file']['tmp_name'];
}
# invoke function from the fax library
#
if ($local_file != '') {
    $local_file = gs_get_conf('GS_FAX_INIT_DOCDIR', '') . '/' . preg_replace('/\\.\\./', '', $local_file);
    if (file_exists($local_file)) {
        $fax_job_id = fax_send($user_id, $user, $to, $tsi, $local_file, $email, $resolution, $pin);
    }
}
# result
#
if (isset($fax_job_id) && $fax_job_id >= 1) {
    die_ok('Fax job sent with id: ' . $fax_job_id);
} else {
    die_error('Fax job not accepted');
}
예제 #3
0
파일: call-init.php 프로젝트: rkania/GS3
if ($user_is_on_this_host) {
    # the Asterisk of this user and the web server both run on this host
    //$ok = @rename( $filename, $spoolfile );
    $err = 0;
    $out = array();
    @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
    if ($err != 0) {
        @unlink($filename);
        gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
        die_error('Failed to move call file.');
    }
} else {
    $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
    //echo $cmd, "\n";
    @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
    @unlink($filename);
    if ($err != 0) {
        gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
        die_error('Failed to scp call file.');
    }
    //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
    $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
    //echo $cmd, "\n";
    @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
    if ($err != 0) {
        gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
        die_error('Failed to mv call file on remote host.');
    }
}
die_ok("OK. Calling {$to_num} from {$from_num_effective} ...");