Giter Site home page Giter Site logo

bcit-ci / codeigniter Goto Github PK

View Code? Open in Web Editor NEW
18.3K 1.6K 7.6K 53.49 MB

Open Source PHP Framework (originally from EllisLab)

Home Page: https://codeigniter.com/

License: MIT License

PHP 97.32% HTML 1.35% Makefile 0.23% Python 0.57% JavaScript 0.32% CSS 0.12% Shell 0.09%
php php7 php8 php-framework

codeigniter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter's Issues

Cache.php#save behavior depending on the adapter method

Hi,

Adapter currently available (dummy, file, apc, memcached) of, file, apc on, save method, but the behavior of the data to be overwritten, memcached on, not over, they become new additions.

Maybe, but I think a small mistake, such as implementing a fundamentally different behavior using the same interface, so I think that is wrong, memcached think is right even if the override.

Memcache:: add instead the following Memcache:: set method that I think is right.
http://www.php.net/manual/en/memcache.set.php

=== system/libraries/Cache/drivers/Cache_file.php ===
{{{

!php

public function save($id, $data, $ttl = 60)
{       
    $contents = array(
            'time'      => time(),
            'ttl'       => $ttl,            
            'data'      => $data
        );

    if (write_file($this->_cache_path.$id, serialize($contents)))
    {
        @chmod($this->_cache_path.$id, 0777);
        return TRUE;            
    }

    return FALSE;
}

}}}

=== system/libraries/Cache/drivers/Cache_apc.php ===
{{{

!php

public function save($id, $data, $ttl = 60)
{
    return apc_store($id, array($data, time(), $ttl), $ttl);
}

}}}

=== system/libraries/Cache/drivers/Cache_memcached.php ===
{{{

!php

public function save($id, $data, $ttl = 60)
{
    return $this->_memcached->add($id, array($data, time(), $ttl), $ttl);
}

}}}

Cache with APC doesn't cache Object

Someone forgot to serialize and unserialize content before saving it to the APC (in Cache_apc.php). That is the reason why do not store objects for example.

Cache_XCache Driver

Hi,

I have implemented a rudimentary XCache Driver for my uses at work. Just wanted to share it with you. Maybe you wanna add it to the branch.

Thanks

La funcion $this->input->is_ajax_request() no funciona con formularios multipart

La funcion $this->input->is_ajax_request() no funciona con formularios multipart:

En mi caso tengo un formulario sencillo:
un campo texto y un campo imagen, al enviar el formulario usando el plugin jquery.form la funcion $this->input->is_ajax_request() me devuelve FALSE siendo que deberia devolver TRUE puesto que estoy enviando el formulario por AJAX.

uri_string is nto returning a starting slash

In core uri_string() returns /blabla/bla while in reactor it returns blabla/bla.
According to docs it should return a starting slash.

In core before they return the uri_string
{{{

!php

if ($parsed_uri != '')
{
$parsed_uri = '/'.$parsed_uri;
}
return $parsed_uri;
}}}

Security.php - CSRF cookie name = token name

$config['csrf_token_name'] is set to $config['csrf_token_name'].

I found this is Security.php in __construct()

{{{

!php

// Append application specific cookie prefix to token name
$this->csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->csrf_token_name : $this->csrf_token_name;
}}}

Should it not be...

{{{

!php

// Append application specific cookie prefix to token name
$this->csrf_token_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->csrf_token_name : $this->csrf_token_name;
}}}

get_metadata in Cache_file.php fails

get_metadata() in File cache never returns valid data.

Line 160 in /system/libraries/Cache/drivers/Cache_file.php looks like it’s the problem:

Lines 160-171 shown below:
$data = $data['data'];

$mtime = filemtime($this->_cache_path.$id);

        if ( ! isset($data['ttl']))
        {
            return FALSE;
        }

        return array(
            'expire'     => $mtime + $data['ttl'],
            'mtime'        => $mtime
        ); 

If I do a print_r of $data, it contains [‘ttl’]. However assigning $data = $data[‘data’] does not work here, as it loses the metadata. So the function can never return the array.

Line 160 should be removed / commented out, and then it’ll work.

Library Form_validation ¿bug?

Hi! For me, this behavior is a bug.

The form validation library does not return false if a set of functions does not exist.

For example:

