Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ulddld.php
- // uldとdldで使用するサーバープログラム。データフォルダは手動で作成。
- // 「uld」-> https://pastebin.com/KsMM0Fjt
- // 「dld」-> https://pastebin.com/zNZECshU
- define("PASSWORD", "xxxxxx");
- define("DATA_FOLDER", "ulddld/");
- define("NAME_FILE_NAME", DATA_FOLDER . "the_file_name.txt");
- define("DATA_FILE_NAME", DATA_FOLDER . "the_file_data.txt");
- function execute() {
- if (false == isset($_POST["command"])) {
- echo "NG\n";
- echo "Error No.1\n";
- return;
- }
- $command = $_POST["command"];
- if (false == isset($_POST["password"])) {
- echo "NG\n";
- echo "Error No.2\n";
- return;
- }
- $password = $_POST["password"];
- if (PASSWORD !== $password) {
- echo "NG\n";
- echo "Error No.3\n";
- return;
- }
- switch ($command) {
- case "uld":
- doUld();
- break;
- case "dld":
- doDld();
- break;
- }
- }
- function doUld() {
- if(!(isset($_POST["fileName"]) &&
- isset($_POST["fileData"]))) {
- echo "NG\n";
- echo "Error No.4\n";
- } else {
- $fileName = $_POST["fileName"];
- file_put_contents(NAME_FILE_NAME, $fileName);
- $fileData = $_POST["fileData"];
- file_put_contents(DATA_FILE_NAME, $fileData);
- echo "OK\n";
- }
- }
- function doDld() {
- if (false) {
- echo "NG\n";
- echo "Error No.5\n";
- } else {
- $fileName = file_get_contents(NAME_FILE_NAME);
- $fileData = file_get_contents(DATA_FILE_NAME);
- echo "OK\n";
- echo $fileName . "\n";
- echo $fileData;
- }
- }
- execute();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement