Location: PHPKode > projects > WH Community > wh_community/userlist.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 colspan="4"><h1>' . $lang['user_list'] . '</h1></td></tr>';
    		
    		echo '<tr><td colspan="4"><table width="100%" cellpadding="0">';
		
		if(isset($_POST['submit'])) {
		$problem = FALSE;
		
		if(empty($_POST['search'])) {
		$problem = TRUE;
		echo '<p class="false">' . $lang['enter_search_term'] . '!</p>
		      <p>[ <a href="userlist.php">' . $lang['go_to_search'] . '</a> ]</p><br>';
		      }
		
		if(!$problem) {
		
		$text = htmlentities($_POST['search']);
		
		$querys = "SELECT
						user_id,
						user_name
				   FROM
						users
				   WHERE
						user_name LIKE '%$text%' OR user_id LIKE '%$text%' OR user_email LIKE '%$text%'
				   ORDER BY
						user_id DESC";
		
		$results = mysql_query($querys) OR die(mysql_error());
		
		if($results) {
		
		echo '<tr>
		      <td colspan="3"><p><small><strong><u>' . mysql_num_rows($results) . '</u></strong> ' . $lang['search_results_found'] . ':</small></p></td>
		      </tr>';
		
		while($row = mysql_fetch_array($results, MYSQL_ASSOC)) {
		
    		echo '<tr>
    		      <td colspan="3">&#8226; <a href="profile.php?user_id=' . $row['user_id'] . '">' . htmlentities($row['user_name'], ENT_QUOTES) . '<br><br></a></td>
    		      </tr>';
    		      }
    		
    		echo '<tr>
    		      <td colspan="3"><p>[ <a href="userlist.php">' . $lang['search_again'] . '?</a> ]</p><br></td>
    		      </tr>';
    		
    			}else{
    			
    			echo '<br><p class="false"><small>' . $lang['no_search_results_found'] . '.</small></p>
    			      <p>[ <a href="userlist.php">' . $lang['go_to_search'] . '</a> ]</p><br>';
    			      }
    		    }
		
		}else{
		
		echo '<tr>
    		  <td width="50%" valign="top"><form id="search" action="userlist.php?search" method="post">
    		  <input type="text" name="search" size="30" class="fields">
    		  <input type="submit" name="submit" class="button" value="' . $lang['search'] . '"><br>
    		  <small>' . $lang['search_reg_user'] . '</small>
    		  </form><br><br></td>';
		
		$abfrage = mysql_query("SELECT user_id FROM users") OR die(mysql_error());
		$total = intval(mysql_num_rows($abfrage));
		
		echo '<td width="50%" align="right" valign="top"><u><strong>' . (int)$total . '</strong> ' . $lang['registered_user'] . '</u><br><br></td></tr>';
		}
		
		echo '</table>
		      </td></tr>';
		
		echo '<tr>
    		  <td width="10%"><span class="blue">User ID</span></td>
    		  <td width="45%"><span class="blue">User Name</span></td>
    		  <td width="25%" align="right"><span class="blue">' . $lang['last_signin'] . '</span></td>
    		  <td width="20%" align="right"><span class="blue">' . $lang['registration'] . '</span></td>
    		  </tr>';
		
		$pfad = $_SERVER['PHP_SELF'];
		$query = mysql_query("SELECT user_id FROM users") OR die(mysql_error());
		$total = intval(mysql_num_rows($query));
		$seiten = ceil($total / $datensaetze_pro_liste);
		
		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_liste;
		$link_string = implode(" ", $links);
		
		$query = "SELECT user_id, user_name, user_date, user_status FROM users ORDER BY user_date DESC LIMIT $start,$datensaetze_pro_liste";
		$result = mysql_query($query) OR die(mysql_error());
		
		if($result) {
		
		while($row = mysql_fetch_assoc($result)) {
		
    		echo '<tr>
    		      <td width="10%">' . (int)$row['user_id'] . '</td>
    		      <td width="45%"><a href="profile.php?user_id=' . (int)$row['user_id'] . '">' . htmlentities($row['user_name'], ENT_QUOTES) . '</a></td>
    		      <td width="25%" align="right">'; if($row['user_status'] > 0) {
    			
    			if($language == "de") {
                    echo date('d.m.Y', strtotime($row['user_status']));
    
                }elseif($language == "en") {
                    echo date('Y-m-d', strtotime($row['user_status'])); }
    		
    		}else{
    		
    		echo '<span class="admin">' . $lang['no_signins'] . '</span>'; }
    		echo '</td><td width="20%" align="right">';
            
                  if($language == "de") {
                      echo date('d.m.Y - H:i', strtotime($row['user_date']));
        
                  }elseif($language == "en") {
                      echo date('Y-m-d - H:i', strtotime($row['user_date'])); }
            
            echo '</td></tr>';
    		}
		
			}else{
			
			echo '<p class="false">' . $lang['no_user_found'] . '.</p>';
			}
		
		echo '<tr><td><br></td></tr>
		      </table>';
		
		echo '<table align="center" class="usertable">
    		  <tr><td><span class="pages_main">' . $lang['page'] . ' <u>' . $page . '</u> ' . $lang['by'] . ' ' . $seiten . '</span>';
		echo $link_string;
		echo '</td></tr></table>';
		}
		
		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