Revision 51a14c58
Added by Phil Davis over 9 years ago
src/etc/inc/voucher.inc | ||
---|---|---|
93 | 93 |
XML_RPC_encode($execcmd) |
94 | 94 |
); |
95 | 95 |
|
96 |
log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}.");
|
|
96 |
log_error(sprintf(gettext("Captive Portal Voucher XMLRPC sync data %s."), $url . ":" . $port));
|
|
97 | 97 |
$msg = new XML_RPC_Message($method, $params); |
98 | 98 |
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); |
99 | 99 |
$cli->setCredentials($username, $password); |
100 | 100 |
$resp = $cli->send($msg, "250"); |
101 | 101 |
if (!is_object($resp)) { |
102 |
$error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
|
|
102 |
$error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url . ":" . $port);
|
|
103 | 103 |
log_error($error); |
104 | 104 |
file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); |
105 | 105 |
return false; |
106 | 106 |
} elseif ($resp->faultCode()) { |
107 |
$error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
|
|
107 |
$error = sprintf(gettext('An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %1$s - Code %2$s'), $url . ":" . $port, $resp->faultCode() . ": " . $resp->faultString());
|
|
108 | 108 |
log_error($error); |
109 | 109 |
file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); |
110 | 110 |
return false; |
111 | 111 |
} else { |
112 |
log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
|
|
112 |
log_error(sprintf(gettext("CaptivePortalVoucherSync XMLRPC reload data success with %s (pfsense.exec_php)."), $url . ":" . $port));
|
|
113 | 113 |
} |
114 | 114 |
|
115 | 115 |
$toreturn = XML_RPC_Decode($resp->value()); |
... | ... | |
153 | 153 |
XML_RPC_encode($execcmd) |
154 | 154 |
); |
155 | 155 |
|
156 |
log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}.");
|
|
156 |
log_error(sprintf(gettext("Captive Portal Voucher XMLRPC sync data %s."), $url . ":" . $port));
|
|
157 | 157 |
$msg = new XML_RPC_Message($method, $params); |
158 | 158 |
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); |
159 | 159 |
$cli->setCredentials($username, $password); |
160 | 160 |
$resp = $cli->send($msg, "250"); |
161 | 161 |
if (!is_object($resp)) { |
162 |
$error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
|
|
162 |
$error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url . ":" . $port);
|
|
163 | 163 |
log_error($error); |
164 | 164 |
file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); |
165 | 165 |
return false; |
166 | 166 |
} elseif ($resp->faultCode()) { |
167 |
$error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
|
|
167 |
$error = sprintf(gettext('An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %1$s - Code %2$s'), $url . ":" . $port, $resp->faultCode() . ": " . $resp->faultString());
|
|
168 | 168 |
log_error($error); |
169 | 169 |
file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); |
170 | 170 |
return false; |
171 | 171 |
} else { |
172 |
log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
|
|
172 |
log_error(sprintf(gettext("CaptivePortalVoucherSync XMLRPC reload data success with %s (pfsense.exec_php)."), $url . ":" . $port));
|
|
173 | 173 |
} |
174 | 174 |
|
175 | 175 |
$toreturn = XML_RPC_Decode($resp->value()); |
... | ... | |
212 | 212 |
XML_RPC_encode($execcmd) |
213 | 213 |
); |
214 | 214 |
|
215 |
log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}.");
|
|
215 |
log_error(sprintf(gettext("Captive Portal Voucher XMLRPC sync data %s."), $url . ":" . $port));
|
|
216 | 216 |
$msg = new XML_RPC_Message($method, $params); |
217 | 217 |
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); |
218 | 218 |
$cli->setCredentials($username, $password); |
219 | 219 |
$resp = $cli->send($msg, "250"); |
220 | 220 |
if (!is_object($resp)) { |
221 |
$error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
|
|
221 |
$error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s (pfsense.exec_php)."), $url . ":" . $port);
|
|
222 | 222 |
log_error($error); |
223 | 223 |
file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); |
224 | 224 |
return null; // $timeleft |
225 | 225 |
} elseif ($resp->faultCode()) { |
226 |
$error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
|
|
226 |
$error = sprintf(gettext('An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %1$s - Code %2$s'), $url . ":" . $port, $resp->faultCode() . ": " . $resp->faultString());
|
|
227 | 227 |
log_error($error); |
228 | 228 |
file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); |
229 | 229 |
return null; // $timeleft |
230 | 230 |
} else { |
231 |
log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
|
|
231 |
log_error(sprintf(gettext("CaptivePortalVoucherSync XMLRPC reload data success with %s (pfsense.exec_php)."), $url . ":" . $port));
|
|
232 | 232 |
} |
233 | 233 |
$toreturn = XML_RPC_Decode($resp->value()); |
234 | 234 |
if (!is_array($config['voucher'])) { |
... | ... | |
237 | 237 |
|
238 | 238 |
if (is_array($toreturn['voucher']) && is_array($toreturn['voucher']['roll'])) { |
239 | 239 |
$config['voucher'][$cpzone]['roll'] = $toreturn['voucher']['roll']; |
240 |
write_config("Captive Portal Voucher database synchronized with {$url}");
|
|
240 |
write_config(sprintf(gettext("Captive Portal Voucher database synchronized with %s"), $url));
|
|
241 | 241 |
voucher_configure_zone(true); |
242 | 242 |
unset($toreturn['voucher']); |
243 | 243 |
} else if (!isset($toreturn['timeleft'])) { |
... | ... | |
324 | 324 |
$unsetindexes[] = $cpentry[5]; |
325 | 325 |
} |
326 | 326 |
} else { |
327 |
captiveportal_syslog("$voucher ($roll/$nr): not found on any registered Roll");
|
|
327 |
captiveportal_syslog(sprintf(gettext('%1$s (%2$s/%3$s): not found on any registered Roll'), $voucher, $roll, $nr));
|
|
328 | 328 |
} |
329 | 329 |
} else { |
330 | 330 |
// hmm, thats weird ... not what I expected |
331 |
captiveportal_syslog("$voucher invalid: {$output[0]}!!");
|
|
331 |
captiveportal_syslog(sprintf(gettext('%1$s invalid: %2$s!!'), $voucher, $output[0]));
|
|
332 | 332 |
} |
333 | 333 |
} |
334 | 334 |
|
... | ... | |
415 | 415 |
foreach ($a_vouchers_received as $voucher) { |
416 | 416 |
$v = escapeshellarg($voucher); |
417 | 417 |
if (strlen($voucher) < 5) { |
418 |
$test_result[] = "{$voucher} invalid: Too short!"; |
|
419 |
captiveportal_syslog("{$voucher} invalid: Too short!"); |
|
418 |
$voucher_err_text = sprintf(gettext("%s invalid: Too short!"), $voucher); |
|
419 |
$test_result[] = $voucher_err_text; |
|
420 |
captiveportal_syslog($voucher_err_text); |
|
420 | 421 |
$error++; |
421 | 422 |
continue; // seems too short to be a voucher! |
422 | 423 |
} |
... | ... | |
452 | 453 |
$pos = $nr >> 3; // divide by 8 -> octet |
453 | 454 |
$mask = 1 << ($nr % 8); |
454 | 455 |
if (ord($bitstring[$roll][$pos]) & $mask) { |
455 |
$test_result[] = "$voucher ($roll/$nr) already used and expired"; |
|
456 |
captiveportal_syslog("$voucher ($roll/$nr) already used and expired"); |
|
456 |
$voucher_err_text = sprintf(gettext('%1$s (%2$s/%3$s) already used and expired'), $voucher, $roll, $nr); |
|
457 |
$test_result[] = $voucher_err_text; |
|
458 |
captiveportal_syslog($voucher_err_text); |
|
457 | 459 |
$total_minutes = -1; // voucher expired |
458 | 460 |
$error++; |
459 | 461 |
} else { |
460 | 462 |
// mark bit for this voucher as used |
461 | 463 |
$bitstring[$roll][$pos] = chr(ord($bitstring[$roll][$pos]) | $mask); |
462 |
$test_result[] = "$voucher ($roll/$nr) good for {$minutes_per_roll[$roll]} Minutes";
|
|
464 |
$test_result[] = sprintf(gettext('%1$s (%2$s/%3$s) good for %4$s Minutes'), $voucher, $roll, $nr, $minutes_per_roll[$roll]);
|
|
463 | 465 |
$total_minutes += $minutes_per_roll[$roll]; |
464 | 466 |
} |
465 | 467 |
} |
466 | 468 |
} else { |
467 |
$test_result[] = "$voucher ($roll/$nr): not found on any registered Roll"; |
|
468 |
captiveportal_syslog("$voucher ($roll/$nr): not found on any registered Roll"); |
|
469 |
$voucher_err_text = sprintf(gettext('%1$s (%2$s/%3$s): not found on any registered Roll'), $voucher, $roll, $nr); |
|
470 |
$test_result[] = $voucher_err_text; |
|
471 |
captiveportal_syslog($voucher_err_text); |
|
469 | 472 |
} |
470 | 473 |
} else { |
471 | 474 |
// hmm, thats weird ... not what I expected |
472 |
$test_result[] = "$voucher invalid: $result !!"; |
|
473 |
captiveportal_syslog("$voucher invalid: $result !!"); |
|
475 |
$voucher_err_text = sprintf(gettext('%1$s invalid: %2$s !!'), $voucher, $result); |
|
476 |
$test_result[] = $voucher_err_text; |
|
477 |
captiveportal_syslog($voucher_err_text); |
|
474 | 478 |
$error++; |
475 | 479 |
} |
476 | 480 |
} |
... | ... | |
647 | 651 |
fwrite($fd, $vdb . "\n"); |
648 | 652 |
fclose($fd); |
649 | 653 |
} else { |
650 |
voucher_log(LOG_ERR, sprintf(gettext('cant write %1$s/voucher_%s_used_%2$s.db'), $g['vardb_path'], $cpzone, $roll));
|
|
654 |
voucher_log(LOG_ERR, sprintf(gettext('cant write %1$s/voucher_%2$s_used_%3$s.db'), $g['vardb_path'], $cpzone, $roll));
|
|
651 | 655 |
} |
652 | 656 |
} |
653 | 657 |
|
... | ... | |
733 | 737 |
$vdb = trim(fgets($fd)); |
734 | 738 |
fclose($fd); |
735 | 739 |
} else { |
736 |
voucher_log(LOG_ERR, sprintf(gettext('cant read %1$s/voucher_%s_used_%2$s.db'), $g['vardb_path'], $cpzone, $roll));
|
|
740 |
voucher_log(LOG_ERR, sprintf(gettext('cant read %1$s/voucher_%2$s_used_%3$s.db'), $g['vardb_path'], $cpzone, $roll));
|
|
737 | 741 |
} |
738 | 742 |
} |
739 | 743 |
return base64_decode($vdb); |
... | ... | |
805 | 809 |
|
806 | 810 |
unlock($voucherlck); |
807 | 811 |
|
808 |
write_config("Syncing vouchers");
|
|
812 |
write_config(gettext("Syncing vouchers"));
|
|
809 | 813 |
return; |
810 | 814 |
} |
811 | 815 |
|
Also available in: Unified diff
Internationalize etc inc uvx