Click to See Complete Forum and Search --> : my admin page code


tuf-web.co.uk
09-30-2003, 03:21 AM
heres my admin page which i have updated quite a few times

i know i should add some comments in, but i was only a beginner when i started this and i havent the time to run through the whole code again to comment it (though i will later;))

anyways here it is, say your worst about it

but dont be mean :(

clicky here (http://www.theutherfish.com/admin.phps)

comms :)

LordShryku
09-30-2003, 01:33 PM
Well, more personal opinions than "coding standards", but my two cents:

1) The multiple echo statements in you functions could be turned into one echo statement. This would help a bit with dalecosp's need to get his HTML source formatted right. And it's just a bit easier/prettier.

2) The long if/elseif statements should be made into switch statements. Prime example...
if ($_GET[mode] == 'news') {
$admin = "New News";
}
else if ($_GET[mode] == 'edit') {
$admin = "Add/Change Edit";
}
else if ($_GET[mode] == 'joke') {
$admin = "New Joke";
}
else if ($_GET[mode] == 'cheats') {
$admin = "New Cheat";
}
else if ($_GET[mode] == 'poll') {
$admin = "New Poll";
}
else if ($_GET[mode] == 'users') {
$admin = "Users Admin";
}
else if ($_GET[mode] == 'version') {
$admin = "Version History";
}
else if ($_GET[mode] == 'counter') {
$admin = "Counter";
}
else if ($_GET[mode] == 'enews') {
$admin = "Edit News";
}
else if ($_GET[mode] == 'guest') {
$admin = "Guestbook";
}
else if ($_GET[mode] == 'blog') {
$admin = "Blogs";
}

// made into a switch statement...

switch($_GET[mode]) {
case "news":
$admin = "New News";
break;

case "edit":
$admin = "Add/Change Edit";
break;

case "joke":
$admin = "New Joke";
break;

case "cheats":
$admin = "New Cheat";
break;

case "poll":
$admin = "New Poll";
break;

case "users":
$admin = "Users Admin";
break;

case "version":
$admin = "Version History";
break;

case "counter":
$admin = "Counter";
break;

case "enews":
$admin = "Edit News";
break;

case "guest":
$admin = "Guestbook";
break;

case "blog":
$admin = "Blogs";
break;

default:
break;
}
planetsim did a good article on this that was made sticky on one of the forums. Can;t remember which one, but I'll link it once I find it.

Didn't get through it all, but everything else I saw looks pretty nice. GJ :)

jstarkey
09-30-2003, 01:49 PM
You also have some array keys that aren't quoted. It's generally a good idea to do so in order to avoid stepping on any keys names that may become reserved in the future.

LordShryku
09-30-2003, 03:02 PM
Here's that link....

http://www.phpbuilder.com/board/showthread.php?s=&threadid=10245251&perpage=15&pagenumber=2

Sxooter
09-30-2003, 03:06 PM
Originally posted by jstarkey
You also have some array keys that aren't quoted. It's generally a good idea to do so in order to avoid stepping on any keys names that may become reserved in the future.

Note that as of PHP 4.3.something the use of unquoted identifiers in arrays will result in a warning during run time.

Moonglobe
10-01-2003, 02:29 AM
actually as of a long time ago, on any setup running error_reporting(E_ALL) :)

The Chancer
10-01-2003, 08:36 AM
Doesn't it just give a notice rather than a warning, and let you know that is assumed it to be $info['var' ] ? (Just being picky...)

Sxooter
10-01-2003, 10:45 AM
Originally posted by The Chancer
Doesn't it just give a notice rather than a warning, and let you know that is assumed it to be $info['var' ] ? (Just being picky...)

Yep. Sorry, hadn't checked the actual text in a while.

Moonglobe
10-01-2003, 10:47 AM
Originally posted by The Chancer
Doesn't it just give a notice rather than a warning, and let you know that is assumed it to be $info['var' ] ? (Just being picky...) yup it suuuuure does.

The Chancer
10-02-2003, 05:57 AM
Oh well - was my own fault for updating my PHP and finding that loads of my old code fell into that trap...

After seeing it for the n000'th time, I had to say something... :D