Skip to content

Instantly share code, notes, and snippets.

View john-henry's full-sized avatar

John Henry Donovan john-henry

View GitHub Profile
@john-henry
john-henry / security-headers-worker
Created October 10, 2022 02:14
security-headers-worker for Cloudflare worker
const securityHeaders = {
"Content-Security-Policy": "upgrade-insecure-requests",
"Strict-Transport-Security": "max-age=31536000",
"X-Xss-Protection": "1; mode=block",
"X-Content-Type-Options": "nosniff",
"Referrer-Policy": "strict-origin-when-cross-origin",
"Connection":"keep-alive",
"X-Frame-Options":"SAMEORIGIN"
},
sanitiseHeaders = {
@john-henry
john-henry / export-members.html
Created November 15, 2018 13:16
JSON Member Export for ExpressionEngine
<?php
// Pass group ID as a query string
$group = $_GET['id'];
$content = array();
// exclude an id like your own
$entries_query = $this->EE->db->query("SELECT * FROM exp_members as m LEFT JOIN exp_member_data AS d ON d.member_id = m.member_id WHERE m.group_id = '$group' and m.member_id != 4664");
foreach ($entries_query->result_array() as $id => $row) {
$content[$id] = array();
// Remove spaces from EE usernames
$content[$id]['username'] = str_replace(' ', '', $row['username']);
@john-henry
john-henry / export-entries.html
Created November 15, 2018 13:11
JSON Entry Export for ExpressionEngine with offset and limit
<?php
// Pass id, limit and offset in as a query string
// Allow PHP and parse on Output
$channel = $_GET['id'];
$limit = $_GET['limit'];
$offset = $_GET['offset'];
$content = array();
@john-henry
john-henry / config.php
Created July 14, 2016 11:37
CE Lossless sample config for ExpressionEngine
$config['ce_lossless_enabled'] = 'jpegoptim|optipng';
$config['ce_lossless_linux_path'] = '/usr/bin/';
$config['ce_lossless_log_output'] = 'y';
$config['ce_lossless_native_hook_enabled'] = 'no';
$config['ce_lossless_commands'] = array(
'optipng' => '-quiet -o7 {{path}}',
'jpegoptim' => '--strip-all --all-progressive -q {{path}}'
);
@john-henry
john-henry / pi.charge_update_fields.php
Created May 10, 2016 10:25
Update Zoo Vistor Entry with extra Meta info from Charge and subscribe to Campaign Monitor
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$plugin_info = array(
'pi_name' => 'Charge Update Fields',
'pi_version' => '1.1',
'pi_author' => 'John Henry Donovan',
'pi_author_url' => 'http://www.redmoonmedia/',
'pi_description'=> 'Update Zoo Vistor Entry with extra Meta info',
'pi_usage' => Charge_update_fields::usage()
);
@john-henry
john-henry / Entry Subscriptions
Created May 18, 2015 13:30
Show list of subscribed entries via Comment add-on and Stash for logged in users in ExpressionEngine.
{exp:stash:set_list name="author-comments" parse_tags="yes" parse_depth="2" refresh="6" save="yes" scope="site" replace="no"}
{exp:comment:entries sort="asc" limit="500" dynamic="no" author_id="{member_id}"}
{stash:comment-title}{title}{/stash:comment-title}
{stash:comment-entry_id}{entry_id}{/stash:comment-entry_id}
{/exp:comment:entries}
{/exp:stash:set_list}
<ul>
@john-henry
john-henry / gist:3179683
Created July 26, 2012 01:07
Infinite Scroll & Masonry in ExpressionEngine
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
@john-henry
john-henry / infite-scroll.js
Created July 24, 2012 13:12
Infite Scroll Demo
/*
<section>
{exp:channel:entries channel="articles" dynamic="no" status="not closed" paginate="bottom" limit="12"}
<article>
<header>
<h1>{title} </h1>
</header>
</article>
{paginate}
@john-henry
john-henry / ext.mx_notify_control.php
Created April 18, 2012 14:04
Send emails from MX Notify if manually validating ExpressionEngine members
function cp_members_validate_members($member_id)
{
$site_settings = $this->settings[SITE_ID];
$memberArray = $_POST['toggle'];
foreach ($site_settings['row_order'] as $key => $value)
{
$iRow = $value;