codeigniter-2

How to load hook for particular controller

半世苍凉 提交于 2019-12-24 05:27:48
问题 I am new in codeigniter. I want to load hooks for admin panel controller. $hook['post_controller_constructor'][] = array( 'class' => 'AdminData', 'function' => 'myfunction', 'filename' => 'loginhelp.php', 'filepath' => 'hooks', 'params' => array() ); 回答1: The post_controller_constructor hook gets called after a $class is loaded. The class that gets loaded is based on the route parameters. system/core/Codeigniter.php /** *<code> * http://example.com/adminData/method *</code> * * $CI = new

Codeigniter at subfolder and htaccess for inner redirection

别来无恙 提交于 2019-12-24 04:08:21
问题 I have a project with custom engine at backend, I'm trying to hook every request at /somewhere/ with my CodeIgniter. So I put my CI to /www/somewhere/ , configured my CodeIgniter's .htaccess with new RewriteBase, so it now looks like: AddDefaultCharset UTF-8 Options All -Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /somewhere/ DirectoryIndex index.html index.php RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^application.

How can I download file in codeigniter?

妖精的绣舞 提交于 2019-12-24 03:27:31
问题 I am trying to download file in my codeigniter web application using javascript and codeigniter controller, it shows the file contents in ASCII format but not download the file directly view.php <a href="javascript:prd_download(this)">Download</a> <img src="<?php echo site_url()."/../images/uploads/".$jobno."/thumb_".$prd_row->filename; ?>" alt="Loading Image..." > <input type="checkbox" name="img_check" id="img_check" class="img_check" image="<?php echo $prd_row->filename ?>"> <script type=

Extend Codeigniter Exceptions class to add a custom method

天涯浪子 提交于 2019-12-24 03:12:49
问题 I created a new method to handle with 401 apache error. My core class extends CI core class but when I call the method name I receive this message: Fatal error: Call to undefined function show_401() in G:\Path\application\controllers\loader.php on line 29 class MI_Exceptions extends CI_Exceptions { function __construct() { parent::__construct(); } /** * 401 Unauthorized * * @access private * @param string the page * @param bool log error yes/no * @return string */ function show_401($page = ''

Google Two-factor Authentication Tutorial for Codeigniter

瘦欲@ 提交于 2019-12-24 02:34:11
问题 Does anyone know a good Google Two-factor Authentication tutorial for Codeigniter? 回答1: Here tutsplus Integrating Two-Factor Authentication with CodeIgniter http://net.tutsplus.com/tutorials/php/integrating-two-factor-authentication-with-codeigniter/ 来源: https://stackoverflow.com/questions/16908124/google-two-factor-authentication-tutorial-for-codeigniter

Codeigniter - How to upload original image with thumbnail image?

白昼怎懂夜的黑 提交于 2019-12-24 00:10:01
问题 I have this code to file upload in codeigniter: if(!empty($_FILES['userfile'])){ $name_array = array(); $count = count($_FILES['userfile']['size']); foreach($_FILES as $key => $value) for ($s=0; $s<=$count-1; $s++){ $_FILES['userfile']['name'] = $value['name'][$s]; $_FILES['userfile']['type'] = $value['type'][$s]; $_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s]; $_FILES['userfile']['error'] = $value['error'][$s]; $_FILES['userfile']['size'] = $value['size'][$s]; $config['upload_path'

How to use comparison operator for numeric string in mysql?

独自空忆成欢 提交于 2019-12-23 22:07:41
问题 I have an employee table which has field like experience with varchar type, this field combines both total year and total month separated by dash(-), so I have to filter experience by year who has more than 3 years experience. my table structure: So now I have to get more than 3 years experienced id's. I tried like below, SELECT * FROM employee WHERE experience LIKE '>=3%'; I know comparison operator will not support for string but I do not have any new solution for that, Is there any

upload size limit in codeigniter

六月ゝ 毕业季﹏ 提交于 2019-12-23 22:04:19
问题 I have a page where user can register. He uploads a profile picture in the process. I want to limit the size but there is not much emphasis on codeigniter documentation except for $config['maxsize']. I tried the following but I don't get any messages. I set the size to 10 (KB) just for testing. Do I have to handle it somehow to get the message across to my view? public function add_user() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['max_size

Session Timeout in codeigniter dyanamicly

北城余情 提交于 2019-12-23 19:49:18
问题 I have issue regarding codeigniter Timeout . I know the config folder setting session timeout manually like as l $config['sess_expiration'] = 123; but i need to the website admin manage the session time out dyanamicly in to the admin page please help me how to implement this logic i tried this logic but not working $this->session->sess_expiration = "120"; Note:here i am storing database in the value. based on the database value i can set in to the session expiration time note 1: $config['sess

IF Session data exists, output in view

六眼飞鱼酱① 提交于 2019-12-23 15:39:34
问题 So I'm trying to output a session's variable value into a view (only if it exists). But I can't seem to get it to work. No error. Nothing. What am I missing? Thought I had this down packed by now - guess not... In controller...FYI, $data is assigned to the view (i.e. $this -> load -> view('view', $data); $data['campaign_name'] = $this -> session -> userdata('campaign_name'); Here's my php snippet in the view that I'm trying to output. So in short, if the session exists, output it. If not, do