Update README.md


Strona stworzona według wzorca MVC odstępna: http://wzaleski.x25.pl/cv



Tworzenie routing i obsługa nie odnalezionych stron (404):

	
    	function __construct()
    	{
    		$url = isset($_GET['url']) ? $_GET['url'] : null;
    		$url = rtrim($url, '/');
    		$url = explode('/', $url);
    
    		//print_r($url);
    
    		if (empty($url[0])) {
    			require 'controllers/index.php';
    			$controller = new Index();
    			$controller->index();
    			return false;
    		}
    
    		$file = 'controllers/' . $url[0] . '.php';
    		if (file_exists($file)) {
    			require $file;
    			$controller = new $url[0];
    			$controller->loadModel($url[0]);
    			$controller->index();
    
    		} else {
    			$this->error();
    			exit;
    		}
    
    		// methods checking
    		if (isset($url[2])) {
    			if (method_exists($controller, $url[1])) {
    				$controller->{$url[1]}($url[2]);
    
    			} else {
    				$this->error($noTemplate = true);
    				return false;
    			}
    
    		} else {
    			if (isset($url[1]))
    			{
    				if (method_exists($controller, $url[1])) {
    				$controller->{$url[1]}();
    				
    				} else {
    					$this->error($noTemplate = true);
    					return false;
    				}
    			}
    		}
    	}
    	
    	function error($noTemplate = false)
    	{
    		require 'controllers/error.php';
    		$controller = new Error();
    		$controller->index($noTemplate);
    		return false;
    	}

Logowanie:

      public function run()
      	{
      		/*CLEAN DATA 
      		$login 	= $_POST['login'];
      		$password = $_POST['password'];
      		*/
      		if (isset($_POST['login'], $_POST['password'])){
      			$login 	= filter_input(INPUT_POST, 'login', FILTER_SANITIZE_STRING);
      			$password = md5(filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING));
      			
      			//Check size of hash (MD5 should be 32 char)
      			if (strlen($password) != 32) {
      				require 'controllers/error.php';
      				$controller = new Error();
      				$controller->index($noTemplate = true, $erMsg = 'Invalid password');
      				exit;
      			}
      		}
      
      		$result = pg_query("SELECT id FROM users WHERE 
      			login = '$login' AND password = '$password'");
      		while  ($row = pg_fetch_array($result)) {
      			//print_r($row);
      		}
      
      		$count = pg_num_rows($result);
      		if (!$count) {
      			header('location: '.URL. 'login');
      			
      		} else {
      			//Password is correct and match user
      			Session::set('loggedIn', true);
      			header('location: '.URL. 'dashboard');
      		}
      
      	}