- fixes missing () from num_rows in authenticate user function - removes passwordhash library in favor of built in PHP password_hash and password_verify functions - uppercase all class filenames - add new CLI error templates, move HTML error templates - update mimes file to latest version - update routes to latest version
		
			
				
	
	
		
			90 行
		
	
	
		
			无行尾
		
	
	
		
			2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			90 行
		
	
	
		
			无行尾
		
	
	
		
			2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 | |
| 
 | |
| class Notes extends CI_Controller {
 | |
| 
 | |
| 	/* Displays all notes in a list */
 | |
| 	public function index()
 | |
| 	{
 | |
| 		$this->load->model('note');
 | |
| 		$data['notes'] = $this->note->list_all();
 | |
| 		$data['page_title'] = "Notes";
 | |
| 		$this->load->view('layout/header', $data);
 | |
| 		$this->load->view('notes/main');
 | |
| 		$this->load->view('layout/footer');
 | |
| 	}
 | |
| 	
 | |
| 	/* Provides function for adding notes to the system. */
 | |
| 	function add() {
 | |
| 	
 | |
| 		$this->load->model('note');
 | |
| 	
 | |
| 		$this->load->library('form_validation');
 | |
| 
 | |
| 		$this->form_validation->set_rules('title', 'Note Title', 'required');
 | |
| 		$this->form_validation->set_rules('content', 'Content', 'required');
 | |
| 
 | |
| 
 | |
| 		if ($this->form_validation->run() == FALSE)
 | |
| 		{
 | |
| 			$data['page_title'] = "Add Notes";
 | |
| 			$this->load->view('layout/header', $data);
 | |
| 			$this->load->view('notes/add');
 | |
| 			$this->load->view('layout/footer');
 | |
| 		}
 | |
| 		else
 | |
| 		{	
 | |
| 			$this->note->add();
 | |
| 			
 | |
| 			redirect('notes');
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	/* View Notes */
 | |
| 	function view($id) {
 | |
| 		$this->load->model('note');
 | |
| 		
 | |
| 		$data['note'] = $this->note->view($id);
 | |
| 		
 | |
| 		// Display
 | |
| 		$data['page_title'] = "Note";
 | |
| 		$this->load->view('layout/header', $data);
 | |
| 		$this->load->view('notes/view');
 | |
| 		$this->load->view('layout/footer');
 | |
| 	}
 | |
| 	
 | |
| 	/* Edit Notes */
 | |
| 	function edit($id) {
 | |
| 		$this->load->model('note');
 | |
| 		$data['id'] = $id;
 | |
| 		
 | |
| 		$data['note'] = $this->note->view($id);
 | |
| 			
 | |
| 		$this->load->library('form_validation');
 | |
| 
 | |
| 		$this->form_validation->set_rules('title', 'Note Title', 'required');
 | |
| 		$this->form_validation->set_rules('content', 'Content', 'required');
 | |
| 
 | |
| 
 | |
| 		if ($this->form_validation->run() == FALSE)
 | |
| 		{
 | |
| 			$data['page_title'] = "Edit Note";
 | |
| 			$this->load->view('layout/header', $data);
 | |
| 			$this->load->view('notes/edit');
 | |
| 			$this->load->view('layout/footer');
 | |
| 		}
 | |
| 		else
 | |
| 		{
 | |
| 			$this->note->edit();
 | |
| 			
 | |
| 			redirect('notes');
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	/* Delete Note */
 | |
| 	function delete($id) {
 | |
| 		$this->load->model('note');
 | |
| 		$this->note->delete($id);
 | |
| 		
 | |
| 		redirect('notes');
 | |
| 	}
 | |
| } |