Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?php
  3. //Print "Hello how are you";
  4. //die();
  5. $opt = getopt("u:m:");
  6. $u = $opt['u'];
  7. $m = $opt['m'];
  8. if ( strlen($u) < 4 || strlen($m) < 4 )
  9. {
  10. Print "Syntax: adduser.php -u<username> -m<email@example.com>\n";
  11. die();
  12. }
  13.  
  14. $pn = "parentname";
  15. $pw = randpw();
  16. $rp = "free___client-parentname";
  17.  
  18. $addcmd = "/usr/bin/sudo /script/add --type=add --parent-class=client --class=client --send_welcome_f=on --v-type=customer ";
  19. $addcmd .="--parent-name=".$pn." --nname=".$u." --v-password=".$pw." --contactemail=".$m." --v-plan_name=".$rp;
  20. Print "\n".$addcmd."\n";
  21. $output = "";
  22. $returncode = 0;
  23. exec($addcmd, $output, $returncode);
  24. Print "\nOutput of add user:\n";
  25. Print_r($output);
  26. Print "\nReturn Code of add user: ".$returncode;
  27.  
  28. function randpw()
  29. {
  30. $chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  31. $i = 0;
  32. $pw = '';
  33. while ($i <= 10) {
  34. $pw = $pw . substr($chars, rand(0,strlen($chars)-1), 1);
  35. $i++;
  36. }
  37. return $pw;
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement