Comments/Critism please
I've been messing around with PHP quite a bit, and I decided that as sort of, a learning experience, I would try and construct my own forums from scratch. Well, I basically succeded, they work, nothing crazy fancy like YaBBSE, vB or anything, but pretty good considering I've been using PHP for about a year or two and I'm 16 going on 17.
If anyone wants to dig through my code, most of it isn't commented unfortunatly due to my own lazyness, but any comments at all are very welcome, as this wouldn't quite be a learning experience without being 'graded' on it, now would it?
You can look at the source here:
http://www.sonofthor.com/fc/pro/forums/source.php
Or you can download all the files here (I've been told my site's running quite slow):
http://www.sonofthor.com/fc/pro/forums/download.php
There are a couple things that I've started working on but havn't done anything quite good with, such as the install script.
But again, please, if you have the time please give me any feedback.
[ FinalCreations ]
Abhishek Reddy posted this at 03:33 — 3rd December 2002.
He has: 3,348 posts
Joined: Jul 2001
Wow... not too bad.
Any chance we could see a working sample? And also your db structures?
Anonymous posted this at 04:36 — 3rd December 2002.
They have: 5,633 posts
Joined: Jan 1970
looks good to me.
Mark Hensler posted this at 06:37 — 3rd December 2002.
He has: 4,048 posts
Joined: Aug 2000
CODE:
First thing I noticed was that it's not compatable with PHP <4.1.0. You have used $_SESSIONS, which was added in 4.1.0.
From what I can see, it looks like you stuck with a naming scheme for your fields: ID_post, ID_thread, ID_forum -- a big help in large scale projects.
You've made use of require_once(). Better to use that when possible rather than just sticking require() everywhere. This prevents unnecessary code.
You avoided the short open tags. Helps with compatability.
You seem to vary in your code format. I always encourage people to code to the PEAR coding standards.
Another thing I like to avoid is having an echo() or print() statment span multiple lines..
I see you've used the heredoc syntax in your source.php file. Very nice. I think that is often over-looked and under-used. But I don't understand the purpose of fwriting all the files.
For the section of install.php that writes the files, you should use:
fopen (filename", "w+");
This will create the file if it does not already exist.
DATABASE:
Index the following fields:
_cats.ID_order
_forums.ID_cat, _forums.ID_order
_replies.ID_thread, _replies.ID_forum, _replies.ID_poster, _replies.postdate
_threads.ID_forum, _threads.firstpost, _threads.ID_lastpost
_user.username, _user.password
Indexing makes sorting and joining on indexed fields faster.
I'm assuming you'll be searching for _user.username and _user.password when the user logs on. If not, then they don't need to be indexed.
You're forum moderators should be linked with a foreign key: __user.ID_user
Good job!
For extra credit, try adding smilie capabilities to your posts.
Mark Hensler
If there is no answer on Google, then there is no question.
FinalMjolnir666 posted this at 20:00 — 3rd December 2002.
They have: 45 posts
Joined: Feb 2002
Just two quickies as I just got home from school and I need food/drink and stuff before I get to work on anything.
Could you look through and give me examples on how I could make the code more OO? I think my main problem with OO is I'm not sure when to use it. My dad, who's into C++/# for his work, tried explaining it to me before, but I can't think of any good uses for it, so I'm probably just using the wrong frame of mind, so if you could point out a couple things I could use it for, that would probably help put me on track.
And the other thing, that PEAR coding standards thing, is that manual avaliable for download, if so could you download it and email it to me at [email protected]? Because my internet is being dumb and says PHP.net isn't avaliable, same with anitrade.net, infoceptor.com even though I know the sites are up because of various other people saying so. Just one of the jolly things about my computer.
Thanks.
[ FinalCreations ]
Mark Hensler posted this at 21:58 — 3rd December 2002.
He has: 4,048 posts
Joined: Aug 2000
It has links for downloading the manual in several formats and languages, but they all seem to be broken links.
I've not found many places to use OO myself. I tend to stay away from it because if it's not done properly, you can waste memory. This is because every instance of an object reserves enough memory for the entire object, even if you only plan to use a small part of the object.
Mark Hensler
If there is no answer on Google, then there is no question.
FinalMjolnir666 posted this at 17:38 — 4th December 2002.
They have: 45 posts
Joined: Feb 2002
Okay, well.
About the fwriting, the script actually makes all the files for you, similiar to YABBSE. So it opens or creates the files, then writes to then the source, which is contained in the source.php file.
As for the database, making them indexed, do you mean like with phpMyAdmin, make the actual feilds indexed?
[ FinalCreations ]
FinalMjolnir666 posted this at 21:46 — 7th December 2002.
They have: 45 posts
Joined: Feb 2002
Made completely new forums for my site.
And there's a little 'View Source' thing at the bottom so you can see the code that way.
FinalCreations Forums
There's smilies too.
[ FinalCreations ]
Renegade posted this at 23:59 — 7th December 2002.
He has: 3,022 posts
Joined: Oct 2002
yeah, i'll like to c a wroking sample too
Renegade posted this at 00:00 — 8th December 2002.
He has: 3,022 posts
Joined: Oct 2002
o there it is didn't c the link ... duh!!! ...
Mark Hensler posted this at 04:29 — 9th December 2002.
He has: 4,048 posts
Joined: Aug 2000
Yes.
Mark Hensler
If there is no answer on Google, then there is no question.
FinalMjolnir666 posted this at 23:15 — 9th December 2002.
They have: 45 posts
Joined: Feb 2002
Okay, so doing that will just make it query faster?
Is there a techinical explanation that I would care about/understand at all?
Suzanne posted this at 01:16 — 10th December 2002.
She has: 5,507 posts
Joined: Feb 2000
http://www.your-name-here.co.uk/mysql/indexing.html
I was interested myself, so a quick boo around Google netted me (get it? netted!) the link above which explains it nicely, I think.
Wil posted this at 11:23 — 10th December 2002.
They have: 601 posts
Joined: Nov 2001
Be careful with your indexes. Simply indexing all your databases can have an adverse effect in many setups.
Suzanne posted this at 15:16 — 10th December 2002.
She has: 5,507 posts
Joined: Feb 2000
Can you explain that a bit for me, Wil? I'm learning about databases slowly -- what are the issues, and how can I avoid problems?
pfeiffdog posted this at 18:40 — 18th December 2002.
They have: 25 posts
Joined: Dec 2002
I think you have created a nice foundation to build on. It appears that you are really trying to learn this on your own which I am all for. Keep up the good work and good luck.
At UcanfindFreelancers.com you will receive custom programming and webdesign at the price you choose to pay. Sign up now for free and post your project. http://www.ucanfindfreelancers.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.