Skip to content

Instantly share code, notes, and snippets.

View AndrewChamp's full-sized avatar
:octocat:
Web Application Developer / System Admin

Andrew Champ AndrewChamp

:octocat:
Web Application Developer / System Admin
View GitHub Profile
@AndrewChamp
AndrewChamp / class.installer.php
Created November 10, 2020 08:29
Downloads remote framework and unpacks contents.
<?php
/**
* EXAMPLES OF USE
*************************************
*
* Download and unzip your custom framework. Then create the database connection file.
*
* $install = new installer();
* $install->download('http://your-domain.com/framework.zip');
@AndrewChamp
AndrewChamp / search_database_tables_for_column_name.sql
Last active November 17, 2022 12:32
Search Database Tables for Column Name
# SEARCH DATABASE TABLES FOR COLUMN NAME
SELECT
table_name,
column_name,
data_type,
ordinal_position
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
@AndrewChamp
AndrewChamp / find.and.replace.sql
Created February 12, 2019 15:25
MySQL Find & Replace
UPDATE TABLE_NAME
SET COLUMN_NAME = REPLACE(COLUMN_NAME, 'string/to/find', 'string/to/replace')
# OPTIONAL: Replaces embedded strings
WHERE COLUMN_NAME LIKE ('%string_to_find%');
@AndrewChamp
AndrewChamp / .htaccess
Last active February 13, 2024 20:37
Force Port 80 or Port 443 via .htaccess. This will also remove www. from the url.
# FORCE PORT 80 (insecure / regular traffic)
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
###########################################################
#FORCE PORT 443 && REMOVE WWW. (secure / SSL)
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
@AndrewChamp
AndrewChamp / .htaccess-parse-html-as-php
Last active January 11, 2016 15:23
Parse html, htm, or anything you like as PHP via htaccess. cPanel compatible.
AddHandler application/x-httpd-php5 .htm .html
@AndrewChamp
AndrewChamp / domainAvailabilityChecker.php
Created December 22, 2015 20:51
Checks if a domain is available or taken.
<?php
$domain = parse_url($_GET['domain']);
$explode = array_reverse(explode('.', $domain['path']));
$dns = dns_get_record($explode['1'].'.'.$explode['0'], DNS_A);
if(count($dns) > 0):
print 'Domain Taken';
else:
print 'Domain Avaliable.';
@AndrewChamp
AndrewChamp / iframed.js
Last active December 24, 2018 06:11
iFrame'd Site
$(document).ready(function($) {
if(window.location !== window.parent.location){
$('header, footer').hide();
}
});
@AndrewChamp
AndrewChamp / autoloader.php
Last active December 24, 2018 06:11
PHP Autoloader - Includes files for classes that are instantiated.
<?php
spl_autoload_register(function($class){
$directorys = array(PATH.VERSION.MODULES, INSTALL.MODULES, INSTALL.THEME.'modules/');
foreach($directorys as $directory):
if(file_exists($directory.'class.'.$class.'.php')):
require($directory.'class.'.$class.'.php');
return;
endif;
endforeach;
@AndrewChamp
AndrewChamp / keygen.php
Created September 29, 2015 02:57
Random Keygen
<?php
function keygen($length='40'){
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen($chars);
for($i = 0; $i < $length; $i++):
$str .= $chars[ rand( 0, $size - 1 ) ];
endfor;
return $str;
}
@AndrewChamp
AndrewChamp / hashing.php
Created September 29, 2015 02:50
Simple Hashing
<?php
function hasher($password, $salt){
$result = base64_encode(hash('md5', $password.$salt));
$result = substr($result, 5, -5);
return strrev($result);
}
//Example
print hasher('myPassword', time());
?>