Exemple #1
0
 public function saveInformation($userid)
 {
     //Writes JSON to file so we can load it later.
     $facepunch = new facepunch();
     $facepunch->setUserID($userid);
     //Opens/Creates a new file.
     $file = fopen($this->filepath["json"] . $userid . '.json', 'w');
     //Write information.
     if ($facepunch->getUserInformation(true)) {
         //Write the information too file.
         fwrite($file, $facepunch->getUserInformation(true));
     } else {
         return false;
     }
     //Close the file.
     fclose($file);
     //Return true
     return true;
 }
Exemple #2
0
                 }
             }
         }
     }
     die(json_encode($response));
 }
 if ($_POST["action"] == "getmyinformation") {
     $response = array();
     $response["error"] = "false";
     if (!$_POST["sessionid"]) {
         $response["error"] = "no session id";
     } else {
         if (!$session->activeSession($_POST["sessionid"])) {
             $response["error"] = "session id is invalid!";
         } else {
             $facepunch = new facepunch();
             $facepunch->setUserID($session->sessionToUserID($_POST["sessionid"]));
             if (!$facepunch->isUserValid()) {
                 $response["error"] = "user is invalid";
                 unset($facepunch);
             } else {
                 $account->setPaths('../json/facepunch/', '../../images/facepunch/avatars/');
                 if (!$account->hasInformation($facepunch->currentUserID())) {
                     $account->checkInformation($facepunch->currentUserID());
                 }
                 $response["information"] = $account->getInformation($facepunch->currentUserID(), false);
             }
         }
     }
     die(json_encode($response));
 }
Exemple #3
0
 public function setCookies()
 {
     $facepunch = new facepunch();
     $facepunch->setUserID($this->sessionToUserID(session_id()));
     //Set cookies
     setcookie("fpusername", $facepunch->getUsername());
     setcookie("fpid", $facepunch->currentUserID());
     unset($facepunch);
 }