Skip to content

Instantly share code, notes, and snippets.

Igor Buyanov artifex404

  • Finland
Block or report user

Report or block artifex404

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@artifex404
artifex404 / wordpress_change_domains.sql
Last active Apr 21, 2016
This query will find and replace URLs in all standard WordPress installation SQL tables. Remember to save the permalinks from the administration panel after doing this query.
View wordpress_change_domains.sql
SET @olddomain = "'olddomain.dev'";
SET @newdomain = "'newdomain.com'";
SET @prefix = "wp_";
SET @postmeta = CONCAT('UPDATE ', @prefix, 'postmeta SET meta_value = REPLACE(meta_value,', @olddomain, ',',@newdomain,')');
SET @excerpt = CONCAT('UPDATE ', @prefix, 'posts SET post_excerpt = REPLACE(post_excerpt,', @olddomain, ',',@newdomain,')');
SET @content = CONCAT('UPDATE ', @prefix, 'posts SET post_content = REPLACE(post_content,', @olddomain, ',',@newdomain,')');
SET @guid = CONCAT('UPDATE ', @prefix, 'posts SET guid = REPLACE(guid,', @olddomain, ',',@newdomain,')');
SET @options = CONCAT('UPDATE ', @prefix, 'options SET option_value = REPLACE(option_value,', @olddomain, ',',@newdomain,') WHERE option_name = "siteurl" OR option_name = "home"');
View get-ip-address-optimized.php
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
$items = explode(',', $_SERVER[$key]);
You can’t perform that action at this time.