{{{

!php

  // Ej. $this->input->post('text-to-test') = "hello world!";

    $this->form_validation->set_rules('text-to-test', 'Text to test' , 'not_exist|asd');

if ($this->form_validation->run() == FALSE)
{
    echo 'BAD!'
}
else
{
    echo 'GOOD!'
}

}}}

This controller, show 'GOOD!'...

This strikes me as dangerous, an input error can have it either.

For me, if some of the functions set does not exist, the implementation should return false.

PD. Sorry for my bad english... i'm speak spanish...

CodeIgniter attempts to validate data it didn't create and crashes

In system/core/Input.php::_sanitize_globals(), CodeIgniter checks all the cookies on the current domain, and crashes the app (in _clean_input_keys()) if one of the cookie names is considered invalid.

The problem is that CI is also checking cookies that it didn't create. So, for example, if a website on the same domain created a cookie that CI doesn't like, it's going to crash, even though the other website might be completely unrelated.

This is easy to test with Glype, which creates cookies with names such as "c[nameofwebsite.com][/][authtoken]":

  • Put a clean install of Glype (http://www.glype.com/downloads.php) and a clean install of CI on the same domain.
  • Run Glype once then run CI.
  • CI crashes even though it's a clean install.

I think this is a big problem because it means CI can randomly crashes when things outside of its own environment change. For now, the problem can be "fixed" by clearing the cookies, but a permanent solution would obviously be better.

now() in Date Helper returns wrong timestamp

I'm re-posting this from the CI forums (http://codeigniter.com/forums/viewthread/169964/):

The now() function of the Date helper returns a timestamp that (for me) is 5 hours ahead of actual UTC time. To the best of my knowledge, this is what’s happening:

In the ‘system/helpers/date_helper.php’ file on line 47 (as well as system/libraries/Session.php line 623), the timestamp is being formed by several gmdate() functions combined within a mktime() function. The problem with this: gmdate() outputs a GMT/UTC-based date/time, and mktime() does as well. Therefore, we’re doubling our efforts here and converting to UTC twice. That would certainly explain why now() output a timestamp 5 hours ahead of the actual UTC time (for me since I’m in America/Chicago).

Instead of using mktime(), CodeIgniter should be using gmmktime() since it expects to receive GMT/UTC values. When I changed line 47 to reflect this, the problems noted in my previous post vanished. Now, that said…

I STILL DO NOT UNDERSTAND THE POINT OF THE now() FUNCTION. Was there a time or are there certain installations of PHP where time() will return a Unix timestamp referencing the timezone set for PHP? That’s the only reason I can think of that would explain why this function exists. I'm flummoxed. Someone please set me straight here.

Active Record Join Multiple conditions

If there is a JOIN with multiple conditions it does not escape everything

For example:
{{{

!php

->join('tasks', 'projects.id = tasks.project_id AND tasks.deleted=0', 'left')
}}}

does not add the table prefix to the condition tasks.deleted=0

#77 Transaction Test Mode is not working (all drivers)

Quote from [[https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all|"https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all"]]

The documentation specifies a capability of rolling back any transaction regardless of the success of the queries for testing purposes (see user guide under Database Library > Transactions > Test Mode).

This feature however is broken. See below for the resolution.

Affected files (system/database/drivers/_/__driver.php):

* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysql/mysql_driver.php#cl-216
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysqli/mysqli_driver.php#cl-217
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/oci8/oci8_driver.php#cl-326
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/odbc/odbc_driver.php#cl-196
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/postgre/postgre_driver.php#cl-219
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/sqlite/sqlite_driver.php#cl-213 

The following line uses _trans_failure which is not defined elsewhere:

$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;

Replace the above with:

$this->_trans_status = ($test_mode === TRUE) ? FALSE : $this->_trans_status;

Image Library text_watermark placement.

The vertical placement of text when using TTF's seems a bit erratic. On looking through the code for the text_watermark() method in Image_lib.php, I find:

{{{

!php

$fontwidth = $this->wm_font_size-($this->wm_font_size/4);
$fontheight = $this->wm_font_size;
$this->wm_vrt_offset += $this->wm_font_size;
}}}

On my develoment system, I've replaced this with the following using the php imagettfbbox function to determine the boundaries of the text. It seems to give a much more accurate result.

{{{

!php

$wm_text_box = imagettfbbox($this->wm_font_size,0,$this->wm_font_path,$this->wm_text);
$wm_text_width = $wm_text_box[2] - $wm_text_box[0];
$wm_text_height = $wm_text_box[1] - $wm_text_box[7];
$fontheight = $wm_text_height;
$fontwidth = $wm_text_width/strlen($this->wm_text);
$this->wm_vrt_offset += $fontheight;
}}}

csrf_verify() fails on AJAX calls

On AJAX calls, the following validation that is a part of the Security class csrf_verify() function evaluates and triggers the $this->csrf_show_error() function:

// Do the tokens exist in both the _POST and _COOKIE arrays?
<?php
if ( ! isset($_POST[$this->_csrf_token_name]) OR ! isset($_COOKIE[$this->_csrf_cookie_name]) )
{
    $this->csrf_show_error();
}

I'm passing on the ci_csrf_token post variable in my AJAX call, so $_POST[$this->_csrf_token_name] is assigned the proper hash set in the hidden form field generated by form_openl, but $_COOKIE[$this->_csrf_cookie_name] has no value assigned to it, therefore triggering the error.

database cache directory

On fresh install the APP cache directory contains .htaccess and index.html file.
If you setup the database cache to
$db[$active_group]['cachedir'] = APPPATH.'cache/';
and after that you use the
$this->db->cache_on();
it will create the required structure on that cache folder.
The problem is when you use
$this->db->cache_delete_all();
It delete everything from that directory - including .htaccess file and the index.html file which could result in some potentials security holes.

Form validation: set_select() re-population with arrays as field names

I can't get re-population working for my select boxes while using arrays as field names, which I believe is due to a bug. Check the following post for details about what I am trying to do: http://codeigniter.com/forums/viewthread/178442/

The set_value() was buggy as well but recently got fixed: https://bitbucket.org/ellislab/codeigniter-reactor/changeset/19fc3732e593

The current set_select() function checks, when it's an array, if the selected value is in the POST array for the current field name. When you select different options from the select boxes there will be a few different values in the POST array. This will result in select boxes where multiple options will have the 'selected="selected"' added to it. I hope you understand what I mean.

For example: I have 3 select boxes with example[] as name and 'example-1', 'example-2' and 'example-3' as options. Select 'example-1' for the first, 'example-2' for the second and 'example-3' for the third select box, hit the submit button and make sure the form validation fails. Now set_select() should do the re-population for the 3 example[] select boxes. But all options from all the select boxes will get the 'selected="selected"' added to it :(

#77 Transaction Test Mode is not working (all drivers)

Quote from [[https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all|"https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all"]]

The documentation specifies a capability of rolling back any transaction regardless of the success of the queries for testing purposes (see user guide under Database Library > Transactions > Test Mode).

This feature however is broken. See below for the resolution.

Affected files (system/database/drivers/_/__driver.php):

* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysql/mysql_driver.php#cl-216
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysqli/mysqli_driver.php#cl-217
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/oci8/oci8_driver.php#cl-326
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/odbc/odbc_driver.php#cl-196
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/postgre/postgre_driver.php#cl-219
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/sqlite/sqlite_driver.php#cl-213 

The following line uses _trans_failure which is not defined elsewhere:

$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;

Replace the above with:

$this->_trans_status = ($test_mode === TRUE) ? FALSE : $this->_trans_status;

Can't Replace core classes in 2.0.0

in system/core/Common.php line 127~129 says:
// Look for the class first in the native system/libraries folder
// thenin the local application/libraries folder
foreach (array(BASEPATH, APPPATH) as $path)

thus, we can't replace any core classes,
plz fix, thanks!

odbc error

ErrorException [ Fatal Error ]: Call to undefined method CI_DB::CI_DB()
FCPATH/system\database\drivers\odbc\odbc_driver.php [ 53 ]

wow no patch till now..

#77 Transaction Test Mode is not working (all drivers)

Quote from [[https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all|"https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all"]]

The documentation specifies a capability of rolling back any transaction regardless of the success of the queries for testing purposes (see user guide under Database Library > Transactions > Test Mode).

This feature however is broken. See below for the resolution.

Affected files (system/database/drivers/_/__driver.php):

* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysql/mysql_driver.php#cl-216
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysqli/mysqli_driver.php#cl-217
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/oci8/oci8_driver.php#cl-326
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/odbc/odbc_driver.php#cl-196
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/postgre/postgre_driver.php#cl-219
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/sqlite/sqlite_driver.php#cl-213 

The following line uses _trans_failure which is not defined elsewhere:

$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;

Replace the above with:

$this->_trans_status = ($test_mode === TRUE) ? FALSE : $this->_trans_status;

Problem when inserting special characters into input-fields, resulting in blank $this->input->get_post("title")

Hi there,

I have a problem with special characters. I want to input text like "Ich wünschte es wäre Samstag", but the validation class won't validate it and returns an error. If I comment out the validation rules, it runs trough the script but inserts "" (blank) into the database. This only happens, when I try to input special characters (ä, ö, ü, etc.), non-special characters work fine.

The weird thing is, that this bug only happens with PHP 5.3.5. When I switch to PHP 5.2.17 everything works fine.

Here's some of my code:
{{{

!html

}}}

{{{

!php

$this->load->library("form_validation");
$this->form_validation->set_rules("title", "Title", "trim|required|xss-clean|max_length[1000]");

if ($this->form_validation->run()) == FALSE) {
// Load 'fail-form'
} else {
// Escape data and insert into db
// Display 'success-page'
}
}}}

{{{

!text

Here's my test-input:
title = "I wish today would be Saturday"
result = validates fine, database data correct
---
title = "Ich wünschte heute wäre Samstag"
result = doesn't validate (error: title field is required, or results in blank field on db if validation is commented out)
}}}

In addition, my database is set to "utf8_general_ci" and I'm using utf-8 as my content type.

Kind regards and thanks in advance,
Simon

Need support for InnoDB in migrations

The migrations should have a way to specify a table type of InnoDB in order to enforce foreign key support on mysql / mysqli. I was able to hack it in by changing line 180 of the mysqli/mysqli_forge.php from

$sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";

to

$sql .= "\n) ENGINE=InnoDB DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";

but thats an ugly hack. Perhaps something like

$this->dbforge->set_table_type('InnoDB');
if ( ! $this->db->table_exists('my_innodb_table'))
{

    // Setup Keys
    $this->dbforge->add_key('id', TRUE);

    $this->dbforge->add_field(array(
        'id' => array('type' => 'INT', 'constraint' => 5, 'unsigned' => TRUE, 'auto_increment' => TRUE),
        'account_id' => array('type' => 'INT', 'constraint' => '5', 'unsigned' => TRUE, 'null' => FALSE),
        'category_id' => array('type' => 'INT', 'constraint' => '5', 'unsigned' => TRUE, 'null' => FALSE),
    ));
    $this->dbforge->add_field("CONSTRAINT FOREIGN KEY (account_id) REFERENCES accounts(id)");

    // NEED SUPPORT FOR SOMETHING LIKE THIS 
    $this->dbforge->set_table_type('InnoDB');

    $this->dbforge->create_table('categories', TRUE);
}

I know foreign key support is a pain, but it's easily done with

$this->dbforge->add_field("CONSTRAINT FOREIGN KEY (account_id) REFERENCES accounts(id)");

now we just need support for InnoDB to really make migrations useful.

Allow more options to be sent to the captcha helper

Right now, the options you can send to the captcha helper include word, image path and image url, image width and height, font path and expiration. This way, you have to provide a list of words (using the $word option) or the system will generate random words by itself. However, you don't have much control on the random words.

I would like to propose these options to be added as well:

(1) $pool: A set of letters that will be used to generate random captchas. Right now, there is a hardcoded $pool variable defined on line 111, but you can't override it. Instead, it should be added to the $defaults, and one should be able to override it.

(2) $length: Number of letters in the captcha. Right now, a hardcoded value of 8 is used on line 114. Instead, one should have control on the number of letters. This has been previously requested in bug 31, so if you fix this, close that bug too.

Hope you will oblige.

insert_id is wrong after batch insert of > 100

Since DB_active_rec does batch insert 100 at a time, insert_id will be wrong if the batch inset is more than 100 elems. it will return the insert id of the last 100-chunk.

A solution could be to save insert_id after the first 100-chunk.

File renaming fail on upload

Hi, if i upload the same file more than 100 times codeigniter fail to rename it and raise an error.
The problem is in this loop
{{{

!php

$new_filename = '';
for ($i = 1; $i < 100; $i++)
{
if ( ! file_exists($path.$filename.$i.$this->file_ext))
{
$new_filename = $filename.$i.$this->file_ext;
break;
}
}

}}}

in the upload library…
It could seem a silly problem but if you give to the end user some template files to upload you could have some problems…

bye
Luca

mysqli database driver - out of sync

The mysqli driver fails to call next result on _execute()
Proposed fix is to insert a call to mysqli_next_result on line 164 of mysqli_driver.php
{{{

!php

if (!mysqli_errno($this->conn_id)) {
mysqli_next_result($this->conn_id);
}
}}}

Language key error logging

If a language key doesn't exist, but error logging is set to error level, then log the non-existent key.

if ( ! isset($this->language[$line]))
{
log_message('error', 'Could not find the language key "'.$line.'"');
}

Core/URI.php: Parse_url() fails if a segment contains "foo:digit"

== Details ==
Type: Function stops script
File: core/URI.php:176

== Description ==
Parse_url will fail on URIs with segments that look like "foo:number". It is the colon that appears to be causing it (probably because parse_url thinks that it is a port number, and thus malformed).

== Replication ==
Go to a URL like this: http://localhost/ci/foo/bar/test:2/

== Proposed fix ==
Substitute ":" with a tag, parse the URI, and then reinstate the ":" again.

== Original code ==
{{{

!php

$uri = parse_url($uri, PHP_URL_PATH);
}}}

== Workaround ==
{{{

!php

if (preg_match('/:\d/', $uri))
{
$uri = str_replace('{C0L0N}',':',parse_url(str_replace(':','{C0L0N}',$uri),PHP_URL_PATH));
}
else $uri = parse_url($uri, PHP_URL_PATH);
}}}

"Filter segments for malicious characters", really ?

When requesting a URI containing URI encoded parenthesis (I mean %28 and %29), they reach the controller maimed and unusable. Their strlen() reads wrong and they wont be matched as parenthesis by regex.

The reason for this is in system/core/URI.php at lines 238-241. Why would the parenthesis be replaced by shitty HTML entities that damage the string ?

// Convert programatic characters to entities
$bad    = array('$',        '(',        ')',        '%28',      '%29');
$good   = array('&#36;',    '&#40;',    '&#41;',    '&#40;',    '&#41;');
return str_replace($bad, $good, $str);

Unless there's a good reason for it, I think this replacement should be removed altogether. You don't want to know how many hours it took me to pinpoint this issue.

With love,

Antoine Gersant

Add in Memcache (not Memcached) Driver

I ran into a issue recently as I had Memcache installed, not Memcached. Here's a really quick Memcache driver.

Incidentally: I can include this file in my application folder (i.e. APPPATH."/libraries/Cache/drivers") but I either have to hack core to add to $valid_drivers OR copy the whole of Cache.php and stick it in APPPATH."/libraries/Cache" - any idea of how I can just overload Cache.php and add in only the new array for $valid_drivers?

Update memcached Driver support for Memcache && Memcached

When I am using Memcached driver of CodeIgniter, i have problem about it's not support for memcache lib on Zend Server.

This is patch for Memcached Drivers

{{{

!php

array( 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 1 ) ); // ------------------------------------------------------------------------ /** * Fetch from cache * * @param mixed unique key id * @return mixed data on success/false on failure */ public function get($id) { $data = $this->_memcached->get($id); return (is_array($data)) ? $data[0] : FALSE; } // ------------------------------------------------------------------------ /** * Save * * @param string unique identifier * @param mixed data being cached * @param int time to live * @return boolean true on success, false on failure */ public function save($id, $data, $ttl = 60) { return $this->_memcached->add($id, array($data, time(), $ttl), $ttl); } // ------------------------------------------------------------------------ /** * Delete from Cache * * @param mixed key to be deleted. * @return boolean true on success, false on failure */ public function delete($id) { return $this->_memcached->delete($id); } // ------------------------------------------------------------------------ /** * Clean the Cache * * @return boolean false on failure/true on success */ public function clean() { return $this->_memcached->flush(); } // ------------------------------------------------------------------------ /** * Cache Info * * @param null type not supported in memcached * @return mixed array on success, false on failure */ public function cache_info($type = NULL) { return $this->_memcached->getStats(); } // ------------------------------------------------------------------------ /** * Get Cache Metadata * * @param mixed key to get cache metadata on * @return mixed FALSE on failure, array on success. */ public function get_metadata($id) { $stored = $this->_memcached->get($id); if (count($stored) !== 3) { return FALSE; } list($data, $time, $ttl) = $stored; return array( 'expire' => $time + $ttl, 'mtime' => $time, 'data' => $data ); } // ------------------------------------------------------------------------ /** * Setup memcached. */ private function _setup_memcached() { // Try to load memcached server info from the config file. $CI =& get_instance(); if ($CI->config->load('memcached', TRUE, TRUE)) { if (is_array($CI->config->config['memcached'])) { $this->_memcache_conf = NULL; foreach ($CI->config->config['memcached'] as $name => $conf) { $this->_memcache_conf[$name] = $conf; } } } if(class_exists('Memcached')) { $this->_memcached = new Memcached(); } else if(class_exists('Memcache')) { $this->_memcached = new Memcache(); } else { show_error('Can\'t create Memcached object.'); return FALSE; } foreach ($this->_memcache_conf['memcached'] as $name => $cache_server) { if ( ! array_key_exists('host', $cache_server)) { $cache_server['host'] = $this->_default_options['host']; } if ( ! array_key_exists('port', $cache_server)) { $cache_server['port'] = $this->_default_options['port']; } if ( ! array_key_exists('weight', $cache_server)) { $cache_server['weight'] = $this->_default_options['weight']; } $this->_memcached->addServer( $cache_server['host'], $cache_server['port'], $cache_server['weight'] ); } } // ------------------------------------------------------------------------ /** * Is supported * * Returns FALSE if memcached is not supported on the system. * If it is, we setup the memcached object & return TRUE */ public function is_supported() { if ( ! extension_loaded('memcache') && !extension_loaded('memcached')) { log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); return FALSE; } $this->_setup_memcached(); return TRUE; } // ------------------------------------------------------------------------ ``` } // End Class /\* End of file Cache_memcached.php _/ /_ Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ }}}

CI > Session > function _serialize($data) + _unserialize($data)

Hi there,

I found a really nasty problem using the internal session-store of codeigniter...

The problem is, that if I want to store a quote ("), the session-string gets destoryed!

You could use json_encode and json_decode for the function. I was overloading your both functions by:

{{{

!php

function _unserialize($data)
{
return json_decode($data, true);
}

function _serialize($data)
{
return json_encode($data);
}

}}}

and everything is fine... keep on running ;-)

with best regards,

Patrick ([email protected])

#77 Transaction Test Mode is not working (all drivers)

Quote from [[https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all|"https://bitbucket.org/ellislab/codeigniter/issue/77/transaction-test-mode-is-not-working-all"]]

The documentation specifies a capability of rolling back any transaction regardless of the success of the queries for testing purposes (see user guide under Database Library > Transactions > Test Mode).

This feature however is broken. See below for the resolution.

Affected files (system/database/drivers/_/__driver.php):

* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysql/mysql_driver.php#cl-216
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/mysqli/mysqli_driver.php#cl-217
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/oci8/oci8_driver.php#cl-326
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/odbc/odbc_driver.php#cl-196
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/postgre/postgre_driver.php#cl-219
* http://bitbucket.org/ellislab/codeigniter/src/tip/system/database/drivers/sqlite/sqlite_driver.php#cl-213 

The following line uses _trans_failure which is not defined elsewhere:

$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;

Replace the above with:

$this->_trans_status = ($test_mode === TRUE) ? FALSE : $this->_trans_status;

CI_Session Object wont store items with namespace class inheritance

Found while implementing PHP ActiveRecord with CI, ActiveRecord Models extends ActiveRecord/Model. The class instance created stores in a PHP Sesssion without issue but wont store in the CI_Session. When trying to store, both key and value are dropped from CI_Session while all other data remains intact.

extends Cache class

Hi,

My system / libraries / Cache / Cache subclass that inherits from the class tried. We have inherited as a result, there are some problems. I'm sorry in Japanese, it is good because I want to see blogged. (Since most of the code, tell it to do that would convey to some extent)

http://fukata.org/2011/03/25/codeigniter2-how-to-extends-cache/

This time, to hear the future as CI_Driver_Library Cache is that whether a view to have a class with a subclass of the superclass. If you have an eye if not how to react blog, for those you want in a smart way Pull Request bit.

Thank you.

char_set on the _create_database on DB_forge

I propose to extend the //_create_database()// function which is, for now, only :

{{{

!php

return "CREATE DATABASE ".$name;
}}}

The goals is to copy the as the _create_table function.

So, to simply extend the core to :

{{{

!php

CREATE DATABASE $name
CHARACTER SET {$this->db->char_set}
DEFAULT CHARACTER SET {$this->db->char_set}
COLLATE {$this->db->dbcollat}
DEFAULT COLLATE {$this->db->dbcollat};
}}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.