From 5585e10967268cd1d281b8a713d16305d18d8991 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 29 Aug 2016 09:17:39 +0200 Subject: [PATCH] src: strip gettext() from write_config(); closes #1158 --- src/etc/inc/config.lib.inc | 6 +-- src/etc/inc/services.inc | 25 ---------- src/etc/inc/system.inc | 2 +- src/etc/inc/xmlrpc/legacy.inc | 2 +- src/etc/rc.initial.password | 2 +- src/etc/rc.initial.setlanip | 2 +- src/wizard/setup.xml | 2 +- src/www/diag_backup.php | 2 +- src/www/diag_confbak.php | 2 +- src/www/firewall_nat_1to1.php | 20 ++++---- src/www/firewall_nat_npt.php | 76 +++++++++++++++---------------- src/www/index.php | 2 +- src/www/services_rfc2136_edit.php | 3 +- src/www/services_upnp.php | 2 +- src/www/system_crlmanager.php | 10 ++-- src/www/vpn_ipsec_keys.php | 2 +- 16 files changed, 64 insertions(+), 96 deletions(-) diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc index 919582e51..6d73983e3 100644 --- a/src/etc/inc/config.lib.inc +++ b/src/etc/inc/config.lib.inc @@ -138,7 +138,7 @@ function convert_config() } if ($prev_version != $config['version']) { - write_config(sprintf(gettext('Upgraded config version level from %s to %s'), $prev_version, $config['version'])); + write_config(sprintf('Upgraded config version level from %s to %s', $prev_version, $config['version'])); } } @@ -222,7 +222,7 @@ function config_restore($conffile) $config = parse_config(); - write_config(gettext("Reverted to") . " " . array_pop(explode("/", $conffile)) . ".", false); + write_config(sprintf('Reverted to %s', array_pop(explode('/', $conffile))), false); return 0; } @@ -312,7 +312,7 @@ function make_config_revision_entry($desc = '') } if (empty($desc)) { - $desc = sprintf(gettext('%s made changes'), $_SERVER['SCRIPT_NAME']); + $desc = sprintf('%s made changes', $_SERVER['SCRIPT_NAME']); } $revision = array(); diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 0e2ec47f8..406fde3f9 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -2355,31 +2355,6 @@ function configure_cron() { global $config; - /* - * Strip the cron jobs that we no longer save explicitly. - * This can be safely removed on our final road to 17.1. - */ - if (isset($config['cron']['item'])) { - $flush = false; - $index = 0; - - /* PHP retains the index, can iterate all and unset */ - foreach ($config['cron']['item'] as $item) { - unset($config['cron']['item'][$index]); - $flush = true; - $index++; - } - - if (!count($config['cron']['item'])) { - unset($config['cron']); - $flush = true; - } - - if ($flush) { - write_config(gettext('Removed obsolete cron jobs')); - } - } - $autocron = array(); /* hourly */ diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index b98b88b64..06bccd4ba 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -981,7 +981,7 @@ function system_webgui_configure() cert_import($cert, $crt, $key); $a_cert[] = $cert; $config['system']['webgui']['ssl-certref'] = $cert['refid']; - write_config(gettext("Importing HTTPS certificate")); + write_config('Importing HTTPS certificate'); } else { $crt = base64_decode($cert['crt']); $key = base64_decode($cert['prv']); diff --git a/src/etc/inc/xmlrpc/legacy.inc b/src/etc/inc/xmlrpc/legacy.inc index 237611835..ce7ec251e 100644 --- a/src/etc/inc/xmlrpc/legacy.inc +++ b/src/etc/inc/xmlrpc/legacy.inc @@ -200,7 +200,7 @@ function restore_config_section_xmlrpc($new_config) /* Log what happened */ $mergedkeys = implode(",", array_merge(array_keys($new_config), $sync_full_done)); - write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."), $mergedkeys)); + write_config(sprintf('Merged %s config sections from XMLRPC client.', $mergedkeys)); /* * Handle virtual ips diff --git a/src/etc/rc.initial.password b/src/etc/rc.initial.password index fe9cb7f51..fbae06c99 100755 --- a/src/etc/rc.initial.password +++ b/src/etc/rc.initial.password @@ -72,7 +72,7 @@ if (strcasecmp(chop(fgets($fp)), 'y') == 0) { local_user_set_password($admin_user, $g['factory_shipped_password']); local_user_set($admin_user); - write_config(gettext("password changed from console menu")); + write_config('Password reset from console menu'); printf("\n\n"); printf(gettext("The password has been reset.")); diff --git a/src/etc/rc.initial.setlanip b/src/etc/rc.initial.setlanip index c7893c654..ff6a296d3 100755 --- a/src/etc/rc.initial.setlanip +++ b/src/etc/rc.initial.setlanip @@ -492,7 +492,7 @@ if (!$config['interfaces']['lan']) { $upperifname = strtoupper($interface); if (!$dry_run) { echo "\nPlease wait while the changes are saved to {$upperifname}..."; - write_config(sprintf(gettext("%s IP configuration from console menu"), $interface)); + write_config(sprintf('%s IP configuration from console menu', $interface)); interface_reconfigure(strtolower($upperifname)); echo "\n Reloading filter..."; filter_configure_sync(); diff --git a/src/wizard/setup.xml b/src/wizard/setup.xml index d068da071..969f0958b 100644 --- a/src/wizard/setup.xml +++ b/src/wizard/setup.xml @@ -43,7 +43,7 @@ if (isset($config['trigger_initial_wizard'])) { unset($config['trigger_initial_wizard']); - write_config(gettext("Triggered initial wizard")); + write_config('Triggered initial wizard'); } diff --git a/src/www/diag_backup.php b/src/www/diag_backup.php index d848b55fb..113e00b23 100644 --- a/src/www/diag_backup.php +++ b/src/www/diag_backup.php @@ -57,7 +57,7 @@ function restore_config_section($section_name, $new_contents) $config[$section_name] = $xml[$section_name]; - write_config(sprintf(gettext("Restored %s of config file"), $section_name)); + write_config(sprintf('Restored section %s of config file', $section_name)); convert_config(); disable_security_checks(); diff --git a/src/www/diag_confbak.php b/src/www/diag_confbak.php index 8af37e960..063c7c827 100644 --- a/src/www/diag_confbak.php +++ b/src/www/diag_confbak.php @@ -94,7 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } if (count($input_errors) == 0) { $config['system']['backupcount'] = $pconfig['backupcount']; - write_config(gettext('Changed backup revision count.')); + write_config('Changed backup revision count'); $savemsg = get_std_save_message(); } } diff --git a/src/www/firewall_nat_1to1.php b/src/www/firewall_nat_1to1.php index 247de66a6..b6abf4085 100644 --- a/src/www/firewall_nat_1to1.php +++ b/src/www/firewall_nat_1to1.php @@ -51,9 +51,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif (isset($pconfig['action']) && $pconfig['action'] == 'del' && isset($id)) { // delete single entry unset($a_1to1[$id]); - if (write_config()) { - mark_subsystem_dirty('natconf'); - } + write_config(); + mark_subsystem_dirty('natconf'); header("Location: firewall_nat_1to1.php"); exit; } elseif (isset($pconfig['action']) && $pconfig['action'] == 'del_x' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) { @@ -61,9 +60,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($pconfig['rule'] as $rulei) { unset($a_1to1[$rulei]); } - if (write_config()) { - mark_subsystem_dirty('natconf'); - } + write_config(); + mark_subsystem_dirty('natconf'); header("Location: firewall_nat_1to1.php"); exit; } elseif (isset($pconfig['action']) && $pconfig['action'] == 'move') { @@ -75,9 +73,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } $a_1to1 = legacy_move_config_list_items($a_1to1, $id, $pconfig['rule']); - if (write_config()) { - mark_subsystem_dirty('natconf'); - } + write_config(); + mark_subsystem_dirty('natconf'); header("Location: firewall_nat_1to1.php"); exit; } @@ -88,9 +85,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } else { $a_1to1[$id]['disabled'] = true; } - if (write_config(gettext('Toggled NAT rule'))) { - mark_subsystem_dirty('natconf'); - } + write_config('Toggled NAT 1:1 rule'); + mark_subsystem_dirty('natconf'); header("Location: firewall_nat_1to1.php"); exit; } diff --git a/src/www/firewall_nat_npt.php b/src/www/firewall_nat_npt.php index a9c3293b9..e011acc90 100644 --- a/src/www/firewall_nat_npt.php +++ b/src/www/firewall_nat_npt.php @@ -47,52 +47,48 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $savemsg = get_std_save_message(); clear_subsystem_dirty('natconf'); clear_subsystem_dirty('filter'); - } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del' && isset($id)) { + } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del' && isset($id)) { // delete single record unset($a_npt[$id]); - if (write_config()) { - mark_subsystem_dirty('natconf'); - } + write_config(); + mark_subsystem_dirty('natconf'); header("Location: firewall_nat_npt.php"); exit; - } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del_x' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) { - /* delete selected rules */ - foreach ($pconfig['rule'] as $rulei) { - if (isset($a_npt[$rulei])) { - unset($a_npt[$rulei]); - } - } - if (write_config()) { - mark_subsystem_dirty('natconf'); - } - header("Location: firewall_nat_npt.php"); - exit; - } elseif ( isset($pconfig['act']) && $pconfig['act'] == 'move') { - // move records - if (isset($pconfig['rule']) && count($pconfig['rule']) > 0) { - // if rule not set/found, move to end - if (!isset($id)) { - $id = count($a_npt); - } - $a_npt = legacy_move_config_list_items($a_npt, $id, $pconfig['rule']); + } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del_x' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) { + /* delete selected rules */ + foreach ($pconfig['rule'] as $rulei) { + if (isset($a_npt[$rulei])) { + unset($a_npt[$rulei]); } - if (write_config()) { - mark_subsystem_dirty('natconf'); + } + write_config(); + mark_subsystem_dirty('natconf'); + header("Location: firewall_nat_npt.php"); + exit; + } elseif (isset($pconfig['act']) && $pconfig['act'] == 'move') { + // move records + if (isset($pconfig['rule']) && count($pconfig['rule']) > 0) { + // if rule not set/found, move to end + if (!isset($id)) { + $id = count($a_npt); } - header("Location: firewall_nat_npt.php"); - exit; - } elseif (isset($pconfig['act']) && $pconfig['act'] == 'toggle' && isset($id)) { - // toggle item - if(isset($a_npt[$id]['disabled'])) { - unset($a_npt[$id]['disabled']); - } else { - $a_npt[$id]['disabled'] = true; - } - if (write_config(gettext("Firewall: NAT: NPT, enable/disable NAT rule"))) { - mark_subsystem_dirty('natconf'); - } - header("Location: firewall_nat_npt.php"); - exit; + $a_npt = legacy_move_config_list_items($a_npt, $id, $pconfig['rule']); + } + write_config(); + mark_subsystem_dirty('natconf'); + header("Location: firewall_nat_npt.php"); + exit; + } elseif (isset($pconfig['act']) && $pconfig['act'] == 'toggle' && isset($id)) { + // toggle item + if(isset($a_npt[$id]['disabled'])) { + unset($a_npt[$id]['disabled']); + } else { + $a_npt[$id]['disabled'] = true; + } + write_config('Toggled NAT NPT rule'); + mark_subsystem_dirty('natconf'); + header("Location: firewall_nat_npt.php"); + exit; } } diff --git a/src/www/index.php b/src/www/index.php index 3c42f9941..4840a8412 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -83,7 +83,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } elseif(isset($config['widgets']['column_count'])) { unset($config['widgets']['column_count']); } - write_config(gettext('Widget configuration has been changed.')); + write_config('Widget configuration has been changed'); header('Location: index.php'); exit; } diff --git a/src/www/services_rfc2136_edit.php b/src/www/services_rfc2136_edit.php index 1c88e52f5..e5a171f77 100644 --- a/src/www/services_rfc2136_edit.php +++ b/src/www/services_rfc2136_edit.php @@ -101,7 +101,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } else { $a_rfc2136[] = $rfc2136; } - write_config(gettext("New/Edited RFC2136 dnsupdate entry was posted.")); + + write_config('New/Edited RFC2136 dnsupdate entry was posted'); if (!empty($pconfig['force'])) { services_dnsupdate_process("", $rfc2136['host'], true); diff --git a/src/www/services_upnp.php b/src/www/services_upnp.php index d29d40f8e..de202b9cf 100644 --- a/src/www/services_upnp.php +++ b/src/www/services_upnp.php @@ -148,7 +148,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // sync to config $config['installedpackages']['miniupnpd']['config'] = $upnp; - write_config(gettext('Modified Universal Plug and Play settings.')); + write_config('Modified Universal Plug and Play settings'); sync_package_miniupnpd(); header("Location: services_upnp.php"); exit; diff --git a/src/www/system_crlmanager.php b/src/www/system_crlmanager.php index 00ba44e06..39c65415c 100644 --- a/src/www/system_crlmanager.php +++ b/src/www/system_crlmanager.php @@ -158,7 +158,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { unset($a_crl[$cid]); } } - write_config("Deleted CRL {$name}."); + write_config(sprintf('Deleted CRL %s', $name)); header("Location: system_crlmanager.php"); exit; } @@ -181,11 +181,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $name = $thiscert['descr']; if (cert_unrevoke($thiscert, $thiscrl)) { openvpn_refresh_crls(); - write_config(sprintf(gettext("Deleted Certificate %s from CRL %s"), $name, $thiscrl['descr'])); + write_config(sprintf('Deleted certificate %s from CRL %s', $name, $thiscrl['descr'])); header("Location: system_crlmanager.php"); exit; } else { - $savemsg = sprintf(gettext("Failed to delete Certificate %s from CRL %s"), $name, $thiscrl['descr']) . "
"; + $savemsg = sprintf(gettext("Failed to delete certificate %s from CRL %s"), $name, $thiscrl['descr']) . "
"; } $act="edit"; } elseif ($act == "addcert") { @@ -214,7 +214,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $reason = (empty($pconfig['crlreason'])) ? OCSP_REVOKED_STATUS_UNSPECIFIED : $pconfig['crlreason']; cert_revoke($cert, $crl, $reason); openvpn_refresh_crls(); - write_config("Revoked cert {$cert['descr']} in CRL {$crl['descr']}."); + write_config(sprintf('Revoked certificate %s in CRL %s', $cert['descr'], $crl['descr'])); header("Location: system_crlmanager.php"); exit; } @@ -269,7 +269,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $a_crl[] = $crl; } - write_config("Saved CRL {$crl['descr']}"); + write_config(sprintf('Saved CRL %s', $crl['descr'])); openvpn_refresh_crls(); header("Location: system_crlmanager.php"); exit; diff --git a/src/www/vpn_ipsec_keys.php b/src/www/vpn_ipsec_keys.php index 6c2725a67..835e4dee3 100644 --- a/src/www/vpn_ipsec_keys.php +++ b/src/www/vpn_ipsec_keys.php @@ -49,7 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // delete entry if (isset($config['ipsec']['mobilekey'][$_POST['id']])) { unset($config['ipsec']['mobilekey'][$_POST['id']]); - write_config(gettext("Deleted IPsec Pre-Shared Key")); + write_config('Deleted pre-shared IPsec key'); mark_subsystem_dirty('ipsec'); header("Location: vpn_ipsec_keys.php"); exit;