Location: PHPKode > projects > WH Community > wh_community/mypostings.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><h1>' . $lang['my_posts'] . '</h1></td>
		</tr>';
		
		include_once('functions/bbcode.php');
		include_once('functions/badwords.php');
		
        $query = "SELECT post_id, post_by FROM posts WHERE post_by = " . (int)$_SESSION['user_id'] . "";
        $result = mysql_query($query) OR die(mysql_error());

		if(!$result) {
		
        echo '<tr><td><span class="false">' . $lang['no_posts_written'] . '.</span><br><br></td></tr>';

            }else{

            if(intval(mysql_num_rows($result)) == 0) {
            
            echo '<tr><td><span class="false">' . $lang['no_posts_written'] . '.</span><br><br></td></tr>';

        }else{
		
		echo '<tr>';
		
		$allposts = mysql_query("SELECT post_id, post_by FROM posts WHERE post_by = " . (int)$_SESSION['user_id'] . "") OR die(mysql_error());
		$totalposts = intval(mysql_num_rows($allposts));
		
		if($totalposts > 0) {
		
		echo '<td><span class="right"><u>' . $lang['you_have_already'] . ' ' . $totalposts . ' ' . $lang['posts_written'] . '!</u></span></td>';
		
    		}else{
    		
    		echo '<td><span class="false">' . $lang['no_posts_written'] . '!</u></span></td>';
            }
        
    	echo '</tr>';
		
		$pfad = $_SERVER['PHP_SELF'];
		$query = mysql_query("SELECT post_id, post_by FROM posts WHERE post_by = " . (int)$_SESSION['user_id'] . "") OR die(mysql_error());
		$total = intval(mysql_num_rows($query));
		$seiten = ceil($total / $datensaetze_pro_mypost);
		
		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="mypostings.php?id=' . $_SESSION['user_id'] . '&page=' . $first . '" title="' . $lang['goto_first_page'] . '" class="topicby">&laquo; ' . $lang['first'] . ' ...</a>';      
			}
		
		if($page != 1) {
			$prev = $page-1;
			$links[] = '<a href="mypostings.php?id=' . $_SESSION['user_id'] . '&page=' . $prev . '" title="' . $lang['page_back'] . '" class="topicby"> &laquo;</a>';     
			}
		
		for($i = $off; $i <= ($page + $danach); $i++) {
		if($i != $page) {
			$links[] = '<a href="mypostings.php?id=' . $_SESSION['user_id'] . '&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="mypostings.php?id=' . $_SESSION['user_id'] . '&page=' . $next . '" title="' . $lang['next_page'] . '" class="topicby"> &raquo;</a>';
			}
		
		if($seiten - $page - $p > 0 ) {
			$last = $seiten; 
			$links[] = '<a href="mypostings.php?id=' . $_SESSION['user_id'] . '&page=' . $last . '" title="' . $lang['last_page'] . '" class="topicby">... ' . $lang['last'] . ' &raquo;</a>';
			}
		
		$start = ($page-1) * $datensaetze_pro_mypost;
		$link_string = implode(" ", $links);
		
		$abfrage = "SELECT
						posts.post_id,
						posts.post_content,
						posts.post_date,
						posts.post_topic,
						posts.post_by,
						topics.topic_id,
						topics.topic_subject,
						topics.topic_cat,
						categories.cat_id,
						categories.cat_name,
						users.user_id,
						users.user_name
					FROM
						posts
					LEFT JOIN
						topics
					ON
						posts.post_topic = topics.topic_id
					LEFT JOIN
						categories
					ON
						topics.topic_cat = categories.cat_id
					LEFT JOIN
						users
					ON
						posts.post_by = users.user_id
					WHERE
						post_by = '" . (int)$_SESSION['user_id'] . "'
					ORDER BY
						post_id DESC
					LIMIT
						$start,$datensaetze_pro_mypost";
		
		echo '<tr><td>
		      <table width="100%">';
		
		$result = mysql_query($abfrage) OR die(mysql_error());
		$total = intval(mysql_num_rows($result));
		
		if($result) {
		
		echo '<tr>
		      <td colspan="2"><p><small><strong><u>' . $total . '</u></strong> ' . $lang['posts_on_page'] . ':</small></p></td>
		      </tr>';
		
		while($row = mysql_fetch_assoc($result)) {
		    
		    $message = strip_tags($row['post_content']);
    		$message = str_replace("\\r\\n","<br>", $message);
		    
    		echo '<tr>
        		  <td width="100" valign="top"><span class="blue">' . $lang['category'] . ':</span></td>
        		  <td valign="top"><a href="category.php?id=' . (int)$row['cat_id'] . '">' . htmlentities($row['cat_name'], ENT_QUOTES) . ' </a></td>
        		  </tr>
        		  <tr>
        		  <td width="100" valign="top"><span class="blue">' . $lang['topic'] . ':</span></td>
        		  <td valign="top"><a href="topic.php?id=' . (int)$row['topic_id'] . '">' . htmlentities($row['topic_subject'], ENT_QUOTES) . ' </a></td>
        		  </tr>
        		  <tr>
        		  <td width="100" valign="top"><span class="blue">' . $lang['on_b'] . ':</span></td>
        		  <td valign="top"><em>';
            
                  if($language == "de") {
                      echo date('d.m.Y - H:i', strtotime($row['post_date']));
        
                  }elseif($language == "en") {
                      echo date('Y-m-d - H:i', strtotime($row['post_date'])); }
            
            echo '</em></td>
    		      </tr>
    		      <tr>
    		      <td width="100" valign="top"><span class="blue">' . $lang['post'] . ':</span><br><br></td>
    		      <td valign="top">' . parseBBCode2HTML(delBad(nl2br(stripslashes($message)))) . '<br><br><br></td>
    		      </tr>';
    		      }
		
		echo '</table>';
		
		echo '<span class="pages_main">' . $lang['page'] . ' <u>' . $page . '</u> ' . $lang['by'] . ' ' . $seiten . '</span>';
		echo $link_string;
		}
		
		echo '</td></tr>';
		
        }}}
		
		echo '</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