home *** CD-ROM | disk | FTP | other *** search
/ The Elite Hackers Toolkit / TheEliteHackersToolkitVolume1_1998.rar / HACKERS.BIN / appcraks / MESSAGEB.ZIP / BOARD.CGI < prev    next >
Text File  |  1998-01-14  |  28KB  |  1,170 lines

  1. #!/usr/local/bin/perl
  2.  
  3. ######################################################################
  4. #  BEFORE TRYING TO EDIT THIS SCRIPT, READ THE README FILE
  5. ###################################################################### 
  6. #
  7. #     Dream Catchers CGI Scripts               Feel free to modify 
  8. #     Message Board                            this script to your 
  9. #     Created by Seth Leonard                  needs, but please
  10. #     for Dream Catchers Technologies, Inc.    keep this portion so
  11. #                                              that I get credit.  
  12. #     http://dreamcatchersweb.com/scripts      The same goes for 
  13. #                                              distribution.
  14. #
  15. #     (c)1996/1997 Dream Catchers Technologies, Inc.,
  16. #     All Rights Reserved
  17. #
  18. ######################################################################
  19.  
  20. $userdir = "users";
  21. $datafile = "data.txt";
  22. $messagedir = "messages";
  23. $responsedir = "responses";
  24. $archivedir = "archives";
  25. $dateprogram = "/bin/date";
  26.  
  27. $bgcolor = "FFFFFF";
  28. $textcolor = "000000";
  29. $linkcolor = "0000FF";
  30. $boardname = "Message Board";
  31. $loginpage = "http://server.com/board/login.html";
  32. $script = "http://server.com/cgi-bin/board.cgi";
  33.  
  34. ############################################################################
  35.  
  36. &getdate;
  37.  
  38. if ($ENV{'QUERY_STRING'}) {
  39.     $namevalues = $ENV{'QUERY_STRING'};
  40. } else {
  41.     read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});
  42. }
  43.  
  44. @pairs = split(/&/, $namevalues);
  45.     foreach $pair (@pairs) {
  46.     ($name, $value) = split(/=/, $pair);
  47.     $value =~ tr/+/ /;
  48.     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  49.     $value =~ s/<!--(.|\n)*-->//g;
  50.     $value =~ s/<([^>]|\n)*>//g;
  51.     $INPUT{$name} = $value;
  52. }
  53.  
  54. $action = $INPUT{'action'};
  55.  
  56. if ($action eq 'login') {
  57.     &login;
  58. }
  59. if ($action eq 'main') {
  60.     &main;
  61. }
  62. if ($action eq 'view') {
  63.     &view;
  64. }
  65. if ($action eq 'post') {
  66.     &post;
  67. }
  68. if ($action eq 'userarchive') {
  69.     &userarchive;
  70. }
  71. if ($action eq 'viewarchive') {
  72.     &viewarchive;
  73. }
  74. if ($action eq 'editarchive') {
  75.     &editarchive;
  76. }
  77. if ($action eq 'deletearchive') {
  78.     &deletearchive;
  79. }
  80. if ($action eq 'archivemessage') {
  81.     &archivemessage;
  82. }
  83. if ($action eq 'register') {
  84.     ®ister;
  85. }
  86.  
  87. ############################################################################
  88. # REGISTER
  89. ############################################################################
  90.  
  91. sub register {
  92.  
  93. unless ($INPUT{'user'}) {
  94.     &requireuser;
  95. }
  96.  
  97. &user;
  98.  
  99. $filetoexist = "$userdir/$user.user";
  100.  
  101. @atribs = stat("$filetoexist");
  102.  
  103. if ($atribs[7] > 0 || $INPUT{'user'} eq 'guest') {
  104.  
  105.     &usernametaken;
  106. }
  107.  
  108. $INPUT{'password'} =~ tr/ /-/;
  109.  
  110. $cryptpassword = crypt($INPUT{'password'}, sb);
  111.  
  112. open (NEWUSER, ">$userdir/$user.user");
  113.  
  114. print NEWUSER ("$cryptpassword\n");
  115. if ($INPUT{'alias1'}) {
  116.     print NEWUSER ("$INPUT{'alias1'}");
  117. }
  118. if ($INPUT{'alias2'}) {
  119.     print NEWUSER ("\t");
  120.     print NEWUSER ("$INPUT{'alias2'}");
  121. }
  122. if ($INPUT{'alias3'}) {
  123.     print NEWUSER ("\t");
  124.     print NEWUSER ("$INPUT{'alias3'}");
  125. }
  126. if ($INPUT{'alias4'}) {
  127.     print NEWUSER ("\t");
  128.     print NEWUSER ("$INPUT{'alias4'}");
  129. }
  130. if ($INPUT{'alias5'}) {
  131.     print NEWUSER ("\t");
  132.     print NEWUSER ("$INPUT{'alias5'}");
  133. }
  134. print NEWUSER ("\n");
  135.  
  136.  
  137. if ($INPUT{'email'} && $INPUT{'email'} =~ /(.*)@(.*)/) {
  138.     print NEWUSER ("$INPUT{'email'}\n");
  139. } else {
  140.     print NEWUSER ("none\n");
  141. }
  142.  
  143. print NEWUSER ("$INPUT{'archive'}\n");
  144.  
  145. close (NEWUSER);
  146.  
  147. if ($INPUT{'archive'} eq 'yes') {
  148.  
  149.     open (NEWARCHIVE, ">$archivedir/$user.archive");
  150.     close (NEWARCHIVE);
  151.  
  152. }
  153.  
  154. print ("Content-type: text/html\n\n");
  155.  
  156. print <<"html";
  157.  
  158. <HTML>
  159. <HEAD>
  160. <TITLE>Thank You For Registering</TITLE>
  161. </HEAD>
  162. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  163. <center><font size=6>Thank you for Registering</font></center><hr>
  164. <b>Welcome to $boardname $userview,</b><br><br>
  165. Please go to the <a href=$loginpage>login page</a> and login using the username '<i>$userview</i>' and the password '<i>$INPUT{'password'}</i>'.<br><br>
  166. Thank you!
  167.  
  168. <hr>
  169. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  170. </body>
  171. </html>
  172.  
  173. html
  174.  
  175. exit;
  176.  
  177. }
  178.  
  179. ############################################################################
  180. # MAIN MENU
  181. ############################################################################
  182.  
  183. sub login {
  184.  
  185. &user;
  186.  
  187. &checkpassword;
  188.  
  189. print ("Content-type: text/html\n\n");
  190.  
  191. print <<"html";
  192.  
  193. <HTML>
  194. <HEAD>
  195. <TITLE>Welcome To $boardname</TITLE>
  196. </HEAD>
  197. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  198. <center><font size=6>Welcome to $boardname</font></center><hr>
  199. <center><b>You have the following options:</b><br><br>
  200.  
  201. <table border=0>
  202. <tr><td>
  203. <form method=get action=$script>
  204. <input type=hidden name=action value=main>
  205. <input type=hidden name=user value="$user">
  206. <input type=hidden name=password value="$INPUT{'password'}">
  207. <input type=submit value="View the Board">
  208. </form>
  209. </td><td>
  210. <form method=get action=$script>
  211. <input type=hidden name=action value=viewarchive>
  212. <input type=hidden name=user value="$user">
  213. <input type=hidden name=password value="$INPUT{'password'}">
  214. <input type=submit value="View an Archive">
  215. </form></td>
  216. html
  217.  
  218. unless ($user eq 'guest') {
  219.  
  220. print <<"html";
  221. <td>
  222. <form method=get action=$script>
  223. <input type=hidden name=action value=editarchive>
  224. <input type=hidden name=user value="$user">
  225. <input type=hidden name=password value="$INPUT{'password'}">
  226. <input type=submit value="Edit your Archive">
  227. </form>
  228. </td>
  229. html
  230. }
  231.  
  232. print <<"html";
  233. </tr></table>
  234. </center>
  235. <hr>
  236. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  237. </body>
  238. </html>
  239.  
  240. html
  241.  
  242. exit;
  243.  
  244. }
  245.  
  246. ############################################################################
  247. # VIEW BOARD
  248. ############################################################################
  249.  
  250. sub main {
  251.  
  252. &user;
  253.  
  254. &checkpassword;
  255. &getuserinfo;
  256.  
  257. opendir (MESSAGES, "$messagedir");
  258. @files = readdir(MESSAGES);
  259. close (MESSAGES);
  260.  
  261. $numberoffiles = @files;
  262. $numberoffiles -= 1;
  263.  
  264. @rmessages = @files[2..$numberoffiles];
  265.  
  266. foreach $message (@rmessages) {
  267.         $x = 1;
  268.         while ($x < @rmessages) {
  269.                 if ($rmessages[$x - 1] > $rmessages[$x]) {
  270.                         @rmessages[$x - 1, $x] = @rmessages[$x, $x - 1];
  271.                 }
  272.                 $x++;
  273.         }
  274. }
  275.  
  276. @messages = reverse(@rmessages);
  277.  
  278. print ("Content-type: text/html\n\n");
  279.  
  280. print <<"html";
  281.  
  282. <HTML>
  283. <HEAD>
  284. <TITLE>$boardname</TITLE>
  285. </HEAD>
  286. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  287. <center><b><font size=6>$boardname</font></b></center>
  288. <hr>
  289. <ul>
  290.  
  291. html
  292.  
  293. foreach $message (@messages) {
  294.     
  295.     chop ($message);
  296.     chop ($message);
  297.     chop ($message);
  298.     chop ($message);
  299.     open (MESSAGE, "$messagedir/$message.txt");
  300.     ($subject, $name, $postunder, $responses, $date, $puser, $post) = <MESSAGE>;
  301.     close (MESSAGE);
  302.  
  303.     chop ($subject) if ($subject =~ /\n$/);
  304.     chop ($name) if ($name =~ /\n$/);
  305.     chop ($postunder) if ($postunder =~ /\n$/);
  306.     chop ($responses) if ($responses =~ /\n$/);
  307.     chop ($date) if ($date =~ /\n$/);
  308.     chop ($puser) if ($puser =~ /\n$/);
  309.     chop ($post) if ($post =~ /\n$/);
  310.  
  311.     @responses = split(/\t/, $responses);
  312.     $responses = @responses;
  313.  
  314.     print ("<li><a href=\"$script?action=view&message=$message&location=messages&user=$user&password=$INPUT{'password'}\">$subject</a> - <b>$name</b> <i>$date</i></li>\n");
  315.  
  316. }
  317.  
  318. if ($user eq 'guest') {
  319.  
  320. print <<"html";
  321.  
  322. </ul>
  323. <hr>
  324. <center>
  325. [ <a href=\"$script?action=login&user=$user&password=$INPUT{'password'}\">Main Menu</a> ]
  326. </center>
  327. <hr>
  328. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  329. </body>
  330. </html>
  331.  
  332. html
  333.  
  334. } else {
  335.  
  336. print <<"html";
  337.  
  338. </ul>
  339. <hr>
  340. <form method=post action=$script>
  341. <input type=hidden name=action value=post>
  342. <input type=hidden name=postunder value=main>
  343. <input type=hidden name=status value=original>
  344. <input type=hidden name=user value="$user">
  345. <input type=hidden name=password value="$INPUT{'password'}">
  346. <table cellpadding=0 cellspacing=0 width=100%>
  347. <tr><td width=15%><b>Name:</b></td><td>
  348. <SELECT NAME="name">
  349. <OPTION SELECTED="selected" VALUE="$userview">$userview</OPTION>
  350.  
  351. html
  352.  
  353. unless ($aliases == 0) {
  354.     foreach $alias (@aliases) {
  355.         print ("<OPTION VALUE=\"$alias\">$alias</OPTION>\n");
  356.     }
  357. }
  358.  
  359. print <<"html";
  360.  
  361. </SELECT>
  362. </td></tr>
  363. <tr><td width=15%><b>Subject:</b></td><td><input type=text name=subject size=40 maxlength=75</td></tr>
  364. html
  365.  
  366. if ($userarchive eq 'available') {
  367.     print ("<tr><td width=15%><b>Archive:</b></td><td>\n");
  368.     print ("<INPUT TYPE=radio NAME=archive VALUE=yes> Yes\n");
  369.     print ("<INPUT TYPE=radio NAME=archive VALUE=no CHECKED=checked> No\n");
  370.     print ("</td></tr>\n");
  371. }
  372.  
  373. print <<"html";
  374. </table>
  375. <b>Post:</b><br>
  376. <TEXTAREA NAME="message" ROWS="10" COLS="75"></TEXTAREA><br><br>
  377. <input type=submit value=Post> <input type=reset>
  378. <hr>
  379. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  380. </body>
  381. </html>
  382.  
  383. html
  384.  
  385. }
  386.  
  387. exit;
  388.  
  389. }
  390.  
  391. ############################################################################
  392. # VIEW A MESSAGE
  393. ############################################################################
  394.  
  395. sub view {
  396.  
  397. &user;
  398.  
  399. &checkpassword;
  400.  
  401. if ($INPUT{'location'} eq 'messages') {
  402.     $dir = $messagedir;
  403. } else {
  404.     $dir = $responsedir;
  405. }
  406.  
  407. open (MESSAGE, "$dir/$INPUT{'message'}.txt");
  408. ($subject, $name, $postunder, $responses, $date, $puser, $post) = <MESSAGE>;
  409. close (MESSAGE);
  410.  
  411. chop ($subject) if ($subject =~ /\n$/);
  412. chop ($name) if ($name =~ /\n$/);
  413. chop ($postunder) if ($postunder =~ /\n$/);
  414. chop ($responses) if ($responses =~ /\n$/);
  415. chop ($date) if ($date =~ /\n$/);
  416. chop ($puser) if ($puser =~ /\n$/);
  417. chop ($post) if ($post =~ /\n$/);
  418.  
  419. &getpostunderinfo;
  420. &getpostuserinfo;
  421.  
  422. print ("Content-type: text/html\n\n");
  423.  
  424. print <<"html";
  425.  
  426. <HTML>
  427. <HEAD>
  428. <TITLE>$subject</TITLE>
  429. </HEAD>
  430. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  431. <center><font size=6>$subject</font></center><hr>
  432. <table cellpadding=0 cellspacing=0 width=100%>
  433. <tr><td width=15%><b>Posted By:</b></td><td>$name</td></tr>
  434. html
  435.  
  436. if ($INPUT{'location'} eq 'messages') {
  437.     $no = "yes";
  438. } else {
  439.     print ("<tr><td width=15%><b>Response to:</b></td><td><a href=\"$script?action=view&message=$postunder&location=messages&user=$user&password=$INPUT{'password'}\">$osubject</a> posted by $oname</td></tr>\n");
  440. }
  441.  
  442. print <<"html";
  443. <tr><td width=15%><b>Email:</b></td><td>$pemail</td></tr>
  444. <tr><td width=15%><b>Date:</b></td><td>$date</td></tr>
  445. html
  446.  
  447. if ($puserarchive eq 'available') {
  448.     print ("<tr><td width=15%><b>Archive:</b></td><td><a href=\"$script?action=userarchive&archive=$puser&user=$user&password=$INPUT{'password'}\">Available</a></td></tr>\n");
  449. } else {
  450.     print ("<tr><td width=15%><b>Archive:</b></td><td>Not Available</td></tr>\n");
  451. }
  452.  
  453. print <<"html";
  454. </table>
  455. <hr>
  456. $post
  457. <hr>
  458. <b>Responses:</b>
  459. <ul>
  460. html
  461.  
  462. unless ($responses eq "") {
  463.  
  464.     @responses = split(/x/, $responses);
  465.  
  466.     foreach $response (@responses) {
  467.  
  468.         &getresponseinfo;
  469.         print ("<li><a href=\"$script?action=view&message=$response&location=responses&user=$user&password=$INPUT{'password'}\">$rsubject</a> -- $rname<br></li>\n");
  470.     }
  471. }
  472.  
  473. print <<"html";
  474. </ul>
  475. <hr>
  476. html
  477.  
  478. if ($user eq 'guest') {
  479.  
  480. print <<"html";
  481.  
  482. <center>
  483. [ <a href=\"$script?action=login&user=$user&password=$INPUT{'password'}\">Main Menu</a> ]
  484. </center>
  485. <hr>
  486. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  487. </body>
  488. </html>
  489.  
  490. html
  491.  
  492. } else {
  493.  
  494. &getuserinfo;
  495.  
  496. print <<"html";
  497. <font size=4><b>Post Response:</font></b><br><br>
  498. <form method=post action=$script>
  499. <input type=hidden name=action value=post>
  500. <input type=hidden name=postunder value=$INPUT{'message'}>
  501. html
  502.  
  503. if ($INPUT{'location'} eq 'messages') {
  504.     $status = "original";
  505. } else {
  506.     $status = "response";
  507. }
  508.  
  509. print <<"html";
  510. <input type=hidden name=status value=$status>
  511. <input type=hidden name=user value="$user">
  512. <input type=hidden name=password value="$INPUT{'password'}">
  513. <table cellpadding=0 cellspacing=0 width=100%>
  514. <tr><td width=15%><b>Name:</b></td><td>
  515. <SELECT NAME="name">
  516. <OPTION SELECTED="selected" VALUE="$userview">$userview</OPTION>
  517.  
  518. html
  519.  
  520. unless ($aliases == 0) {
  521.     foreach $alias (@aliases) {
  522.         print ("<OPTION VALUE=\"$alias\">$alias</OPTION>\n");
  523.     }
  524. }
  525.  
  526. chop ($subject) if ($subject =~ /\n$/);
  527.  
  528. if ($subject =~ /Re:/) {
  529.     $newsubject = $subject;
  530. } else {
  531.     $newsubject = "Re: $subject";
  532. }
  533.  
  534. print <<"html";
  535.  
  536. </SELECT>
  537. </td></tr>
  538. <tr><td width=15%><b>Subject:</b></td><td><input type=text name=subject size=40 maxlength=75 value="$newsubject"></td></tr>
  539. html
  540.  
  541. if ($userarchive eq 'available') {
  542.     print ("<tr><td width=15%><b>Archive:</b></td><td>\n");
  543.     print ("<INPUT TYPE=radio NAME=archive VALUE=yes> Yes\n");
  544.     print ("<INPUT TYPE=radio NAME=archive VALUE=no CHECKED=checked> No\n");
  545.     print ("</td></tr>\n");
  546. }
  547.  
  548. print <<"html";
  549. </table>
  550. <b>Post:</b><br>
  551. <TEXTAREA NAME="message" ROWS="10" COLS="75"></TEXTAREA><br><br>
  552. <input type=submit value=Post> <input type=reset>
  553. <hr>
  554. <center>
  555. [ <a href=\"$script?action=main&user=$user&password=$INPUT{'password'}\">$boardname</a> ]
  556. [ <a href=\"$script?action=login&user=$user&password=$INPUT{'password'}\">Main Menu</a> ]
  557. </center>
  558. <hr>
  559. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  560. </body>
  561. </html>
  562.  
  563. html
  564.  
  565. }
  566.  
  567. exit;
  568.  
  569. }
  570.  
  571. ############################################################################
  572. # POST A MESSAGE
  573. ############################################################################
  574.  
  575. sub post {
  576.  
  577. $INPUT{'message'} =~ s/\cM\n/<br>/g;
  578. $post = $INPUT{'message'};
  579.  
  580. &user;
  581.  
  582. &checkpassword;
  583.  
  584. open (DATA, "$datafile");
  585. $count = <DATA>;
  586. close (DATA);
  587.  
  588. chop ($count) if ($count =~ /\n$/);
  589.  
  590. $count += 1;
  591.  
  592. open (DATA, ">$datafile");
  593. print DATA ("$count");
  594. close (DATA);
  595.  
  596. if ($INPUT{'postunder'} eq 'main') {
  597.  
  598.     open (NEWFILE, ">$messagedir/$count.txt");
  599.     print NEWFILE ("$INPUT{'subject'}\n");
  600.     print NEWFILE ("$INPUT{'name'}\n");
  601.     print NEWFILE ("$INPUT{'postunder'}\n");
  602.     print NEWFILE ("\n");
  603.     print NEWFILE ("$date\n");
  604.     print NEWFILE ("$user\n");
  605.     print NEWFILE ("$post\n");
  606.     close (NEWFILE);
  607.  
  608. } else {
  609.  
  610.     open (NEWFILE, ">$responsedir/$count.txt");
  611.     print NEWFILE ("$INPUT{'subject'}\n");
  612.     print NEWFILE ("$INPUT{'name'}\n");
  613.     print NEWFILE ("$INPUT{'postunder'}\n");
  614.     print NEWFILE ("\n");
  615.     print NEWFILE ("$date\n");
  616.     print NEWFILE ("$user\n");
  617.     print NEWFILE ("$post\n");
  618.     close (NEWFILE);
  619.  
  620.     if ($INPUT{'status'} eq 'original') {
  621.         $dir = $messagedir;
  622.     } else {
  623.         $dir = $responsedir;
  624.     }
  625.  
  626.     open (UNDER, "$dir/$INPUT{'postunder'}.txt");
  627.     @lines = <UNDER>;
  628.     close (UNDER);
  629.  
  630.     chop ($lines[3]) if ($lines[3] =~ /\n$/);
  631.     if ($lines[3] eq "") {
  632.         $responses = $count;
  633.     } else {
  634.         $responses = $count . 'x' . $lines[3];
  635.     }
  636.     open (UNDER, ">$dir/$INPUT{'postunder'}.txt");
  637.     print UNDER ("$lines[0]");
  638.     print UNDER ("$lines[1]");
  639.     print UNDER ("$lines[2]");
  640.     print UNDER ("$responses\n");
  641.     print UNDER ("$lines[4]");
  642.     print UNDER ("$lines[5]");
  643.     print UNDER ("$lines[6]");
  644.     close (UNDER);
  645.  
  646. }
  647.  
  648. if ($INPUT{'archive'} eq 'yes') {
  649.  
  650.     open (ARCHIVE, ">>$archivedir/$user.archive");
  651.     print ARCHIVE ("$INPUT{'subject'}\t");
  652.     print ARCHIVE ("$date\t");
  653.     print ARCHIVE ("$post\n");
  654.     close (ARCHIVE);
  655.  
  656.     open (ARCHIVE, "$archivedir/$user.archive");
  657.     @lines = <ARCHIVE>;
  658.     close (ARCHIVE);
  659.  
  660.     $lines = @lines;
  661.  
  662.     if ($lines > 10) {
  663.  
  664.         open (ARCHIVE, ">$archivedir/$user.archive");
  665.         print ARCHIVE ("$lines[$lines - 10]");
  666.         print ARCHIVE ("$lines[$lines - 9]");
  667.         print ARCHIVE ("$lines[$lines - 8]");
  668.         print ARCHIVE ("$lines[$lines - 7]");
  669.         print ARCHIVE ("$lines[$lines - 6]");
  670.         print ARCHIVE ("$lines[$lines - 5]");
  671.         print ARCHIVE ("$lines[$lines - 4]");
  672.         print ARCHIVE ("$lines[$lines - 3]");
  673.         print ARCHIVE ("$lines[$lines - 2]");
  674.         print ARCHIVE ("$lines[$lines - 1]");
  675.     }
  676. }
  677.  
  678. &getuserinfo;
  679.  
  680. print ("Content-type: text/html\n\n");
  681.  
  682. print <<"html";
  683.  
  684. <HTML>
  685. <HEAD>
  686. <TITLE>$INPUT{'subject'}</TITLE>
  687. </HEAD>
  688. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  689. <center><font size=6>$INPUT{'subject'}</font></center><hr>
  690. <table cellpadding=0 cellspacing=0 width=100%>
  691. <tr><td width=15%><b>Posted By:</b></td><td>$INPUT{'name'}</td></tr>
  692. <tr><td width=15%><b>Email:</b></td><td>$email</td></tr>
  693. <tr><td width=15%><b>Date:</b></td><td>$date</td></tr>
  694.  
  695. html
  696.  
  697. if ($userarchive eq 'available') {
  698.  
  699.     print ("<tr><td width=15%><b>Archive:</b></td><td><a href=\"$script?action=userarchive&archive=$INPUT{'user'}&user=$user&password=$INPUT{'password'}\">Available</a></td></tr>\n");
  700.  
  701. } else {
  702.  
  703.     print ("<tr><td width=15%><b>Archive:</b></td><td>Not Available</td></tr>\n");
  704. }
  705.  
  706. print <<"html";
  707.  
  708. </table>
  709. <hr>
  710. $post
  711. <hr>
  712. <center>
  713. <table border=0>
  714. <tr><td>
  715. <form method=get action=$script>
  716. <input type=hidden name=action value=login>
  717. <input type=hidden name=user value="$user">
  718. <input type=hidden name=password value="$INPUT{'password'}">
  719. <input type=submit value="Main Menu">
  720. </form>
  721. </td><td>
  722. <form method=get action=$script>
  723. <input type=hidden name=action value=main>
  724. <input type=hidden name=user value="$user">
  725. <input type=hidden name=password value="$INPUT{'password'}">
  726. <input type=submit value="$boardname">
  727. </form>
  728. </td></tr></table></center>
  729. <hr>
  730. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  731. </body>
  732. </html>
  733.  
  734. html
  735.  
  736. exit;
  737.  
  738. }
  739.  
  740. ############################################################################
  741. # VIEW A USER'S ARCHIVE
  742. ############################################################################
  743.  
  744. sub userarchive {
  745.  
  746. &user;
  747.  
  748. $archive = $INPUT{'archive'};
  749. $archive =~ tr/ /_/;
  750. $archiveview = $INPUT{'archive'};
  751. $archiveview =~ tr/_/ /;
  752.  
  753. open (ARCHIVE, "$archivedir/$archive.archive");
  754. @lines = <ARCHIVE>;
  755. close (ARCHIVE);
  756.  
  757. print ("Content-type: text/html\n\n");
  758.  
  759. print <<"html";
  760.  
  761. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  762. <HTML>
  763. <HEAD>
  764. <TITLE>$archiveview Archive</TITLE>
  765. </HEAD>
  766. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  767. <font size=5>$archiveview Archive</font><hr>
  768. <ul>
  769. html
  770.  
  771. $archivenum = 0;
  772. foreach $line (@lines) {
  773.     ($subject, $date, $post) = split(/\t/, $line);
  774.     print ("<li><a href=\"$script?action=archivemessage&archivenumber=$archivenum&archive=$archive&user=$user&password=$INPUT{'password'}\">$subject</a> posted on $date</li>\n");
  775.     $archivenum += 1;
  776. }
  777.  
  778. print <<"html";
  779. </ul>
  780. <hr>
  781. <center>
  782. [ <a href=\"$script?action=main&user=$user&password=$INPUT{'password'}\">$boardname</a> ]
  783. [ <a href=\"$script?action=login&user=$user&password=$INPUT{'password'}\">Main Menu</a> ]
  784. </center>
  785. <hr>
  786. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  787. </BODY>
  788. </HTML>
  789. html
  790.  
  791. exit;
  792.  
  793. }
  794.  
  795. ############################################################################
  796. # PAGE TO INPUT USER FOR ARCHIVE
  797. ############################################################################
  798.  
  799. sub viewarchive {
  800.  
  801. &user;
  802.  
  803. &checkpassword;
  804.  
  805. print ("Content-type: text/html\n\n");
  806.  
  807. print <<"html";
  808.  
  809. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  810. <HTML>
  811. <HEAD>
  812. <TITLE>View an Archive</TITLE>
  813. </HEAD>
  814. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  815. <center><font size=6>View an Archive</font></center><hr>
  816. <form method=get action=$script>
  817. <b>Please type the name of the user who's archive you would like to view:</b><br><br>
  818. <input type=text name=archive size=12>
  819. <input type=hidden name=action value=userarchive>
  820. <input type=hidden name=user value="$user">
  821. <input type=hidden name=password value="$INPUT{'password'}">
  822. <input type=submit value="View Archive">
  823. <hr>
  824. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  825. </body>
  826. </html>
  827.  
  828. html
  829.  
  830. exit;
  831.  
  832. }
  833.  
  834. ############################################################################
  835. # EDIT ARCHIVE
  836. ############################################################################
  837.  
  838. sub editarchive {
  839.  
  840. &user;
  841.  
  842. &checkpassword;
  843.  
  844. open (ARCHIVE, "$archivedir/$user.archive");
  845. @lines = <ARCHIVE>;
  846. close (ARCHIVE);
  847.  
  848. print ("Content-type: text/html\n\n");
  849.  
  850. print <<"html";
  851.  
  852. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  853. <HTML>
  854. <HEAD>
  855. <TITLE>Edit Your Archive</TITLE>
  856. </HEAD>
  857. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  858. <font size=5>Edit Your Archive</font><hr>
  859. <b>Select which archive message you would like to delete:</b><br><br>
  860. <form method=get action=$script>
  861. <input type=hidden name=action value=deletearchive>
  862. <input type=hidden name=user value="$user">
  863. <input type=hidden name=password value="$INPUT{'password'}">
  864. html
  865.  
  866. $archivenum = 0;
  867. foreach $line (@lines) {
  868.     ($subject, $date, $post) = split(/\t/, $line);
  869.     print ("<input type=radio name=delete value=$archivenum> <b>$subject</b> posted on $date<br>\n");
  870.     $archivenum += 1;
  871. }
  872.  
  873. print <<"html";
  874. <hr>
  875. <input type=submit value="Delete Archive Message">
  876. <hr>
  877. <center>
  878. [ <a href=\"$script?action=main&user=$user&password=$INPUT{'password'}\">$boardname</a> ]
  879. [ <a href=\"$script?action=login&user=$user&password=$INPUT{'password'}\">Main Menu</a> ]
  880. </center>
  881. <hr>
  882. <a href=http://dreamcatchersweb.com/scripts/>©1997 Dream Catchers Technologies, Inc.</a>
  883. </BODY>
  884. </HTML>
  885. html
  886.  
  887. exit;
  888.  
  889. }
  890.  
  891. ############################################################################
  892. # DELETE ARCHIVE MESSAGES
  893. ############################################################################
  894.  
  895. sub deletearchive {
  896.  
  897. &user;
  898.  
  899. &checkpassword;
  900.  
  901. open (ARCHIVE, "$archivedir/$user.archive");
  902. @lines = <ARCHIVE>;
  903. close (ARCHIVE);
  904.  
  905. $thecount = 0;
  906.  
  907. open (ARCHIVE, ">$archivedir/$user.archive");
  908.  
  909. foreach $line (@lines) {
  910.  
  911.     if ($thecount == $INPUT{'delete'}) {
  912.         $thecount += 1;
  913.     } else {
  914.         print ARCHIVE ("$line");
  915.         $thecount += 1;
  916.     }
  917. }
  918.  
  919. print ("Location: $script?action=userarchive&archive=$user&user=$user&password=$INPUT{'password'}\n\n");
  920.  
  921. exit;
  922.  
  923. }
  924.  
  925. ############################################################################
  926. # VIEW AN ARCHIVE MESSAGE
  927. ############################################################################
  928.  
  929. sub archivemessage {
  930.  
  931. &user;
  932.  
  933. $archive = $INPUT{'archive'};
  934. $archive =~ tr/ /_/;
  935. $archiveview = $INPUT{'archive'};
  936. $archiveview =~ tr/_/ /;
  937.  
  938. $archivenumber = $INPUT{'archivenumber'};
  939.  
  940. open (ARCHIVE, "$archivedir/$archive.archive");
  941. @lines = <ARCHIVE>;
  942. close (ARCHIVE);
  943.  
  944. ($subject, $date, $post) = split(/\t/, $lines[$archivenumber]);
  945.  
  946. $puser = $archive;
  947.  
  948. &getpostuserinfo;
  949.  
  950. print ("Content-type: text/html\n\n");
  951.  
  952. print <<"html";
  953.  
  954. <HTML>
  955. <HEAD>
  956. <TITLE>$subject</TITLE>
  957. </HEAD>
  958. <BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>
  959. <center><font size=6>$subject</font></center><hr>
  960. <table cellpadding=0 cellspacing=0 width=100%>
  961. <tr><td width=15%><b>Posted By:</b></td><td>$archiveview</td></tr>
  962. <tr><td width=15%><b>Email:</b></td><td>$pemail</td></tr>
  963. <tr><td width=15%><b>Date:</b></td><td>$date</td></tr>
  964. </table>
  965. <hr>
  966. $post
  967. <hr>
  968. <center>
  969. [ <a href=\"$script?action=userarchive&archive=$archive&user=$user&password=$INPUT{'password'}\">$archiveview Archive</a> ]
  970. [ <a href=\"$script?action=main&user=$user&password=$INPUT{'password'}\">$boardname</a> ]
  971. [ <a href=\"$script?action=login&user=$user&password=$INPUT{'password'}\">Main Menu</a> ]
  972. </center>
  973. </BODY>
  974. </HTML>
  975. html
  976.  
  977. exit;
  978.  
  979. }
  980.  
  981. ############################################################################
  982. # SUB ROUTINES
  983. ############################################################################
  984.  
  985. sub getuserinfo {
  986.  
  987.     open (USER, "$userdir/$user.user");
  988.     @userinfo = <USER>;
  989.     close (USER);
  990.  
  991.     foreach $line (@userinfo) {
  992.         chop ($line) if ($line =~ /\n$/);
  993.     }
  994.  
  995.     if ($userinfo[1] eq "") {
  996.         $aliases = 0;
  997.     } else {
  998.         @aliases = split(/\t/, $userinfo[1]);
  999.         $aliases = @aliases;
  1000.     }
  1001.  
  1002.     if ($userinfo[2] eq 'none') {
  1003.         $email = "Not Given";
  1004.     } else {
  1005.         $email = "<a href=mailto:$userinfo[2]>$userinfo[2]</a>";
  1006.     }
  1007.  
  1008.     if ($userinfo[3] eq 'yes') {
  1009.         $userarchive = "available";
  1010.     } else {
  1011.         $userarchive = "not available";
  1012.     }
  1013.  
  1014. }
  1015.  
  1016.  
  1017. sub checkpassword {
  1018.  
  1019.     unless ($user eq 'guest') {
  1020.  
  1021.         unless (-e "$userdir/$user.user") {
  1022.             &userdoesntexist;
  1023.         }
  1024.  
  1025.         $userpassword = crypt($INPUT{'password'}, sb);
  1026.  
  1027.         open (USER, "$userdir/$user.user");
  1028.         $password = <USER>;
  1029.         close (USER);
  1030.  
  1031.         chop ($password) if ($password =~ /\n$/);
  1032.  
  1033.         unless ($password eq $userpassword) {
  1034.             print ("Content-type: text/html\n\n");
  1035.             print ("<html><BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>\n");
  1036.             print ("<font size=5>You Entered an Illegal Password</font>\n");
  1037.             print ("</body></html>\n");
  1038.             exit;
  1039.         }
  1040.     }
  1041.  
  1042. }
  1043.  
  1044. sub getdate {
  1045.  
  1046.     $day = `$dateprogram +"%d"`;
  1047.     chop ($day) if ($day =~ /\n$/);
  1048.  
  1049.     unless ($day == 10 || $day == 20 || $day == 30) {
  1050.         $day =~ tr/0/ /;
  1051.     }
  1052.  
  1053.     $date = `$dateprogram +"%B $day, %Y"`;
  1054.     chop ($date) if ($date =~ /\n$/);
  1055.  
  1056. }
  1057.  
  1058. sub usernametaken {
  1059.  
  1060.     print ("Content-type: text/html\n\n");
  1061.     print ("<html><BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>\n");
  1062.     print ("<font size=5>The User Name you selected is already in use, please choose another</font>\n");
  1063.     print ("</body></html>\n");
  1064.     exit;
  1065.  
  1066. }
  1067.  
  1068. sub userdoesntexist {
  1069.  
  1070.     print ("Content-type: text/html\n\n");
  1071.     print ("<html><BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>\n");
  1072.     print ("<font size=5>You Entered an Illegal User Name</font>\n");
  1073.     print ("</body></html>\n");
  1074.     exit;
  1075. }
  1076.  
  1077. sub requireuser {
  1078.  
  1079.     print ("Content-type: text/html\n\n");
  1080.     print ("<html><BODY BGCOLOR=$bgcolor TEXT=$textcolor LINK=$linkcolor>\n");
  1081.     print ("<font size=5>You Did Not Enter a User Name, Please Do So</font>\n");
  1082.     print ("</body></html>\n");
  1083.     exit;
  1084. }
  1085.  
  1086. sub getpostuserinfo {
  1087.  
  1088.     open (USER, "$userdir/$puser.user");
  1089.     @puserinfo = <USER>;
  1090.     close (USER);
  1091.  
  1092.     foreach $line (@puserinfo) {
  1093.         chop ($line) if ($line =~ /\n$/);
  1094.     }
  1095.  
  1096.     if ($puserinfo[1] eq "") {
  1097.         $paliases = 0;
  1098.     } else {
  1099.         @paliases = split(/\t/, $puserinfo[1]);
  1100.         $paliases = @paliases;
  1101.     }
  1102.  
  1103.     if ($puserinfo[2] eq 'none') {
  1104.         $pemail = "Not Given";
  1105.     } else {
  1106.         $pemail = "<a href=mailto:$puserinfo[2]>$puserinfo[2]</a>";
  1107.     }
  1108.  
  1109.     if ($puserinfo[3] eq 'yes') {
  1110.         $puserarchive = "available";
  1111.     } else {
  1112.         $puserarchive = "not available";
  1113.     }
  1114.  
  1115. }
  1116.  
  1117. sub getpostunderinfo {
  1118.  
  1119.     $filetoexist = "$messagedir/$postunder.txt";
  1120.  
  1121.     @atribs = stat("$filetoexist");
  1122.  
  1123.     if ($atribs[7] > 0) {
  1124.  
  1125.         open (OVER, "$filetoexist");
  1126.         ($osubject, $oname, $opostunder, $oresponses, $odate, $opuser, $opost) = <OVER>;
  1127.         close (OVER);
  1128.  
  1129.     } else {
  1130.  
  1131.         open (OVER, "$responsedir/$postunder.txt");
  1132.         ($osubject, $oname, $opostunder, $oresponses, $odate, $opuser, $opost) = <OVER>;
  1133.         close (OVER);
  1134.  
  1135.     }
  1136.  
  1137.     chop ($osubject) if ($osubject =~ /\n$/);
  1138.     chop ($oname) if ($oname =~ /\n$/);
  1139.     chop ($opostunder) if ($opostunder =~ /\n$/);
  1140.     chop ($oresponses) if ($oresponses =~ /\n$/);
  1141.     chop ($odate) if ($odate =~ /\n$/);
  1142.     chop ($opuser) if ($opuser =~ /\n$/);
  1143.     chop ($opost) if ($opost =~ /\n$/);
  1144. }
  1145.  
  1146. sub getresponseinfo {
  1147.  
  1148.     open (OVER, "$responsedir/$response.txt");
  1149.     ($rsubject, $rname, $rpostunder, $rresponses, $rdate, $rpuser, $rpost) = <OVER>;
  1150.     close (OVER);
  1151.  
  1152.     chop ($rsubject) if ($rsubject =~ /\n$/);
  1153.     chop ($rname) if ($rname =~ /\n$/);
  1154.     chop ($rpostunder) if ($rpostunder =~ /\n$/);
  1155.     chop ($rresponses) if ($rresponses =~ /\n$/);
  1156.     chop ($rdate) if ($rdate =~ /\n$/);
  1157.     chop ($rpuser) if ($rpuser =~ /\n$/);
  1158.     chop ($rpost) if ($rpost =~ /\n$/);
  1159.  
  1160. }
  1161.  
  1162. sub user {
  1163.  
  1164.     $user = $INPUT{'user'};
  1165.     $userview = $INPUT{'user'};
  1166.     $userview =~ tr/_/ /;
  1167.     $user =~ tr/ /_/;
  1168.  
  1169. }
  1170.