473,320 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PHP flat file comment engine -- Design

RedSon
5,000 Expert 4TB
Greetings all,

The host I use does not let me have mysql so I am going to need to write a comment engine that uses flat files. Unless of course there are commenting solutions already available that do not use mysql.

So now lets talk about how this is going to work... (your input is appreciated). I think we are going to need a couple things, an admin panel and the UI. The user is going to need a UI, so we will have a few fields, probably name, email address, comment area, and a captcha. Captcha is needed to prevent spam. The user will fill out the form, (name, comment and captcha will be required) and the comment will be stored in a file somewhere. Now this is where it gets a little tricky because I'm not a web programmer, the comment gets stored in a file, the file will need to have some kind of identifier that maps it to the page that is being commented on. Then the rendering php will grab the comment information in the file and reload the page with the comments rendered at the bottom.

How is that for a preliminary idea. Anyone have any thoughts on important cases that have not been considered? We haven't looked at the admin side of this yet but I want to get one side working before I start in on the other.
Aug 16 '07 #1
12 4762
pbmods
5,821 Expert 4TB
Heya, RedSon.

You have a couple of options. You could create a separate comments file for each page. Alternatively, you could prefix each comment with the name of the page.

There's advantages and disadvantages to each method.

Using separate files is great for viewing comments on a per-page basis, but it isn't quite so good at viewing comments for more than one page (such as, "show me the 5 most recent comments").

Using one big file makes it more of a pain to view comments per-page, but aggregate stuff is much easier.

I suppose you could create 'index' files by assigning each comment a unique identifier and then creating one big file to hold all of the comments, and then index files that list id numbers per page....

This all depends, of course, on whether you're getting paid per project or per hour :P
Aug 16 '07 #2
RedSon
5,000 Expert 4TB
Heya, RedSon.

You have a couple of options. You could create a separate comments file for each page. Alternatively, you could prefix each comment with the name of the page.

There's advantages and disadvantages to each method.

Using separate files is great for viewing comments on a per-page basis, but it isn't quite so good at viewing comments for more than one page (such as, "show me the 5 most recent comments").

Using one big file makes it more of a pain to view comments per-page, but aggregate stuff is much easier.

I suppose you could create 'index' files by assigning each comment a unique identifier and then creating one big file to hold all of the comments, and then index files that list id numbers per page....

This all depends, of course, on whether you're getting paid per project or per hour :P
Heh, this is strictly for fun, but I like your idea about putting them in one file. Maybe I can have a sorted tree then it would grow slowly be easiy to index and have easy ways to aggregate data. Not sure how to work that...
Aug 16 '07 #3
pbmods
5,821 Expert 4TB
Assuming that you make '|' characters illegal in comments, you could do something like this:
Expand|Select|Wrap|Line Numbers
  1. comment_id|page_name|comment_poster|comment_text
  2. 1|main.php|William Scott|love the site!
  3. 2|main.php|Scott Williams|I HATE THIS SITE!
  4. 3|main.php|William Scott|o yeah?  well ur dumb!!1!1!
  5. 4|home.php|Mark|(they'll never find me)
  6.  
And so on.

Then you could create a couple of index files. For example,main.php.idx would contain:
Expand|Select|Wrap|Line Numbers
  1. 1
  2. 2
  3. 3
  4.  
And then if you wanted to get REALLY intricate, you could create a williamscott.idx file:
Expand|Select|Wrap|Line Numbers
  1. 1
  2. 3
  3.  
You can use file() and explode() to turn your flat files into arrays.
Aug 16 '07 #4
pbmods
5,821 Expert 4TB
Of course, you could also use var_export() and just output PHP code to create an array and be done with it....
Aug 16 '07 #5
jx2
228 100+
for fun u said ? ;-)

i had exactly the same problem once
i wrote(for fun) the database engine in php :-) yeah!!
it was faster then mysql :-) yeah:-)

so listen to me:-)

