Jump to content

Import details from file


strategos

Recommended Posts

Hello, I am new to PHP and am trying to make a script that will ftp into the server via a cron of every hour or so and save the data to a mysql table. The first step is to draw variables out of information in the file via ftp. Its a ban list for a game server I run.

 

How could I get php to single out the ban reason, admin, etc.

 

the looks like this

 

"STEAM_0:0:42741441"	
{
"name"	"good mom"
"unban"	"0"
"time"	"1329161245"
"admin"	"(Console)"
"reason"	"no more trolling for you"
}
"STEAM_0:1:40563669"	
{
"unban"	"0"
"admin"	"Headcrap(STEAM_0:1:42287608)"
"time"	"1332855999"
"reason"	""
}
"STEAM_0:1:17693550"	
{
"name"	"ʎɖɑɱ"
"time"	"1323055427"
"modified_time"	"1323221308"
"unban"	"0"
"modified_admin"	"Strategos(STEAM_0:0:26662109)"
"admin"	"Strategos(STEAM_0:0:26662109)"
"reason"	"And so died the trolling"
}

 

Example:

<?php
$bannedid = "STEAM_0:0:42741441";
$bannedby "(console)";
// and so on
?>

Link to comment
Share on other sites

Hello !!!

 

I can help you but sorry about my English... Because, I'm learning :(      ( You're new in PHP / I'm new in English )

 

For your question...

Your data is in the file ???

Or your data is in the MySQL ???

 

Where is the ban data ?

 

 

 

Link to comment
Share on other sites

You should really focus on getting the information indo a much more managebale format.  There is no consistancy in that file layout, so getting something to work on that test data may not help on the actual full file, or on future data.

 

First find a consistant format to store the information in and then worry about coding a script to extract it (I suggest xml if databases arn't your thing).

Link to comment
Share on other sites

Hello !!!

 

I can help you but sorry about my English... Because, I'm learning :(      ( You're new in PHP / I'm new in English )

 

For your question...

Your data is in the file ???

Or your data is in the MySQL ???

 

Where is the ban data ?

 

The ban data is the first example where the code is not highlighted. It is in a .txt file on a remote server. I want to import that data.

 

I can't change the format of the ban file, because that's how the administration system is designed to interpret it. I want to save key details from the data to a mysql table, but right now I just want to focus on being able to capture the data.

Link to comment
Share on other sites

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.