<?
if(array_key_exists('Action', $_GET))
{
  if($_GET['Action'] == 'CustomizeNewsSave')
  {
    $Checkbox = array('' => 0, 'on' => 1);
//    print_r($_POST);
    $Setting = array();
    for($I = 0; $I < $_POST['NewsCategoryCount']; $I++)
    {
      $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1));
    }
//    print_r($Setting);
    $_COOKIE['NewsSetting'] = serialize($Setting);
    setcookie('NewsSetting', $_COOKIE['NewsSetting']);
  }
}


include_once('style.php');
ShowHeader('Vítejte na <strong>Centrále!</strong> - serveru komunitní počítačové sítě <strong>ZdechovNET</strong>','Rozcestník');
include_once('is/db.php');
//include_once('is/global.php');
DB_Init('localhost','root','','share');

?>

<script type="text/javascript">
<!--
function openClient(client_type)
{
  if(client_type=="java")clientWindow = window.open("http://go.icq.com/icq2go/web.html","ICQ2Go","left=20,top=20,width=156,height=446,toolbar=0,resizable=0");
  else clientWindow = window.open("http://go.icq.com/icq2go/flicq.html","ICQ2Go","left=20,top=20,width=176,height=441,toolbar=0,resizable=0");
}

var predchozi = 'first'; 

function zobraz(idecko)
{
  skryj(predchozi);
  el=document.getElementById(idecko).style;
  el.display='block';
  predchozi = idecko;
}

function skryj(idecko)
{
  if(idecko != 'first')
  {
    el=document.getElementById(idecko).style;
    el.display='none';
  }
}
//-->
</script>

<table width="100%"><tr><td valign="top">
<?
DB_Init('localhost','root','','is');
?>

<table width="100%">
<tr><td width="20%" valign="top">
<strong>Důležité odkazy:</strong><br>
<img alt="" src="images/favicons/money.gif" width="16" height="16"> <a href="/finance/">Finance</a><br>
<img alt="" src="images/favicons/chart.gif" width="16" height="16"> <a href="/statistic/trafficview2.php">Statistika</a><br>
<img alt="" src="images/favicons/prohledavac_sdileni.gif" width="15" height="15"> <a href="/share">Prohledat sdílení</a><br>
<img alt="" src="images/favicons/comp.gif" width="16" height="16"> <a href="/userlist.php">Seznam uživatelů</a><br>
<img alt="" src="images/favicons/comp.gif" width="16" height="16"> <a href="/hostlist.php">Seznam počítačů</a><br>
<img alt="" src="images/favicons/sunrisechat.gif" width="16" height="16"> <a href="/sunrisechat/history.php">Historie SunriseChatu</a><br>
<img alt="" src="images/favicons/sunrisechat.gif" width="16" height="16"> <a href="/sunrisechat/webchat.php">Webový SunriseChatu</a><br>
<img alt="" src="images/favicons/discus.gif" width="16" height="16"> <a href="/forum">Diskusní fórum</a><br>
<img alt="" src="images/favicons/openwebmail.gif" width="16" height="16"> <a href="https://centrala.zdechov.net/cgi-bin/openwebmail/openwebmail.pl">WebMail</a><br>
<img alt="" src="images/favicons/apple.gif" width="16" height="16"> <a href="/jidelna">Jídelníček</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="http://tv.zdechov.net/">Televize</a><br>
<img alt="" src="images/favicons/cube.gif" width="16" height="16"> <a href="http://game-server.zdechov.net/">Herní server</a><br>
<img alt="" src="images/favicons/cfix.gif" width="16" height="16"> <a href="/farnost">Rozpis mší</a><br>
<img alt="" src="images/favicons/tel.gif" width="16" height="16"> <a href="/telseznam.php">Telefonní seznam</a><br>
<img alt="" src="images/favicons/pripoj.gif" width="16" height="16"> <a href="/nabidky_pripojeni.php">Nabídky připojení</a><br>
<img alt="" src="images/favicons/zapisy.gif" width="16" height="16"> <a href="/docs/zapisy/zapisy.php">Zápisy ze schůzí</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="/mapy/mapa.php">Mapa Zděchova</a><br>
<img alt="" src="images/favicons/otv_doby.gif" width="16" height="16"> <a href="/otevreno.php">Otvírací doby</a><br>
<img alt="" src="images/favicons/topologie.gif" width="16" height="16"> <a href="/is/topologie.php">Topologie sítě</a><br>
<img alt="" src="images/favicons/satellite.gif" width="16" height="16"> <a href="/is/dostupnost.php">Dostupnost sítě</a><br>
<img alt="" src="images/favicons/tech.gif" width="16" height="16"> <a href="/network.php">Technické informace</a><br>
<img alt="" src="images/favicons/socer.gif" width="16" height="16"> <a href="http://fotbal.zdechov.net/">Fotbal Sokol Zděchov</a><br>
<br>
<strong>Další odkazy:</strong><br>
<img alt="" src="images/favicons/tv.gif" width="16" height="16"> <a href="/tkr.php">Kanály kabelovky</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="/mapy/mapa_nabidka.php">Nabídka mapy</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="/history.php">Historie sítě</a><br>
<img alt="" src="images/favicons/electric.gif" width="16" height="16"> <a href="/merak.php">Měřič spotřeby</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="/sluzby.php">Seznam služeb</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="/ukoly.php">Plány do budoucna</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="/navody.php">Návody</a><br>
<img alt="" src="images/favicons/info.gif" width="16" height="16"> <a href="/infokanal/index.htm">Infokanál</a><br>
<img alt="" src="images/favicons/progman.gif" width="16" height="16"> <a href="/manualy.php">Programátorské manuály</a><br>


