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


Ignore:
Timestamp:
Dec 25, 2013 12:47:12 AM (10 years ago)
Author:
anonymous
Message:

Merged changes to lib/SortOrder.inc.php from eli_branch; other minor changes

File:
1 edited

Legend:

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

    r441 r452  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    8686        'session_name' => '_session',
    8787        'session_use_cookies' => true,
    88        
     88
    8989        // Pass the session-id through URLs if cookies are not enabled?
    9090        // Disable this to prevent session ID theft.
     
    190190        // Initialize default parameters.
    191191        $this->_params = array_merge($this->_params, $this->_param_defaults);
    192        
     192
    193193        // Begin timing script.
    194194        require_once dirname(__FILE__) . '/ScriptTimer.inc.php';
     
    362362            $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'))));
    363363        }
    364        
     364
    365365        // In case site_email isn't set, use something halfway presentable.
    366366        if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_email')) {
     
    375375        // Character set. This should also be printed in the html header template.
    376376        header('Content-type: text/html; charset=' . $this->getParam('character_set'));
    377        
     377
    378378        // Set the version of the codebase we're using.
    379379        $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt';
     
    404404            $this->db->close();
    405405        }
     406        $mem_current = memory_get_usage();
     407        $mem_peak = memory_get_peak_usage();
    406408        $this->timer->stop('_app');
    407         $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s.', $this->timer->getTime('_app'), $num_queries), LOG_DEBUG, __FILE__, __LINE__);
     409        $this->logMsg(sprintf('Script ended gracefully. Execution time: %s. Number of db queries: %s. Memory usage: %s. Peak memory: %s.', $this->timer->getTime('_app'), $num_queries, $mem_current, $mem_peak), LOG_DEBUG, __FILE__, __LINE__);
    408410    }
    409411
     
    434436            return false;
    435437        }
    436        
     438
    437439        // Avoid duplicate full-stops..
    438440        $message = trim(preg_replace('/\.{2}$/', '.', $message));
     
    454456        }
    455457    }
    456    
     458
    457459    /**
    458460     * Returns an array of the raised messages.
     
    472474        return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array();
    473475    }
    474    
     476
    475477    /**
    476478     * Resets the message list.
     
    486488            return false;
    487489        }
    488        
     490
    489491        $_SESSION['_app'][$this->_ns]['messages'] = array();
    490492    }
     
    507509            return false;
    508510        }
    509        
     511
    510512        $messages = $this->getRaisedMessages();
    511513        if (!empty($messages)) {
     
    590592            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
    591593        }
    592        
     594
    593595        // Before we get any further, let's see if ANY log events are configured to be reported.
    594596        if ((false === $this->getParam('log_file_priority') || $priority > $this->getParam('log_file_priority'))
     
    626628            $site_hash = md5(empty($_SERVER['SERVER_NAME']) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['SERVER_NAME']);
    627629            $lock_dir = $this->getParam('tmp_dir') . "/codebase_msgs_$site_hash/";
    628             // Just use the file and line for the msg_id to limit the number of possible messages 
     630            // Just use the file and line for the msg_id to limit the number of possible messages
    629631            // (the message string itself shan't be used as it may contain innumerable combinations).
    630632            $lock_file = $lock_dir . md5($file . ':' . $line);
     
    647649            }
    648650        }
    649        
     651
    650652        // Data to be stored for a log event.
    651653        $event = array(
     
    685687            mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers);
    686688        }
    687    
     689
    688690        // SCREEN ACTION
    689691        if (false !== $this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
     
    693695        // Restore original locale.
    694696        setlocale(LC_TIME, $locale);
    695        
     697
    696698        return true;
    697699    }
     
    771773
    772774    /**
    773      * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 
     775     * dropQuery() is the opposite of carryQuery(). The specified value will not appear in
    774776     * url()/ohref()/printHiddenSession() modified URLs unless explicitly written in.
    775      * 
     777     *
    776778     * @access  public
    777779     * @param   mixed   $query_key  The key (or keys, as an array) of the query argument to remove.
Note: See TracChangeset for help on using the changeset viewer.