示例#1
0
 public function _remap($method)
 {
     if (!$this->config->item('allow_forgotten_password', 'fuel')) {
         show_404();
     }
     $this->load->library('session');
     $this->load->helper('string');
     $this->load->module_model(FUEL_FOLDER, 'fuel_users_model');
     $this->load->module_language(FUEL_FOLDER, 'fuel');
     $email = fuel_uri_segment(2);
     $reset_key = fuel_uri_segment(3);
     $user = $this->fuel_users_model->find_one('MD5(email) = "' . $email . '" AND MD5(reset_key) = "' . $reset_key . '"');
     if (isset($user->id)) {
         $new_pwd = random_string('alnum', 8);
         $user->password = $new_pwd;
         $user->reset_key = '';
         if ($user->save()) {
             $params['to'] = $user->email;
             $params['subject'] = lang('pwd_reset_subject_success');
             $params['message'] = lang('pwd_reset_email_success', $new_pwd);
             $params['use_dev_mode'] = FALSE;
             if ($this->fuel->notification->send($params)) {
                 $this->session->set_flashdata('success', lang('pwd_reset_success'));
                 $this->fuel->logs->write(lang('auth_log_pass_reset', $user->user_name, $this->input->ip_address()), 'debug');
             } else {
                 $this->session->set_flashdata('error', $this->email->print_debugger());
             }
         } else {
             $this->session->set_flashdata('error', lang('error_pwd_reset'));
         }
     } else {
         $this->session->set_flashdata('error', lang('error_pwd_reset'));
     }
     redirect(fuel_url('login'));
 }
示例#2
0
 public function __construct()
 {
     parent::__construct(FALSE);
     // allow the select URL page to show up regardless of permissions
     $validate = fuel_uri_segment(2) == 'select' ? FALSE : TRUE;
     if ($validate) {
         $this->_validate_user($this->permission);
     }
     $this->load->module_model(FUEL_FOLDER, 'fuel_pagevariables_model');
 }
示例#3
0
 public function __construct()
 {
     parent::__construct(FALSE);
     // allow the select URL page to show up regardless of permissions
     $validate = fuel_uri_segment(2) == 'select' ? FALSE : TRUE;
     if ($validate) {
         $load_vars['user'] = $this->fuel->auth->user_data();
         $load_vars['session_key'] = $this->fuel->auth->get_session_namespace();
         $this->load->vars($load_vars);
         $this->_validate_user($this->permission);
     }
     $this->load->module_model(FUEL_FOLDER, 'fuel_pagevariables_model');
 }
示例#4
0
 function _remap($method)
 {
     if (!$this->config->item('allow_forgotten_password', 'fuel')) {
         show_404();
     }
     $this->load->library('session');
     $this->load->helper('string');
     $this->load->module_model(FUEL_FOLDER, 'users_model');
     $this->load->module_language(FUEL_FOLDER, 'fuel');
     $email = fuel_uri_segment(2);
     $reset_key = fuel_uri_segment(3);
     $user = $this->users_model->find_one('MD5(email) = "' . $email . '" AND MD5(reset_key) = "' . $reset_key . '"');
     if (isset($user->id)) {
         $new_pwd = random_string('alnum', 8);
         $user->password = $new_pwd;
         $user->reset_key = '';
         if ($user->save()) {
             $this->load->library('email');
             $config['wordwrap'] = TRUE;
             $this->email->initialize($config);
             $this->email->from($this->config->item('from_email', 'fuel'), $this->config->item('site_name', 'fuel'));
             $this->email->to($user->email);
             $this->email->subject(lang('pwd_reset_subject_success'));
             $msg = lang('pwd_reset_email_success', $new_pwd);
             $this->email->message($msg);
             if ($this->email->send()) {
                 $this->session->set_flashdata('success', lang('pwd_reset_success'));
             } else {
                 $this->session->set_flashdata('error', $this->email->print_debugger());
             }
         } else {
             exit('yo3');
             $this->session->set_flashdata('error', lang('error_pwd_reset'));
         }
     } else {
         $this->session->set_flashdata('error', lang('error_pwd_reset'));
     }
     redirect(fuel_url('login'));
 }
