Jump to content

Recommended Posts

Hi, I am relatively new to PHP, and I am making a php script that will FTP into a server and add a donator's ID to a text file.

 

However, I need it to check and see if the user is already listed under a usergroup in that file, and if so, remove those lines of text. Here's an example of what values in the file look like.

 

Basically, I don't know how I could compare the contents of the file and delete it or replace parts of it when necessary :(

 

"STEAM_0:0:33358541"	
{
"deny"	
{
}
"group"	"moderator"
"name"	"TR Cpt. K. Reese"
"allow"	
{
}
}

 

Also, notice the "deny"{} and "allow"{} These are used for storing special commands that you allow or disallow the user to have in a game. How would i get a PHP script to ignore that...

This uses STEAM's framework for userids. All help is appreciated!!

 

Thanks! :)

Your question is common that's why the first answer (set of answers) would be common also.

 

First, you have to create a structure inside PHP which is equivalent to your data. This is the main. You may use class(es) to do it.

 

Second, about data. In your example "allow" is related to "TR Cpt. K. Reese" from "moderator" group - is it true? What about "deny" - is it related to this or other user?

And what about data concerning to other users? How are they structured?

 

 

My question is in regards to using FTP to update the file, instead of a local file or a database.

 

with a ftp u will have to make a remote connection, grab the file, update the file, and upload it back.

 

Even a php script on the ftp server would be better utilized.

This is for a donation mod for a game server where as the only ports I can use are 21 and the game port. I can't upload php files directly to the sv and they couldn't be accessed anyways. The deny and allow in the example are relative to the user. It stores commands that are explicity allowed or denied to the user therefore, they change per user.

This is just a suggestion but I do believe it may point you in the right direction.

 

After you download the file from your FTP:

 

$lines = file('your_text_file.txt');

// Loop through our array
foreach ($lines as $line_num => $line) {
    
//use a ereg to search for a certain user/setting -- replace if necessary

}

 

 

I am not really familiar with ereg or I would try to help more.. maybe someone else can build on this if it will get you going to the right place.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.