Welcome, Guest
You have to register before you can post on our site.



Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,927
» Latest member: dushee
» Forum threads: 66,205
» Forum posts: 415,477

Full Statistics

Latest Threads
How to create resful web ...
Forum: Learn More
7 hours ago
» Replies: 0   » Views: 44
download remote file wit...
Forum: General Help
11 hours ago
» Replies: 2   » Views: 61
Query Caching or NOT?!!!
Forum: Best Practices
11 hours ago
» Replies: 4   » Views: 152
Fetch data in a selected ...
Forum: CodeIgniter 3.x
Today, 09:56 AM
» Replies: 8   » Views: 216
JWT for APIs
Forum: Lounge
Today, 09:37 AM
» Replies: 4   » Views: 203
Common function
Forum: General Help
Today, 08:39 AM
» Replies: 1   » Views: 53
Message before redirect
Forum: General Help
Today, 08:30 AM
» Replies: 2   » Views: 44
Make sure show result at ...
Forum: General Help
Today, 05:51 AM
» Replies: 2   » Views: 52
php mailer
Forum: General Help
Today, 04:55 AM
» Replies: 2   » Views: 56
CodeIgniter Filipino Comm...
Forum: Regional User Groups
Yesterday, 08:28 PM
» Replies: 21   » Views: 7,145

  Saving Hashed Passwords in my database.php
Posted by: zashishz - 06-19-2017, 07:45 AM - Forum: Libraries & Helpers - Replies (5)

Looking for a way to store hashed passwords for my DB Connections in database.php file instead of plaintext.

Please let me know any examples.


  CodeIgniter 3.1.5 Released
Posted by: jlp - 06-19-2017, 02:59 AM - Forum: News & Discussion - Replies (22)

CodeIgniter 3.1.5 was released today, with one security fix and some bug fixes.

Security: Fixed email address handling in the form validation library.

Bug fixes: Database Forge, Email, Query Builder and XML-RPC libraries; and the Inflector helper.

Enhancements: Form helper.

This is recommended for all users of version 3. Download v3.1.5 now, and we encourage you to read the changelog, and to check the directions for upgrading from a previous version.

  ion_auth messing up my query
Posted by: frocco - 06-18-2017, 12:28 PM - Forum: Addins - Replies (2)


$user = $this->ion_auth->user()->row();
$this->db->where('appt_date >=', $FromAppt_Date);
$this->db->where('appt_date<=', $ToAppt_Date);
$group = 'Requester';
        if ($this->ion_auth->in_group($group)) {
            $this->db->where('department_code', $user->department_code);
$query = $this->db->get('table');

Unknown column 'appt_date' in 'where clause'

SELECT `users_groups`.`group_id` as `id`, `groups`.`name`, `groups`.`description` FROM `users_groups` JOIN `groups` ON `users_groups`.`group_id`=`groups`.`id` WHERE `appt_date` >= '2017-06-12' AND `appt_date` <= '2017-06-12' AND `users_groups`.`user_id` = '1'
Above fails because query is trying to select query based on ion_table

  Encode with Encrypt class, Decrypt with Encryption class
Posted by: skunkbad - 06-18-2017, 09:17 AM - Forum: CodeIgniter 3.x - Replies (7)

I'd like to be able to use the CI3 Encryption class to decrypt values that were "encoded" with the CI2 (deprecated) Encrypt class. So I set up a test controller and have been playing around, but no success. Method:

PHP Code:
 * Attempt to encode via Encrypt class
 * and decrypt via Encryption class.
public function encryption_test()

// Old encryption_key from CI2
$key 'o23tngn2o2o3ngngnno22gon2oFdEzX2';

// Encrypt with CI2's Encrypt library (blowfish/cbc)

     * CI3 Encryption class will need to use mycrypt, I think.
     * I'm just guessing that it does because the encoding
     * will be done through mcrypt. It would be great if I
     * was wrong.
$this->encryption->initialize(['driver' => 'mcrypt']);

$string 'ABC123';
$encrypted_string $this->encrypt->encode($string);

//echo $encrypted_string . '<br />';

    // Decrypt using CI3's Encryption library
$decrypted_string $this->encryption->decrypt
'cipher'   => 'blowfish',
'mode'     => 'cbc',
'key'      => $key,
'hmac'     => FALSE,
'raw_data' => FALSE

$string === $decrypted_string ){
'Encrypt encode/Encrpytion decrypt success';
'Encrypt encode/Encrpytion decrypt failure';

// ----------------------------------------------------------------------- 

I need help though, because no matter what I try for the custom parameters, I can never get it right.

I even tried to extend the Encryption class:

PHP Code:
public function legacy_decrypt$base64_encoded$key )

