This file is indexed.

/usr/share/simpleid/www/log.inc is in simpleid 0.8.1-14.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/*
 * SimpleID
 *
 * Copyright (C) Kelvin Mo 2007-9
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * $Id: log.inc 160 2009-08-24 11:02:16Z kmo $
 */

define('SIMPLEID_LOG_DEBUG', 5);
define('SIMPLEID_LOG_INFO', 4);
define('SIMPLEID_LOG_NOTICE', 3);
define('SIMPLEID_LOG_WARN', 2);
define('SIMPLEID_LOG_ERROR', 1);
define('SIMPLEID_LOG_FATAL', 0);

/**
 * This variable holds the pointer to the currently opened log file.  If the
 * log file is not open, this variable is NULL.
 *
 * @global resource $log
 */
$log = NULL;


/**
 * Opens the log file.
 *
 * This function opens a pointed to the log file for later usage.
 *
 * @return bool true if the log file is opened successfully.
 */
function log_open() {
    global $log;
    if (!defined('SIMPLEID_LOGFILE') || (SIMPLEID_LOGFILE == '')) return;
    $log = fopen(SIMPLEID_LOGFILE, 'a');
    
    if ($log === false) {
        $log = NULL;
        return false;
    } else {
        return true;
    }
}

/**
 * Closes the log file, if it is open.
 */
function log_close() {
    if ($log != NULL) {
        fflush($log);
        fclose($log);
        $log = NULL;
    }
}

/**
 * Logs a DEBUG message.
 *
 * @param string $message the message to log
 * @see _log_write()
 */
function log_debug($message) {
    _log_write($message, SIMPLEID_LOG_DEBUG);
}

/**
 * Logs an INFO message.
 *
 * @param string $message the message to log
 * @see _log_write()
 */
function log_info($message) {
    _log_write($message, SIMPLEID_LOG_INFO);
}

/**
 * Logs a NOTICE message.
 *
 * @param string $message the message to log
 * @see _log_write()
 */
function log_notice($message) {
    _log_write($message, SIMPLEID_LOG_NOTICE);
}

/**
 * Logs a WARN message.
 *
 * @param string $message the message to log
 * @see _log_write()
 */
function log_warn($message) {
    _log_write($message, SIMPLEID_LOG_WARN);
}

/**
 * Logs a ERROR message.
 *
 * @param string $message the message to log
 * @see _log_write()
 */
function log_error($message) {
    _log_write($message, SIMPLEID_LOG_ERROR);
}

/**
 * Logs a FATAL message.
 *
 * @param string $message the message to log
 * @see _log_write()
 */
function log_fatal($message) {
    _log_write($message, SIMPLEID_LOG_FATAL);
}

/**
 * Converts an array into a string for logging purposes.
 *
 * @param array $array the array the convert
 * @param array $keys an array of keys to include in the converted string.  Set
 * to false if all the keys in the array should be included
 * @return string the converted string.
 */
function log_array($array, $keys = false) {
    $output = array();
    
    if ($keys == false) $keys = array_keys($array);
    
    foreach ($keys as $key) {
        $output[] = $key . ": " . $array[$key];
    }
    
    return implode('; ', $output);
}

/**
 * Logs a message
 *
 * @param string $message the message to log
 * @param int $level the log level
 * @param bool true if the log has been written successfully
 */
function _log_write($message, $level = false) {
    global $log;
    static $levels;
    
    if (!$levels) {
        $levels = array(
            SIMPLEID_LOG_DEBUG => 'DEBUG',
            SIMPLEID_LOG_INFO => 'INFO',
            SIMPLEID_LOG_NOTICE => 'NOTICE',
            SIMPLEID_LOG_WARN => 'WARN',
            SIMPLEID_LOG_ERROR => 'ERROR',
            SIMPLEID_LOG_FATAL => 'FATAL'
        );
    }
    
    /* If a priority hasn't been specified, use the default value. */
    if ($level === false) {
        $level = SIMPLEID_LOG_INFO;
    }

    /* Abort early if the priority is above the maximum logging level. */
    if ($level > SIMPLEID_LOGLEVEL) {
        return false;
    }

    /* If the log file isn't already open, open it now. */
    if (($log == NULL) && !log_open()) {
        return false;
    }

    /* Build the string containing the complete log line. */
    $line = sprintf('%1$s %2$s [%3$s] %4$s', strftime(SIMPLEID_DATE_TIME_FORMAT), session_id(), $levels[$level], $message) . "\n";

    /* Write the log line to the log file. */
    $success = (fwrite($log, $line) !== false);

    return $success;
}

?>