Reference

Slash::Utility::Data(3pm)

Slash::MODULE - SHORT DESCRIPTION for Slash

        use Slash::Utility;
        # do not use this module directly

LONG DESCRIPTION.
root2abs() Convert "rootdir" to its absolute equivalent. By default, "rootdir" is protocol-inspecific (such as "//www.example.com") and for redirects needs to be converted to its absolute form. There is an "absolutedir" var, but it is protocol-specific, and we want to inherit the protocol. So if $ENV{HTTPS} is true, we use HTTPS, else we use HTTP. rootdir variable, converted to absolute with proper protocol.
url2abs(URL) Take URL and make it absolute. It takes a URL, and adds rootdir to the beginning if necessary, and adds the protocol to the beginning if necessary, and then uses URI->new_abs() to get the correct string. URL to make absolute. Fixed URL.
formatDate(DATA [, COLUMN, AS, FORMAT]) Converts dates from the database; takes an arrayref of rows. This example would take the 1th element of each arrayref in $data, format it, and put the result in the 2th element.

        formatDate($data, 1, 2);

This example would take the "foo" key of each hashref in $data, format it, and put the result in the "bar" key.

        formatDate($data, 'foo', 'bar');

The "timeCalc" function does the formatting. Data is either an arrayref of arrayrefs, or an arrayref of hashrefs. Which it is will be determined by whether COLUMN is numeric or not. If it is numeric, then DATA will be assumed to be an arrayref of arrayrefs. The column to take the data from, to be translated. If numeric, then DATA will be taken to be an arrayref of arrayrefs. Otherwise, the value will be the hashref key. Default value is "date". The column where to put the newly formatted data. If COLUMN is numeric and AS is not defined, then AS will be the same value as COLUMN. Otherwise, the default value of AS is "time". Optional Date::Format format string. True if successful, false if not. Changes values in DATA. The "timeCalc" function.
timeCalc(DATE [, FORMAT, OFFSET]) Format time strings using user's format preference. Raw date from database. Optional format to override user's format. Optional positive or negative integer for offset seconds from GMT, to override user's offset. Formatted date string. The 'atonish' and 'aton' template blocks.
changePassword() Return new random 8-character password composed of 0..9, A..Z, a..z (but not including possibly hard-to-read characters [0O1Iil]) and the special characters <>()-\/%&$?=_:.#*+@. Really random password. Not really easy to remember, but at least Slashcode is on the secure side.
encryptPassword(PASSWD) Encrypts given password. Currently uses MD5, but could change in the future, so do not depend on implementation. Password to be encrypted. Encrypted password.
stripByMode(STRING [, MODE, NO_WHITESPACE_FIX]) Private function. Fixes up a string based on what the mode is. This function is no longer exported, use the "strip_*" functions instead.

[ Should this be somewhat templatized, so they can customize the little HTML bits? Same goes with related functions. -- pudge ] The string to be manipulated. May be one of: The default. Just strips out HTML. Prints the text verbatim into HTML, which means just converting < and > and & to their HTML entities. Also turns on NO_WHITESPACE_FIX. Similarly to 'literal', converts everything to its HTML entity, but then formatting is preserved by converting spaces to HTML space entities, and multiple newlines into BR tags. Just like 'extrans' but wraps in CODE tags. Attempts to format string to fit in as an HTML attribute, which means the same thing as 'literal', but " marks are also converted to their HTML entity. Similar to 'extrans', but does not translate < and > and & first (so "stripBadHtml" is called first). Removes ALL whitespace from inside the filter. It's is indented for use (but not limited to) the removal of white space from in side HREF anchor tags to prevent nasty browser artifacts from showing up in the display. (Note: the value of NO_WHITESPACE_FIX is ignored) Just runs through "stripBadHtml". A boolean that, if true, disables fixing of whitespace problems. A common exploit in these things is to run a lot of characters together so the page will stretch very wide. If NO_WHITESPACE_FIX is false, then space is inserted to prevent this (see "breakHtml"). The manipulated string.
strip_anchor(STRING [, NO_WHITESPACE_FIX])
strip_attribute(STRING [, NO_WHITESPACE_FIX])
strip_code(STRING [, NO_WHITESPACE_FIX])
strip_extrans(STRING [, NO_WHITESPACE_FIX])
strip_html(STRING [, NO_WHITESPACE_FIX])
strip_literal(STRING [, NO_WHITESPACE_FIX])
strip_nohtml(STRING [, NO_WHITESPACE_FIX])
strip_notags(STRING [, NO_WHITESPACE_FIX])
strip_plaintext(STRING [, NO_WHITESPACE_FIX])
strip_mode(STRING [, MODE, NO_WHITESPACE_FIX]) Wrapper for "stripByMode". "strip_mode" simply calls "stripByMode" and has the same arguments, but "strip_mode" will only allow modes with values greater than 0, that is, the user-supplied modes. "strip_mode" is only meant to be used for processing user-supplied modes, to prevent the user from accessing other mode types. For using specific modes instead of user-supplied modes, use the function with that mode's name. See "stripByMode" for details.
stripBadHtml(STRING) Private function. Strips out "bad" HTML by removing unbalanced HTML tags and sending balanced tags through "approveTag". The "unbalanced" checker is primitive; no "<" or ">" tags will are allowed inside tag attributes (such as <A NAME=">">), that breaks the tag. Also, whitespace is inserted between adjacent tags, so "<BR><BR>" becomes "<BR> <BR>". String to be processed. Processed string. "approveTag" function.
breakHtml(TEXT, MAX_WORD_LENGTH) Private function. Break up long words in some text. Will ignore the contents of HTML tags. Called from "stripByMode" functions. The text to be fixed. The maximum length of a word. Default is 50. The text.
fixHref(URL [, ERROR]) Take a relative URL and fix it to some predefined set. I don't really like this function much, it should be played with. Relative URL to manipulate. Boolean whether or not to return error number. Undef if URL is not handled. If it is handled and ERROR is false, new URL is returned. If it is handled and ERROR is true, URL and the error number are returned. The fixhrefs section in the vars table, and some sort of table (like 404-main) for determining what the number means.
approveTag(TAG) Private function. Checks to see if HTML tag is OK, and adjusts it as necessary. Tag to check. Tag after processing. Uses the "approvetags" variable in the vars table. Passes URLs in HREFs through "fudgeurl".
fixparam(DATA) Prepares data to be a parameter in a URL. Such as:

        my $url = 'http://example.com/foo.pl?bar=' . fixparam($data);

