Skip to content

Instantly share code, notes, and snippets.

Avatar

Mat Dave Jones matdave

View GitHub Profile
@matdave
matdave / createdBy.plugin.php
Created Aug 12, 2020
MODX change author plugin
View createdBy.plugin.php
<?php
/**
* Plugin to add a "created by" field on a resource form and moves "published on" to document tab
*
* @var modX $modx
* @var array $scriptProperties
*
* @event OnDocFormPrerender
*/
$dateFormat = $modx->getOption('manager_date_format',null,'d.m.Y');
View recaptchav3.post.snippet.php
<?php
/**
* recaptchav3 POST Validator for use with MODX form processors
*
* Based on https://github.com/google/recaptcha
*
* @copyright Copyright (c) 2014, Google Inc.
* @link http://www.google.com/recaptcha
*
* Ported to MODX by YJ Tso @sepiariver
View codeSample.snippet.php
<?php
/**
* codeSample Snippet for rendering ASCII characters of element calls in MODX frontend
* e.g.
* [[codeSample?&element=`QuickEmail`&properties=`debug=1` &cachedFlag=`true`]]
* outputs [[!QuickEmail? &debug=`1`]]
**/
$element = $modx->getOption('element', $scriptProperties, null);
$type = $modx->getOption('elementClass', $scriptProperties, 'modSnippet');
@matdave
matdave / imageRotate.plugin.php
Created Apr 3, 2020
MODX imageRotate Plugin
View imageRotate.plugin.php
<?php
// run plugin OnFileManagerUpload
switch ($modx->event->name) {
case "OnFileManagerUpload":
if(!empty($files)){
foreach($files as $file){
if ($file['type'] != "image/jpeg" && $file['type'] != "image/png")
return;
// max number of pixels wide or high
$max_image_dimension = $modx->getOption('max_image_dimension',$scriptProperties,0);
View dev-tools-bookmarklets.txt
BuiltWith
javascript:void(window.open('http://builtwith.com?'+location.hostname,'_blank'))
DNS Whois IP
javascript:void(window.open('https://dnslytics.com/domain/'+location.hostname,'_blank'))
MX Toolbox
javascript:void(window.open('https://mxtoolbox.com/SuperTool.aspx?action=mx%3a'+location.hostname+'&run=toolpage','_blank'))
Wayback Machine
@matdave
matdave / tablePresentation.php
Created Dec 20, 2019
MODX tablePresentation plugin
View tablePresentation.php
<?php
// Run OnWebPagePrereneder
$modx->resource->_output = str_replace('<table', '<table role="presentation"', $modx->resource->_output);
@matdave
matdave / delayClearCache.plugin.php
Created Oct 16, 2019
Delay Clearing Cache on Resource Save
View delayClearCache.plugin.php
<?php
switch ($modx->event->name) {
case 'OnBeforeDocFormSave':
$now = mktime();
$lastcache = $modx->cacheManager->get('delaycache');
if(!empty($lastcache) && ($now - $lastcache) < 300){
$_POST['syncsite'] = 0;
}
return;
break;
@matdave
matdave / sp.nginx
Created Aug 8, 2019
Stackpath nginx Real IP
View sp.nginx
#list of trusted IPs
set_real_ip_from 69.16.133.0/24
set_real_ip_from 69.16.176.0/20
set_real_ip_from 69.16.182.0/24
set_real_ip_from 69.16.184.0/24
set_real_ip_from 69.16.188.0/24
set_real_ip_from 74.209.134.0/24
set_real_ip_from 74.209.134.128/25
set_real_ip_from 81.171.60.0/24
set_real_ip_from 81.171.61.0/24
@matdave
matdave / list_all_tags.chunk.tpl
Last active Feb 21, 2019
getResource with NO tags
View list_all_tags.chunk.tpl
[[TaggerGetTags? &groups=`2` &parents=`5` &rowTpl=`tag_groups_tpl`]]
[[getResources:toPlaceholder=`uncategorized`?
&parents=`5`
&limit=`0`
&tpl=`list_row_tpl`
&sortby=`publishedon`
&sortdir=`DESC`
&includeContent=`1`
&includeTVs=`1` &processTVs=`1` &tvPrefix=`tv.`
&where=`["NOT EXISTS (SELECT 1 FROM `modx_tagger_tag_resources` r WHERE r.resource = modResource.id)"]`
@matdave
matdave / pdftojpeg.snippet.php
Last active Jan 29, 2019 — forked from netProphET/pdftojpeg.snippet.php
PDF Thumbnailing in MODX - Proof of Concept
View pdftojpeg.snippet.php
<?php
/**
* Warning: this code is for demonstration purposes only
*/
if (!preg_match("/\.pdf$/", $input)) {
return "PDF file not specified.";
}
$options = explode('&', $modx->getOption('options', $scriptProperties, null));
if(empty($options)){
You can’t perform that action at this time.