Advertisement
Guest User

Untitled

a guest
May 30th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. include('pini.php'); //includes Pini :)
  4.  
  5. //Example of how to use Pini in PHP
  6.  
  7. $ftp_server = "***"; //Server
  8. $ftp_user = "***"; //User
  9. $ftp_pass = "***"; //Pass
  10. $fextention = ".sav"; //File Extention
  11.  
  12. //Connecting with FTP
  13. $conn_id = ftp_connect($ftp_server);
  14. ftp_login($conn_id, $ftp_user, $ftp_pass);
  15.  
  16. if(!empty($_POST[submit])) //Checks if submit button has been pressed
  17. {
  18. $res = ftp_size($conn_id, 'scriptfiles/'.udb_encode($_POST[nick]).$fextention);
  19. if ($res != -1) //checks if file exists, you could use pini_Exists if the file would be on the same host
  20. {
  21. ftp_get($conn_id, udb_encode($_POST[nick]), 'scriptfiles/'.udb_encode($_POST[nick]).$fextention, FTP_BINARY); //saves the file
  22. echo 'You are viewing stats of '.$_POST[nick].'<br />';
  23. echo 'Player has $'.pini_Get(udb_encode($_POST[nick]), "Money").' dollars!'; //reads the ammount of money
  24. unlink(udb_encode($_POST[nick])); //deletes the file
  25. }
  26. else //if file does not exist, this message shows up :)
  27. {
  28. echo 'User '.$_POST[nick].' is not registered!';
  29. }
  30. }
  31. else //if submit button has not been pressed
  32. {
  33. echo '<form action="'.basename($_SERVER['SCRIPT_FILENAME']).'" method="post">Enter player\'s nickname: <input type="text" name="nick"><br /><input type="submit"
  34.  
  35. value="Submit" name="submit"></form>';
  36. }
  37.  
  38. ftp_close($conn_id); //closes the connection
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement