View cloudflare-masive.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
RUN: | |
composer install cloudflare/sdk | |
*/ | |
require_once('vendor/autoload.php'); | |
$domains = array('domain1.com','domain2.com'); | |
$key = new \Cloudflare\API\Auth\APIKey('useremail@email.com', 'ApiKey'); |
View functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend_search_tag($query){ | |
global $wpdb; | |
if(is_tag()){ | |
// GET LIMIT RANGE OF ORIGINAL SQL QUERY | |
preg_match('@(LIMIT [0-9]+, [0-9]+)@', $query, $limitData); | |
$limit = $limitData[1]; | |
$query = str_replace($limit, '', $query); | |
$query = str_replace('SQL_CALC_FOUND_ROWS', '', $query); | |
View Sincronizar posts Wordpress diferentes servidores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Se utilizo https://www.percona.com/doc/percona-toolkit/LATEST/pt-table-sync.html para sincronizar la tablas | |
# En el hosting destino ejecutar las lineas | |
# Sincronizar tabla wp_posts | |
pt-table-sync --execute h=host_source,D=database_source,u=username_source,p="pass_source",t=wp_posts h=127.0.0.1,D=database_end,u=user_end,p=password_end --function MD5 | |
# Replicar lo mismo para wp_posts, wp_postmeta, wp_termmeta, wp_terms, wp_term_relationships, wp_term_taxonomy |
View command-varnish.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Muestro las URL que se envian al backend | |
varnishtop -i BereqURL | |
# Muestro los host de peticiones al back | |
varnishtop -b -I BeReqHeader:Host | |
# Muestro todas URL peticionadas | |
varnishtop -i requrl | |
# Mostrar peticiones metodo |
View signed_url_google_storage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
DOCS: | |
https://cloud.google.com/storage/docs/access-control/signed-urls | |
https://cloud.google.com/storage/docs/access-control/signing-urls-manually | |
Translate to PHP of code Python: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/storage/signed_urls/generate_signed_urls.py | |
*/ | |
function generate_signed_url_google($service_account_file, $bucket_name, $object_name, $subresource = null, $expiration=604800, $http_method='GET', $query_parameters = array(), $headers = array()){ | |
date_default_timezone_set('UTC'); |
View limit_rate.vcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ## Not complete default.vcl code | |
# Install https://github.com/varnish/varnish-modules | |
import vsthrottle; | |
# If I want to implement limitation to any request (do not declare req.http.X-Actual-IP again in other subsequent subroutines) | |
sub vcl_recv { | |
# GET REAL IP USER from proxy CLOUDFLARE | |
set req.http.X-Actual-IP = regsub(req.http.X-Forwarded-For, "[, ].*$", ""); | |
if(vsthrottle.is_denied(req.http.X-Actual-IP, 50, 5s, 60s)) { |
View default.vcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ## Not complete default.vcl code | |
sub vcl_recv { | |
set req.http.IPCountry = "no-specified"; | |
# usage ISO 3166-1 alpha-2 ( https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ) | |
## If I want to group BR and US in same group cache | |
if (req.http.CF-IPCountry == "BR" || req.http.CF-IPCountry == "US") { | |
set req.http.IPCountry = "group-br-and-us"; | |
} else { | |
set req.http.IPCountry = req.http.CF-IPCountry; | |
} |
View default.vcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ## Not complete default.vcl code | |
# Routine to try and identify device | |
sub identify_device { | |
# Default to thinking it's desktop | |
set req.http.X-UA-Device = "desktop"; | |
if (req.http.User-Agent ~ "iPad" ) { | |
# It says its a iPad - so let's give them the tablet-site | |
set req.http.X-UA-Device = "tablet"; |
View cloudflare_remove_gets.vcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in vcl_recv | |
if (req.url ~ "(\?|&)(__cf_chl_jschl_tk__)=") { | |
set req.url = regsuball(req.url, "&(__cf_chl_jschl_tk__)=([A-z0-9_\-\.%25]+)", ""); | |
set req.url = regsuball(req.url, "\?(__cf_chl_jschl_tk__)=([A-z0-9_\-\.%25]+)", "?"); | |
set req.url = regsub(req.url, "\?&", "?"); | |
set req.url = regsub(req.url, "\?$", ""); | |
} |