Member Avatar

I have a helper function in codeigniter php where I can use helper like so load_controller('column_left', 'index'); for example "column_left" is the file and class name. How ever that works fine but I would like to be able to type a folder name in load_controller('some_folder/some_class', 'index'); and it would detect controller. **Question** How can I make it so if I type a name of a subfolder in controllers then will pick folder and filename up. <?php function load_controller($controller, $method = 'index', $params = '') { require_once (APPPATH . 'controllers/' . $controller . '.php'); // Need to sill have as backup …

+0 forum 0
Member Avatar

I would like to know if possible to convert this to the codeigniter active record way using this->db->join etc. What's the best. It works fine with the code I got but would like to make it work with codeigniter db active records. http://www.codeigniter.com/userguide2/database/active_record.html public function get_category($category_id) { $language_id = $this->check_language(); $query = $this->db->query("SELECT DISTINCT *, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR '&nbsp;&nbsp;&gt;&nbsp;&nbsp;') FROM " . $this->db->dbprefix . "category_path cp LEFT JOIN " . $this->db->dbprefix . " category_description cd1 ON (cp.path_id = cd1.category_id AND cp.category_id != cp.path_id) WHERE cp.category_id = c.category_id AND cd1.language_id = '" . (int)$language_id . "' GROUP BY …

Member Avatar
+0 forum 1
Member Avatar

On my controller I have a variable called 'name' => $child['name'], for my drop down menu. The problem I am having is that in the child dropdown menu it still shows parent name. I am trying to make it so if parent_id name is equal 0 then will not show in dropdown child links. Why is it still showing parent name in dropdown child links **Controller** <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Test extends MX_Controller { public function index() { $this->load->model('admin/catalog/model_catalog_category'); $data['categories'] = array(); $categories = $this->get_categories(0); foreach ($categories as $category) { if ($category['top']) { …

Member Avatar
+0 forum 3
Member Avatar

When I view my list in my admin I would like to be able to make sure the controller name is sorted asc Currently it does not sort alphabetically 'name' => ucwords(str_replace('_', ' ', $controller)), **Function** public function index() { $data['title'] = "User Group Permissions"; $controller_files = $this->get_installed_permissions('name'); $data['controller_files'] = array(); $files = glob(FCPATH . 'application/modules/admin/controllers/*/*.php'); if ($files) { foreach ($files as $file) { $controller = basename(strtolower($file), '.php'); $modules = $this->get_permissions_by_controller($controller); $module_data = array(); foreach ($modules as $module) { $module_data[] = array( 'user_group_id' => $module['user_group_id'], 'name' => ucwords(str_replace('_', ' ', $controller) . ' &gt; ' . $module['name']), 'edit' => site_url('admin/extension/permissions/update' …

Member Avatar
-1 forum 2
Member Avatar

When I or user logs on it checks what permissions it has. And then on a form if has not got permission throws error. Example: <?php class Users_groups extends CI_Controller { public function update() { if (($this->input->server('REQUEST_METHOD') == 'POST') && $this->validateForm()) { // Modal stuff } } public function index() { // form content } public function validateForm() { if (!$this->user_auth->hasPermission('modify', 'user/Users_groups')) { $this->error['warning'] = 'You do not have permission to modify'; } return !$this->error; } } When I submit form it should let me edit and save but for some reason this if(isset($value)) {return $value==$this->permission[$key];} is not working so …

Member Avatar
+0 forum 2
Member Avatar

I have made a library class in php which can get data from my database table settings. I can get information if it is not serialized. But I would like to know on my get function what would be best method to be able to return unserialise information just incase it is serialized. <?php class Settings { private $data = array(); public function __construct() { $this->CI =& get_instance(); } public function get($key = NULL) { if ($key != NULL) { $value = $this->get_where($key); return $value; } else { return FALSE; } } public function get_where($key = NULL) { if ($key …

Member Avatar
+0 forum 1
Member Avatar

I have three files which when i click on delete should be removed. How am I able to use the unlink and realpath for my multiple files? public function delete() { $path_to_file = FCPATH . 'application/modules/admin/controllers/module' .'/'. $this->uri->segment(5).'.php'; $path_to_file_lang = FCPATH . 'application/modules/admin/language'.'/' .'english' .'/'. 'module/'. $this->uri->segment(5).'lang.php'; $path_to_file_view = FCPATH . 'application/modules/admin/views/template/module' .'/'. $this->uri->segment(5).'.tpl'; if (unlink(realpath($path_to_file), realpath($path_to_file_lang)) ) { echo "deleted" .' '. $path_to_file; echo "<br/>"; echo "deleted" .' '. $path_to_file_lang; echo "<br/>"; echo "deleted" .' '. $path_to_file_view; } else { echo "did not delete"; } }

Member Avatar
+0 forum 4
Member Avatar

I am having trouble with unserialize method does not seem to work for my codeigniter project. What is the best method to unserialize with codeigniter php. I get a error A PHP Error was encountered Severity: Notice Message: unserialize(): Error at offset 67 of 139 bytes Filename: extension/model_module.php Line Number: 25 Model Function public function getModule($module_id) { $query = $this->db->query("SELECT * FROM `" . $this->db->dbprefix . "module` WHERE `module_id` = " . $this->db->escape($module_id) . " "); if ($query->row()) { return unserialize($query->row('setting')); } else { return array(); } }

Member Avatar
+0 forum 1
Member Avatar

On my view I am trying to get it so if my input link[] is next to the upload button then that link post will be inserted into the database with image I use codeigniter for a mvc frame work. I can insert the links and images fine, but the link/url that I type in, in each link input are not matching the uploaded filename. How can I resolve this? Thanks In Advance function do_upload() { $files = $_FILES; $file_loop = count($_FILES['userfile']['name']); for($i= 0; $i < $file_loop; $i++) { $_FILES['userfile']['name'] = $files['userfile']['name'][$i]; $_FILES['userfile']['type'] = $files['userfile']['type'][$i]; $_FILES['userfile']['tmp_name'] = $files['userfile']['tmp_name'][$i]; $_FILES['userfile']['error'] = …

Member Avatar
+0 forum 1
Member Avatar

When there should be a error it does not show. I can not seem to get the erorrs to work in the correct order How can I improve my file upload errors to work in correct order? public function upload() { $name = $_FILES['userfile']['name']; $tmp_name = $_FILES['userfile']['tmp_name']; $type = $_FILES['userfile']['type']; $size = $_FILES['userfile']['size']; $error = $_FILES['userfile']['error']; for($i = 0; $i < count($tmp_name); $i++) { $dir = FCPATH . "upload/"; if (is_dir($dir)) { if (!empty($name[$i]) && is_file($name[$i])) { // Allowed file extension types $allowed = array( 'jpg', 'jpeg', 'gif', 'png' ); if (in_array(utf8_strtolower(utf8_substr(strrchr($name[$i], '.'), 1)), $allowed)) { $this->error['warning'] = 'Incorrect File …

Member Avatar
+0 forum 2
Member Avatar

I would like to know if possible in my php codeigniter modelto be able to insert my file names where it matches up with the link insert post. The link post are in array i.e. <input type="text" name="link[]" /> Not sure whats best the name of the file inserts but over does not insert correct name. The input for user file is <input type="file" name="userfile+row_id" the row id produces auto generated number. **Model** public function add_banner_image($banner_id = 0) { foreach ($this->input->post('link') as $link) { $data = array( 'banner_id' => $banner_id, 'link' => $link, ); foreach($_FILES as $field => $file) { …

Member Avatar
+0 forum 1
Member Avatar

On my readURL() function in my scrtipt. I would like to know what would be the best method in being able to auto get the ID from my img tag. Because I have mulitple img rows that get created with own id. What would you think so that the reader.onload part can set it so the selector part where put ID can auto get any id from img tag. And work with the attr 'src'. Currently I have to enter each id in manuall which is bit anoying. Thanks very much in advance. **Script ** function readURL(input) { if (input.files …

Member Avatar
+0 forum 9
Member Avatar

When I upload I can upload single files fine but, I cannot seem to upload if input is like **<input type="file" name="file[]">** I am not sure on my php upload function how to make it allow multiple files? Thanks in advance. public function upload() { $this->load->library('request'); $directory = FCPATH .'upload/'; $full_path = $directory . basename($this->request->files['file']['name']); $file_name = basename($this->request->files['file']['name']); $file_ext = array('jpeg', 'jpg', 'gif','png'); $file_size = 3000; if (is_dir($directory)) { if (!move_uploaded_file($this->request->files['file']['tmp_name'], $full_path)) { if (!in_array(utf8_strtolower(utf8_substr(strrchr($file_name, '.'), 1)), $file_ext)) { $this->error['warning'] = 'Warning: Incorrect file type!'; } if ($_FILES["file"]["size"] < $file_size) { $this->error['warning'] = 'Warning: Incorrect file size!'; } return !$this->error; …

Member Avatar
+0 forum 3
Member Avatar

When I click on my button add new row it creates a new row and with the same content as what is in orignal row. But for each img I would like to be able to have its own unique id / selector rather than the same id. How am I able to make that possible with code I have. <script type="text/javascript"> $("#insert-more").click(function () { $("#images").each(function () { var tds = '<tr>'; jQuery.each($('tr:last td', this), function () { tds += '<td>' + $(this).html() + '</td>'; }); tds += '</tr>'; if ($('tbody', this).length > 0) { $('tbody', this).append(tds); } else { …

Member Avatar
+0 forum 1
Member Avatar

I have a custom php function for my multiple upload function. I cannot figure out how to make it so when I insert the file name to the database that it matches the row id, of that insert. How can I make it so. When I create a new banner that each image multiple images that each match the there inserted id. ** Model Function** public function addBanner($data) { $this->db->query("INSERT INTO " . $this->db->dbprefix . "banner SET name = " . $this->db->escape($data['name']) . ", status = '" . (int)$data['status'] . "' "); $banner_id = $this->get_id->get_last_id(); if (isset($data['banner_image'])) { foreach ($data['banner_image'] …

Member Avatar
+0 forum 3
Member Avatar

I use codeigniter 2+ for my frame work I am having issue with my multple file upload that are in array. I is not picking up the number with in the array. Example: name="banner_image[auto_generated_number]['image']" how to make a foreach work with the banner_image[auto_generated_number]['image'] Currently my code is public function do_upload() { $config['upload_path'] = './upload/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['max_size'] = '0'; $config['max_width'] = '*'; $config['max_height'] = '*'; $config['overwrite'] = TRUE; $this->load->library('upload', $config); $this->upload->initialize($config); $files = $_FILES['banner_image']['name']; foreach ($files as $FIELD => $name) { if ($this->upload->do_upload($FIELD)) { } else { $this->form_validation->set_message('do_upload', $this->upload->display_errors()); return false; } } } View sample <?php $image_row = …

Member Avatar
+0 forum 1

The End.