Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. if (isset($_POST['create']) && !empty($_POST['botName']) && $users[$_SESSION['user']]['botCreate'] === true && !isset($_COOKIE['WykonanoAll'])) {
  2. $v = $ssh->exec("ls -dq ".$botPath."$botsName* | wc -l");
  3. if ($v == 0)
  4. $number = 0;
  5. elseif ($v == 1)
  6. $number = $v;
  7. else
  8. $number = $v;
  9. for ($a = 0 ; $a <= $number + 5; $a++) {
  10. $b = $ssh->exec("ls ".$botPath."$botsName".$a);
  11. if (strstr($b, 'No such file or directory') !== false) {
  12. $number = $a;
  13. break;
  14. }
  15. }
  16. $nick = $_POST['botName'];
  17. $channel = $_POST['botChannel'];
  18. $serverAddress = $_POST['botServer'];
  19. if (isset($_POST['botGroup']))
  20. $botGroup = $_POST['botGroup'];
  21. $nickLine = $configs['nameLine'];
  22. $channelLine = $configs['channelLine'];
  23. $serverLine = $configs['serverLine'];
  24. $usersGroups = $_POST['userGroup'];
  25. $adminsGroups = $_POST['adminGroup'];
  26. $usersGroupsLine = $configs['userRoleLine'];
  27. $adminsGroupsLine = $configs['adminRoleLine'];
  28. if (!empty($channel))
  29. $ssh->exec("sed -i '".$channelLine."s/.*/channel = \"\/$channel\"/' ".$botPath."botTemplate/Bots/bot_default.toml");
  30. $ssh->exec("sed -i '".$nickLine."s/.*/name = \"$nick\"/' ".$botPath."botTemplate/Bots/bot_default.toml");
  31. $ssh->exec("sed -i '".$serverLine."s/.*/address = \"$serverAddress\"/' ".$botPath."botTemplate/Bots/bot_default.toml");
  32. $ssh->exec("sed -i '".$usersGroupsLine."s/.*/ groupid = [ $usersGroups ]/' ".$botPath."botTemplate/MuzoBot-Permissions.toml");
  33. $ssh->exec("sed -i '".$adminsGroupsLine."s/.*/ groupid = [ $adminsGroups ]/' ".$botPath."botTemplate/MuzoBot-Permissions.toml");
  34. $ssh->exec("cp -R ".$botPath."botTemplate ".$botPath."$botsName".$number);
  35. if($_FILES['botAvatar']['size'] > 0) {
  36. $ssh->exec("rm ".$botPath."$botsName$number/assets/avatar_away.png");
  37. if (is_uploaded_file($_FILES['botAvatar']['tmp_name'])) {
  38. move_uploaded_file($_FILES['botAvatar']['tmp_name'], 'tmp/'.$_FILES['botAvatar']['name']);
  39. }
  40. $sftp->put($botPath."$botsName".$number."/assets/avatar_away.png", 'tmp/'.$_FILES['botAvatar']['name'], NET_SFTP_LOCAL_FILE);
  41. unlink('tmp/'.$_FILES['botAvatar']['name']);
  42. $ssh->exec("rm ".$botPath."$botsName$number/assets/noGraphic.png");
  43. $ssh->exec("cp ".$botPath."$botsName$number/assets/avatar_away.png ".$botPath."$botsName$number/assets/noGraphic.png");
  44. }
  45. //$ssh->exec("cd ".$botPath."$botsName".$number." && screen -AmdS $botsName".$number." mono MuzoBot.exe");
  46. $ok = "Pomyślnie Utworzono Bota <b>$nick</b> <i>ID: $number</i>";
  47. unset($_POST['create']);
  48. $_POST = array();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement