Guest User

Untitled

a guest
Sep 23rd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2. if(isset( $_POST ) && array_key_exists( 'username', $_POST ) && array_key_exists( 'password', $_POST )) {
  3. $ftph = @ftp_connect( 'localhost' ) or die( 'Could not connect to server, try again later' );
  4. @ftp_login( $ftph, $_POST['username'], $_POST['password']) or die( 'Not enough sweeties' );
  5. @ftp_close( $ftph );
  6.  
  7. $hdir = '/home/' . get_current_user();
  8. $dir = $hdir . '/.ftp_enfocer/';
  9.  
  10. if( !is_dir( $hdir ) )
  11. die( 'Who knows' );
  12.  
  13. if( !is_dir( $dir ) )
  14. mkdir( $dir ) or die( 'Dir doesn\'t like you' );
  15.  
  16. $etime = time()+3600; // UNIX time
  17. @file_put_contents( $dir . 'allowed_ips', $etime . "\n" ) or die( 'File doesn\'t like you' );
  18.  
  19. print "Wibble, flobble";
  20. /*
  21. Could also do something like
  22. @file_put_contents( $dir . 'allowed_ips', $_ENV["REMOTE_ADDR"] . ",Magic comment!\n", FILE_APPEND ) or die( 'File doesn\'t like you' );
  23.  
  24. Or if you where a reseller;
  25. @file_put_contents( $dir . 'global_allowed_ips', $_ENV["REMOTE_ADDR"] . ",Magic comment!\n", FILE_APPEND ) or die( 'File doesn\'t like you' );
  26.  
  27. If I really didn't want to give the office a dyndns address and didn't have a static IP I could scrap ftp auth, stick a static token in then
  28. have a scheduled task do curl stuff from the cruddy win95 box in the corner to give all the staff access... or something.
  29. */
  30. } else {
  31. ?>
  32. <form action="#" method="POST">
  33. <p>FTP username: <input type="text" name="username" /></p>
  34. <p>FTP password: <input type="password" name="password" /></p>
  35. <input type="select" value="Give me an hour of access!" />
  36. </form>
  37. <?php
  38. }
  39. ?>
Add Comment
Please, Sign In to add comment