Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / get_all_permissions.sh
Created September 21, 2012 15:53
This script creates a text file that contains all the current permissions of the entire linux system.
#!/bin/bash
### ——————————————————————– ###
# This script creates a text file that contains all the current permissions
# of the entire linux system.
# Run: sudo bash get_all_permissions.sh
# Location: http://virtualparadise.wordpress.com/2010/04/29/linux-repair-permissions
@josephspurrier
josephspurrier / color.php
Last active August 29, 2015 13:55
CSS Style Selectors for Color
<!DOCTYPE HTML>
<html>
<style>
* {
color: white;
}
p {
color: green;
}
@josephspurrier
josephspurrier / loadCSV.php
Last active September 28, 2022 10:34
Parse a CSV file in PHP, remove hidden characters, escape fields to prepare for MySQL, and return an associative array.
// Auto detect line endings
ini_set('auto_detect_line_endings', true);
function loadCSV($file)
{
// Create an array to hold the data
$arrData = array();
// Create a variable to hold the header information
$header = NULL;
@josephspurrier
josephspurrier / .htaccess
Last active August 29, 2015 13:57
Apache root configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
# Remove Apache variations on URL, best for SEO
Options -MultiViews
<IfModule mod_dir.c>
# Ensure index.php is only allowed as index
DirectoryIndex index.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@josephspurrier
josephspurrier / .htaccess
Last active August 29, 2015 13:57
Apache CheckSpelling for .htaccess
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
@josephspurrier
josephspurrier / nginx.conf
Last active June 1, 2017 04:46
Nginx root configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
http {
# Ensure index.php is only allowed as index
index index.php;
server {
listen 80;
server_name localhost;
root /var/www;
# Manage the slashes via rewrites
@josephspurrier
josephspurrier / .htaccess
Last active August 29, 2015 13:57
Apache sub folder configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
# Strip main index.php and query string
RewriteCond %{THE_REQUEST} ^GET./+test/+index\.php\?
RewriteRule . /test/? [R=301,NE,L]
# Strip multiple slashes and query string
RewriteCond %{THE_REQUEST} (.*)//(.*)
@josephspurrier
josephspurrier / nginx.conf
Last active January 26, 2018 05:32
Nginx sub folder configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
location @testrewrites {
# Send all requests to index.php
rewrite ^ /test/index.php last;
}
# Else use this location block
location ~* ^/test/.*\.php$ {
# Strip subdir index.php and query string
if ( $request_uri ~* ^/(.*)/index\.php\?+) {
rewrite (?i)^/(.*)/index\.php /$1/? permanent;
@josephspurrier
josephspurrier / contentstrip.php
Last active August 29, 2015 13:58
Strip content from between header and footer tags and insert into WordPress database
<?php
function getMiddle($first, $end, $contents, $file)
{
$arrBegin = explode($first, $contents);
if (count($arrBegin) != 2)
{
echo 'Bad Begin: '.$file;
die();
/**
* Get the OS from the HTTP_USER_AGENT string
*
* * @link http://stackoverflow.com/questions/18070154/get-operating-system-info-with-php
*
* @return string
*/
function getOS()
{
$user_agent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'NA');