$pre_noise_removal  base64_decode$base64_encoded );

$dec $this->_remove_cipher_noise$pre_noise_removal$key );

$init_size 8;

$iv substr($dec0$init_size);
$data substr($dec$init_size);

/*$CI =& get_instance();

$str openssl_decrypt($data'BF-CBC'$key0$iv);


$keyhash sha1($key);
$keylen strlen($keyhash);
$str '';

    for (
$i 0$j 0$len strlen($data); $i $len; ++$i, ++$j)
        if (
$j >= $keylen)
$j 0;

$temp ord($data[$i]) - ord($keyhash[$j]);

        if (
$temp 0)
$temp $temp 256;

$str .= chr($temp);


If I try to use the legacy_decrypt method, my debugging shows that the string is exactly what it should be compared to what it was before encoding with the Encrypt class. The data is the same, the key, the IV, and everything I can see is the same.

The problem for me is that we have a lot of stored records that have been "encoded" using the Encrypt class, and it may be impossible (due to physical access issues) for me to get those records and work on them, yet there may be a time when we need to "decode" them and mcrypt is no longer on the server.

If anyone can help I'd appreciate it.

Exclamation mcrypt is deprecated in PHP 7.x
Posted by: DuoS - 06-18-2017, 06:06 AM - Forum: CodeIgniter 3.x - Replies (6)

Hello friends,

I tried one of my CI based apps that built with CI v3.x latest version in PHP 7.1.5

And then I got this huge list of mcript depricated errors. 

[Image: 5Yy1YQLQQ0mfhnSB14dzvA.png]

I just wanted to know that, are you guys gonna remove this mcript library from CI v3.x and rewrite encription library from scracth?

I saw somewere that mcript library gonna completely remove from PHP 7.2. so if that happen, our apps will not gonna work.

Thankyou guys


  Get last item in list
Posted by: wolfgang1983 - 06-18-2017, 04:16 AM - Forum: General Help - Replies (3)

Hi, In my database table I would like to be able to get the last row that was created.

Have I got this model function correct. Just unsure of my self not sure if there is another easier way?

PHP Code:
public function getpostinfofordeleteupdate()
   $query $this->db->order_by('datecreated''desc')
     ->get($this->db->dbprefix 'posts');

   return $query->row_array();

Thanks for your time.

  CI4 Docs
Posted by: donpwinston - 06-17-2017, 10:04 PM - Forum: CodeIgniter 4 Support - Replies (3)

I've noticed what appears to be errors in the tutorial and the Database docs. Is it ok for the rabble to open issues in GitHub about these or should I just post them here?

  Erro listar dados
Posted by: [email protected] - 06-17-2017, 07:41 PM - Forum: Regional User Groups - Replies (2)

Pessoal, sou novo com o CI, estou tentando listar dados do banco de dados, mas estou recebendo o erro: 

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: ramais
Filename: ramais/view_ramais.php
Line Number: 46

Segue abaixo o codigo:


public function mListarRamais(){

   $this->db->select('id, name, callerid, context, qualify');
   $data['ramais'] = $this->db->get('ramais')->result();
   return $data['ramais'];



public function index()

   $data['ramais'] = $this->M_ramais->mListarRamais();
   $this->load->view('ramais/view_ramais', $data);




<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">

   <?php foreach ($ramais as $ramal){?>
       <td><?= $ramal->id; ?></td>
       <td><?= $ramal->name; ?></td>
       <td><?= $ramal->callerid; ?></td>
       <td><?= $ramal->context; ?></td>
   <?php }?>


Alguem pode me dizer oq eu estou fazendo de errado, ele chegar a listar os dados, mas no topo da tela exibe essa mensagem...

  Message: reset() expects parameter 1 to be array, null given
Posted by: iridion2015 - 06-17-2017, 06:54 PM - Forum: General Help - Replies (5)

Hi guys

I'm having this error below.

A PHP Error was encountered
Severity: Warning

Message: reset() expects parameter 1 to be array, null given

Filename: controllers/Language.php

Line Number: 89


File: C:\xampp\htdocs\ci\ci3-codes-mastery4\application\controllers\Language.php
Line: 89
Function: reset

File: C:\xampp\htdocs\ci\ci3-codes-mastery4\index.php
Line: 315
Function: require_once

and the codes of language.php are these below,

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Language extends MY_Controller
   public $current_id = array();
   public $array_container = array();
   public $total_array = 0;
   public $result_msg = '';
   function __construct()

   *  author: warren nazareno
   *  email: [email protected]
   *  purpose:
   *  Date created:
   public function index()
       echo 'Index...';
   public function suggestion() {
       $this->dryview2($header='templates/header', $msg='Welcome back ', $menu='templates/menu', $content='forms/suggestion_form', $footer='templates/footer', $master='templates/landing_master');
   public function landing()
       $language = $this->uri->segment(3, 0);
       $version = $this->subject_mdl->get_version($language);
       $this->set_button_clicks(); //initialize button clicks value to zeros
       $total_basic        = $this->qa_mdl->get_total_questions($language, $version, $topic="basic");
       $total_oop          = $this->qa_mdl->get_total_questions($language, $version, $topic="oop");
       $total_regex        = $this->qa_mdl->get_total_questions($language, $version, $topic="regex");
       $total_functions    = $this->qa_mdl->get_total_questions($language, $version, $topic="built-in functions");
       $total_patterns     = $this->qa_mdl->get_total_questions($language, $version, $topic="design patterns");
       $total_advance      = $this->qa_mdl->get_total_questions($language, $version, $topic="advance");
       $total_general      = $this->qa_mdl->get_total_questions($language, $version, $topic="general");
       $total_libraries    = $this->qa_mdl->get_total_questions($language, $version, $topic="libraries");
       $total_helper       = $this->qa_mdl->get_total_questions($language, $version, $topic="helpers");
       $total_database     = $this->qa_mdl->get_total_questions($language, $version, $topic="database");
       $content_data = array(
           "subject"           => $language,
           "version"           => $version,
           "total_basic"       => $total_basic,
           "total_oop"         => $total_oop,
           "total_regex"       => $total_regex,
           "total_functions"   => $total_functions,
           "total_patterns"    => $total_patterns,
           "total_advance"     => $total_advance,
           "total_general"     => $total_general,
           "total_libraries"   => $total_libraries,
           "total_helper"      => $total_helper,
           "total_database" => $total_database,
       $this->session->set_userdata('content_data', $content_data);
       $this->dryview2($header='templates/header', $msg='Welcome back ', $menu='templates/menu', $content='templates/landing_content', $footer='templates/footer', $master='templates/landing_master');
   public function show_qa()
       $content = $this->session->userdata('content_data');
       //Get language, version and topic
       $language = $content['subject'];
       $version = $content['version'];
       $topic = $this->uri->segment(3, 0);
       $array_init = $this->uri->segment(4, 0);
       $topic2 = str_ireplace("_", " ", $topic);
       $this->session->set_userdata('init', $array_init);    
       //Begin initializing array...
       //do this once only.
       if($array_init === 'init') {
           $this->set_array_container($language, $version, $topic2);       //do only once
           reset($this->array_container); //set the array pointer in the very first index which is zero.
           $idx = key($this->array_container);  
           $condition = 'no';
           $this->total_array = count($this->array_container);
           $this->session->set_userdata('total_array', $this->total_array);
           $this->set_button_clicks(); //initialize button clicks value to zeros

       $this->total_array = $this->session->userdata('total_array');
       //Begin catch yes or no button
       if (isset($_POST['yes']) || isset($_POST['no'])) {
               $this->array_container = $this->fetch_array_from_session();
               $last_idx = $this->get_last_idx_key();
               $idx = $this->get_idx_position();
               if($idx < $last_idx) {

               if($idx === $last_idx) {
               $idx = $this->get_idx_position();
               $condition = $this->get_end_of_array();
       //End catch yes or no button
       //replace blank space with underscore
       $topic_underscore = str_ireplace(" ", "_", $topic);
       $this->session->set_userdata('topic', $topic_underscore);    

       #get current url and store to session
       $segments = array('language', 'show_qa', $topic_underscore);
       $qa_url = site_url($segments);        
       $this->session->set_userdata('qa_url', $qa_url);    

       echo 'Index position: '. $idx;                      
       echo '<br>Topic: '. $topic;
       echo '<br>QA_ID: '. $this->array_container[$idx]->qa_id;
       echo '<br> End of Array: '. $condition;
       echo '<br>End of Array Segment: '. $array_init;
       echo '<br>Total array: '. $this->total_array .'<br>';
       $button_clicks = $this->get_button_clicks();
       echo '<br><br><Br>';
       echo 'Button clicked - yes: '. $button_clicks['yes'];
       echo '<br>Button clicked - no: '. $button_clicks['no'];
       $total_clicks = $button_clicks['yes'] + $button_clicks['no'];
       if($this->total_array === $total_clicks)
           if($this->total_array === $button_clicks['yes'])
               $this->result_msg = '<br>If that was an honest answers congrats!<br> Perfect answer.';
               $this->result_msg = 'S C O R E  <br> Right Answer: '. $button_clicks['yes'] .' <br> Wrong Answer: '. $button_clicks['no'];
       $this->session->set_userdata('result_msg', $this->result_msg);
       //Get question, answer, reference through an array key.
       $qa_data = $this->qa_mdl->get_data_by_id($this->array_container[$idx]->qa_id);
       $qa_data['yes'] = $button_clicks['yes'];
       $qa_data['no'] = $button_clicks['no'];
       $this->session->set_userdata('qa_data', $qa_data);

       $this->dryview2($header='templates/header', $msg='Welcome back ', $menu='templates/menu', $content='templates/landing_qa', $footer='templates/footer', $master='templates/landing_master2');
* PHP Array Driver methods
   //define the array_container once.
   public function set_array_container($language, $version, $topic)
       $this->array_container = $this->qa_mdl->get_qa_ids($language, $version, $topic);
   //save array_container to session
   public function save_array_2_session()
       $this->session->set_userdata('array_set', $this->array_container);
   //retrieve array_container from session
   public function fetch_array_from_session()
       return $this->session->userdata('array_set');
   //Count all elements in an array, or something in an object
   public function a_count($array_name)
       $result = count($array_name);
       //return $result;
       echo 'total indexes'. $result;
   #get the last index key
   public function get_last_idx_key()
       return key($this->array_container);          
   //save index position into session
   public function save_idx_position($idx)
       $this->session->set_userdata('idx_key', $idx);
   //retrieve index position from session
   public function get_idx_position()
       $idx_key = $this->session->userdata('idx_key');
       return $idx_key;
   //save counter position into session
   public function save_end_of_array($condition)
       $this->session->set_userdata('condition', $condition);
   //retrieve counter position from session
   public function get_end_of_array()
       $condition = $this->session->userdata('condition');
       return $condition;
   //Initialize button clicks value to zeros
   public function set_button_clicks()
       $button_clicks = array(
               'yes'  => 0,
               'no'     => 0,
       $this->session->set_userdata('button_clicks', $button_clicks);
   //record button clicks.
   public function record_button_clicks($button)
       //get button clicks from session first.
       $button_clicks = $this->get_button_clicks();
       //determine what button was clicked.
       if($button === 'yes')
           $button_clicks['yes'] += 1;
       if($button === 'no')
           $button_clicks['no'] += 1;
       //save click to array as session
       $this->session->set_userdata('button_clicks', $button_clicks);
   //ret nittpm c;ocls.
   public function get_button_clicks()
       return $this->session->userdata('button_clicks');
* These methods below are for testing purpose only
   public function ver()
       echo CI_VERSION;
   public function replace_word()
       $topic = 'built-in functions';
       $word_replaced = str_ireplace(" ", "_", $topic);
       echo $word_replaced;
   //Will get the cuurrent Q&A in an array
   public function current_qa($current_array, $current_pointer)
       //Get the current array
       //Get the current pointer (beginning)
       //Store the $current_pointer into session
       //if the user click the next button, pointer will also cal next() method
       //then store the $current_pointer into session again.
       //do this until the end of the array index/value
   public function dialog()


Thanks in advnce

  Bootstrap 4 almost beta?
Posted by: skunkbad - 06-17-2017, 06:49 PM - Forum: Lounge - Replies (2)

I've been following development of Bootstrap 4 for a long time, and the beta milestone is at 99%! I'm guilty of using the alpha v6 version for a couple of personal projects, and I'm really enjoying it.


At this rate, it could be a couple years before it's production ready, but it looks like progress is being made.

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.