function __construct() { parent::__construct("../../model/events.json"); $this->userController = UserController::getInstance(); }
<?php if (!isset($_SESSION)) { session_start(); } require_once "../../UserController.php"; $userController = UserController::getInstance(); $firstName = $_SESSION["brukernavn"]; $image = $_POST["profilbilde"]; $farge = $_POST["farge"]; $error = false; if ($farge == "" and $image != "") { //lagre bilde $success = file_put_contents("../resources/images/users/" . $firstName, $image); } if ($image == "" and $farge != "") { //lagre farge $success = $userController->setUserColor($firstName, $farge); $_SESSION["farge"] = $farge; } if ($farge != "" and $image != "") { //lagre bilde og farge $success = file_put_contents("../resources/images/users/" . $firstName, $image); $success = $userController->setUserColor($firstName, $farge); $_SESSION["farge"] = $farge; } echo $success;
} if ( $this->user->login( $connection ) ) { $this->session = SessionController::getInstance(); $this->session->setMessage( "Welcome back {$this->user->username}"); $this->session->setupAuthorizedSession( $this->user ); } else { echo "not logged in"; print_r( $this->user); } } } if(!isset($application)){ $application = ApplicationController::getInstance(); } $userProcessor = UserController::getInstance(); $message = $_REQUEST[ 'message']; switch( $message ) { case 'registration': $userProcessor->registration( $application->getDatabaseConnection() ); break; case 'login': $userProcessor->login( $application->getDatabaseConnection() ); break; default: break; } ?>