Changeset 534 for trunk/lib/App.inc.php


Ignore:
Timestamp:
Jul 27, 2015 7:56:08 AM (9 years ago)
Author:
anonymous
Message:

Improved module maker validation output. Allow disabling cache at run time for ACL. Added ACL getList() method. Improved ACL CLI listing. Fixed app boomerang array initialization. Now retaining identical boomerang URLs if the key is different. Added a maximum boomerang time. Added a way to disable cache per request through a query string. Added validator isDecimal() method. Added disableSelectOptions() HTML method. Added getGravatarURL() method. Change how navigation page array is managed. Updated navigation currentPage() method to test an array of URLs.

File:
1 edited

Legend:

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

    r532 r534  
    416416                $_SESSION['_app'][$this->_ns] = array(
    417417                    'messages' => array(),
    418                     'boomerang' => array('url'),
     418                    'boomerang' => array('url' => array()),
    419419                );
    420420            }
     
    539539
    540540        if (!$this->running) {
    541             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     541            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    542542            return false;
    543543        }
    544544
    545545        if (!$this->getParam('enable_session')) {
    546             $this->logMsg(sprintf('Canceled method call %s, session not enabled.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     546            $this->logMsg(sprintf('Canceled %s, session not enabled.', ≠), LOG_NOTICE, __FILE__, __LINE__);
    547547            return false;
    548548        }
     
    609609    {
    610610        if (!$this->running) {
    611             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     611            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    612612            return false;
    613613        }
     
    625625    {
    626626        if (!$this->running) {
    627             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     627            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    628628            return false;
    629629        }
     
    647647
    648648        if (!$this->running) {
    649             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     649            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    650650            return false;
    651651        }
     
    968968    {
    969969        if (!$this->running) {
    970             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     970            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    971971            return false;
    972972        }
     
    10951095    {
    10961096        if (!$this->running) {
    1097             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1097            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    10981098            return false;
    10991099        }
     
    12031203    *
    12041204    * @access   public
     1205    * @param    string  $user_submitted_csrf_token The user-submitted token to compare with the session token.
    12051206    * @param    string  $csrf_token     The token to compare with the session token.
    12061207    * @return   bool    True if the tokens match, false otherwise.
     
    12131214
    12141215        if (!$this->getParam('csrf_token_enabled')) {
    1215             $this->logMsg(sprintf('%s method called, but csrf_token_enabled=false', __FUNCTION__), LOG_ERR, __FILE__, __LINE__);
     1216            $this->logMsg(sprintf('%s called, but csrf_token_enabled=false', __METHOD__), LOG_ERR, __FILE__, __LINE__);
    12161217            return true;
    12171218        }
     
    12381239    *
    12391240    * @access   public
    1240     * @param    string  $user_submitted_csrf_token The user-submitted token to compare with the session token.
    12411241    * @param    string  $message    Optional message to display to the user (otherwise default message will display). Set to an empty string to display no message.
    12421242    * @param    int    $type    The type of message: MSG_NOTICE,
     
    12741274    {
    12751275        if (!$this->running) {
    1276             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1276            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    12771277            return false;
    12781278        }
     
    13271327    {
    13281328        if (!$this->running) {
    1329             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1329            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    13301330            return false;
    13311331        }
     
    13691369    {
    13701370        if (!$this->running) {
    1371             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1371            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    13721372            return false;
    13731373        }
     
    13771377        if ('' != $url && is_string($url)) {
    13781378            // Delete any boomerang request keys in the query string (along with any trailing delimiters after the deletion).
    1379             $url = preg_replace(array('/([&?])boomerang=\w+[&?]?/', '/[&?]$/'), array('$1', ''), $url);
     1379            $url = preg_replace(array('/([&?])boomerang=[^&?]+[&?]?/', '/[&?]$/'), array('$1', ''), $url);
    13801380
    13811381            if (isset($_SESSION['_app'][$this->_ns]['boomerang']['url']) && is_array($_SESSION['_app'][$this->_ns]['boomerang']['url']) && !empty($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
    1382                 // If the URL currently exists in the boomerang array, delete.
    1383                 while ($existing_key = array_search($url, $_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
    1384                     unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$existing_key]);
     1382                // If the ID=>URL pair currently exists in the boomerang array, delete.
     1383                foreach (array_keys($_SESSION['_app'][$this->_ns]['boomerang']['url'], $url) as $existing_key) {
     1384                    if ($existing_key == $id) {
     1385                        $this->logMsg(sprintf('Found and deleting existing ID=>URL pair: %s=>%s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     1386                        unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$existing_key]);
     1387                    }
    13851388                }
    13861389            }
     
    14071410    {
    14081411        if (!$this->running) {
    1409             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1412            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    14101413            return false;
    14111414        }
     
    14321435    {
    14331436        if (!$this->running) {
    1434             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1437            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    14351438            return false;
    14361439        }
     
    14541457    {
    14551458        if (!$this->running) {
    1456             $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     1459            $this->logMsg(sprintf('Canceled %s, application not running.', __METHOD__), LOG_NOTICE, __FILE__, __LINE__);
    14571460            return false;
    14581461        }
     
    14901493            // Last boomerang direction was less than 2 seconds ago.
    14911494            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s seconds', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
     1495            return false;
     1496        }
     1497        if ($boomerang_time < (time() - 72000)) {
     1498            // Last boomerang direction was more than 20 minutes ago.
     1499            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too long: %s seconds', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
    14921500            return false;
    14931501        }
Note: See TracChangeset for help on using the changeset viewer.