示例#5
0
 function activity()
 {
     $this->_validate_user('manage/activity');
     $this->load->module_model(FUEL_FOLDER, 'logs_model');
     $this->load->library('pagination');
     $this->load->library('data_table');
     $this->load->helper('convert');
     $this->nav_selected = 'manage/activity';
     $page_state = $this->_get_page_state();
     /* PROCESS PARAMS BEGIN */
     $filters = array();
     $defaults = array();
     $defaults['col'] = 'entry_date';
     $defaults['order'] = 'asc';
     $defaults['offset'] = 0;
     $defaults['limit'] = 25;
     $defaults['search_term'] = '';
     $defaults['precedence'] = NULL;
     $uri_params = uri_safe_batch_decode(fuel_uri_segment(4), '|', TRUE);
     $uri_params = array();
     if (fuel_uri_segment(4)) {
         $uri_params['offset'] = (int) fuel_uri_segment(4);
     }
     $posted = array();
     if (!empty($_POST)) {
         if ($this->input->post('col')) {
             $posted['col'] = $this->input->post('col');
         }
         if ($this->input->post('order')) {
             $posted['order'] = $this->input->post('order');
         }
         if ($this->input->post('limit')) {
             $posted['limit'] = $this->input->post('limit');
         }
         if ($this->input->post('limit')) {
             $posted['offset'] = (int) $this->input->post('offset');
         }
         $posted['search_term'] = $this->input->post('search_term');
     }
     //$params = array_merge($defaults, $uri_params, $posted);
     $params = array_merge($defaults, $page_state, $uri_params, $posted);
     if ($params['search_term'] == lang('label_search')) {
         $params['search_term'] = NULL;
     }
     /* PROCESS PARAMS END */
     $seg_params = $params;
     unset($seg_params['offset']);
     $seg_params = uri_safe_batch_encode($seg_params, '|', TRUE);
     // if (!is_ajax() AND !empty($_POST))
     // {
     // 	$uri = fuel_url('manage/activity/offset/'.$params['offset']);
     // 	redirect($uri);
     // }
     $filters['first_name'] = $params['search_term'];
     $filters['last_name'] = $params['search_term'];
     $filters['message'] = $params['search_term'];
     $filters['entry_date'] = $params['search_term'];
     $this->logs_model->add_filters($filters);
     // pagination
     $config['base_url'] = fuel_url('manage/activity/offset/');
     $config['total_rows'] = $this->logs_model->list_items_total();
     $config['uri_segment'] = fuel_uri_index(4);
     $config['per_page'] = $params['limit'];
     $config['page_query_string'] = FALSE;
     $config['num_links'] = 5;
     $config['prev_link'] = lang('pagination_prev_page');
     $config['next_link'] = lang('pagination_next_page');
     $config['first_link'] = lang('pagination_first_link');
     $config['last_link'] = lang('pagination_last_link');
     $this->pagination->initialize($config);
     $this->_save_page_state($params);
     // data table
     $vars['params'] = $params;
     $vars['table'] = '';
     if (is_ajax()) {
         $items = $this->logs_model->list_items($params['limit'], $params['offset'], $params['col'], $params['order']);
         $this->data_table->row_alt_class = 'alt';
         $this->data_table->id = 'activity_data_table';
         // change this so that it doesn't have clickable rows'
         $this->data_table->only_data_cols = array('id');
         $this->data_table->set_sorting($params['col'], $params['order']);
         $this->data_table->auto_sort = TRUE;
         $this->data_table->sort_js_func = 'page.sortList';
         $headers = array('entry_date' => lang('form_label_entry_date'), 'name' => lang('form_label_name'), 'message' => lang('form_label_message'));
         $this->data_table->assign_data($items, $headers);
         $vars['table'] = $this->data_table->render();
         $this->load->view('_blocks/module_list_table', $vars);
         return;
     } else {
         $this->load->library('form_builder');
         $this->js_controller_params['method'] = 'activity';
         $vars['table'] = $this->load->view('_blocks/module_list_table', $vars, TRUE);
         $vars['pagination'] = $this->pagination->create_links();
         // for extra module filters
         $field_values = array();
         $this->_render('manage/activity', $vars);
     }
 }
示例#6
0
 protected function _list_process()
 {
     $this->load->library('pagination');
     $this->load->helper('convert');
     $this->load->helper('cookie');
     /* PROCESS PARAMS BEGIN */
     $filters = array();
     $page_state = $this->_get_page_state();
     $defaults = array();
     $defaults['col'] = !empty($this->default_col) ? $this->default_col : $this->display_field;
     $defaults['order'] = !empty($this->default_order) ? $this->default_order : NULL;
     $defaults['offset'] = 0;
     $defaults['limit'] = 25;
     $defaults['search_term'] = '';
     $defaults['view_type'] = 'list';
     $defaults['extra_filters'] = array();
     // custom module filters defaults
     foreach ($this->filters as $key => $val) {
         $defaults[$key] = isset($val['default']) ? $val['default'] : NULL;
     }
     $uri_params = uri_safe_batch_decode(fuel_uri_segment(4), '|', TRUE);
     $uri_params['offset'] = fuel_uri_segment(4) ? (int) fuel_uri_segment(4) : 0;
     $posted = array();
     if (!empty($_POST)) {
         $posted['search_term'] = $this->input->post('search_term');
         $posted_vars = array('col', 'order', 'limit', 'offset', 'view_type');
         foreach ($posted_vars as $val) {
             if ($this->input->post($val)) {
                 $posted[$val] = $this->input->post($val);
             }
         }
         // custom module filters
         $extra_filters = array();
         foreach ($this->filters as $key => $val) {
             if (isset($_POST[$key])) {
                 $posted[$key] = $this->input->post($key);
                 $this->filters[$key]['value'] = $this->input->post($key);
                 $extra_filters[$key] = $this->input->post($key);
             }
         }
         $posted['extra_filters'] = $extra_filters;
     }
     $params = array_merge($defaults, $page_state, $uri_params, $posted);
     if ($params['search_term'] == 'Search') {
         $params['search_term'] = null;
     }
     /* PROCESS PARAMS END */
     return $params;
 }