<?//<a href="/cgi-bin/openwebmail/openwebmail.pl">Poątovní schránka</a><br>
//<a href="/download/addfile.php">Stahování souborů</a><br>
?>
<br>
</td><td width="13%" valign="top">
<strong>Vyhledávání:</strong><br>
<img alt="" src="images/favicons/www_google_com.gif" width="16" height="16"> <a href="http://www.google.cz/">Google</a><br>
<img alt="" src="images/favicons/morfeo.png" width="16" height="16"> <a href="http://morfeo.centrum.cz">Morfeo</a><br>
<img alt="" src="images/favicons/www_centrum_cz.gif" width="16" height="16"> <a href="http://www.centrum.cz">Centrum</a><br>
<img alt="" src="images/favicons/www_seznam_cz.gif" width="16" height="16"> <a href="http://www.seznam.cz">Seznam</a><br>
<img alt="" src="images/favicons/www_atlas_cz.gif" width="16" height="16"> <a href="http://www.atlas.cz">Atlas</a><br>
<img alt="" src="images/favicons/www_tiscali_cz.gif" width="16" height="16"> <a href="http://www.tiscali.cz">Tiscali</a><br>
<br>
<strong>Užitečné:</strong><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="http://www.zdechov.net">Stránky naší sítě</a><br>
<img alt="" src="images/favicons/www_tvinfo_cz.gif" width="16" height="16"> <a href="http://www.tvinfo.cz/live/televize/cz">Online TV</a><br>
<img alt="" src="images/favicons/www_idos_cz.gif" width="16" height="16"> <a href="http://www.idos.cz/ConnForm.asp?tt=c">Jízdní řády</a><br>
<img alt="" src="images/favicons/www_atlas_cz.gif" width="16" height="16"> <a href="http://tv.atlas.cz">TV programy</a><br>
<img alt="" src="images/favicons/www_icq_com.gif" width="16" height="16"> Web ICQ <a href="javascript:openClient('flash')">Flash</a>&nbsp;<a href="javascript:openClient('java')">Java</a><br>
<img alt="" src="images/favicons/www_centrum_cz.gif" width="16" height="16"> <a href="http://slovniky.centrum.cz">Slovníky</a><br>
<img alt="" src="images/favicons/pocasi.gif" width="16" height="16"> <a href="http://www.meteopress.cz/">Počasí</a><br>
<img alt="" src="images/favicons/www_tzones_cz.gif" width="16" height="16"> <a href="http://www.tzones.cz/">T-Mobile SMS</a><br>
<img alt="" src="images/favicons/www_mvk_cz.png" width="16" height="16"> <a href="http://www.mvk.cz/">Knihovna&nbsp;Vsetín</a><br>
<br>
<strong>Prodej počítačů:</strong><br>
<img alt="" src="images/favicons/www_computershop_cz.png" width="16" height="16"> <a href="http://shop.computershop.cz/eshop/">SOFTCOM</a><br>
<img alt="" src="images/favicons/www_alfacomp_cz.gif" width="16" height="16"> <a href="http://www.alfacomp.cz/php/zbozi.php?akc=2">Alfacomp</a><br>
<img alt="" src="images/favicons/www_petracomp_cz.png" width="16" height="16"> <a href="http://www.petracomp.cz/">Petracomp</a><br>
<img alt="" src="images/favicons/www_tsbohemia_cz.png" width="16" height="16"> <a href="http://interlink.tsbohemia.cz/">TS Bohemia</a><br>
<br>
<?
/*
<strong>Osobní stránky:</strong><br>
<img alt="" src="images/favicons/bomi.gif" width="16" height="16"> <a href="~mirek/">Miroslav Hajda</a><br>
<img alt="" src="images/favicons/clear.gif" width="16" height="16"> <a href="~george/">Jiří Hajda</a><br>
*/
?>
</td>
<td width="15%" valign="top">
<?
// Zobrazení seznamu online počítačů
echo('<strong>Online počítače:</strong><br><span style="font-size: smaller;">');
DB_Query('SELECT * FROM hosts WHERE online=1 AND show_online=1 ORDER BY name');
while($Row  = DB_Row())
{
  echo($Row['name'].'<br>');
}
echo('</span>');

