CI Framework security Analysis, CI Framework security Analysis _php Tutorial

Source: Internet
Author: User

CI Framework security Analysis, CI framework security analysis


This paper analyzes the security of CI framework. Share to everyone for your reference, as follows:

People who have used the CI framework know that the CI framework can greatly shorten your code. In fact, the CI framework can improve the security of your website.

Preventing attacks against the database

Data entry can cause many problems. Because of the limitations of HTML and database, the data always contains specific symbols-for example, omitting symbols and quotation marks-can cause your database to be attacked and eventually get the results you can't predict.

The solution is to process the data before it is stored in the database. Doing so wastes some system time and adds some extra code.

The form helper functions of CI automatically do the work. So, when you write an input box:

echo form_input (' username ', ' johndoe ');

CI also implicitly performs the following check functions:

function Form_prep ($str = ") {  if ($str = = = ')  {    return ';  }  $temp = ' __temp_ampersands__ ';  Replace entities to temporary markers so,  //Htmlspecialchars won ' t mess them up  $str = preg_replace ("/& ; # (\d+);/"," $temp \\1; ", $str);  $str = Preg_replace ("/& (\w+);/", "$temp \\1;", $str);  $str = Htmlspecialchars ($STR);  In case Htmlspecialchars misses these.  $str = Str_replace (Array ("'", ' "'), Array (" ' "," ""), $str);  Decode the temp markers back to Entities  $str = Preg_replace ("/$temp (\d+);/", "&#\\1;", $str);  $str = Preg_replace ("/$temp (\w+);/", "&\\1;", $str);  return $STR;}

The above function captures special characters like "&" so that it does not cause confusion when you submit your page. You should know that some characters can cause problems.

Not all users will be able to enter the information that meets the requirements, and you will never know what people are, what they are thinking about, and what they are doing with the browser. You can use CI to prevent entering information that does not meet the requirements. Of course, you do not need to know how CI is behind the scenes for you to do all this, you simply need to enter the following code:

echo form_input (' username ', ' johndoe ');

More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", "thinkphp Getting Started", " Summary of common methods of thinkphp, "Introduction to Zend Framework Frame", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operation" and "PHP common database Operation Skills Summary"

It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.

http://www.bkjia.com/PHPjc/1127847.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127847.html techarticle CI Framework security Analysis , CI framework security Analysis This paper analyzes the security of CI framework. Share to everyone for your reference, as follows: People who have used CI framework know that CI framework can ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.