displayErrorAndDie() static public method

Simple Error message page
static public displayErrorAndDie ( $message, $minimal = false ) : nothing
$message string displayed before dying
$minimal set to true do not display app menu (false by default)
return nothing as function kill script
示例#1
0
/**
 * Obsolete function provided to detect compatibility issue
 *
 * @since version 0.84
**/
function handleObsoleteCall($func)
{
    $name = NOT_AVAILABLE;
    foreach (debug_backtrace() as $row) {
        if (isset($row['function']) && $row['function'] == $func && isset($row['file']) && preg_match(':(/|\\\\)plugins(/|\\\\)(.*)(/|\\\\):', $row['file'], $reg)) {
            $name = $reg[3];
            break;
        }
    }
    echo "</table>";
    Html::displayErrorAndDie(sprintf(__('The plugin %s is incompatible with this version of GLPI'), $name) . "<br><br>" . __('Delete or update it otherwise GLPI will not work correctly.'));
}
示例#2
0
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.85
*/
if (!$item_device instanceof Item_Devices) {
    Html::displayErrorAndDie('');
}
if (!$item_device->canView()) {
    // Gestion timeout session
    Session::redirectIfNotLoggedIn();
    Html::displayRightError();
}
if (isset($_POST["id"])) {
    $_GET["id"] = $_POST["id"];
} else {
    if (!isset($_GET["id"])) {
        $_GET["id"] = -1;
    }
}
if (isset($_POST["purge"])) {
    $item_device->check($_POST["id"], PURGE);
示例#3
0
if (isset($_REQUEST['forcetab'])) {
    if (preg_match('/([a-zA-Z]+).form.php/', $_SERVER['PHP_SELF'], $matches)) {
        $itemtype = $matches[1];
        Session::setActiveTab($matches[1], $_REQUEST['forcetab']);
    }
}
// Manage tabs
if (isset($_REQUEST['glpi_tab']) && isset($_REQUEST['itemtype'])) {
    Session::setActiveTab($_REQUEST['itemtype'], $_REQUEST['glpi_tab']);
}
// Override list-limit if choosen
if (isset($_REQUEST['glpilist_limit'])) {
    $_SESSION['glpilist_limit'] = $_REQUEST['glpilist_limit'];
}
// Security : Check HTTP_REFERRER : need to be in GLPI.
if (!defined('DO_NOT_CHECK_HTTP_REFERER') && !isCommandLine() && isset($_POST) && is_array($_POST) && count($_POST)) {
    if (!isset($_SERVER['HTTP_REFERER']) || !is_array($url = parse_url($_SERVER['HTTP_REFERER'])) || !isset($url['host']) || $url['host'] != $_SERVER['SERVER_NAME'] && (!isset($_SERVER['HTTP_X_FORWARDED_SERVER']) || $url['host'] != $_SERVER['HTTP_X_FORWARDED_SERVER']) || !isset($url['path']) || !empty($CFG_GLPI['root_doc']) && strpos($url['path'], $CFG_GLPI['root_doc']) !== 0) {
        Html::displayErrorAndDie(__("The action you have requested is not allowed. Reload previous page before doing action again."), true);
    }
}
// Security : check CSRF token
if (GLPI_USE_CSRF_CHECK && isset($_POST) && is_array($_POST) && count($_POST)) {
    // No ajax pages
    if (!preg_match(':' . $CFG_GLPI['root_doc'] . '(/plugins/[^/]*|)/ajax/:', $_SERVER['REQUEST_URI'])) {
        if (!Session::validateCSRF($_POST)) {
            Html::displayErrorAndDie(__("The action you have requested is not allowed. Reload previous page before doing action again."), true);
        }
    }
}
// SET new global Token
$CURRENTCSRFTOKEN = '';
 static function alter_json($action_type, $params)
 {
     //route to sub class
     $item_type = $params['itemtype'];
     if (in_array($item_type, array('PluginFusioninventoryDeployCheck', 'PluginFusioninventoryDeployFile', 'PluginFusioninventoryDeployAction'))) {
         switch ($action_type) {
             case "add_item":
                 $item_type::add_item($params);
                 break;
             case "save_item":
                 $item_type::save_item($params);
                 break;
             case "remove_item":
                 $item_type::remove_item($params);
                 break;
             case "move_item":
                 $item_type::move_item($params);
                 break;
         }
     } else {
         Toolbox::logDebug("package subtype not found : " . $params['itemtype']);
         Html::displayErrorAndDie("package subtype not found");
     }
 }
示例#5
0
    $_POST["locations_id"] = $_GET["locations_id"];
}
if (isset($_POST["affich"]) && !isset($_POST["itemtype"])) {
    $_POST["itemtype"] = "0";
}
$types = PluginPositionsPosition::getTypes();
if (!isset($_POST["itemtype"])) {
    $_POST["itemtype"] = $types;
}
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    //from central
    Html::header(PluginPositionsPosition::getTypeName(), '', "tools", "pluginpositionsmenu", "positions");
} else {
    //from helpdesk
    Html::helpHeader(PluginPositionsPosition::getTypeName());
}
$pos = new PluginPositionsPosition();
if ($pos->canView() || Session::haveRight("config", UPDATE)) {
    if (!$_POST["locations_id"]) {
        PluginPositionsPosition::showLocationForm($_POST["locations_id"]);
        Html::displayErrorAndDie(__('No location selected', 'positions'), false, ERROR);
    } else {
        $options = array('id' => 0, 'locations_id' => $_POST["locations_id"], 'itemtype' => $_POST['itemtype'], 'target' => $_SERVER['PHP_SELF'] . "?locations_id=" . $_POST["locations_id"]);
        PluginPositionsPosition::showMap($options);
    }
}
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
    Html::footer();
} else {
    Html::helpFooter();
}
 /**
  * Check valid referer accessing GLPI
  *
  * @since version 0.84.2
  *
  * @return nothing : display error if not permit
  **/
 static function checkValidReferer()
 {
     global $CFG_GLPI;
     if (!isset($_SERVER['HTTP_REFERER']) || !is_array($url = parse_url($_SERVER['HTTP_REFERER'])) || !isset($url['host']) || $url['host'] != $_SERVER['SERVER_NAME'] && (!isset($_SERVER['HTTP_X_FORWARDED_SERVER']) || $url['host'] != $_SERVER['HTTP_X_FORWARDED_SERVER']) || !isset($url['path']) || !empty($CFG_GLPI['root_doc']) && strpos($url['path'], $CFG_GLPI['root_doc']) !== 0) {
         Html::displayErrorAndDie(__("The action you have requested is not allowed. Reload previous page before doing action again."), true);
     }
 }