echo('<br>');

// Zobrazení seznamu neplaticich uzivatelu
echo('<strong>Dlužníci:</strong><br><span style="font-size: smaller;">');
DB_Query('SELECT * FROM users WHERE cash<0 ORDER BY cash');
while($Row  = DB_Row())
{
  echo($Row['fullname'].'<br>');
}
echo('</span>');
?>

</td></tr></table>
<?

// Zobrazení času běhu počítače
$Data = explode(' ',exec('uptime'));
$Data = array_slice($Data,3,-8);
$Uptime = '';
foreach($Data as $Item)
{
  if(strpos($Item,':')) $Uptime .= substr($Item,0,-1).' hodin';
  else $Uptime .= $Item.' ';
}
$Uptime = str_replace('2 days,','2 dny a',$Uptime);
$Uptime = str_replace('3 days,','3 dny a',$Uptime);
$Uptime = str_replace('4 days,','4 dny a',$Uptime);
$Uptime = str_replace('days,','dní a',$Uptime);
$Uptime = str_replace('day,','den a',$Uptime);
$Uptime = str_replace('min,','minut',$Uptime);
echo('Server běží '.$Uptime);

?>
</td><td width="50%" valign="top" style="font-size: smaller;">
<?

$File = fopen('/tmp/temperature2','r');
$Teplota = fgets($File);
$Teplota = round($Teplota*10)/10;
fclose($File);


