Strip HTML comments

@param string $data Data to strip comments from
@return string Comment stripped string
324893
public static function strip_comments($data)
	{
		$output = '';
		while (($start = strpos($data, '<!--')) !== false)
		{
			$output .= substr($data, 0, $start);
			if (($end = strpos($data, '-->', $start)) !== false)
			{
				$data = substr_replace($data, '', 0, $end + 3);
			}
			else
			{
				$data = '';
			}
		}
		return $output . $data;
	}
919796
public function packageRemoveSnippet($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
        
            return $response;
        }
        
        
        $package=SnippetPackage::get()->byID(intval($data->packageID));
        if(!empty($package) && $package!==false && $package->ID!=0) {
            $package->Snippets()->removeByID(intval($data->snippetID));
            
            
            $response['status']='HELO';
        }else {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PACKAGE_NOT_FOUND', '_Package not found');
        }
        
        return $response;
    }
50163
protected function stripCssExpressions($source)
    {
        // Strip any comments out (in the form of /*...*/)
        $test = preg_replace('#\/\*.*\*\/#U', '', $source);

        // Test for :expression
        if (!stripos($test, ':expression')) {
            // Not found, so we are done
            $return = $source;
        } else {
            // At this point, we have stripped out the comments and have found :expression
            // Test stripped string for :expression followed by a '('
            if (preg_match_all('#:expression\s*\(#', $test, $matches)) {
                // If found, remove :expression
                $test = str_ireplace(':expression', '', $test);
                $return = $test;
            }
        }

        return $return;
    }
676297
protected function cleanText($text)
    {
        $strippedText = strip_tags($text);
        $strippedText = htmlentities($strippedText, ENT_QUOTES, $this->getCharset(), FALSE);
        return html_entity_decode($strippedText, ENT_QUOTES, $this->getCharset());
    }
309803
static public function stripslashes($data) 
	{
	    if(!is_array($data)) return stripslashes($data);
	    
	    foreach($data as $key => $val) {
	        $data[$key] = static::stripslashes($val);
	    }
	    
	    return $data;
	}
1232030
public static function stripTags($data, $allow_tags = null)
    {
        if (\is_array($data)) {
            foreach ($data as $k => $v) {
                $data[$k] = self::stripTags($v, $allow_tags);
            }

            return $data;
        }

        if (\is_string($data) || is_numeric($data)) {
            return strip_tags($data, $allow_tags);
        }

        return false;
    }
