{"id":5557,"date":"2011-04-08T12:09:32","date_gmt":"2011-04-08T03:09:32","guid":{"rendered":"http:\/\/fukata.org\/?p=5557"},"modified":"2017-08-11T22:58:49","modified_gmt":"2017-08-11T22:58:49","slug":"codeigniter2-how-to-extends-cache-2-0-2","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/5557\/","title":{"rendered":"[CodeIgniter2.x]Cache\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3059\u308b\u306b\u306f(+2.0.2)"},"content":{"rendered":"
XSS\u30d5\u30a3\u30eb\u30bf\u90e8\u5206\u306b\u8106\u5f31\u6027\u304c\u898b\u3064\u304b\u308a\u3001CodeIgniter 2.0.2<\/a>\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u3002\u305f\u3060\u3001CSRF\u95a2\u9023\u306e\u30d0\u30b0<\/a>\u304c\u65b0\u305f\u306b\u767a\u751f\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u306b\u3064\u3044\u3066\u306f\u5341\u5206\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n 2.0.1\u30682.0.2\u306ediff<\/a>\u3092\u898b\u3066\u307f\u305f\u3068\u3053\u308d\u3001<\/p>\n \u3068\u8a00\u3063\u305f\u611f\u3058\u3067\u3057\u305f\u3002<\/p>\n Cache\u307e\u308f\u308a\u306e\u30af\u30e9\u30b9\u540d\u306bCI_\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u304c\u4ed8\u4e0e<\/strong>\u3068\u3044\u3046\u4e8b\u3060\u3063\u305f\u306e\u3067\u3001\u3064\u3044\u306b\u7d99\u627f\u3092\u8003\u616e\u3055\u308c\u305f\u306e\u304b\u3068\u601d\u3044\u3001\u524d\u56de\u3001[CodeIgniter2.x]Cache\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3059\u308b\u306b\u306f<\/a>\u3067\u66f8\u3044\u305f\u3001Cache\u30af\u30e9\u30b9\u306e\u7d99\u627f\u3067\u3059\u304c\u30012.0.2\u3092\u5229\u7528\u3059\u308b\u5834\u5408\u3001\u7d99\u627f\u65b9\u6cd5\u304c\u3069\u306e\u3088\u3046\u306b\u5909\u308f\u3063\u305f\u306e\u304b\u8a66\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n \u76ee\u6b21<\/p> \u524d\u56de\u306e\u30bd\u30fc\u30b9<\/a>\u3092\u30d9\u30fc\u30b9\u306b\u8a71\u3092\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n \u307e\u305a\u3001Cache.php\u3001Cache\/drivers\/\u4ee5\u4e0b\u306e\u30af\u30e9\u30b9\u306bCI_\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u306e\u3067MY_Cache\u306b\u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n \u3053\u306e\u72b6\u614b\u3067\u52d5\u304b\u3059\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u305d\u306e\u969b\u306e\u30ed\u30b0\u3067\u3059\u3002<\/p>\n \u4ee5\u524d\u3068\u8aad\u307f\u8fbc\u307f\u5834\u6240\u304c\u5909\u308f\u3063\u3066\u3044\u307e\u3059\u306d\u3002\u524d\u56de\u307e\u3067\u306e\u69cb\u9020\u306f\u3001<\/p>\n \u3068\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u306e\u3067\u3001\u8aad\u307f\u8fbc\u307f\u5834\u6240\u306e\u6307\u5b9a\u65b9\u6cd5\u304c\u5909\u308f\u3063\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n 2.0.1\u306e\u9803\u3068\u6bd4\u3079\u308b\u3068$lib_name\u3084$child_class\u304cstrtolower\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306b\u5c0f\u6587\u5b57\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8aad\u307f\u8fbc\u307f\u5bfe\u8c61\u3068\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n \u4eca\u307e\u3067\u306e\u8aac\u660e\u3092\u8e0f\u307e\u3048\u3066\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u5909\u66f4\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n \u3053\u308c\u3067\u3001\u518d\u5ea6\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3068\u7121\u4e8b\u52d5\u304f\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n CI_\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u304c\u4ed8\u4e0e\u3055\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u7d99\u627f\u3092\u8003\u616e\u3055\u308c\u3066\u3044\u308b\u306e\u304b\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u6b8b\u5ff5\u306a\u304c\u3089\u307e\u3060\u4e2d\u9014\u534a\u7aef\u306a\u72b6\u614b\u3067\u3057\u305f\u3002\u307e\u3060\u307e\u3060\u3001\u3053\u306e\u8fba\u306f\u5909\u66f4\u3055\u308c\u305d\u3046\u306a\u611f\u3058\u304c\u3057\u307e\u3059\u306e\u3067\u3001\u7d99\u627f\u3059\u308b\u5834\u5408\u306f\u6fc0\u3057\u304f\u81ea\u5df1\u8cac\u4efb\u3067\u304a\u9858\u3044\u3057\u307e\u3059\u3002<\/p>\n \u8ffd\u8a18\uff1a2011.04.09 18:21<\/strong> XSS\u30d5\u30a3\u30eb\u30bf\u90e8\u5206\u306b\u8106\u5f31\u6027\u304c\u898b\u3064\u304b\u308a\u3001CodeIgniter 2.0.2\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u3002\u305f\u3060\u3001CSRF\u95a2\u9023\u306e\u30d0\u30b0\u304c\u65b0\u305f\u306b\u767a\u751f\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u306b\u3064\u3044\u3066\u306f\u5341\u5206\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002 2. … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[153,850],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/5557"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=5557"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/5557\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=5557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=5557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=5557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
\nCI_\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u306e\u4ed8\u4e0e<\/span><\/h2>\n
application\/libraries\/Cache\/MY_Cache.php<\/span><\/h3>\n
\r\n< ?php\r\n- class MY_Cache extends Cache {\r\n+ class MY_Cache extends CI_Cache {\r\n<\/pre>\n
application\/libraries\/MY_Cache\/drivers\/MY_Cache_memcached.php<\/span><\/h3>\n
\r\n< ?php\r\nrequire_once BASEPATH.'libraries\/Cache\/drivers\/Cache_memcached.php';\r\n- class MY_Cache_memcached extends Cache_memcached {\r\n+ class MY_Cache_memcached extends CI_Cache_memcached {\r\n<\/pre>\n
An Error Was Encountered\r\nUnable to load the requested driver: MY_Cache_memcached<\/pre>\n
INFO - 2011-04-08 10:47:41 --> load driver=application\/libraries\/my_cache\/drivers\/My_cache_memcached.php\r\nINFO - 2011-04-08 10:47:41 --> load driver=application\/libraries\/my_cache\/drivers\/my_cache_memcached.php\r\nINFO - 2011-04-08 10:47:41 --> load driver=\/home\/tatsuya\/Dropbox\/www\/ci202_cache\/system\/libraries\/my_cache\/drivers\/My_cache_memcached.php\r\nINFO - 2011-04-08 10:47:41 --> load driver=\/home\/tatsuya\/Dropbox\/www\/ci202_cache\/system\/libraries\/my_cache\/drivers\/my_cache_memcached.php\r\nERROR - 2011-04-08 10:47:41 --> Unable to load the requested driver: MY_Cache_memcached\r\n<\/pre>\n
\r\n.\/\r\n|-- Cache\r\n| `-- MY_Cache.php\r\n|-- MY_Cache\r\n| `-- drivers\r\n| |-- MY_Cache_apc.php\r\n| |-- MY_Cache_dummy.php\r\n| |-- MY_Cache_file.php\r\n| `-- MY_Cache_memcached.php\r\n`-- index.html\r\n<\/pre>\n
Driver.php\u306eCI_\u5bfe\u5fdc<\/span><\/h3>\n
system\/libraries\/Driver.php<\/span><\/h2>\n
\r\n--- CodeIgniter_2.0.1\/system\/libraries\/Driver.php 2011-03-16 02:54:00.000000000 +0800\r\n+++ CodeIgniter_2.0.2\/system\/libraries\/Driver.php 2011-04-07 12:20:00.000000000 +0800\r\n@@ -44,7 +44,11 @@\r\n \/\/ The class will be prefixed with the parent lib\r\n $child_class = $this->lib_name.'_'.$child;\r\n\r\n- if (in_array(strtolower($child_class), array_map('strtolower', $this->valid_drivers)))\r\n+ \/\/ Remove the CI_ prefix and lowercase\r\n+ $lib_name = strtolower(preg_replace('\/^CI_\/', '', $this->lib_name));\r\n+ $driver_name = strtolower(preg_replace('\/^CI_\/', '', $child_class));\r\n+\r\n+ if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))\r\n {\r\n \/\/ check and see if the driver is in a separate file\r\n if ( ! class_exists($child_class))\r\n@@ -52,19 +56,15 @@\r\n \/\/ check application path first\r\n foreach (array(APPPATH, BASEPATH) as $path)\r\n {\r\n- \/\/ and check for case sensitivity of both the parent and child libs\r\n- foreach (array(ucfirst($this->lib_name), strtolower($this->lib_name)) as $lib)\r\n+ \/\/ loves me some nesting!\r\n+ foreach (array(ucfirst($driver_name), $driver_name) as $class)\r\n {\r\n- \/\/ loves me some nesting!\r\n- foreach (array(ucfirst($child_class), strtolower($child_class)) as $class)\r\n- {\r\n- $filepath = $path.'libraries\/'.$this->lib_name.'\/drivers\/'.$child_class.EXT;\r\n+ $filepath = $path.'libraries\/'.$lib_name.'\/drivers\/'.$class.EXT;\r\n\r\n- if (file_exists($filepath))\r\n- {\r\n- include_once $filepath;\r\n- break;\r\n- }\r\n+ if (file_exists($filepath))\r\n+ {\r\n+ include_once $filepath;\r\n+ break;\r\n }\r\n }\r\n }\r\n<\/pre>\n
\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u30922.0.2\u306b\u5bfe\u5fdc<\/span><\/h2>\n
\r\n.\/\r\n|-- Cache\r\n| `-- MY_Cache.php\r\n|-- my_cache\r\n| `-- drivers\r\n| |-- My_cache_apc.php\r\n| |-- My_cache_dummy.php\r\n| |-- My_cache_file.php\r\n| `-- My_cache_memcached.php\r\n`-- index.html\r\n<\/pre>\n
\u6700\u5f8c\u306b<\/span><\/h2>\n
\nellislab \/ CodeIgniter Reactor \/ issues \/ #193 – CI_Cache_file \u2014 Bitbucket<\/a>
\n\u65e2\u306b\u672c\u5bb6\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u3066\u5bfe\u5fdc\u3082\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u4e0a\u8a18\u306eDriver.php\u5185\u306e$lib_name\u5909\u6570\u304cstrtolower\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u5c0f\u6587\u5b57\u5316\u3055\u308c\u3066\u3057\u307e\u3063\u3066\u304a\u308a\u3001\u8aad\u307f\u8fbc\u307f\u5bfe\u8c61\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30822.0.1\u306eucfirst\u3067\u306f\u306a\u304f\u306a\u3063\u3066\u304a\u308a\u3001\u6b63\u5e38\u306b\u8aad\u307f\u8fbc\u3081\u306a\u3044\u30d0\u30b0\u304c\u4eca\u56de\u65b0\u305f\u306b\u767a\u751f\u3057\u3066\u3044\u307e\u3059\u3002\u5bfe\u51e6\u6cd5\u3068\u3057\u3066\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b$lib_name\u306bucfirst\u5b9f\u884c\u5f8c\u306e\u5024\u3092\u4ee3\u5165\u3059\u308c\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n\r\n$lib_name = ucfirst(strtolower(preg_replace('\/^CI_\/', '', $this->lib_name)));\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"