echo('<table width="100%"><tr><td><strong>Aktuálně:</strong></td><td align="right">
<a href="?Action=CustomizeNews">Upravit</a></td></tr></table>');

$NewsCountPerCategory = 3;
$UploadedFilesFolder = 'aktuality/uploads/';

if(array_key_exists('NewsSetting', $_COOKIE))
  $NewsSetting = unserialize($_COOKIE['NewsSetting']);
  else 
$NewsSetting = array(
  array('CategoryId' => 5, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 3, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 1, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 2, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 4, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 6, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 8, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 9, 'Enabled' => 1, 'ItemCount' => 3),
  array('CategoryId' => 10, 'Enabled' => 1, 'ItemCount' => 3),
);

if(array_key_exists('Action', $_GET))
{
  if($_GET['Action'] == 'CustomizeNews')
  {
    echo('<form action="?Action=CustomizeNewsSave" method="post">');
    echo('<table cellspacing="0">');
    $I = 0;
    foreach($NewsSetting as $SettingItem)
    {
      DB_Select('news_category', '*', 'id='.$SettingItem['CategoryId']);
      $NewsCategory = DB_Row();
      echo('<tr><td>'.$NewsCategory['caption'].'</td><td><input type="checkbox" name="NewsCategoryEnabled'.$I.'"');
      if($SettingItem['Enabled'] == 1) echo(' CHECKED'); 
      echo('></td>'.
      '<td><input type="text" size="1" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'">'.
      '<input type="hidden" name="NewsCategoryId'.$I.'" value="'.$SettingItem['CategoryId'].'"></td></tr>');
      $I++;
    }
    echo('</table><input type="hidden" name="NewsCategoryCount" value="'.count($NewsSetting).'"><input type="submit" value="Uložit"></form>');
  }
}

echo('<div onmouseout="skryj(predchozi)">');
function ShowNews($Category, $ItemCount)
{
  global $NewsCategoryNames, $NewsCountPerCategory, $UploadedFilesFolder;

  DB_Select('news_category', '*', 'id='.$Category);
  $Row = DB_Row();
  echo('<table cellspacing="0" cellpadding="0" border="0" width="100%" style="font-size: small; padding-bottom: 5px;"><tr>');
  echo('<td width="40%">'.$Row['caption'].'</td><td width="80%" align="right">');
  echo('<a href="aktuality/index.php?category='.$Category.'">Zobrazit všechny aktuality</a>&nbsp;');
  if($Row['permission'] == 1) echo('<a href="aktuality/index.php?action=add&amp;category='.$Category.'">Přidat aktualitu</a>&nbsp;');
  echo('</td></tr><tr><td colspan="2">');
  echo('<table cellspacing="0" width="100%" style="padding: 2px 2px 2px 2px; font-size: small; border-style: solid; border-color: red; border-width: 1; background-color: #FFF0F0;">');
  DB_Query('SELECT * FROM news WHERE category='.$Category.' ORDER BY date DESC LIMIT 0,'.$ItemCount);
//echo('<table cellpadding="0" cellspacing="0" width="100%"><tr><td>');
  $Index = 0;
  $FontSize = 12;
  while($Row  = DB_Row())
  {
    echo('<tr><td onmouseover="zobraz('."'new".$Category.$Index."'".')" style="cursor: pointer; margin: 0px;"><table cellspacing="0" cellpadding="0" style="padding: 0px; margin: 0px; font-size: small; color: red;" width="100%">
<tr><td style="font-size: '.$FontSize.'pt"><strong>'.$Row['title'].'</strong></td>
<td align="right" style="font-size: '.$FontSize.'pt">'.$Row['author'].' ('.HumanDate($Row['date']).')</td></tr></table>');
    echo('<div id="new'.$Category.$Index.'" class="skryty" style="display: none; border-width: 1; border-style: solid; border-color: blue; padding: 3px; font-size: 9pt;">'.$Row['content']);

      if($Row['enclosure'] != '')
      { 
        echo('<br>Přílohy: ');
        $Enclosures = explode(';', $Row['enclosure']);
 	 foreach($Enclosures as $Enclosure)
	 {
	  if(file_exists($UploadedFilesFolder.$Enclosure)) echo(' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>');
	 }
      }

    echo('</div></td></tr>');
    $Index = $Index + 1;    
    $FontSize = $FontSize - 1;
  }
  echo('</table></td></tr></table>'."\n\n");
}
foreach($NewsSetting as $SettingItem)
  if($SettingItem['Enabled'] == 1) ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount']);

echo('<a href="aktuality/subscription.php"><img style="margin: 0px 0px 0px 0px;" border="0" src="images/rss20.png" alt="Aktuality přes RSS"></a>  <a href="aktuality/subscription.php">Automatické sledování novinek</a>');

//echo('</td></tr></table>'
?>
</div></td></tr></table>
<?
//if(IsInternetAddr()) echo('Internet'); else echo('LAN');

ShowFooter();

?>
