Skip to content

Instantly share code, notes, and snippets.

View earth3300's full-sized avatar

Earth3300 earth3300

View GitHub Profile
@earth3300
earth3300 / .htaccess
Last active December 17, 2022 07:11
A PHP script to print out different versions of an .htaccess file, as needed.
# Generated automatically by: htaccess.php
# This PHP script should work only a local machine.
# Code: d9015a.
# Created: 2019-03-14
# Updated: 2019-06-17
# Time: 21:11:32 EDT
# SECURITY BEGIN (Deny First, Then Allow)
<FilesMatch "xmlrpc.php|config|error|debug|changelog|readme|license">
@earth3300
earth3300 / printer.htac.php
Created March 11, 2020 15:52
Prints an htaccess file.
<?php
/**
* Htaccess Printer
*
* Prints an `.htaccess` file.
*
* @package Earth3300\EC01
* @since 1.0.1
* @author Clarence J. Bos <cbos@tnoep.ca>
* @copyright Copyright (c) 2018, Clarence J. Bos
@earth3300
earth3300 / _wp_upload_dir-wp.php
Last active May 29, 2021 15:16
The _wp_upload_dir function that tries to do too much (and fails when you need it most).
/**
* A non-filtered, non-cached version of wp_upload_dir() that doesn't check the path.
*
* @since 4.5.0
* @access private
*
* @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
* @return array See wp_upload_dir()
*/
function _wp_upload_dir( $time = null ) {
@earth3300
earth3300 / SecureSessionHandler.php
Created January 10, 2021 00:46 — forked from eddmann/SecureSessionHandler.php
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
<footer class="site site-footer">
<div class="inner">
<nav class="console"
style="display: table; margin: 0 auto; text-align: center;">
<div>
<a href="/" class="arrow previous" title="Previous Page">
<span class="icon icon-left">‹</span>
</a>
<a href="/#" class="arrow next" title="Next Page">
<span class="icon icon-right">›</span>
@earth3300
earth3300 / paragraph.css
Last active August 8, 2020 20:19
Paragraph styling to normalize text across websites. Font is Open Sans. Note the metric units in font-size and text-indent.
p {
max-width: 14.5cm !important;
font-size: 3mm !important;
text-indent: 4mm !important;
line-height: 1.5 !important;
text-align: justify !important;
margin: 0 !important;
}
@earth3300
earth3300 / .htaccess-dir-cached
Last active July 20, 2020 18:55
# Rewrite all requests to /foo
# Rewrite to the cached file if it exists and is not a post or attachment.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# RewriteCond %{REQUEST_METHOD} !=POST
# RewriteCond %{QUERY_STRING} !.*=.*
# RewriteCond %{DOCUMENT_ROOT}/$1/index.html -f
# RewriteRule ^(.*) /$1/index.html [L]
</IfModule>
@earth3300
earth3300 / get_paths.php
Last active March 6, 2020 19:01
Get the Paths Used in the Current Project
/**
* Get the Paths Used in the Current Project
*
* Uses options values if these are set. Modify on a per-project basis.
* Intended to be used to save and retrieve files, but can be used more
* generically as it sets and standardizes the document root and the relative
* path to the directory in which the containing file resides.
*
* Last updated: 2020-03-06
* No. of lines: 42
@earth3300
earth3300 / pre-dump.php
Last active March 6, 2020 17:38
Uses var_dump with <pre>...</pre> to dump and format an array or string when debugging (usually locally).
if ( ! function_exists( 'pre_dump' ) ) {
/**
* Uses var_dump with <pre>...</pre> to dump and format an array or string when debugging (usually locally).
*
* Requires the debug flag to be set `?debug` AND a file named .security
* to be present in the same directory to function. This prevents it from
* inadvertangly working online UNLESS the `.security` file is present.
* Converts &, ", ', < and > to their corresponding HTML entities.
*
* @link https://www.php.net/manual/en/function.htmlspecialchars.php
@earth3300
earth3300 / .htaccess-www-https-dir
Last active March 5, 2020 21:20
ROOT directory .htaccess script when ALL files are in sub-directory.
# ALWAYS rewrite to the specified directory (excluding the directory itself).
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/main/
RewriteRule ^(.*)$ /main/$1
</IfModule>