Changeset 362 for trunk


Ignore:
Timestamp:
Jan 18, 2012, 9:32:07 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Doplněny rozšiřující typy s jinou velikostí.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Model.php

    r360 r362  
    11<?php
     2
     3define('PropertyInteger8', 'Integer8');
     4define('PropertyInteger16', 'Integer16');
     5define('PropertyInteger24', 'Integer24');
     6define('PropertyInteger32', 'Integer32');
     7define('PropertyInteger64', 'Integer64');
     8
     9define('PropertyText8', 'Text8');
     10define('PropertyText16', 'Text16');
     11define('PropertyText24', 'Text24');
     12define('PropertyText32', 'Text32');
    213
    314define('PropertyDate', 'Date');
    415define('PropertyTime', 'Time');
    516define('PropertyDateTime', 'DateTime');
    6 define('PropertyText', 'Text');
     17define('PropertyText', 'Text16');
    718define('PropertyString', 'String');
    819define('PropertyBoolean', 'Boolean');
    9 define('PropertyInteger', 'Integer');
     20define('PropertyInteger', 'Integer32');
    1021define('PropertyFloat', 'Float');
     22define('PropertyDouble', 'Double');
    1123define('PropertyOneToMany', 'OneToMany');
    1224define('PropertyManyToOne', 'ManyToOne');
    1325define('PropertyManyToMany', 'ManyToMany');
     26
    1427
    1528class Model
     
    5669  }
    5770
     71  function AddPropertyText8($Name)
     72  {     
     73    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText8);
     74  }
     75
     76  function AddPropertyText16($Name)
     77  {     
     78    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText16);
     79  }
     80
     81  function AddPropertyText24($Name)
     82  {     
     83    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText24);
     84  }
     85
     86  function AddPropertyText32($Name)
     87  {     
     88    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText32);
     89  }
     90
    5891  function AddPropertyString($Name)
    5992  {     
     
    6699  }
    67100
    68     function AddPropertyFloat($Name)
     101  function AddPropertyInteger8($Name)
     102  {     
     103    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger8);
     104  }
     105
     106  function AddPropertyInteger16($Name)
     107  {     
     108    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger16);
     109  }
     110
     111  function AddPropertyInteger24($Name)
     112  {     
     113    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger24);
     114  }
     115
     116  function AddPropertyInteger32($Name)
     117  {     
     118    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger32);
     119  }
     120
     121  function AddPropertyInteger64($Name)
     122  {     
     123    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger64);
     124  }
     125
     126  function AddPropertyFloat($Name)
    69127  {     
    70128    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyFloat);
     129  }
     130
     131  function AddPropertyDouble($Name)
     132  {     
     133    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDouble);
    71134  }
    72135
  • trunk/Modules/NetworkShare/NetworkShare.php

    r358 r362  
    44
    55include_once('SharePage.php');
     6
     7class NetworkShareItem extends Model
     8{
     9  function __construct($Database, $System)
     10  {
     11    parent::__construct($Database, $System);
     12    $this->Name = 'NetworkShareItem';
     13    $this->AddPropertyString('Name');
     14    $this->AddPropertyOneToMany('Parent', 'NetworkShareItems');
     15    $this->AddPropertyOneToMany('Host', 'NetworkDevice');
     16    $this->AddPropertyInteger64('Size');
     17    $this->AddPropertyString('Ext');
     18    $this->AddPropertyDate('Date');
     19    $this->AddPropertyInteger('Type');
     20  }
     21}
     22
     23class NetworkShareError extends Model
     24{
     25  function __construct($Database, $System)
     26  {
     27    parent::__construct($Database, $System);
     28    $this->Name = 'NetworkShareError';
     29    $this->AddPropertyOneToMany('Host', 'NetworkDevice');
     30    $this->AddPropertyString('Message');
     31  }
     32}
    633
    734class ModuleNetworkShare extends Module
     
    1542    $this->License = 'GNU/GPL';
    1643    $this->Description = 'System for loading network computer share file list and allow fast searching.';
    17     $this->Dependencies = array();
    18     $this->Models = array();
     44    $this->Dependencies = array('Network');
     45    $this->Models = array('NetworkShareItem', 'NetworkShareError');
    1946  }
    2047 
  • trunk/Modules/NetworkShare/SharePage.php

    r355 r362  
    4242    while(($Otec > 1) && ($i < $this->MaxNesting))
    4343    {
    44       $DbResult = $this->Database->query('SELECT id,name,parent FROM items WHERE id='.$Otec);
     44      $DbResult = $this->Database->query('SELECT id,name,parent FROM NetworkShareItem WHERE id='.$Otec);
    4545      $Row = $DbResult->fetch_array();
    4646      $this->Loguj('Name: '.$Row['name'].' ID:'.$Row['id'].' Parent:'.$Row['parent']);
     
    146146    {
    147147      // Zobrazení obsahu vybrané složky
    148       $DbResult = $this->Database->query('SELECT * FROM items WHERE id='.$view);
     148      $DbResult = $this->Database->query('SELECT * FROM NetworkShareItem WHERE id='.$view);
    149149      $Row = $DbResult->fetch_array();
    150150      $Cesta = $this->PlnaCesta($Row);
     
    194194
    195195    // Zjištění počtu výskytů
    196     //DB_Query("SELECT COUNT(*) FROM items WHERE ($Podminka)");
     196    //DB_Query("SELECT COUNT(*) FROM NetworkShareItem WHERE ($Podminka)");
    197197    //$Row = DB_Row();
    198198    //$Pocet = $Row[0];
     
    201201    if(($view != '') && ($page == 0) && ($Nahoru > 0))
    202202    {
    203       $DbResult = $this->Database->query('SELECT * FROM items WHERE id='.$view);
     203      $DbResult = $this->Database->query('SELECT * FROM NetworkShareItem WHERE id='.$view);
    204204      $Row = $DbResult->fetch_array();
    205205      //ShowArray($Row);
     
    210210    // Nacteni vysledku z databaze
    211211    $PerPage = 30;
    212     $Dotaz = "SELECT SQL_CALC_FOUND_ROWS * FROM items WHERE ($Podminka)";
     212    $Dotaz = "SELECT SQL_CALC_FOUND_ROWS * FROM NetworkShareItem WHERE ($Podminka)";
    213213    if($order != '') $Dotaz .= ' ORDER BY '.$order;
    214214    $Dotaz .= " LIMIT ".($page * $PerPage).",".$PerPage;
     
    262262      if($view == 1)
    263263      {
    264         $DbResult = $this->Database->query('SELECT SUM(size) FROM items WHERE (parent=1) AND (host IN ('.substr($Vyber,0,-1).'))');
     264        $DbResult = $this->Database->query('SELECT SUM(size) FROM NetworkShareItem WHERE (parent=1) AND (host IN ('.substr($Vyber,0,-1).'))');
    265265        $Row = $DbResult->fetch_array();
    266266        $SizeOnline = $this->PrevedVelikost($Row[0]);
    267         $DbResult = $this->Database->query('SELECT size FROM items WHERE id=1');
     267        $DbResult = $this->Database->query('SELECT size FROM NetworkShareItem WHERE id=1');
    268268        $Row = $DbResult->fetch_array();
    269269        $Size = $this->PrevedVelikost($Row['size']);
    270         $DbResult = $this->Database->query('SELECT COUNT(*) FROM items');
     270        $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkShareItem');
    271271        $Row = $DbResult->fetch_array();
    272272        $Output .= '<br />Celková velikost online sdílených dat: '.$SizeOnline;
  • trunk/Modules/NetworkShare/browse.php

    r129 r362  
    4848  //$Vlozit = '';
    4949  // Nacti parent ID
    50   $DbResult = $Database->query('SELECT LAST_INSERT_ID() FROM items LIMIT 0,1');
     50  $DbResult = $Database->query('SELECT LAST_INSERT_ID() FROM NetworkShareItem LIMIT 0,1');
    5151  //echo(DB_NumRows());
    5252  $Row = $DbResult->fetch_array();
     
    9999      $Nazev = substr($Nazev,0,strrpos($Nazev,'.'));
    100100    } else $Ext = '';
    101     //$Vlozit .= "INSERT INTO items (name,size,date,ext,parent,type,host) ".
     101    //$Vlozit .= "INSERT INTO NetworkShareItem (name,size,date,ext,parent,type,host) ".
    102102    //"VALUES ('$Nazev','$Velikost',NOW(),'$Ext','$Parent','$Type','$HostID'); ";
    103103   
    104     $Database->insert('items', array(
     104    $Database->insert('NetworkShareItem', array(
    105105      'name' => $Nazev,
    106106      'size' => $Velikost,
     
    126126 
    127127  // Aktualizuj velikost
    128   //DB_Query("SELECT SUM(size) FROM items WHERE (parent=".$Parent.")");
     128  //DB_Query("SELECT SUM(size) FROM NetworkShareItem WHERE (parent=".$Parent.")");
    129129  //$Row = DB_Row();
    130   $Database->update('items', 'id='.$Parent, array('size' => $VelikostSlozky));
     130  $Database->update('NetworkShareItem', 'id='.$Parent, array('size' => $VelikostSlozky));
    131131  //closedir($Dir);
    132132  return($VelikostSlozky);
     
    134134
    135135// Proskenuj jednotlive sdileni
    136 $Database->query('DELETE FROM items WHERE host='.$HostID);      // Smaz predchozi polozky
     136$Database->query('DELETE FROM NetworkShareItem WHERE host='.$HostID);   // Smaz predchozi polozky
    137137
    138138// Zapis nazev pocitace
    139 $Database->insert('items',array(
     139$Database->insert('NetworkShareItem',array(
    140140  'name' => $Host,
    141141  'size' => 0,
     
    148148
    149149// Nacti Parent ID
    150 $DbResult = $Database->query('SELECT LAST_INSERT_ID() FROM items LIMIT 0,1');
     150$DbResult = $Database->query('SELECT LAST_INSERT_ID() FROM NetworkShareItem LIMIT 0,1');
    151151$Row = $DbResult->fetch_array();
    152152$Parent = $Row[0];
     
    170170    {
    171171      // Přidej poloľku sdílení do datanáze
    172       $Database->insert('items',array(
     172      $Database->insert('NetworkShareItem',array(
    173173        'name' => $Share,
    174174        'size' => 0,
     
    196196
    197197// Aktualizuj velikost dat pocitace
    198 $DbResult = $Database->query("SELECT SUM(size) FROM items WHERE parent=".$Parent);
    199 $Row = $DbResult->fetch_array();
    200 $Database->update('items','id='.$Parent,array('size' => $Row[0]));
     198$DbResult = $Database->query("SELECT SUM(size) FROM NetworkShareItem WHERE parent=".$Parent);
     199$Row = $DbResult->fetch_array();
     200$Database->update('NetworkShareItem','id='.$Parent,array('size' => $Row[0]));
    201201
    202202// Zaktivuj strom
     
    207207$NewID = $Row['id'];
    208208$Database->select_db('share');
    209 $Database->query("DELETE FROM items WHERE host=".$NewID);
    210 $Database->update('items','host='.$HostID,array('host' => $NewID));
     209$Database->query("DELETE FROM NetworkShareItem WHERE host=".$NewID);
     210$Database->update('NetworkShareItem','host='.$HostID,array('host' => $NewID));
    211211echo("OK\n");
    212212
     
    219219 
    220220$Database->select_db('share');
    221 $DbResult = $Database->query("SELECT SUM(size) FROM items WHERE ((parent=1) AND (host IN (".substr($Vyber,0,-1).')))');
    222 $Row = $DbResult->fetch_array();
    223 $Database->update('items','id=1',array('size' => $Row[0]));
     221$DbResult = $Database->query("SELECT SUM(size) FROM NetworkShareItem WHERE ((parent=1) AND (host IN (".substr($Vyber,0,-1).')))');
     222$Row = $DbResult->fetch_array();
     223$Database->update('NetworkShareItem','id=1',array('size' => $Row[0]));
    224224
    225225// Zapiš chyby do databáze
    226226echo("Chyby sdílení...\n");
    227 $Database->delete('errors', 'host="'.$Host.'"');
     227$Database->delete('NetworkShareError', 'host="'.$Host.'"');
    228228if(is_dir($TempDir.'errors'))
    229229{
     
    244244          {
    245245            $Row = substr($ShareFull.'/'.substr($Row, 39), 0, -1);
    246             $Database->insert('errors', array('host' => $Host, 'message' => $Row));
     246            $Database->insert('NetworkShareError', array('host' => $Host, 'message' => $Row));
    247247            echo($Row."\n");
    248248          }
  • trunk/Modules/NetworkShare/update.php

    r40 r362  
    99  $Hosts = array();
    1010  $StartTime = GetMicrotime();
    11   $DbResult = $Database->query("SELECT * FROM hosts WHERE online=1 AND (block=0 OR name='centrala') AND (name!='GATE') AND user>0");
     11  $DbResult = $Database->query("SELECT * FROM NetworkDevice WHERE Online=1 AND (block=0 OR Name='centrala') AND (name!='GATE') AND user>0");
    1212  while($Row = $DbResult->fetch_array())
    1313  {
     
    2929 
    3030  // Oprav a zoptimalizuj tabulku
    31   $Database->select_db('share');
     31  //$Database->select_db('share');
    3232  echo('Opravuji tabulku...');
    33   $Database->query('REPAIR TABLE items');
     33  $Database->query('REPAIR TABLE NetworkShareItem');
    3434  echo("\nOptimalizuji tabulku...");
    35   $Database->query('OPTIMIZE TABLE items');
     35  $Database->query('OPTIMIZE TABLE NetworkShareItem');
    3636 
    3737  echo("\nDoba procháení ".date("H:i:s",$Rozdil-3600)."\n\n");
Note: See TracChangeset for help on using the changeset viewer.