Skip to content

Instantly share code, notes, and snippets.

View zaigham's full-sized avatar
🌏

Zaigham R. zaigham

🌏
View GitHub Profile
@AidasK
AidasK / HowToDeleteAllCloudflareRecors.md
Last active November 5, 2024 17:22
Cloudflare delete all DNS records. Just go to cloudflare dns zones, open your browers developer console and paste this javascript code.

image

Real developers are not used to clicking, it's allways easier to write a script to do it for you.
<?php
/**
* A custom FormIt hook for CSRF Protection
*
* Usage:
* Append this Plugin as PreHook and Hook
*
* [[!FormIt?
* &preHooks=`FormItCSRF`
* &hooks=`spam,FormItCSRF,email`
@sepiariver
sepiariver / sample_json_export.php
Last active December 22, 2023 12:26
Example of export script from MODX Resources to JSON, for importing to another site.
<?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');
@Mark-H
Mark-H / PoweredBy.php
Created January 26, 2016 18:27
MODX X-Powered-By header
<?php
/**
* Add as a plugin
* System Event: OnHandleRequest
*/
if (!headers_sent()) {
header('X-Powered-By: MODX Revolution');
}
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active November 7, 2024 08:58
All those damned wp-config constants you can never remember.
<?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
@goldsky
goldsky / includeFile.snippet.php
Last active July 20, 2016 12:46
includeFile snippet is to include any file in MODX's page, either in resource, template, or chunk
<?php
/**
* includeFile snippet is to include any file in MODX's page, either in resource, template, or chunk
*
* @author goldsky <[email protected]>
* @copyright Copyright (c) 2015, goldsky
* @example [[!includeFile? &file=`[[++core_path]]statics/chunks/mychunk.chunk.tpl`]]
* [[!includeFile? &file=`[[++core_path]]statics/snippets/mysnippet.snippet.php`]]
*
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?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
@opengeek
opengeek / src-Middleware-MODSlim.php
Created June 9, 2015 15:52
This is a proof of concept for using MODX 2.x as a dependency in a Slim application
<?php
/*
* This file is part of the MODSlim package.
*
* Copyright (c) Jason Coward <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@sepiariver
sepiariver / ContentBlocksTemplates.php
Last active December 21, 2017 12:09
Scope ContentBlocks (modmore's premium plugin for MODX) to specific templates
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnDocFormPrerender':
if (!is_object($resource)) { // prevents bad error when user doesn't have perms to resource
$modx->log(modX::LOG_LEVEL_ERROR, '[ContentBlocks Templates] No Resource Object on line: ' . __LINE__);
return;
}
// a system setting must be created with the key 'contentblocks.enabled_template_ids'
$enabledTemplates = array_map('trim', explode(',', $modx->getOption('contentblocks.enabled_template_ids')));