示例#1
0
 protected function write(array $record)
 {
     unset($record["formatted"]);
     $dttm = new \MongoDB\BSON\UTCDateTime($record['datetime']->getTimestamp() * 1000);
     $record['dttm'] = $dttm;
     $doc = new MongoDoc("log", $record);
     $doc->save();
 }
示例#2
0
 public function doPost($render, $params)
 {
     $userID = strtolower(filter_input(INPUT_POST, 'userid'));
     $password = filter_input(INPUT_POST, 'password');
     $error = null;
     $message = null;
     $user = Mongo::get()->findDoc("users", ["id" => $userID]);
     if ($user != null) {
         $error = 'User account already exists';
     } else {
         $user = new MongoDoc("users");
         $user->set("id", $userID);
         $user->set("name", $userID);
         $user->set("password", password_hash($password, PASSWORD_DEFAULT));
         $user->save();
         $message = "Account created!";
         $params['user_name'] = $userID;
         Session::getSession()->set("userID", $userID);
     }
     $params['errorCode'] = $error === null ? 'Success' : 'Error';
     $params['errorMessage'] = $error === null ? $message : $error;
     $render->render('error', $params);
 }