Skip to content

Instantly share code, notes, and snippets.

View chrisdempsey's full-sized avatar

Chris Dempsey chrisdempsey

View GitHub Profile
@chrisdempsey
chrisdempsey / 00 MODX Trustpilot RSS Reade - readme.txt
Last active August 29, 2015 14:05
Trustpilot RSS Reader for MODX
Collection of code blocks for the Trustpilot RSS Reader example.
@chrisdempsey
chrisdempsey / 00 Sweet Captcha FormIt Hook for MODX - readme.txt
Last active August 29, 2015 14:06
Sweet Captcha FormIt Hook for MODX
Collection of code blocks to create a FormIt Hook for Sweet Captcha.
Sweet Captcha - Fun and Human Friendly Captcha: http://sweetcaptcha.com/ (requires no cost account to be set up).
01 SwtCaptchaFormItHook.php - Hook to validate Sweet Captcha
02 SwtCaptchaHTML.php - Output Sweet Captcha HTML
03 sweetcaptcha.php - 01 SwtCaptchaFormItHook.php assumes sweetcaptcha.php is in your web root directory.
Note: 03 sweetcaptcha.php requires your account credentials to be defined by updating the placeholders at the
@chrisdempsey
chrisdempsey / .htaccess
Last active August 29, 2015 14:06 — forked from opengeek/.htaccess
# Add this before your MODX Friendly URLs RewriteCond's and RewriteRule...
RewriteCond /abs/path/to/docroot/statcache%{REQUEST_URI} -f
RewriteRule ^(.*)$ /statcache/$1 [L,QSA]
@chrisdempsey
chrisdempsey / Contract Killer 3.md
Created May 25, 2016 18:25 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

<?php
/**
*
* Plugin fires OnWebPagePrerender system event, loads Minify HTML by Mr Clay and minifies the requested Resource HTML inc. inline css and js.
*
* If used in conjunction with StatCache the minified HTML is cached and served as a flat file via IIS Rewrite.
*
* CREDITS
*
* http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins
<?php
/**
* registerAssets
*
* DESCRIPTION
*
* Registers assets to MODX Placeholder.
*
* Requires call to [[activateAssets]] before closing body tag in template. This grabs files list from the Placeholder and outputs a javascript block
* of assets to be injected after page load.
<?php
/**
* activateAssets
*
* DESCRIPTION
*
* Activates assets registered in placeholder.
*
* PROPERTIES:
*
@chrisdempsey
chrisdempsey / in_arrayi.php
Created June 24, 2017 23:05 — forked from sepehr/in_arrayi.php
PHP: Case-insensitive in_array()
<?php
/**
* Case-insensitive in_array() wrapper.
*
* @param mixed $needle Value to seek.
* @param array $haystack Array to seek in.
*
* @return bool
*/
@chrisdempsey
chrisdempsey / sessionmanager.class.php
Created August 1, 2017 13:36
SessionManager: A script that can be used for easy control over your session variables
<?php
/**
* SessionManager
* A script that can be used for easy control over your session variables.
* Put this script in your core/components/ folder, inside a sessionman/ subdirectory.
*
* Load this one in your snippets/plugins like;
*
* $sessman = $modx->getService('session','SessionManager', $modx->getOption('sessman.core_path',null,$modx->getOption('core_path').'components/sessionman/'), $scriptProperties);
* if(!($sessman instanceof SessionManager)) { $modx->log(modX::LOG_LEVEL_ERROR, 'Session manager could not be loaded..'); return ''; }
<?php
function send_http_auth_headers(){
header('WWW-Authenticate: Basic realm="Your Website Name Restricted"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please speak to an administrator for access to the this feature.';
exit;
}
add_action('template_redirect', 'maybe_add_http_auth_basic', 0);
function maybe_add_http_auth_basic(){
# Add your specific URI segment (i.e. http://example.com/segment-string/)