示例#7
0
 function dev()
 {
     $this->config->set_item('allow_forgotten_password', FALSE);
     if (!empty($_POST)) {
         if (!$this->config->item('dev_password', 'fuel')) {
             redirect('');
         } else {
             if ($this->config->item('dev_password', 'fuel') == $this->input->post('password', TRUE)) {
                 $this->load->helper('convert');
                 $this->session->set_userdata('dev_password', TRUE);
                 $forward = uri_safe_decode($this->input->post('forward'));
                 redirect($forward);
             } else {
                 add_error(lang('error_invalid_login'));
             }
         }
     }
     $fields['password'] = array('type' => 'password', 'size' => 25);
     $fields['forward'] = array('type' => 'hidden', 'value' => fuel_uri_segment(2));
     $this->form_builder->show_required = FALSE;
     $this->form_builder->submit_value = 'Login';
     $this->form_builder->set_fields($fields);
     if (!empty($_POST)) {
         $this->form_builder->set_field_values($_POST);
     }
     $vars['form'] = $this->form_builder->render();
     $vars['notifications'] = $this->load->view('_blocks/notifications', $vars, TRUE);
     $vars['display_forgotten_pwd'] = FALSE;
     $vars['instructions'] = lang('dev_pwd_instructions');
     $vars['page_title'] = lang('fuel_page_title');
     $this->load->view('login', $vars);
 }
 protected function _nav_selected()
 {
     if (empty($this->nav_selected)) {
         if (fuel_uri_segment(1) == '') {
             $this->nav_selected = 'dashboard';
         } else {
             $this->nav_selected = fuel_uri_segment(1);
         }
     }
 }
示例#9
0
 protected function _list_process()
 {
     $this->load->library('pagination');
     $this->load->helper('convert');
     $this->load->helper('cookie');
     /* PROCESS PARAMS BEGIN */
     $filters = array();
     $page_state = $this->_get_page_state($this->module_uri);
     $defaults = array();
     $defaults['col'] = !empty($this->default_col) ? $this->default_col : $this->display_field;
     $defaults['order'] = !empty($this->default_order) ? $this->default_order : 'asc';
     $defaults['offset'] = 0;
     $defaults['limit'] = 25;
     $defaults['search_term'] = '';
     $defaults['view_type'] = 'list';
     $defaults['extra_filters'] = array();
     $defaults['precedence'] = 0;
     // custom module filters defaults
     foreach ($this->filters as $key => $val) {
         $defaults[$key] = isset($val['default']) ? $val['default'] : NULL;
     }
     $mod_segs = explode('/', $this->module_uri);
     $mod_offset_index = count($mod_segs) + 3;
     $uri_params = uri_safe_batch_decode(fuel_uri_segment($mod_offset_index), '|', TRUE);
     $uri_params['offset'] = fuel_uri_segment($mod_offset_index) ? (int) fuel_uri_segment($mod_offset_index) : 0;
     $posted = array();
     if (!empty($_POST)) {
         $posted['search_term'] = $this->input->post('search_term');
         $posted_vars = array('col', 'order', 'limit', 'offset', 'precedence', 'view_type');
         foreach ($posted_vars as $val) {
             if ($this->input->post($val)) {
                 $posted[$val] = $this->input->post($val, TRUE);
             }
         }
         // custom module filters
         $extra_filters = array();
         foreach ($this->filters as $key => $val) {
             if (isset($_POST[$key])) {
                 $posted[$key] = $this->input->post($key, TRUE);
                 $this->filters[$key]['value'] = $posted[$key];
                 $extra_filters[$key] = $posted[$key];
             }
         }
         $posted['extra_filters'] = $extra_filters;
     }
     //$params = array_merge($defaults, $page_state, $uri_params, $posted);
     $params = array_merge($defaults, $page_state, $uri_params, $posted);
     // reset offset if you apply a filter (via POST and not ajax)
     if (!empty($_POST) and !is_ajax()) {
         $params['offset'] = 0;
     }
     if ($params['search_term'] == lang('label_search')) {
         $params['search_term'] = NULL;
     }
     /* PROCESS PARAMS END */
     return $params;
 }
