Skip to content

Instantly share code, notes, and snippets.

@irazasyed
irazasyed / block-robots.php
Created February 12, 2015 13:14
PHP: Block Robots using Headers in PHP.
<?php
@header('X-Robots-Tag: "none, noindex, nofollow, noarchive, nosnippet, noodp, notranslate, noimageindex"');
@irazasyed
irazasyed / xss-protection.php
Last active March 5, 2022 01:01
PHP: XSS Protection.
<?php
/* Prevent XSS - Trims and Sanitizes GET/POST Data */
$_GET = array_map(function ($param) {
return strip_tags(trim(addslashes(htmlspecialchars($param))));
}, $_GET);
$_POST = array_map(function ($param) {
return htmlspecialchars(addslashes(trim($param)));
}, $_POST);
@irazasyed
irazasyed / spintax.php
Last active May 21, 2024 08:42
PHP: Text Spinner Class - Nested spinning supported.
<?PHP
/**
* Spintax - A helper class to process Spintax strings.
*/
class Spintax
{
/**
* Set seed to make the spinner predictable.
*/