static function makeTextSearch($val, $not = false) { $NOT = ""; if ($not) { $NOT = "NOT"; } // Unclean to permit < and > search $val = Toolbox::unclean_cross_side_scripting_deep($val); // escape _ char used as wildcard in mysql likes $val = str_replace('_', '\\_', $val); if ($val == 'NULL' || $val == 'null') { $SEARCH = " IS {$NOT} NULL "; } else { $begin = 0; $end = 0; if (($length = strlen($val)) > 0) { if ($val[0] == '^') { $begin = 1; } if ($val[$length - 1] == '$') { $end = 1; } } if ($begin || $end) { // no Toolbox::substr, to be consistent with strlen result $val = substr($val, $begin, $length - $end - $begin); } $SEARCH = " {$NOT} LIKE '" . (!$begin ? "%" : "") . $val . (!$end ? "%" : "") . "' "; } return $SEARCH; }
function plugin_mreporting_addWhere($link, $nott, $type, $ID, $val, $searchtype) { $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $SEARCH = Search::makeTextSearch($val, $nott); exit; switch ($table . "." . $field) { case "glpi_plugin_mreporting_configs.graphtype": return $link . " `{$table}`.`{$field}` = '{$val}' "; } return ""; }