The data to be escaped. The escaped data.
fixurl(DATA) Prepares data to be a URL or in part of a URL. Such as:

        my $url = 'http://example.com/~' . fixurl($data) . '/';

The data to be escaped. The escaped data.
fudgeurl(DATA) Prepares data to be a URL. Such as:

        my $url = fixparam($someurl);

The data to be escaped. The escaped data.
chopEntity(STRING) Chops a string to a specified length, without splitting in the middle of an HTML entity or HTML tag (so we will err on the short side). String to be chomped. Chomped string.
balanceTags(HTML [, DEEP_NESTING]) Balances HTML tags; if tags are not closed, close them; if they are not open, remove close tags; if they are in the wrong order, reorder them (order of open tags determines order of close tags). The HTML to balance. Integer for how deep to allow nesting indenting tags, 0 means no limit. The balances HTML. The 'approvedtags' and 'lonetags' entries in the vars table.
parseDomainTags(HTML, RECOMMENDED, NOTAGS) To be called before sending the HTML to the user for display. Takes HTML with domain tags (see addDomainTags()) and parses out the tags, if necessary. The HTML with tagged with domains. Boolean for whether or not domain tags are recommended. They are not required, the user can choose to leave it up to us. Boolean overriding RECOMMENDED; it strips out all domain tags if true. The parsed HTML.
addDomainTags(HTML) To be called only after "balanceTags", or results are not guaranteed. Munges HTML </a> tags into </a foo.com> tags, where "foo.com" is the domain name of the link found in the opening <a> tag. Note that this is not proper HTML, and that "dispComment" knows how properly to convert it back to proper HTML. The HTML to tag with domains. The tagged HTML.
xmlencode_plain(TEXT) Same as xmlencode(TEXT), but does not encode for use in HTML. This is currently ONLY for use for <link> elements. Whatever text it is you want to encode. The encoded string. XML::Parser::Expat(3).
xmlencode(TEXT) Encodes / escapes a string for putting into XML. The text goes through three phases: we first convert all "&" that are not part of an entity to "&amp;"; then we convert all "&", "<", and ">" to their entities. Then all characters that are not printable ASCII characters (\040 to \176) are converted to their numeric entities (such as "&#192;"). Note that this is basically encoding a string into valid HTML, then escaping it for XML. When run through regular XML unescaping, a valid HTML string should remain (that is, the characters will be valid for HTML, while it may not be syntactically correct). You may use something like "HTML::Entities::decode_entities" if you wish to get the regular text. Whatever text it is you want to encode. The encoded string. XML::Parser::Expat(3).
xmldecode(TEXT) Decodes / unescapes an XML string. It basically just decodes the five entities used to encode "<", ">", '"', "'", and "&". "&" is only decoded if it is not the start of an entity. This will decode the named, decimal numeric, or hex numeric versions of the entities. Note that while "xmlencode" will make sure the characters in the string are proper HTML characters, "xmldecode" will not take the extra step to get back the original non-HTML text; we want to leave the text as OK to put directly into HTML. You may use something like "HTML::Entities::decode_entities" if you wish to get the regular text. Whatever text it is you want to decode. The decoded string.
getArmoredEmail (UID) Returns a Spam Armored email address for the user associated with the given UID. This routine DOES NOT save its results back to the user record. This is the responsibility of the calling routine. The user's ID whose email address you wish to randomize. The email address, if successful. Slash(3), Slash::Utility(3). $Id: Data.pm,v 1.1.2.39 2002/07/03 17:06:09 pudge Exp $

History