Adding more comunication skills
[mnenc] / mnencd.hpp
index 379f7f9..50065c8 100644 (file)
@@ -21,6 +21,9 @@
 #include <string>
 #include <iostream>
 #include <fstream>
+#include "php.hpp"
+#include <vector>
+std::string masterpasswd = "";
 
 std::string remove_char(std::string str, char c) {
        std::string::size_type k = 0;
@@ -60,8 +63,17 @@ void put_password(std::string masterpasswd, std::string passwd, std::string user
 }
 
 std::string do_something(std::string str) {
-       if(str[0] == '0')       {
-               return "201_Created\n";
+       std::vector<std::string> request;
+       request = explode(str, "|");
+       if(request[0][0] == '0') {
+               if(masterpasswd == "")  {
+                       masterpasswd = request[1];
+                       return "201_Created\n";
+               } else if(masterpasswd!= "") {
+                       return "403 Forbidden\n";
+               } else {
+                       return "400_Bad_Request " + str + '\n';
+               }
        } else {
                return "400_Bad_Request " + str + '\n';
        }