Changeset 282 for trunk/lib


Ignore:
Timestamp:
Oct 14, 2007 7:19:17 AM (17 years ago)
Author:
quinn
Message:

Added length arg to *Signature functions; added App::setQuery() method; FormValidator? msg rewording.

Location:
trunk/lib
Files:
4 edited

Legend:

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

    r260 r282  
    616616
    617617    /**
    618      * Sets which query arguments will be carried persistently between requests.
     618     * Forcefully set a query argument even if one currently exists in the reqeust.
     619     * Values in the _carry_queries array will be copied to URLs (via $app->url()) and
     620     * to hidden input values (via printHiddenSession()).
     621     *
     622     * @access  public
     623     * @param   mixed   $query_key  The key (or keys, as an array) of the query argument to save.
     624     * @param   mixed   $val        The new value of the argument key.
     625     * @author  Quinn Comendant <quinn@strangecode.com>
     626     * @since   13 Oct 2007 11:34:51
     627     */
     628    function setQuery($query_key, $val)
     629    {
     630        if (!is_array($query_key)) {
     631            $query_key = array($query_key);
     632        }
     633        foreach ($query_key as $k) {
     634            // Set the value of the specified query argument into the _carry_queries array.
     635            $this->_carry_queries[$k] = $val;
     636        }
     637    }
     638
     639    /**
     640     * Specify which query arguments will be carried persistently between requests.
    619641     * Values in the _carry_queries array will be copied to URLs (via $app->url()) and
    620642     * to hidden input values (via printHiddenSession()).
  • trunk/lib/Email.inc.php

    r247 r282  
    233233    {
    234234        $app =& App::getInstance();
    235    
     235
    236236        // Use arguments if provided.
    237237        if (isset($to)) {
  • trunk/lib/FormValidator.inc.php

    r279 r282  
    521521            return true;
    522522        } else {
    523             $this->addError($form_name, sprintf(_("<em>%s</em> is not a valid credit card number."), $cc_num));
     523            $this->addError($form_name, sprintf(_("The credit card number you entered is not valid. Please check the number and try again."), $cc_num));
    524524            return false;
    525525        }
  • trunk/lib/Utilities.inc.php

    r264 r282  
    708708 * @param   string  $val    The string to sign.
    709709 * @param   string  $salt   (Optional) A text key to use for computing the signature.
     710 * @param   string  $length (Optional) The length of the added signature. Longer signatures are safer. Must match the length passed to verifySignature() for the signatures to match.
    710711 * @return  string  The original value with a signature appended.
    711712 */
    712 function addSignature($val, $salt=null)
     713function addSignature($val, $salt=null, $length=18)
    713714{
    714715    $app =& App::getInstance();
     
    723724    }
    724725
    725     return $val . '-' . mb_substr(md5($salt . md5($val . $salt)), 0, 18);
     726    return $val . '-' . mb_substr(md5($salt . md5($val . $salt)), 0, $length);
    726727}
    727728
     
    750751 * @return  bool    True if the signature matches the var.
    751752 */
    752 function verifySignature($signed_val, $salt=null)
     753function verifySignature($signed_val, $salt=null, $length=18)
    753754{
    754755    // Strip the value from the signed value.
    755756    $val = removeSignature($signed_val);
    756757    // If the signed value matches the original signed value we consider the value safe.
    757     if ($signed_val == addSignature($val, $salt)) {
     758    if ($signed_val == addSignature($val, $salt, $length)) {
    758759        // Signature verified.
    759760        return true;
Note: See TracChangeset for help on using the changeset viewer.