Skip to content

Instantly share code, notes, and snippets.

@rootwyrm
Created July 26, 2018 17:41
Show Gist options
  • Save rootwyrm/ec8a8189221539df5d2720da9855f2ca to your computer and use it in GitHub Desktop.
Save rootwyrm/ec8a8189221539df5d2720da9855f2ca to your computer and use it in GitHub Desktop.
/*
Copyright (C) 2018-* Phillip R. Jaenke
All rights reserved.
Anti-Thief License:
- You may freely copy and distribute this code providing it retains the complete copyright notice.
- You may not copy or distribute modified versions of this code.
- You may not use this code without crediting the original author.
- You may not use this code in any form in the following projects:
pfSense, m0n0wall
- You may not use this code if you are an employee of:
Juniper, Cisco, Netgate, Inc.
*/
/* Start DynDNS for CARP nodes */
$first_zero = null;
foreach($config['dyndnses']['dyndns'] as $foo_index => $useless_foo) {
file_put_contents("/tmp/dyn.start", var_export($config['dyndnses'], true
) );
$config['dyndnses']['dyndns'][$foo_index]['enable'] = false;
if( $first_zero == null && (string)$config['dyndnses']['dyndns'][$foo_in
dex]['id'] == "0" ) {
$first_zero = $foo_index;
}
file_put_contents("/tmp/dyn.start2", var_export($config['dyndnses'], tru
e) );
}
if( $first_zero !== null ) {
$config['dyndnses']['dyndns'][$first_zero]['enable'] = true;
}
foreach($config['dyndnses']['dyndns'] as &$foo) {
# assume all should be forced to disabled
$foo['enable'] = null;
# but if you are the magic id zero
if( $foo['id'] == 0 ) {
$foo['enable'] = true;
}
}
# because memory reference
unset($foo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment