G2A Many GEOs
SHARE
TWEET

ulddld.php

kssr3951 May 1st, 2018 (edited) 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // ulddld.php
  3. // uldとdldで使用するサーバープログラム。データフォルダは手動で作成。
  4. // 「uld」-> https://pastebin.com/KsMM0Fjt
  5. // 「dld」-> https://pastebin.com/zNZECshU
  6. define("PASSWORD", "xxxxxx");
  7. define("DATA_FOLDER", "ulddld/");
  8. define("NAME_FILE_NAME", DATA_FOLDER . "the_file_name.txt");
  9. define("DATA_FILE_NAME", DATA_FOLDER . "the_file_data.txt");
  10. function execute() {
  11.     if (false == isset($_POST["command"])) {
  12.         echo "NG\n";
  13.         echo "Error No.1\n";
  14.         return;
  15.     }
  16.     $command = $_POST["command"];
  17.     if (false == isset($_POST["password"])) {
  18.         echo "NG\n";
  19.         echo "Error No.2\n";
  20.         return;
  21.     }
  22.     $password = $_POST["password"];
  23.     if (PASSWORD !== $password) {
  24.         echo "NG\n";
  25.         echo "Error No.3\n";
  26.         return;
  27.     }
  28.     switch ($command) {
  29.         case "uld":
  30.             doUld();
  31.             break;
  32.         case "dld":
  33.             doDld();
  34.             break;
  35.     }
  36. }
  37. function doUld() {
  38.     if(!(isset($_POST["fileName"]) &&
  39.          isset($_POST["fileData"]))) {
  40.         echo "NG\n";
  41.         echo "Error No.4\n";
  42.     } else {
  43.         $fileName = $_POST["fileName"];
  44.         file_put_contents(NAME_FILE_NAME, $fileName);
  45.         $fileData = $_POST["fileData"];
  46.         file_put_contents(DATA_FILE_NAME, $fileData);
  47.         echo "OK\n";
  48.     }
  49. }
  50. function doDld() {
  51.     if (false) {
  52.         echo "NG\n";
  53.         echo "Error No.5\n";
  54.     } else {
  55.         $fileName = file_get_contents(NAME_FILE_NAME);
  56.         $fileData = file_get_contents(DATA_FILE_NAME);
  57.         echo "OK\n";
  58.         echo $fileName . "\n";
  59.         echo $fileData;
  60.     }
  61. }
  62. execute();
  63. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top