Current location: Hot Scripts Forums » Programming Languages » PHP » VERY simple weblog script?


VERY simple weblog script?

Reply
  #1 (permalink)  
Old 02-02-04, 04:49 AM
mixermanic mixermanic is offline
Newbie Coder
 
Join Date: Aug 2003
Location: London UK
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
VERY simple weblog script?

Hi,

I would like to put a "news" page on my site, and a "latest news" section on my homepage (with the first 30 or so words of the 4 most recent news items, then a "more...." link to the main article).

Ideally the news will be read from a directory of text files (numbered - like 1.inc, 2.inc, 3.inc, 4.inc, 5.inc etc... with the highest number being the newest news item). I want to be able to code the news items myself (i.e. no "admin" interface - I just want to do the text file and dump it in the directory).

Would this be relatively simple to do in PHP? I have just converted the rest of my site, and a a *little* experience with the language... always willing to learn though!!

All the weblog scripts I have come across as freeware seem to do far too much - comments, smilies, admin interface etc.

Thanks, (and happy monday...!)

Martin
Reply With Quote
  #2 (permalink)  
Old 02-02-04, 08:37 AM
jewellgr jewellgr is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Michigan USA
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Martin,

Here is a start:

PHP Code:

<?PHP

$Num 
1;

while(
file_exists("items/$Num.inc"))  # SEARCH EACH NEWS FILE
{
  
$file "items/$Num.inc";           # FILE ADDRESS OF EACH NEWS FILE
  
$item[0] = $item[1];
  
$item[1] = $item[2];
  
$item[2] = $item[3];
  
$item[3] = $file;
  
$Num++;
}

for (
$x=count($item)-1;$x>=0;$x--)
{
 
$handle fopen($item[$x],'r');       # OPEN NEWS FILE
 
$news fread($handle,99999);         # READ NEWS FILE
 
fclose($handle);                      # CLOSE NEWS FILE
 
 
$max strlen($news);                 # GET STRING LENGTH OF NEWS
 
if ($max 300)
  
$news substr($news,0,300);         # IF NEWS > 300 CHARACTERS TRIM NEWS TO 300 CHARACTERS
  
 
echo $news "<br><a href=\"$item[$x]\" target=\"new\">Full Story</a><br><br>";              # DISPLAY NEWS FROM THE FILE
}
?>
Save this php file in a directory and then make a subdirectory called 'items'.
Put your files in the subdirectory (1.inc, 2.inc, 3.inc,.....).
This script will read all files in that subdirectory and display the first 300 characters of news from the latest four files.

It will also provide a link to each file. You can play with the code to fit it to your liking. Any questions, email me at greggjewell@yahoo.com.

Hope this helps.
__________________
ArecaWeb Team
Gregg Kenneth Jewell
Reply With Quote
  #3 (permalink)  
Old 02-02-04, 09:44 AM
mixermanic mixermanic is offline
Newbie Coder
 
Join Date: Aug 2003
Location: London UK
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
That's brilliant thank you! I will play around with this and see what I can come up with.

Thanks again,

Martin



Quote:
Originally Posted by jewellgr
Martin,

Here is a start:

PHP Code:

<?PHP

$Num 
1;

while(
file_exists("items/$Num.inc"))  # SEARCH EACH NEWS FILE
{
  
$file "items/$Num.inc";           # FILE ADDRESS OF EACH NEWS FILE
  
$item[0] = $item[1];
  
$item[1] = $item[2];
  
$item[2] = $item[3];
  
$item[3] = $file;
  
$Num++;
}

for (
$x=count($item)-1;$x>=0;$x--)
{
 
$handle fopen($item[$x],'r');       # OPEN NEWS FILE
 
$news fread($handle,99999);         # READ NEWS FILE
 
fclose($handle);                      # CLOSE NEWS FILE
 
 
$max strlen($news);                 # GET STRING LENGTH OF NEWS
 
if ($max 300)
  
$news substr($news,0,300);         # IF NEWS > 300 CHARACTERS TRIM NEWS TO 300 CHARACTERS
  
 
echo $news "<br><a href=\"$item[$x]\" target=\"new\">Full Story</a><br><br>";              # DISPLAY NEWS FROM THE FILE
}
?>
Save this php file in a directory and then make a subdirectory called 'items'.
Put your files in the subdirectory (1.inc, 2.inc, 3.inc,.....).
This script will read all files in that subdirectory and display the first 300 characters of news from the latest four files.

It will also provide a link to each file. You can play with the code to fit it to your liking. Any questions, email me at greggjewell@yahoo.com.

Hope this helps.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
simple register script evolutiontheory The Lounge 0 01-27-04 01:00 PM
Need a simple uploading script DarkSamurai2003 Script Requests 2 11-21-03 04:59 AM
Seeking for a simple photo gallery script... Sgrebs PHP 0 10-27-03 02:00 PM
help with a really simple script theMezz Perl 3 10-04-03 09:26 PM


All times are GMT -5. The time now is 08:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.