function write_pluga($sd_card, &$out) { $file = $sd_card . "/serverPlugUpdate/plg/pluga"; if ($f = @fopen($file, "w+")) { $pluga = ""; $nb_plug = get_configuration("NB_PLUGS", $out); while (strlen("{$nb_plug}") < 2) { $nb_plug = "0{$nb_plug}"; } $pluga = $nb_plug . "\r\n"; for ($i = 0; $i < $nb_plug; $i++) { // Get power of the plug $tmp_power_max = get_plug_conf("PLUG_POWER_MAX", $i + 1, $out); // Get module of the plug $tmp_MODULE = get_plug_conf("PLUG_MODULE", $i + 1, $out); if ($tmp_MODULE == "") { $tmp_MODULE = "wireless"; } // Get module number of the plug $tmp_NUM_MODULE = get_plug_conf("PLUG_NUM_MODULE", $i + 1, $out); if ($tmp_NUM_MODULE == "") { $tmp_NUM_MODULE = 1; } // Get module options of the plug $tmp_MODULE_OPTIONS = get_plug_conf("PLUG_MODULE_OPTIONS", $i + 1, $out); // Get module output used $tmp_MODULE_OUTPUT = get_plug_conf("PLUG_MODULE_OUTPUT", $i + 1, $out); if ($tmp_MODULE_OUTPUT == "") { $tmp_MODULE_OUTPUT = 1; } // Create adress for this plug $tmp_pluga = 0; switch ($tmp_MODULE) { case "wireless": if ($tmp_power_max == "3500") { $tmp_pluga = $GLOBALS['PLUGA_DEFAULT_3500W'][$i]; } else { $tmp_pluga = $GLOBALS['PLUGA_DEFAULT'][$i]; } break; case "direct": // Direct plug case (Adresse 50 --> 58) $tmp_pluga = $tmp_MODULE_OUTPUT + 49; break; case "mcp230xx": // MCP plug case // Module 1 : (Adresse 60 --> 67) // Module 2 : (Adresse 70 --> 77) // Module 3 : (Adresse 80 --> 87) $tmp_pluga = 60 + 10 * ($tmp_NUM_MODULE - 1) + $tmp_MODULE_OUTPUT - 1; break; case "dimmer": // Dimmer plug case // Module 1 : (Adresse 90 --> 93) // Module 2 : (Adresse 95 --> 98) // Module 3 : (Adresse 100 --> 103) $tmp_pluga = 90 + 5 * ($tmp_NUM_MODULE - 1) + $tmp_MODULE_OUTPUT - 1; break; case "network": // 1000 ... $tmp_pluga = 1000 + 16 * ($tmp_NUM_MODULE - 1) + $tmp_MODULE_OUTPUT - 1; break; case "xmax": // xmax plug case // Module 1 : (Adresse 105 --> 108) $tmp_pluga = 105 + $tmp_MODULE_OUTPUT - 1; break; case "pwm": // pwm plug case // Module 1 : (Adresse 31 --> 38) // Module 2 : (Adresse 39 --> 44) // Module 3 : (Adresse 45 --> 49) $base = 31; if ($tmp_NUM_MODULE == 2) { $base = 39; } if ($tmp_NUM_MODULE == 3) { $base = 45; } $tmp_pluga = $base + $tmp_MODULE_OUTPUT - 1; break; case "bulcky": // bulcky plug case // Module 1 : (Adresse 2000 --> 2004) // Module 2 : (Adresse 2010 --> 2014) // Module 3 : (Adresse 2020 --> 2024) //$tmp_pluga = 2000 + 10 * ($tmp_NUM_MODULE - 1) + $tmp_MODULE_OUTPUT - 1; $tmp_pluga = 2000 + $tmp_MODULE_OUTPUT - 1; break; } while (strlen($tmp_pluga) < 3) { $tmp_pluga = "0{$tmp_pluga}"; } $pluga = $pluga . $tmp_pluga . "\r\n"; } if (!@fwrite($f, "{$pluga}")) { fclose($f); return false; } } else { return false; } fclose($f); return true; }
global $_admin_menu; global $_admin_toolbar_button; $_admin_menu = array(); $_admin_toolbar_button = array(); global $_admin_plugin_content; $_admin_plugin_content = ''; global $locale; $locale = !empty($_GET['lang']) ? $_GET['lang'] : DEFAULT_LOCALE; $_SESSION['lang'] = $locale; load_admin_plugins(DEFAULT_PLUGIN_PATH); load_active_plugins(); load_theme_language('admin_theme', '', 'default'); load_includes_language(); $theme = get_option('active_theme'); load_theme_language($theme . '-theme', '', $theme); $charset = get_configuration('charset_html'); global $admin_page; $admin_page = isset($_GET['admin-page']) ? $_GET['admin-page'] : 'dashboard'; if ($admin_page == 'dashboard') { $_GET['admin-page'] = $admin_page; } global $sub_page; $sub_page = isset($_GET['sub_page']) ? $_GET['sub_page'] : ''; $m2 = isset($_admin_menu[$admin_page]) ? $_admin_menu[$admin_page] : array(); if (!empty($m2)) { $_call_back = isset($m2['callback']) ? $m2['callback'] : ''; if (!empty($m2['sub']) && !empty($sub_page) && !empty($m2['sub'][$sub_page])) { if (!empty($m2['sub'][$sub_page]['callback'])) { $_call_back = $m2['sub'][$sub_page]['callback']; } }
<?php // Include commonly-used functions include_once 'general_functions.php'; // Access parameters for the database and OFS configuration table $database_config = array('db_host' => 'localhost', 'db_user' => 'openfood_user', 'db_pass' => 'openfood_password', 'db_name' => 'openfoodsource', 'db_prefix' => 'ofs_', 'openfood_config' => 'configuration'); // Include override values, but only if the file exists @(include_once "config_override.php"); // Establish database connection connect_to_database($database_config); // Set all additional configurations from the database get_configuration($database_config, $override_config); // Set the time zone date_default_timezone_set(LOCAL_TIME_ZONE); // Set error reporting level ini_set('display_errors', DEBUG); // Set error reporting level // Convert the comma-separated ERROR_FLAGS into boolean constants and bitwise-or them together if (!is_int(ERROR_FLAGS)) { $error_flags = array_reduce(array_map('constant', explode(',', ERROR_FLAGS)), function ($a, $b) { return $a | $b; }, 0); } error_reporting($error_flags);
// Include necessary files include_once 'config.php'; include_once 'functions.php'; // MySQL mysql_connect(global_mysql_server, global_mysql_user, global_mysql_password) or die('<span class="error_span"><u>MySQL error:</u> ' . htmlspecialchars(mysql_error()) . '</span>'); mysql_select_db(global_mysql_database) or die('<span class="error_span"><u>MySQL error:</u> ' . htmlspecialchars(mysql_error()) . '</span>'); mysql_set_charset('utf8'); define('global_mysql_configuration_table', 'phpmyreservation_configuration'); define('global_mysql_users_table', 'phpmyreservation_users'); define('global_mysql_reservations_table', 'phpmyreservation_reservations'); // Cookies define('global_cookie_prefix', 'phpmyreservation'); // Start session session_start(); // Configuration define('global_price', get_configuration('price')); // Date define('global_year', date('Y')); // define('global_week_number', ltrim(date('W'), '0')); define('global_week_number', 1); define('global_day_number', date('N')); define('global_day_name', date('l')); // User agent if (isset($_SERVER['HTTP_USER_AGENT'])) { define('global_ua', $_SERVER['HTTP_USER_AGENT']); } else { define('global_ua', 'CLI'); } if (strstr(global_ua, 'iPhone') || strstr(global_ua, 'iPod') || strstr(global_ua, 'iPad') || strstr(global_ua, 'Android')) { if (strstr(global_ua, 'AppleWebKit')) { if (strstr(global_ua, 'OS 5_') || strstr(global_ua, 'Android 2.3') || strstr(global_ua, 'Android 3') || strstr(global_ua, 'Android 4')) {
foreach ($tags as $ns => $tag) { if (!empty($_GET[$ns . '_code'])) { die(call_user_func($tag[$_GET[$ns . '_code']], $_REQUEST, null, $_GET[$ns . '_code'])); } } } // get layout $layout = array(); $layouts = get_option('layouts'); foreach ($layouts as $v) { if ($v['id'] == $rs['page_layout']) { $layout = $v; break; } } if (get_configuration('accessibility') == 'onlymember' && !is_login()) { $layout = array('layout_name' => '', 'pattern' => 1, 'json_data' => '{}', 'setting_data' => array()); } $widgets = array(); if (!empty($layout['json_data'])) { $widgets = json_decode($layout['json_data'], true); $active_widgets = get_option('active_widgets'); } $setting_data = array(); if (!empty($layout['setting_data'])) { $setting_data = $layout['setting_data']; } // get footer $footer = get_option('footer'); $widgets_footer = array(); if (!empty($footer['json_data'])) {
<p class="smalltext_p">These will require a confirmation. Your user and reservations will not be deleted unless you delete everything.</p> <p><input type="button" class="small_button" id="delete_all_reservations_button" value="Delete all reservations"> <input type="button" class="small_button" id="delete_all_users_button" value="Delete all users"> <input type="button" class="small_button" id="delete_everything_button" value="Delete everything"></p> <p id="database_administration_message_p"></p> <hr> <h3>System configuration</h3> <p class="smalltext_p">Changing the price will not affect previous reservations.</p> <form action="." id="system_configuration_form"><p> <input type="text" id="price_input" value="<?php echo get_configuration('price'); ?> "> <label for="price_input">Price per reservation, in <?php echo global_currency; ?> </label><br><br> <input type="submit" class="blue_button small_button" value="Save configuration"> </p></form> <p id="system_configuration_message_p"></p> <hr class="blue_hr thick_hr"> <?php
$name = $_GET['name']; } else { echo json_encode(""); return 1; } if (!empty($_GET['value'])) { $value = $_GET['value']; } else { echo json_encode(""); return 1; } if (!empty($_GET['id'])) { $id = $_GET['id']; } else { echo json_encode(""); return 1; } if ($id == "all") { for ($nb = 1; $nb <= get_configuration("NB_PLUGS", $main_error); $nb++) { insert_plug_conf(strtoupper($name), $nb, $value, $main_error); } } else { insert_plug_conf(strtoupper($name), $id, $value, $main_error); } if (count($main_error) > 0) { foreach ($main_error as $error) { echo json_encode($error); } } else { echo json_encode(""); }
if (!isset($value_program)) { $value_program = getvar('value_program'); } if (!isset($regul_program)) { $regul_program = getvar("regul_program"); } if (!isset($start_time)) { $start_time = getvar("start_time"); } if (!isset($end_time)) { $end_time = getvar("end_time"); } // Get configuration value $second_regul = get_configuration("ADVANCED_REGUL_OPTIONS", $main_error); $remove_1000_change_limit = get_configuration("REMOVE_1000_CHANGE_LIMIT", $main_error); $remove_5_minute_limit = get_configuration("REMOVE_5_MINUTE_LIMIT", $main_error); $resume_regul = array(); $tmp_prog = ""; $start = ""; $end = ""; // Var used to choose programm to display and modify if (!isset($program_index_id)) { $program_index_id = getvar("program_index_id"); } if ($program_index_id == "") { $program_index_id = 1; } // Get "number" field of program table $program_index = programs\get_field_from_program_index("program_idx", $program_index_id); // Get number of daily program recorded: $nb_daily_program = get_nb_daily_program($main_error);
function compare_program($data, $file) { $out = array(); if (is_file("{$file}")) { $nb = 0; //On compte le nombre d'entrée dans la base des programmes: $nbdata = count($data); //Si les changements de la base dépassent ceux de maximum définit, on coupe le tableau des programmes pour le faire //correspondre au nombre maximal if (get_configuration("REMOVE_1000_CHANGE_LIMIT", $out) == "False") { if ($nbdata > $GLOBALS['PLUGV_MAX_CHANGEMENT']) { $tmp_array = array_slice($data, 0, $GLOBALS['PLUGV_MAX_CHANGEMENT'] - 1); $tmp_array[] = $data[$nbdata - 1]; $data = $tmp_array; $nbdata = count($data); } } while (strlen($nbdata) < 5) { $nbdata = "0{$nbdata}"; } if (count($data) > 0) { //On récupère les informations du fichier courant plugv $buffer_array = @file("{$file}"); foreach ($buffer_array as $buffer) { $buffer = trim($buffer); //On supprime les caractères invisibles if (!empty($buffer)) { if ($nb == 0) { if (strcmp("{$nbdata}", "{$buffer}") != 0) { //S'il s'agit de la première ligne, qui contient le nombre d'entrée, on compare le nombre d'entrée du fichier avec le nombre d'entrée du tableau return false; } } else { if (strcmp($data[$nb - 1], $buffer) != 0) { //Sinon on compare le contenu du fichier et celui de la ligne correspondante dans le tableau return false; } } $nb = $nb + 1; } else { if ($nb == 0) { return false; } } } return true; //Tout est égal, on renvoie true } } return false; }
logs\reset_fake_log(); } } //============================== GET OR SET CONFIGURATION PART ==================== //update_conf is used to define if there is an impact on SD card $conf_arr["COLOR_HUMIDITY_GRAPH"] = array("update_conf" => "0", "var" => "color_humidity"); $conf_arr["COLOR_TEMPERATURE_GRAPH"] = array("update_conf" => "0", "var" => "color_temperature"); $conf_arr["COLOR_WATER_GRAPH"] = array("update_conf" => "0", "var" => "color_water"); $conf_arr["COLOR_LEVEL_GRAPH"] = array("update_conf" => "0", "var" => "color_level"); $conf_arr["COLOR_PH_GRAPH"] = array("update_conf" => "0", "var" => "color_ph"); $conf_arr["COLOR_EC_GRAPH"] = array("update_conf" => "0", "var" => "color_ec"); $conf_arr["COLOR_OD_GRAPH"] = array("update_conf" => "0", "var" => "color_od"); $conf_arr["COLOR_ORP_GRAPH"] = array("update_conf" => "0", "var" => "color_orp"); $conf_arr["COLOR_PROGRAM_GRAPH"] = array("update_conf" => "0", "var" => "color_program"); foreach ($conf_arr as $key => $value) { ${$value['var']} = get_configuration($key, $main_error); } // Build array for y axis $yaxis_array = array(); $yaxis_array[0] = programs\get_curve_information('temperature'); $yaxis_array[1] = programs\get_curve_information('humidity'); $yaxis_array[2] = programs\get_curve_information('water'); $yaxis_array[3] = programs\get_curve_information('level'); $yaxis_array[4] = programs\get_curve_information('ph'); $yaxis_array[5] = programs\get_curve_information('ec'); $yaxis_array[6] = programs\get_curve_information('od'); $yaxis_array[7] = programs\get_curve_information('orp'); $yaxis_array[8] = programs\get_curve_information('power'); $yaxis_array[9] = programs\get_curve_information('program'); // Used to alert user if export is could be done $check_log = logs\check_export_table_csv("logs", $main_error);
function create_program_from_database(&$out, $fieldNumber = 1) { date_default_timezone_set('UTC'); // Read the number of plugs $nb_plugs = get_configuration("NB_PLUGS", $out); // Read plugs configuration $plugsConfig = plugs\getDB(); // Get programs for plugs $sql = "SELECT * FROM programs WHERE plug_id IN (SELECT id FROM plugs WHERE id <= " . $nb_plugs . ") AND number = '" . $fieldNumber . "' ORDER BY time_start ASC;"; $db = db_priv_pdo_start(); try { $sth = $db->prepare($sql); $sth->execute(); $res = $sth->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $ret = $e->getMessage(); if ($GLOBALS['DEBUG_TRACE']) { $out[] = __('ERROR_SELECT_SQL') . $ret; } else { $out[] = __('ERROR_SELECT_SQL'); } unset($ret); } // Select first element of program $sql = "SELECT * FROM programs WHERE time_start = '000000' AND plug_id IN (SELECT id FROM plugs WHERE id <= " . $nb_plugs . ") AND number = '" . $fieldNumber . "' ORDER BY time_start ASC;"; try { $sth = $db->prepare($sql); $sth->execute(); $first = $sth->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $ret = $e->getMessage(); if ($GLOBALS['DEBUG_TRACE']) { $out[] = __('ERROR_SELECT_SQL') . $ret; } else { $out[] = __('ERROR_SELECT_SQL'); } unset($ret); } // Select last element of program $sql = "SELECT * FROM programs WHERE time_stop = '235959' AND plug_id IN (SELECT id FROM plugs WHERE id <= " . $nb_plugs . ") AND number = '" . $fieldNumber . "' ORDER by time_start ASC;"; try { $sth = $db->prepare($sql); $sth->execute(); $last = $sth->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $ret = $e->getMessage(); if ($GLOBALS['DEBUG_TRACE']) { $out[] = __('ERROR_SELECT_SQL') . $ret; } else { $out[] = __('ERROR_SELECT_SQL'); } unset($ret); } $j = 1; $data = array(); $data[0] = ""; date_default_timezone_set('UTC'); if (count($first) > 0) { while ($j <= $GLOBALS['NB_MAX_PLUG']) { if ($j > $nb_plugs) { $result = "000"; } else { $result = find_value_for_plug($first, "000000", $j, $plugsConfig[$j - 1]["PLUG_TYPE"]); } $data[0] = $data[0] . "{$result}"; $j = $j + 1; } $data[0] = "00000" . $data[0]; } else { $data[0] = "00000000000000000000000000000000000000000000000000000"; } $event = array(); foreach ($res as $result) { if ($result['time_start'] != "000000") { $event[] = $result['time_start']; } if ($result['time_stop'] != "235959") { $event[] = $result['time_stop']; } } if (count($event) > 0) { $event = array_unique($event); sort($event); } $evt = array(); $i = 0; $count = 0; if (count($event) > 0) { while ($count < count($event)) { if (isset($event[$i])) { $evt[] = $event[$i]; $count = $count + 1; } $i = $i + 1; } $event = $evt; } $plg = array(); for ($i = 1; $i <= $nb_plugs; $i++) { $sql = "SELECT * FROM programs WHERE plug_id = " . $i . " AND number = '" . $fieldNumber . "' ORDER BY time_start ASC;"; try { $sth = $db->prepare($sql); $sth->execute(); $plg[$i] = $sth->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $plg[$i] = $e->getMessage(); if ($GLOBALS['DEBUG_TRACE']) { $out[] = __('ERROR_SELECT_SQL') . $ret; } else { $out[] = __('ERROR_SELECT_SQL'); } unset($ret); } } if (count($event) > 0) { for ($i = 0; $i < count($event); $i++) { $data[$i + 1] = ""; $j = 1; while ($j <= $GLOBALS['NB_MAX_PLUG']) { if ($j > $nb_plugs) { $result = "000"; } else { $result = find_value_for_plug($plg[$j], $event[$i], $j, $plugsConfig[$j - 1]["PLUG_TYPE"]); } $data[$i + 1] = $data[$i + 1] . "{$result}"; $j = $j + 1; } $ehh = substr($event[$i], 0, 2); $emm = substr($event[$i], 2, 2); $ess = substr($event[$i], 4, 2); $time_event = mktime($ehh, $emm, $ess, 1, 1, 1970); while (strlen($time_event) != 5) { $time_event = "0{$time_event}"; } $data[$i + 1] = $time_event . $data[$i + 1]; } } $count = count($data); $j = 1; if (count($last) > 0) { while ($j <= $GLOBALS['NB_MAX_PLUG']) { if ($j > $nb_plugs) { $result = "000"; } else { $result = find_value_for_plug($last, "235959", $j, $plugsConfig[$j - 1]["PLUG_TYPE"]); } if (isset($data[$count])) { $data[$count] = $data[$count] . "{$result}"; } else { $data[$count] = "{$result}"; } $j = $j + 1; } $data[$count] = "86399" . $data[$count]; } else { $data[$count] = "86399000000000000000000000000000000000000000000000000"; } return $data; }
} header('location: ?page=login'); } else { header('location: index.php'); } } else { if (!isset($_GET['page'])) { if (!empty($_GET['ref'])) { header('location: ?page=login&ref=' . urlencode($_GET['ref'])); } else { header('location: ?page=login'); } } } global $locale; define('DEFAULT_LOCALE', get_configuration('site_language')); $locale = !empty($_GET['lang']) ? $_GET['lang'] : DEFAULT_LOCALE; $_SESSION['lang'] = $locale; load_includes_language(); load_language('user', 'user'); ?> <html class="bg-blue"> <head> <meta charset="UTF-8"> <title><?php echo $sitename . " | " . __('Login', 'user'); ?> </title> <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> <!-- bootstrap 3.0.2 --> <link href="../media/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
function get_curve_information($curveType, $curveIndex = 0) { // init return array $ret_array = array(); // In function of curve information asked switch ($curveType) { case 'temperature': case '21': $ret_array['name'] = __('TEMP_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_TEMPERATURE_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_RED"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('TEMP_LEGEND', 'hc'); $ret_array['yaxis'] = 0; $ret_array['unit'] = "°C"; $ret_array['curveType'] = "temperature"; break; case 'humidity': case '121': $ret_array['name'] = __('HUMI_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_HUMIDITY_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_BLUE"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('HUMI_LEGEND', 'hc'); $ret_array['yaxis'] = 1; $ret_array['unit'] = "%RH"; $ret_array['curveType'] = "humidity"; break; case 'water': case '31': $ret_array['name'] = __('WATER_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_WATER_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_ORANGE"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('WATER_LEGEND', 'hc'); $ret_array['yaxis'] = 2; $ret_array['unit'] = "°C"; $ret_array['curveType'] = "water"; break; case 'level': case '61': case '71': $ret_array['name'] = __('LEVEL_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_LEVEL_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_PINK"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('LEVEL_LEGEND', 'hc'); $ret_array['yaxis'] = 3; $ret_array['unit'] = "cm"; $ret_array['curveType'] = "level"; break; case 'ph': case '81': $ret_array['name'] = __('PH_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_PH_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_BROWN"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('PH_LEGEND', 'hc'); $ret_array['yaxis'] = 4; $ret_array['unit'] = ""; $ret_array['curveType'] = "ph"; break; case 'ec': case '91': $ret_array['name'] = __('EC_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_EC_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_YELLOW"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('EC_LEGEND', 'hc'); $ret_array['yaxis'] = 5; $ret_array['unit'] = "mS"; $ret_array['curveType'] = "ec"; break; case 'od': case ':1': $ret_array['name'] = __('OD_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_OD_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_RED"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('OD_LEGEND', 'hc'); $ret_array['yaxis'] = 6; $ret_array['unit'] = "mg/L"; $ret_array['curveType'] = "od"; break; case 'orp': case ';1': $ret_array['name'] = __('ORP_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_ORP_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_BLUE"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('ORP_LEGEND', 'hc'); $ret_array['yaxis'] = 7; $ret_array['unit'] = "mV"; $ret_array['curveType'] = "orp"; break; case 'co2': case '101': $ret_array['name'] = __('CO2_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_CO2_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_BLUE"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('CO2_LEGEND', 'hc'); $ret_array['yaxis'] = 7; $ret_array['unit'] = "ppm"; $ret_array['curveType'] = "co2"; break; case 'pressure': case '111': $ret_array['name'] = __('PRESSURE_SENSOR', 'hc'); $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_" . strtoupper(get_configuration("COLOR_PRESSURE_GRAPH", $main_error)); if ($colorIndexName == "LIST_GRAPHIC_COLOR_SENSOR_") { $colorIndexName = "LIST_GRAPHIC_COLOR_SENSOR_BLUE"; } $ret_array['color'] = $GLOBALS[$colorIndexName][$curveIndex % 5]; $ret_array['legend'] = __('PRESSURE_LEGEND', 'hc'); $ret_array['yaxis'] = 7; $ret_array['unit'] = "bar"; $ret_array['curveType'] = "pressure"; break; case 'power': $ret_array['name'] = __('POWER'); $ret_array['color'] = $GLOBALS["LIST_GRAPHIC_COLOR_POWER"][$curveIndex % 10]; $ret_array['legend'] = __('POWER_LEGEND', 'hc'); $ret_array['yaxis'] = 8; $ret_array['unit'] = "W"; $ret_array['curveType'] = "power"; break; case 'program': default: $ret_array['name'] = __('PROGRAM_LEGEND'); $ret_array['color'] = $GLOBALS["LIST_GRAPHIC_COLOR_PROGRAM"][$curveIndex % 10]; $ret_array['legend'] = __('PROGRAM_LEGEND'); $ret_array['yaxis'] = 9; $ret_array['unit'] = ""; $ret_array['curveType'] = "program"; break; } // Common parameters for each curv switch ($ret_array['color']) { case 'blue': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_BLUE']; break; case 'red': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_RED']; break; case 'green': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_GREEN']; break; case 'black': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_BLACK']; break; case 'purple': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_PURPLE']; break; case 'orange': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_ORANGE']; break; case 'pink': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_PINK']; break; case 'brown': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_BROWN']; break; case 'yellow': $ret_array['colorgrid'] = $GLOBALS['GRAPHIC_COLOR_GRID_YELLOW']; break; default: $ret_array['colorgrid'] = ""; } return $ret_array; }
$value = explode('_', $value); if (count($value) != 2) { echo "error"; break; } if (!check_times($value[0], $value[1])) { echo "error"; } break; case 'cyclic_time': if (!check_format_time("{$value}")) { echo "error"; } // Check if cyclic time is under 5minutes only if this limit is not deselected $main_error = ""; if (strcmp(get_configuration("REMOVE_5_MINUTE_LIMIT", $main_error), "False") == 0) { $tmp = str_replace(":", "", $value); if ($tmp < 500) { echo "2"; return 0; } } break; case 'value_program': if (isset($_GET['plug_type']) && !empty($_GET['plug_type'])) { if (!isset($_GET['plug_tolerance']) || empty($_GET['plug_tolerance'])) { $tolerance = 0; } else { $tolerance = $_GET['plug_tolerance']; } $plug_type = $_GET['plug_type'];
require_once '../../libs/utilfunc.php'; require_once '../../libs/db_get_common.php'; require_once '../../libs/db_set_common.php'; require_once '../../libs/config.php'; if (isset($_GET['startday']) && !empty($_GET['startday'])) { $startday = $_GET['startday']; } if (isset($_GET['select_plug']) && !empty($_GET['select_plug'])) { $select_plug = $_GET['select_plug']; } if (isset($_GET['type']) && !empty($_GET['type'])) { $type = $_GET['type']; } if (isset($startday) && !empty($startday) && isset($select_plug) && !empty($select_plug) && isset($type) && !empty($type)) { $main_error = array(); $cost_type = get_configuration("COST_TYPE", $main_error); $power = 0; //Computing cost value: if (strcmp("{$type}", "theorical") == 0) { $power = get_theorical_power($select_plug, $cost_type, $main_error, $check); } else { $startTime = strtotime("{$startday} 12:00"); $thisDate = date('Y-m-d', $startTime); // 2010-05-01, 2010-05-02, etc $data_power = get_data_power($thisDate, $thisDate, $select_plug, $main_error); $power = get_real_power($data_power, $cost_type, $main_error); unset($data_power); } echo "{$power}"; }
if (!isset($submenu)) { $submenu = getvar("submenu", $main_error); } if (!isset($reccord)) { $reccord = getvar('reccord'); } // By default the expanded menu is the plug1 menu if (!isset($submenu) || empty($submenu)) { $submenu = "1"; } if (!isset($selected_plug) || empty($selected_plug)) { $selected_plug = "1"; } $nb_plugs = get_configuration("NB_PLUGS", $main_error); if (!isset($second_regul)) { $second_regul = get_configuration("ADVANCED_REGUL_OPTIONS", $main_error); } // Retrieve plug's informations from the database if (!isset($plugs_infos)) { $plugs_infos = get_plugs_infos($nb_plugs, $main_error); } for ($nb = 1; $nb <= $nb_plugs; $nb++) { $plug_name[$nb] = get_plug_conf("PLUG_NAME", $nb, $main_error); $plug_type[$nb] = get_plug_conf("PLUG_TYPE", $nb, $main_error); $plug_power[$nb] = get_plug_conf("PLUG_POWER", $nb, $main_error); $plug_regul[$nb] = get_plug_conf("PLUG_REGUL", $nb, $main_error); $plug_senso[$nb] = get_plug_conf("PLUG_SENSO", $nb, $main_error); $plug_senss[$nb] = get_plug_conf("PLUG_SENSS", $nb, $main_error); $plug_regul_value[$nb] = get_plug_conf("PLUG_REGUL_VALUE", $nb, $main_error); $plug_power_max[$nb] = get_plug_conf("PLUG_POWER_MAX", $nb, $main_error); $plug_tolerance[$nb] = get_plug_conf("PLUG_TOLERANCE", $nb, $main_error);
$cost_price_hp = str_replace(",", ".", "{$cost_price_hp}"); insert_configuration("COST_PRICE_HP", "{$cost_price_hp}", $main_error); } else { $cost_price_hp = get_configuration("COST_PRICE_HP", $main_error); } if (isset($start_hc) && !empty($start_hc)) { insert_configuration("START_TIME_HC", "{$start_hc}", $main_error); } else { $start_hc = get_configuration("START_TIME_HC", $main_error); } if (isset($stop_hc) && !empty($stop_hc)) { insert_configuration("STOP_TIME_HC", "{$stop_hc}", $main_error); } else { $stop_hc = get_configuration("STOP_TIME_HC", $main_error); } $cost_price = get_configuration("COST_PRICE", $main_error); } //Computing cost value: if (strcmp($select_plug, "distinct_all") != 0 && strcmp($select_plug, "all") != 0) { if (isset($submit_cost) && !empty($submit_cost)) { $theorical_power = "0"; $real_power = "0"; } else { $theorical_power = get_theorical_power($select_plug, $cost_type, $main_error, $check); $nb = get_nb_days($startday, $endday) + 1; $theorical_power = $theorical_power * $nb; $startTime = strtotime("{$startday} 12:00"); $endTime = strtotime("{$endday} 12:00"); $real_power = 0; for ($i = $startTime; $i <= $endTime; $i = $i + 86400) { $thisDate = date('Y-m-d', $i);