Changeset 468


Ignore:
Timestamp:
Dec 16, 2012, 10:46:34 PM (11 years ago)
Author:
chronos
Message:
  • Přidáno: Třída pro manipulaci s obrázky.
  • Přidáno: Generování obrázku z měřených dat meteostanice.
Location:
trunk
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Log.php

    r438 r468  
    77  function NewRecord($Module, $Operation, $Value = '')
    88  {
    9     $this->Database->insert('Log', array('Time' => 'NOW()', 'User' => $this->System->Modules['User']->User['Id'], 'Module' => $Module, 'Operation' => $Operation, 'Value' => $Value));
     9    if(array_key_exists('User', $this->System->Modules) and
     10      array_key_exists('Id', $this->System->Modules['User']->User))
     11      $UserId = $this->System->Modules['User']->User['Id'];
     12      else $UserId = NULL;
     13    $this->Database->insert('Log', array('Time' => 'NOW()',
     14      'User' => $UserId, 'Module' => $Module,
     15      'Operation' => $Operation, 'Value' => $Value));
    1016    //echo($this->Database->LastQuery);
    1117  }
  • trunk/Modules/Meteostation/Download.php

    r467 r468  
    44
    55$MeteoStation = new MeteoStation($System->Database, $System);
    6 $MeteoStation->DownloadAll();
     6while(true)
     7{
     8  $MeteoStation->DownloadAll();
     9  sleep(60);
     10}
    711
    812?>
  • trunk/Modules/Meteostation/Meteostation.php

    r467 r468  
    11<?php
     2
     3include_once('../../Common/Image.php');
    24
    35class PageMeteo extends Page
     
    1113class MeteoStation extends AppModule
    1214{
    13  
     15  var $Data;
     16 
    1417  function __construct($Database, $System)
    1518  {
     
    4851      'RelHumidity' => $Data['RelHumidity'], 'AbsHumidity' => $Data['AbsHumidity'],
    4952      'DewPoint' => $Data['DewPoint']));
     53    $this->Data = $Data;
    5054  }
    5155 
     
    5660    {
    5761      $this->DownloadData($DbRow['Id'], $DbRow['URL']);
     62      $this->CreateImage('cache/'.$DbRow['Id'].'.png');
    5863    }
     64  }
     65 
     66  function CreateImage($FileName)
     67  {
     68    $Image = new Image();
     69    $Image->SetSize(150, 150);
     70    $Image->Brush->Color = COLOR_WHITE;
     71    $Image->FillRect(0, 0, $Image->GetWidth(), $Image->GetHeight());
     72    //$Image->Font->Color = COLOR_RED;
     73    //$Image->Line(10, 10, 100, 100);
     74    $Image->TextOut(10, 10, 'Meteo Koliba Zděchov');
     75    $Image->TextOut(10, 30, 'Teplote: '.$this->Data['Temperature'].' °C');
     76    $Image->SaveToFile($FileName);
    5977  }
    6078 
  • trunk/sql/updates/468.sql

    r467 r468  
    3333ALTER TABLE `MeteoStationMeasure`
    3434  ADD CONSTRAINT `MeteoStationMeasure_ibfk_1` FOREIGN KEY (`MeteoStation`) REFERENCES `MeteoStation` (`Id`);
     35
     36ALTER TABLE `Log` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL ;
Note: See TracChangeset for help on using the changeset viewer.