示例#7
0
文件: apirest.php 项目: btry/glpi
LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 9.1
*/
define('DO_NOT_CHECK_HTTP_REFERER', 1);
ini_set('session.use_cookies', 0);
include './inc/includes.php';
$api = new APIRest();
if ($CFG_GLPI['enable_api']) {
    $api->call();
} else {
    Html::displayErrorAndDie(__("API disabled"), true);
}
示例#8
0
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since vesion 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
$group_user = new Group_User();
if (isset($_POST["add"])) {
    $group_user->check(-1, CREATE, $_POST);
    if ($group_user->add($_POST)) {
        Event::log($_POST["groups_id"], "groups", 4, "setup", sprintf(__('%s adds a user to a group'), $_SESSION["glpiname"]));
    }
    Html::back();
}
Html::displayErrorAndDie("lost");
示例#9
0
<?php

include "../../../inc/includes.php";
if (!isset($_REQUEST['tickets_id'])) {
    Html::displayErrorAndDie(__("missing parameters", "escalade"));
}
PluginEscaladeTicket::assign_me(intval($_REQUEST['tickets_id']));
示例#10
0
 /**
  * Check CSRF data
  *
  * @since version 0.84.2
  *
  * @param $data array $_POST datas
  *
  * @return nothing : display error if not permit
  **/
 public static function checkCSRF($data)
 {
     if (GLPI_USE_CSRF_CHECK && !Session::validateCSRF($data)) {
         Html::displayErrorAndDie(__("The action you have requested is not allowed."), true);
     }
 }
