This file is indexed.

/usr/share/zabbix/include/regexp.inc.php is in zabbix-frontend-php 1:1.8.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/*
** ZABBIX
** Copyright (C) 2000-2008 SIA Zabbix
**
** This program 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.
**
** This program 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 this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
?>
<?php
function get_regexp_by_regexpid($regexpid){
	$sql = 'SELECT re.* '.
					' FROM regexps re '.
					' WHERE '.DBin_node('re.regexpid').
						' AND regexpid='.$regexpid;

	$db_regexp = DBfetch(DBselect($sql));
return $db_regexp;
}

// Author: Aly
// function add_regexp($regexp=array()){
function add_regexp($regexp=array()){
	$db_fields = array('name' => null,
						'test_string' => '',
					);

	if(!check_db_fields($db_fields, $regexp)){
		error(S_INCORRECT_ARGUMENTS_PASSED_TO_FUNCTION.' [add_regexp]');
		return false;
	}

	$sql = 'SELECT regexpid FROM regexps WHERE name='.zbx_dbstr($regexp['name']);
	if(DBfetch(DBselect($sql))){
		info(S_REGULAR_EXPRESSION.' ['.$regexp['name'].'] '.S_ALREADY_EXISTS_SMALL);
		return false;
	}

	$regexpid = get_dbid('regexps','regexpid');

	$result = DBexecute('INSERT INTO regexps (regexpid,name,test_string) '.
				' VALUES ('.$regexpid.','.
						zbx_dbstr($regexp['name']).','.
						zbx_dbstr($regexp['test_string']).')');

return $result?$regexpid:false;
}

// Author: Aly
// function update_regexp($regexpid, $regexp=array())
function update_regexp($regexpid, $regexp=array()){
	$db_fields = array('name' => null,
						'test_string' => '',
					);

	if(!check_db_fields($db_fields, $regexp)){
		error(S_INCORRECT_ARGUMENTS_PASSED_TO_FUNCTION.' [update_regexp]');
		return false;
	}

	$sql = 'SELECT regexpid FROM regexps WHERE name='.zbx_dbstr($regexp['name']);
	if($db_regexp = DBfetch(DBselect($sql))){
		if(bccomp($regexpid,$db_regexp['regexpid']) != 0){
			info(S_REGULAR_EXPRESSION.' ['.$regexp['name'].'] '.S_ALREADY_EXISTS_SMALL);
			return false;
		}
	}

	$sql = 'UPDATE regexps SET '.
				' name='.zbx_dbstr($regexp['name']).','.
				' test_string='.zbx_dbstr($regexp['test_string']).
			' WHERE regexpid='.$regexpid;
	$result = DBexecute($sql);
return $result;
}

// Author: Aly
// function delete_regexp($regexpids)
function delete_regexp($regexpids){
	zbx_value2array($regexpids);

// delete expressions first
	delete_expressions_by_regexpid($regexpids);
	$result = DBexecute('DELETE FROM regexps WHERE '.DBcondition('regexpid',$regexpids));

return $result;
}

// Author: Aly
// function add_expression($expression = array())
function add_expression($regexpid, $expression = array()){
	$db_fields = array('expression' => null,
						'expression_type' => null,
						'case_sensitive' => 0,
						'exp_delimiter' => ',',
					);

	if(!check_db_fields($db_fields, $expression)){
		error(S_INCORRECT_ARGUMENTS_PASSED_TO_FUNCTION.' [add_expression]');
		return false;
	}

	$expressionid = get_dbid('expressions','expressionid');

	$result = DBexecute('INSERT INTO expressions (expressionid,regexpid,expression,expression_type,case_sensitive,exp_delimiter) '.
				' VALUES ('.$expressionid.','.
						$regexpid.','.
						zbx_dbstr($expression['expression']).','.
						$expression['expression_type'].','.
						$expression['case_sensitive'].','.
						zbx_dbstr($expression['exp_delimiter']).')');

return $result?$expressionid:false;
}

// Author: Aly
// function delete_expression_by_regexpid($regexpids)
function delete_expressions_by_regexpid($regexpids){
	zbx_value2array($regexpids);
	$sql = 'DELETE FROM expressions WHERE '.DBcondition('regexpid',$regexpids);
return DBexecute($sql);
}

// Author: Aly
// function delete_expression($expressionids)
function delete_expression($expressionids){
	zbx_value2array($expressionids);
	$sql = 'DELETE FROM expressions WHERE '.DBcondition('expressionid',$expressionids);
return DBexecute($sql);
}

// Author: Aly
// function expression_type2str($expression_type)
function expression_type2str($expression_type){
	switch($expression_type){
		case EXPRESSION_TYPE_INCLUDED:
			$str = S_CHARACTER_STRING_INCLUDED;
			break;
		case EXPRESSION_TYPE_ANY_INCLUDED:
			$str = S_ANY_CHARACTER_STRING_INCLUDED;
			break;
		case EXPRESSION_TYPE_NOT_INCLUDED:
			$str = S_CHARACTER_STRING_NOT_INCLUDED;
			break;
		case EXPRESSION_TYPE_TRUE:
			$str = S_RESULT_IS_TRUE;
			break;
		case EXPRESSION_TYPE_FALSE:
			$str = S_RESULT_IS_FALSE;
			break;
		default:
			$str = S_UNKNOWN;
	}
return $str;
}
?>