diff --git a/BaseController.php b/BaseController.php new file mode 100644 index 0000000..99f0bdc --- /dev/null +++ b/BaseController.php @@ -0,0 +1,53 @@ +session = \Config\Services::session(); + $this->validation = \Config\Services::validation(); + } +} diff --git a/Login.php b/Login.php new file mode 100644 index 0000000..29a23ab --- /dev/null +++ b/Login.php @@ -0,0 +1,37 @@ +MitgliederModel = new MitgliederModel(); + } + + public function index() + { + helper('form'); + + + if (isset($_POST['username']) and isset($_POST['password']) and $this->validation->run($_POST, 'login') === true) { + $known_login = $this->MitgliederModel->login(); + + if (($known_login != NULL) && (password_verify($_POST['password'], $known_login['password']))) { + session()->set('logged_in', true); + session()->set('username', $_POST['username']); + return redirect()->to(base_url('/Projekte')); + } + } else { + $data['error'] = $this->validation->getErrors(); + } + + echo view('templates/header'); + echo view('login', $data); + echo view('templates/footer'); + } +} diff --git a/Mitglieder.php b/Mitglieder.php new file mode 100644 index 0000000..1af6787 --- /dev/null +++ b/Mitglieder.php @@ -0,0 +1,131 @@ +
+
Aufgabenplaner: Mitglieder
+ + + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + +
UsernameE-MailIm Projekt:
+
+ + + +
+
+ + + +
+ + "> +
+
+ + "> +
+
+ + "> +
+ get("username") == $data['item']['username'])): ?> +
+ + +
+ +
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+ + + + + + + +
+
+
+
\ No newline at end of file diff --git a/MitgliederModel.php b/MitgliederModel.php new file mode 100644 index 0000000..1423494 --- /dev/null +++ b/MitgliederModel.php @@ -0,0 +1,84 @@ +db->table('members'); + $members->select('*'); + + if ($member_id != NULL) + $members->where('id', $member_id); + + $members->orderBy('id'); + $result = $members->get(); + + if ($member_id != NULL) + return $result->getRowArray(); + else + return $result->getResultArray(); + } + + public function createMember() + { + $hashed_password = password_hash($_POST['password'], PASSWORD_DEFAULT); + + $data = array( + 'username' => $_POST['username'], + 'email' => $_POST['email'], + 'password' => $hashed_password, + 'firstname' => $_POST['firstname'], + 'lastname' => $_POST['lastname'], + 'street' => $_POST['street'], + 'zip' => $_POST['zip'], + 'city' => $_POST['city'], + ); + + $members = $this->db->table('members'); + $members->insert($data); + } + + public function updateMember() + { + $data = array( + // TODO: should we be able to edit username? + // 'username' => $_POST['username'], + 'email' => $_POST['email'], + 'firstname' => $_POST['firstname'], + 'lastname' => $_POST['lastname'], + 'street' => $_POST['street'], + 'zip' => $_POST['zip'], + 'city' => $_POST['city'], + ); + if ((isset($_POST['password'])) && ($_POST['password'] !== '')) { + $hashed_password = password_hash($_POST['password'], PASSWORD_DEFAULT); + $data['password'] = $hashed_password; + } + $members = $this->db->table('members'); + $members->where('id', $_POST['id']); + $members->update($data); + } + + public function login() + { + $members = $this->db->table('members'); + $members->select('password'); + $members->where('username', $_POST['username']); + $result = $members->get(); + + return $result->getRowArray(); + } + + public function deleteMember($member_id) + { + $members = $this->db->table('members'); + $members->where('id', $member_id); + $members->delete(); + } + + +} diff --git a/Projekte.php b/Projekte.php new file mode 100644 index 0000000..1f58359 --- /dev/null +++ b/Projekte.php @@ -0,0 +1,49 @@ +
+
Aufgabenplaner: Projekte
+
+
+ +
+ +
+
+
+

Projekt auswählen:

+ +
+ + + +
+
+
+
+

Projekt bearbeiten/erstellen

+
+ + +
+
+ + +
+
+ + + +
+
+
+
+
\ No newline at end of file diff --git a/ProjekteModel.php b/ProjekteModel.php new file mode 100644 index 0000000..0e62138 --- /dev/null +++ b/ProjekteModel.php @@ -0,0 +1,18 @@ + $id, + 'description' => $description + ); + $this->db->insert('projects', $data); + } + public function updateProject($id, $description) { + $data = array( + 'name' => $id, + 'description' => $description + ); + $this->db->where('name', $id); + $this->db->update('projects', $data); + } +} \ No newline at end of file diff --git a/Routes.php b/Routes.php new file mode 100644 index 0000000..7bbcc1a --- /dev/null +++ b/Routes.php @@ -0,0 +1,68 @@ +setDefaultNamespace('App\Controllers'); +$routes->setDefaultController('Login'); +$routes->setDefaultMethod('index'); +$routes->setTranslateURIDashes(false); +$routes->set404Override(); +// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps +// where controller filters or CSRF protection are bypassed. +// If you don't want to define all routes, please use the Auto Routing (Improved). +// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true. +// $routes->setAutoRoute(false); + +/* + * -------------------------------------------------------------------- + * Route Definitions + * -------------------------------------------------------------------- + */ + +// We get a performance increase by specifying the default +// route since we don't have to scan directories. +$routes->get('/', 'Login::index'); +$routes->get('/Login', 'Login::index'); +$routes->post('/Login', 'Login::index'); +$routes->get('/Aufgaben', 'Aufgaben::index'); +$routes->get('/Mitglieder', 'Mitglieder::index'); +$routes->get('/Mitglieder/edit/(:num)', 'Mitglieder::edit/$1'); +$routes->post('/Mitglieder/update', 'Mitglieder::update'); +$routes->post('/Mitglieder/create', 'Mitglieder::createMember'); +$routes->get('/Projekte/create', 'Projekte::create'); +$routes->post('/Projekte/create', 'Projekte::create'); +$routes->get('/Mitglieder/delete/(:num)', 'Mitglieder::deleteMember/$1'); // FIXME: dirty! don't GET! +$routes->get('/Reiter', 'Reiter::index'); +$routes->get('/Todos', 'Todos::index'); +$routes->get('/Projekte', 'Projekte::index'); + +/* + * -------------------------------------------------------------------- + * Additional Routing + * -------------------------------------------------------------------- + * + * There will often be times that you need additional routing and you + * need it to be able to override any defaults in this file. Environment + * based routes is one such time. require() additional route files here + * to make that happen. + * + * You will have access to the $routes object within that file without + * needing to reload it. + */ +if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { + require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; +} diff --git a/Validation.php b/Validation.php new file mode 100644 index 0000000..29d71ba --- /dev/null +++ b/Validation.php @@ -0,0 +1,50 @@ + + */ + public $templates = [ + 'list' => 'CodeIgniter\Validation\Views\list', + 'single' => 'CodeIgniter\Validation\Views\single', + ]; + + // -------------------------------------------------------------------- + // Rules + // -------------------------------------------------------------------- + public $login = [ + 'username' => 'required', + 'password' => 'required', + 'AGB' => 'required' + ]; + +} diff --git a/login.php b/login.php new file mode 100644 index 0000000..e91b734 --- /dev/null +++ b/login.php @@ -0,0 +1,37 @@ +
+
+
+ 'form')) ?> + Login +
+
+ + +
+ +
+
+
+ + +
+ +
+
+ +
+
+ + +
+ +
+
+ +

Noch nicht registriert? Registrierung

+
+
+
\ No newline at end of file