1. we need to know what you going to do with this data later
2. you need search engine?
3. how many treads you expect?(fix number?)
4. how many posts per tread?
5. how long is each coment?

for know i can tell you if i were you i would use 2 files
1 for adres user name and so on
2 for coments

file one fixed lenght
lets say tread name 30, user name 30, adress 70 and position of the coment in 2th file about 10(140toghether) fixed lengh help to serach throu data

i would use 3th file as an index file for treads (that depends how many treads you going to have)
you can also try to store adres of the last coment in the tread so u can easly locate the previousecoment in the same tread

okey
what do you think?

lol
i know ...
Aug 17 '07 #6
RedSon
5,000 Expert 4TB
for fun u said ? ;-)

i had exactly the same problem once
i wrote(for fun) the database engine in php :-) yeah!!
it was faster then mysql :-) yeah:-)

so listen to me:-)

1. we need to know what you going to do with this data later
2. you need search engine?
3. how many treads you expect?(fix number?)
4. how many posts per tread?
5. how long is each coment?

for know i can tell you if i were you i would use 2 files
1 for adres user name and so on
2 for coments

file one fixed lenght
lets say tread name 30, user name 30, adress 70 and position of the coment in 2th file about 10(140toghether) fixed lengh help to serach throu data

i would use 3th file as an index file for treads (that depends how many treads you going to have)
you can also try to store adres of the last coment in the tread so u can easly locate the previousecoment in the same tread

okey
what do you think?

lol
i know ...
Yes all good design ideas. How did your code work? Are you still using it in production? Maybe you want to share some of the harder parts?
Aug 17 '07 #7
RedSon
5,000 Expert 4TB
I also found a website that will give you a free mysql database, so I think I might try that solution with one of the comment engines I foudn that need sql databases
Aug 17 '07 #8
jx2
228 100+
I also found a website that will give you a free mysql database, so I think I might try that solution with one of the comment engines I foudn that need sql databases
yeah mysql is cool :-) if you can use it it save a lot of your time

the thing i did was bit different it collected personal detail (fixed size 1000 ppl) was simple and fast really fast.

how big your project going to be?
Aug 17 '07 #9
RedSon
5,000 Expert 4TB
yeah mysql is cool :-) if you can use it it save a lot of your time

the thing i did was bit different it collected personal detail (fixed size 1000 ppl) was simple and fast really fast.

how big your project going to be?
Not sure, it is so that users can comment on pages of the site. Kind of like a blog but more like a feedback type of thing then anything else.
Aug 17 '07 #10
jx2
228 100+
then i wouldnt bother with database
just uuse regular expression which add coments to the recent page

something like ereg_replace("</body>","$newComent</body>",$html);
then replase old page with this one

should work fine( as long as there is no to many coments on one page)

regards
jx2
Aug 17 '07 #11
pbmods
5,821 Expert 4TB
something like ereg_replace("</body>","$newComent</body>",$html);
then replase old page with this one
Or better yet, just use str_replace(), since you don't need the regular expression overhead ~_^
Aug 17 '07 #12
jx2
228 100+
Or better yet, just use str_replace(), since you don't need the regular expression overhead ~_^
yeah yo're right :-) that would make it the simpiest data base i've ever seen :-)
Aug 17 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steve Jenkins | last post by:
Hi, Wonder if someone could help me. I'm looking for a PHP/MySQL based search engine that can search flat files i.e. build it's own index from flat files. I've used Apaches' Lucene before...
1
by: Tim Fierro | last post by:
Hello, I have had many years using flat file databases (File Express from way back) but am now at a company where a relational database is needed and would carry us into the future. Since I...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
4
by: Jacob Lyles | last post by:
Hello All, I'm trying to make a comment section on my website. However, I don't want to set up a MYSQL database to do so because I want to make it really simple, just a form that asks for their...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
5
by: Gorilla3D | last post by:
I've writing my own flat file database.. well table-based pure php code, PhpSimpleDb but I was looking into some bench marking so was wonder if anyone knew any other flat-file php db's out there. ...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.