function _remap($segment) { $this->load->library('session'); $this->session->sess_destroy(); $this->load->module_library(FUEL_FOLDER, 'fuel_auth'); $this->load->helper('cookie'); $this->fuel_auth->logout(); $config = array( 'name' => $this->fuel_auth->get_fuel_trigger_cookie_name(), 'path' => WEB_PATH ); delete_cookie($config); $redirect = $this->config->item('logout_redirect', 'fuel'); if ($redirect == ':last') { $this->load->helper('convert'); // if ($segment == 'index') // { // $redirect = fuel_uri('login'); // } // else // { $redirect = uri_safe_decode($segment); //} } redirect($redirect); }
function list_items($limit = null, $offset = 0, $col = 'name', $order = 'asc') { $CI =& get_instance(); $CI->load->helper('array'); $CI->load->helper('convert'); if (!isset($this->filters['group_id'])) { return array(); } $group_id = $this->filters['group_id']; // not encoded yet... then decode if (!$this->_encoded) { $this->filters['group_id'] = uri_safe_encode($group_id); // to pass the current folder $this->_encoded = TRUE; } else { $group_id = uri_safe_decode($group_id); } $asset_dir = $this->get_dir($group_id); $assets_path = $CI->asset->assets_server_path . $asset_dir . DIRECTORY_SEPARATOR; $tmpfiles = directory_to_array($assets_path, TRUE, $CI->config->item('assets_excluded_dirs', 'fuel'), FALSE); $files = get_dir_file_info($assets_path, TRUE); $cnt = count($tmpfiles); $return = array(); $asset_type_path = WEB_PATH . $CI->config->item('assets_path') . $asset_dir . '/'; //for ($i = $offset; $i < $cnt - 1; $i++) for ($i = 0; $i < $cnt; $i++) { if (!empty($tmpfiles[$i]) && !empty($files[$tmpfiles[$i]])) { $key = $tmpfiles[$i]; if (empty($this->filters['name']) || !empty($this->filters['name']) && (strpos($files[$key]['name'], $this->filters['name']) !== FALSE || strpos($key, $this->filters['name']) !== FALSE)) { $file['id'] = uri_safe_encode(assets_server_to_web_path($files[$tmpfiles[$i]]['server_path'], TRUE)); //$file['filename'] = $files[$key]['name']; $file['name'] = $key; $file['preview/kb'] = $files[$key]['size']; $file['link'] = NULL; $file['last_updated'] = english_date($files[$key]['date'], true); $return[] = $file; } } } $return = array_sorter($return, $col, $order, TRUE); // do a check for empty limit values to prevent issues found where an empty $limit value would return nothing in 5.16 $return = empty($limit) ? array_slice($return, $offset) : array_slice($return, $offset, $limit); // after sorting add the images foreach ($return as $key => $val) { if (is_image_file($return[$key]['name'])) { $return[$key]['preview/kb'] = $return[$key]['preview/kb'] . ' kb <div class="img_crop"><a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank"><img src="' . $asset_type_path . $return[$key]['name'] . '" border="0"></a></div>'; $return[$key]['link'] = '<a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank">' . $asset_dir . '/' . $return[$key]['name'] . '</a>'; } else { $return[$key]['preview/kb'] = $return[$key]['preview/kb']; $return[$key]['link'] = '<a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank">' . $asset_dir . '/' . $return[$key]['name'] . '</a>'; } } return $return; }
public function _remap($segment) { $this->load->helper('convert'); $this->fuel->auth->logout(); $config = array('name' => $this->fuel->auth->get_fuel_trigger_cookie_name(), 'path' => WEB_PATH); delete_cookie($config); $redirect = $this->fuel->config('logout_redirect'); if ($redirect == ':last') { $this->load->helper('convert'); $redirect = uri_safe_decode($segment); } if (is_home($segment) or is_home($redirect)) { $redirect = $this->fuel->config('default_home_view'); } redirect($redirect, 'location', 302, FALSE); }
/** * Returns the name of the file and will decode it if necessary * * @access public * @param string An asset file * @return string */ public function get_file($file) { // if no extension is provided, then we determine that it needs to be decoded if (strpos($file, '.') === FALSE) { $file = uri_safe_decode($file); } return $file; }
/** * Decode a key/value array or string into a URI safe value * * @access public * @param string string to be converted * @param string delimiter to split string * @param boolean value is hexified * @return string */ function uri_safe_batch_decode($str, $delimiter = '|', $hexify = TRUE) { $str = uri_safe_decode($str, $hexify); $tmp = explode($delimiter, $str); $params = array(); foreach ($tmp as $val) { $key_val = explode('/', $val); if (count($key_val) >= 2) { if (strncmp($key_val[1], '??', 2) === 0) { $key_val[1] = unserialize(substr($key_val[1], 2)); } $params[$key_val[0]] = $key_val[1]; } } return $params; }
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); }
public function create($dir = NULL, $inline = FALSE) { $id = NULL; if (!empty($dir)) { $dir = uri_safe_decode($dir); } if ($inline !== FALSE) { $this->fuel->admin->set_inline(TRUE); } $inline = $this->fuel->admin->is_inline(); if (!empty($_POST)) { if (!empty($_FILES['userfile']) and $_FILES['userfile']['error'] != 4 or !empty($_FILES['userfile___0']) and $_FILES['userfile___0']['error'] != 4) { $this->model->on_before_post(); if ($this->input->post('asset_folder')) { $dir = $this->input->get_post('asset_folder', TRUE); if (!in_array($dir, array_keys($this->fuel->assets->dirs()))) { show_404(); } } $subfolder = $this->config->item('assets_allow_subfolder_creation', 'fuel') ? str_replace('..' . DIRECTORY_SEPARATOR, '', $this->input->get_post('subfolder', TRUE)) : ''; // remove any going down the folder structure for protections $upload_path = $this->config->item('assets_server_path') . $this->fuel->assets->dir($dir) . DIRECTORY_SEPARATOR . $subfolder; //assets_server_path is in assets config $posted['upload_path'] = $upload_path; $posted['overwrite'] = $this->input->get_post('overwrite') ? TRUE : FALSE; $posted['create_thumb'] = $this->input->get_post('create_thumb') ? TRUE : FALSE; $posted['resize_method'] = $this->input->get_post('resize_method') ? $this->input->get_post('resize_method', TRUE) : 'maintain_ratio'; $posted['resize_and_crop'] = $this->input->get_post('resize_and_crop', TRUE); $posted['width'] = $this->input->get_post('width', TRUE); $posted['height'] = $this->input->get_post('height', TRUE); $posted['master_dim'] = $this->input->get_post('master_dim', TRUE); $posted['file_name'] = $this->input->get_post('userfile_file_name', TRUE); $posted['unzip'] = $this->input->get_post('unzip') ? TRUE : FALSE; $posted['remove_subfolder'] = $this->input->get_post('remove_subfolder', TRUE); $redirect_to = uri_safe_decode($this->input->get_post('redirect_to')); $id = $posted['file_name']; // run before_create hook $this->_run_hook('before_create', $posted); // run before_save hook $this->_run_hook('before_save', $posted); if ($this->fuel->assets->upload($posted)) { foreach ($_FILES as $filename => $fileinfo) { $msg = lang('module_edited', $this->module_name, $fileinfo['name']); $this->fuel->logs->write($msg); } // explicitly set the flash values to save cookie space $flashdata['asset_folder'] = $this->input->post('asset_folder', TRUE); $flashdata['userfile_file_name'] = $this->input->post('userfile_file_name', TRUE); $flashdata['subfolder'] = $this->input->post('subfolder', TRUE); $flashdata['overwrite'] = $this->input->post('overwrite', TRUE); $flashdata['resize_method'] = $this->input->post('resize_method', TRUE); $flashdata['width'] = $this->input->post('width', TRUE); $flashdata['height'] = $this->input->post('height', TRUE); $flashdata['resize_method'] = $this->input->post('resize_method', TRUE); $flashdata['master_dim'] = $this->input->post('master_dim', TRUE); $flashdata['resize_method'] = $this->input->post('resize_method', TRUE); $uploaded_data = $this->fuel->assets->uploaded_data(); $first_file = current($uploaded_data); $uploaded_file_name_arr = array(); $uploaded_file_webpath_arr = array(); foreach ($uploaded_data as $ud) { $uploaded_path = assets_server_path() . $dir; if (is_true_val($posted['remove_subfolder'])) { $uploaded_path = $uploaded_path . '/' . $subfolder; } $uploaded_file_name_arr[] = trim(str_replace($uploaded_path, '', $ud['full_path']), '/'); $uploaded_file_webpath_arr[] = assets_server_to_web_path($ud['full_path']); } // set the uploaded file name to a concatenated string separated by commas $uploaded_file_name = implode(', ', $uploaded_file_name_arr); $flashdata['uploaded_file_name'] = $uploaded_file_name; $flashdata['uploaded_file_webpath'] = $uploaded_file_webpath_arr; $this->session->set_flashdata('uploaded_post', $flashdata); $this->fuel->admin->set_notification(lang('data_saved'), Fuel_admin::NOTIFICATION_SUCCESS); $this->model->on_after_post($posted); $inline = $this->fuel->admin->is_inline(); $query_str = query_str(array(), TRUE); if (!empty($redirect_to)) { $url = $redirect_to; } else { if ($inline === TRUE) { $url = fuel_uri($this->module . '/inline_create/' . uri_safe_encode($dir) . $query_str, FALSE); } else { $url = fuel_uri($this->module . '/create/' . uri_safe_encode($dir) . $query_str, FALSE); } } redirect($url); } else { add_errors($this->fuel->assets->errors()); } } else { add_errors(lang('error_upload')); } } $form_vars = $this->input->get(NULL, TRUE); if (!empty($dir)) { $form_vars['asset_folder'] = $dir; } $form_vars['asset_folder'] = !empty($form_vars['asset_folder']) ? trim($form_vars['asset_folder'], '/') : ''; $vars = $this->_form($form_vars, $inline); $vars['related_items'] = $this->model->related_items($vars); $list_view = $inline ? $this->module_uri . '/inline_items/' : $this->module_uri; $crumbs = array($list_view => $this->module_name, lang('assets_upload_action')); $this->fuel->admin->set_titlebar($crumbs); $this->fuel->admin->set_inline($inline === TRUE); if ($inline === TRUE) { $this->fuel->admin->set_display_mode(Fuel_admin::DISPLAY_COMPACT_TITLEBAR); } else { $vars['actions'] = $this->load->module_view(FUEL_FOLDER, '_blocks/module_create_edit_actions', $vars, TRUE); } $this->fuel->admin->render($this->views['create_edit'], $vars, '', FUEL_FOLDER); return $id; }
function delete($id = NULL) { if (!$this->fuel_auth->has_permission($this->permission, 'delete')) { show_error(lang('error_no_permissions')); } if (!empty($_POST['id'])) { $posted = explode('|', $this->input->post('id')); foreach ($posted as $id) { $this->model->delete(uri_safe_decode($id)); } $this->session->set_flashdata('success', $this->lang->line('data_deleted')); $this->_clear_cache(); $this->logs_model->logit('Multiple module ' . $this->module . ' data deleted'); redirect(fuel_uri($this->module_uri)); } else { $this->js_controller_params['method'] = 'deleteItem'; $vars = array(); if (!empty($_POST['delete']) and is_array($_POST['delete'])) { $data = array(); foreach ($this->input->post('delete') as $key => $val) { $d = $this->model->find_by_key(uri_safe_decode($key), 'array'); if (!empty($d)) { $data[] = $d[$this->display_field]; } } $vars['id'] = implode('|', array_keys($_POST['delete'])); $vars['title'] = implode(', ', $data); } else { $data = $this->model->find_by_key(uri_safe_decode($id)); $vars['id'] = $id; if (isset($data[$this->display_field])) { $vars['title'] = $data[$this->display_field]; } } if (empty($data) or !empty($data['server_path']) and empty($data['name'])) { show_404(); } $vars['error'] = $this->model->get_errors(); $vars['notifications'] = $this->load->module_view(FUEL_FOLDER, '_blocks/notifications', $vars, TRUE); $this->_render($this->views['delete'], $vars); } }
function do_action() { if (is_ajax()) { // $result['status'] = -98; // echo json_encode($result); // die; $post_arr = $this->input->post(); $now = datetime_now(false); $start = date(uri_safe_decode($post_arr['start'])); $deadline = date(uri_safe_decode($post_arr['deadline'])); // $result['now'] = $now; // $result['start'] = $start; // $result['deadline'] = $deadline; // $result['test1'] = $now>=$start; // $result['test2'] = $now<$deadline; // $result['test3'] = $now<$start; // $result['test4'] = $now>$deadline; // echo json_encode($result); // die; if ($now < $start) { $result['status'] = -97; echo json_encode($result); die; } if ($now > $deadline) { $result['status'] = -98; echo json_encode($result); die; } $item_id = $post_arr['item_id']; $action_code = $post_arr['action_code']; $this->load->helper('cookie'); $target_url = $this->input->cookie("voting_target_url"); if (!isset($target_url) || $target_url == "") { $target_url = site_url(); } $user_id = $this->code_model->get_logged_in_account(); if ($user_id == null || $user_id == "") { $result['status'] = -99; $result['login_url'] = site_url() . 'login'; echo json_encode($result); die; } $is_fb = !filter_var($user_id, FILTER_VALIDATE_EMAIL); //fb 登入才能分享&讚 if (!$is_fb && ($action_code == 'S' || $action_code == 'L')) { $result['forbidden'] = 'Y'; } else { $result['forbidden'] = 'N'; // $result['user_id'] = $user_id; // echo json_encode($result); // die; // $user_id = 」;//TODO:先寫死 $can_vote = $this->events_model->user_can_action($user_id, $item_id, $action_code); if ($can_vote) { $sucesss = $this->events_model->insert($user_id, $action_code, $item_id); $result['exists'] = $sucesss ? 'N' : 'Y'; $result['limit_of_vote'] = 'N'; } else { $result['limit_of_vote'] = 'Y'; $result['exists'] = 'Y'; } } $result['status'] = 1; echo json_encode($result); } else { // redirect(site_url(), 'refresh'); $result['status'] = -1; $result['msg'] = "發生錯誤,請再試一次"; echo json_encode($result); } die; }