user_file.php 523 B

123456789101112131415161718192021222324252627
  1. <?php
  2. include("../public/config.php");
  3. $USER_ID = "";
  4. if(isset($_COOKIE["username"]) && !empty($_COOKIE["username"])){
  5. $USER_ID = $_COOKIE["userid"];
  6. }
  7. if($USER_ID!=""){
  8. $user_path=$dir_user_base.$USER_ID."/";
  9. $filename=$user_path.$_POST["filename"];
  10. switch($_POST["op"]){
  11. case "save":
  12. $data=$_POST["data"];
  13. //save data file
  14. echo file_put_contents($filename,$data);
  15. echo("Successful");
  16. break;
  17. case "read":
  18. echo file_get_contents($filename);
  19. break;
  20. }
  21. }
  22. else{
  23. echo("user id is vailed");
  24. }
  25. ?>