<?php
	$nebeneinander = 2;
	$counter = 0;
	$active_page = !empty($_GET['page']) ? $_GET['page'] : 1;
?>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="34%"><div id="s1">
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
<?php
	if ($_SESSION['user_eingeloggt'])
				{
				
				$get_money = mysql_query("SELECT gamecash FROM global_users WHERE gameuser = '".$_SESSION['username']."' LIMIT 1");
				$row_money = mysql_fetch_array($get_money);
				$aktmoney = $row_money['gamecash'];
				
				$redate = explode(" ",$_SESSION['since']);
				
				$formatted_cash = number_format($aktmoney, 0, '.', '.' );
?>
		<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><strong>Logged in as <?php echo $_SESSION['username']; ?></td>
        </tr>
		</table>
		</strong><hr width="80%" size="1" />
		<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr class="login">
          <td width="40%">Cash:</td>
          <td width="60%" align="right"><img src="gfx/content/g-pip12px.png" width="10" height="10" /> <?php echo $formatted_cash; ?></td>
        </tr>
        <tr class="login">
          <td>User since:</td>
          <td align="right"><?php echo $redate[0]." ".$redate[1]." ".$redate[2]; ?></td>
        </tr>
		</table>
		</strong><hr width="80%" size="1" />
		<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<?php 
		if($_SESSION['level'] > 7)
			{
?>
			<tr>
			<td>&nbsp;</td>
			<td align="right"><a href="./admin/">AdminPanel</a></td>  
			</tr>
<?php			
			}
?>	
        <tr>
		<td><a href="index.php?show=editprofile">Edit Profile</a></td>
         <td align="right"><a href="action.php?action=logout&site=<?php echo $_GET['show']; ?>">Logout</a></td>  
        </tr>
      </table><br><br>
<?php
				} else {
?>
      <form id="form1" name="form1" method="post" action="action.php?action=login&site=<?php echo $_GET['show']; ?>">
        <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="login">Username:</td>
          </tr>
          <tr>
            <td><label>
              <input name="loginname" type="text" class="input" id="username" size="35" />
            </label></td>
          </tr>
          <tr>
            <td class="login">Password:</td>
          </tr>
          <tr>
            <td><input name="loginpass" type="password" class="input" id="password" size="35" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
				<td>&nbsp;&nbsp;
              <input type='submit' name='login' value='' class='login_bgImage' />
              </form> &nbsp;&nbsp;&nbsp;</td>
			<td>
			  <form id="form2" name="form2" method="post" action="index.php?show=forgotPW">
			  <input type='submit' name='login' value='' class='getpw_bgImage' /></form></td>
			</tr>
		</table></td>
          </tr>
        </table>
      <br>
<?php
				}
include('serverstatus.php');
?>
    </div></td>
    <td width="66%" align="left" valign="top"><table width="515" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="368" align="left" valign="top" background="gfx/content/news_main_bg.png">

<?php
			
			$result=mysql_query("SELECT COUNT(newstopic) FROM global_news");

			list($entries)=mysql_fetch_row($result);
			$blaettern=new blaettern($active_page, $entries);
			$blaettern->setLinkHref('index.php?show=news&amp;page=');
			$blaettern->setDelimiter1(' ');
			$blaettern->setDelimiter3(', ');
			$blaettern->setLinkActiveMore(' style="font-size:13px;"');
			$blaettern->setLinkFirstLastText('Machst Du Seite 1', 'Machst Du Seite ganz hinten');
			$blaettern->setShowActiveLink('false');
			$blaettern->setShowFirstLast(false);
			$blaettern->setShowNextPrev(false);
			$blaettern->setEntriesPerPage(6);
			$start = ".$blaettern->getEntriesPerPage()." * ".$blaettern->getActivePage().";
			$stop = ".$blaettern->getEntriesPerPage().";
			$result=mysql_query('SELECT * FROM global_news ORDER BY newsdate DESC LIMIT '.($blaettern->getEntriesPerPage() * $blaettern->getActivePage()).', '.$blaettern->getEntriesPerPage());
			while($data = mysql_fetch_array($result))
				{
				
				
					//if ($counter != 0 && ($counter % $nebeneinander == 0)) echo "</tr>\n<tr>\n";
					
					$prozent = number_format(100 / $nebeneinander);
					$newstext = cutter($data['newstext'], 70);
					$datum = date("M d Y",$data['newsdate']);
					$newstext2 = htmlspecialchars($data['newstext']);
					$newstext2 = nl2br($data['newstext']);		
							
							echo "
								<div id='news_overview1'>
									<table width='95%' border='0' cellspacing='0' cellpadding='0' align='center'>
										<tr>
											<td width='79%' align='left' valign='top' class='mainnewshead'>".$data['newstopic']."</td>
											<td width='200' align='right'><strong>".$datum."</strong></td>
										</tr>
										<tr>
											<td align='left' valign='top'>".$newstext."</td>
											<td align='right'>";
											?>
											<a onClick="swap('<?php echo $data['id']; ?>')" href='#'>[open]</a>
											<?php echo "</td>
										</tr>
									</table>
								</div>";
								?>
						<div id='<?php echo $data['id']; ?>' style='display: none; width: 500px; margin-top: -100px; margin-left: -150px; position: absolute; background-color: #333; border: 1px solid #000; z-index: 40; -moz-border-radius: 10px;'><br />
						<table width='90%' border='0' align='center' cellpadding='0' cellspacing='0'>
							<tr>
								<td width="80%" align='left'><p class="mainnewshead"><?php echo $data['newstopic']; ?></p></td>
								<td width="200" align='right'><?php echo $datum; ?></td>
							</tr>
							<tr>
							  <td colspan="2" align='left' class="mainnews"><hr size="1" /></td>
						  </tr>
							<tr>
							  <td colspan="2" align='left' class="mainnews"><?php echo $newstext2; ?></td>
						  </tr>
							<tr>
							  <td colspan="2" align='right'>by <?php echo $data['newsposter']; ?></td>
						  </tr>
						</table>
						<br />
						<table width="20%" border="0" align="center" cellpadding="0" cellspacing="0">
						  <tr>
						    <td align="center"><a onClick="swap('<?php echo $data['id']; ?>')" href='#'>[close]</a></td>
					      </tr>
						</table>
						<br />
						</div>
<?php						
					
							$counter++;
						}
?>	
        <div id="news_overview2"><?php echo $blaettern->create(); ?></div>
        
        </td>
      </tr>
    </table></td>
  </tr>
</table>