Ignore:
Timestamp:
Apr 27, 2006 1:49:54 AM (18 years ago)
Author:
scdev
Message:

Q - Finished depreciating addslashes. array_map instances need to use array('DB', 'escapeString') as first argument.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r103 r111  
    105105/**
    106106 * Returns text with stylistic modifications. Warning: this will break some HTML attibutes!
    107  * FIXME: Allow a string such as this to be passted: <a href="javascript:openPopup('/foo/bar.php')">Click here</a>
     107 * TODO: Allow a string such as this to be passted: <a href="javascript:openPopup('/foo/bar.php')">Click here</a>
    108108 *
    109109 * @param  string   $txt  Text to clean.
     
    463463
    464464/**
    465  * Adds slashes to values of an array and converts the array to a
    466  * comma delimited list. If value provided is not an array or is empty
    467  * return nothing. This is useful for putting values coming in from
    468  * posted checkboxes into a SET column of a database.
    469  *
    470  * @param  array $array   Array to convert.
     465 * Adds slashes to values of an array and converts the array to a comma
     466 * delimited list. If value provided is a string return the string
     467 * escaped.  This is useful for putting values coming in from posted
     468 * checkboxes into a SET column of a database.
     469 *
     470 *
     471 * @param  array $in      Array to convert.
    471472 * @return string         Comma list of array values.
    472473 */
    473 function dbArrayToList($array)
    474 {
    475     if (is_array($array) && !empty($array)) {
    476         return join(',', array_map('addslashes', array_keys($array)));
    477     }
    478 }
    479 
    480 /**
    481  * Converts a human string date into a SQL-safe date.
    482  * Dates nearing infinity use the date 2038-01-01 so conversion to unix time
    483  * format remain within valid range.
     474function escapedList($in)
     475{
     476    if (is_array($in) && !empty($in)) {
     477        return "'" . join("', '", array_map(array('DB', 'escapeString'), $in)) . "'";
     478    } else {
     479        return DB::escapeString($in);
     480    }
     481}
     482
     483/**
     484 * Converts a human string date into a SQL-safe date.  Dates nearing
     485 * infinity use the date 2038-01-01 so conversion to unix time format
     486 * remain within valid range.
    484487 *
    485488 * @param  array $date     String date to convert.
Note: See TracChangeset for help on using the changeset viewer.