コード例 #1
0
ファイル: notify.php プロジェクト: NetOverflow/ruTorrent
    if ($at->advancedSettings) {
        $useEncryption = $at->useEncryption;
        if ($at->jabberHost) {
            $jabberHost = $at->jabberHost;
        }
        if ($at->jabberPort) {
            $jabberPort = $at->jabberPort;
        }
    }
    $conn = new XMPPHP_XMPP($jabberHost, $jabberPort ? $jabberPort : 5222, $at->jabberLogin, $at->jabberPasswd, 'xmpphp', $at->jabberServer);
    if ($useEncryption) {
        $conn->useEncryption(true);
        $opts = array('ssl' => array('verify_peer' => true, 'allow_self_signed' => true));
        if ($at->jabberHost != $at->jabberServer) {
            $opts['ssl']['CN_match'] = $at->jabberServer;
        }
        $conn->set_context($opts);
    } else {
        $conn->useEncryption(false);
    }
    try {
        $message = str_replace("{TORRENT}", $name, $at->message);
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->presence();
        $conn->message($at->jabberFor, $message);
        $conn->disconnect();
    } catch (XMPPHP_Exception $e) {
        die($e->getMessage());
    }
}