Codegeniter protection not working, overwrites csrf_show_error message

CI version: 2.2.0

I am creating a file at /CI220/application/libraries/MY_Security.php config which I have installed

$config['subclass_prefix'] = 'MY_';

      

I found it was not loading MY_Security, My MY_Controller is loading but not this library. Below is my call stack log:

Call Stack
#   Time    Memory  Function    Location
1   0.0004  242064  {main}( )   ../index.php:0
2   0.0009  244352  require_once( '/Users/User/Sites/CI220/system/core/CodeIgniter.php' )   ../index.php:202
3   0.0091  478200  load_class( )   ../CodeIgniter.php:213
4   0.0096  489872  CI_Input->__construct( )    ../Common.php:174
5   0.0097  491432  CI_Input->_sanitize_globals( )  ../Input.php:103
6   0.0232  499224  CI_Security->csrf_verify( ) ../Input.php:647
7   0.0233  499432  CI_Security->csrf_show_error( ) ../Security.php:149

      

I am not downloading my extended library from Security. I want to overwrite the csrf_show_error function

public function csrf_show_error()
{
    show_error('The action you have requested is not allowed.!!!');
}

      

+3


source to share


2 answers


The Security class is located in system / core /Security.php

Email class is in system / libraries / Email.php



You can refer to this link for the main class: http://www.codeigniter.com/user_guide/general/core_classes.html

Key classes are ALWAYS loaded automatically, so you don't need to include in autoloading either.

+3


source


Thanks for @Svetlio for the answer

libraries / MY_Security.php is wrong path which should be in main folder> core / MY_Security.php

I am having this confusion because of this page. http://www.codeigniter.com/user_guide/general/creating_libraries.html



Extending your own libraries

If all you have to do is add some functionality to the existing library - maybe add a function or two - then it overflows to replace the entire library with your version. In this case, it's best to just extend the class. Extending a class is almost identical to replacing a class with a few exceptions:

The class declaration must extend the parent class. Your new class name and filename must be prefixed with MY_ (This element is configurable. See below.). For example, to extend the native Email class, you create a file called application / libraries /MY_Email.php, and declare your class: .....

Thanks for the answer, so if you find that the libraries folder is not working, you can try for the main folder.

0


source







All Articles