Changeset 785 for trunk


Ignore:
Timestamp:
Mar 14, 2023 6:24:45 PM (14 months ago)
Author:
anonymous
Message:

Add App::unsetCookie(). Quench some PHP 8 depreciation notices.

Location:
trunk
Files:
3 edited

Legend:

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

    r784 r785  
    429429                $this->setParam(array('db_pass' => $_SERVER['DB_PASS']));
    430430            }
     431            unset($_SERVER['DB_SERVER'], $_SERVER['DB_NAME'], $_SERVER['DB_USER'], $_SERVER['DB_PASS'], $_SERVER['SIGNING_KEY']);
    431432
    432433            // DB credentials for CLI scripts stored in a JSON file with read rights given only to the user who will be executing the scripts: -r--------
     
    594595                if ($this->getParam('http_cache_headers') > 0) {
    595596                    // Allow HTTP caching, for this many seconds.
    596                     header(sprintf('Cache-Control: no-transform, public, max-age=%d', $this->getParam('http_cache_headers')));
     597                    header(sprintf('Cache-Control: max-age=%d', $this->getParam('http_cache_headers')));
    597598                    header('Vary: Accept-Encoding');
    598599                } else {
     
    643644            }
    644645        }
    645 
    646         // Unset environment variables we're done with.
    647         unset($_SERVER['DB_SERVER'], $_SERVER['DB_NAME'], $_SERVER['DB_USER'], $_SERVER['DB_PASS'], $_SERVER['SIGNING_KEY']);
    648646
    649647        $this->running = true;
     
    18391837
    18401838    /*
     1839    * Delete a cookie previously created by setCookie().
     1840    *
     1841    * @access   public
     1842    * @param    string  $name       The name of the cookie.
     1843    * @return   bool                True on success, false on error.
     1844    * @author   Quinn Comendant <quinn@strangecode.com>
     1845    * @since    14 Mar 2023 12:12:15
     1846    */
     1847    public function unsetCookie($name)
     1848    {
     1849        $ret = setcookie($name, '', 1);
     1850        if (false === $ret) {
     1851            $this->logMsg(sprintf('Failed to unset cookie (%s) probably due to output before headers.', $name), LOG_NOTICE, __FILE__, __LINE__);
     1852        }
     1853        return $ret;
     1854    }
     1855
     1856    /*
    18411857    * Set timezone used internally by PHP. See full list at https://www.php.net/manual/en/timezones.php
    18421858    *
     
    19101926        $format = $format ?: $this->getParam('lc_date_format');
    19111927        if ($format && mb_strpos($format, '%') !== false) {
    1912             // The data format is localized for strftime(). It only accepts a timestamp, which are always in UTC, so we hack this by offering the date from the user's timezone in a format without a TZ specified, which is used to a make a timestamp for strftime (we can't use DaateTime->format('U') because that would convert the date back to UTC).
     1928            // The date format is localized for strftime(). It only accepts a timestamp, which are always in UTC, so we hack this by offering the date from the user's timezone in a format without a TZ specified, which is used to a make a timestamp for strftime (we can't use DaateTime->format('U') because that would convert the date back to UTC).
    19131929            return strftime($format, strtotime($dt->format('Y-m-d H:i:s')));
    19141930        } else {
  • trunk/lib/Utilities.inc.php

    r783 r785  
    230230{
    231231    $app =& App::getInstance();
     232
     233    if ('' == $text) {
     234        return '';
     235    }
    232236
    233237    $search = array();
  • trunk/services/login.php

    r784 r785  
    3333// We may want to use the add/edit interface from another script, so this
    3434// allows us to remember which page we came from so we can go back there.
    35 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER']) || preg_match('!^(https?://\w+|/\w+)!', getFormData('boomerang'))) {
    36     $url = preg_match('!^(https?://\w+|/\w+)!', getFormData('boomerang')) ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
     35if (getFormData('boomerang', false) && (isset($_SERVER['HTTP_REFERER']) || preg_match('!^(?:https?:/)?/\w!', getFormData('boomerang')))) {
     36    $url = preg_match('!^(?:https?:/)?/\w!', getFormData('boomerang')) ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
    3737    $app->setBoomerangURL($url, 'login');
    3838}
Note: See TracChangeset for help on using the changeset viewer.