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


Ignore:
Timestamp:
Nov 24, 2015 5:38:54 PM (8 years ago)
Author:
anonymous
Message:

Escaped quotes from email from names.
Changed logMsg string truncation method and added version to email log msg.
Better variable testing in carry queries.
Spelling errors.
Added runtime cache to Currency.
Added logging to form validation.
More robust form validation.
Added json serialization methond to Version.

File:
1 edited

Legend:

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

    r547 r550  
    4242class App
    4343{
    44 
    4544    // Minimum version of PHP required for this version of the Codebase.
    4645    const CODEBASE_MIN_PHP_VERSION = '5.3.0';
     
    753752
    754753        // Serialize multi-line messages.
    755         $message = preg_replace('/\s+/m', ' ', $message);
     754        $message = preg_replace('/\s+/m', ' ', trim($message));
    756755
    757756        // Store this event under a unique key, counting each time it occurs so that it only gets reported a limited number of times.
     
    807806            'file:line' => "$file : $line",
    808807            'url'       => mb_substr(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 0, 1024),
    809             'message'   => $message
     808            'message'   => mb_substr($message, 0, 1024),
    810809        );
    811810        // Here's a shortened version of event data.
     
    819818        if (false !== $this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
    820819            $event_str = '[' . join('] [', $event_short) . ']';
    821             error_log(mb_substr($event_str, 0, 1024) . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
     820            error_log("$event_str\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
    822821        }
    823822
     
    826825            $hostname = (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n');
    827826            $subject = sprintf('[%s %s] %s', $hostname, $event['type'], mb_substr($event['message'], 0, 64));
    828             $email_msg = sprintf("A %s log event occurred on %s\n\n", $event['type'], $hostname);
     827            $email_msg = sprintf("A log event of type '%s' occurred on %s\n\n", $event['type'], $hostname);
    829828            $headers = 'From: ' . $this->getParam('site_email');
    830829            foreach ($event as $k=>$v) {
    831                 $email_msg .= sprintf("%-11s%s\n", $k, $v);
    832             }
     830                $email_msg .= sprintf("%-16s %s\n", $k, $v);
     831            }
     832            $email_msg .= sprintf("%-16s %s\n", 'codebase version', $this->getParam('codebase_version'));
     833            $email_msg .= sprintf("%-16s %s\n", 'site version', $this->getParam('site_version'));
    833834            mb_send_mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers);
    834835        }
     
    916917        foreach ($query_key as $k) {
    917918            // If not already set, and there is a non-empty value provided in the request...
    918             if (!isset($this->_carry_queries[$k]) && false !== getFormData($k, $default)) {
     919            if (isset($k) && '' != $k && !isset($this->_carry_queries[$k]) && false !== getFormData($k, $default)) {
    919920                // Copy the value of the specified query argument into the _carry_queries array.
    920921                $this->_carry_queries[$k] = getFormData($k, $default);
     
    990991        $one_time_carry_queries = array();
    991992        if (!is_null($carry_args)) {
    992             if (is_array($carry_args) && !empty($carry_args)) {
    993                 foreach ($carry_args as $key=>$arg) {
    994                     // Get query from appropriate source.
    995                     if (false === $arg) {
    996                         $do_carry_queries = false;
    997                     } else if (false !== getFormData($arg, false)) {
    998                         $one_time_carry_queries[$arg] = getFormData($arg); // Set arg to form data if available.
    999                     } else if (!is_numeric($key) && '' != $arg) {
    1000                         $one_time_carry_queries[$key] = getFormData($key, $arg); // Set to arg to default if specified (overwritten by form data).
     993            if (is_array($carry_args)) {
     994                if (!empty($carry_args)) {
     995                    foreach ($carry_args as $key=>$arg) {
     996                        // Get query from appropriate source.
     997                        if (false === $arg) {
     998                            $do_carry_queries = false;
     999                        } else if (false !== getFormData($arg, false)) {
     1000                            $one_time_carry_queries[$arg] = getFormData($arg); // Set arg to form data if available.
     1001                        } else if (!is_numeric($key) && '' != $arg) {
     1002                            $one_time_carry_queries[$key] = getFormData($key, $arg); // Set to arg to default if specified (overwritten by form data).
     1003                        }
    10011004                    }
    10021005                }
     
    11101113        $one_time_carry_queries = array();
    11111114        if (!is_null($carry_args)) {
    1112             if (is_array($carry_args) && !empty($carry_args)) {
    1113                 foreach ($carry_args as $key=>$arg) {
    1114                     // Get query from appropriate source.
    1115                     if (false === $arg) {
    1116                         $do_carry_queries = false;
    1117                     } else if (false !== getFormData($arg, false)) {
    1118                         $one_time_carry_queries[$arg] = getFormData($arg); // Set arg to form data if available.
    1119                     } else if (!is_numeric($key) && '' != $arg) {
    1120                         $one_time_carry_queries[$key] = getFormData($key, $arg); // Set to arg to default if specified (overwritten by form data).
     1115            if (is_array($carry_args)) {
     1116                if (!empty($carry_args)) {
     1117                    foreach ($carry_args as $key=>$arg) {
     1118                        // Get query from appropriate source.
     1119                        if (false === $arg) {
     1120                            $do_carry_queries = false;
     1121                        } else if (false !== getFormData($arg, false)) {
     1122                            $one_time_carry_queries[$arg] = getFormData($arg); // Set arg to form data if available.
     1123                        } else if (!is_numeric($key) && '' != $arg) {
     1124                            $one_time_carry_queries[$key] = getFormData($key, $arg); // Set to arg to default if specified (overwritten by form data).
     1125                        }
    11211126                    }
    11221127                }
     
    11361141                if (is_array($val)) {
    11371142                    foreach ($val as $subval) {
    1138                         printf('<input type="hidden" name="%s[]" value="%s" />', $key, $subval);
     1143                        if ('' != $key && '' != $subval) {
     1144                            printf('<input type="hidden" name="%s[]" value="%s" />', $key, $subval);
     1145                        }
    11391146                    }
    1140                 } else {
     1147                } else if ('' != $key && '' != $val) {
    11411148                    printf('<input type="hidden" name="%s" value="%s" />', $key, $val);
    11421149                }
Note: See TracChangeset for help on using the changeset viewer.