2

I am trying to register user on ejabberd linux server.

I am using below php code

<?php
  $username = 'hello';
  $password = 'hello';
  $node = 'my ip';
  exec('sudo -S ejabberd /usr/sbin/ejabberdctl register '.$username.' '.$node.' '.$password.' 2>&1',$output,$status);
  if($output == 0){
        // Success!
        echo 'success';
   }else{
        // Failure, $output has the details
        echo '<pre>';
        foreach($output as $o){
                echo $o."\n";
        }
         echo '</pre>';
   }
?>

But when I execute the file i got following error :

sudo: /etc/sudoers.d is world writable
        [sudo] password for daemon:

Also I found the solution from below url

sudo in php exec()

but I am not getting how to use this

Please help

Community
  • 1
  • 1
Sunil Bhawsar
  • 201
  • 3
  • 14

1 Answers1

0

you can also use ejabberd_xmlrpc to register user using php but you have to change setting in your ejabberd configuration file.Uncomment these lines in ejabberd configuration file-

 ## - 
  ##   port: 4560
  ##   module: ejabberd_xmlrpc
  ##   maxsessions: 10
  ##   timeout: 5000
  ##   access_commands:
  ##     xmlrpc:
  ##       commands: all
  ##   options: []

for php sample check this link

Sunil Singh
  • 538
  • 3
  • 12