Skip to content

Instantly share code, notes, and snippets.

@matdave
matdave / imageRotate.2.x.plugin.php
Last active October 2, 2023 07:35
MODX imageRotate Plugin
<?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);
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 December 20, 2019 17:03
MODX tablePresentation plugin
<?php
// Run OnWebPagePrereneder
$modx->resource->_output = str_replace('<table', '<table role="presentation"', $modx->resource->_output);
@matdave
matdave / delayClearCache.plugin.php
Created October 16, 2019 20:35
Delay Clearing Cache on Resource Save
<?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 August 8, 2019 21:24
Stackpath nginx Real IP
#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 February 21, 2019 16:08
getResource with NO tags
[[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 January 29, 2019 20:26 — forked from mkschell/pdftojpeg.snippet.php
PDF Thumbnailing in MODX - Proof of Concept
<?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)){
@matdave
matdave / formtabs.json
Last active December 13, 2022 19:22
Convert Maxi to MIGX
[
{"caption":"Image", "fields":[
{"field":"image","caption":"Image","inputTVtype":"image"}
]},
{"caption":"Info", "fields": [
{"field":"title","caption":"Title"},
{"field":"description","caption":"Description","inputTVtype":"richtext"}
]}
]
@matdave
matdave / evoURI.plugin.php
Created October 19, 2018 18:58
Evo to Revo URI Plugin
<?php
/**
** OnPageNotFound
**/
$URI = $_SERVER['REQUEST_URI'];
if(strpos($URI, '.html') !== false){
$URI = ltrim(str_replace('.html','/',$URI), '/');
$resource = $modx->getObject('modResource', array('uri:='=>$URI, 'context_key:='=> $modx->context->key));
@matdave
matdave / maxi.import.php
Last active October 11, 2019 15:14
Maxi to MIGX
<?php
ini_set('max_execution_time', 72000);
ini_set('memory_limit', '2048M');
define('MODX_CORE_PATH', '/home/www/core/');
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
if(!function_exists('csv2array')){
function csv2array($filename = '', $delimiter = ',', $asHash = true)
{