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

<div id="content_wrapper">
    <div class="content"><?php
		
		if((isset($_GET['user_id'])) && (is_numeric($_GET['user_id']))) {
		
		$id = mysql_real_escape_string($_GET['user_id']);
		$id = intval($_GET['user_id']);
	
			}else{
			
			echo '<p align="center" class="false">' . $lang['invalid_id'] . '!</p>';
			exit();
			}
		
		include('functions/bbcode.php');
		include('functions/badwords.php');
		
		echo '<table align="center" class="usertable">
		      <tr><td>
              <h1>' . $lang['user_guestbook'] . '</h1><br></td>
		      </tr>
		      <tr><td><a href="create_gb.php?user_id=' . $id . '" class="css_button">' . $lang['new_gb_entry'] . '</a></td><tr>';
				
		echo '<tr><td>';
		
		$pfad = $_SERVER['PHP_SELF'];
		$query = mysql_query("SELECT gb_id FROM guestbook WHERE gb_id2 = '" . $id . "'");
		$total = intval(mysql_num_rows($query));
		$seiten = ceil($total / $datensaetze_pro_gb);
		
		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="read_gb.php?user_id=' . $id . '&page=' . $first . '" title="' . $lang['goto_first_page'] . '">&laquo; ' . $lang['first'] . ' ...</a>';      
			}
		
		if($page != 1) {
			$prev = $page-1;
			$links[] = '<a href="read_gb.php?user_id=' . $id . '&page=' . $prev . '" title="' . $lang['page_back'] . '"> &laquo;</a>';     
			}
		
		for($i = $off; $i <= ($page + $danach); $i++) {
		if($i != $page) {
			$links[] = '<a href="read_gb.php?user_id=' . $id . '&page=' . $i . '">' . $i . '</a>';
		
		}elseif($i == $seiten) {
			$links[] = '<span class="current">[ <u>' . $i . '</u> ]</span>';  
		
		}elseif($i == $page) {
			$links[] = '<span class="current">[ <u>' . $i . '</u> ]</span>';
			}
		}                
		
		if($page != $seiten) {
			$next = $page+1;
			$links[] = '<a href="read_gb.php?user_id=' . $id . '&page=' . $next . '" title="' . $lang['next_page'] . '"> &raquo;</a>';
			}
		
		if($seiten - $page - $p > 0 ) {
			$last = $seiten; 
			$links[] = '<a href="read_gb.php?user_id=' . $id . '&page=' . $last . '" title="' . $lang['last_page'] . '">... ' . $lang['last'] . ' &raquo;</a>';
			}
		
		$start = ($page-1) * $datensaetze_pro_gb;
		$link_string = implode(" ", $links);
		
		$sql = "SELECT * FROM guestbook WHERE gb_id2 = '" . $id . "' ORDER BY gb_id DESC LIMIT $start,$datensaetze_pro_gb";
		
		$result = mysql_query($sql) OR die(mysql_error());
		
		if(intval(mysql_num_rows($result)) == 0) {
		
		echo '<p class="false">' . $lang['no_gb_entries'] . '.</p>';
		
			}else{
			
			while($row = mysql_fetch_assoc($result)) {
			
    			$message = strip_tags($row['post']);
    			$message = str_replace("\\r\\n","<br>", $message);
    			
    			echo '<table width="100%" cellpadding="5" class="pmtable">
    			      <tr>
    			      <td width="70%"><span class="blue"><u>' . htmlentities($row['name'], ENT_QUOTES) . '</u></span></td>
    			      <td width="30%" align="right"><em>';
                
                      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 ' ' . $lang['o_clock'] . '</em></td>
        			  </tr>
        			  <tr>
        			  <td colspan="2"><div id="gb_line">&nbsp;</div></td>
        			  </tr>
        			  <tr>
        			  <td colspan="2">' . parseBBCode2HTML(delBad(nl2br(stripslashes($message)))) . '</td>
        			  </tr>
        			  <tr>
        			  <td colspan="2"><div id="blog_line">&nbsp;</div></td>
        			  </tr>
        			  <tr>
        			  <td width="70%" height="22" valign="bottom" align="left"><a href="' . htmlentities($row['url'], ENT_QUOTES) . '" target="_blank"><img src="images/icons/homepage.png" width="16" height="16" border="0" title="Homepage"></a><a href="mailto:' . htmlentities($row['email'], ENT_QUOTES) . '"><img src="images/icons/mail.png" width="16" height="16" hspace="6"  border="0" title="E-Mail"></a></td>
        			  <td width="30%" height="22" valign="bottom" align="right"><a href="#top"><img src="images/icons/top_small.png" width="16" height="16" border="0" title="Top"></a></td>
        			  </tr>
        			  </table>';
        			  }
		
		echo '<br><div id="navigation">
		      <span class="pages">' . $lang['page'] . ' <u>' . $page . '</u> ' . $lang['by'] . ' ' . $seiten . '</span>';
		echo $link_string;
		echo '</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