Skip to content

Instantly share code, notes, and snippets.

View mklooss's full-sized avatar

Mathis Klooß mklooss

View GitHub Profile
@mklooss
mklooss / Observer.php
Created November 13, 2013 09:09
Magento form_key validation failed in 1.8 after upgrade from 1.7
<?php
class MyCompany_MyModul_Model_Observer
{
/**
*
*
*/
public function addDisableValidatFromKey(Varien_Event_Observer $observer)
{
<?php
$cfg = array(
'server' => 'mongodb://127.0.0.1:27017/?journal=false&w=1&wTimeoutMS=20000',
'db' => 'cm_cache',
'collection' => 'cm_cache'
);
// set to timezone to UTC, like magento do this
date_default_timezone_set('UTC');
@mklooss
mklooss / init.sh
Last active March 4, 2016 12:47
iptables whitelisting with file source
iptables -N ftpwhitelist
iptables -A INPUT -j ftpwhitelist
@mklooss
mklooss / Observer.php
Created January 9, 2014 08:32
Magento: add layout xml via event to add the layout file direct before local.xml
<?php
class Loewenstark_Layout_Model_Observer
{
// set loewenstark_layout.xml before local.xml
public function addLayoutXml($event)
{
$xml = $event->getUpdates()
->addChild('loewenstark_layout');
/* @var $xml SimpleXMLElement */
@mklooss
mklooss / copyImages.php
Last active January 3, 2016 05:29
Magento Copy Active Images
<?php
define('DS', DIRECTORY_SEPARATOR);
$xml = simplexml_load_file('app/etc/local.xml');
$mysql_user = (string)$xml->global->resources->default_setup->connection->username;
$mysql_password = (string)$xml->global->resources->default_setup->connection->password;
$mysql_dbname = (string)$xml->global->resources->default_setup->connection->dbname;
$mysql_host = (string)$xml->global->resources->default_setup->connection->host;
@mklooss
mklooss / mysqldump.sh
Created January 20, 2014 13:52
Magento MySQL Dump
#!/bin/bash
MYSQL_HOST=`xmllint --nocdata --xpath 'string(//config/global/resources/default_setup/connection/host)' app/etc/local.xml`
MYSQL_PASS=`xmllint --nocdata --xpath 'string(//config/global/resources/default_setup/connection/password)' app/etc/local.xml`
MYSQL_USER=`xmllint --nocdata --xpath 'string(//config/global/resources/default_setup/connection/username)' app/etc/local.xml`
MYSQL_DB=`xmllint --nocdata --xpath 'string(//config/global/resources/default_setup/connection/dbname)' app/etc/local.xml`
BACKUPDIR="$HOME/backups/sql"
DIRNAME=`date +%Y-%m-%d`;
GZIP=$(which gzip);
@mklooss
mklooss / iptables.sh
Last active August 29, 2015 13:56
nginx UserAgent Blacklist, so i found this UserAgent on different system.
for ip in $(grep -ri Baidu /var/log/nginx/access.log | cut -f1 -d' ' | sort | uniq); do echo $ip && iptables -I INPUT -s $ip -j DROP; done
for ip in $(grep -ri 200please /var/log/nginx/access.log | cut -f1 -d' ' | sort | uniq); do echo $ip && iptables -I INPUT -s $ip -j DROP; done
for ip in $(grep -ri majestic12 /var/log/nginx/access.log | cut -f1 -d' ' | sort | uniq); do echo $ip && iptables -I INPUT -s $ip -j DROP; done
for ip in $(grep -ri opensiteexplorer /var/log/nginx/access.log | cut -f1 -d' ' | sort | uniq); do echo $ip && iptables -I INPUT -s $ip -j DROP; done
for ip in $(grep -ri seokicks /var/log/nginx/access.log | cut -f1 -d' ' | sort | uniq); do echo $ip && iptables -I INPUT -s $ip -j DROP; done
@mklooss
mklooss / .htaccess
Created March 21, 2014 10:18
Wordpress DDoS via Pingback
<FilesMatch "^(xmlrpc\.php|wp-trackback\.php)">
Order Deny,Allow
Deny from all
</FilesMatch>
@mklooss
mklooss / install-1.0.0.0.php
Last active August 29, 2015 13:57
Dummy Installer Element for Magento
<?php
$installer = $this;
/* @var Loewenstark_Dummy_Model_Resource_Setup $installer */
$installer->startSetup();
$mail = '';
$name = '';
$company = '';
$phone = '';
$fax = '';
@mklooss
mklooss / reindex.php
Last active August 29, 2015 13:57
Magento Reindex All, some parts from AvS_Fastsimpleimport :)
<?php
if(php_sapi_name() != 'cli')
{
echo "only for cli!";
exit;
}
require 'app/Mage.php';
Mage::app('admin');