Example #1
0
/**
 * Prepare URL Query Value
 * 
 * Sanitize and standardize a URL Query Value for storage in a database.
 * Does not support ?keyword[]=value, i.e. - $value cannot be an Array. 
 *
 * @param    string  $value		URL Query Value to be sanitized and standardized; will fail if array 
 * @return   string             URL Query Value after being sanitized and standardized
 */
function jr_mt_prep_query_value($value)
{
    return str_ireplace('%e2%80%8e', '', jr_mt_strtolower(trim($value)));
}
 /**	Prepare URL for JavaScript compares
 	
 		Remove http[s]//: from beginning
 		Convert rest of URL to lower-case
 		Remove www. from beginning, if present
 		Convert any backslashes to forward slashes
 		Remove any trailing slash(es).
 	*/
 function jr_mt_prep_comp_url($url)
 {
     $comp_url = jr_mt_strtolower(jr_mt_substr($url, 3 + strpos($url, '://')));
     if ('www.' === jr_mt_substr($comp_url, 0, 4)) {
         $comp_url = jr_mt_substr($comp_url, 4);
     }
     return rtrim(str_replace('\\', '/', $comp_url), '/');
 }
Example #3
0
function jr_mt_echo_all_things($thing)
{
    $settings = get_option('jr_mt_settings');
    $field = 'all_' . jr_mt_strtolower($thing['thing']);
    jr_mt_themes_field($field, $settings[$field], 'jr_mt_settings', TRUE);
}
Example #4
0
/**	Build Query Array

	$array[keyword] = array( value, value, ... )
	Sets both keyword and value to lower-case as
	that is how they are stored in Settings.
	
	Supports only & separator, not proposed semi-colon separator.
	
	Handles duplicate keywords in all four of these forms:
	kw=val1&kw=val2 kw[]=val1&kw[]=val2 kw=val1&kw=val1 kw[]=val1&kw[]=val1
	but nothing else, e.g. - kw=val1,val2 is not valid;
	it returns "val1,val2" as the Value.
	Also handles kw1&kw2
	
	Tests of parse_str() in PHP 5.5.9 proved that semi-colon and comma
	are not supported.  But, neither is kw=val1,kw=val2 which is why
	this function is written without the use of parse_str.
*/
function jr_mt_query_array()
{
    /*	Remove array entry indicators ("[]") as we properly handle duplicate keywords,
    		and covert to lower-case for comparison purposes.
    	*/
    $queries = array();
    if (!empty($_SERVER['QUERY_STRING'])) {
        $query = explode('&', jr_mt_strtolower(str_replace('[]', '', $_SERVER['QUERY_STRING'])));
        foreach ($query as $kwval) {
            $query_entry = explode('=', $kwval);
            if (!isset($query_entry[1])) {
                $query_entry[1] = '';
            }
            $queries[$query_entry[0]][] = $query_entry[1];
        }
    }
    return $queries;
}