...

View Full Version : search an array



GO ILLINI
06-22-2006, 12:19 AM
config.cfg


stuff here stuff here stuff here
// [EDITOR]
// User name Joe
joe@lotofafa.com
stuff here stuff here stuff here
// [EDITOR]
// User name hank
hank@lotofafa.com
// this is some other stuff
stuff here stuff here stuff here

What I want is a script that can search through that file, find // [EDITOR] and the next two lines, and put that into an array. So in that example you would end up with two arrays, with three vars each.
I have searched and not really found what i needed...

The one and only,
ILLINI

Nicklas
06-22-2006, 01:18 AM
Something like this?

preg_match_all('/\/\/ \[.*?\]|\/\/ User name .*?(?=\n)|[-a-z0-9_\.]+@[-a-z0-9_\.]+\.[a-z]{2,6}/is', $string, $matches);
$matches = (array_chunk($matches[0], 3));

print_r($matches);

Not because I have anything to do with it, but isnīt it enough with just the user name and the e-mail? like this:

preg_match_all('/(?<=name ).*?(?=\n)|[-a-z0-9_\.]+@[-a-z0-9_\.]+\.[a-z]{2,6}/is', $string, $matches);
$matches = (array_chunk($matches[0], 2));

print_r($matches);

GO ILLINI
06-22-2006, 03:44 AM
Well i could do that, but I dont want them to edit it by hand and change something. and it says dont edit anything under the [EDITOR] line.
I might just do the 2 line one though...


After testing, it prints out " Array ( [0] => Array ( [0] => // [EDITOR] [1] => // [EDITOR] ) )"

marek_mar
06-22-2006, 10:50 AM
parse_ini_file() (http://www.php.net/manual/en/function.parse-ini-file.php)

GO ILLINI
06-22-2006, 06:57 PM
I get an error where the |TAG|=>GO ILLINI line is.

//
// Add your IP's Steam addresses, Names and Passwords
// in this file for admins
//
//
// e.g STEAM_0:0:21233123
// 213.44.33.47
//
// ADDING FLAGS MEANS YOUR ARE STOPPING ADMINS FROM USING
// THOSE OPTIONS UNLESS YOU HAVE mani_reverse_admin_flags set to 1
// in your autoexec.cfg
//
// Restriction options are :-
//
// k = restrict admin from kicking players
// r = restrict admin from executing rcon commands via ma_rcon
// q = restrict admin from executing rcon commands from the menu
// e = restrict admin from the adminexplode command
// m = restrict admin from slaying players
// b = restrict admin from banning players
// s = restrict admin from running ma_say
// o = restrict admin from running ma_chat
// a = restrict admin from running ma_psay
// c = restrict admin from changing maps
// p = restrict admin from playing sounds
// w = restrict admin from restricting weapons
// z = restrict admin from plug-in config menu
// x = restrict admin from running admincexec commands
// y = restrict admin from running admincexec from the menu
// i = restrict admin from running blind commands
// l = restrict admin from running slap commands
// f = restrict admin from running freeze commands
// t = restrict admin from running teleport commands
// d = restrict admin from running drug commands
// g = restrict admin from running ma_teamswap and ma_balance commands
// j = restrict admin from running gimp commands
// R = restrict admin from running rcon vote
// v = restrict admin from running random vote map
// V = restrict admin from running vote map
// Q = restrict admin from running question vote
// C = restrict admin from running Cancel Vote
// A = restrict admin from being able to accept/refuse a vote they started
// B = restrict admin from running a menu rcon vote
// D = restrict admin from running a question menu vote
// E = restrict admin from using ma_rates
// F = restrict admin from running burn commands
// G = restrict admin from running noclip command
// H = restrict admin from running ma_war command
// I = restrict admin from running ma_mute command
// J = restrict admin from resetting all the player ranks
// K = restrict admin from setting player cash
// L = restrict admin from using rconsay commands setup as type R in commandlist.txt
// M = restrict admin from having custom skins to choose
// N = restrict admin from being able to set a players skin
// O = restrict admin from running ma_dropc4 command
// P = restrict admin from running ma_setadminflag command
// T = restrict admin from running ma_timebomb command
// U = restrict admin from running ma_firebomb command
// W = restrict admin from running ma_freezebomb command
// X = restrict admin from running ma_sethealth and derived commands
// Y = restrict admin from running ma_beacon command
// S = restrict admin from running ma_setcolour or ma_setcolor
// Z = restrict admin from running ma_give and ma_giveammo
// p = restrict admin from running ma_spray
//
// An example would be if you wanted to prevent admin
// with steam id STEAM_0:0:2388333
// from being able to play sounds and rcon command
//
// do not delete the next line
// |TAG|=>GO ILLINI
STEAM_0:1:6207481
// STEAM_0:0:2388333 rp // Admin can't rcon and play sound !!
//
// Another example
// STEAM_0:0:3389333 kmc // Admin can't kick, slay or change maps
//
//
// You can also use admin groups instead of flags, you setup admin groups
// in the admingroups.txt file then use them in this file.
// For example if you setup a group called "Clan Member" and "Kick Only" you would set it per
// player like this:-
//
// STEAM_0:0:1234234 Clan Member // Fred
// STEAM_0:0:234884 Kick Only // Jim
//
//
// If you wanted an admin to be created by IP Address you
// set your entry to be in the format
//
// ;IP Address flag
//
// Example
//
// ;213.133.76.58 rp // Admin can't rcon and play sound !!
// ;113.124.36.2 kmc // Admin can't kick, slay or change maps
//
// If you want to have an Admin created by both steam ID and IP address you
// use the format STEAM_ID;IP_ADDRESS flags
//
// Example
//
// STEAM_0:1:877489;231.192.67.5 rp // Admin can't rcon and play sound !!
//
// IMPORTANT NOTES !!!!
//
// If you only use an IP Address, the character ';' MUST be directly in
// front of it.
//
// There must be a space between the steam ID/IP Address and restriction flags
// or the plug-in will assume that it is part of the Steam ID/IP Address
//
// Another alternative to using a steam id is a name and password
//
// The format of this is ;;"name";password flags
//
// For example I would use
//
// ;;"Mani";maniadminplugin rp // Admin can't rcon or playsound
//
// In order to use the password, put
//
// setinfo _password mypassword
//
// in your config.cfg file in your client installation.
//
//
// [EDITOR]
// Admin adam
steamid all

// [EDITOR]
// Admin adam
steamid all


How would I get the parser to just get the sections with [EDITOR]?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum