Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("./XMPPHP/XMPP.php");
- $master = '';
- $user = '';
- $pass = '';
- $server = '';
- $resource = '';
- $myhandle = $user.'@'.$server.'/'.$resource;
- class Bot {
- public $uname;
- //problem occurs whatever line you try put in a variable . see below for where it's called
- public $info = array(1 => array("ENTRY" => "BOTID", VALUE => "cow boy"),
- 2 => array("ENTRY" => "UNAME", VALUE => "WAKER"),
- 3 => array("ENTRY" => "TEST", VALUE => $uname));
- public $PWD;
- };
- $bot = new Bot;
- $conn = new XMPPHP_XMPP($server, 5222, $user, $pass, $resource, '', $printlog=True, $loglevel='LOGGING_VERBOSE');
- try {
- $conn->useEncryption(true);
- $conn->connect();
- //exec('echo $PWD',$initialPWD); $bot->PWD = $initialPWD[0];
- // exec('uname -a',$uname); $bot->uname = $uname[0];
- while(!$conn->disconnected){
- $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
- foreach($payloads as $event) {
- $pl = $event[1];
- switch($event[0]) {
- case 'message':
- if(!empty($pl['body']) ){
- echo "\n-----------------------------
- MESSAGE:
- {$pl['body']}
- -----------------------------\n";
- parser($bot,$conn,$pl);
- }
- break;
- case 'presence':
- print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
- break;
- case 'session_start':
- $conn->presence($status="");
- break;
- }
- }
- }
- } catch(XMPPHP_Exception $e) {
- die($e->getMessage());
- }
- function parser($bot,$conn,$pl){
- if($pl['body'] == "SENDINFO"){
- echo "RECEIVED 'SENDINFO'\n";
- updateInfo($bot,$conn,$pl);
- }
- }
- function updateInfo($bot,$conn,$pl){
- foreach($bot->info as $entry){
- // now, this works as it is! so wtf?
- $conn->message($pl['from'],"NEWINFO {$entry['ENTRY']} {$entry['VALUE']}");
- }
- }
- ?>
Add Comment
Please, Sign In to add comment