<?php

// activate full error reporting
//error_reporting(E_ALL & E_STRICT);
include 'XMPPHP/XMPP.php';
#Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports
#If this doesn't work, are you running 64-bit PHP with < 5.2.6?
$conn = new XMPPHP_XMPP('talk.google.com', 5222, 'spottersu', 'spotGSP11', 'xmpphp', 'gmail.com', $printlog = true, $loglevel = XMPPHP_Log::LEVEL_INFO);
$conn->autoSubscribe();
$vcard_request = array();
try {
    $conn->connect();
    while (!$conn->isDisconnected()) {
        $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start', 'vcard'));
        foreach ($payloads as $event) {
            $pl = $event[1];
            switch ($event[0]) {
                case 'message':
                    print "---------------------------------------------------------------------------------\n";
                    print "Message from: {$pl['from']}\n";
                    if ($pl['subject']) {
                        print "Subject: {$pl['subject']}\n";
                    }
                    print $pl['body'] . "\n";
                    print "---------------------------------------------------------------------------------\n";
                    $conn->message($pl['from'], $body = "Thanks for sending me \"{$pl['body']}\".", $type = $pl['type']);
                    $cmd = explode(' ', $pl['body']);
                    if ($cmd[0] == 'quit') {
                        $conn->disconnect();
                    }
                    if ($cmd[0] == 'break') {