News index / Submit files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dragonsimoto
Forum Newbie
Posts: 2
Joined: Sat Apr 05, 2003 1:05 pm
Location: USA
Contact:

News index / Submit files

Post by Dragonsimoto »

I have had problems thinking how i would go about this.

I want to have an index that fgetss() so many bytes(undecided) of the 5 latest news submits in the articles directory. And i would want the article to have a picture that would go with the article on the index as well.

On the submit page, i would allow uploading to /articles, of .jpg and .html articles, which would be parsed with index's fgetss....

The problem i am thinking of is How would i go about keeping track of the latest five submits? How would i know the .jpg and .html file to load on index.php dynamically? I dont want to use a DB (MySQL) for this site since it is for a friend, and he wont have access to MySQL.

THanks alot guys,
Clark Askam Dragonsimoto
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

If the files are named with a timestamp (or any sequential number) you could use readdir() to find the latest filenames - perhaps by building an array of filenames and then doing a sort().

You could even manage it manually by ftp (saves some script overhead): ie only ever keep the latest five files in a "latest" folder.

Could name jpg's the same as the file for easy linking.

Create a single html template and include it in your script, echo'ing out (in the template) <?php echo $text; ?> and <img src="path/to/file/<?php echo $filename; ?>.jpg">.

Just some basic ideas - have to admit I'm more used to working with mysql than with files.
Dragonsimoto
Forum Newbie
Posts: 2
Joined: Sat Apr 05, 2003 1:05 pm
Location: USA
Contact:

Post by Dragonsimoto »

Thanks,

I thought about rotating the files out of a "latest" directory, then to a "old" one.

I will probably do that, then i wont have to deal with a news posting script...Just a readdir() then take whatever is there and fgetss(somenum) for each html file. then use some variable control like you stated for the jpg's.

Thanks alot,
Dragon/Clark
Post Reply