Revision 8341eb47
Added by Renato Botelho about 10 years ago
etc/inc/pfsense-utils.inc | ||
---|---|---|
450 | 450 |
@file_put_contents($file, $text); |
451 | 451 |
} |
452 | 452 |
|
453 |
/* |
|
454 |
* add_text_to_file($file, $text): adds $text to $file. |
|
455 |
* replaces the text if it already exists. |
|
456 |
*/ |
|
457 |
function add_text_to_file($file, $text, $replace = false) { |
|
458 |
if (file_exists($file) and is_writable($file)) { |
|
459 |
$filecontents = file($file); |
|
460 |
$filecontents = array_map('rtrim', $filecontents); |
|
461 |
array_push($filecontents, $text); |
|
462 |
if ($replace) { |
|
463 |
$filecontents = array_unique($filecontents); |
|
464 |
} |
|
465 |
|
|
466 |
$file_text = implode("\n", $filecontents); |
|
467 |
|
|
468 |
@file_put_contents($file, $file_text); |
|
469 |
return true; |
|
470 |
} |
|
471 |
return false; |
|
472 |
} |
|
473 |
|
|
474 | 453 |
/* |
475 | 454 |
* after_sync_bump_adv_skew(): create skew values by 1S |
476 | 455 |
*/ |
Also available in: Unified diff
Remove unused function add_text_to_file()