php (split)

Everything todo with programming goes HERE.
User avatar
nelg
Average Program
Posts: 67
Joined: Wed Apr 25, 2012 12:18 am

php (split)

Post by nelg »

Moofie wrote:Lol nelg it's php, and there is an easier one for you to use if you've never seen any script like this before (http://wiki.armagetronad.org/index.php? ... ion_Server) :P. And I guess I'll have to edit the forum to make it use md5.
I program with php...
Heres an example of a script:
http://pastebin.com/f6dcUbdE

Yep it works in arma server! Hehe.
I can use kmdr scripts... but it would be more of a mess
Last edited by nelg on Sat Apr 28, 2012 3:23 pm, edited 3 times in total.
<!DOCTYPE UI><UI version=''3.0'' stdsetdef=>''1''
<class>Form1</class>
<widget class=>''Dialog''

User avatar
AI-team
Shutout Match Winner
Posts: 1021
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Setting up auth server

Post by AI-team »

that code is unreadable.
put it on pastebin and paste the link

edit: you should never ever use $GLOBALS
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 

Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Setting up auth server

Post by Moofie »

...what does that do... I didn't read it all, was too unreadable like AI said but... from what i saw does it just make people die when someone enters/renames, etc?

User avatar
nelg
Average Program
Posts: 67
Joined: Wed Apr 25, 2012 12:18 am

Re: Setting up auth server

Post by nelg »

Again: http://pastebin.com/f6dcUbdE
If a player enters it writes it in "levels.txt" on level 1
If a player left.. well that part doesn't madder exactly...
If a player renames it switches the configs (if not logged in)
Why cant i use @GOBALS? it works... heh?
Last edited by nelg on Sat Apr 28, 2012 3:23 pm, edited 1 time in total.
<!DOCTYPE UI><UI version=''3.0'' stdsetdef=>''1''
<class>Form1</class>
<widget class=>''Dialog''

User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1860
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Setting up auth server

Post by kyle »

Just because it works does not mean it is right.

For instance you can have a c program that takes some input and cuasses a bufferoverflow vulnerability. It may work but it is open to exploit.
Image

User avatar
AI-team
Shutout Match Winner
Posts: 1021
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Setting up auth server

Post by AI-team »

nelg wrote:Why cant i use @GOBALS? it works... heh?
I thought it was going to be deprecated in PHP 5.4 or later but I just checked and it turned out to be wrong :)
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 

chrisd
Round Winner
Posts: 314
Joined: Sat May 29, 2010 1:13 pm

Re: php (split)

Post by chrisd »

Good programming practice teaches us to not write everything in one big blob of code but to use functions with nice descriptive names instead....

User avatar
AI-team
Shutout Match Winner
Posts: 1021
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: php (split)

Post by AI-team »

chrisd wrote:Good programming practice teaches us to not write everything in one big blob of code but to use functions with nice descriptive names instead....
This might apply for "bigger" projects with more than one file, but I think for a simple script like this it's ok
(although I'd never use it myself)
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 

User avatar
Z-Man
God & Project Admin
Posts: 11365
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: php (split)

Post by Z-Man »

At least, one would write some comments and document the used variables.

User avatar
nelg
Average Program
Posts: 67
Joined: Wed Apr 25, 2012 12:18 am

Re: php (split)

Post by nelg »

its pretty easy for me to read... Altho i didn't bother to use comments in the PHP script. I guess the computer reads it just fine.

I just dont want to put comments... Also Loverboy put @GOBALS in his script!
<!DOCTYPE UI><UI version=''3.0'' stdsetdef=>''1''
<class>Form1</class>
<widget class=>''Dialog''

User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6709
Joined: Thu Dec 18, 2003 7:03 pm

Re: php (split)

Post by Tank Program »

Ah, what fun. Looking at that code reminds me of when I was doing lots of PHP programming.
Image

chrisd
Round Winner
Posts: 314
Joined: Sat May 29, 2010 1:13 pm

Re: php (split)

Post by chrisd »

Actually, I am not so sure if comments are really that great. Naresh Jain has a point http://blogs.agilefaqs.com/2009/08/19/a ... ents-evil/ . ("Also the first thing I do when I see some code is delete all the comments in it.") Also, comments can easily get outdated compared to the code that they supposed to apply to.

Martin Fowler has said a similar thing in http://martinfowler.com/bliki/ComposedRegex.html
This is easier to follow, but comments never quite satisfy me. Occasionally I've been accused of saying comments are bad, and that you shouldn't use them. This is wrong, in both senses. Comments are not bad - but there are often better options. I always try to write code that doesn't need comments, usually by good naming and structure. (I can't always succeed, but I feel I do more often than not.)
Of course, Donald Knuth goes completely to the other extreme with his literal programming, but that never really took off.

In schools they teach aspiring programmers to write comments but that is not really convincing. In general, one learns a lot of goofy things in schools. Fortunately, I never went to a school where the main purpose was to learn programming.

User avatar
Jonathan
A Brave Victim
Posts: 3392
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: php (split)

Post by Jonathan »

Code should document itself whenever possible. Use descriptive (but concise!) variable and function names and structure it cleanly. Then add comments to clarify anything that doesn't stand out, often a higher-level description of what would otherwise look like a mess of lower-level operations.
ˌɑrməˈɡɛˌtrɑn

User avatar
Lucifer
Project Developer & Local Moonshiner
Posts: 8610
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Re: php (split)

Post by Lucifer »

Jonathan wrote:Code should document itself whenever possible. Use descriptive (but concise!) variable and function names and structure it cleanly. Then add comments to clarify anything that doesn't stand out, often a higher-level description of what would otherwise look like a mess of lower-level operations.
+1

I use comments to say what's happening in a section of code, and for apidocs (doxygen rocks). I don't bother to say what the variables are because the code does, and as Jonathan points out, if you use reasonable variable names, you don't have to comment.

"Programmers don't like repeating themselves, but they do like to be double-quoted." --Z-man
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden

User avatar
Z-Man
God & Project Admin
Posts: 11365
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: php (split)

Post by Z-Man »

Jonathan wrote:Code should document itself whenever possible. Use descriptive (but concise!) variable and function names and structure it cleanly.
His code is none of that. Hence the call for comments. When I read the line

Code: Select all

$Player_Ladder_Name[2] += 50;
I lost all interest in trying to unravel the rest.

Post Reply