diff --git a/get.py b/get.py index 62af317..675771a 100644 --- a/get.py +++ b/get.py @@ -2,25 +2,25 @@ import sys import requests filename = sys.argv[1] -password = str(raw_input("Enter the password for the file")) -if (password == ""): - password = "null" -r = requests.post("http://sharecode.co.nf/getcode.php?filename="+filename+"&password="+password+"&getname=true") -localname = r.text -r = requests.post("http://sharecode.co.nf/getcode.php?filename="+filename+"&password="+password) -if (r.text == "False"): +file_password = str(raw_input("Enter the password for the file")) +if (file_password == ""): + file_password = "null" +req = requests.post("http://sharecode.co.nf/getcode.php?filename="+filename+"&password="+file_password+"&getname=true") +local_filename = req.text +req = requests.post("http://sharecode.co.nf/getcode.php?filename="+filename+"&password="+file_password) +if (req.text == "False"): print "Wrong combination of filename and password" exit(0) flag = True for i in os.listdir(os.getcwd()): - if (i == localname): - print "A file with the name " + localname + " already exists" - newname = str(raw_input("Enter new file name ")) - if (newname != ""): - localname = newname + if (i == local_filename): + print "A file with the name " + local_filename + " already exists" + new_local_filename = str(raw_input("Enter new file name ")) + if (new_local_filename != ""): + local_filename = new_local_filename break -file = open(localname,'w+') -file.write(r.text) +file = open(local_filename,'w+') +file.write(req.text) file.close() diff --git a/getcode.php b/getcode.php index 533dfe8..48e69c2 100644 --- a/getcode.php +++ b/getcode.php @@ -1,18 +1,18 @@