Skip to content

Instantly share code, notes, and snippets.

View artifex404's full-sized avatar

Igor Buyanov artifex404

View GitHub Profile
@artifex404
artifex404 / wordpress_change_domains.sql
Last active April 21, 2016 07:12
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.
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"');
<?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]);