Пример #1
0
 /**
  * Attempts to return a concrete DTtemp_Driver instance based
  * on $driver.
  *
  * @param $driver   The type of concrete Kronolith_Driver subclass to return.
  *                  This is based on the sensor driver ($driver). The
  *                  code is dynamically included.
  *
  * @param $params   (optional) A hash containing any additional
  *                  configuration or connection parameters a subclass
  *                  might need.
  *
  * @return          The newly created concrete Kronolith_Driver instance, or false
  *                  on error.
  */
 function &factory($driver, $params = array())
 {
     $basename = DTtemp_Driver::makeDriverFileName($driver);
     require_once $basename;
     $class = 'DTtemp_Driver_' . $driver;
     if (class_exists($class)) {
         return new $class($params);
     } else {
         Utils::fatal(new PEAR_Error(sprintf(_("Unable to load the definition of %s."), $class)), __FILE__, __LINE__);
     }
 }
Пример #2
0
<HTML>
    <HEAD><TITLE>Admin DTGraph Metadata</TITLE></HEAD>
    <BODY>
        <!-- DRAW existing table -->
        <FORM method="POST">
        <?php 
$dtDir = '../';
//may have to adjust if you move admin directory contents
require_once $dtDir . 'conf.php';
//require_once($dtDir.'utils.php');
require_once $dtDir . 'Driver.php';
$driver =& DTtemp_Driver::factory($conf['driver'], $conf['sql']);
$driver->connect();
//$driver->updateMetadata('2322', 'testing', "junky, ignore", 1, 23, 34, 1, 78.3, 600, 'brown');
//First, read submitted info to see if there is anything to do.
//check if a delete is pressed:
if (isset($delete)) {
    //echo "NEED to delete $delete";
    $result = $driver->deleteMetadata($delete);
    if ($result == true) {
        echo "Success: Deleted {$delete}";
        echo "&nbsp; <SMALL>Note: Sensor will always show if there are any readings for it</SMALL>";
    } else {
        echo "Failed to delete: {$result}";
    }
} else {
    //echo "Sorry, no delete";
}
if (isset($total) && isset($update)) {
    $counter = 0;
    echo "Committing changes... ";