示例#10
0
 function __construct($validate = TRUE)
 {
     parent::__construct($validate);
     $this->load->module_model(FUEL_FOLDER, 'fuel_archives_model');
     if (empty($this->module)) {
         $this->module = fuel_uri_segment(1);
     }
     if (empty($this->module)) {
         show_error(lang('cannot_determine_module'));
     }
     $params = array();
     if ($this->fuel->modules->exists($this->module, FALSE)) {
         $this->module_obj = $this->fuel->modules->get($this->module, FALSE);
         $params = $this->module_obj->info();
     } else {
         if ($this->fuel->modules->exists($this->module . '_' . fuel_uri_segment(2), FALSE)) {
             // if it is a module with multiple controllers, then we'll check first and second FUEL segment with an underscore'
             $this->module = $this->module . '_' . fuel_uri_segment(2);
             if ($this->fuel->modules->exists($this->module, FALSE)) {
                 $this->module_obj = $this->fuel->modules->get($this->module, FALSE);
                 $params = $this->module_obj->info();
             }
         } else {
             if ($this->fuel->modules->exists(fuel_uri_segment(2), FALSE)) {
                 $this->module = fuel_uri_segment(2);
                 $this->module_obj = $this->fuel->modules->get($this->module, FALSE);
                 if ($this->module and $this->module_obj) {
                     $mod_name = $this->module_obj->name();
                 }
                 if (empty($mod_name)) {
                     show_error(lang('error_missing_module', fuel_uri_segment(1)));
                 }
                 unset($mod_name);
                 $params = $this->module_obj->info();
             }
         }
     }
     // stop here if the module is disabled
     if (empty($params) or $params['disabled'] === TRUE) {
         show_404();
     }
     foreach ($params as $key => $val) {
         $this->{$key} = $val;
     }
     // load any configuration
     if (!empty($this->configuration)) {
         if (is_array($this->configuration)) {
             $config_module = key($this->configuration);
             $config_file = current($this->configuration);
             $this->config->module_load($config_module, $config_file);
         } else {
             $this->config->load($this->configuration);
         }
     }
     // load any language
     if (!empty($this->language)) {
         if (is_array($this->language)) {
             $lang_module = key($this->language);
             $lang_file = current($this->language);
             // now check to see if we need to load the language file or not...
             // we load the main language file automatically with the Fuel_base_controller.php
             $this->load->module_language($lang_module, $lang_file, $this->fuel->auth->user_lang());
         } else {
             $this->load->language($this->language);
         }
     }
     // load the model
     if (!empty($this->model_location)) {
         $this->load->module_model($this->model_location, $this->model_name);
     } else {
         $this->load->model($this->model_name);
     }
     // get the model name
     $model_parts = explode('/', $this->model_name);
     $model = end($model_parts);
     // set the module_uri
     if (empty($this->module_uri)) {
         $this->module_uri = $this->module;
     }
     $this->js_controller_params['module'] = $this->module_uri;
     if (!empty($model)) {
         $this->model =& $this->{$model};
     } else {
         show_error(lang('incorrect_route_to_module'));
     }
     // global variables
     $vars = array();
     if (!empty($params['js'])) {
         if (is_string($params['js'])) {
             $params['js'] = preg_split("/,\\s*/", $params['js']);
         }
         $vars['js'] = $params['js'];
     }
     if (!empty($this->nav_selected)) {
         $vars['nav_selected'] = $this->nav_selected;
     }
     $this->load->vars($vars);
     $this->fuel->admin->load_js_localized($params['js_localized']);
     if (!empty($this->permission) and $validate) {
         $this->_validate_user($this->permission);
     }
 }
示例#11
0
 /**
  * Returns the selected navigation
  *
  * @access	public
  * @return	string
  */
 public function nav_selected()
 {
     if (empty($this->CI->nav_selected)) {
         if (fuel_uri_segment(1) == '') {
             $nav_selected = 'dashboard';
         } else {
             $nav_selected = fuel_uri_segment(1);
         }
     } else {
         $nav_selected = $this->CI->nav_selected;
     }
     // Convert wild-cards to RegEx
     $nav_selected = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $nav_selected));
     $this->CI->load->vars(array('nav_selected' => $nav_selected));
     return $nav_selected;
 }