Changeset 44


Ignore:
Timestamp:
Dec 19, 2005 7:10:45 AM (18 years ago)
Author:
scdev
Message:

${1}

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/form_template.cli.php

    r43 r44  
    3434
    3535$exclude = array('added_by_user_id', 'added_datetime', 'hit_count', 'modified_datetime', 'modified_by_user_id');
    36 $primary_key_field = '';
     36$primary_key = '<##>';
    3737$output = array();
    3838
     
    4646        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    4747        if ('PRI' == $col[3]) {
    48             $primary_key_field = $field;
     48            $primary_key = $field;
    4949        }
    5050
     
    5454        }
    5555
    56         if (in_array($field, $exclude) || $primary_key_field == $field) {
     56        if (in_array($field, $exclude) || $primary_key == $field) {
    5757            // Don't add a field for this column.
    5858            continue;
     
    8787        <td>
    8888            <input type="file" name="$field" />
    89             <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
    90             <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\\\$s\"><strong>%2\\\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div>
     89            <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
     90            <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\\\$s\"><strong>%2\\\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key') . '_*')) \x3f></div>
    9191            <\x3fphp } \x3f>
    9292            <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->getParam('valid_file_extensions'))) \x3f></div>
  • trunk/bin/module_maker/list_template.cli.php

    r43 r44  
    4545    $cols[] = $row;
    4646}
     47
     48$primary_key = '<##>';
    4749
    4850// Loop through columns
  • trunk/bin/module_maker/sql.cli.php

    r43 r44  
    5252
    5353$sort_columns = '';
     54$primary_key = '<##>';
    5455
    5556// Loop through columns
  • trunk/lib/App.inc.php

    r43 r44  
    367367
    368368        // Save message in session under unique key to avoid duplicate messages.
    369         $_SESSION[$this->app]['messages'][md5($type . $message . $file . $line)] = array(
     369        $msg_id = md5($type . $message . $file . $line);
     370        $_SESSION[$this->app]['messages'][$msg_id] = array(
    370371            'type'    => $type,
    371372            'message' => $message,
    372373            'file'    => $file,
    373             'line'    => $line
     374            'line'    => $line,
     375            'count'   => (isset($_SESSION[$this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->app]['messages'][$msg_id]['count']) : 1)
    374376        );
    375377
     
    425427
    426428    /**
    427      * Logs a message to a user defined log file. Additional actions to take for
    428      * different types of message types can be specified (ERROR, NOTICE, etc).
     429     * Logs messages to defined channels: file, email, sms, and screen. Repeated messages are
     430     * not repeated but printed once with count.
    429431     *
    430432     * @access public
    431      *
    432433     * @param string $message   The text description of the message.
    433434     * @param int    $priority  The type of message priority (in descending order):
     
    445446    function logMsg($message, $priority=LOG_INFO, $file=null, $line=null)
    446447    {
     448        static $previous_events = array();
     449
    447450        if (!isset($this) || !is_a($this, 'App')) {
    448451            $this =& App::getInstance();
     
    466469        setlocale(LC_TIME, 'C');
    467470
     471        // Strip HTML tags except any with more than 7 characters because that's probably not a HTML tag, e.g. <email@address.com>.
     472        preg_match_all('/(<[^>\s]{7,})[^>]*>/', $message, $strip_tags_allow);
     473        $message = strip_tags(preg_replace('/\s+/', ' ', $message), (!empty($strip_tags_allow[1]) ? join('> ', $strip_tags_allow[1]) . '>' : null));
     474
     475        // Store this event under a unique key, counting each time it occurs so that it only gets reported a limited number of times.
     476        $msg_id = md5($message . $priority . $file . $line);
     477        if (isset($previous_events[$msg_id])) {
     478            $previous_events[$msg_id]++;
     479            if ($previous_events[$msg_id] == 2) {
     480                $this->logMsg(sprintf('%s (Event repeated more than %s times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
     481            }
     482            return false;
     483        } else {
     484            $previous_events[$msg_id] = 1;
     485        }
     486       
    468487        // Data to be stored for a log event.
    469         $event = array();
    470         $event['date'] = date('Y-m-d H:i:s');
    471         $event['remote ip'] = getRemoteAddr();
    472         if (substr(PHP_OS, 0, 3) != 'WIN') {
    473             $event['pid'] = posix_getpid();
    474         }
    475         $event['type'] = $this->logPriorityToString($priority);
    476         $event['file:line'] = "$file : $line";
    477         preg_match_all('/(<[^>\s]{7,})[^>]*>/', $message, $strip_tags_allow); // <...> with lots of chars maybe we don't want stripped.
    478         $event['message'] = strip_tags(preg_replace('/\s+/', ' ', $message), (!empty($strip_tags_allow[1]) ? join('> ', $strip_tags_allow[1]) . '>' : null));
    479         $event_str = '[' . join('] [', $event) . ']';
     488        $event = array(
     489            'date'      => date('Y-m-d H:i:s'),
     490            'remote ip' => getRemoteAddr(),
     491            'pid'       => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''),
     492            'type'      => $this->logPriorityToString($priority),
     493            'file:line' => "$file : $line",
     494            'message'   => $message
     495        );
    480496
    481497        // FILE ACTION
    482498        if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
     499            $event_str = '[' . join('] [', $event) . ']';
    483500            error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
    484501        }
  • trunk/lib/Nav.inc.php

    r43 r44  
    261261     * @access  public
    262262     *
    263      * @param   mixed   $page   The URI of the page to query.
     263     * @param   mixed   $page   The URI of the page to query, with PREG express markup, if needed.
    264264     * @param   mixed   $return The value to return if the current page matches the page queried.
    265265     *
    266      * @return  bool    True on success, false on failure.
     266     * @return  mixed   The value set for $return, TRUE by default.
    267267     */
    268268    function currentPage($page_uri, $return=true)
    269269    {
    270         if (preg_match('/^' . preg_quote($page_uri, '/') . '/i', $_SERVER['PHP_SELF'])) {
     270        $page_uri = str_replace('/', '\/', $page_uri);
     271        if (preg_match('/^' . $page_uri . '/i', $_SERVER['PHP_SELF'])) {
    271272            return $return;
    272273        }
  • trunk/lib/SessionCache.inc.php

    r43 r44  
    100100
    101101        if (!$this->getParam('enabled')) {
     102            App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
    102103            return false;
    103104        }
  • trunk/lib/SortOrder.inc.php

    r43 r44  
    106106
    107107    /**
    108      * Set sort and order values. This is how you set new sort values after
     108     * Forcibly set sort and order values. This is how you set new sort values after
    109109     * already declaring a SortOrder object. This will ignore getFormData values.
    110110     *
    111      * @param string $col            The database column to sort by.
    112      * @param string $col_name       The human-readable title of the column.
    113      * @param string $default_order  The default order for this column (ASC,
     111     * @param string $sort           The sort by name.
     112     * @param string $order          The order direction (ASC,
    114113     *                               for example, for an alphabetical sort)
    115114     */
     
    144143
    145144        if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) {
    146             return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]);
     145            return sprintf(' ORDER BY %s ', addslashes($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]));
    147146        } else {
    148147            App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);
Note: See TracChangeset for help on using the changeset viewer.