Location: PHPKode > projects > DoubleSpeak > igloo-0.1/html/comments.php
<?

/*
 | This file is part of the Igloo Weblog system.
 | Igloo is available under the GNU General Public
 | License.  For details on the GNU General Public
 | License, read the COPYING or the LICENSE file
 | that you received with this distribution.  If
 | you did not receive one of these files with the
 | distribution, you can find more information at
 | http://www.gnu.org.
 |
 | Igloo is the creation of Brad Johnson.  It is not
 | based on any other works.  Brad Johnson is the
 | sole owner of the copyright, but he welcomes all
 | to take the software, use it, modify it, change
 | it, or to do whatever they can do with it under
 | the provisions of the GNU General Public License.
 |
 | This software is provided as-is, with no warranty
 | whatsoever.  The author is not responsible for
 | anything that may happen as a result of your
 | using this software unless you have purchased an
 | extended warranty.  If you would like to
 | purchase an extended warranty, please contact
 | Brad Johnson via e-mail at hide@address.com
 |
 | This software may destroy your system, date your
 | sister, drink your beer, eat the last of the
 | potato chips, cause Democrats to get elected,
 | kick your dog, burn your house, wreck your car,
 | cause nuclear war, force you to kiss your
 | grandmother, or make you eat brussel sprouts.
 | You have been warned.
 |
 | If it breaks, you may feel free to keep both
 | pieces.
 */

  require "config.inc";
  require "$config[private]/local.inc";
  require "$config[private]/commentfun.inc";
  require "$config[private]/storyfun.inc";

  common_header();

  $date = exec("date +%A,\ %B\ %d\ @\ %l:%M:%S\ %p");

  if ($sid) {

    $status = validate_sid($sid);
    if (!$status) {

      if ($post_a_comment) {

        $comment_vars = array ("sid" => "$sid",
                               "uid" => "$uid",
                               "subject" => "$subject",
                               "comment" => "$comment",
                               "date"    => "$date"     );
        post_comment($comment_vars);
      } elseif ($preview) {
    
        if (!$uid) {
          $uid = 0;
        }
    
        $Results = do_mysql_query("SELECT * FROM users WHERE id='$uid'")
          or die("I could not SELECT FROM the database\n");
        $Row = mysql_fetch_array($Results);
        mysql_free_result($Results);
        $nickname   = $Row[nickname];
        $fake_email = $Row[fake_email];
        $homepage   = $Row[homepage];
    
        $dis_subject = stripslashes($subject);
        $dis_comment = stripslashes($comment);
    
    
        print "                <tr>\n";
        print "                  <td>\n";
        print "                    This is what your comment is going to look like:\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <tr>\n";
        print "                  <td>\n";
        print "                    <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
        print "                    <tr>\n";
        print "                      <td bgcolor=\"$config[color_one]\">\n";
        print "                        <font size=\"2\">\n";
        print "                          <b>$dis_subject</b>\n";
        print "                        </font>\n";
        print "                      </td>\n";
        print "                    </tr>\n";
        print "                    <tr>\n";
        print "                      <td bgcolor=\"#eeeeee\">\n";
        print "                        <font size=\"2\">\n";
        print "                          Posted by $nickname\n";
        if ($fake_email) {
          print "                        [$fake_email]\n";
        }
        if ($homepage) {
          print "                        <a href=\"$homepage\">$homepage</a>\n";
        }
        print "                          on $date\n";
        print "                        </font>\n";
        print "                      </td>\n";
        print "                    </tr>\n";
        print "                    <tr>\n";
        print "                      <td>\n";
        print "                        <blockquote>\n";
        print "                          <font size=\"2\">\n";
        print "                            $comment\n";
        print "                          </font>\n";
        print "                        </blockquote>\n";
        print "                      </td>\n";
        print "                    </tr>\n";
        print "                    </table>\n";
        print "                  </td>\n";
        print "                  <td>\n";
        print "                    &nbsp;\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <tr>\n";
        print "                  <td>\n";
        print "                    &nbsp;\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <tr>\n";
        print "                  <td>\n";
        print "                    Now, you can make changes to your post if you like, or just hit \"Post Comment\"\n";
        print "                    to print it like it is.\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <form action=\"/comments.php\" method=\"post\">\n";
        print "                <tr>\n";
        print "                  <td bgcolor=\"#dddddd\">\n";
        print "                    Subject:\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <tr>\n";
        print "                  <td>\n";
        print "                    <input type=\"text\" name=\"subject\" value=\"$subject\">\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <tr>\n";
        print "                  <td bgcolor=\"#dddddd\">\n";
        print "                    Comment:\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <tr>\n";
        print "                  <td>\n";
        print "                    <textarea wrap=\"virtual\" name=\"comment\" cols=\"50\" rows=\"6\">$comment</textarea>\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                <input type=\"hidden\" name=\"sid\" value=\"$sid\">\n";
        print "                <tr>\n";
        print "                  <td bgcolor=\"#dddddd\">\n";
        print "                    <input type=\"submit\" name=\"preview\" value=\"Preview your comment\">\n";
        print "                    <input type=\"submit\" name=\"post_a_comment\" value=\"Post your comment\">\n";
        print "                    <input type=\"reset\" value=\"Clear this form\">\n";
        print "                  </td>\n";
        print "                </tr>\n";
        print "                </form>\n";
    
      } elseif ($post) {
        if ($re) {
          $Results = do_mysql_query("SELECT * FROM comments WHERE id='$re'")
            or die("I could not SELECT FROM the database\n");
          $Row = mysql_fetch_array($Results);
          mysql_free_result($Results);
          $reply = "Re:  $Row[subject]";
        }
    
        print "              <tr>\n";
        print "                <td>\n";
        print "                  So, you want to post a comment, eh?  Just fill out this snazzy\n";
        print "                  little form, and we'll drop it in the database!\n";
        print "                </td>\n";
        print "              </tr>\n";
        print "              <form action=\"comments.php\" method=\"post\">\n";
        print "              <tr>\n";
        print "                <td bgcolor=\"#dddddd\">\n";
        print "                  Subject:\n";
        print "                </td>\n";
        print "              </tr>\n";
        print "              <tr>\n";
        print "                <td>\n";
        print "                  <input type=\"text\" name=\"subject\" value=\"$reply\">\n";
        print "                </td>\n";
        print "              </tr>\n";
        print "              <tr>\n";
        print "                <td bgcolor=\"#dddddd\">\n";
        print "                  Your comment:\n";
        print "                </td>\n";
        print "              </tr>\n";
        print "              <tr>\n";
        print "                <td>\n";
        print "                  <textarea wrap=\"virtual\" name=\"comment\" cols=\"50\" rows=\"6\"></textarea>\n";
        print "                </td>\n";
        print "              </tr>\n";
        if ($re) {
          print "              <input type=\"hidden\" name=\"re\" value=\"$re\">\n";
        }
        print "              <input type=\"hidden\" name=\"sid\" value=\"$sid\">\n";
        print "              <tr>\n";
        print "                <td bgcolor=\"#dddddd\">\n";
        print "                  <input type=\"submit\" name=\"preview\" value=\"Preview your comment\">\n";
        print "                  <input type=\"submit\" name=\"post_a_comment\" value=\"Post your comment\">\n";
        print "                  <input type=\"reset\" value=\"Clear this form\">\n";
        print "                </td>\n";
        print "              </tr>\n";
        print "              </form>\n";
    
      } else {
    
        display_story($sid);
    
        print "              <tr>\n";
        print "                <td align=\"right\">\n";
        print "                  <a href=\"/comments.php?sid=$sid&post=$uid\">Post a comment</a>\n";
        print "                </td>\n";
        print "              </tr>\n";

        display_comments($sid);
    
      }    

    } else {
      invalid_story_id();
    }
  } else {
    get_story_list();
  }

  common_footer();

?>
Return current item: DoubleSpeak