This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//TEST CODE | |
//Simple example of links to files in a privately accessible s3 bucket being authorised. | |
//If the link is followed directly a 403 error will be returned with an xml error page. | |
//Instead jquery catches the click and creates an authorisation for the request assisted by | |
//a server that holds the access keys. The region, bucket and key are extracted and then a | |
//server-side authorisation query string is requested, appended to the link href and then the | |
//file is requested from s3. | |
// Bucket needs CORS turning on (for GET) and s3:GetObject permission needs to be present. | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* dbpdo.php | |
* | |
* Wrapper class for PDO to handle connecting to different types of db (mssql and mysql). | |
* Also handles mssql on both windows and linux platforms by using sqlsrv and dblib pdo drivers. | |
* Adds a logging and timing facility for queries and prepared statements. | |
* A logging function can be passed to the constructor to capture all calls to the PDO routines. | |
* | |
* All normal PDO and PDOStatement functions can be used with no alterations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Logger class. | |
* Logs to file and defaults to a /logs/ subdirectory under this script location | |
* | |
* This is a bit mickey-mouse as loggers go, but helpful. | |
* | |
*/ | |
// ------------------------------------------------------------------------- // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JS form data verification routine. Uses data attributes on the field: | |
* "data-verify": regex pattern that must be true for no error. | |
* "data-error": error message. | |
* "data-options": options separated by "|". First is regex parameters i/g/m as per the RegExp constructor, | |
* second is inversion of the test if "not", or "req" if the test must pass and a non-empty field is | |
* not allowed (both req and not can be used if separated by a ";" or space). Third is the name of a special test function when | |
* a regex isn't sufficient to do the test. Test fn must be within ValidateForm (or added to the prototype). | |
* If an option is blank, it can just be left empty e.g. "|req" if there are no regex params, but data-verify | |
* field must be present so the field is recognised as needing verifying. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//js async loader | |
var $$ = $$ || {}; | |
$$.asyncScriptLoader = function (url) { | |
//get currently loaded scripts | |
var allScripts = document.getElementsByTagName('script'), | |
alreadyLoaded = false; | |
function onLoad(){}; //url is parameter | |
function onError(){}; //url is parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Mysql DB Session class with PDO | |
* | |
* Uses row locking to handle concurrent ajax access | |
* | |
* Requires a PDO db connection to be handed to the session constructor. | |
* | |
* Table: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Provision the vultr Centos6 LAMP stack as it is a bit broken as standard | |
#update and fetch missing things | |
yum update -y | |
yum install -y php56u-bcmath php56u-imap php56u-intl php56u-pecl-memcache | |
#disable opcache for development | |
perl -pi -e 's/^opcache.enable=1/opcache.enable=0/' /etc/php.d/10-opcache.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#install memcache on AWS lightsail bitnami | |
#memcache (no "d") is handy for cross platform testing as it will work on windows | |
#WAMP etc. where the memcached version does not appear to have a windows port) | |
#(lightsail lamp has the build environment gcc etc. already installed) | |
#memcache version | |
VERSION='3.0.8' | |
cd /root/bitnami |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//e.g.semi-colon separated define list of all allowable hosts (does not need to show sub-domains - works automatically) | |
//$valid_hosts = 'first-host.com;second-host.com'; | |
//create absolute url for page address - quite tricky to make this work on linux / windows and shared hosting and also | |
//php built-in web server. | |
//Constructed URL ends up in a trailing slash with the $target parameter appended. | |
//defaults to not checking a valid host list unless one is supplied | |
function get_host_url($target = '', $valid_hosts = '*'){ | |
// Get HTTP/HTTPS (the possible values for this vary from server to server) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* PHP backup class. Based on an old script updated to use mysqli_ routines. | |
* Extended and bugfixed - now handles NULL's, doesn't quote numbers, handles utf-8, | |
* creates multiple inserts and breaks to a new one after a defined number, creates gzip | |
* or zip files, generates foriegn key disable and table lock/unlock statements. | |
* Handles Views, Triggers, Procedures and Functions. | |
* Optionally removes DEFINER from views/procs/funcs and DB names from views. | |
* | |
* Thanks to Phil Rodgers (https://github.com/placeposition) for spotting the field type |
OlderNewer