Skip to content

Instantly share code, notes, and snippets.

<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if ($ip != 'my-ip') {
@epson121
epson121 / customers_xcart_magento_2.php
Created January 6, 2015 15:38
xcart_to_magento_customers.php
<?php
require_once 'app/Mage.php';
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
set_time_limit(0);
Mage::app('admin')->setUseSessionInUrl(false);
@epson121
epson121 / customers_xcart_magento
Last active August 29, 2015 14:12
xcart_to_magento_customers.php
<?php
$magento_header = array("website","email","group_id","disable_auto_group_change","firstname","lastname","password_hash","billing_prefix","billing_firstname","billing_middlename","billing_lastname","billing_suffix","billing_street_full","billing_street1","billing_street2","billing_street3","billing_street4","billing_street5","billing_street6","billing_street7","billing_street8","billing_city","billing_region","billing_country","billing_postcode","billing_telephone","billing_company","billing_fax","shipping_prefix","shipping_firstname","shipping_middlename","shipping_lastname","shipping_suffix","shipping_street_full","shipping_street1","shipping_street2","shipping_street3","shipping_street4","shipping_street5","shipping_street6","shipping_street7","shipping_street8","shipping_city","shipping_region","shipping_country","shipping_postcode","shipping_telephone","shipping_company","shipping_fax","created_in","is_subscribed","group","prefix","middlename","suffix","taxvat");
// Array
// (
// [0] => login
@epson121
epson121 / gist:f382f8c292ba92856e54
Created November 9, 2014 19:58
apiv2 call on sales order list
$params = array('complex_filter' =>
array(
array('key' => 'increment_id', 'value' => array('key' => 'gt', 'value' => '100015225'))
)
);
// $result = $proxy->salesOrderList((object)array('sessionId' => $sessionId->result, 'filters' => array(array('increment_id' =>'100015226'))));
$result = $proxy->salesOrderList((object)array('sessionId' => $sessionId->result, 'filters' => $params));
@epson121
epson121 / xmlrpc_test.php
Created September 24, 2014 10:00
xmlrpc_test script
<?php
require_once('app/Mage.php');
$client = new Zend_XmlRpc_Client('----url----/api/xmlrpc/');
// If somestuff requires api authentification,
// we should get session token
$session = $client->call('login', array('username', 'password'));
$res = $client->call('call', array($session, 'catalog_product.info', 'id'));
<?php
if(!in_array($_SERVER['REMOTE_ADDR'], array('212.92.214.170','74.97.45.98', '213.147.103.86'))){
echo "Maintenance mode.";
exit;
}
@epson121
epson121 / rewrites.php
Last active August 29, 2015 14:01
List all rewrites in magento application
<?php
$folders = array('app/code/local/', 'app/code/community/');//folders to parse
$configFiles = array();
foreach ($folders as $folder){
$files = glob($folder.'*/*/etc/config.xml');//get all config.xml files in the specified folder
$configFiles = array_merge($configFiles, $files);//merge with the rest of the config files
}
$rewrites = array();//list of all rewrites
foreach ($configFiles as $file){
@epson121
epson121 / berw.js
Last active August 29, 2015 14:01
Berwaz foto contest get highest vote
function returnInt(x){return parseInt(x, 0);};var a=document.getElementsByClassName('votes');var c=[];for(var i=0;i<a.length;i++){c[i]=a[i].getElementsByTagName('strong')[0].innerHTML};Math.max.apply(Math,c.map(returnInt));
// Some helpful snippets of code to use when debugging magento:
var_export(get_class_methods(get_class($classname)));
var_export(array_keys( $this->getData() )); //or
var_export(array_keys( $object->getData() ));
var_export($object->debug());
// When using with Mage::log()...
Mage::log(var_export(get_class_methods(get_class($classname)), TRUE),NULL,'some_filename.log');
https://sublime.wbond.net/installation#st2