示例#11
0
 /**
  * Display the mount toolbox
  *
  * @param CommonDBTM $item        Item referenced with the mount
  * @param string     $formName    Name of the form
  * @param string     $mountAction Action to perform
  * @param array      $data        Default data (if modified)
  * @param bool       $showDelete  Display "Delete" action button
  */
 static function rackview_mount_toolbox($item, $formName = "mountForm", $mountAction = "mount", $data = array(), $showDelete = false)
 {
     global $CFG_GLPI, $DB, $LANG;
     print '<div>';
     print '<form name="' . $formName . '" method="post" action="' . $CFG_GLPI['root_doc'] . '/plugins/rackview/front/plugin_rackview_mount.php">';
     print '<table class="tab_cadre_fixe" style="width: 100%">';
     print '<input type="hidden" name="mount_action" value="' . $mountAction . '" />';
     print '<input type="hidden" name="object_type" ' . 'value="' . $item->getType() . '" />';
     print '<input type="hidden" name="object_id" ' . 'value="' . $item->getID() . '" />';
     if (isset($data['id'])) {
         print '<input type="hidden" name="mount_id" ' . 'value="' . $data['id'] . '" />';
     }
     print '<tr class="tab_bg_1">';
     $title = $LANG['plugin_rackview']['label_addmount'];
     if (isset($data['rack_id'])) {
         // Get rack name
         $table = getTableForItemType('PluginRackviewRack');
         $rack = $DB->request($table, array('id' => $data['rack_id']));
         if ($rack->numrows() == 0) {
             Html::displayErrorAndDie($LANG['plugin_rackview']['error_invalidrackid']);
         }
         $rack = $rack->next();
         $rackLink = sprintf('<a href="%s?id=%s">%s</a>', Toolbox::getItemTypeFormURL('PluginRackviewRack'), $data['rack_id'], $rack['name']);
         $title = sprintf($LANG['plugin_rackview']['label_mount'], $rackLink);
     }
     print '<th colspan="2">' . $title . '</th>';
     print '</tr>';
     // Rack
     print '<tr>';
     print '<td title="' . $LANG['plugin_rackview']['help_rack'] . '">' . $LANG['plugin_rackview']['field_rack'] . '</td>';
     print '<td>';
     $value = -1;
     if (isset($data['rack_id'])) {
         $value = $data['rack_id'];
     }
     $mount_id = -1;
     if (isset($data['id'])) {
         $mount_id = $data['id'];
     }
     $startuCode = 'rackview_startu_';
     if (isset($data['id'])) {
         $startuCode .= $data['id'];
     } else {
         $startuCode .= 'new';
     }
     $onChangeCode = sprintf('rackview_display_rack("%s", "id", "%s", "plugin_rackview_racks_id", ' . '%d, "mini=true&startu=%s", "%s")', $CFG_GLPI["root_doc"] . '/plugins/rackview/ajax/ajax_show_rack.php', $formName, $mount_id, $startuCode, $LANG['plugin_rackview']['label_selectarack']);
     Dropdown::show('PluginRackviewRack', array('value' => $value, 'on_change' => $onChangeCode));
     print '</td>';
     print '</tr>';
     // Start-U
     print '<tr>';
     print '<td title="' . $LANG['plugin_rackview']['help_startu'] . '">' . $LANG['plugin_rackview']['field_startu'] . '</td>';
     print '<td>';
     $startuId = 'new';
     if (isset($data['id'])) {
         $startuId = $data['id'];
     }
     print '<input type="text" name="startu" id="' . 'rackview_startu_' . $startuId . '" maxlength="4" ';
     if (isset($data['startu'])) {
         print 'value="' . $data['startu'] . '"';
     }
     print '/>';
     print '</td>';
     print '</tr>';
     // Mount-Size
     print '<tr>';
     print '<td title="' . $LANG['plugin_rackview']['help_mount_size'] . '">' . $LANG['plugin_rackview']['field_mount_size'] . '</td>';
     print '<td>';
     print '<input type="checkbox" name="use_default" value="true"';
     if (!isset($data['mount_size']) || is_null($data['mount_size'])) {
         print ' checked="checked"';
     }
     $mount_size_id = 'new';
     if (isset($data['id'])) {
         $mount_size_id = $data['id'];
     }
     print sprintf('onClick = "rackview_toggle(this, \'rackview_mount_size_%s\')"', $mount_size_id);
     print '/> ' . $LANG['plugin_rackview']['label_usedefault'] . '&nbsp;';
     print sprintf('<input type="text" name="mount_size" id="rackview_mount_size_%s" ' . 'maxlength="4" ', $mount_size_id);
     if (isset($data['mount_size']) && !is_null($data['mount_size'])) {
         print 'value="' . $data['mount_size'] . '"';
     } else {
         print 'disabled="disabled"';
     }
     print '/>';
     print '</td>';
     print '</tr>';
     // Depth
     print '<tr>';
     print '<td title="' . $LANG['plugin_rackview']['help_depth'] . '">' . $LANG['plugin_rackview']['field_depth'] . '</td>';
     print '<td>';
     print '<select name="depth">';
     $value = 0;
     if (isset($data['depth'])) {
         $value = $data['depth'];
     }
     print '<option value="0"';
     if ($value == 0) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_depth_full'] . '</option>';
     print '<option value="1"';
     if ($value == 1) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_depth_front'] . '</option>';
     print '<option value="2"';
     if ($value == 2) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_depth_back'] . '</option>';
     print '</select>';
     print '</td>';
     print '</tr>';
     // Horizontal
     print '<tr>';
     print '<td title="' . $LANG['plugin_rackview']['help_horizontal'] . '">' . $LANG['plugin_rackview']['field_horizontal'] . '</td>';
     print '<td>';
     print '<select name="horizontal">';
     $value = 0;
     if (isset($data['horizontal'])) {
         $value = $data['horizontal'];
     }
     print '<option value="0"';
     if ($value == 0) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_horizontal_full'] . '</option>';
     print '<option value="1"';
     if ($value == 1) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_horizontal_left'] . '</option>';
     print '<option value="2"';
     if ($value == 2) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_horizontal_center'] . '</option>';
     print '<option value="3"';
     if ($value == 3) {
         print 'selected="selected"';
     }
     print '>' . $LANG['plugin_rackview']['option_horizontal_right'] . '</option>';
     print '</select>';
     print '</td>';
     print '</tr>';
     // Description
     print '<tr>';
     print '<td title="' . $LANG['plugin_rackview']['help_description'] . '">' . $LANG['plugin_rackview']['field_description'] . '</td>';
     print '<td>';
     $value = '&nbsp;';
     if (isset($data['description'])) {
         $value = $data['description'];
     }
     print '<textarea name="description" cols="40" rows="4">' . $value . '</textarea>';
     print '</td>';
     print '</tr>';
     print '<tr>';
     print '<td colspan="2" align="center">';
     // Submit
     print '<input type="submit" class="submit" value="' . $LANG['plugin_rackview']['label_update'] . '" />';
     if ($showDelete) {
         // Delete
         print '&nbsp;<input type="button" onClick="';
         print 'document.' . $formName . '.mount_action.value = \'unmount\'; ' . 'document.' . $formName . '.submit();';
         print '" class="submit" value="' . $LANG['plugin_rackview']['label_delete'] . '" />';
     }
     print '</td>';
     print '</tr>';
     print '</table>';
     Html::closeForm();
     print '</div>';
 }
 (at your option) any later version.

 Genericobject plugin is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Genericobject. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   genericobject
 @author    the genericobject plugin team
 @copyright Copyright (c) 2010-2014 Generic Object plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/genericobject
 @link      http://www.glpi-project.org/
 @since     2014
 ---------------------------------------------------------------------- */
