tp5 Mall

Record a few key points:

  • User firbug fake form fields, such as fake id form field, how to prevent, tp5 does not seem to.
  • xss attacks: using htmlspecialchars () will img, p, and so filter out legitimate label, want to have selective filtering tab, use htmlpurifier packages, search htmlpurifier downloading codecs, the library into the project directory. If the frame, then the relevant public documents generated code in a function, at any time convenient to call.
    / * * 
     * @ Js script HTMLPurifier selective filter filtering XSS - "Description: performance is very low -" sparingly 
     * / 
    function removeXss ( $ Data ) {
     // introduction path is provided according to the specific location, other unwanted changes 
        require_once '../HtmlPurifier/HTMLPurifier.auto.php' ;
         $ _clean_xss_config = HTMLPurifier_Config :: createDefault ();
         $ _clean_xss_config -> sET ( 'Core.Encoding', 'UTF-. 8' );
         // set the reservation label 
        _clean_xss_config $ -> SET ( 'HTML.Allowed', 'div, B, strong, I, EM, A [the href | title], UL, OL, Li, P [style], br, span [style], IMG [ width | height | alt | src] ' );
         $ _clean_xss_config->set('CSS.AllowedProperties', 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
        $_clean_xss_config->set('HTML.TargetBlank', TRUE);
        $_clean_xss_obj = new HTMLPurifier($_clean_xss_config);
        return $_clean_xss_obj->purify($data);
    }

     

  • Commodity generate thumbnail: Product List Next need to, product details page need, need a magnifying glass, and so on. So when you add product images, data tables have several fields to store different sized images.
  • . Optimization project in the picture: 1 picture Write configuration in the configuration file; 2 image path dead do not write, write in the configuration file; 3. upload pictures and picture processing code is encapsulated into a function.
    // Image configuration 
        'Image' => [
             'the maxSize' => 1024 * 1024, 
            'EXTS' => Array ( 'JPG', 'JPEG', 'PNG', 'GIF'), 
            'rootPath' => '. ./public/uploads/ ',     // upload the saved image path, the path that PHP uses, it is the path on the hard disk, he is the root of D: 
            ' viewPath '=>' / public / uploads',        // display picture path, the path used by the browser, the root directory is the root directory of the site 
        ], // in the configuration file to write the code, such as this
    
    

     

Guess you like

Origin www.cnblogs.com/bneglect/p/11106234.html