Results 1 to 3 of 3

Thread: [Resolved]Editing a .ini file

  1. #1

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Resolved [Resolved]Editing a .ini file

    Hey all

    Im trying to edit an ini file automaticly,example:

    Users fill in username($user)
    Users fill in password($passwd)
    Users fill in domain name($domain)

    Now I want to add those values to an ini file like this

    [$user]
    Login=$user
    Pass=$passwd
    AllowChangePassword=1
    Home-Ip=-= All IP Homes =-
    RelativePath=1
    TimeOut=600
    MaxConPerIp=1
    MaxUsers=0
    RatioMethod=0
    RatioUp=1
    RatioDown=1
    RatioCredit=0
    MaxSpeedRcv=512
    MaxSpeedSnd=512
    QuotaCurrent=0
    QuotaMax=0
    EnableSITECHAT=1
    EnableSITEWHO=1
    Dir0=D:\Server\WAMP\www\Users\$domain
    Attr0=RWDAMLSK


    Is there an easy way to do this?
    I am not an PHP expert, I barely know the syntax, But I know I would need to open the file for writing and after that for reading or something of the likes right?

    Could someone give me a code snippet?

    Thanks a bunch!
    Last edited by Neo-dark; Jun 29th, 2007 at 07:29 AM. Reason: Solved
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Editing a .ini file

    The most straightforward way is to open the file for appending and write to it using fwrite().

    PHP Code:
    $file fopen($filename'a'):

    fwrite($file"[{$user}]
    Login=
    {$user}
    Pass=
    {$passwd}
    AllowChangePassword=1
    Home-Ip=-= All IP Homes =-
    RelativePath=1
    TimeOut=600
    MaxConPerIp=1
    MaxUsers=0
    RatioMethod=0
    RatioUp=1
    RatioDown=1
    RatioCredit=0
    MaxSpeedRcv=512
    MaxSpeedSnd=512
    QuotaCurrent=0
    QuotaMax=0
    EnableSITECHAT=1
    EnableSITEWHO=1
    Dir0=D:\\Server\\WAMP\\www\\Users\\
    {$domain}
    Attr0=RWDAMLSK"
    );

    fclose($file); 
    A more sophisticated and comprehensive approach to managing INI files would be to use the PEAR::Config package.

  3. #3

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Resolved [Solved]Re: Editing a .ini file

    Thank you ! It works great, I needed to add some extra spaces and change a few things, This is the finished code for anyone using BPFTPServer and wanting to add users by using php:

    PHP Code:
    <?php
    If(file_exists("D:\\Server\\WAMP\\www\\Users\\{$domain}")) 
    {
    echo(
    "Problem with domain name Please select an another domain name");
    exit();
    }
    else
    {
    mkdir("D:\\Server\\WAMP\\www\\Users\\{$domain}"0700);
    }
    $filename "D:\\Server\\FTP Server\\users.ini";
    $file fopen($filename'a');

    fwrite($file"[{$user}]
    Login=
    {$user}
    Pass=
    {$passwd}
    AllowChangePassword=1
    Home-Ip=-= All IP Homes =-
    RelativePath=1
    TimeOut=600
    MaxConPerIp=1
    MaxUsers=0
    RatioMethod=0
    RatioUp=1
    RatioDown=1
    RatioCredit=0
    MaxSpeedRcv=512
    MaxSpeedSnd=512
    QuotaCurrent=0
    QuotaMax=0
    EnableSITECHAT=1
    EnableSITEWHO=1
    Dir0=D:\\Server\\WAMP\\www\\Users\\
    {$domain}
    Attr0=RWDAMLSK
    "
    );

    fclose($file);
    ?>

    Thank you for registering at cyberdrain networks!
    Your account will be activated within 30 minutes.
    If you would like a database/Cyberdrain.com Email adress please mail [email protected]
    If you have any problems at all feel free to contact us!
    The place its used is http://www.cyberdrain.com/account.php .

    Thank you again!
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width