/** * Saves log settings frontend configurations * * @return void * */ private function save() { onapp_debug(__CLASS__ . ' :: ' . __FUNCTION__); $settings = onapp_get_arg('settings'); onapp_debug('save: $settings => ' . print_r($settings, true)); if (file_exists(ONAPP_PATH . ONAPP_DS . 'config.ini')) { $conf = parse_ini_file(ONAPP_PATH . ONAPP_DS . 'config.ini'); onapp_debug('$conf => ' . print_r($conf, true)); // get constant string names instead of numeric values $frontend_error_levels = onapp_get_frontend_errors(); $php_error_levels = onapp_get_php_errors(); foreach ($conf as $key => $value) { if ($key == 'log_level_php') { $conf[$key] = $php_error_levels[$value]; } else { if ($key == 'log_level_frontend') { $conf[$key] = $frontend_error_levels[$value]; } } } $result = array_merge($conf, $settings); if (!$result) { $error = 'COULD_NOT_UPDATE_CONFIG_FILE'; } else { onapp_debug('$conf and $settings arrays merge => ' . print_r($result, true)); $updated = $this->write_config($result, ONAPP_PATH . ONAPP_DS . 'config.ini'); if (!is_null($updated)) { $error = $updated; } } if (!isset($error)) { onapp_debug('Update Success'); } } else { $error = 'CONFIG_FILE_DOES_NOT_EXISTS'; } if (!isset($error)) { $this->show_template_view('CONFIGURATIONS_HAVE_BEEN_UPDATED'); } else { trigger_error(onapp_string($error)); $this->show_template_edit($error); } }
/** * Adds onapp error message. * * @param string $message Error message from error_get_last function * * @return void * */ function onapp_error_reporting($error) { $error_levels = onapp_get_php_errors(); if (ONAPP_LOG_LEVEL_PHP < $error['type'] || is_null($error)) { return; } $error_type = in_array($error['type'], array_keys($error_levels)) ? $error_levels[$error['type']] : "ERROR ID " . $error['type']; if ($error !== NULL && isset($_SESSION['log_id'])) { if (is_null($error['file']) && is_null($error['line'])) { $msg = '[' . $_SESSION['log_id'] . "] : [{$error_type}] : " . $error['message']; } else { $msg = '[' . $_SESSION['log_id'] . "] : [{$error_type}] in " . $error['file'] . ' on line ' . $error['line'] . ' \'' . $error['message'] . '\''; } onapp_file_write($msg, 'error'); onapp_file_write($msg, 'frontend'); } }