Ejemplo n.º 1
0
$supportsDaily = array(1, 0, 0, 0);
if (key_exists('dataset', $_GET) && FALSE !== ($dataset = array_search($_GET['dataset'], $datasets))) {
    // ini contains defaults which can be overriden by the ini file
    $ini = array('database_type' => 'mysql', 'database_host' => 'localhost', 'database_name' => 'bec', 'database_username' => 'www-data', 'database_user_password' => '', 'bec_fault_mon_path' => '..');
    // Read configuration from ini file to override defaults
    if (file_exists($iniFilename)) {
        $ini = array_merge($ini, parse_ini_file($iniFilename));
    } else {
        if ($iniFilename != DATA_INI_FILENAME) {
            die("Error: Requested ini file '{$iniFilename}' not found\n");
        }
    }
    // Pull in the becdb.php file from the BEC fault monitoring software
    set_include_path(get_include_path() . PATH_SEPARATOR . $ini['bec_fault_mon_path']);
    require_once 'becdb.php';
    $becDB = new BECDB($ini['database_type'], $ini['database_host'], $ini['database_name'], $ini['database_username'], $ini['database_user_password']);
    $sql = '';
    if ($_GET['dataset'] == 'simtricity_flows') {
        // The Simtricity flows dataset
        $sql = "SELECT webapp_shortcode, flow_token_gen, flow_token_exp, flow_token_use\n                    FROM {$tables[$dataset]}";
        if (key_exists('site_shortcode', $_GET)) {
            $sql .= " WHERE webapp_shortcode = '{$_GET['site_shortcode']}'";
        }
    } else {
        // Weather datasets
        $sql = 'SELECT * FROM ' . $tables[$dataset];
        $dateOnly = FALSE;
        $needAnd = FALSE;
        $needWhere = TRUE;
        if (key_exists('format', $_GET)) {
            switch ($_GET['format']) {
Ejemplo n.º 2
0
        }
        $deleteSimtricityMode = TRUE;
    }
}
// ini contains defaults which can be overriden by the ini file
$ini = array('database_type' => 'mysql', 'database_host' => 'localhost', 'database_name' => 'bec', 'database_username' => 'www-data', 'database_user_password' => '', 'gmail_application_name' => 'BEC Fault Monitoring', 'gmail_credentials_path' => __DIR__ . '/bec_fault_mon.json', 'gmail_client_secret_path' => __DIR__ . '/client_secret.json', 'gmail_username' => 'me', 'gmail_from' => '*****@*****.**', 'simtricity_base_uri' => 'https://trial.simtricity.com', 'simtricity_token_path' => __DIR__ . '/simtricity_token.txt', 'forecast_io_api_key_path' => __DIR__ . '/forecast_io_api_key.txt');
// Read configuration from ini file to override defaults
if (file_exists($iniFilename)) {
    $ini = array_merge($ini, parse_ini_file($iniFilename));
} else {
    if ($iniFilename != BECFM_INI_FILENAME) {
        die("Error: Requested ini file '{$iniFilename}' not found\n");
    }
}
// Connect to the BEC database
$becDB = new BECDB($ini['database_type'], $ini['database_host'], $ini['database_name'], $ini['database_username'], $ini['database_user_password']);
// Create Centre data: get the Gmail API client and construct the service object.
$gmail = new BECGmailWrapper();
if ($deleteCCRMode) {
    // Drop the Create Centre table from the database
    $result = $becDB->exec('DROP TABLE ' . BEC_DB_CREATE_CENTRE_RAW_TABLE);
    if ($result !== FALSE) {
        $result = $gmail->deleteLabel('IMPORTED');
    }
    exit($result !== FALSE ? 0 : 1);
}
if ($deleteSimtricityMode) {
    // Drop Simtricity reading tables
    $meterInfo = $becDB->getMeterInfoArray();
    $result = TRUE;
    foreach ($meterInfo as $meter) {