mirror of
https://github.com/Ekokumppanit/ystavakylaecard.git
synced 2026-02-17 21:48:32 +00:00
Initial commit, Ecard system build with CodeIgniter PHP framework
Currently working - Basic structure - Basic caching and gzip compression for speed - Admin authentication
This commit is contained in:
committed by
Ismo Vuorinen
parent
345d8ea65a
commit
c10c9e3131
10
application/controllers/index.html
Normal file
10
application/controllers/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
107
application/controllers/welcome.php
Normal file
107
application/controllers/welcome.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class Welcome extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ecard_model', 'ecard');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = array(
|
||||
'page_title' => array( 'Etusivu', 'Ystäväkylä eKortti' ),
|
||||
'page_classes' => array( 'frontpage' )
|
||||
);
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('welcome_message', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$data = array(
|
||||
'page_title' => array( 'Tietoa', 'Ystäväkylä eKortti' ),
|
||||
'page_classes' => array( 'info' )
|
||||
);
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('info', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
public function newCard()
|
||||
{
|
||||
|
||||
$data = array(
|
||||
'page_title' => array( 'Uusi eKortti', 'Ystäväkylä eKortti' ),
|
||||
'page_classes' => array( 'new_card' ),
|
||||
|
||||
'images' => array(
|
||||
"http://placekitten.com/800/550",
|
||||
"http://placekitten.com/g/800/550",
|
||||
"http://placekitten.com/800/551",
|
||||
"http://placekitten.com/g/800/551",
|
||||
"http://placekitten.com/800/552",
|
||||
"http://placekitten.com/g/800/552"
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('new', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
public function ecards($card_id = null)
|
||||
{
|
||||
$data = array(
|
||||
'page_classes' => array( 'ecards' )
|
||||
);
|
||||
|
||||
if (empty($card_id)) {
|
||||
$data['ecards'] = $this->ecard->get_all();
|
||||
$data['page_title'] = array( 'Listaa kaikki kortit', 'Ystäväkylä eKortti' );
|
||||
$data['page_classes'][] = 'show_all';
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('show_all', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
|
||||
} else {
|
||||
|
||||
if (strlen($card_id) != 32) {
|
||||
redirect("ecards");
|
||||
}
|
||||
|
||||
$data['ecard'] = $this->ecard->get_by('hash', $card_id);
|
||||
$data['page_title'] = array( 'eKortti', 'Ystäväkylä eKortti' );
|
||||
|
||||
if (empty($data['ecard'])) {
|
||||
$data['ecard'] = new stdClass();
|
||||
$data['ecard']->id = $card_id;
|
||||
$data['ecard']->response = "error";
|
||||
$data['ecard']->response_text = "No card found with that id";
|
||||
}
|
||||
|
||||
$data['page_classes'][] = 'show_one';
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('show_one', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
|
||||
}
|
||||
# code...
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
# code...
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
107
application/controllers/yllapito.php
Normal file
107
application/controllers/yllapito.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class Yllapito extends CI_Controller
|
||||
{
|
||||
private $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ecard_model', 'ecard');
|
||||
$this->load->model('erkanaauth_model', 'erkana');
|
||||
|
||||
$this->user = $this->erkana->getUser();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
redirect("/yllapito/kirjaudu");
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'page_title' => array( 'Etusivu', 'Ystäväkylä eKortti' ),
|
||||
'page_classes' => array( 'frontpage' ),
|
||||
'user' => $this->user,
|
||||
'messages' => $this->session->flashdata('messages')
|
||||
);
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('yllapito/dashboard', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
public function kirjaudu()
|
||||
{
|
||||
// POST
|
||||
$login = $this->input->post();
|
||||
if ($login) {
|
||||
$user = $this->input->post('username');
|
||||
$pass = $this->input->post('password');
|
||||
|
||||
// Hash the password
|
||||
$pass = $this->passwordhash($pass);
|
||||
|
||||
$test = array(
|
||||
'username' => $user,
|
||||
'password' => $pass // Hashed password
|
||||
);
|
||||
$this->erkana->try_login($test);
|
||||
|
||||
if (($user = $this->erkana->getUser())) {
|
||||
$this->db->update(
|
||||
'users',
|
||||
array(
|
||||
'last_login' => date("Y-m-d H:i:s")
|
||||
),
|
||||
"id = ". $user->id
|
||||
);
|
||||
redirect("yllapito");
|
||||
} else {
|
||||
$this->session->set_flashdata(
|
||||
'error',
|
||||
'Kirjautuminen epäonnistui'
|
||||
);
|
||||
redirect("yllapito/kirjaudu");
|
||||
}
|
||||
}
|
||||
|
||||
// GET
|
||||
if (! empty($this->user)) {
|
||||
redirect("yllapito");
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'page_title' => array( 'Kirjaudu', 'Ystäväkylä eKortti' ),
|
||||
'page_classes' => array( 'login' ),
|
||||
'user' => $this->user,
|
||||
'error' => $this->session->flashdata('error')
|
||||
);
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view('yllapito/login', $data);
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
|
||||
public function logout()
|
||||
{
|
||||
$this->erkana->logout();
|
||||
redirect("yllapito");
|
||||
}
|
||||
|
||||
public function makePassword($password = null)
|
||||
{
|
||||
echo $this->passwordhash($password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function passwordhash($password = null)
|
||||
{
|
||||
return hash(
|
||||
'ripemd160',
|
||||
$password . $this->config->item('encryption_key')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user