cleanParametersURL() static public method

Clean all parameters of an URL. Get a clean URL
static public cleanParametersURL ( $url ) : clean
$url string URL
return clean URL
 static function detectRootDoc()
 {
     global $CFG_GLPI;
     if (!isset($CFG_GLPI["root_doc"])) {
         if (!isset($_SERVER['REQUEST_URI'])) {
             $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
         }
         $currentdir = getcwd();
         chdir(GLPI_ROOT);
         $glpidir = str_replace(str_replace('\\', '/', getcwd()), "", str_replace('\\', '/', $currentdir));
         chdir($currentdir);
         $globaldir = Html::cleanParametersURL($_SERVER['REQUEST_URI']);
         $globaldir = preg_replace("/\\/[0-9a-zA-Z\\.\\-\\_]+\\.php/", "", $globaldir);
         $CFG_GLPI["root_doc"] = str_replace($glpidir, "", $globaldir);
         $CFG_GLPI["root_doc"] = preg_replace("/\\/\$/", "", $CFG_GLPI["root_doc"]);
         // urldecode for space redirect to encoded URL : change entity
         $CFG_GLPI["root_doc"] = urldecode($CFG_GLPI["root_doc"]);
     }
 }
コード例 #2
0
ファイル: HtmlTest.php プロジェクト: btry/glpi
 /**
  * @covers Html::cleanParametersURL
  */
 public function cleanParametersURL()
 {
     $url = 'http://host/glpi/path/to/file.php?var1=2&var2=3';
     $expected = 'http://host/glpi/path/to/file.php';
     $this->assertEquals($expected, Html::cleanParametersURL($url));
 }
