bbs admin problem

Discussion in 'Perl Misc' started by Robin, Jan 21, 2004.

  1. Robin

    Robin Guest

    This one's really got me stumped... the bbs files are "something.post" and
    the reply files are "something2.something" the second something being the
    name of the person who posted originally. What I'd like this script to do is
    to remove all of the reply files that corospond to the original post file...
    and when I run it it just deletes them all... I already understand why, but
    how can I get this so it only deletes the corosponding files. Thanks. btw,
    I'm doing this as a hobby, I study creative writing- some of my stories are
    at http://www.reachcac.org/robin/stories.html

    #!/usr/bin/perl

    #admin.cgi for bbs.cgi v.1.0.1

    require ('lib.cgi');
    require ('authlib.cgi');
    &data_cgivars;
    $" = "";
    $, = "";
    &login ("bbs.cgi");
    if ($FORM{'Logout'})
    {
    &logout ("bbs.cgi");
    exit;
    }
    if (! ($FORM{'Submit'}))
    {
    &output ("Welcome to BBS Admin...");
    exit;
    }
    if (! ($FORM{'del'}) && $FORM{'Submit'})
    {
    &output ("Please select a file!");
    exit;
    }
    print ("Content-type:text/html\n\n");
    opendir (BBSFILES, "BBSFILES/");
    @files = readdir (BBSFILES);
    closedir (BBSFILES);
    foreach $file (@files)
    {
    if ($file ne "." and $file ne "..")
    {
    #opendir (BBSFILES, "BBSFILES/");
    #@files2 = readdir (BBSFILES);
    #closedir (BBSFILES);
    unlink ("BBSFILES/$file") if ($file eq $FORM{'del'});
    @sec = split (/\./, $file);a
    if ($sec[1] ne "post")
    {
    $file =~ s/\..+//;
    if (-e "BBSFILES/$file.$sec[1]")
    {
    unlink ("BBSFILES/$file.$sec[1]");
    }
    }
    else
    { next; }
    }
    }
    &output ("Your changes have been made!");
    exit;



    sub output
    {
    my ($output) = @_;
    print ("Content-type:text/html\n\n");
    print <<END;
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>BBS ADMIN</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <div align="center">
    <p><strong>BBS Admin</strong></p>
    <p>$output</p>
    <p>Delete Entries:</p>
    <form action="admin.cgi" method="post">
    <p>
    <select name="del" size="7" id="del">
    END

    opendir (BBSFILES, "BBSFILES/");
    @filesout = readdir (BBSFILES);
    closedir (BBSFILES);
    foreach $fileout (@filesout)
    {
    if ($fileout =~ /\.post/)
    {
    print ("<option value=\"$fileout\">$fileout</option>");
    }
    }

    print <<END;

    </select>
    </p>
    <p>
    <input type="submit" name="Submit" value="Delete">
    <input type="submit" name="Logout" value="Logout">
    </p>
    </form>
    </div>
    </body>
    </html>

    END

    }
     
    Robin, Jan 21, 2004
    #1
    1. Advertising

  2. Robin

    Robin Guest

    Robin, Jan 21, 2004
    #2
    1. Advertising

  3. Robin <> wrote:

    > #!/usr/bin/perl


    use strict;
    use warnings;


    > require ('lib.cgi');


    use CGI;


    > &data_cgivars;


    data_cgivars();


    [ snip 100 lines of code ]


    Have you seen the Posting Guidelines that are posted here frequently?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 21, 2004
    #3
  4. Robin

    Robin Guest

    >
    > use CGI;
    >

    I want to use the code I have...
    -Robin
     
    Robin, Jan 21, 2004
    #4
  5. "Robin" <> wrote in news:bukuvn$v23$:

    >>
    >> use CGI;
    >>

    > I want to use the code I have...


    Robin;

    I went through this argument that you are sinking into a couple of years
    ago in this newsgroup - I asked for suggestions on how to do (whatever)
    without using CGI.pm and was repeatedly told to stop wasting everyone's
    time if I insisted on doing things the wrong way.

    Skip ahead these past years and all of my CGI scripts use CGI.pm. Why ?
    Because they (the regulars in this newsgroup) were right and I was wrong.

    CGI.pm has been developed - and peer reviewed - in such a way as to
    provide the most efficient method for performing the most common of CGI
    related tasks.

    If you think that you are improving your skills such that a potential
    employer will be impressed that you can dump all your passed arguments
    from a website into your own hash all by hand - instead of using CGI.pm

    (ex:
    use CGI;
    $q = new CGI;
    %in = $q->Vars;
    )

    then you are mistaken - Why would an employer want to be paying you to
    re-invent an already solidly designed wheel for each and every single
    script your write ? This is also assuming that the code you are re-
    creating (that pre-exists in CGI.pm) is as secure, efficient and as fast
    as the routines available within CGI.

    CGI.pm is *standard* these days - it's not like you are being told to go
    out and use some eccentric bit of code. It will save you *hundreds* of
    hours per year in your coding by allowing you to focus on creating perl
    code that does the actual work you desire to accomplish, rather than re-
    writing the precursors to simply parsing and displaying the data you need
    to do your work.

    I suspect there are others in this NG who could give you better examples
    than this, but you're really wasting your own time and that of the many
    people in this NG who are *invaluable* in providing advice, providing
    you're able to show a willingness to actually follow it.

    You can do a google groups search on within
    comp.lang.perl.misc and you'll see that I went through this *exact*
    argument - I was wrong - I admitted it - I learned - I am a better
    programmer because of it.


    --
    Marc Bissonnette
    CGI / Database / Web Management Tools: http://www.internalysis.com
    Something To Sell? Looking To Buy? http://www.whitewaterclassifieds.ca
    Looking for a new ISP? http://www.canadianisp.com
     
    Marc Bissonnette, Jan 21, 2004
    #5
  6. "Robin" <> wrote in news:bukuvn$v23$:

    >>
    >> use CGI;
    >>

    > I want to use the code I have...
    > -Robin


    But it is not working ... Do you see where I am going with this.

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, Jan 21, 2004
    #6
  7. Robin

    Robin Guest


    > I went through this argument that you are sinking into a couple of years
    > ago in this newsgroup - I asked for suggestions on how to do (whatever)
    > without using CGI.pm and was repeatedly told to stop wasting everyone's
    > time if I insisted on doing things the wrong way.
    >
    > Skip ahead these past years and all of my CGI scripts use CGI.pm. Why ?
    > Because they (the regulars in this newsgroup) were right and I was wrong.
    >
    > CGI.pm has been developed - and peer reviewed - in such a way as to
    > provide the most efficient method for performing the most common of CGI
    > related tasks.
    >
    > If you think that you are improving your skills such that a potential
    > employer will be impressed that you can dump all your passed arguments
    > from a website into your own hash all by hand - instead of using CGI.pm
    >
    > (ex:
    > use CGI;
    > $q = new CGI;
    > %in = $q->Vars;
    > )

    thanks marc, I like what you said about cgi.pm being standard, I like all
    the stuff u said actually. I'll try to shut up.

    peace,
    -Robin
     
    Robin, Jan 21, 2004
    #7
  8. Robin <> wrote:
    >>
    >> use CGI;
    >>

    > I want to use the code I have...



    I give up.

    So long.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 21, 2004
    #8
  9. "Robin" <> wrote in news:bul10h$jp$:

    >
    >> I went through this argument that you are sinking into a couple of
    >> years ago in this newsgroup - I asked for suggestions on how to do
    >> (whatever) without using CGI.pm and was repeatedly told to stop
    >> wasting everyone's time if I insisted on doing things the wrong way.
    >>
    >> Skip ahead these past years and all of my CGI scripts use CGI.pm. Why
    >> ? Because they (the regulars in this newsgroup) were right and I was
    >> wrong.
    >>
    >> CGI.pm has been developed - and peer reviewed - in such a way as to
    >> provide the most efficient method for performing the most common of
    >> CGI related tasks.
    >>
    >> If you think that you are improving your skills such that a potential
    >> employer will be impressed that you can dump all your passed
    >> arguments from a website into your own hash all by hand - instead of
    >> using CGI.pm
    >>
    >> (ex:
    >> use CGI;
    >> $q = new CGI;
    >> %in = $q->Vars;
    >> )

    > thanks marc, I like what you said about cgi.pm being standard, I like
    > all the stuff u said actually. I'll try to shut up.


    It's not so much that people are telling you to shut up - it's more along
    the lines of if you're going to come in here and ask for advice, then
    have the good graces to follow - or at least try - the advice.

    It's sorta kinda like an apprentice carpenter telling his mentor "I'm
    going to cut this board with this hammer - how to I do it ?" And the
    mentor replying "No, use this saw, instead". - If you insist on using the
    hammer to cut the board, eventually the mentor will just give up and walk
    away, no matter how many questions you ask.

    Out of curiosity, do you posess the book "Learning Perl", 3rd edition, by
    Randal Schwartz and Tom Phoenix ?

    http://www.oreilly.com/catalog/lperl3/

    This is a must have for a starting point.
    When you've gone through that two or three times, move on to
    "Programming Perl, 3rd Edition
    By Larry Wall, Tom Christiansen, Jon Orwant"
    http://www.oreilly.com/catalog/pperl3/

    Go through as much of that as you can and practice, practice, practice.

    For me, once past those two (And I don't claim to have mastered the
    second, by far - I still pick it up to learn what I need at a given point
    in time), I moved on to

    Managing & Using MySQL, 2nd Edition
    By George Reese, Randy Jay Yarger, Tim King
    http://www.oreilly.com/catalog/msql2/

    for a while, because perl works beautifully with it, then came back to

    Mastering Regular Expressions, 2nd Edition
    By Jeffrey E. F. Friedl
    http://www.oreilly.com/catalog/regex2/

    This book is where you'll learn a lot of the power of Perl, IMO.

    For the CGI.pm stuff, a cursory search turns this up as a decent starting
    place:

    http://stein.cshl.org/WWW/software/CGI/


    --
    Marc Bissonnette
    CGI / Database / Web Management Tools: http://www.internalysis.com
    Something To Sell? Looking To Buy? http://www.whitewaterclassifieds.ca
    Looking for a new ISP? http://www.canadianisp.com
     
    Marc Bissonnette, Jan 21, 2004
    #9
  10. In article <Xns947712C956359dragnetinternalysisc@206.172.150.13>,
    Marc Bissonnette <> wrote:

    > For me, once past those two (And I don't claim to have mastered the
    > second, by far - I still pick it up to learn what I need at a given point
    > in time), I moved on to
    >
    > Managing & Using MySQL, 2nd Edition
    > By George Reese, Randy Jay Yarger, Tim King
    > http://www.oreilly.com/catalog/msql2/


    I feel I need to comment that this is by far the _worst_ OReilly book
    I've ever bought...

    I'd suggest
    Programming the Perl DBI
    By  Alligator Descartes ,Tim Bunce
    http://www.oreilly.com/catalog/perldbi/

    is a far more useful Perl book (if you already know MySQL), and

    MySQL
    by Paul Dubois
    http://www.newriders.com/books/product.asp?product_id={FC784549-C0F6-44
    BC-8D69-393B557CDF40%7D

    if you want to learn about how to use MySQL (rather than just how to use
    it from perl).

    Managing & Using MySQL (though, admittedly, I've got the first edition)
    is little more than a printed copy of a bunch of out of date MySQL
    documentation with maybe 3 or 4 chapters of original stuff...

    big

    --
    'When I first met Katho, she had a meat cleaver in one hand and
    half a sheep in the other. "Come in", she says, "Hammo's not here.
    I hope you like meat.' Sharkey in aus.moto
     
    Iain Chalmers, Jan 21, 2004
    #10
  11. Iain Chalmers <> wrote:
    > In article <Xns947712C956359dragnetinternalysisc@206.172.150.13>,
    > Marc Bissonnette <> wrote:
    >
    >> moved on to
    >>
    >> Managing & Using MySQL, 2nd Edition
    >> By George Reese, Randy Jay Yarger, Tim King
    >> http://www.oreilly.com/catalog/msql2/



    Even the beloved O'Reilly makes mistakes.


    > I feel I need to comment that this is by far the _worst_ OReilly book
    > I've ever bought...



    George Reese has a reputation hereabouts.

    He trolled here with vigor some years ago.

    Message-ID: <7pvkeo$v15$>

    Message-ID: <>


    I expect that a book written by a troll would be suboptimal.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 21, 2004
    #11
  12. Iain Chalmers <> wrote in
    news:-berlin.de:

    > In article <Xns947712C956359dragnetinternalysisc@206.172.150.13>,
    > Marc Bissonnette <> wrote:
    >
    >> For me, once past those two (And I don't claim to have mastered the
    >> second, by far - I still pick it up to learn what I need at a given
    >> point in time), I moved on to
    >>
    >> Managing & Using MySQL, 2nd Edition
    >> By George Reese, Randy Jay Yarger, Tim King
    >> http://www.oreilly.com/catalog/msql2/

    >
    > I feel I need to comment that this is by far the _worst_ OReilly book
    > I've ever bought...
    >
    > I'd suggest
    > Programming the Perl DBI
    > By  Alligator Descartes ,Tim Bunce
    > http://www.oreilly.com/catalog/perldbi/
    >
    > is a far more useful Perl book (if you already know MySQL), and
    >
    > MySQL
    > by Paul Dubois
    > http://www.newriders.com/books/product.asp?product_id={FC784549-C0F6-
    > 44 BC-8D69-393B557CDF40%7D
    >
    > if you want to learn about how to use MySQL (rather than just how to
    > use it from perl).
    >
    > Managing & Using MySQL (though, admittedly, I've got the first
    > edition) is little more than a printed copy of a bunch of out of date
    > MySQL documentation with maybe 3 or 4 chapters of original stuff...


    Hrm, that's good to know - The Reese book got me started, though just
    about all my MySQL learning these days comes from
    http://www.mysql.com/documentation/ along with Usenet and Google.

    The Reese threads are making for entertaining afternoon reading, however
    :)

    Thanks for the correction/heads up.


    --
    Marc Bissonnette
    CGI / Database / Web Management Tools: http://www.internalysis.com
    Something To Sell? Looking To Buy? http://www.whitewaterclassifieds.ca
    Looking for a new ISP? http://www.canadianisp.com
     
    Marc Bissonnette, Jan 21, 2004
    #12
  13. Robin

    Robin Guest

    I finally got it working, now using subs called without "ampersands" thanks
    to whoever corrected me... is this a top post or something else? I read some
    articles on top posting btw, so I'm more informed...

    peace,
    -Robin
     
    Robin, Jan 22, 2004
    #13
  14. This line would be top-posting. [And I apologize to others... I only
    do it for demonstration.]

    In article <bun79g$to1$>, Robin <> wrote:
    :I finally got it working, now using subs called without "ampersands" thanks
    :to whoever corrected me... is this a top post or something else? I read some
    :articles on top posting btw, so I'm more informed...

    This line isn't top-posting. Nor was your most recent post. Top-posting
    is posting on the top of whatever you are replying to.
    --
    Pity the poor electron, floating around minding its own business for
    billions of years; and then suddenly Bam!! -- annihilated just so
    you could read this posting.
     
    Walter Roberson, Jan 22, 2004
    #14
  15. Robin

    Robin Guest

    Sweet...thanks.

    peace,
    -Robin
     
    Robin, Jan 22, 2004
    #15
  16. Robin

    Tintin Guest

    "Robin" <> wrote in message
    news:bun79g$to1$...
    > I finally got it working, now using subs called without "ampersands"

    thanks
    > to whoever corrected me... is this a top post or something else? I read

    some
    > articles on top posting btw, so I'm more informed...


    For some definition of "working".

    I don't know why you are still confused about top posting. You've been
    given plenty of articles to read and you can see perfect examples everyday
    in this group.

    The next thing you need to learn is context and references. Please re-read
    Tad's posting guidelines *again*
     
    Tintin, Jan 22, 2004
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Welman Jordan

    How to write BBS format conversion code?

    Welman Jordan, May 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    708
    Welman Jordan
    May 11, 2004
  2. Winkin
    Replies:
    1
    Views:
    3,709
    Stuart Golodetz
    Nov 24, 2003
  3. sarah Fernandes
    Replies:
    0
    Views:
    521
    sarah Fernandes
    Nov 1, 2010
  4. Phlip
    Replies:
    1
    Views:
    293
    Eero Saynatkari
    Sep 15, 2006
  5. Robin

    bbs problem

    Robin, Jan 20, 2004, in forum: Perl Misc
    Replies:
    56
    Views:
    2,395
    gnari
    Jan 26, 2004
Loading...

Share This Page