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



Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,441
» Latest member: sushant
» Forum threads: 65,877
» Forum posts: 413,880

Full Statistics

Latest Threads
Where to store static arr...
Forum: General Help
4 minutes ago
» Replies: 3   » Views: 21
Unsetting Session In Arra...
Forum: General Help
1 hour ago
» Replies: 1   » Views: 55
XML error: Invalid docume...
Forum: CodeIgniter 2.x
3 hours ago
» Replies: 4   » Views: 80
CSV Importing Advice
Forum: General Help
9 hours ago
» Replies: 6   » Views: 192
Are there any CodeIgniter...
Forum: Jobs
Yesterday, 11:24 PM
» Replies: 4   » Views: 190
Redirect doesn't work wit...
Forum: General Help
Yesterday, 10:40 PM
» Replies: 7   » Views: 355
How to format template?
Forum: Model-View-Controller
Yesterday, 03:59 PM
» Replies: 6   » Views: 360
Forum: General Help
Yesterday, 02:38 PM
» Replies: 0   » Views: 45
How to Get Banned
Forum: News & Discussion
Yesterday, 12:08 PM
» Replies: 12   » Views: 7,351
Create custom link url fo...
Forum: General Help
Yesterday, 11:47 AM
» Replies: 5   » Views: 219

  Is my code OK any room for improvment
Posted by: wolfgang1983 - 04-18-2017, 11:35 PM - Forum: General Help - Replies (1)

Hello, On my function below I load modules in to set module positions

I just would like to know if the code could be improved if so how so? 

I am getting the expected result just not sure if could improve it.

[Image: 3JZiFYzj8Vdl.png]

PHP Code:

class Welcome extends CI_Controller {


