#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Gig Harbor, Washington, USA
    Posts
    29
    Rep Power
    0
    Without MySQL..

    Just practicing with the fopen and fclose stuff. I made a very useful news script, but there is one little problem. I need old news to go out automaticly instead of manually!

    I am thinking that I could somehow (I have no idea) assign each news story an ID, then when there are x number of stories, move ID#whatever to an archive file.

    Or, when the current date is x higher than a older story, move that story to an archive.

    All I am doing here, essentially, is taking the admin's input and writing it to a txt file. With a little HTML and other stuff in between.. just your simple news writer

    A snipplet...
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $file = "news.txt"; // Name of the news archive file
    $open_old = fopen($file,"r"); // Open news.txt for reading. We'll close this later

    if(!file_exists($file)) { // Check if news.txt exists
    echo // It could not be opened, so let's show an error.
    "News.txt could not be found. Please create this file in the same directory as snews.php3. and the page in which you are using sNEWS.<br><br>Although when you add a story, this script will automaticly create a news.txt file if there isn't one, the process of keeping old news requires that you have a news.txt already created.";
    exit;
    }

    if (!$open_old) { // news.txt couldnt open!
    print "$file was not able to be opened"; // Display message
    exit; // exit conditional statement
    }

    $oldnews = fread($open_old, filesize ($file)); // Make sure old news is not overwritten
    fclose($open_old); // Close $open_old, which we opened above


    // VARIABLES
    $news = fopen($file, "w+"); // open news.txt again, this time it is read/writable
    $themonth = date(F); // grab the month
    $theday = date(j); // grab the day
    $theyear = date(Y);
    $format = // this is how the news will look like
    "<font face="Verdana,Arial,Helvica" size=2><b>$themonth $theday, $theyear: $write_title </b> <br> $write_news -<a href="mailto:$email">$name</a></font><br><br>$oldnews";
    $format = stripslashes($format);

    fwrite($news,$format); // write the news into news.txt
    fclose($news); // close news.txt, and we're done


    echo // display sucess message
    "<font face="Ms Sans Serif,Verdana,Arial,Helvica" size=2><b>News was updated!</b><br> Visit the page in which news.txt is included to view the changes.</font>";
    [/code]
    Heh, I know the way I did the dates was not what a "pro" would do.. seeing as I have viewed some complicated stuff out there. But thats what I am using for now

    ------------------
    chris swanicke
    swanicke@defected.net

    [This message has been edited by swanicke (edited August 26, 2000).]
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Gig Harbor, Washington, USA
    Posts
    29
    Rep Power
    0
    please?

    ------------------
    chris swanicke
    swanicke@defected.net

Similar Threads

  1. Can't move or delete it!
    By Hykinsel007 in forum Windows Help
    Replies: 3
    Last Post: June 15th, 2004, 03:41 PM
  2. using webdav to move php files with Apache 2
    By jkrew_devshed in forum Apache Development
    Replies: 1
    Last Post: May 15th, 2003, 10:00 AM
  3. archive project/coverting sounds problem
    By Exxit in forum Dev Shed Lounge
    Replies: 2
    Last Post: April 17th, 2002, 04:49 AM
  4. move folder script from move file
    By BladeTMC2 in forum PHP Development
    Replies: 0
    Last Post: March 17th, 2002, 01:51 PM
  5. Replies: 1
    Last Post: February 1st, 2002, 11:58 AM

IMN logo majestic logo threadwatch logo seochat tools logo