Skip to content

Instantly share code, notes, and snippets.

@redesigned
redesigned / magento_logging
Created September 22, 2013 02:53
Magento Logging
#Log to your own logfile
Mage::log('My log entry', null, 'mylogfile.log');
#Log to the system logfile
Mage::log('My log entry');
#Log to the exception logfile
Mage::logException($e);
@redesigned
redesigned / mod_security
Created September 18, 2013 11:19
mod_security
Troubleshooting Mod_Security 2.5:
The first step is to identify which rule is blocking your users or breaking your site. To see what is happening, check your Apache Error log or your Mod_Security log. In your logs, you will see something like this:
Pattern match "(?:cd |\;|php |echo |perl |killall |python |rpm |yum |apt-get |emerge |lynx |links |mkdir |elinks |wget |lwp-(?:download|request|mirror|rget) |id|uname |cvs |svn |(?:s|r)(?:cp|sh) |net(?:stat|cat) |rexec |smbclient |t?ftp |ncftp |curl |telnet |g?cc |cp ..." at REQUEST_URI. [file "/etc/modsecurity/10_asl_rules.conf"]
[line "587"] [id "340037"] [rev "3"] [msg "Atomicorp.com - FREE UNSUPPORTED DELAYED FEED - WAF Rules: Generic command injection"] [severity "CRITICAL"]
yoursite.com 81.99.13.12 340037 [07/Jan/2011:22:43:29 --0800]
Pattern match "(?:cd |\;|php |echo |perl |killall |python |rpm |yum |apt-get |emerge |lynx |links |mkdir |elinks |wget |lwp-(?:download|request|mirror|rget) |id|uname |cvs |svn |(?:s|r)(?:cp|sh) |net(?:stat|cat) |rexec |smbclie
@redesigned
redesigned / backup_database
Created September 14, 2013 02:25
Backup and Restore Database via SSH
mysqldump --user username --password='password' databasename | gzip -9 > ./backup_database.sql.zip
@redesigned
redesigned / mod_rewrites
Last active December 19, 2023 11:44
Helpful Mod Rewrites and .htaccess rules
#### IMAGE PROTECTION ####
#protect images from hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domainname.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|bmp|tiff|svg)$ - [NC,F,L]
#protect images from hotlinking send new image
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domainname.com [NC]
@redesigned
redesigned / shell
Last active October 19, 2016 19:30
Wordpress Shell Commands
Install:
wget --no-check-certificate https://wordpress.org/latest.tar.gz
tar xvzf latest.tar.gz
cp -rf wordpress/* .
rm -r wordpress
rm latest.tar.gz
@redesigned
redesigned / remove-dotted-outlines
Created August 7, 2013 07:15
Remove annoying dotted outlines from around links and objects when clicked. In Firefox especially.
/* Remove Link Outlines */
a, a:active, a:focus { outline: none; -moz-outline-style: none; }
:-moz-any-link:focus { outline: none; -moz-outline-style: none; }
*, *:focus, *:active { outline: none; -moz-outline-style: none; }
@redesigned
redesigned / magento upgrade
Last active April 9, 2018 21:26
Magneto Upgrading Commands
After upgrading:
delete all files except config.xml from the following directory:
/app/code/core/Mage/GoogleCheckout/etc
go to www.mywebsite/downloader then reinstall the package called Lib_Varien
go to /app/design/frontend/base/default/template/checkout/onepage/ file payment.phtml
(add this id to the fieldset)
<fieldset id="checkout-payment-method-load">
<?php echo $this->getChildHtml('methods') ?>
@redesigned
redesigned / functions.php
Last active March 24, 2016 12:27
Wordpress Magento Cross Integration
/* ===================================== */
/* Add This to Wordpress's /wp-content/yourtheme/functions.php file */
define('MAGENTO_ROOT', '/Volumes/Storage/www/heartandsun/store/');
define('MAGENTO_LOADER', MAGENTO_ROOT.'app/Mage.php');
if (!class_exists('Mage')) {
require_once(MAGENTO_LOADER);
umask(0);
Mage::app("default");
};
/* ===================================== */
@redesigned
redesigned / sqlfix
Created July 5, 2013 06:17
Fix for deleted shipping method, in this case matrix rate. This problem occurs as Magento is not very good at clearing out shipping methods when you delete them. The shipping method can be the name of any shipping extension you have deleted.
SELECT * FROM core_config_data WHERE path LIKE "carriers/matrixrate%";
-- If you are happy that the result set is that which you want to delete (should be around 15 rows) do following:
DELETE FROM core_config_data WHERE path LIKE "carriers/matrixrate%";
@redesigned
redesigned / favicon.html
Created June 18, 2013 16:06
Favicon (various formats and sizes/resolutions)
<!-- Note: Whenever possible keep the name favicon and put in the web root as browsers look there by default even without the link tags. -->
<!-- Note: Only types png, gif, and ico support animation. -->
<!-- Favicon - Alternate Icon Types (Mixed Browser Support in order from least to most supported.) -->
<link rel="icon" href="/favicon.bmp" type="image/bmp" />
<link rel="icon" href="/favicon.jpg" type="image/jpeg" />
<link rel="icon" href="/favicon.gif" type="image/gif" />
<link rel="icon" href="/favicon.png" type="image/png" />
<!-- Favicon - IE 5 -->
<link rel="address bar icon" href="/favicon.ico">
<!-- Favicon - IE 6 -->