Advertisement
rotrevrep

drapeaux.php

Sep 5th, 2018
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_GET["hash"])) {
  4.     $hash = $_GET["hash"];
  5.     if (file_exists ("data.json"))
  6.         $json = file_get_contents ("data.json");
  7.     else
  8.         $json = "{}";
  9.    
  10.     $obj = json_decode ($json);
  11.     if ($obj == null)
  12.         $obj = json_decode ("{}");
  13.     if (isset($obj->{$hash}))
  14.         echo $obj->{$hash};
  15.     else
  16.         echo "e30="; // => "{}"
  17.     return;
  18. }
  19.  
  20. if (!isset($_POST["json"]) || !isset($_POST["hash"])) {
  21.     echo "-1";
  22.     return;
  23. }
  24.  
  25. $data = $_POST["json"];
  26. $hash = $_POST["hash"];
  27.  
  28. if (file_exists ("data.json"))
  29.     $json = file_get_contents ("data.json");
  30. else
  31.     $json = "{}";
  32.  
  33. $obj = json_decode ($json);
  34. if ($obj == null)
  35.     $obj = json_decode ("{}");
  36. $obj->{$hash} = $data;
  37. file_put_contents ("data.json", json_encode ($obj));
  38. echo "0";
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement