<?php // please don't copy this line.
/**
* Get SERP Name
*/
function jiv_get_serp_name() {
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
$serps = array( 'google', 'bing', 'yahoo', 'duckduckgo' );
$referer = $_SERVER['HTTP_REFERER'];
$result = jiv_get_domain_from_url( $referer );
$result = explode( ".", $result );
if ( in_array( $result[0], $serps ) ) {
return $result[0];
} else {
return false;
}
}
return false;
}
function jiv_get_domain_from_url( $url ) {
$pieces = parse_url( $url );
$domain = isset( $pieces['host'] ) ? $pieces['host'] : $pieces['path'];
if ( preg_match( '/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs ) ) {
return $regs['domain'];
}
return false;
}