コード例 #3
0
ファイル: display.class.php プロジェクト: geldarr/hack-space
 function showTabs($options = array())
 {
     global $CFG_GLPI;
     // for objects not in table like central
     $ID = 0;
     if (isset($this->fields['id'])) {
         $ID = $this->fields['id'];
     }
     $target = $_SERVER['PHP_SELF'];
     $extraparamhtml = "";
     $extraparam = "";
     $withtemplate = "";
     if (is_array($options) && count($options)) {
         if (isset($options['withtemplate'])) {
             $withtemplate = $options['withtemplate'];
         }
         foreach ($options as $key => $val) {
             $extraparamhtml .= "&{$key}={$val}";
             $extraparam .= "&{$key}={$val}";
         }
     }
     if (empty($withtemplate) && $ID && $this->getType() && $this->displaylist) {
         $glpilistitems =& $_SESSION['glpilistitems'][$this->getType()];
         $glpilisttitle =& $_SESSION['glpilisttitle'][$this->getType()];
         $glpilisturl =& $_SESSION['glpilisturl'][$this->getType()];
         if (empty($glpilisturl)) {
             $glpilisturl = $this->getSearchURL();
         }
         echo "<div id='menu_navigate'>";
         $next = $prev = $first = $last = -1;
         $current = false;
         if (is_array($glpilistitems)) {
             $current = array_search($ID, $glpilistitems);
             if ($current !== false) {
                 if (isset($glpilistitems[$current + 1])) {
                     $next = $glpilistitems[$current + 1];
                 }
                 if (isset($glpilistitems[$current - 1])) {
                     $prev = $glpilistitems[$current - 1];
                 }
                 $first = $glpilistitems[0];
                 if ($first == $ID) {
                     $first = -1;
                 }
                 $last = $glpilistitems[count($glpilistitems) - 1];
                 if ($last == $ID) {
                     $last = -1;
                 }
             }
         }
         $cleantarget = Html::cleanParametersURL($target);
         echo "<ul>";
         echo "<li><a href=\"javascript:showHideDiv('tabsbody','tabsbodyimg','" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png','" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png')\">";
         echo "<img alt='' name='tabsbodyimg' src=\"" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png\">";
         echo "</a></li>";
         echo "<li><a href=\"" . $glpilisturl . "\">";
         if ($glpilisttitle) {
             if (Toolbox::strlen($glpilisttitle) > $_SESSION['glpidropdown_chars_limit']) {
                 $glpilisttitle = Toolbox::substr($glpilisttitle, 0, $_SESSION['glpidropdown_chars_limit']) . "&hellip;";
             }
             echo $glpilisttitle;
         } else {
             echo __('List');
         }
         echo "</a>&nbsp;:&nbsp;</li>";
         if ($first > 0) {
             echo "<li><a href='{$cleantarget}?id={$first}{$extraparamhtml}'><img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __('First') . "\" title=\"" . __('First') . "\"></a></li>";
         } else {
             echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/first_off.png' alt=\"" . __('First') . "\" title=\"" . __('First') . "\"></li>";
         }
         if ($prev > 0) {
             echo "<li><a href='{$cleantarget}?id={$prev}{$extraparamhtml}'><img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __('Previous') . "\" title=\"" . __('Previous') . "\"></a></li>";
         } else {
             echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/left_off.png' alt=\"" . __('Previous') . "\" title=\"" . __('Previous') . "\"></li>";
         }
         if ($current !== false) {
             echo "<li>" . ($current + 1) . "/" . count($glpilistitems) . "</li>";
         }
         if ($next > 0) {
             echo "<li><a href='{$cleantarget}?id={$next}{$extraparamhtml}'><img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __('Next') . "\" title=\"" . __('Next') . "\"></a></li>";
         } else {
             echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/right_off.png' alt=\"" . __('Next') . "\" title=\"" . __('Next') . "\"></li>";
         }
         if ($last > 0) {
             echo "<li><a href='{$cleantarget}?id={$last}{$extraparamhtml}'><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/last.png\" alt=\"" . __('Last') . "\" title=\"" . __('Last') . "\"></a></li>";
         } else {
             echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/last_off.png' alt=\"" . __('Last') . "\" title=\"" . __('Last') . "\"></li>";
         }
         echo "</ul></div>";
         echo "<div class='sep'></div>";
     }
     echo "<div id='tabspanel' class='center-h'></div>";
     $onglets = $this->defineTabs($options);
     $display_all = true;
     if (isset($onglets['no_all_tab'])) {
         $display_all = false;
         unset($onglets['no_all_tab']);
     }
     $class = $this->getType();
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE && ($ID > 0 || $this->showdebug) && (method_exists($class, 'showDebug') || in_array($class, $CFG_GLPI["infocom_types"]) || in_array($class, $CFG_GLPI["reservation_types"]))) {
         $onglets[-2] = __('Debug');
     }
     if (count($onglets)) {
         $tabpage = $this->getTabsURL();
         $tabs = array();
         foreach ($onglets as $key => $val) {
             $tabs[$key] = array('title' => $val, 'url' => $tabpage, 'params' => "target={$target}&itemtype=" . $this->getType() . "&glpi_tab={$key}&id={$ID}{$extraparam}");
         }
         $plug_tabs = Plugin::getTabs($target, $this, $withtemplate);
         $tabs += $plug_tabs;
         // Not all tab for templates and if only 1 tab
         if ($display_all && empty($withtemplate) && count($tabs) > 1) {
             $tabs[-1] = array('title' => __('All'), 'url' => $tabpage, 'params' => "target={$target}&itemtype=" . $this->getType() . "&glpi_tab=-1&id={$ID}{$extraparam}");
         }
         Ajax::createTabs('tabspanel', 'tabcontent', $tabs, $this->getType(), "'100%'");
     }
 }
