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

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

        if(!isset($_SESSION['signed_in'])) {
        
		echo '<p class="false">' . $lang['just_for_users'] . '!</p>
              <p>' . $lang['you_need_to'] . ' <a href="signin.php">' . $lang['signin_s'] . '</a>. 
              - ' . $lang['not_yet'] . ' <a href="signup.php">' . $lang['registered'] . '</a>?</p>';

		}else{

		echo '<table align="center" class="usertable">
		<tr>
			<td align="center"><ul class="usermenu">
				<li><a href="myprofile.php">' . $lang['my_profile'] . '</a></li>
				<li><a href="guestbook.php">' . $lang['guestbook'] . '</a></li>
				<li><a href="messagebox.php">' . $lang['messagebox'] . '</a></li>
				<li><a href="password.php">' . $lang['password'] . '</a></li>
				<li><a href="inbox.php">' . $lang['inbox'] . '</a></li>
				<li><a href="outbox.php">' . $lang['outbox'] . '</a></li>
				<li><a href="create_pm.php">' . $lang['m_newpm'] . '</a></li>
				<li><a href="mypostings.php">' . $lang['my_posts'] . '</a></li>
				<li><a href="infos.php">' . $lang['informations'] . '</a></li>
				<li><a href="todo.php">' . $lang['m_todo'] . '</a></li>
				<li><a href="news.php">' . $lang['news'] . '</a></li>
			</ul></td>
		</tr>
		<tr>
			<td><br><span class="leftside"><img src="images/icons/news.png" alt="News"> <span class="news_blue">' . $lang['news'] . '</span></span>';
            $newscount = mysql_query("SELECT id FROM news");
            $showcount = intval(mysql_num_rows($newscount));
			
            echo '<span class="rightside"><u><strong>' . $showcount . '</strong> ' . $lang['news_available'] . '</u></span><br><br></td>
		</tr>';
		
		$sql = "SELECT
					id,
					author,
					title,
					text,
					date,
					imageurl
				FROM
					news
				WHERE
					`check` = '1'";
		
		$result = mysql_query($sql) OR die(mysql_error());
		
		
		$pfad = $_SERVER['PHP_SELF'];
		$query = mysql_query("SELECT id FROM news");
		$total = intval(mysql_num_rows($query));
		$seiten = ceil($total / $datensaetze_pro_news);
		
		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_news;
		$link_string = implode(" ", $links);
		
		$abfrage = "SELECT
						id,
						author,
						title,
						text,
						date,
						imageurl
					FROM
						news
					ORDER BY
						id DESC 
					LIMIT
						$start,$datensaetze_pro_news";
		
		$news_result = mysql_query($abfrage) OR die(mysql_error());
		
        if(!$news_result) {
        
        echo '<tr><td><p><strong>' . $lang['no_news_published'] . '.</strong></p></td></tr>';
        
            }else{
        
            if(intval(mysql_num_rows($news_result)) == 0) {
            
            echo '<tr><td><p><strong>' . $lang['no_news_published'] . '.</strong></p></td></tr>';
        
        }else{
		
		while($news_row = mysql_fetch_assoc($news_result)) {
		
    		include_once('functions/bbcode.php');
    		
    		echo '<tr><td>';
    		echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
    		      <tr>
    		      <td width="70%"><h1>' . htmlentities($news_row['title'], ENT_QUOTES) . '</h1></td>
    		      <td width="30%" align="right"><em>';
            
                  if($language == "de") {
                      echo date('d.m.Y - H:i', strtotime($news_row['date']));
        
                  }elseif($language == "en") {
                      echo date('Y-m-d - H:i', strtotime($news_row['date'])); }
            
            echo ' ' . $lang['o_clock'] . '</em></td>
    		      </tr>
    		      <tr>
    		      <td colspan="2"><div id="news_line">&nbsp;</div></td>
    		      </tr>
    		      <tr>
    		      <td align="justify" colspan="2">' . parseBBCode2HTML(nl2br(stripslashes($news_row['text']))) . '<br><br></td>
    		      </tr>
    		      <tr>
    		      <td width="70%"><strong>' . $lang['author'] . ':</strong> <a href="mailto:' . $webmaster . '">' . htmlentities($news_row['author'], ENT_QUOTES) . '</a><br></td>
    		      <td width="30%" align="right"><a href="news.php#top"><img src="images/icons/top_small.png" alt="Top" border="0"></a></td>
    		      </tr>
    		      <tr><td><br><br></td></tr>
    		      </table>';
    		      }
		
		echo '<br><span class="pages_main">' . $lang['page'] . ' <u>' . $page . '</u> ' . $lang['by'] . ' ' . $seiten . '</span>';
		echo $link_string;
		
		}}}
		
		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