Skip to content

Instantly share code, notes, and snippets.

View zacscott's full-sized avatar

Zac Scott zacscott

View GitHub Profile
@zacscott
zacscott / class.Thumbnailer.php
Last active December 29, 2015 10:09
Simple utility which dynamically creates thumbnail/preview images.
<?php
namespace \net\zeddev\util;
/**
* A simple utility to dynamically create thumbnail images. Images can be
* stored on disk, or served on the fly (depending how constructed). For
* example:
*
* $ondisk = new Thumbnailer('thumbnail/dir/path');
@zacscott
zacscott / bbcode.php
Last active April 6, 2020 07:59
Simple BBcode rendering function (PHP).
<?php
/**
* Renders BBCode to html, suitable to be embedded in a document. Supports only
* a limited set of BBCode tags (can be extended), which are:
*
* @param $bbcode The bbcode to be rendered. Must not be `null` or empty
* string.
* @param $reps Optional additional replacements. Allows you to add custom tags
* etc. Should be an associative array, mapping a regex (preg) to replacement.
@zacscott
zacscott / class.XSRFToken.php
Last active December 30, 2015 04:49
Utility to prevent cross-site request forgeries (XSRF).
<?php
namespace net\zeddev\util;
// start session if not already
if (session_id() == '')
session_start();
/**
* Utility to prevent cross-site request forgeries (XSRF) using a request scoped
@zacscott
zacscott / fuzzyDate.php
Last active January 2, 2016 19:09 — forked from CodeNegar/gist:3713606
Fuzzy/approx of a date in the past (php function).
<?php
/** Returns a fuzzy/approx of a date in the past. */
function fuzzyDate($date){
$time = strtotime($date);
$now = time();
$ago = $now - $time;
if ($ago < 60) {
@zacscott
zacscott / secman.php
Last active August 29, 2015 14:04
Checks HTTP requests for common attacks/exploits (XSS, XSRF and SQL injection).
<?php
/**
Plugin Name: Secman
Plugin URI: https://gist.github.com/zscott92/0b052fc6f5fd42d33a02
Description: Checks HTTP requests for common attacks/exploits (XSS, XSRF and SQL injection). Just activate and forget - no configuration!
Version: 1.0
License: MIT License
Author: Zachary Scott
Author URI: http://www.zacscott.net
*/
License Key PhpStorm 8
User Name : EMBRACE
===== LICENSE BEGIN =====
43136-12042010
00002UsvSON704l"dILe1PVx3y4"B3
49AU6oSDJrsjE8nMOQh"8HTDJHIUUh
gd1BebYc5U"6OxDbVsALB4Eb10PW8"
===== LICENSE END =====
@zacscott
zacscott / s3_signed_url.php
Last active August 29, 2015 14:21
AWS S3 Signed URL
<?php
/** @file s3_signed_url.php - provides the s3_signed_url() function to produce time-limited URL's using AWS S3.
* Based off; http://dev.wattswork.com/make-signed-urls-for-amazon-s3-with-php/
*/
if ( !function_exists('s3_signed_url' ) ) {
/**
* Create signed URLs to your protected Amazon S3 files.
*
@zacscott
zacscott / GeoIP.php
Last active August 29, 2015 14:22
GeoIP.php
<?php
/** GeoIP.php - GeoIP API lookup interface
* Uses the Free GeoIP API to perform lookup - http://freegeoip.net
*/
// dont double include
if ( class_exists( 'GeoIP' ) ) {
return;
}
@zacscott
zacscott / WpVulnDb.php
Created June 9, 2015 20:43
WpVulnDb.php
<?php
/** @file WpVulnDb.php - WordPress utility class for the WPScan API
* Uses the WPVulnDB - https://wpvulndb.com/api
*/
/**
* WPScan vulnerability database/API interface.
*
* @author Zachary Scott <zscott.dev@gmail.com>
*/
@zacscott
zacscott / notes.php
Last active March 11, 2017 11:09
Notes - WordPress Plugin
<?php
/**
* Plugin Name: Notes
* Description: Keep private notes within WordPress
* Version: 1.0
* Author: Zachary Scott
* Author URI: https://www.zacscott.net
* Plugin URI: https://gist.github.com/zacscott/b4cbacf5a0825a270a28
* License: GPLv3+
*/