コード例 #4
0
ファイル: includes.php プロジェクト: gaforeror/glpi
}
include_once GLPI_ROOT . "/inc/autoload.function.php";
// Init Timer to compute time of display
$TIMER_DEBUG = new Timer();
$TIMER_DEBUG->start();
foreach (array('glpi_table_of', 'glpi_foreign_key_field_of') as $session_array_fields) {
    if (!isset($_SESSION[$session_array_fields])) {
        $_SESSION[$session_array_fields] = array();
    }
}
/// TODO try to remove them if possible
include_once GLPI_ROOT . "/inc/db.function.php";
// Standard includes
include_once GLPI_ROOT . "/config/config.php";
// Security of PHP_SELF
$_SERVER['PHP_SELF'] = Html::cleanParametersURL($_SERVER['PHP_SELF']);
// Load Language file
Session::loadLanguage();
if (isset($_SESSION['glpi_use_mode']) && $_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
    $SQL_TOTAL_REQUEST = 0;
    $DEBUG_SQL["queries"] = array();
    $DEBUG_SQL["errors"] = array();
    $DEBUG_SQL["times"] = array();
    $DEBUG_AUTOLOAD = array();
}
// Security system
if (isset($_POST)) {
    if (Toolbox::get_magic_quotes_gpc()) {
        $_POST = array_map(array('Toolbox', 'stripslashes_deep'), $_POST);
    }
    if (isset($_POST['_glpi_simple_form'])) {
コード例 #5
0
 protected function setUp()
 {
     global $CFG_GLPI, $DB;
     $DB = new DB();
     // Force profile in session to SuperAdmin
     $_SESSION['glpiprofiles'] = array('4' => array('entities' => 0));
     $_SESSION['glpi_plugin_fusioninventory_profile']['unmanaged'] = 'w';
     $_SESSION['glpiactiveentities'] = array(0, 1);
     $_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
     require GLPI_ROOT . "/inc/includes.php";
     $plugin = new Plugin();
     $DB->connect();
     $plugin->getFromDBbyDir("fusioninventory");
     $plugin->activate($plugin->fields['id']);
     file_put_contents(GLPI_ROOT . "/files/_log/sql-errors.log", '');
     file_put_contents(GLPI_ROOT . "/files/_log/php-errors.log", '');
     $dir = GLPI_ROOT . "/files/_files/_plugins/fusioninventory";
     if (file_exists($dir)) {
         $objects = scandir($dir);
         foreach ($objects as $object) {
             if ($object != "." && $object != "..") {
                 if (filetype($dir . "/" . $object) == "dir") {
                 } else {
                     unlink($dir . "/" . $object);
                 }
             }
         }
     }
     include_once GLPI_ROOT . "/inc/timer.class.php";
     // Security of PHP_SELF
     $_SERVER['PHP_SELF'] = Html::cleanParametersURL($_SERVER['PHP_SELF']);
     //      function glpiautoload($classname) {
     //         global $DEBUG_AUTOLOAD, $CFG_GLPI;
     //         static $notfound = array();
     //
     //         // empty classname or non concerted plugin
     //         if (empty($classname) || is_numeric($classname)) {
     //            return FALSE;
     //         }
     //
     //         $dir=GLPI_ROOT . "/inc/";
     //         //$classname="PluginExampleProfile";
     //         if ($plug=isPluginItemType($classname)) {
     //            $plugname=strtolower($plug['plugin']);
     //            $dir=GLPI_ROOT . "/plugins/$plugname/inc/";
     //            $item=strtolower($plug['class']);
     //            // Is the plugin activate ?
     //            // Command line usage of GLPI : need to do a real check plugin activation
     //            if (isCommandLine()) {
     //               $plugin = new Plugin();
     //               if (count($plugin->find("directory='$plugname' AND state=".Plugin::ACTIVATED)) == 0) {
     //                  // Plugin does not exists or not activated
     //                  return FALSE;
     //               }
     //            } else {
     //               // Standard use of GLPI
     //               if (!in_array($plugname, $_SESSION['glpi_plugins'])) {
     //                  // Plugin not activated
     //                  return FALSE;
     //               }
     //            }
     //         } else {
     //            // Is ezComponent class ?
     //            $matches = array();
     //            if (preg_match('/^ezc([A-Z][a-z]+)/', $classname, $matches)) {
     //               include_once(GLPI_EZC_BASE);
     //               ezcBase::autoload($classname);
     //               return TRUE;
     //            } else {
     //               $item=strtolower($classname);
     //            }
     //         }
     //
     //         // No errors for missing classes due to implementation
     //         if (!isset($CFG_GLPI['missingclasses'])
     //                 OR !in_array($item, $CFG_GLPI['missingclasses'])){
     //            if (file_exists("$dir$item.class.php")) {
     //               include_once ("$dir$item.class.php");
     //               if ($_SESSION['glpi_use_mode']==Session::DEBUG_MODE) {
     //                  $DEBUG_AUTOLOAD[]=$classname;
     //               }
     //
     //            } else if (!isset($notfound["$classname"])) {
     //               // trigger an error to get a backtrace, but only once (use prefix 'x' to handle empty case)
     //               //Toolbox::logInFile('debug', "file $dir$item.class.php not founded trying to load class $classname\n");
     //               trigger_error("GLPI autoload : file $dir$item.class.php not founded trying to load class '$classname'");
     //               $notfound["$classname"] = TRUE;
     //            }
     //         }
     //      }
     //
     //      spl_autoload_register('glpiautoload');
     //      restore_error_handler();
     //      error_reporting(E_ALL | E_STRICT);
     //      ini_set('display_errors', 'On');
     ini_set("memory_limit", "-1");
     ini_set("max_execution_time", "0");
 }