Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / get_all_permissions.sh
Created Sep 21, 2012
This script creates a text file that contains all the current permissions of the entire linux system.
View get_all_permissions.sh
#!/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 Aug 29, 2015
CSS Style Selectors for Color
View color.php
<!DOCTYPE HTML>
<html>
<style>
* {
color: white;
}
p {
color: green;
}
@josephspurrier
josephspurrier / loadCSV.php
Last active Feb 3, 2020
Parse a CSV file in PHP, remove hidden characters, escape fields to prepare for MySQL, and return an associative array.
View loadCSV.php
// 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 Aug 29, 2015
Apache root configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
View .htaccess
# 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 Aug 29, 2015
Apache CheckSpelling for .htaccess
View .htaccess
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
@josephspurrier
josephspurrier / nginx.conf
Last active Jun 1, 2017
Nginx root configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
View nginx.conf
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 Aug 29, 2015
Apache sub folder configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
View .htaccess
<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 Jan 26, 2018
Nginx sub folder configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
View nginx.conf
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 Aug 29, 2015
Strip content from between header and footer tags and insert into WordPress database
View contentstrip.php
<?php
function getMiddle($first, $end, $contents, $file)
{
$arrBegin = explode($first, $contents);
if (count($arrBegin) != 2)
{
echo 'Bad Begin: '.$file;
die();
View browserdetection.php
/**
* 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');
You can’t perform that action at this time.