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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 9,192
» Latest member: vjci
» Forum threads: 66,447
» Forum posts: 417,006

Full Statistics

Latest Threads
Server config causing CSR...
Forum: General Help
1 hour ago
» Replies: 2   » Views: 40
routing to IIS though I a...
Forum: Installation & Setup
3 hours ago
» Replies: 0   » Views: 9
dynamic input field valid...
Forum: CodeIgniter 3.x
4 hours ago
» Replies: 0   » Views: 26
Errors In Code
Forum: CodeIgniter 4 Support
9 hours ago
» Replies: 7   » Views: 196
Version/System update not...
Forum: General Help
Yesterday, 10:14 AM
» Replies: 3   » Views: 194
Multilingual site
Forum: Lounge
Yesterday, 09:36 AM
» Replies: 3   » Views: 185
encryption_key in CI 3.x
Forum: Installation & Setup
Yesterday, 08:12 AM
» Replies: 3   » Views: 204
oops in codeigniter
Forum: Choosing CodeIgniter
Yesterday, 06:02 AM
» Replies: 1   » Views: 187
Switch button active/inac...
Forum: General Help
Yesterday, 03:38 AM
» Replies: 3   » Views: 146
[Solved] Files-Sessions s...
Forum: General Help
Yesterday, 02:20 AM
» Replies: 2   » Views: 74

 
  Sitebuilder with Codeigniter
Posted by: ponzo - 08-17-2017, 04:58 AM - Forum: Lounge - Replies (1)

