Example #1
0
/**
 * @brief Set the enable attribute
 * ¨
 * @param boolean       $new_enable         The new enable state
 * @param string|NULL   $admin_password     @li The admin password for enabling/disabling the debug log (from "config.php").
 *                                          @li see $config['debug']['password'] in config_defaults.php
 *                                          @li For disabling the debug log,
 *                                              the passwort is not required (pass NULL)!
 *
 * @throws Exception if there was an error (maybe wrong password)
 */
function set_debug_enable($new_enable, $admin_password = NULL)
{
    global $config;
    if ($new_enable == $config['debug']['enable']) {
        return;
    }
    // there is nothing to do...
    if ($new_enable == false) {
        $config['debug']['enable'] = false;
        $config['debug']['template_debugging_enable'] = false;
        $config['debug']['request_debugging_enable'] = false;
        try {
            save_config();
        } catch (Exception $e) {
            $config['debug']['enable'] = true;
            throw $e;
        }
        return;
    }
    // to activate the debug log, we have to check the admin password.
    // or, for online demos, it's allowed to activate debugging for everyone.
    if (!is_admin_password($admin_password) && !$config['is_online_demo']) {
        throw new Exception('Das Passwort ist nicht korrekt!');
    }
    // create new debug log file if it does not exist already
    if (!is_readable(DEBUG_LOG_FILENAME)) {
        create_debug_log_file();
    }
    $config['debug']['enable'] = true;
    try {
        save_config();
    } catch (Exception $e) {
        $config['debug']['enable'] = false;
        throw $e;
    }
    return;
}
Example #2
0
    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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/
include_once 'start_session.php';
$errors = array();
if (isset($_REQUEST["add"])) {
    try {
        debug($_REQUEST['new_type'], $_REQUEST['new_text'], __FILE__, __LINE__, __METHOD__, false);
    } catch (Exception $exception) {
        $errors[] = $exception->getMessage();
    }
} elseif (isset($_REQUEST["clear"])) {
    try {
        create_debug_log_file();
        // override the existing debug log with a new, empty debug log
    } catch (Exception $exception) {
        $errors[] = $exception->getMessage();
    }
} elseif (isset($_REQUEST["download"])) {
    if (is_readable(DEBUG_LOG_FILENAME)) {
        send_file(DEBUG_LOG_FILENAME);
        // TODO: how can we re-activate the autorefresh now?!
    } else {
        $errors[] = 'Die Log-Datei kann nicht gelesen werden!';
    }
} elseif (isset($_REQUEST["enable"])) {
    try {
        set_debug_enable(true, $_REQUEST['admin_password']);
        header('Location: system_debug.php');