00001 <?php 00002 function change_broadcast() { 00003 $myFile = "/etc/conf.d/net.eth0"; 00004 $fr = fopen($myFile, 'r') or die("Can't open file in read mode"); 00005 $data = fread($fr, filesize($myFile)); 00006 $replace_value = "BROADCAST=" . $_POST['new_broadcast']; 00007 fclose($fr); 00008 preg_match('/BROADCAST=\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/', $data, $matches); 00009 $replace = str_replace($matches[0], $replace_value, $data); 00010 $fw = fopen($myFile, 'w') or die ("Can't open file in write mode"); 00011 fwrite($fw, $replace); 00012 fclose($fw); 00013 } 00014 change_broadcast(); 00015 print "Broadcast is now set to " . "<b>" . $_POST['new_broadcast'] . "</b>" . "<br />"; 00016 print "Reboot camera for these changes to take effect."; 00017 ?>