    public function 
__construct() {
$this->page $this->router->class;


    public function 
index() {        
$modules $this->layout_model->getlayoutmodules($this->page);

$modules_content = array();

// Module Data Content
if ($modules) {
            foreach (
$modules as $module) {
$modules_name $module['modules_name'];

              // Load module library

$this->load->library('module/' $modules_name);

// Returns data only
$module_data $this->$modules_name->get();

                if (
$module_data) {

                   // Load the module view
    $modules_content[$module['position']]['modules'][] = $this->load->view('module/' $modules_name$module_dataTRUE);

// Positions with modules
if ($modules_content) {
            foreach (
$modules_content as $key => $value) {    
$data[$key] = $this->load->view($key$modules_content[$key], TRUE);

// Positions with no modules
$layouts_positions_with_no_modules $this->layout_model->get_non_active_layouts_positions($this->page);

        foreach (
$layouts_positions_with_no_modules as $position) {
$data[$position] = '';



PHP Code:

class Layout_model extends CI_Model {

    public function 
getlayoutmodules($page) {
$this->db->select('l.*, m.*, lp.*');
$this->db->from('layouts l');
$this->db->join('modules m''m.modules_id = l.modules_id');
$this->db->join('layouts_positions lp''lp.layout_position_id = l.layout_position_id');
$query $this->db->get();

        if (
$query->num_rows() > 0) {



    public function 
get_active_layouts_positions($page NULL) {
   $this->db->from('layouts l');
   $this->db->join('layouts_positions lp''lp.layout_position_id = l.layout_position_id''LEFT');
   $query $this->db->get();
        if (
$query->num_rows() > 0) {


    public function 
get_non_active_layouts_positions($page NULL) {
$data = array();

        foreach (
$this->get_active_layouts_positions($page) as $position) {
   $this->db->where('layout_position_id !='$position['layout_position_id']);

$query $this->db->get('layouts_positions');

       if ($query->num_rows() > 0) {

           foreach ($query->result_array() as $result) {
               $data[] = $result['position']; 


    public function 
getlayoutpositions() {
$query $this->db->get();

        if (
$query->num_rows() > 0) {


  NTier architecture and CodeIgniter
Posted by: antony - 04-18-2017, 07:13 PM - Forum: Model-View-Controller - Replies (3)

Hello everyone!

Firstly, let me thank all of you volunteers who are in this forum, this is such an amazing and underrated framework!

I've got an architecture question which has been bugging me for a small while here.
Recently, I have been working on a huge (work) project which uses the N-Tier architecture, and I am now confused on its DTO and DAO aspect within CI.

For those unfamiliar with the ntier architecture, here is a quick summary of both those terms. 
A DTO, which stands for Data Transfer Object, is what should be returned by the models. 
 It does not contain accès to the database, as this logic is in the DAO.
A DAO, which stands for Data Access Object, which is whatever method you use to access your data.

In my case, I'm trying to port my user login to such an architecture, with typed data.
In CodeIgniter, I would call my users model and use a method such as getUserFromId($id), where the model would act as DAO and return a DTO. 

As I'm working towards having a lot of abstraction, here is how I currently planned on structuring my folders:

 - Models
 |-- IUserDAO
 |-- MariaDB
    |-- UserDaoImpl
 |-- DTO
    |-- IUser
    |-- Impl
       |-- UserImpl

As you can see, this doesn't seem very clean.
It feels wrong to have the DTO folder inside the Models folders, yet I can't seem to find a better place.

In a usual project, I would have both a DTO and DAO folder but there does not seem to be such a predefined folder in CI. 
Perhaps I should create it, but I preferred asking here first Smile

Update: While writing this post, I've had a quick look in newmythmedia's blog and it seem Entities would solve my problems.
Leaving this question up if I'm mistaken 

On an unrelated note, here are few other questions not worthy of a post themselves I'd like to ask:
 - Are there any medium-big open-sourced projects using CI?
    I'd like to navigate into the architecture of decently-sized projects for inspiration.

 - CI4: While I only had a quick glance over the proposed changes, would you recommend waiting for CI4 until making an architecture revamp (which would take few months) or waiting until it is out before attempting this change?

  API authentication for android application
Posted by: Angelo - 04-18-2017, 06:05 PM - Forum: General Help - Replies (2)

Hello everyone, all right?

Has anyone ever created any api with authentication for mobile applications with codeigniter? It is a simple api where the user logs in and can consume her data in json form.

If anyone has any tutorial to tell me, or something to help me beat the stones, I'm grateful.


  Codeigniter Protector BETA
Posted by: napa - 04-18-2017, 04:54 PM - Forum: Addins - No Replies

Hi, this is my fist time in the forum, sorry for my bad english. I have been using Codeigniter for last 4 years and have make a lot of libraries for my own, so i want to share some service i publish today.

please feel free to make any comments and help me with beta testing http://www.securitynation.com

Codeigniter Protector Features:

-Crypt any of your php files inside codeigniter.
-Protect with time limit the application. (Make trials for your clients)
-Protect copy or use in others domains (Just run inside licensed domain)
-Inject a variable inside every page $GLOBALS['license'] with all info.
-Make some limits for users, like how much users will be in the app. (just inject variable)

Code is not obfuscated, it get really crypted with AES 256. is not hacker proof, but is the best tool i have found.. (And it's mine!)


1.- Create a key.php file, this is the key for running software in anyplace.
2.- Get your KeyID, this is needed for crypting files, must be saved only for you.
3.- Get the CIDecrypter.php Library into library folder of Codeigniter.
4.- Crypt your PHP files! and have fun!

  German User
Posted by: Rufnex - 04-18-2017, 08:46 AM - Forum: Regional User Groups - Replies (3)

Hallo Leute,

vor längere Zeit habe ich mal eine dt. Forum eingerichtet, was mangels Nachfrage wieder eingestellt wurde. Die Idee für einen dt. Support für CI schlummer nach wie vor in mir, daher möchte ich auf diesem Weg nachfragen, wieviele deutsche Anwender CI verwenden. Jeder der sich angesprochen fühlt, kann gerne einfach einen Beitrag mit

+1-1  ( privat und beruflich)
+1-0 ( nur privat)

erstellen ;o) 


  Custom Exception & get_instance()
Posted by: petewulf1 - 04-18-2017, 05:21 AM - Forum: General Help - Replies (4)

Hello guys,

i was searching for hours to find a solution to generate usable 404 errors in CI, but i think this section is not well integrated in CI:

When extending the CI Exception class, there is no way to get the instance with "get_instance()" because as what i've seen, CI isn't loading the core before the Exception controller. 
I need some basic functions to generate my 404 error pages, so this behavious is completely useless for me as it only handles static output.

If i use the method with 404_override in the config file, it works well, i can use the whole CI core functions but it is also not thought to end because sometimes i need to call show_404() manually which shows the ugly default error from the CI Exception class which leads to the problems above.

So there are 2 ways of integrating, but none of them is really usable. 
Sounds like a joke to me...

Has anyone solved this problem without modifying the core? 

Thanks in advance,

  [Solved] inner foreach loop not displaying correct amount of modules
Posted by: wolfgang1983 - 04-18-2017, 04:23 AM - Forum: General Help - Replies (1)

On my set_positions foreach loop I load modules in side that foreach loop. I have two modules set at the moment. 

But only one of them is showing for some reason should be another under it.

As shown here in image 

[Image: 3JU5XOtHqfFL.png]
The slide show module should show above the Question Help but as you can see below only one is showing in image

[Image: 3JU6L2jhu34P.png]

Question how can I make sure I can get all modules set for that position.

PHP Code:
public function index() {
$set_positions $this->getlayoutpositions($this->router->class);

foreach (
$set_positions as $set_position) {

$page_data['modules'] = array();

$modules $this->getmodules($set_position['module_id']);

foreach (
$modules as $module) {
$module_name $module['module_name'];

$this->load->library('module/' $module_name);

$page_data['modules'][] = $this->load->view('module/' $module_name$this->$module_name->get(), TRUE);


$data[$set_position['position']] = $this->load->view($set_position['position'], $page_dataTRUE);


$positions_not_set $this->getpositions($set_positions);

foreach (
$positions_not_set as $position_not_set) {
$page_data['modules'] = array();

$data[$position_not_set['position']] = $this->load->view($position_not_set['position'], $page_dataTRUE);


Model functions

PHP Code:
public function getpositions($positions = array()) {

    foreach (
$positions as $position) {
$this->db->where('position_id !='$position['position_id']);

$query $this->db->get();

public function 
getlayoutpositions($page) {
$this->db->select('l.*, p.position');
$this->db->from('layouts l''LEFT');
$this->db->join('positions p''p.position_id = l.position_id''LEFT');
$query $this->db->get();

public function 
getmodules($module_id) {
$query $this->db->get('module');

Attached Files
.php   Welcome.php (Size: 1.94 KB / Downloads: 10)

  Cutter Template Library (CI3)
Posted by: anovsiradj - 04-18-2017, 04:18 AM - Forum: Addins - No Replies

Hello everyone.., I want to share my library for template view. It's called Cutter. For CI3 only

Basically it was extending CI core view, and add more functionalty on it.

main functionalty on this library is (i dont know what it's called) block-template.

TL;DR. example:

PHP Code:
class Homepage extends CI_Controller {

    public function 
$offset 10;
$this->cutter->view('post/list', array('pagination_current_offset' => $offset));

create file layout.cutter.php in view directory.

PHP Code:
<!DOCTYPE html>
link rel="stylesheet" href="assets/style.css"/>
php cutter_field('css-section'?>
        <?php cutter_field('content-section'?>

    <script src="assets/main.js"></script>
    <?php cutter_field('js-section'?>

and then, create file post/list.cutter.php in view directory

PHP Code:
<?php cutter_start('content-section'?>
        <li>new codeigniter release</li>
        <li>how to make fancy-cool website</li>
        <li>my first post</li>
<?php cutter_end() ?>

<?php cutter_start('js-section'?>
$.ajax('/service/data', function() {
<?php cutter_end() ?>

<?php cutter_start('css-section'?>
<link rel="stylesheet" href="assets/custom.css"/>
<?php cutter_end() ?>

you can get the library at: https://github.com/anovsiradj/codeigniter-cutter

that's all.   Big Grin sorry for my english

Lightbulb use CI as micro engine without views folder
Posted by: ardavan - 04-18-2017, 03:12 AM - Forum: General Help - Replies (4)

Hi guys,

I'm working on a project which is an engine to do something based on inputs.
This project is using controller and model only to read / save manipulated data or return some results to the referrer URL.

I wanna hide this engine-CI view pages from users who wants to have direct access to the views or search engines.
My question is how to delete/redirect/block the direct URLs to my engine-CI?

Thanks guys

Attached Files Thumbnail(s)

  how can i get system mac address
Posted by: demonicinn - 04-17-2017, 11:09 PM - Forum: General Help - Replies (3)

i'm using this code

function get_real_mac_addr(){
system('ipconfig /all');
$findme = "Physical";
$pmac = strpos($mycom, $findme);
return $mac;

its working in localhost and get mac address but in live server its not working

how can i get mac address in live server??

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