define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
PluginMonitoringProfile::checkRight("weathermap", "w");
commonHeader($LANG['plugin_monitoring']['title'][0], $_SERVER["PHP_SELF"], "plugins", "monitoring", "weathermap");
$pmWeathermap = new PluginMonitoringWeathermap();
//print_r($_POST);exit;
if (isset($_POST['deletepic_x'])) {
    // Delete picture
    $input = array();
    $input['id'] = $_POST['id'];
    $input['background'] = '';
    $pmWeathermap->update($input);
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["add"])) {
        $pmWeathermap->add($_POST);
        glpi_header($_SERVER['HTTP_REFERER']);
    } else {
        if (isset($_POST["update"])) {
            $pmWeathermap->update($_POST);
            glpi_header($_SERVER['HTTP_REFERER']);
        } else {
            if (isset($_POST["delete"])) {
                $pmWeathermap->delete($_POST);
                $pmWeathermap->redirectToList();
            }
        }
    }
}
if (isset($_GET["id"])) {
    $pmWeathermap->showForm($_GET["id"]);