121995
private function fixIe($data)
    {
        $data = preg_replace(
            '#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i',
            '$1>',
            $data
        );
        $data = preg_replace(
            '#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i',
            '$1>',
            $data
        );
        $data = preg_replace(
            '#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i
            [\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu',
            '$1>',
            $data
        );

        return $data;
    }
1066772
public function stripResponseData(array $data)
	{
		if (isset($data[self::getEntityName()]) && is_array($data[self::getEntityName()]))
			$data = $data[self::getEntityName()];

		if (isset($data[self::getSingularEntityName()]) && is_array($data[self::getSingularEntityName()]))
			$data = $data[self::getSingularEntityName()];

		return $data;
	}
578741
protected function _unserialize($data)
	{
		$data = @unserialize(stripslashes($data));

		if (is_array($data))
		{
			foreach ($data as $key => $val)
			{
				if (is_string($val))
				{
					$data[$key] = str_replace('{{slash}}', '\\', $val);
				}
			}

			return $data;
		}

		return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
	}
431725
protected function stripAttributeMarker(array $data)
    {
        foreach ($data as $key => $value) {
            if (substr($key, 0, 5) == '@xml:') {
                $data[substr($key, 5)] = $value;
                unset ($data[$key]);
            } elseif (substr($key, 0, 1) == '@') {
                $data[substr($key, 1)] = $value;
                unset ($data[$key]);
            }

            if (is_array($value)) {
                $data[$key] = $this->stripAttributeMarker($value);
            }
        }

        return $data;
    }
681101
public function parse($data)
    {
        $this->table();
        $this->images();
        $this->text();
        $this->html();

        // Replace everything that has been found
        foreach ($this->matches as $key => $val) {
            $data = preg_replace_callback($key, $val, $data);
        }

        // Replace line-breaks
        return preg_replace_callback("/\n\r?/", function () {
            return '<br />';
        }, $data
        );
    }
144025
public function unredislize($data)
    {
        $data = urldecode($data);

        if (self::isSerialized($data)) {
            $unserializedData = @unserialize($data);
            if ($unserializedData !== false) {
                return $unserializedData;
            }
        }

        return $data;
    }
1005160
protected static function removeEmptyAttributes($data)
    {
        $records = $data;
        $unwrapped = false;
        if (isset($data[ResourcesWrapper::getWrapper()])) {
            $records = $data[ResourcesWrapper::getWrapper()];
            $unwrapped = true;
        }

        foreach ($records as $i => $record) {
            if (is_numeric($i) && [$record]) {
                foreach ($record as $key => $value) {
                    if (empty($value)) {
                        unset($records[$i][$key]);
                    } elseif (is_string($value)) {
                        if (strtolower($value) === "true") {
                            $records[$i][$key] = true;
                        } elseif (strtolower($value) === "false") {
                            $records[$i][$key] = false;
                        } elseif (strtolower($value) === "null") {
                            $records[$i][$key] = null;
                        }
                    }
                }
            }
        }

        $data = $records;
        if ($unwrapped) {
            $data = ResourcesWrapper::wrapResources($data);
        }

        return $data;
    }
982863
function commentStrip(string) {
  // Remove commented lines
  string = string.replace(RE_COMMENT_SINGLE_LINE, '');
  string = string.replace(RE_COMMENT_MULTI_LINES, '');
  return string;
}
1181176
public function makeAdminActions($data)
    {
        $actions = [];

        if ($html = $this->makeVisibilityAction($data)) {
            $actions['visibility'] = $html;
        }

        if ($html = $this->makeEditAction($data)) {
            $actions['edit'] = $html;
        }

        if ($html = $this->makeViewAction($data)) {
            $actions['view'] = $html;
        }

        if ($html = $this->makeDeleteAction($data)) {
            $actions['delete'] = $html;
        }

        return $actions;
    }
655991
public function doReplace($data)
    {
        $data = preg_replace_callback(
            '/#([^\s\r#]+)#/',
            function ($matches) {
                if (defined($matches[1])) {
                    return constant($matches[1]);
                }

                return $matches[0];
            },
            $data
        );

        if (isset($this->values)) {
            $values = $this->values;

            $data = preg_replace_callback(
                '/%([^\s\r%]+)%/',
                function ($matches) use ($values) {
                    if (isset($values[$matches[1]])) {
                        return $values[$matches[1]];
                    }

                    return $matches[0];
                },
                $data
            );
        }

        return $data;
    }
1023606
protected function cleanData($data)
    {
        $replacementChars = array(
            "\xe2\x80\x98" => "'",   // ‘
            "\xe2\x80\x99" => "'",   // ’
            "\xe2\x80\x9a" => "'",   // ‚
            "\xe2\x80\x9b" => "'",   // ‛
            "\xe2\x80\x9c" => '"',   // “
            "\xe2\x80\x9d" => '"',   // ”
            "\xe2\x80\x9e" => '"',   // „
            "\xe2\x80\x9f" => '"',   // ‟
            "\xe2\x80\x93" => '-',   // –
            "\xe2\x80\x94" => '--',  // —
            "\xe2\x80\xa6" => '...', // …
            "\xc2\xa0"     => ' ',
        );
        // Replace UTF-8 characters
        $cleanedData = strtr($data, $replacementChars);

        // Replace Windows-1252 equivalents
        $charsToReplace = array_map(function ($code) {
            return $this->mb_chr($code);
        }, array(133, 145, 146, 147, 148, 150, 151, 194));
        $cleanedData = $this->mb_str_replace($charsToReplace, $replacementChars, $cleanedData);

        return $cleanedData;
    }