Welcome, Guest
  • Author Topic: script to aujtomatically delete TXT files from server?  (Read 2312 times)

    Glenn

    • Server what's that
    • *
    • Posts: 5
      • View Profile
      • Email
    Hi!

    I've gone through the Flash-DB eCards tutorial and think it's great, but now I'd like to customize it so the TXT files get deleted from the server once the eCard is viewed. Thus, the user will only be able to view the eCard once and then the TXT file will get deleted. With this I won't have to manually clean up the online folder of TXT files that are generated.

    Any ideas on how to do this?

    Thanks!
    Glenn

    Glenn

    • Server what's that
    • *
    • Posts: 5
      • View Profile
      • Email
    h ;D hehe... I've changed my mind.

    Instead of automaticallly deleting the text file I'd like to be able to write to the text file an 'ecard_read' variable which will either be 'Yes' or 'No' (to the question of whether the ecard has been read yet).

    Also, I'd like to record the senders IP address in the TXT file.

    Is this do-able?

    Thanks
    Glenn

    Glenn

    • Server what's that
    • *
    • Posts: 5
      • View Profile
      • Email
    I've figured out how to get the IP address written to the TXT file. I've also added a Read variable, but am still unsure how I can write to the TXT file when the user views their eCard for the first time.

    Just add/update these lines in 'SendECard.php':

    // note that $ip is also added to the EcardText string below
    $ip = $REMOTE_ADDR;  

    // The default is that the user has not yet viewed the card
    // This is what I want to turn to a "yes" once the user views the ecard
    $Read = "no";    

    // added $ip and $read variables
    $EcardText = "ToName=$ToName&ToEmail=$ToEmail&FromName=$FromName&FromEmail=
    $FromEmail&Greeting=$Greeting&IntroMessage=$IntroMessage&IP=
    $ip&Created=$Created&Read=$Read";


    Is there anyone out there that can help me write "yes" to the $Read variable in the the TXT file once the eCard is viewed?   ???
    « Last Edit: 02/26/02, 01:29 by Glenn »

    Flich

    • Server what's that
    • *
    • Posts: 2
      • View Profile
      • Email
    hiya,

    I can't think of a good way of doing it on the top of my head. A dirty soloution would be to read all the data, and write it all again with any changes there might be (in your case "Read=yes" instead of "no"). And after you have done this you still need to find which ecards have been changed so you can delete them.

    Anyways, its kinda mean to delete them after they have read it once no?  ;D

    What I have done is made a cron job that deletes any ecard data files more than 30 days old. Of course this means that my ecards data files have the proper name format so my script knows how old it is. I believe thats how some of the more "established" ecards sites do it as well.

    Goodluck,

    flich