Follow us on Twitter!
One mans freedom fighter, another's terrorist.
Wednesday, April 16, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 21
Guests Online: 17
Members Online: 4

Registered Members: 82811
Newest Member: IsaiahBowman
Latest Articles
View Thread

HellBound Hackers | Computer General | Webmasters Lounge

Author

PHP News Updater


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-06-07 01:39
Okay, so, I would like to create a script that would allow people to update the news section of my site from within the site in an admin section. I'm aware that this would involve fopen() and fwrite() and all that, and I know how those work.

However, what if I don't want to write to the top/bottom of the file?
Say I have a header and I want to insert the submitted news under information already in the file?
Is there any way I can fwrite() to a point within the file rather then to the top or the bottom?

Thanks in advance.


Author

RE: PHP News Updater


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-06-07 01:50
I wrote a thread on this yesturday, but I would use SQL, in one column I would use a date function to retrieve the date and time, and then add that data to a row, with the name of the news article in another, and then use a select statement with where to echo them in chronological order. But hang on, ill find my other fuller post that explains it with a bit more detail.
Author

RE: PHP News Updater


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 12-06-07 06:12
Definitely use an SQL backend instead of flat files. But, what people often do wrong is they forget about caching.

They create a CMS which can post news, and such stuff. When someone loads the main page perhaps it does something like 20 SQL requests, but their last news post was 3 months ago. It's a total waste of resources. Ideally you'd use HTTP's Last-modified header to tell the client to use the cached version. That could save resources. If the site is actually very popular and perhaps you're posting a few news posts per week, maybe even one per day then you definitely need to find ways to save resources. In that case you should look into using memcached and the memcache extension for PHP and store the HTML for the front page in memory which saves you from those very expensive SQL commands.

Back to the first point though, definitely use SQL over files, it's much cleaner that way.