function kses_attr($element, $attr, $allowed_html, $allowed_protocols) { # Is there a closing XHTML slash at the end of the attributes? $xhtml_slash = ''; if (preg_match('%\\s/\\s*$%', $attr)) { $xhtml_slash = ' /'; } # Are any attributes allowed at all for this element? $x = array_lookup($allowed_html, strtolower($element)); if (count($x) == 0) { return "<{$element}{$xhtml_slash}>"; } # Split it $attrarr = kses_hair($attr, $allowed_protocols); # Go through $attrarr, and save the allowed attributes for this element # in $attr2 $attr2 = ''; foreach ($attrarr as $arreach) { $current = array_lookup($allowed_html[strtolower($element)], strtolower($arreach['name'])); if ($current == '') { continue; } # the attribute is not allowed if (!is_array($current)) { $attr2 .= ' ' . $arreach['whole']; } else { # there are some checks $ok = true; foreach ($current as $currkey => $currval) { if (!kses_check_attr_val($arreach['value'], $currkey, $currval)) { $ok = false; break; } } if ($ok) { $attr2 .= ' ' . $arreach['whole']; } # it passed them } # if !is_array($current) } # foreach # Remove any "<" or ">" characters $attr2 = preg_replace('/[<>]/', '', $attr2); return "<{$element}{$attr2}{$xhtml_slash}>"; }
/** * Generate a query string with the option to exclude key/value pairs * * @param array/String $exclude * @param array $arr * @param String $glue * @return String */ function query_string($exclude = array(), array $arr = NULL, $glue = '&') { $ret = ''; if (!is_array($exclude)) { $exclude = array((string) $exclude); } $exclude = array_lookup($exclude); if (!isset($arr)) { $arr = $_GET; } $get = array(); foreach ($arr as $key => $val) { if (!isset($exclude[$key])) { $get[$key] = $val; } } if (!empty($get)) { $ret = implode($glue, implode_assoc('=', $get)); } return $ret; }
/** * Check if a user has a specific addon * * @param type $addon * @return type */ function check_addon($addon) { $addons = array_lookup(array_to_lower($this->subscriber_addons)); return isset($addons[strtolower($addon)]); }