public_html/wp-content/plugins/wp-statistics/includes/classes/statistics.class.php
// This function will parse a URL from a referrer and return the search query words used.
This function will parse a URL from a referrer and return the search query words used.
This function will parse a URL from a referrer and return the search query words used .
public function Search_Engine_QueryString( $url = false ) {
		if(!$url) {
			$url = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : false;
		}
		if($url == false) {
			return false;
		}
		$parts = parse_url( $url );
		if( array_key_exists( 'query', $parts ) ) { parse_str( $parts['query'], $query ); } else { $query = array(); }
		$search_engines = wp_statistics_searchengine_list();
		foreach( $search_engines as $key => $value ) {
			$search_regex = wp_statistics_searchengine_regex( $key );
			preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
			if( isset($matches[1]) )
				{
				if( array_key_exists( $search_engines[$key]['querykey'], $query ) ) {
					$words = strip_tags( $query[$search_engines[$key]['querykey']] );
				}
				else {
					$words = '';
				}
				if( $words == '' ) { $words = 'No search query found!'; }
				return $words;
				}
		}
		return 'No search query found!';
	}
public function Search_Engine_QueryString ( $ url = false ) { if ( ! $ url ) { $ url = isset ( $ _SERVER [ 'HTTP_REFERER' ] ) ? $ _SERVER [ 'HTTP_REFERER' ] : false ; } if ( $ url == false ) { return false ; } $ parts = parse_url ( $ url ) ; if ( array_key_exists ( 'query' , $ parts ) ) { parse_str ( $ parts [ 'query' ] , $ query ) ; } else { $ query = array ( ) ; } $ search_engines = wp_statistics_searchengine_list ( ) ; foreach ( $ search_engines as $ key => $ value ) { $ search_regex = wp_statistics_searchengine_regex ( $ key ) ; preg_match ( '/' . $ search_regex . '/' , $ parts [ 'host' ] , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { if ( array_key_exists ( $ search_engines [ $ key ] [ 'querykey' ] , $ query ) ) { $ words = strip_tags ( $ query [ $ search_engines [ $ key ] [ 'querykey' ] ] ) ; } else { $ words = '' ; } if ( $ words == '' ) { $ words = 'No search query found!' ; } return $ words ; } } return 'No search query found!' ; }
This function will parse a URL from a referrer and return the search query words used.
This function will parse a URL from a referrer and return the search query words used .
// If no URL was passed in, get the current referrer for the session. // If there is no URL and no referrer, always return false. // Parse the URL in to it's component parts. // Check to see if there is a query component in the URL (everything after the ?).  If there isn't one // set an empty array so we don't get errors later. // Get the list of search engines we currently support. // Loop through the SE list until we find which search engine matches. // Check to see if the query key the SE uses exists in the query part of the URL. // If no words were found, return a pleasant default. // We should never actually get to this point, but let's make sure we return something // just in case something goes terribly wrong.