コード例 #1
0
ファイル: fetion.php プロジェクト: rfyiamcool/solrex
/**
 * main
 * 
 * @args command line args
 */
function main($argc, $argv)
{
    global $fetion_proxy;
    global $fetion_debug;
    $user_mobile = null;
    $password = null;
    $sendto_sid = null;
    $content = null;
    $send_all = false;
    $proxy_host = null;
    $proxy_port = null;
    // caution, need to change to your own fetion number
    $mobiledn = 'FIXME';
    $passwd = 'FIXME';
    $cmcc_fetion_ip = '221.176.31.36';
    $cmcc_fetion_pt = '443';
    if ($argc < 2) {
        usage();
        return 1;
    }
    for ($I = 1; $I < $argc; ++$I) {
        if ($argv[$I] == '-p') {
            $fetion_proxy = $argv[++$I];
            list($proxy_host, $proxy_port) = split(":", $fetion_proxy, 2);
            if ($proxy_host === null) {
                $proxy_host = '10.10.10.10';
            }
            if ($proxy_port === null) {
                $proxy_port = '8080';
            }
        } else {
            if ($argv[$I] == '-d') {
                $fetion_debug = true;
            } else {
                if ($argv[$I] == '-a') {
                    $send_all = true;
                } else {
                    if ($argv[$I] == '-c') {
                        $content = $argv[++$I];
                    }
                }
            }
        }
        /*		} else {
        			$user_mobile = $argv[$I++];
        			$password = $argv[$I++];
        			if (isset($argv[$I])) {
        				$sendto_sid = $argv[$I++];
        				$content = $argv[$I];
        			}
        			break;
        		}
        */
    }
    if ($content === null) {
        $content = "\n";
        $content = sms_get_txt("http://10.10.10.11/GRE.txt", $content);
        $content = sms_get_txt("http://10.10.10.11/GRE1.txt", $content);
        //$content = sms_get_news($content);
    } else {
        $content = iconv("GBK", "UTF-8", $content);
    }
    /*wopwhite login fetion and get ssic and sid*/
    $login_info = fetion_login($mobiledn, $passwd);
    if ($login_info === false) {
        print "[*] login failed\r\n";
        return 1;
    }
    $ssic = $login_info['ssic'];
    $sid = $login_info['sid'];
    $domain = $login_info['domain'];
    if ($fetion_debug) {
        print "[*] https get successful\r\n";
        print "[*] ssic={$ssic}\n";
        print "[*] sid={$sid}\n";
        print "[*] domain={$domain}\n";
    }
    if ($fetion_proxy != null) {
        $http_tunnel = http_tunnel_connect($proxy_host, $proxy_port, $cmcc_fetion_ip, $cmcc_fetion_pt);
        if ($http_tunnel === false) {
            print "[*] http_tunnel failed\r\n";
            return 1;
        }
        $ok = fetion_register($ssic, $sid, $domain, $passwd, $http_tunnel);
        if ($ok === false) {
            print "[*] register failed\r\n";
            return 1;
        }
        fetion_debug("register successful");
        // send sms to wopwhite himself
        // caution, need to change fetion id to your own number
        $ok = fetion_send_sms($sid, 'sip:FIXME@fetion.com.cn;p=0000', $content, $http_tunnel);
        if ($fetion_debug) {
            print "[*] send sms " . strval($ok ? 'successful' : 'failed') . "\r\n";
        }
        if ($send_all === true) {
            $buddies = fetion_get_buddy_list_directly($sid, $http_tunnel);
            if ($buddies === false) {
                print "[*] get buddy list failed\r\n";
            } else {
                if ($fetion_debug) {
                    print "[buddy_sid]                                   [name]\r\n";
                }
                foreach ($buddies as $buddy_sid => $name) {
                    if ($fetion_debug) {
                        printf("  %35s => %s\r\n", $buddy_sid, $name);
                    }
                    $ok = fetion_send_sms($sid, $buddy_sid, $content, $http_tunnel);
                    if ($fetion_debug) {
                        print "[*] send sms " . strval($ok ? 'successful' : 'failed') . "\r\n";
                    }
                }
            }
        }
    }
}
コード例 #2
0
ファイル: fetion.php プロジェクト: babaloveyou1/uims
/**
 * send sms use http
 * 
 * @ssic user identification
 * @sid fetion id
 * @to receiver mobile number or sid
 * @content sms content
 */
function fetion_http_send_sms($ssic, $sid, $to, $content)
{
    $ok_regex = '/Send SMS OK/s';
    $msg = fetion_sip_create('M fetion.com.cn SIP-C/2.0', array('F' => $sid, 'I' => fetion_next_call(), 'Q' => '1 M', 'T' => $to, 'N' => 'SendSMS'), $content) . FETION_SIPP;
    fetion_debug("send sms...");
    fetion_curl_exec(fetion_next_url(), $ssic, $msg);
    $msg = fetion_curl_exec(fetion_next_url(), $ssic, FETION_SIPP);
    return preg_match($ok_regex, $msg);
}