Location: PHPKode > projects > Open ShareLive > F3-OSL-pre_alpha-2005_05_30/discuss.php
<?php 
/******************************************************************************
*
*    Open ShareLive (main site code)
*    Copyright (C) 2002-2005  ShareLive
*
*    This program is free software; you can redistribute it and/or
*    modify it under the terms of the GNU General Public License
*    as published by the Free Software Foundation; either version 2
*    of the License, or (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
******************************************************************************/

include("tmpl_top.php") ?>
<?php

	require("backend/date_functions.php");

	if (!$pid=$_GET[pid]) {
		echo "Error: missing pid";
		exit;
	}

	$q = mysql_query("SELECT * FROM ".$dbprefix."shares WHERE rel_id=$pid");

	if (!mysql_num_rows($q)) {
		echo "Error: pid does not have any associated release or request";
		exit;
	}

	$row = mysql_fetch_array($q);

?>
            <h2><strong>Discuss <?php echo $row[str_full] ?></strong></h2>
              <?php
				$q = mysql_query("SELECT *, ".$dbprefix."users.username, ".$dbprefix."users.user_id FROM ".$dbprefix."comments INNER JOIN ".$dbprefix."users ON ".$dbprefix."comments.user_id=".$dbprefix."users.user_id INNER JOIN ".$dbprefix."shares ON ".$dbprefix."comments.rel_id = ".$dbprefix."shares.rel_id WHERE ".$dbprefix."comments.rel_id=$pid ORDER BY datetime");