Previous year I build a sitebuilder with Codeigniter.  
I recorded a screencast for those who what to have a basic visual idea about it.
[/url]
[url=http://ponzo.nl/ponzotool.mp4]

After 10 months there is a proof of concept which has all the basic functionalities.
The problem is that I'm a designer and not a coder.  But although I managed to learn CodeIgniter, setup a VPS, grunt, sass, Cpanel cronjobs etc). But I'm not confident with the results. 

At the moment I don't know how to develop this Frankenstein of code to a lean Cinderella.
Ofcourse I could find some investors, hire people, but honestly the whole idea of this tool is not about profit, 
There is no clear business plan, there is no sign of earning money yet with this project.
I just started, and developed, learned and designed with one (big) testcase,

The problem is: 
The coders I asked to join are all busy earning big money, or they hate sitebuilders, or the find the project to big to contribute.
I think there are lot's of USP's I designed within the tool, and a focusgroup of designers are enthousiast (except for the bugs). So there is enough motivation for me to continue, but how?!  Confused

Any advice is welcome.


  [Solved] Database Driven Config Question
Posted by: wolfgang1983 - 08-17-2017, 04:56 AM - Forum: General Help - Replies (2)

I am working on a config file that I get my contents from database and set them in my config

application/config/setting.php

As you can see below I can require the database file fine,

Is there any way to be able to require codeigniter URI segments

Because currently I have to get segments like this  so would be better if I could use the url in my config file any ideas how to load url helper in my config file below 

cheers.


PHP Code:
$segments explode('/'trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$numSegments count($segments); 
$currentSegment 
$segments[$numSegments 3]; 

PHP Code:
<?php

$config 
= array();

require_once(
BASEPATH 'database/DB.php');

$db =& DB();

$db->where('type''config');
$query $db->get($db->dbprefix 'setting');

foreach (
$query->result_array() as $result) {
    
$config[$result['item']] = $result['value'];
}

$segments explode('/'trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$numSegments count($segments); 
$currentSegment $segments[$numSegments 3];

if (
$currentSegment == 'admin') {
    
$db->where('code'config_item('admin_language'));
} elseif (
$currentSegment != 'admin') {
    
$db->where('code'config_item('language'));
}

$lang_query $db->get($db->dbprefix 'language');

if (
$query->num_rows() > 0) {
    
$config['language']    = strtolower($lang_query->row()->name);
} else {
    
$config['language']    = 'english';


  Filename: libraries/Session/Session.php Line Number: 102
Posted by: Husnainkhan - 08-17-2017, 03:54 AM - Forum: General Help - Replies (4)

    I am student  i dont know anything about coding  when i put my scripts  in my website 
This type of error  i  am facing
Please  resolve  my issue  step by step 
Checkout problem on my website
My website  url is myviralhax.tk
A Database Error Occurred

Unable to connect to your database server using the provided settings.

libraries/Session/Session.php

Line Number: 102

This is session.php file 

PHP Code:
<?php
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP
 *
 * This content is released under the MIT License (MIT)
 *
 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @package    CodeIgniter
 * @author    EllisLab Dev Team
 * @copyright    Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
 * @copyright    Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
 * @license    http://opensource.org/licenses/MIT    MIT License
 * @link    http://codeigniter.com
 * @since    Version 2.0.0
 * @filesource
 */
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * CodeIgniter Session Class
 *
 * @package        CodeIgniter
 * @subpackage    Libraries
 * @category    Sessions
 * @author        Andrey Andreev
 * @link        http://codeigniter.com/user_guide/libraries/sessions.html
 */
class CI_Session {

    
/**
     * Userdata array
     *
     * Just a reference to $_SESSION, for BC purposes.
     */
    
public $userdata;

    protected 
$_driver 'files';
    protected 
$_config;

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

    /**
     * Class constructor
     *
     * @param    array    $params    Configuration parameters
     * @return    void
     */
    
public function __construct(array $params = array())
    {
        
// No sessions under CLI
        
if (is_cli())
        {
            
log_message('debug''Session: Initialization under CLI aborted.');
            return;
        }
        elseif ((bool) 
ini_get('session.auto_start'))
        {
            
log_message('error''Session: session.auto_start is enabled in php.ini. Aborting.');
            return;
        }
        elseif ( ! empty(
$params['driver']))
        {
            
$this->_driver $params['driver'];
            unset(
$params['driver']);
        }
        elseif (
$driver config_item('sess_driver'))
        {
            
$this->_driver $driver;
        }
        
// Note: BC workaround
        
elseif (config_item('sess_use_database'))
        {
            
$this->_driver 'database';
        }

        
$class $this->_ci_load_classes($this->_driver);

        
// Configuration ...
        
$this->_configure($params);

        
$class = new $class($this->_config);
        if (
$class instanceof SessionHandlerInterface)
        {
            if (
is_php('5.4'))
            {
                
session_set_save_handler($classTRUE);
            }
            else
            {
                
session_set_save_handler(
                    array(
$class'open'),
                    array(
$class'close'),
                    array(
$class'read'),
                    array(
$class'write'),
                    array(
$class'destroy'),
                    array(
$class'gc')
                );

                
register_shutdown_function('session_write_close');
            }
        }
        else
        {
            
log_message('error'"Session: Driver '".$this->_driver."' doesn't implement SessionHandlerInterface. Aborting.");
            return;
        }

        
// Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers
        
if (isset($_COOKIE[$this->_config['cookie_name']])
            && (
                ! 
is_string($_COOKIE[$this->_config['cookie_name']])
                OR ! 
preg_match('/^[0-9a-f]{40}$/'$_COOKIE[$this->_config['cookie_name']])
            )
        )
        {
            unset(
$_COOKIE[$this->_config['cookie_name']]);
        }

        
session_start();

        
// Is session ID auto-regeneration configured? (ignoring ajax requests)
        
if ((empty($_SERVER['HTTP_X_REQUESTED_WITH']) OR strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest')
            && (
$regenerate_time config_item('sess_time_to_update')) > 0
        
)
        {
            if ( ! isset(
$_SESSION['__ci_last_regenerate']))
            {
                
$_SESSION['__ci_last_regenerate'] = time();
            }
            elseif (
$_SESSION['__ci_last_regenerate'] < (time() - $regenerate_time))
            {
                
$this->sess_regenerate((bool) config_item('sess_regenerate_destroy'));
            }
        }
        
// Another work-around ... PHP doesn't seem to send the session cookie
        // unless it is being currently created or regenerated
        
elseif (isset($_COOKIE[$this->_config['cookie_name']]) && $_COOKIE[$this->_config['cookie_name']] === session_id())
        {
            
setcookie(
                
$this->_config['cookie_name'],
                
session_id(),
                (empty(
$this->_config['cookie_lifetime']) ? time() + $this->_config['cookie_lifetime']),
                
$this->_config['cookie_path'],
                
$this->_config['cookie_domain'],
                
$this->_config['cookie_secure'],
                
TRUE
            
);
        }

        
$this->_ci_init_vars();

        
log_message('info'"Session: Class initialized using '".$this->_driver."' driver.");
    }

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

    /**
     * CI Load Classes
     *
     * An internal method to load all possible dependency and extension
     * classes. It kind of emulates the CI_Driver library, but is
     * self-sufficient.
     *
     * @param    string    $driver    Driver name
     * @return    string    Driver class name
     */
    
protected function _ci_load_classes($driver)
    {
        
// PHP 5.4 compatibility
        
interface_exists('SessionHandlerInterface'FALSE) OR require_once(BASEPATH.'libraries/Session/SessionHandlerInterface.php');

        
$prefix config_item('subclass_prefix');

        if ( ! 
class_exists('CI_Session_driver'FALSE))
        {
            require_once(
                
file_exists(APPPATH.'libraries/Session/Session_driver.php')
                    ? 
APPPATH.'libraries/Session/Session_driver.php'
                    
BASEPATH.'libraries/Session/Session_driver.php'
            
);

            if (
file_exists($file_path APPPATH.'libraries/Session/'.$prefix.'Session_driver.php'))
            {
                require_once(
$file_path);
            }
        }

        
$class 'Session_'.$driver.'_driver';

        
// Allow custom drivers without the CI_ or MY_ prefix
        
if ( ! class_exists($classFALSE) && file_exists($file_path APPPATH.'libraries/Session/drivers/'.$class.'.php'))
        {
            require_once(
$file_path);
            if (
class_exists($classFALSE))
            {
                return 
$class;
            }
        }

        if ( ! 
class_exists('CI_'.$classFALSE))
        {
            if (
file_exists($file_path APPPATH.'libraries/Session/drivers/'.$class.'.php') OR file_exists($file_path BASEPATH.'libraries/Session/drivers/'.$class.'.php'))
            {
                require_once(
$file_path);
            }

            if ( ! 
class_exists('CI_'.$classFALSE) && ! class_exists($classFALSE))
            {
                throw new 
UnexpectedValueException("Session: Configured driver '".$driver."' was not found. Aborting.");
            }
        }

        if ( ! 
class_exists($prefix.$class) && file_exists($file_path APPPATH.'libraries/Session/drivers/'.$prefix.$class.'.php'))
        {
            require_once(
$file_path);
            if (
class_exists($prefix.$classFALSE))
            {
                return 
$prefix.$class;
            }
            else
            {
                
log_message('debug''Session: '.$prefix.$class.".php found but it doesn't declare class ".$prefix.$class.'.');
            }
        }

        return 
'CI_'.$class;
    }

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

    /**
     * Configuration
     *
     * Handle input parameters and configuration defaults
     *
     * @param    array    &$params    Input parameters
     * @return    void
     */
    
protected function _configure(&$params)
    {
        
$expiration config_item('sess_expiration');

        if (isset(
$params['cookie_lifetime']))
        {
            
$params['cookie_lifetime'] = (int) $params['cookie_lifetime'];
        }
        else
        {
            
$params['cookie_lifetime'] = ( ! isset($expiration) && config_item('sess_expire_on_close'))
                ? 
: (int) $expiration;
        }

        isset(
$params['cookie_name']) OR $params['cookie_name'] = config_item('sess_cookie_name');
        if (empty(
$params['cookie_name']))
        {
            
$params['cookie_name'] = ini_get('session.name');
        }
        else
        {
            
ini_set('session.name'$params['cookie_name']);
        }

        isset(
$params['cookie_path']) OR $params['cookie_path'] = config_item('cookie_path');
        isset(
$params['cookie_domain']) OR $params['cookie_domain'] = config_item('cookie_domain');
        isset(
$params['cookie_secure']) OR $params['cookie_secure'] = (bool) config_item('cookie_secure');

        
session_set_cookie_params(
            
$params['cookie_lifetime'],
            
$params['cookie_path'],
            
$params['cookie_domain'],
            
$params['cookie_secure'],
            
TRUE // HttpOnly; Yes, this is intentional and not configurable for security reasons
        
);

        if (empty(
$expiration))
        {
            
$params['expiration'] = (int) ini_get('session.gc_maxlifetime');
        }
        else
        {
            
$params['expiration'] = (int) $expiration;
            
ini_set('session.gc_maxlifetime'$expiration);
        }

        
$params['match_ip'] = (bool) (isset($params['match_ip']) ? $params['match_ip'] : config_item('sess_match_ip'));

        isset(
$params['save_path']) OR $params['save_path'] = config_item('sess_save_path');

        
$this->_config $params;

        
// Security is king
        
ini_set('session.use_trans_sid'0);
        
ini_set('session.use_strict_mode'1);
        
ini_set('session.use_cookies'1);
        
ini_set('session.use_only_cookies'1);
        
ini_set('session.hash_function'1);
        
ini_set('session.hash_bits_per_character'4);
    }

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

    /**
     * Handle temporary variables
     *
     * Clears old "flash" data, marks the new one for deletion and handles
     * "temp" data deletion.
     *
     * @return    void
     */
    
protected function _ci_init_vars()
    {
        if ( ! empty(
$_SESSION['__ci_vars']))
        {
            
$current_time time();

            foreach (
$_SESSION['__ci_vars'] as $key => &$value)
            {
                if (
$value === 'new')
                {
                    
$_SESSION['__ci_vars'][$key] = 'old';
                }
                
// Hacky, but 'old' will (implicitly) always be less than time() ;)
                // DO NOT move this above the 'new' check!
                
elseif ($value $current_time)
                {
                    unset(
$_SESSION[$key], $_SESSION['__ci_vars'][$key]);
                }
            }

            if (empty(
$_SESSION['__ci_vars']))
            {
                unset(
$_SESSION['__ci_vars']);
            }
        }

        
$this->userdata =& $_SESSION;
    }

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

    /**
     * Mark as flash
     *
     * @param    mixed    $key    Session data key(s)
     * @return    bool
     */
    
public function mark_as_flash($key)
    {
        if (
is_array($key))
        {
            for (
$i 0$c count($key); $i $c$i++)
            {
                if ( ! isset(
$_SESSION[$key[$i]]))
                {
                    return 
FALSE;
                }
            }

            
$new array_fill_keys($key'new');

            
$_SESSION['__ci_vars'] = isset($_SESSION['__ci_vars'])
                ? 
array_merge($_SESSION['__ci_vars'], $new)
                : 
$new;

            return 
TRUE;
        }

        if ( ! isset(
$_SESSION[$key]))
        {
            return 
FALSE;
        }

        
$_SESSION['__ci_vars'][$key] = 'new';
        return 
TRUE;
    }

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

    /**
     * Get flash keys
     *
     * @return    array
     */
    
public function get_flash_keys()
    {
        if ( ! isset(
$_SESSION['__ci_vars']))
        {
            return array();
        }

        
$keys = array();
        foreach (
array_keys($_SESSION['__ci_vars']) as $key)
        {
            
is_int($_SESSION['__ci_vars'][$key]) OR $keys[] = $key;
        }

        return 
$keys;
    }

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

    /**
     * Unmark flash
     *
     * @param    mixed    $key    Session data key(s)
     * @return    void
     */
    
public function unmark_flash($key)
    {
        if (empty(
$_SESSION['__ci_vars']))
        {
            return;
        }

        
is_array($key) OR $key = array($key);

        foreach (
$key as $k)
        {
            if (isset(
$_SESSION['__ci_vars'][$k]) && ! is_int($_SESSION['__ci_vars'][$k]))
            {
                unset(
$_SESSION['__ci_vars'][$k]);
            }
        }

        if (empty(
$_SESSION['__ci_vars']))
        {
            unset(
$_SESSION['__ci_vars']);
        }
    }

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

    /**
     * Mark as temp
     *
     * @param    mixed    $key    Session data key(s)
     * @param    int    $ttl    Time-to-live in seconds
     * @return    bool
     */
    
public function mark_as_temp($key$ttl 300)
    {
        
$ttl += time();

        if (
is_array($key))
        {
            
$temp = array();

            foreach (
$key as $k => $v)
            {
                
// Do we have a key => ttl pair, or just a key?
                
if (is_int($k))
                {
                    
$k $v;
                    
$v $ttl;
                }
                else
                {
                    
$v += time();
                }

                if ( ! isset(
$_SESSION[$k]))
                {
                    return 
FALSE;
                }

                
$temp[$k] = $v;
            }

            
$_SESSION['__ci_vars'] = isset($_SESSION['__ci_vars'])
                ? 
array_merge($_SESSION['__ci_vars'], $temp)
                : 
$temp;

            return 
TRUE;
        }

        if ( ! isset(
$_SESSION[$key]))
        {
            return 
FALSE;
        }

        
$_SESSION['__ci_vars'][$key] = $ttl;
        return 
TRUE;
    }

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

    /**
     * Get temp keys
     *
     * @return    array
     */
    
public function get_temp_keys()
    {
        if ( ! isset(
$_SESSION['__ci_vars']))
        {
            return array();
        }

        
$keys = array();
        foreach (
array_keys($_SESSION['__ci_vars']) as $key)
        {
            
is_int($_SESSION['__ci_vars'][$key]) && $keys[] = $key;
        }

        return 
$keys;
    }

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

    /**
     * Unmark flash
     *
     * @param    mixed    $key    Session data key(s)
     * @return    void
     */
    
public function unmark_temp($key)
    {
        if (empty(
$_SESSION['__ci_vars']))
        {
            return;
        }

        
is_array($key) OR $key = array($key);

        foreach (
$key as $k)
        {
            if (isset(
$_SESSION['__ci_vars'][$k]) && is_int($_SESSION['__ci_vars'][$k]))
            {
                unset(
$_SESSION['__ci_vars'][$k]);
            }
        }

        if (empty(
$_SESSION['__ci_vars']))
        {
            unset(
$_SESSION['__ci_vars']);
        }
    }

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

    /**
     * __get()
     *
     * @param    string    $key    'session_id' or a session data key
     * @return    mixed
     */
    
public function __get($key)
    {
        
// Note: Keep this order the same, just in case somebody wants to
        //       use 'session_id' as a session data key, for whatever reason
        
if (isset($_SESSION[$key]))
        {
            return 
$_SESSION[$key];
        }
        elseif (
$key === 'session_id')
        {
            return 
session_id();
        }

        return 
NULL;
    }

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

    /**
     * __set()
     *
     * @param    string    $key    Session data key
     * @param    mixed    $value    Session data value
     * @return    void
     */
    
public function __set($key$value)
    {
        
$_SESSION[$key] = $value;
    }

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

    /**
     * Session destroy
     *
     * Legacy CI_Session compatibility method
     *
     * @return    void
     */
    
public function sess_destroy()
    {
        
session_destroy();
    }

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

    /**
     * Session regenerate
     *
     * Legacy CI_Session compatibility method
     *
     * @param    bool    $destroy    Destroy old session data flag
     * @return    void
     */
    
public function sess_regenerate($destroy FALSE)
    {
        
$_SESSION['__ci_last_regenerate'] = time();
        
session_regenerate_id($destroy);
    }

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

    /**
     * Get userdata reference
     *
     * Legacy CI_Session compatibility method
     *
     * @returns    array
     */
    
public function &get_userdata()
    {
        return 
$_SESSION;
    }

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

    /**
     * Userdata (fetch)
     *
     * Legacy CI_Session compatibility method
     *
     * @param    string    $key    Session data key
     * @return    mixed    Session data value or NULL if not found
     */
    
public function userdata($key NULL)
    {
        if (isset(
$key))
        {
            return isset(
$_SESSION[$key]) ? $_SESSION[$key] : NULL;
        }
        elseif (empty(
$_SESSION))
        {
            return array();
        }

        
$userdata = array();
        
$_exclude array_merge(
            array(
'__ci_vars'),
            
$this->get_flash_keys(),
            
$this->get_temp_keys()
        );

        foreach (
array_keys($_SESSION) as $key)
        {
            if ( ! 
in_array($key$_excludeTRUE))
            {
                
$userdata[$key] = $_SESSION[$key];
            }
        }

        return 
$userdata;
    }

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

    /**
     * Set userdata
     *
     * Legacy CI_Session compatibility method
     *
     * @param    mixed    $data    Session data key or an associative array
     * @param    mixed    $value    Value to store
     * @return    void
     */
    
public function set_userdata($data$value NULL)
    {
        if (
is_array($data))
        {
            foreach (
$data as $key => &$value)
            {
                
$_SESSION[$key] = $value;
            }

            return;
        }

        
$_SESSION[$data] = $value;
    }

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

    /**
     * Unset userdata
     *
     * Legacy CI_Session compatibility method
     *
     * @param    mixed    $data    Session data key(s)
     * @return    void
     */
    
public function unset_userdata($key)
    {
        if (
is_array($key))
        {
            foreach (
$key as $k)
            {
                unset(
$_SESSION[$k]);
            }

            return;
        }

        unset(
$_SESSION[$key]);
    }

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

    /**
     * All userdata (fetch)
     *
     * Legacy CI_Session compatibility method
     *
     * @return    array    $_SESSION, excluding flash data items
     */
    
public function all_userdata()
    {
        return 
$this->userdata();
    }

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

    /**
     * Has userdata
     *
     * Legacy CI_Session compatibility method
     *
     * @param    string    $key    Session data key
     * @return    bool
     */
    
public function has_userdata($key)
    {
        return isset(
$_SESSION[$key]);
    }

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

    /**
     * Flashdata (fetch)
     *
     * Legacy CI_Session compatibility method
     *
     * @param    string    $key    Session data key
     * @return    mixed    Session data value or NULL if not found
     */
    
public function flashdata($key NULL)
    {
        if (isset(
$key))
        {
            return (isset(
$_SESSION['__ci_vars'], $_SESSION['__ci_vars'][$key], $_SESSION[$key]) && ! is_int($_SESSION['__ci_vars'][$key]))
                ? 
$_SESSION[$key]
                : 
NULL;
        }

        
$flashdata = array();

        if ( ! empty(
$_SESSION['__ci_vars']))
        {
            foreach (
$_SESSION['__ci_vars'] as $key => &$value)
            {
                
is_int($value) OR $flashdata[$key] = $_SESSION[$key];
            }
        }

        return 
$flashdata;
    }

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

    /**
     * Set flashdata
     *
     * Legacy CI_Session compatibiliy method
     *
     * @param    mixed    $data    Session data key or an associative array
     * @param    mixed    $value    Value to store
     * @return    void
     */
    
public function set_flashdata($data$value NULL)
    {
        
$this->set_userdata($data$value);
        
$this->mark_as_flash(is_array($data) ? array_keys($data) : $data);
    }

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

    /**
     * Keep flashdata
     *
     * Legacy CI_Session compatibility method
     *
     * @param    mixed    $key    Session data key(s)
     * @return    void
     */
    
public function keep_flashdata($key)
    {
        
$this->mark_as_flash($key);
    }

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

    /**
     * Temp data (fetch)
     *
     * Legacy CI_Session compatibility method
     *
     * @param    string    $key    Session data key
     * @return    mixed    Session data value or NULL if not found
     */
    
public function tempdata($key NULL)
    {
        if (isset(
$key))
        {
            return (isset(
$_SESSION['__ci_vars'], $_SESSION['__ci_vars'][$key], $_SESSION[$key]) && is_int($_SESSION['__ci_vars'][$key]))
                ? 
$_SESSION[$key]
                : 
NULL;
        }

        
$tempdata = array();

        if ( ! empty(
$_SESSION['__ci_vars']))
        {
            foreach (
$_SESSION['__ci_vars'] as $key => &$value)
            {
                
is_int($value) && $tempdata[$key] = $_SESSION[$key];
            }
        }

        return 
$tempdata;
    }

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

    /**
     * Set tempdata
     *
     * Legacy CI_Session compatibility method
     *
     * @param    mixed    $data    Session data key or an associative array of items
     * @param    mixed    $value    Value to store
     * @param    int    $ttl    Time-to-live in seconds
     * @return    void
     */
    
public function set_tempdata($data$value NULL$ttl 300)
    {
        
$this->set_userdata($data$value);
        
$this->mark_as_temp(is_array($data) ? array_keys($data) : $data$ttl);
    }

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

    /**
     * Unset tempdata
     *
     * Legacy CI_Session compatibility method
     *
     * @param    mixed    $data    Session data key(s)
     * @return    void
     */
    
public function unset_tempdata($key)
    {
        
$this->unmark_temp($key);
    }



  Pagination only displays the first 10 records
Posted by: Ajax30 - 08-17-2017, 01:05 AM - Forum: General Help - Replies (3)

I am trying to paginate a Codeigniter 3 application without using the framework's pagination library. More exactly, I want to paginate a table with about 100 rows. For this purpose:
In the home controller I have:

Code:
public function index() {
   $this->load->model('Customer');
   $this->load->library('pagination');
   $config = [
       'base_url' => base_url("index.php"),
       'per_page' => 10,
       'total_rows' => $this->Customer->get_num_rows(),
       'uri_segment' => 3,
       'first_tag_open' =>  '<li>',
       'first_tag_close' => '</li>',
       'last_tag_open' =>  '<li>',
       'last_tag_close' => '</li>',
       'full_tag_open' =>  '<ul class="pagination">',
       'full_tag_close' => '</ul>',
       'next_tag_open' =>  '<li>',
       'next_tag_close' => '</li>',
       'prev_tag_open' =>  '<li>',
       'prev_tag_close' => '</li>',
       'num_tag_open' =>   '<li>',
       'num_tag_close' =>  '</li>',
       'cur_tag_open' =>   '<li class="active"><a>',
       'cur_tag_close' =>  '</a></li>',
   ];
   $this->pagination->initialize($config);
   $customers = $this->Customer->getCustomers($config['per_page'], $this->uri->segment($config['uri_segment']));
   $this->load->view('home', ['records'=>$customers]);
}

In the Model file I have:
Code:
class Customer extends CI_Model {
public function __construct() {
   $this->load->database();
}

public function getCustomers($limit, $offset) {
   $this->db->limit($limit, $offset);
   $query = $this->db->get('customers');
   return $query->result();
}
}

Finaly, the view:
Code:
<div class="pagination-container text-center">
   <?php echo $this->pagination->create_links(); ?>
</div>

The pagination is displayed and properly formatted; so are the first 10 records

[Image: 1Roe3.png]


But if I click on page 2, or any other page, I get the same first 10 records as can be seen in the image below:

[Image: 7lEzB.png]

The url of page 2 is:

Code:
http://localhost/cicrud/index.php?page=2


I did something wrong, I can't understand what. Any help? Thank you!


  share data between server applications
Posted by: nasser.man - 08-17-2017, 12:15 AM - Forum: Best Practices - Replies (8)

I have 3 server that same server application is running on each of them. each installation of server app has its own configurations, data and settings. other client users or client applications can connect to this servers and communicate with them.

but now i need to share some data between this server applications. for example server A needs to access to information of server B's customers. or main admin of system want to see some information of server C. other scenario may be back up/sync. each server with 4th server with special application.

this servers are in different places.

this application are created by PHP and servers are ubuntu servers, each server has its own static IP.

how i can do this? any one done same thing before and how? witch is the more secure way?


  Geolocation Library
Posted by: chrislim2888 - 08-17-2017, 12:12 AM - Forum: Addins - No Replies

I have updated my geolocation library https://github.com/ip2location/codeigniter-ip2location to work in CodeIgniter 3.x. Please update the plugin to the latest if you currently used the old version to run with. 

I haven't done the testing for CodeIgniter 4, but will do so when the v4.0 release to production Rolleyes


  What should we call the CLI tool?
Posted by: kilishan - 08-16-2017, 09:40 PM - Forum: CodeIgniter 4 Development - Replies (20)

There's been a few people bring up the idea of getting rid of the .php extension from our CLI tool, currently called ci.php. However, there's an existing Linux command, ci so I don't want to simply rename it to that. having a good idea coming up with a better name for it, however, so help a brother out - what's your idea for our CLI tool name?


  Performance Problem [solved]
Posted by: bitwiz - 08-16-2017, 06:46 PM - Forum: General Help - Replies (17)

I'm building a codeigniter project and I'm experiencing a strange performance problem. This issue is encountered on every single page of the site.

Environment:
Dell Poweredge R720XD, Dual E5-2660 CPUs, 100GB RAM, 2x Boot SSDs running CentOS 7 as a VM host, 10x 1.2TB SAS in RAID6 for VM storage, ISPConfig 3 installed on a CentOS 7 VM as a guest. We followed the CentOS 7 perfect server guide and our company has been running the ISPConfig hosting control panel for about 10 years, so we're very familiar with the server configuration.

The website is hosted on a guest VM with a 4 other sites - so not a lot of activity or load here. There are a couple other VMs on this server, but they are for our company of 3 people and there's practically zero activity across all VMs. All our VMs respond quickly as expected. We plan to move more hosting accounts onto this server at some point, but right now it's virtually empty. We have a 25mbps x 25mbps fiber connection.

I also recently upgraded the site to the latest CI version, so it's current.

CI Symptoms:
1. Initial page load is extremely fast. A tiny fraction of a second.
2. If I click a link in the site, the next page loads slower, approx 15-30 seconds, then suddenly loads instantly.
3. If I then click again, the site hangs for upwards of 3 minutes, then after sitting and waiting the page suddenly loads instantly.

Likewise, below will also produce the same effect:

1. Load a page - instant.
2. Refresh the page, slower, around 15-30 seconds.
3. Refresh the page again, hangs for up to 3 minutes, then suddenly loads instantly.

I've added debug to the code and it confirms the software times are huge, but there's no activity during the hanging. The loading indicator in the browsers just sit and spin. Yes I've tested it cross-browser, it's not the browser.

I've switched caching between the DB and Files. No effect.

I've scoured through the code and minimized database calls, there's no database activity during these random hangs, there's no DB activity at all.

Running the "top" command on the server shows no activity during one of these tests.

We are using MariaDB as the MySQL engine. No errors in the server logs or hosting logs. I own and run the server.

What could be happening? It seems like some strange compatibility problem between CI and Apache or PHP. This web server also hosts a couple other sites: Wordpress and Prestashop, neither of which show these symptoms.

I have bandwidth monitoring on our internet connection, no bandwidth activity during these tests.

I have PHP 5.6 is installed on the server.

I think I would see 100% CPU activity on one processor thread if my code was getting stuck in a loop somewhere.

If I wait for a while (not sure how long - roughly 5-10 minutes), a page load is nearly instant again, but no visitor will wait 5-10 minutes between clicks!

I'm at a loss how to diagnose and/or fix this issue. Obviously visitors aren't going to wait 5-10 minutes between clicks to get a fast response. CI gurus, HELP! What do I do? Where can I look? What tools would you use to figure out what's going wrong? Have you seen this before in your own code development? Any thoughts what else could be the culprit or where to look?

Thanks for any assistance!


  You must use the "set" method to update an entry.
Posted by: Edel - 08-16-2017, 03:24 PM - Forum: CodeIgniter 4 Support - Replies (2)

I am here again.
I want to use the save method of the model class


the code In my controller:

PHP Code:
$data $this->request->getPost();
$model = new \App\Models\MyModel();
$model->save($data); 


My Model:
Code:
protected $table      = 'user';
protected $primaryKey      = 'id_user';
protected $returnType = '\App\Entities\E_User';



the problem is the server returns
"You must use the "set" method to update an entry."
In the user guide the set method is used in database Builder class but not say nothing about the relationship between set and save methods.

so How can I use the save method.?


  How to display .chm file using embed tag?
Posted by: hamid - 08-16-2017, 02:40 PM - Forum: General Help - Replies (1)

I can preview PDF file in embed tag but cannot see the preview of .chm file.
Please suggest me.



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