/** * Loads default home page. */ public function index($lang = 'ch') { if (!file_exists('application/views/' . $lang . '/index.php')) { // Whoops, we don't have a page for that! show_404(); } $this->load->model('video_model', 'video'); $data['video'] = $this->video->get_last_video(Access::isLoggedIn()); $this->load->library('javascript_plugins'); $plugins = $this->javascript_plugins; $footer_data['js_plugins'] = $plugins->generate(array($plugins::FlowPlayer)); $this->loadHeader($lang); $this->load->view($lang . '/index', $data); $this->load->view('templates/footer', $footer_data); }
public function audio($id = NULL) { if (!file_exists('application/views/ch/worship/audio.php')) { // Whoops, we don't have a page for that! show_404(); } $data['video'] = $this->video->get_video($id); // check privilege to see Paster Hou's message if ($data['video']['speaker'] == '侯君麗牧師' && !Access::isLoggedIn()) { show_404(); } $this->load->library('javascript_plugins'); $plugins = $this->javascript_plugins; $footer_data['js_plugins'] = $plugins->generate(array($plugins::FlowPlayer)); $this->load->view('templates/header_ch'); $this->load->view('ch/worship/audio', $data); $this->load->view('templates/footer', $footer_data); }
echo base_url(); ?> assets/js/jquery.js"></script> <script src="<?php echo base_url(); ?> assets/js/bootstrap.min.js"></script> </head> <body> <div class="top"> <div class="container"> <ul class="loginbar pull-right"> <?php if (Access::isLoggedIn()) { $user = $this->session->userdata('firstname'); $url = site_url() . '/auth/doLogout/ch'; printf("<li><a href=\"%s\">%s 注銷</a></li>", $url, $user); } else { $url = site_url() . '/auth/loginForm'; printf("<li><a href=\"%s\">登錄</a></li>", $url); } ?> <li class="devider"></li> <li><a href="<?php echo site_url(); ?> /pages/index/en">English</a> </li> </ul>
public function loginForm($lang = 'ch') { $this->loadResouces($lang); $data['lang'] = $lang; // logout the old user first if (Access::isLoggedIn()) { $this->session->sess_destroy(); } // setting validation rules $this->load->library('form_validation'); $this->load->library('validation_rules'); $rules = $this->validation_rules; $this->form_validation->set_rules($rules::$loginRules); $dispatchUrl; // form validation $refer_url = $this->session->userdata('refer_url'); if ($this->form_validation->run() == FALSE) { if (isset($_SERVER['HTTP_REFERER']) && empty($refer_url)) { $this->session->set_userdata(array('refer_url' => $_SERVER['HTTP_REFERER'])); } $dispatchUrl = 'auth/loginpage'; } else { $username = $this->input->post('username'); $password = $this->input->post('password'); $rows = $this->user_model->get_user($username); // no user if (count($rows) == 0) { $login_error = $this->lang->line('auth_no_user_error'); } else { $row = $rows[0]; $hash = hash('sha256', $row['salt'] . hash('sha256', $password)); if ($hash != $row['password']) { $login_error = $this->lang->line('auth_wrong_password_error'); } } if (empty($login_error)) { // save session data $newdata = array('logged_in' => TRUE, 'username' => $username, 'firstname' => $row['first_name'], 'role' => $row['role']); $this->session->set_userdata($newdata); // referer url cannot be loginForm itself if (!empty($refer_url)) { if (strpos($refer_url, site_url() . '/auth/loginForm') === 0) { $dispatchUrl = site_url(); } else { $dispatchUrl = $refer_url; } } else { $dispatchUrl = site_url(); } // redirect to previous page after login redirect($dispatchUrl, 'refresh'); die; } else { $_REQUEST['login_error'] = $login_error; $dispatchUrl = 'auth/loginpage'; } } $this->load->view('templates/header_' . $lang, $data); $this->load->view($dispatchUrl, $data); $this->load->view('templates/footer'); }