//				echo "SELECT *, users.username FROM comments INNER JOIN users ON comments.user_id=users.user_id INNER JOIN shares ON comments.rel_id = shares.rel_id WHERE rel_id=$pid ORDER BY datetime";
				if ($q && mysql_num_rows($q)) {
					while($row = mysql_fetch_array($q)) {

						$c_top = "#CCCCCC";					// others (greys)
						$c_mid = "#E5E5E5";
						$c_btm = "#F5F5F5";
						$c_ttx = "#000000";
						$c_stx = "#000000";
						$c_lnk = "#000000";

						if ($row[user_id]==$row[req_userid]) {
							$c_top = "#FB8B39";					// requester colours
							$c_mid = "#F8CF85";
							$c_btm = "#FCF3E2";
							$c_ttx = "#FFFFFF";
							$c_stx = "#000000";
							$c_lnk = "#000000";
						}

						if ($row[user_id]==$row[rel_userid]) {
							$c_top = "#8BB32F";					// releaser colours
							$c_mid = "#E8F3BA";
							$c_btm = "#F8FCEB";
							$c_ttx = "#FFFFFF";
							$c_stx = "#000000";
							$c_lnk = "#000000";
						}

						if ($row[level] > 1) {
							$c_top = "#2964BC";					// moderator colours
							$c_mid = "#5F92CB";
							$c_btm = "#E8EFF9";
							$c_ttx = "#FFFFFF";
							$c_stx = "#FFFFFF";
							$c_lnk = "#FFFFFF";
						}

						if ($row[level] == 0) {
							$c_top = "#990000";					// logger colours
							$c_mid = "#D50000";
							$c_btm = "#FFEAEA";
							$c_ttx = "#FFFFFF";
							$c_stx = "#FFFFFF";
							$c_lnk = "#FFFFFF";
						}



			?></h2>
              </h2>
            <table width="100%" border="0" cellspacing="0" cellpadding="1">
              <tr>
                <td bgcolor="<?php echo $c_top ?>"><table width="100%" border="0" cellspacing="0" cellpadding="4">
                    <tr>
                      <td bgcolor="<?php echo $c_top ?>" class="cattitle"><strong><font color="<?php echo $c_ttx ?>"><?php echo $row['subject'] ?></font></strong></td>
                    </tr>
                    <tr>
                      <td bgcolor="<?php echo $c_mid ?>" class="smallprint"><font color="<?php echo $c_stx ?>">Posted
                        by <strong><?php echo "<a href=\"profile.php?uid=$row[user_id]\"><font color=\"$c_lnk\">$row[username]</font></a>" ?></strong> on <strong><?php echo date("d F Y",$row['datetime']) . "</strong> at <strong>". date("H:i", $row['datetime']); ?></strong>
						<?php
							if ($is_admin) {
								echo " [<a href=\"delmsg.php?cid=$row[comment_id]\">Delete</a>]";
							}
						?></font></td>
                    </tr>
                    <tr>
                      <td bgcolor="<?php echo $c_btm ?>" class="bodytext">
                      <?php
                      	require_once("backend/functions.php");

												$message = show_emotions($row['message']);

                        $splitmessasge = explode ("ed2k://", $message);
                        $i=0;
                        foreach($splitmessasge as $ed2klinks) {
                          if (!$i == 0) {
                            $splitmessasge[$i] = 'ed2k://'.$splitmessasge[$i];
                          }
                          $found_ed2klink = '';
                          eregi("(ed2k:(//)?\|(file|server)\|[^\|]+\|[0-9]+\|[0-9a-f]{32}\|/)", $splitmessasge[$i], $found_ed2klink);
                          $found_ed2klink = $found_ed2klink[1];
                          if (ed2k_to_link($found_ed2klink) <> '') {
                            $splitmessasge[$i] = str_replace($found_ed2klink, ed2k_to_link($found_ed2klink), $splitmessasge[$i]);
                          }
                          echo $splitmessasge[$i];
                          $i++;
                        }
                      ?>
                      </td>
                    </tr>
                  </table></td>
              </tr>
            </table><br>
            <?php
					}
				}

				if (QuickCheck()){
					$q = mysql_query("SELECT * FROM ".$dbprefix."comments_notify WHERE rel_id=$pid AND user_id=$uid");
					if (!mysql_num_rows($q)) {
						echo '<a href="discuss_notify.php?pid=' . $pid . '">Subscribe to this Discussion</a>';
					} else {
						mysql_query("UPDATE ".$dbprefix."comments_notify SET email_waiting = 0 where rel_id=$pid AND user_id='$_SESSION[userid]'");
						echo '<a href="discuss_notify.php?pid=' . $pid . '">UnSubscribe from this Discussion</a>';
					}
				} else {
					#No need to show anything, none users can't subscribe
				}

			?>
            <form action="addmsg.php" method="post" name="msg" id="msg">
              <p class="newstitle"><strong>Post a New Message</strong></p>
              <p class="bodytext">If you are logged in, you may post a message.
                You may use limited HTML including links, bold and italic tags
                to format your messages. There is a 1000 character limit for message
                text and 60 character limit for the subject line.</p>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr valign="top">
                  <td width="150" class="smallprint"><strong>Subject<br>
                    </strong>Max 60 chars</td>
                  <td>
                    <input name="title" type="text" id="title" size="42"></td>
                </tr>
                <tr valign="top">
                  <td class="smallprint">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr valign="top">
                  <td class="smallprint"><strong>Message<br>
                    </strong> 1000 characters max<br>
                    Limited HTML </td>
                  <td>
                    <textarea name="message" cols="32" rows="5" id="message"></textarea>
                    <input name="pid" type="hidden" id="pid" value="<?php echo $_GET[pid] ?>"></td>
                </tr>
                <tr>
                  <td class="smallprint">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td class="smallprint">&nbsp;</td>
                  <td>
<input type="submit" name="Submit" value="Post"></td>
                </tr>
              </table>
            </form>
            <a href="view.php?pid=<?php echo $_GET[pid] ?>" class="bodytext">&lt;&lt; Back to Request/Release</a><br>
            <p><strong></strong><span class="smallprint"><strong>Post Colours<br>
              </strong>Use the following colours to quickly identify who's posting
              what.</span></p>
            <table width="415" border="0" cellpadding="0" cellspacing="3" class="smallprint">
              <tr>
                <td width="14" bgcolor="#2964BC">&nbsp;</td>
                <td width="84">&nbsp;Moderator</td>
                <td width="293"><font color="#666666">may edit and remove posts</font></td>
              </tr>
              <tr>
                <td bgcolor="#8BB32F">&nbsp;</td>
                <td>&nbsp;Releaser</td>
                <td><font color="#666666">provided the ed2k links on ShareLive</font></td>
              </tr>
              <tr>
                <td bgcolor="#FB8B39">&nbsp;</td>
                <td>&nbsp;Requester</td>
                <td><font color="#666666">made the original request</font></td>
              </tr>
              <tr>
                <td bgcolor="#CCCCCC">&nbsp;</td>
                <td> &nbsp;Normal User</td>
                <td><font color="#666666">&nbsp;</font></td>
              </tr>
            </table>
            <?php include("tmpl_foot.php"); ?>
Return current item: Open ShareLive