Guest User

Untitled

a guest
Jun 27th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1. <?php
  2.  
  3. include("./XMPPHP/XMPP.php");
  4.  
  5.  
  6. $master = '';
  7. $user = '';
  8. $pass = '';
  9. $server = '';
  10. $resource = '';
  11. $myhandle = $user.'@'.$server.'/'.$resource;
  12.  
  13.  
  14.  
  15. class Bot {
  16.   public $uname;  
  17. //problem occurs whatever line you try put in a variable . see below for where it's called
  18.   public $info = array(1 => array("ENTRY" => "BOTID", VALUE => "cow boy"),
  19.                2 => array("ENTRY" => "UNAME", VALUE => "WAKER"),
  20.                3 => array("ENTRY" => "TEST", VALUE =>  $uname));
  21.   public $PWD;
  22. };
  23. $bot = new Bot;
  24.  
  25. $conn = new XMPPHP_XMPP($server, 5222, $user, $pass, $resource, '', $printlog=True, $loglevel='LOGGING_VERBOSE');
  26.  
  27. try {
  28.   $conn->useEncryption(true);
  29.   $conn->connect();
  30.    //exec('echo $PWD',$initialPWD); $bot->PWD = $initialPWD[0];
  31.   // exec('uname -a',$uname); $bot->uname = $uname[0];
  32.    while(!$conn->disconnected){
  33.    $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
  34.      foreach($payloads as $event) {
  35.         $pl = $event[1];
  36.         switch($event[0]) {
  37.             case 'message':
  38.           if(!empty($pl['body']) ){
  39.         echo "\n-----------------------------
  40. MESSAGE:
  41. {$pl['body']}
  42. -----------------------------\n";
  43.         parser($bot,$conn,$pl);
  44.           }
  45.               break;
  46.             case 'presence':
  47.               print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
  48.               break;
  49.             case 'session_start':
  50.               $conn->presence($status="");
  51.               break;
  52.         }
  53.        
  54.      }
  55.    }
  56. } catch(XMPPHP_Exception $e) {
  57.     die($e->getMessage());
  58. }
  59.  
  60. function parser($bot,$conn,$pl){
  61.   if($pl['body'] == "SENDINFO"){
  62.     echo "RECEIVED 'SENDINFO'\n";
  63.     updateInfo($bot,$conn,$pl);
  64.   }
  65.  
  66. }
  67.  
  68. function updateInfo($bot,$conn,$pl){
  69.   foreach($bot->info as $entry){
  70. // now, this works as it is! so wtf?
  71.     $conn->message($pl['from'],"NEWINFO {$entry['ENTRY']} {$entry['VALUE']}");
  72.   }
  73. }
  74. ?>
Add Comment
Please, Sign In to add comment