Ignore:
Timestamp:
May 24, 2015 3:01:42 PM (9 years ago)
Author:
anonymous
Message:

First set of changes towards 2.2.0. Improved functinoality with integration in wordpress; bugs fixed.

File:
1 edited

Legend:

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

    r520 r523  
    609609/**
    610610 * Tests the existence of a file anywhere in the include path.
     611 * Replaced by stream_resolve_include_path() in PHP 5 >= 5.3.2
    611612 *
    612613 * @param   string  $file   File in include path.
     
    897898{
    898899    // Translate the human string date into SQL-safe date format.
    899     if (empty($date) || mb_strpos($date, '0000-00-00') !== false || strtotime($date) === -1 || strtotime($date) === false) {
     900    if (empty($date) || mb_strpos($date, '0000-00-00') !== false || strtotime($date) === -1 || strtotime($date) === false || strtotime($date) === null) {
    900901        // Return a string of zero time, formatted the same as $format.
    901902        return strtr($format, array(
     
    920921 * @return mixed        $var, minus any magic quotes.
    921922 */
    922 function dispelMagicQuotes($var)
     923function dispelMagicQuotes($var, $always=false)
    923924{
    924925    static $magic_quotes_gpc;
     
    928929    }
    929930
    930     if ($magic_quotes_gpc) {
     931    if ($always || $magic_quotes_gpc) {
    931932        if (!is_array($var)) {
    932933            $var = stripslashes($var);
     
    934935            foreach ($var as $key=>$val) {
    935936                if (is_array($val)) {
    936                     $var[$key] = dispelMagicQuotes($val);
     937                    $var[$key] = dispelMagicQuotes($val, $always);
    937938                } else {
    938939                    $var[$key] = stripslashes($val);
     
    956957function getFormData($var=null, $default=null)
    957958{
     959    $app =& App::getInstance();
     960
    958961    if ('POST' == getenv('REQUEST_METHOD') && is_null($var)) {
    959         return dispelMagicQuotes($_POST);
     962        return dispelMagicQuotes($_POST, $app->getParam('always_dispel_magicquotes'));
    960963    } else if ('GET' == getenv('REQUEST_METHOD') && is_null($var)) {
    961         return dispelMagicQuotes($_GET);
     964        return dispelMagicQuotes($_GET, $app->getParam('always_dispel_magicquotes'));
    962965    }
    963966    if (isset($_POST[$var])) {
    964         return dispelMagicQuotes($_POST[$var]);
     967        return dispelMagicQuotes($_POST[$var], $app->getParam('always_dispel_magicquotes'));
    965968    } else if (isset($_GET[$var])) {
    966         return dispelMagicQuotes($_GET[$var]);
     969        return dispelMagicQuotes($_GET[$var], $app->getParam('always_dispel_magicquotes'));
    967970    } else {
    968971        return $default;
    969972    }
    970973}
     974
    971975function getPost($var=null, $default=null)
    972976{
     977    $app =& App::getInstance();
     978
    973979    if (is_null($var)) {
    974         return dispelMagicQuotes($_POST);
     980        return dispelMagicQuotes($_POST, $app->getParam('always_dispel_magicquotes'));
    975981    }
    976982    if (isset($_POST[$var])) {
    977         return dispelMagicQuotes($_POST[$var]);
     983        return dispelMagicQuotes($_POST[$var], $app->getParam('always_dispel_magicquotes'));
    978984    } else {
    979985        return $default;
    980986    }
    981987}
     988
    982989function getGet($var=null, $default=null)
    983990{
     991    $app =& App::getInstance();
    984992    if (is_null($var)) {
    985         return dispelMagicQuotes($_GET);
     993        return dispelMagicQuotes($_GET, $app->getParam('always_dispel_magicquotes'));
    986994    }
    987995    if (isset($_GET[$var])) {
    988         return dispelMagicQuotes($_GET[$var]);
     996        return dispelMagicQuotes($_GET[$var], $app->getParam('always_dispel_magicquotes'));
    989997    } else {
    990998        return $default;
Note: See TracChangeset for help on using the changeset viewer.