Jump to content

Модификатор для system/library/request.php


ElenaPr
 Share

Go to solution Solved by mpn2005,

Recommended Posts

Привет!

Могу ли я без последствий изменить (модификатором) код в классе Request?

Т.е. нарушит ли это работу магазина? Читала, что ядро нельзя трогать

 

В поля БД попадают всевозможные пробельные символы (в частности, табуляция, которая не обрезается функцией mysql trim)

Для уже введенных данных использую

SELECT ......  WHERE TRIM('\t' FROM TRIM(model)) IN (...,...,....)

 

В system/library/request.php

было

$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');

хочу сделать

$data = htmlspecialchars(trim($data), ENT_COMPAT, 'UTF-8');

 

class Request {
    public $get = array();
    public $post = array();
    public $cookie = array();
    public $files = array();
    public $server = array();
    
    /**
     * Constructor
     */
    public function __construct() {
        $this->get = $this->clean($_GET);
        $this->post = $this->clean($_POST);
        $this->request = $this->clean($_REQUEST);
        $this->cookie = $this->clean($_COOKIE);
        $this->files = $this->clean($_FILES);
        $this->server = $this->clean($_SERVER);
    }
    
    /**
     * 
     * @param    array    $data
     *
     * @return    array
     */
    public function clean($data) {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                unset($data[$key]);

                $data[$this->clean($key)] = $this->clean($value);
            }
        } else {
            $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); //$data = htmlspecialchars(trim($data), ENT_COMPAT, 'UTF-8');
        }

        return $data;
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...