PHP Classes

File: includes/sanitize.php

Recommend this page to a friend!
  Packages of Marcel Kohls   Very Simple API   includes/sanitize.php   Download  
File: includes/sanitize.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Very Simple API
Implement REST APIs using service classes
Author: By
Last change:
Date: 9 years ago
Size: 1,000 bytes
 

Contents

Class file image Download
<?php
if (function_exists('sanitizeParam') == false){
    function sanitizeParam($pContents){
        $retorno = '';

        if (is_array($pContents)){
            $tArray = array();

            foreach($pContents as $index=>$item){
                $tArray[$index] = sanitizeParam($item);
            }

            $retorno = $tArray;
        } else {
            $content = trim(addslashes(strip_tags($pContents)));

            $lValue = preg_replace('/[^a-zA-Z0-9\.\@\-\/\:\,\_]/', " ", $content );
            $lValue = removeKeywords($lValue);

            $retorno = $lValue;
        }

        return $retorno;
    }
}

if (function_exists('removeKeywords') == false){
    function removeKeywords($pString){
        $retorno = $pString;
        $removes = array(' OR ', 'AND ', 'REGEXP', 'LIKE ', 'BENCHMARK', 'WHERE ', 'SUBSTRING', 'SELECT', 'SCHEMA', 'TABLE', 'FROM ', 'WAITFOR', 'DELAY', 'ARRAY', '.ini', 'SCRIPT', 'vbscript', 'javascript', 'alert(', 'onload', 'IFRAME');

        foreach($removes as $value){
            $retorno = str_ireplace($value, " ", $retorno);
        }

        return $retorno;
    }
}