Transferring the code to CodeIgniter Framework