Skip to content

Instantly share code, notes, and snippets.

@yireo
yireo / evaldecode.php
Created June 24, 2014 15:23
Decode evil scripts encoded with eval(gzinflate(base64_decode()))
<?php
/*
* Basic script to decrypt files encoded with eval(gzinflate(base64_decode($data)));
*/
$file = 'encrypted.php';
$content = file_get_contents($file);
function evaldecode($content, $step = 0) {
//echo "STEP $step\n";
@yireo
yireo / .gitignore
Created July 16, 2017 11:11
Magento 2 gitignore file
# Metadata
/.buildpath
/.cache
/.metadata
/.project
/.settings
atlassian*
/nbproject
/sitemap
/.idea
@yireo
yireo / phpstorm_xdebug_gnome.md
Last active July 30, 2022 17:35
Open up XDebug links in PhpStorm under Gnome

Open up XDebug links in PhpStorm under Gnome

Configure XDebug in PHP

Open up your XDebug file (possibly /etc/php.d/15-xdebug.ini) and configure XDebug:

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.file_link_format="phpstorm://open?file=%f&line=%l"

Restart your webserver to activate XDebug.

@yireo
yireo / create_website_scope.php
Last active October 1, 2020 11:02
Magento script to create a new Website, new Store Group, new Store View and new Root Catalog - all linked together.
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog
@yireo
yireo / local.xml
Created February 12, 2013 10:53
Magento XML-layout update to set NOINDEX,FOLLOW tag on Layered Navigation pages (kudos @hans2103)
<layout>
<catalog_category_layered>
<reference name="head">
<action method="setRobots"><meta>NOINDEX,FOLLOW</meta></action>
</reference>
</catalog_category_layered>
<catalog_category_layered_nochildren>
<reference name="head">
<action method="setRobots"><meta>NOINDEX,FOLLOW</meta></action>
@yireo
yireo / phpbrew-install.md
Last active March 25, 2020 14:32
phpbrew installation on Fedora

Installation notes for phpbrew on Fedora

Pre-install

Getting the dependancies right:

$ yum install libxml2-devel openssl-devel curl-devel \
      bzip2-devel libmcrypt-devel readline-devel \
      libxslt-devel httpd-devel

Brewing PHP

<?php
// User settings
define('userDataName', 'EXAMPLE');
define('userDataUsername', 'example');
define('userDataEmail', 'info@example.com');
define('userDataPassword', 'YOURPASSWORD');
// Detect the Joomla! directory
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
@yireo
yireo / yr_rename_database_table_prefix.php
Created July 3, 2013 15:23
PHP-script to rename MySQL database tables in a MySQL database - for instance when using Joomla!
<?php
$database_host = 'localhost'; // Database hostname
$database_user = 'root'; // Database username
$database_password = ''; // Database password
$database_name = 'myjoomla'; // Database name
$new_table_prefix = 'zkl_'; // New table prefix
$old_table_prefix = 'jos_'; // Old table prefix (optional)
$test = false; // Test-run (true or false)
// NO NEED TO EDIT BELOW THIS LINE
<?php
// Basic settings
$storeCodes = array('bork');
$attributes = array('name', 'description');
$categoryIds = array();
// Initialize Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@yireo
yireo / getSkuById.php
Created April 9, 2016 07:29
Magento function to fetch Magento product SKU by ID
<?php
function getSkuById($productId)
{
$productResourceModel = Mage::getResourceModel('catalog/product');
$adapter = Mage::getSingleton('core/resource')->getConnection('core_read');
$select = $adapter->select()
->from($productResourceModel->getEntityTable(), 'sku')
->where('entity_id = :entity_id');
$bind = array(':entity_id' => (string)$productId);
$productSku = $adapter->fetchOne($select, $bind);