include "../../../inc/includes.php";
if (isset($_REQUEST['itemtype'])) {
    $itemtype = $_REQUEST['itemtype'];
    if (class_exists($itemtype)) {
        $dropdown = new $itemtype();
        include GLPI_ROOT . "/front/dropdown.common.form.php";
    } else {
        Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
    }
} else {
    Html::displayErrorAndDie(__('Not Found!'));
}
示例#13
0
/**
 * Install the plugin
 *
 * @return boolean Was the installation successful?
 */
function plugin_rackview_install()
{
    global $DB;
    // Run SQL commands
    if (!TableExists("glpi_plugin_rackview_racks") && !TableExists("glpi_plugin_rackview_mount") && !TableExists("glpi_plugin_rackview_object")) {
        // Read in SQL-commands
        $DB->runFile(dirname(__FILE__) . "/db/mysql.1.1.sql") or Html::displayErrorAndDie("Error installing RackView plugin " . $DB->error());
    }
    return true;
}
示例#14
0
                // Doc alterated
            } else {
                $doc->send();
            }
        } else {
            Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
            // No right
        }
    }
} else {
    if (isset($_GET["file"])) {
        // for other file
        $splitter = explode("/", $_GET["file"]);
        if (count($splitter) == 2) {
            $send = false;
            if ($splitter[0] == "_dumps" && Session::haveRight("backup", CREATE)) {
                $send = true;
            }
            if ($splitter[0] == "_pictures") {
                $send = true;
            }
            if ($send && file_exists(GLPI_DOC_DIR . "/" . $_GET["file"])) {
                Toolbox::sendFile(GLPI_DOC_DIR . "/" . $_GET["file"], $splitter[1]);
            } else {
                Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
            }
        } else {
            Html::displayErrorAndDie(__('Invalid filename'), true);
        }
    }
}
示例#15
0
     $dropdown->redirectToList();
 } else {
     if (isset($_POST["update"])) {
         $dropdown->check($_POST["id"], 'w');
         $dropdown->update($_POST);
         $dropdown->refreshParentInfos();
         Event::log($_POST["id"], get_class($dropdown), 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
         Html::back();
     } else {
         if (isset($_POST['execute']) && isset($_POST['_method'])) {
             $method = 'execute' . $_POST['_method'];
             if (method_exists($dropdown, $method)) {
                 call_user_func(array(&$dropdown, $method), $_POST);
                 Html::back();
             } else {
                 Html::displayErrorAndDie(__('No selected element or badly defined operation'));
             }
         } else {
             if (isset($_GET['popup'])) {
                 Html::popHeader($dropdown->getTypeName(1), $_SERVER['PHP_SELF']);
                 if (isset($_GET["rand"])) {
                     $_SESSION["glpipopup"]["rand"] = $_GET["rand"];
                 }
                 $dropdown->showForm($_GET["id"]);
                 echo "<div class='center'><br><a href='javascript:window.close()'>" . __('Back') . "</a>";
                 echo "</div>";
                 Html::popFooter();
             } else {
                 $dropdown->displayHeader();
                 if (!isset($options)) {
                     $options = array();
示例#16
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkLoginUser();
if (isset($_GET["switchto"])) {
    $_SESSION['glpigraphtype'] = $_GET["switchto"];
    Html::back();
}
if (($uid = Session::getLoginUserID(false)) && isset($_GET["file"])) {
    list($userID, $filename) = explode("_", $_GET["file"]);
    if ($userID == $uid && file_exists(GLPI_GRAPH_DIR . "/" . $_GET["file"])) {
        list($fname, $extension) = explode(".", $filename);
        Toolbox::sendFile(GLPI_GRAPH_DIR . "/" . $_GET["file"], 'glpi.' . $extension);
    } else {
        Html::displayErrorAndDie(__('Unauthorized access to this file'), true);
    }
}
    $requested_type = $_REQUEST['itemtype'];
    $error = array();
    if (!in_array($requested_type, $types)) {
        $error[] = __('The requested type has not been defined yet!');
        if (!PluginGenericobjectType::canCreate()) {
            $error[] = __('Please ask your administrator to create this type of object');
        }
    } else {
        if (!class_exists($requested_type)) {
            $error[] = __('The generated files for the requested type of object are missing!');
            $error[] = __('You might need to regenerate the files under ' . GENERICOBJECT_DOC_DIR . '.');
        }
    }
    if (count($error) > 0) {
        Html::header(__('Type not found!'));
        Html::displayErrorAndDie(implode('<br/>', $error));
    } else {
        $itemtype = $requested_type;
    }
}
if (!is_null($itemtype)) {
    if (!isset($_REQUEST['id'])) {
        $id = -1;
    } else {
        $id = $_REQUEST['id'];
    }
    if (!isset($_GET["withtemplate"])) {
        $_GET["withtemplate"] = "";
    }
    $item = new $itemtype();
    if (isset($_POST["add"])) {
示例#18
0
Projet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Projet. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkLoginUser();
$fup = new PluginProjetFollowup();
if (isset($_POST["add"])) {
    $fup->check(-1, 'w', $_POST);
    $fup->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $fup->check($_POST['id'], 'w');
        $fup->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $fup->check($_POST['id'], 'w');
            $fup->delete($_POST);
            Html::back();
        }
    }
}
Html::displayErrorAndDie('Lost');
示例#19
0
 /**
  * Check valid referer accessing GLPI
  *
  * @since version 0.84.2
  *
  * @return nothing : display error if not permit
  **/
 static function checkValidReferer()
 {
     global $CFG_GLPI;
     $isvalidReferer = true;
     if (!isset($_SERVER['HTTP_REFERER'])) {
         if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
             Html::displayErrorAndDie(__("No HTTP_REFERER found in request. Reload previous page before doing action again."), true);
             $isvalidReferer = false;
         }
     } else {
         if (!is_array($url = parse_url($_SERVER['HTTP_REFERER']))) {
             if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
                 Html::displayErrorAndDie(__("Error when parsing HTTP_REFERER. Reload previous page before doing action again."), true);
                 $isvalidReferer = false;
             }
         }
     }
     if (!isset($url['host']) || $url['host'] != $_SERVER['SERVER_NAME'] && (!isset($_SERVER['HTTP_X_FORWARDED_SERVER']) || $url['host'] != $_SERVER['HTTP_X_FORWARDED_SERVER'])) {
         if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
             Html::displayErrorAndDie(__("None or Invalid host in HTTP_REFERER. Reload previous page before doing action again."), true);
             $isvalidReferer = false;
         }
     }
     if (!isset($url['path']) || !empty($CFG_GLPI['root_doc']) && strpos($url['path'], $CFG_GLPI['root_doc']) !== 0) {
         if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
             Html::displayErrorAndDie(__("None or Invalid path in HTTP_REFERER. Reload previous page before doing action again."), true);
             $isvalidReferer = false;
         }
     }
     if (!$isvalidReferer && $_SESSION['glpi_use_mode'] != Session::DEBUG_MODE) {
         Html::displayErrorAndDie(__("The action you have requested is not allowed. Reload previous page before doing action again."), true);
     }
 }