Changeset 50 for branches/old/index.php


Ignore:
Timestamp:
Feb 20, 2015, 8:54:42 AM (9 years ago)
Author:
chronos
Message:
  • Modified: Show graph, table and other controls horizontally centered.
  • Added: Check for existence of config file.
  • Added: Check if database is accessible.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/old/index.php

    r49 r50  
    1111
    1212      $TimeParts = getdate($_SESSION[$Time]);
    13       //print_r($TimeParts);
    1413
    1514      // Day selection
     
    1716      for($I = 1; $I < 32; $I++)
    1817      {
    19         if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 
     18        if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    2019        $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    2120      }
     
    2524      $Output .= '<select name="Month">';
    2625      foreach($Months as $Index => $Month)
    27       { 
    28         if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = ''; 
     26      {
     27        if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    2928        if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
    3029      }
    3130      $Output .= '</select>. ';
    32      
     31
    3332      // Day selection
    3433      $Output .= '<select name="Year">';
    3534      for($I = 2000; $I < 2010; $I++)
    36       { 
    37         if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = ''; 
     35      {
     36        if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    3837        $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    3938      }
    4039      $Output .= '</select> &nbsp;&nbsp; ';
    41      
    42      
     40
    4341      // Hour selection
    4442      $Output .= '<select name="Hour">';
    4543      for($I = 0; $I < 24; $I++)
    46       { 
    47         if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = ''; 
     44      {
     45        if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    4846        $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    4947      }
     
    5452      for($I = 0; $I < 60; $I++)
    5553      {
    56         if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = ''; 
     54        if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
    5755        $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5856      }
    5957      $Output .= '</select> ';
    60       $Output .= '<input type="submit" value="Nastavit">';     
     58      $Output .= '<input type="submit" value="Nastavit">';
    6159      $Output .= '</form>';
    6260
    6361      $Output .= ' <form style="display: inline;" action="?Operation=SetTimeNow&amp;Time='.$Time.'" method="post">';
    64       $Output .= '<input type="submit" value="Aktuální čas">';     
     62      $Output .= '<input type="submit" value="Aktuální čas">';
    6563      $Output .= '</form>';
    66      
     64
    6765      return($Output);
    6866}
     
    7371$GrafTimeRanges = array(
    7472  'hour' => array(
    75     'caption' => 'Hodina', 
     73    'caption' => 'Hodina',
    7674    'period' => 3600,
    7775  ),
    7876  'day' => array(
    7977    'caption' => 'Den',
    80     'period' => 3600*24,
     78    'period' => 3600 * 24,
    8179  ),
    8280  'week' => array(
    8381    'caption' => 'Týden',
    84     'period' => 3600*24*7,
     82    'period' => 3600 * 24 * 7,
    8583  ),
    8684  'month' => array(
    8785    'caption' => 'Měsíc',
    88     'period' => 3600*24*30,
     86    'period' => 3600 * 24 * 30,
    8987  ),
    9088  'year' => array(
    9189    'caption' => 'Rok',
    92     'period' => 3600*24*365,
     90    'period' => 3600 * 24 * 365,
    9391  ),
    9492  'years' => array(
    9593    'caption' => 'Desetiletí',
    96     'period' => 3600*24*365*10,
    97   ),
    98 ); 
     94    'period' => 3600 * 24 * 365 * 10,
     95  ),
     96);
    9997
    10098foreach($Config['DefaultVariables'] as $Index => $Variable)
     
    104102  if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    105103  //$$Index = $_SESSION[$Index];
    106 } 
     104}
    107105
    108106if($_SESSION['TimeSpecify'] == 0)
     
    112110}
    113111
    114 $Output = '<div class="Title">Statistiky</div>';
     112$Output = '<div style="text-align: center"><div class="Title">Statistiky</div>';
    115113
    116114if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     
    128126        }
    129127      }
    130     break; 
     128    break;
    131129  case 'SetTimeNow':
    132130    if(array_key_exists('Time', $_GET))
     
    138136      }
    139137    }
    140     break; 
    141  
     138    break;
     139
    142140    }
    143141    $Output .= '<strong>Časový úsek:</strong><br>';
    144     // Show graf time range menu
     142    // Show graph time range menu
    145143    if($_SESSION['TimeSpecify'] == 0)
    146144    {
     
    151149      $Output .= '<a href="?TimeSpecify=1">Přesnější nastavení...</a><br>'; 
    152150    } else {
    153       $Output .= '<table cellspacing="0" cellpadding="2" border="0">';
     151      $Output .= '<table cellspacing="0" cellpadding="2" border="0" style="margin: 0px auto;">';
    154152      $Output .= '<tr><td>Počátek:</td><td>'.EditTime('TimeStart').'</td></tr>';
    155153      $Output .= '<tr><td>Konec:</td><td>'.EditTime('TimeEnd').'</td></tr>';
     
    162160$Output .= '<img alt="Graf" src="graph.php?Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width=750&amp;Height=200&amp;Differential='.$_SESSION['Differential'].'" width="750" height="200"><br>';
    163161$Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.$_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
    164 //print_r(GetValues($Measure, $TimeStart, $TimeEnd));
    165  
     162
    166163$Output .= '<br>';
    167164
    168 $Output .= '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">';
     165// Table with available measures
     166$Output .= '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small; margin: 0px auto;">';
    169167$Output .= '<tr><th>Měřená veličina</th><th>Poslední hodnota</th><th>Čas posledního měření</th><th>Interpolace</th><th>Poznámky</th>';
    170168if(array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
    171169$Output .= '</tr>';
    172170$Database->select_db('measure');
    173 $Result = $Database->select('measure', '*', 'Enabled=1 AND PermissionView="all" OR PermissionView="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'" ORDER BY Description');
    174 //echo($Database->error);
    175 
     171$Result = $Database->select('measure', '*', '(Enabled=1) AND ((PermissionView="all") OR (PermissionView="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) ORDER BY Description');
    176172while($Measure = $Result->fetch_array())
    177173{
     
    202198$Output .= '</table>';
    203199$Output .= '<br><a href="http://svn.zdechov.net/trac/statistic/">Sekce vývoje systému</a>';
    204 //echo(time());
    205 //print_r(gd_info());
    206 $Output .= '</body></html>';
    207 //print_r($_SESSION);
     200$Output .= '</div></body></html>';
    208201
    209202ShowPage($Output);
    210 
    211 //echo(AddPrefixMultipliers('-0.000000071112345', 'B'));
Note: See TracChangeset for help on using the changeset viewer.