Page 1 of 1
Need to open files under specific names through PHP
Posted: Fri Mar 14, 2008 12:32 pm
by isgur513
Hi all,
I currently have an html form that is used to register devices on my network. When someone goes to this form and puts in the MAC address, once they hit submit, two files must be created in the directory. A 'mac.cfg' and a 'mac-registration.cfg' (where mac=the mac address of the device). How would I implement this code so that I can open these files under these names and insert the information into it?
Thanks in advance,
Matt
Re: Need to open files under specific names through PHP
Posted: Fri Mar 14, 2008 12:51 pm
by miro_igov
Code: Select all
$fp = fopen('mac.cfg','w');
fwrite($fp, $the_info);
fclose($fp);
Same for the other file.
This sounds like VoIP phone configurator, something i worked on before. Are you working for TierZero ?
Re: Need to open files under specific names through PHP
Posted: Fri Mar 14, 2008 12:55 pm
by isgur513
Yes, this is for Polycom VOIP phone registration. Each phone needs two files to operate. Say I have a phone with MAC address of 0004f2151809, I need to create two files: (1)'0004f2151809.cfg' (2)'0004f2151809-registration.cfg'
How would I create a code to open these files for each individual polycom phone?
Thanks,
Matt
Re: Need to open files under specific names through PHP
Posted: Fri Mar 14, 2008 1:07 pm
by miro_igov

i knew it is the polycom devices. Actually the -registration.cfg is not important, however there are many details in the cfg file that you should have defined before to create these files.
First you should know all the mac addresses you have in the network and insert them in a HTML form, then submit it, process the entries in a loop and with fopen / fwrite / fclose generate file for each device.
You can set a variable and place the the configuration template inside. Take a look in the php manual for the function sprintf() to understand how to change the config values for every device.