Location: PHPKode > projects > WH Community > wh_community/discussion.php
<?php require('layout/header.php'); ?>

<div id="content_wrapper">
    <div class="content"><?php

		echo '<h1>' . $lang['discussions'] . '</h1>';
        
		echo '<small>' . $lang['discuss_with_user'] . '!</small><br><br><br>';
		
		echo '<a href="create_disc.php" class="buttons_h medium blue"><span>' . $lang['new_discussion'] . '</span></a><br><br>';
        
        include_once('functions/bbcode.php');
		include_once('functions/badwords.php');
        
        $pfad = $_SERVER["PHP_SELF"];
    	$query = mysql_query("SELECT disc_id FROM discussions") OR die(mysql_error());
    	$total = intval(mysql_num_rows($query));
    	$seiten = ceil($total / $datensaetze_pro_diskussion);

    	if(empty($_GET['page'])) {
    			$page = 1;

    		}elseif($_GET['page'] <= 0 || $_GET['page'] > $seiten) {
    			$page = 1;

    			}else{

    			$page = mysql_real_escape_string($_GET['page']);
    			}

    		$links = array();

    		if(($page - $p) < 1){ $davor = $page - 1;  }else { $davor = $p; }
    		if(($page + $p) > $seiten){ $danach = $seiten - $page; }else{ $danach = $p; }
    			$off = ($page - $davor);

    		if($page- $davor > 1) {
    			$first = 1;
    			$links[] = '<a href="' . $pfad . '?page=' . $first . '" title="' . $lang['goto_first_page'] . '" class="topicby">&laquo; ' . $lang['first'] . ' ...</a>';
    			}

    		if($page != 1) {
    			$prev = $page-1;
    			$links[] = '<a href="' . $pfad . '?page=' . $prev . '" title="' . $lang['page_back'] . '" class="topicby"> &laquo;</a>';
    			}

    		for($i = $off; $i <= ($page + $danach); $i++) {
    		if($i != $page) {
    			$links[] = '<a href="' . $pfad . '?page=' . $i . '" class="topicby">' . $i . '</a>';

    		}elseif($i == $seiten) {
    			$links[] = '<span class="current_main">' . $i . '</span>';

    		}elseif($i == $page) {
    			$links[] = '<span class="current_main">' . $i . '</span>';
    			}
    		}

    		if($page != $seiten) {
    			$next = $page+1;
    			$links[] = '<a href="' . $pfad . '?page=' . $next . '" title="' . $lang['next_page'] . '" class="topicby"> &raquo;</a>';
    			}

    		if($seiten - $page - $p > 0 ) {
    			$last = $seiten;
    			$links[] = '<a href="' . $pfad . '?page=' . $last . '" title="' . $lang['last_page'] . '" class="topicby">... ' . $lang['last'] . ' &raquo;</a>';
    			}

    		$start = ($page-1) * $datensaetze_pro_diskussion;
    		$link_string = implode(" ", $links);
        
		$sql = "SELECT * FROM discussions ORDER BY disc_id DESC LIMIT $start,$datensaetze_pro_diskussion";
		$result = mysql_query($sql) OR die(mysql_error());
		
		if(!$result) {
        
		echo '<p class="false">' . $lang['no_discussions'] . '.</p>';
        
			}else{
            
			if(intval(mysql_num_rows($result)) == 0) {
            
			echo '<br><br><strong>' . $lang['no_discussions'] . '.</strong>';
        
		}else{
		
		echo '<table width="100%" cellpadding="0" class="maintable">
              <tr><td width="750" valign="top">';
		
		while($row = mysql_fetch_assoc($result)) {
        
            $discussionid = $row['disc_id'];
            
            echo '<table width="100%" cellpadding="3" class="maintable">
                  <tr>
                  <td rowspan="3" width="46" valign="top"><img src="images/icons/discussion.png" alt="Avatar"></td>
                  <td width="524" height="25" valign="top"><img src="images/icons/user_small.png" alt="User"> <strong><a href="mailto:' . htmlentities($row['email'], ENT_QUOTES) . '" class="topicby">' . htmlentities($row['author'], ENT_QUOTES) . '</a></strong></td>
                  <td rowspan="3" align="center" width="70" valign="middle">';
                  
                  $allreps = mysql_query("SELECT * FROM opinions WHERE op_id2 = '" . $discussionid . "'") OR die(mysql_error());
		          $replies = mysql_num_rows($allreps);
                  
            echo '<span class="disc_replies">' . (int)$replies . '</span><br><br>
                  <small>' . $lang['reps_ds'] . '</small>
                  
                  </td>
                  <td rowspan="3" align="center" width="110" valign="middle">
                  
                  <span class="disc_views">' . htmlentities($row['views']) . '</span><br><br>
                  <small>' . $lang['views_ds'] . '</small></td>
                  </tr>
                  <tr>
                  <td width="524" valign="bottom"><a href="read_disc.php?id=' . $row['disc_id'] . '" class="disclink">' . htmlentities($row['subject'], ENT_QUOTES) . '</a></td>
                  </tr>
                  <tr>
                  <td width="524"><img src="images/clock.png" alt="' . $lang['by_o'] . '">';

                  if($language == "de") {
                        echo date('d.m.Y - H:i', strtotime($row['date']));

                  }elseif($language == "en") {
                        echo date('Y-m-d - H:i', strtotime($row['date'])); }

            echo ' <small>' . $lang['o_clock'] . '</small></td>
                  </tr>
                  </table>
                  <div id="disc_line">&nbsp;</div>';
                  }
            
            echo $link_string;
                  
            echo '</td>';
            
            $query = "SELECT * FROM opinions ORDER BY op_id DESC";
		    $opinions = mysql_query($query) OR die(mysql_error());
		    
		    echo '<td width="250" valign="top">
                  <span class="news_blue">' . $lang['latest_opinions'] . '</span>';
		    
		    if(!$opinions) {

    		echo '<p class="false">' . $lang['no_opinions'] . '.</p>';
    
    			}else{
    
    			if(intval(mysql_num_rows($opinions)) == 0) {
    
    			echo '<br><br><strong>' . $lang['no_opinions'] . '.</strong>';
    
    		}else{
    		
    		while($op_row = mysql_fetch_assoc($opinions)) {
            
                $message = strip_tags($op_row['opinion']);
                $message = str_replace("\\r\\n","<br>", $message);
                
                echo '<div class="discussion">
                     <img src="images/latest.png" alt="' . $lang['comment'] . '"> <a href="mailto:' . htmlentities($op_row['op_email'], ENT_QUOTES) . '">' . htmlentities($op_row['op_author'], ENT_QUOTES) . '</a>
                     <p>' . ((strlen($message)<6) ? $message : substr(txt_format(delBad($message)),0,110).'...') . '</p>
                     <img src="images/clock.png" alt="' . $lang['o_clock'] . '"><small><em>';
                
                     if($language == "de") {
                            echo date('d.m.Y - H:i', strtotime($op_row['date']));
                
                     }elseif($language == "en") {
                            echo date('Y-m-d - H:i', strtotime($op_row['date'])); }
                
                echo '</em></small></div>';
            
            }}}
        
        echo '</td></tr>
              </table>';
        
        }}
        
		echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community