Second Commit
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

101 行
3.2 KiB

  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\AuthenticationOtp;
  4. use PEAR2\Net\RouterOS;
  5. use Exception;
  6. use Illuminate\Http\Request;
  7. use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
  8. class RouterController extends Controller
  9. {
  10. public function connecttoWifi(){
  11. try {
  12. $client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
  13. $DeviceConnect = $client->sendSync(new RouterOS\Request('/ip/arp/print'));
  14. dd($DeviceConnect);
  15. foreach ($DeviceConnect as $response) {
  16. if ($response->getType() === RouterOS\Response::TYPE_DATA) {
  17. dd($response->getProperty('mac-address'));
  18. }
  19. }
  20. } catch (Exception $e) {
  21. throw $e;
  22. //die('Unable to connect to the router.');
  23. //Inspect $e if you want to know details about the failure.
  24. }
  25. }
  26. public function subscription(){
  27. //return register user ke paket
  28. try {
  29. $client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
  30. $amount = 5;
  31. $plan1 = 'bronze';
  32. $plan2 = 'diamond';
  33. $plan3 = 'gold';
  34. $user = auth()->user();
  35. $email = $user->name;
  36. $formatted_email = str_replace('','', $email);
  37. $add_user= new RouterOS\Request('/tool/usermanager/user/add');
  38. $client->sendSync(
  39. $add_user
  40. ->setArgument('customer','admin')
  41. ->setArgument('disabled', 'no')
  42. ->setArgument('username', $formatted_email)
  43. ->setArgument('password', $formatted_email)
  44. ->setArgument('shared-users', 1)
  45. );
  46. $activate_profile = new RouterOS\Request('/tool user-manager user create-and-activate-profile');
  47. $client->sendSync(
  48. $activate_profile
  49. ->setArgument('customer', 'admin')
  50. ->setArgument('profile', $plan2)
  51. ->setArgument('numbers', $formatted_email)
  52. );
  53. $authen = AuthenticationOtp::where('package', $plan2)->where('status', 1)->first();
  54. if(!$authen){
  55. }
  56. $authentication = new AuthenticationOtp();
  57. $authentication->user_name = $formatted_email;
  58. $authentication->password = $formatted_email;
  59. $authentication->user_id = auth()->id();
  60. $authentication->package = $plan2;
  61. $authentication->status = 1;
  62. $authentication->amount = $amount;
  63. $authentication->save();
  64. return redirect('/home');
  65. }catch (Exception $e) {
  66. throw $e;
  67. //die('Unable to connect to the router.');
  68. //Inspect $e if you want to know details about the failure.
  69. }
  70. }
  71. public function hostpotUsers(){
  72. $client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
  73. $activate_profile = new RouterOS\Request('/tool user-manager user Print');
  74. $users_Hotspot = $client->sendSync( $activate_profile);
  75. }
  76. }