Changeset 873 for trunk/Modules/NetworkShare/browse.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkShare/browse.php
r790 r873 9 9 $MountDir = '/tmp/browse/host'; // Složka, kde se dočasně připojují síťové disky 10 10 $TempDir = '/tmp/browse/'; // Složka, kde se dočasně připojují síťové disky 11 if (!is_dir($TempDir)) mkdir($TempDir, 0777);12 if (!is_dir($MountDir)) mkdir($MountDir, 0777);11 if (!is_dir($TempDir)) mkdir($TempDir, 0777); 12 if (!is_dir($MountDir)) mkdir($MountDir, 0777); 13 13 14 14 // Nacteni seznamu sdileni 15 15 $Host = strtoupper(getenv('browse_host')); 16 if ($Host=='') die("Musite nastavit browse_host!\n");16 if ($Host=='') die("Musite nastavit browse_host!\n"); 17 17 $HostID = getenv('browse_id'); 18 if ($HostID=='') die("Musite nastavit browse_id!\n");18 if ($HostID=='') die("Musite nastavit browse_id!\n"); 19 19 //echo("\n================== Prochazec sdileni =================\n\n"); 20 20 echo("Nacitam seznam sdileni pro ".$Host.'('.$HostID.')...'); … … 23 23 echo("OK\n"); 24 24 //print_r($Output); 25 if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n");25 if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n"); 26 26 $Output = array_slice($Output,3); 27 27 $Shares = array(); 28 foreach ($Output as $Radek)29 { 30 if ($Radek=='') break;28 foreach ($Output as $Radek) 29 { 30 if ($Radek=='') break; 31 31 //$Radek = iconv('UTF-8','ISO-8859-2',$Radek); 32 32 $Title = trim(substr($Radek,1,16)); … … 34 34 $Desc = trim(substr($Radek,26)); 35 35 //echo($Title.','.$Type.','.$Desc."\n"); 36 if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title);36 if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title); 37 37 //ShowArray($Radek); 38 38 } … … 61 61 //echo(strlen($Nazev).","); 62 62 array_push($Files,$Nazev); 63 } while (($Nazev != "\n") && (!feof($Soubor)));63 } while (($Nazev != "\n") && (!feof($Soubor))); 64 64 array_pop($Files); 65 //if (($Pocet-floor($Pocet/10)*10)==9)65 //if (($Pocet-floor($Pocet/10)*10)==9) 66 66 $Hotovo = floor(ftell($Soubor) / $FileSize * $MaxProgress); 67 if ($Hotovo >= $Pocet)67 if ($Hotovo >= $Pocet) 68 68 { 69 69 echo(str_repeat('#', $Hotovo-$Pocet)); … … 71 71 } 72 72 //echo('['.memory_get_usage().'] '.$Cesta."\n"); 73 foreach ($Files as $Radek)73 foreach ($Files as $Radek) 74 74 { 75 75 //echo($Radek.""); 76 76 $Radek = substr($Radek,0,-1); 77 77 //echo($Radek.",\n"); 78 if ($Radek[0] == 'd') $Type = 2; else $Type = 0;78 if ($Radek[0] == 'd') $Type = 2; else $Type = 0; 79 79 $Prava = substr($Radek,0,strpos($Radek,' ')); 80 80 $Radek = ltrim(substr($Radek,strlen($Prava)+1)); … … 94 94 //echo($Date.','.$Time.','.$Radek.' '); 95 95 96 if ((strpos($Nazev,'.') > 0) && ($Type != 2))96 if ((strpos($Nazev,'.') > 0) && ($Type != 2)) 97 97 { 98 98 $Ext = substr($Nazev,strrpos($Nazev,'.')+1); … … 114 114 $Citac = $Citac + 1; 115 115 // Pokud jde o sloľku, tak projdi jeji obsah a aktualizuj velikost 116 if ($Type == 2)116 if ($Type == 2) 117 117 { 118 118 //echo($Vlozit); 119 // if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky119 // if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 120 120 // $Vlozit = ''; 121 121 $VelikostSlozky += Vetev($Cesta.$Nazev.'/',$Zanoreni+1); … … 123 123 } 124 124 //echo($Vlozit); 125 //if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky125 //if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 126 126 127 127 // Aktualizuj velikost … … 130 130 $Database->update('NetworkShareItem', 'id='.$Parent, array('size' => $VelikostSlozky)); 131 131 //closedir($Dir); 132 return ($VelikostSlozky);132 return ($VelikostSlozky); 133 133 } 134 134 … … 152 152 $Parent = $Row[0]; 153 153 154 foreach ($Shares as $Share)154 foreach ($Shares as $Share) 155 155 { 156 156 $Pocet = 0; … … 163 163 // echo($SambaSbinDir."mount.cifs '".$ShareFull."' ".$MountDir.' -o guest,codepage=cp852,iocharset=iso8859-2'); 164 164 passthru('ls -A -R -X -l --time-style=+"%Y-%m-%d %I:%M:%S" '.$MountDir.'>'.$TempDir.$Host.'.list 2>'.$TempDir.'errors/'.$Host.'_'.$Share.'.err',$Result); 165 //if ($Result==0)165 //if ($Result==0) 166 166 //{ 167 167 echo("OK\n"); 168 168 169 if (file_exists($TempDir.$Host.'.list'))169 if (file_exists($TempDir.$Host.'.list')) 170 170 { 171 171 // Přidej poloľku sdílení do datanáze … … 215 215 $DbResult = $Database->query('SELECT id FROM hosts'); 216 216 $Vyber = ''; 217 while ($Row = $DbResult->fetch_array())217 while ($Row = $DbResult->fetch_array()) 218 218 $Vyber .= $Row['id'].','; 219 219 … … 226 226 echo("Chyby sdílení...\n"); 227 227 $Database->delete('NetworkShareError', 'host="'.$Host.'"'); 228 if (is_dir($TempDir.'errors'))228 if (is_dir($TempDir.'errors')) 229 229 { 230 230 $Dir = scandir($TempDir.'errors'); 231 foreach ($Dir as $File)231 foreach ($Dir as $File) 232 232 { 233 if (substr($File, 0, strpos($File, '_')) == $Host)233 if (substr($File, 0, strpos($File, '_')) == $Host) 234 234 { 235 235 $Share = substr($File, strpos($File, '_')+1, -4); 236 236 $ShareFull = '//'.$Host.'/'.$Share; 237 if (filesize($TempDir.'errors/'.$File) > 0)237 if (filesize($TempDir.'errors/'.$File) > 0) 238 238 { 239 239 $ErrorFile = fopen($TempDir.'errors/'.$File, 'r+'); 240 while (!feof($ErrorFile))240 while (!feof($ErrorFile)) 241 241 { 242 242 $Row = fgets($ErrorFile); 243 if ($Row != '')243 if ($Row != '') 244 244 { 245 245 $Row = substr($ShareFull.'/'.substr($Row, 39), 0, -1);
Note:
See TracChangeset
for help on using the changeset viewer.