You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../../scripts/sys_utils.php');
  3. //require_once('../../scripts/distro_web_utils.php');
  4. $COP = -1;
  5. if( isset( $_GET['OP'] ) ){
  6. $COP = intval( $_GET['OP'] );
  7. } else if( isset( $_POST['OP'] ) ){
  8. $COP = intval( $_POST['OP'] );
  9. };
  10. if( $COP > -1 ){
  11. switch( $COP ){
  12. case 1:{
  13. //Add user
  14. if( !isset( $SYS_CONFIG['NGINX_AUTH_ACCESS_LIST'] ) ) $SYS_CONFIG['NGINX_AUTH_ACCESS_LIST'] = array();
  15. foreach( $SYS_CONFIG['NGINX_AUTH_ACCESS_LIST'] as $U ) if( $U['USERNAME'] == $_POST['uname'] ){
  16. header( 'location: /add_auth.php' );
  17. exit();
  18. };
  19. $NU = array();
  20. $NU['USERNAME'] = $_POST['uname'];
  21. $NU['PASSWORD'] = $_POST['upass'];
  22. $SYS_CONFIG['NGINX_AUTH_ACCESS_LIST'][] = $NU;
  23. save_system_config();
  24. if( $SYS_CONFIG['NGINX_AUTH_IS_SET'] ){
  25. header( 'location: /task_wait.php?TID=8' );
  26. exit();
  27. };
  28. break;
  29. };
  30. case 2:{
  31. //remove user
  32. $UID =$_GET['UID'];
  33. //echo "UID: " . $UID. "\n";
  34. unset( $SYS_CONFIG['NGINX_AUTH_ACCESS_LIST'][$UID] );
  35. save_system_config();
  36. break;
  37. };
  38. };
  39. };
  40. header( 'location: /add_auth.php' );
  41. ?>