Skip to content

Instantly share code, notes, and snippets.

View edmondscommerce's full-sized avatar

Edmonds Commerce edmondscommerce

View GitHub Profile
<?php
$glob = glob('zblog/application/views/scripts/*');
//var_dump($glob);
foreach ($glob as $g) {
if (!is_readable($g)) {
continue;
}
echo '<h1>' . $g . '</h1>
<table>
<h1>Scratch</h1>
<pre>
<?php
date_default_timezone_set('UTC');
$official_pattern='/^[\w\.]+\.[a-zA-Z]{2,4}$/';
$official_pattern_2='/^[\w\.]+\.[a-zA-Z]{2,4}(?:|\/.{3,20})$/';
$pattern = "%";
//match a www or other subdomain followed by a dot if its there,
//not required though, from very start of subject
$pattern.="\A([\w]+\.){0,1}";
@edmondscommerce
edmondscommerce / zend2.php
Created November 2, 2011 11:29
some notes from teaching zend 2
<?php
//setcookie('username', 'joseph');
//echo $_COOKIE['username'];
//Check if they have the cookie value for username
if(!empty($_COOKIE['username1'])){
//If they do display it
echo $_COOKIE['username1'];
}else{
// If they do not, display a form that will post the username
<?php
//First Off - Start the Session
session_start();
//Now Test if the Session contains a Student ID
if(array_key_exists('student_id', $_SESSION)){
//If it does, query the demo.students table for the details of that student
@edmondscommerce
edmondscommerce / paypalCentos-rhel6Fix.sh
Created March 2, 2016 09:55
Paypal TLS upgrade fix PHP on CentOS 6 and RHEL 6 without PHP code changes
#!/bin/sh
rpm -Uvh --force --nodeps --replacepkgs https://copr-be.cloud.fedoraproject.org/results/mmckinst/curl-el6/epel-6-x86_64/00143637-curl/curl-7.19.7-460.el6.x86_64.rpm
rpm -Uvh --force --nodeps --replacepkgs https://copr-be.cloud.fedoraproject.org/results/mmckinst/curl-el6/epel-6-x86_64/00143637-curl/libcurl-7.19.7-460.el6.x86_64.rpm
rpm -Uvh --force --nodeps --replacepkgs https://copr-be.cloud.fedoraproject.org/results/mmckinst/curl-el6/epel-6-x86_64/00143637-curl/libcurl-devel-7.19.7-460.el6.x86_64.rpm
php -r '$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://tlstest.paypal.com/"); var_dump(curl_exec($ch));'
@edmondscommerce
edmondscommerce / getCurrentMysqlConfigForVariable.bash
Created April 26, 2016 13:46
BASH function to get the config value for a variable from MySQL
function getCurrentMysqlConfigForVariable(){
local variable=$1
mysql -e "select variable_value from information_schema.global_variables where variable_name like '$variable'" |
while read variable_value;
do
if [[ 'variable_value' == "$variable_value" ]]
then
# skip the header
continue
fi
@edmondscommerce
edmondscommerce / moduleChecker.bash
Created April 27, 2016 11:01
Recursively check directory for Magento Modules listed as having a possible SQL injection vulnerability
#!/bin/bash
find . -type d -ipath '*app/etc/modules' | \
while read f;
do
echo $f;
ls -l "${f}" | \
grep 'EM_Quickshop.xml\|EM_Ajaxcart.xml\|Smartwave_QuickView.xml\|MD_Quick';
done | grep -B 1 'xml'
@edmondscommerce
edmondscommerce / PARTIAL.domain.com.conf
Last active May 4, 2016 11:33
Jira Nginx SSL Configuration
# /etc/nginx/conf.d/domain.com.conf
location /jira {
if ($scheme = 'http') {
rewrite ^ https://$http_host$request_uri? permanent;
}
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10M;
@edmondscommerce
edmondscommerce / BASH_function_to_email_via_Gmail_SMTP.bash
Last active August 21, 2018 07:58
BASH function to email via Gmail SMTP
# Bash function to send email via Gmail SMTP
# sendEmail [subject] [toEmail] [message] (optional attachment path)
function sendEmail(){
if (($# < 3 ))
then
echo ""
echo "Usage:"
echo "sendEmail [subject] [toEmail] [message] (optional attachment path)"
echo ""
exit 1
@edmondscommerce
edmondscommerce / PHP File Handler that remembers the pointer position when the file is closed and opens there.php
Last active June 10, 2016 11:29
This is used to remember where you where in a file the last time that you closed it. I use it when parsing log file to prevent having to go over the entire file each time when I only want to check the lines that have been added
<?php
/**
* @category EdmondsCommerce
* @package EdmondsCommerce_
* @author Ross Mitchell <ross@edmondscommerce.co.uk>
*/
namespace EdmondsCommerce\ServerHardening;
use Symfony\Component\Yaml\Yaml;