Changeset 148 for www/share/index.php


Ignore:
Timestamp:
Feb 15, 2009, 7:59:35 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Přepracován systém generování zobrazení výstupu. Pro nový systím přepsáno mnoho stránek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/share/index.php

    r4 r148  
    11<?php
    22
    3 function ShowTime()
     3include('../global.php');
     4
     5class SharePage extends Page
    46{
    5   echo(date("H:i:s")."<br>\n");
    6   flush();
     7  var $FullTitle = 'Vyhledávání souborů';
     8  var $ShortTitle = 'Vyhledávání souborů';
     9  var $Dependencies = array('Log');
     10  var $MaxNesting = 20; // Maximální vnoření
     11  var $Promene = array( // Automatické zapamatování proměnných
     12    'keyword' => '',
     13    'file_type' => 0,
     14    'size' => '',
     15    'size_method' => 1,
     16    'size_units' => 2,
     17    'online' => 'on',
     18    'order' => 'size DESC',
     19    'page' => '0',
     20    'view' => 1,
     21  );
     22
     23  function ShowTime()
     24  {
     25    return(date("H:i:s")."<br />\n");
     26  }
     27
     28  // Inicializace Logu
     29  //$LogFile = fopen('info.log','w');
     30  function Loguj($Info)
     31  {
     32    //global $LogFile;
     33    //fputs($LogFile,$Info."\n");
     34  }
     35  //Show_Array($GLOBALS);
     36
     37    // Najde cestu ke keřenu
     38  function PlnaCesta($Row)
     39  {
     40    // Vyhledání cesty
     41    $Otec = $Row['parent'];
     42    $Cesta = ''; //$Row['name'];
     43    $i = 0;
     44    while(($Otec > 1) && ($i < $this->MaxNesting))
     45    {
     46      $DbResult = $this->Database->query('SELECT id,name,parent FROM items WHERE id='.$Otec);
     47      $Row = $DbResult->fetch_array();
     48      $this->Loguj('Name: '.$Row['name'].' ID:'.$Row['id'].' Parent:'.$Row['parent']);
     49      $Cesta = $Row['name'].'\\'.$Cesta;
     50      $Otec = $Row['parent'];
     51      $i++;
     52    }
     53    if($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta;
     54    return('\\\\'.$Cesta);
     55  }
     56
     57  // Převede velikost v bajtech na odpovídající jednotky
     58  function PrevedVelikost($Velikost)
     59  {
     60    $Jednotky = array('B','kB','MB','GB','TB','PB','EB');
     61    while($Velikost >= 1024)
     62    {
     63      $Velikost = round($Velikost / 1024 * 10) / 10;
     64      array_shift($Jednotky);
     65    }
     66    return($Velikost.'&nbsp;'.$Jednotky[0]);
     67  }
     68
     69  function Show()
     70  {
     71    if(!$this->System->Modules['User']->CheckPermission('Share', 'Display')) return('Nemáte oprávnění');
     72
     73    // If not only online checkbox checked
     74    if(array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off';
     75
     76    // Default host list view
     77    if((count($_POST) == 0) and (count($_GET) == 0))
     78    {
     79      $_POST['view'] = 1;
     80      $_POST['page'] = 0; 
     81    }
     82
     83    // Toggle order direction
     84    if(array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC';
     85
     86    //print_r($_POST);
     87    foreach($this->Promene as $Index => $Prvek)
     88    {
     89      if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index];
     90      if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
     91      if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
     92      if(($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index];
     93      if(($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = '';
     94      $$Index = $_SESSION[$Index];
     95      //echo('$'.$Index.' = '.$_SESSION[$Index].'<br>');
     96    }
     97    //echo($keyword);
     98    //if($keyword)
     99    //if($keyword != '') $view = '';
     100
     101    $this->Database->select_db('share');
     102
     103    // Log search
     104    if(array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET))
     105      $this->System->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']);
     106
     107    // Zobrazení formuláře
     108    $Output = '<form action="'.$this->System->Config['Web']['RootFolder'].'/share/" method="post">
     109    <input type="hidden" name="view" value="">
     110    <input type="hidden" name="page" value="0">
     111    Hledat: <input type="text" name="keyword" value="'.$keyword.'">';
     112    $Output .= '<input type="submit" value="Hledat">&nbsp;Typ: <select name="file_type" id="file_type">';
     113    $Selected = array('', '', '', '', '', '', '', '');
     114    $Selected[$file_type] = 'selected ';
     115    $Output .= '<option '.$Selected[0].'value="0">Vše
     116    <option '.$Selected[1].'value="1">Audio(mp3,wav,ogg,mid)
     117    <option '.$Selected[2].'value="2">Dokument(doc,txt,pdf)
     118    <option '.$Selected[3].'value="3">Komprimovaný(zip,rar,ace,tar)
     119    <option '.$Selected[4].'value="4">Video(mpeg,avi,ogm,mkv,asf)
     120    <option '.$Selected[5].'value="5">Obrázek(jpg,bmp,gif,png)
     121    <option '.$Selected[6].'value="6">Složka
     122    <option '.$Selected[7].'value="7">Spustitelný(exe,com)
     123    <option '.$Selected[7].'value="8">Obraz disku(iso,nrg,ccd,bin)
     124    </select>
     125    &nbsp;Velikost: <select name="size_method">';
     126    $Selected = array('', '', '');
     127    $Selected[$size_method] = 'selected ';
     128    $Output .= '<option '.$Selected[0].'value="0">Rovno
     129    <option '.$Selected[1].'value="1">Nejméně
     130    <option '.$Selected[2].'value="2">Nejvíce
     131    </select>
     132    <input type="edit" size="5" name="size" value="'.$size.'">
     133    <select name="size_units">';
     134    $Selected = array('', '', '', '');
     135    $Selected[$size_units] = 'selected ';
     136    $Output .= '<option '.$Selected[0].'value="0">B
     137    <option '.$Selected[1].'value="1">kB
     138    <option '.$Selected[2].'value="2">MB
     139    <option '.$Selected[3].'value="3">GB
     140    </select>&nbsp;';
     141
     142    if($online == 'on') $Selected = 'checked '; else $Selected = '';
     143    $Output .= '<input type="checkbox" '.$Selected.'name="online">Pouze aktivní uživatele<br>
     144    </form>';
     145
     146    //$Output .= $view;
     147    if($view != '')
     148    {
     149      // Zobrazení obsahu vybrané složky
     150      $DbResult = $this->Database->query('SELECT * FROM items WHERE id='.$view);
     151      $Row = $DbResult->fetch_array();
     152      $Cesta = $this->PlnaCesta($Row);
     153      $Output .= '<strong>Obsah složky: '.$Cesta.$Row['name'].'</strong><br />';
     154      $Podminka = '(parent='.$view.')';
     155      $Nahoru = $Row['parent'];
     156    } else
     157    {
     158      // Zobrazení výsledku vyhledávání
     159      $Output .= '<strong>Výsledek hledání:</strong><br />';
     160      $Podminka = "(name LIKE '%".strtr($keyword, '*', '%')."%')";
     161
     162      // Hledání podle typů
     163      $Pripony = array('',
     164        "(ext LIKE 'mp3') OR (ext LIKE 'wav') OR (ext LIKE 'ogg') OR (ext LIKE 'mid')",
     165        "(ext LIKE 'doc') OR (ext LIKE 'txt') OR (ext LIKE 'pdf')",
     166        "(ext LIKE 'zip') OR (ext LIKE 'rar') OR (ext LIKE 'ace') OR (ext LIKE 'tar')",
     167        "(ext LIKE 'mpeg') OR (ext LIKE 'mpg') OR (ext LIKE 'avi') OR (ext LIKE 'ogm') OR (ext LIKE 'mkv') OR (ext LIKE 'asf')",
     168        "(ext LIKE 'jpg') OR (ext LIKE 'gif') OR (ext LIKE 'bmp') OR (ext LIKE 'ico') OR (ext LIKE 'png')",
     169        "(type='2')",
     170        "(ext LIKE 'exe') OR (ext LIKE 'com')",
     171        "(ext LIKE 'iso') OR (ext LIKE 'nrg') OR (ext LIKE 'ccd') OR (ext LIKE 'bin') OR (ext LIKE 'mds')",
     172      );
     173      if($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')';
     174
     175      //Hledání podle velikosti
     176      $Jednotky = array(1, 1024, 1048576, 1073741824);
     177      if(is_numeric($size))
     178      {
     179        $Metoda = array('=', '>', '<');
     180        $Velikost = $size * $Jednotky[$size_units];
     181        $Podminka .= ' AND (size'.$Metoda[$size_method].$Velikost.')';
     182      }
     183    }
     184
     185    // Omezení na online/offline uživatele
     186    $this->Database->select_db('is');
     187    if($online == 'on') $DbResult = $this->Database->query('SELECT id FROM hosts WHERE online=1 AND user>0');
     188    else $DbResult = $this->Database->query('SELECT id FROM hosts');
     189    $Vyber = '';
     190    while($Row = $DbResult->fetch_array()) $Vyber .= $Row['id'].',';
     191    $Podminka .= ' AND (host IN ('.substr($Vyber, 0, -1).'))';
     192    //echo($Podminka.'<br>');
     193    $this->Database->select_db('share');
     194
     195    //ShowTime();
     196
     197    // Zjištění počtu výskytů
     198    //DB_Query("SELECT COUNT(*) FROM items WHERE ($Podminka)");
     199    //$Row = DB_Row();
     200    //$Pocet = $Row[0];
     201
     202    // Zobrazení [..]
     203    if(($view != '') && ($page == 0) && ($Nahoru > 0))
     204    {
     205      $DbResult = $this->Database->query('SELECT * FROM items WHERE id='.$view);
     206      $Row = $DbResult->fetch_array();
     207      //ShowArray($Row);
     208      $Datum = explode(' ', $Row['date']);
     209      $upstr = '<tr><td bgcolor="#F0F0FF"><a href="index.php?view='.$Nahoru.'">[..]</a></td><td bgcolor="#F0F0FF" width="1%"></td><td align="right" bgcolor="#F0F0FF" width="1%">'.$this->PrevedVelikost($Row['size']).'</td><td bgcolor="#F0F0FF" width="90">'.$Datum[0].'</td><td bgcolor="#F0F0FF" width="50%">'.$Cesta.'</td></tr>';
     210    } else $upstr = '';
     211
     212    // Nacteni vysledku z databaze
     213    $PerPage = 30;
     214    $Dotaz = "SELECT SQL_CALC_FOUND_ROWS * FROM items WHERE ($Podminka)";
     215    if($order != '') $Dotaz .= ' ORDER BY '.$order;
     216    $Dotaz .= " LIMIT ".($page * $PerPage).",".$PerPage;
     217    $DbResult = $this->Database->query($Dotaz);
     218
     219    $DbResult2 = $this->Database->query("SELECT FOUND_ROWS()");
     220    $Row = $DbResult2->fetch_array();
     221    $Pocet = $Row[0];
     222
     223    if($Pocet > 0)
     224    {
     225      $Output .= 'Nalezeno celkem: '.$Pocet.' položek<br />';
     226    } else
     227    $Output .= 'Podle zadaných podmínek nic nenalezeno';
     228    if(($Pocet > 0) || ($upstr))
     229    {
     230      $Output .= '<table width="100%" style="font-size: 8pt;" border="0" cellpadding="2" cellspacing="2">
     231      <tr><th bgcolor="#E0E0FF"><a href="index.php?order=name">Soubor</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=ext">Přípona</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=size">Velikost</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=date">Datum</a></th><th bgcolor="#E0E0FF">Umístění</th></tr>';
     232      $Output .= $upstr;
     233      if($Pocet > 0)
     234      {
     235        // Zobrazení tabulky s výsledky
     236        $Pages = floor($Pocet / $PerPage);
     237        // echo($Dotaz);
     238
     239        // Zobrazení poloľek
     240        while($Row = $DbResult->fetch_array())
     241        {
     242          // Loguj('Radek '.$Row['name']);
     243          $Radek = $Row;
     244          $Cesta = $this->PlnaCesta($Row);
     245          $Datum = explode(' ', $Radek['date']);
     246
     247          // Zobrazení řádku
     248          $Cesta2 = strtr($Cesta.$Radek['name'], '\\', '/');
     249          if($Radek['ext'] != '') $Cesta2 .= '.'.$Radek['ext'];
     250          if($Radek['type'] != 0) $Adresa = 'index.php?view='.$Radek['id'].'">['.$Radek['name'].']';
     251          else
     252          {
     253            if(strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['name'];
     254            else $Adresa = 'file:///'.$Cesta2.'">'.$Radek['name'];
     255          }
     256          $Output .= '<tr><td bgcolor="#F0F0FF"><a href="'.$Adresa.'</a></td><td bgcolor="#F0F0FF" width="1%">'.$Radek['ext'].'</td><td align="right"   bgcolor="#F0F0FF" width="1%">'.$this->PrevedVelikost($Radek['size']).'</td><td bgcolor="#F0F0FF" width="90">'.$Datum[0].'</td><td bgcolor="#F0F0FF" width="50%" >'.$Cesta.'</td></tr>';
     257        }
     258        $Output .= '</table>';
     259      }
     260    }
     261    if($Pocet > 0)
     262    {
     263      // Celkový přehled
     264      if($view == 1)
     265      {
     266        $DbResult = $this->Database->query('SELECT SUM(size) FROM items WHERE (parent=1) AND (host IN ('.substr($Vyber,0,-1).'))');
     267        $Row = $DbResult->fetch_array();
     268        $SizeOnline = $this->PrevedVelikost($Row[0]);
     269        $DbResult = $this->Database->query('SELECT size FROM items WHERE id=1');
     270        $Row = $DbResult->fetch_array();
     271        $Size = $this->PrevedVelikost($Row['size']);
     272        $DbResult = $this->Database->query('SELECT COUNT(*) FROM items');
     273        $Row = $DbResult->fetch_array();
     274        $Output .= '<br />Celková velikost online sdílených dat: '.$SizeOnline;
     275        $Output .= '<br />Celkem v databázi '.$Row[0].' položek o celkové velikosti '.$Size.'<br />';
     276        $Output .= '<br /><strong>Popis služby:</strong><br />
     277        Tento vyhledávač slouží k prohledávání obsahu samba sdílení všech uživatelů. Je postaven na filosofii, čím více lidí bude sdílet data, tím větší bude pravděpodobnost, že najdete to co hledáte. Každý počítač je jednou za den oskenován a informace o jeho sdílení jsou zaneseny do databáze. Každou hodinu probíhá kontrola zapnutých počítačů a jejich případné oskenování. Při hledání použíjte znak * podobně jako při vyhledávání souborů na disku.<br><br>
     278        <a href="firefox.php">Vyhledávání přes internetový prohlížeč Firefox</a><br />';
     279        $Output .= '<a href="playlist.php">WinAMP playlist mp3 souborů online počítačů</a><br /><br />';
     280
     281        // Zobrazení chyb sdílení
     282        $Host = gethostbyaddr(GetRemoteAddress());
     283        //echo($Host);
     284        $Host = strtoupper(substr($Host, 0, strpos($Host, '.')));
     285        $DbResult = $this->Database->select('errors', '*', 'host="'.$Host.'"');
     286        if($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />';
     287        //echo('host="'.$Host.'"');
     288        while($Row = $DbResult->fetch_array())
     289        {
     290          $Row['message'] = str_replace('/', '\\', $Row['message']);
     291          $Output .= $Row['message'].'<br />';
     292        }
     293      }
     294
     295      // Zobrazení seznamu stránek
     296      if($Pages > 1)
     297      {
     298        if($page > 0) $Output .= '<a href="index.php?page=0">&lt;&lt;</a> ';
     299        if($page > 0) $Output .= '<a href="index.php?page='.($page-1).'">&lt;</a> ';
     300        $PagesMax = $Pages;
     301        $PagesMin = 0;
     302        if($PagesMax > ($page + 10)) $PagesMax = $page + 10;
     303        if($PagesMin < ($page - 10))
     304        {
     305          $Output .= ' .. ';
     306          $PagesMin = $page - 10;
     307        }
     308        for($i = $PagesMin; $i <= $PagesMax; $i++)
     309        {
     310          if($i == $page) $Output .= '<strong>';
     311          $Output .= '<a href="index.php?page='.$i.'">'.($i + 1).'</a> ';
     312          if($i == $page) $Output .= '</strong>';
     313        }
     314        if($PagesMax < $Pages) $Output .= ' .. ';
     315        if($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">&gt;</a> ';
     316        if($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">&gt;&gt;</a>';
     317      }
     318    }
     319    return($Output);
     320  }
    7321}
    8322
    9 include('../global.php');
    10 include('../style.php');
    11 
    12 // Inicializace Logu
    13 //$LogFile = fopen('info.log','w');
    14 function Loguj($Info)
    15 {
    16   //global $LogFile;
    17   //fputs($LogFile,$Info."\n");
    18 }
    19 //Show_Array($GLOBALS);
    20 
    21 // Maximální vnoření
    22 $MaxNesting = 20;
    23 
    24 // Automatické zapamatování proměnných
    25 $Promene = array(
    26   'keyword' => '',
    27   'file_type' => 0,
    28   'size' => '',
    29   'size_method' => 1,
    30   'size_units' => 2,
    31   'online' => 'on',
    32   'order' => 'size DESC',
    33   'page' => '0',
    34   'view' => 1,
    35 );
    36 
    37 // If not only online checkbox checked
    38 if(array_key_exists('view',$_POST) && !array_key_exists('online',$_POST)) $_POST['online'] = 'off';
    39 
    40 //echo($_SERVER['HTTP_REFERER']);
    41 if(array_key_exists('HTTP_REFERER',$_SERVER))
    42 {
    43   $Url = explode('?',$_SERVER['HTTP_REFERER']);
    44   $Url = explode('/',$Url[0]);
    45   //ShowArray($Url);
    46   $Url[2] = gethostbyname($Url[2]);
    47   if($Url[2]=='127.0.0.1') $Url[2] = '192.168.0.1';
    48   $Server = gethostbyname($_SERVER["HTTP_HOST"]);
    49   if($Server=='127.0.0.1') $Server = '192.168.0.1';
    50   $Url = implode('/',$Url);
    51   //echo($Url.',http://'.$Server.$_SERVER["SCRIPT_NAME"]);
    52   if(($Url!='http://'.$Server.$_SERVER["SCRIPT_NAME"])) { $_POST['view'] = 1; $_POST['page'] = 0; }
    53 } else { $_POST['view'] = 1; $_POST['page'] = 0; }
    54 
    55 // Default host list view
    56 if((count($_POST)==0) && (count($_GET)==0)) $_POST['view'] = 1;
    57 
    58 // Toggle order direction
    59 if(array_key_exists('order',$_GET)&&($_SESSION['order']==$_GET['order'])) $_GET['order'] .= ' DESC';
    60 
    61 //print_r($_POST);
    62 foreach($Promene as $Index => $Prvek)
    63 {
    64   if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Promene[$Index];
    65   if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
    66   if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    67   if(($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $Promene[$Index];
    68   if(($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = '';
    69   $$Index = $_SESSION[$Index];
    70   //echo('$'.$Index.' = '.$_SESSION[$Index].'<br>');
    71 }
    72 //echo($keyword);
    73 //if($keyword)
    74 //if($keyword != '') $view = '';
    75 
    76 if(!isset($page)) $page = 0;
    77 
    78 $Database->select_db('share');
    79 
    80 // Najde cestu ke keřenu
    81 function PlnaCesta($Row)
    82 {
    83   global $MaxNesting, $Database;
    84  
    85   // Vyhledání cesty
    86   $Otec = $Row['parent'];
    87   $Cesta = ''; //$Row['name'];
    88   $i = 0;
    89   while(($Otec>1)&&($i<$MaxNesting))
    90   {
    91     $DbResult = $Database->query('SELECT id,name,parent FROM items WHERE id='.$Otec);
    92     $Row = $DbResult->fetch_array();
    93     Loguj('Name: '.$Row['name'].' ID:'.$Row['id'].' Parent:'.$Row['parent']);
    94     $Cesta = $Row['name'].'\\'.$Cesta;
    95     $Otec = $Row['parent'];
    96     $i++;
    97   }
    98   if($i>=$MaxNesting) $Cesta = '?'.'\\'.$Cesta;
    99   return('\\\\'.$Cesta);
    100 }
    101 
    102 // Převede velikost v bajtech na odpovídající jednotky
    103 function PrevedVelikost($Velikost)
    104 {
    105   $Jednotky = array('B','kB','MB','GB','TB','PB','EB');
    106   while($Velikost>=1024)
    107   {
    108     $Velikost = round($Velikost/1024*10)/10;
    109     array_shift($Jednotky);
    110   }
    111   return($Velikost.'&nbsp;'.$Jednotky[0]);
    112 }
    113 ShowHeader('Vyhledávání souborů','Vyhledávání souborů');
    114 
    115 // Zobrazení formuláře
    116 echo('<form action="/share/index.php" method="post">
    117 <input type="hidden" name="view" value="">
    118 <input type="hidden" name="page" value="0">
    119 Hledat: <input type="text" name="keyword" value="'.$keyword.'">');
    120 echo('<input type="submit" value="Hledat">&nbsp;Typ: <select name="file_type" id="file_type">');
    121 $Selected = array('','','','','','','','');
    122 $Selected[$file_type] = 'selected ';
    123 echo('<option '.$Selected[0].'value="0">Vše
    124 <option '.$Selected[1].'value="1">Audio(mp3,wav,ogg,mid)
    125 <option '.$Selected[2].'value="2">Dokument(doc,txt,pdf)
    126 <option '.$Selected[3].'value="3">Komprimovaný(zip,rar,ace,tar)
    127 <option '.$Selected[4].'value="4">Video(mpeg,avi,ogm,mkv,asf)
    128 <option '.$Selected[5].'value="5">Obrázek(jpg,bmp,gif,png)
    129 <option '.$Selected[6].'value="6">Složka
    130 <option '.$Selected[7].'value="7">Spustitelný(exe,com)
    131 <option '.$Selected[7].'value="8">Obraz disku(iso,nrg,ccd,bin)
    132 </select>
    133 &nbsp;Velikost: <select name="size_method">');
    134 $Selected = array('','','');
    135 $Selected[$size_method] = 'selected ';
    136 echo('<option '.$Selected[0].'value="0">Rovno
    137 <option '.$Selected[1].'value="1">Nejméně
    138 <option '.$Selected[2].'value="2">Nejvíce
    139 </select>
    140 <input type="edit" size="5" name="size" value="'.$size.'">
    141 <select name="size_units">');
    142 $Selected = array('','','','');
    143 $Selected[$size_units] = 'selected ';
    144 echo('<option '.$Selected[0].'value="0">B
    145 <option '.$Selected[1].'value="1">kB
    146 <option '.$Selected[2].'value="2">MB
    147 <option '.$Selected[3].'value="3">GB
    148 </select>&nbsp;');
    149 
    150 if($online=='on') $Selected = 'checked '; else $Selected = '';
    151 echo('<input type="checkbox" '.$Selected.'name="online">Pouze aktivní uživatele<br>
    152 </form>');
    153 
    154 //echo($view);
    155 if($view != '')
    156 {
    157   // Zobrazení obsahu vybrané sloľky
    158   $DbResult = $Database->query("SELECT * FROM items WHERE id=$view");
    159   $Row = $DbResult->fetch_array();
    160   $Cesta = PlnaCesta($Row);
    161   echo('<strong>Obsah složky: '.$Cesta.$Row['name'].'</strong><br>');
    162   $Podminka = '(parent='.$view.')';
    163   $Nahoru = $Row['parent'];
    164 } else
    165 {
    166   // Zobrazení výsledku vyhledávání
    167   echo('<strong>Výsledek hledání:</strong><br>');
    168   $Podminka = "(name LIKE '%".strtr($keyword,'*','%')."%')";
    169  
    170   // Hledání podle typů
    171   $Pripony = array('',
    172     "(ext LIKE 'mp3') OR (ext LIKE 'wav') OR (ext LIKE 'ogg') OR (ext LIKE 'mid')",
    173     "(ext LIKE 'doc') OR (ext LIKE 'txt') OR (ext LIKE 'pdf')",
    174     "(ext LIKE 'zip') OR (ext LIKE 'rar') OR (ext LIKE 'ace') OR (ext LIKE 'tar')",
    175     "(ext LIKE 'mpeg') OR (ext LIKE 'mpg') OR (ext LIKE 'avi') OR (ext LIKE 'ogm') OR (ext LIKE 'mkv') OR (ext LIKE 'asf')",
    176     "(ext LIKE 'jpg') OR (ext LIKE 'gif') OR (ext LIKE 'bmp') OR (ext LIKE 'ico') OR (ext LIKE 'png')",
    177     "(type='2')",
    178     "(ext LIKE 'exe') OR (ext LIKE 'com')",
    179     "(ext LIKE 'iso') OR (ext LIKE 'nrg') OR (ext LIKE 'ccd') OR (ext LIKE 'bin') OR (ext LIKE 'mds')",
    180   );
    181   if($file_type>0) $Podminka .= ' AND ('.$Pripony[$file_type].')';
    182 
    183   //Hledání podle velikosti
    184   $Jednotky = array(1,1024,1048576,1073741824);
    185   if(is_numeric($size))
    186   {
    187     $Metoda = array('=','>','<');
    188     $Velikost = $size*$Jednotky[$size_units];
    189     $Podminka .= ' AND (size'.$Metoda[$size_method].$Velikost.')';
    190   }
    191 }
    192 
    193 // Omezení na online/offline uľivatele
    194 $Database->select_db('is');
    195 if($online == 'on') $DbResult = $Database->query('SELECT id FROM hosts WHERE online=1 AND user>0');
    196 else $DbResult = $Database->query('SELECT id FROM hosts');
    197 $Vyber = '';
    198 while($Row = $DbResult->fetch_array()) $Vyber .= $Row['id'].',';
    199 $Podminka .= ' AND (host IN ('.substr($Vyber,0,-1).'))';
    200 //echo($Podminka.'<br>');
    201 $Database->select_db('share');
    202 
    203 //ShowTime();
    204 flush();
    205 
    206 // Zjištění počtu výskytů
    207 //DB_Query("SELECT COUNT(*) FROM items WHERE ($Podminka)");
    208 //$Row = DB_Row();
    209 //$Pocet = $Row[0];
    210  
    211 // Zobrazení [..]
    212 if(($view!='')&&($page==0)&&($Nahoru>0))
    213 {
    214   $DbResult = $Database->query("SELECT * FROM items WHERE id=$view");
    215   $Row = $DbResult->fetch_array();
    216   //ShowArray($Row);
    217   $Datum = explode(' ',$Row['date']);
    218   $upstr = '<tr><td bgcolor="#F0F0FF"><a href="index.php?view='.$Nahoru.'">[..]</a></td><td bgcolor="#F0F0FF" width="1%"></td><td align="right" bgcolor="#F0F0FF" width="1%">'.PrevedVelikost($Row['size']).'</td><td bgcolor="#F0F0FF" width="90">'.$Datum[0].'</td><td bgcolor="#F0F0FF" width="50%">'.$Cesta.'</td></tr>';
    219 } else $upstr = '';
    220 
    221 // Nacteni vysledku z databaze
    222 $PerPage = 30;
    223 $Dotaz = "SELECT SQL_CALC_FOUND_ROWS * FROM items WHERE ($Podminka)";
    224 if($order!='') $Dotaz .= " ORDER BY $order";
    225 $Dotaz .= " LIMIT ".($page*$PerPage).",".$PerPage;
    226 $DbResult = $Database->query($Dotaz);
    227 
    228 $DbResult2 = $Database->query("SELECT FOUND_ROWS()");
    229 $Row = $DbResult2->fetch_array();
    230 $Pocet = $Row[0];
    231 
    232 if($Pocet > 0) { echo('Nalezeno celkem: '.$Pocet.' položek<br>'); } else echo('Podle zadaných podmínek nic nenalezeno');
    233 if(($Pocet > 0)||($upstr)) {
    234 echo('<table width="100%" style="font-size: 8pt;" border="0" cellpadding="2" cellspacing="2">
    235 <tr><th bgcolor="#E0E0FF"><a href="index.php?order=name">Soubor</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=ext">Přípona</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=size">Velikost</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=date">Datum</a></th><th bgcolor="#E0E0FF">Umístění</th></tr>');
    236 echo $upstr;
    237 if($Pocet > 0) {
    238   // Zobrazení tabulky s výsledky
    239   $Pages = floor($Pocet/$PerPage);
    240   // echo($Dotaz);
    241 
    242   // Zobrazení poloľek
    243   while($Row = $DbResult->fetch_array())
    244   {
    245     // Loguj('Radek '.$Row['name']);
    246     $Radek = $Row;
    247     $Cesta = PlnaCesta($Row);
    248     $Datum = explode(' ',$Radek['date']);
    249 
    250     // Zobrazení řádku
    251     $Cesta2 = strtr($Cesta.$Radek['name'],'\\','/');
    252     if($Radek['ext']!='') $Cesta2 .= '.'.$Radek['ext'];
    253     if($Radek['type']!=0) $Adresa = 'index.php?view='.$Radek['id'].'">['.$Radek['name'].']';
    254     else
    255     {
    256       if(strstr($_SERVER['HTTP_USER_AGENT'],'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['name'];
    257       else $Adresa = 'file:///'.$Cesta2.'">'.$Radek['name'];
    258     }
    259     echo('<tr><td bgcolor="#F0F0FF"><a href="'.$Adresa.'</a></td><td bgcolor="#F0F0FF" width="1%">'.$Radek['ext'].'</td><td align="right" bgcolor="#F0F0FF" width="1%">'.PrevedVelikost($Radek['size']).'</td><td bgcolor="#F0F0FF" width="90">'.$Datum[0].'</td><td bgcolor="#F0F0FF" width="50%" >'.$Cesta.'</td></tr>');
    260 //    flush();
    261   }
    262   echo('</table>');
    263 }}
    264 if($Pocet > 0) {
    265   // Celkový přehled
    266   if($view==1)
    267   {
    268     $DbResult = $Database->query('SELECT SUM(size) FROM items WHERE (parent=1) AND (host IN ('.substr($Vyber,0,-1).'))');
    269     $Row = $DbResult->fetch_array();
    270     $SizeOnline = PrevedVelikost($Row[0]);
    271     $DbResult = $Database->query('SELECT size FROM items WHERE id=1');
    272     $Row = $DbResult->fetch_array();
    273     $Size = PrevedVelikost($Row['size']);
    274     $DbResult = $Database->query('SELECT COUNT(*) FROM items');
    275     $Row = $DbResult->fetch_array();
    276     echo('<br>Celková velikost online sdílených dat: '.$SizeOnline);
    277     echo('<br>Celkem v databázi '.$Row[0].' položek o celkové velikosti '.$Size.'<br>');
    278     echo('<br><strong>Popis služby:</strong><br>
    279     Tento vyhledávač slouží k prohledávání obsahu samba sdílení všech uživatelů. Je postaven na filosofii, čím více lidí bude sdílet data, tím větší bude pravděpodobnost, že najdete to co hledáte. Každý počítač je jednou za den oskenován a informace o jeho sdílení jsou zaneseny do databáze. Každou hodinu probíhá kontrola zapnutých počítačů a jejich případné oskenování. Při hledání použíjte znak * podobně jako při vyhledávání souborů na disku.<br><br>
    280     <a href="firefox.php">Vyhledávání přes internetový prohlížeč Firefox</a><br>');
    281     echo('<a href="playlist.php">WinAMP playlist mp3 souborů online počítačů</a><br><br>');
    282    
    283     // Zobrazení chyb sdílení
    284     $Host = gethostbyaddr(GetRemoteAddress());
    285     //echo($Host);
    286     $Host = strtoupper(substr($Host, 0, strpos($Host, '.')));
    287     $DbResult = $Database->select('errors', '*', 'host="'.$Host.'"');
    288     if($DbResult->num_rows > 0) echo('<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br>');
    289     //echo('host="'.$Host.'"');
    290     while($Row = $DbResult->fetch_array())
    291     {
    292       $Row['message'] = str_replace('/', '\\', $Row['message']);
    293       echo($Row['message'].'<br>');
    294     }
    295   }
    296 
    297   // Zobrazení seznamu stránek
    298   if($Pages>1)
    299   {
    300     if($page>0) echo('<a href="index.php?page=0">&lt;&lt;</a> ');
    301     if($page>0) echo('<a href="index.php?page='.($page-1).'">&lt;</a> ');
    302     $PagesMax = $Pages;
    303     $PagesMin = 0;
    304     if($PagesMax>($page+10)) $PagesMax = $page+10;
    305     if($PagesMin<($page-10))
    306     {
    307       echo(' .. ');
    308       $PagesMin = $page-10;
    309     }
    310     for($i=$PagesMin;$i<=$PagesMax;$i++)
    311     {
    312       if($i==$page) echo('<strong>');
    313       echo('<a href="index.php?page='.$i.'">'.($i+1).'</a> ');
    314       if($i==$page) echo('</strong>');
    315     }
    316     if($PagesMax<$Pages) echo(' .. ');
    317     if($page<$Pages) echo('<a href="index.php?page='.($page+1).'">&gt;</a> ');
    318     if($page<$Pages) echo('<a href="index.php?page='.$Pages.'">&gt;&gt;</a>');
    319   }
    320 }
    321 
    322 ShowFooter();
     323$System->AddModule(new SharePage());
     324$System->Modules['SharePage']->GetOutput();
     325
    323326?>
Note: See TracChangeset for help on using the changeset viewer.