Exemple #1
0
<?php

// Compute page time loading for debug option
$start_load = getmicrotime();
// Language for the interface, using a COOKIE variable and the function __('$msg') from utilfunc.php library to print messages
$main_error = array();
$main_info = array();
$sd_card = $GLOBALS['CULTIPI_CONF_TEMP_PATH'];
if (!is_dir($sd_card . "/serverAcqSensor") || !is_dir($sd_card . "/serverHisto") || !is_dir($sd_card . "/serverPlugUpdate") || !is_dir($sd_card . "/serverLog")) {
    if (strpos($_SERVER['REMOTE_ADDR'], "10.0.0.100") !== false) {
        check_and_update_sd_card($sd_card, $info, $error, false);
    }
}
if (!isset($sd_card) || empty($sd_card)) {
    setcookie("CHECK_SD", "False", time() + 1800, "/", false, false);
}
$webcam_conf = bulcky\get_webcam_conf();
for ($i = 0; $i < $GLOBALS['MAX_WEBCAM']; $i++) {
    if (is_file("tmp/webcam{$i}.jpg")) {
        $screen[$i] = "tmp/webcam{$i}.jpg";
    } else {
        $screen[$i] = "";
    }
}
//Compute time loading for debug option
$end_load = getmicrotime();
if ($GLOBALS['DEBUG_TRACE']) {
    echo __('GENERATE_TIME') . ": " . round($end_load - $start_load, 3) . " secondes.<br />";
    echo "---------------------------------------";
    aff_variables();
    echo "---------------------------------------<br />";
// Include libraries
if (file_exists('../../libs/db_get_common.php') === TRUE) {
    // Script call by Ajax
    require_once '../../libs/config.php';
    require_once '../../libs/db_get_common.php';
    require_once '../../libs/db_set_common.php';
    require_once '../../libs/utilfunc.php';
    require_once '../../libs/utilfunc_sd_card.php';
    require_once '../../libs/debug.php';
}
// Load every plugins
foreach ($GLOBALS['PLUGIN'] as $plugin) {
    $fileName = '../../plugin/' . $plugin . '/lib_' . $plugin . '.php';
    if (is_file($fileName)) {
        require_once $fileName;
    }
}
$sd_card = $_GET['sd_card'];
$main_error = array();
$main_info = array();
// If a  SD card is plugged, manage some administrators operations: check the firmware and log.txt files, check if 'programs' are up tp date...
$return = check_and_update_sd_card($sd_card, $main_info, $main_error);
if ($return > 1) {
    $main_error[] = get_error_sd_card_update_message($return);
}
// Create output array
$ret_array = array();
$ret_array['info'] = $main_info;
$ret_array['error'] = $main_error;
//return it in JSON format
echo json_encode($ret_array);