-
A database for 2022 (hn) (Tailscale uses SQLite)
-
I'm all-in on server-side SQLite (hn) (Fly.io acquires Litstream)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A custom FormIt hook for CSRF Protection | |
* | |
* Usage: | |
* Append this Plugin as PreHook and Hook | |
* | |
* [[!FormIt? | |
* &preHooks=`FormItCSRF` | |
* &hooks=`spam,FormItCSRF,email` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Only executable via SSH | |
if (PHP_SAPI !== 'cli') exit(); | |
// Instantiate MODX | |
@include(dirname(__FILE__) . '/config.core.php'); | |
if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/'); | |
include_once (MODX_CORE_PATH . "model/modx/modx.class.php"); | |
$modx= new modX(); | |
$modx->initialize('web'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add as a plugin | |
* System Event: OnHandleRequest | |
*/ | |
if (!headers_sent()) { | |
header('X-Powered-By: MODX Revolution'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHP memory limit for this site | |
define( 'WP_MEMORY_LIMIT', '128M' ); | |
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit. | |
// Database | |
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database. | |
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users) | |
// Explicitely setting url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dashboard widget to show number of Manager messages | |
$id = $modx->user->get('id'); | |
$output = 'No messages.'; | |
$total = $modx->getCount('modUserMessage',array( | |
'recipient' => $id, | |
)); | |
if($total) { | |
$output = 'You have ' . $total . ' messages'; | |
$unread = $modx->getCount('modUserMessage',array( | |
'recipient' => $id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* includeFile snippet is to include any file in MODX's page, either in resource, template, or chunk | |
* | |
* @author goldsky <goldsky@virtudraft.com> | |
* @copyright Copyright (c) 2015, goldsky | |
* @example [[!includeFile? &file=`[[++core_path]]statics/chunks/mychunk.chunk.tpl`]] | |
* [[!includeFile? &file=`[[++core_path]]statics/snippets/mysnippet.snippet.php`]] | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored) | |
// http://youtu.be/dQw4w9WgXcQ | |
// http://www.youtube.com/embed/dQw4w9WgXcQ | |
// http://www.youtube.com/watch?v=dQw4w9WgXcQ | |
// http://www.youtube.com/?v=dQw4w9WgXcQ | |
// http://www.youtube.com/v/dQw4w9WgXcQ | |
// http://www.youtube.com/e/dQw4w9WgXcQ | |
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Dashboard widget to report on the number of errors in the Error Log | |
$logfile = MODX_CORE_PATH . 'cache/logs/error.log'; | |
if(!$f = fopen($logfile, 'rb')) return 'Could not open log file.'; | |
$lines = 0; | |
while (!feof($f)) { | |
$lines += substr_count(fread($f, 8192), "(ERROR "); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// SiteSummary snippet for Dashboard widget | |
// W. Shawn Wilkerson | |
$o = '<table class="classy" style="width:100%;"><thead><tr style="background:#DDE3EA;color:#000;">'; | |
$o .= '<th style="width:50%;padding:8px 0;text-align:center;">Resources</th>'; | |
$o .= '<th style="width:50%;padding:8px 0;text-align:center;">Elements</th>'; | |
$o .= '</tr></thead><tbody><tr><td style="padding:0 1em;">'; | |
$o .= 'Published Resources: ' . $modx->getCount('modResource', array('published' => '1')); | |
$o .= '<br>Unpublished Resources: ' . $modx->getCount('modResource', array('published' => '0')); |
NewerOlder