This file is indexed.

/usr/share/IlohaMail/include/data_manager.MySQL.inc is in ilohamail 0.8.14-0rc3sid6.2.

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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/////////////////////////////////////////////////////////
//	
//	include/data_manager.MySQL.inc
//
//	(C)Copyright 2003 Ryo Chijiiwa <Ryo@IlohaMail.org>
//
//	This file is part of IlohaMail. IlohaMail is free software released 
//	under the GPL license.  See enclosed file COPYING for details, or 
//	see http://www.fsf.org/copyleft/gpl.html
//
/////////////////////////////////////////////////////////

/********************************************************

	PURPOSE:
		Data handling abstraction class.
	PRE-CONDITIONS:
		$DB_USERS_TABLE - Name of table cotaining users
	POST-CONDITIONS:
	COMMENTS:
		For DB based backend, none of the data will be stored
		in memory, and will be accessed through DB in real time.

********************************************************/

include_once("../include/array2sql.inc");

class DataManager_obj{
	var $user;
	var $host;
	var $table;		//directory for FS backend, table nmae for DB
	var $dataID;		//file name for FS backend, user's ID for DB backend
	var $data;			//actually contains
	var $error;
	var $db;
	
	function initialize($user, $host, $table, $backend){
		global $DB_USERS_TABLE;
		
		if (empty($table)){
			$this->error = "DB table name or ID is empty\n";
			return false;
		}
		
		$this->db = new idba_obj;
		if (!$this->db->connect()) return false;
		
		$sql = "SELECT * FROM $DB_USERS_TABLE WHERE login='$user' and host='$host'";
		$result = $this->db->query($sql);
		if (($result) && ($this->db->num_rows($result)>0)){
			$dataID = $this->db->result($result, 0, "id");
		}else{
			$this->error = $error;
		}
		
		if (!$dataID){
			$this->error.="User not found in database\n";
			return false;
		}
		
		$this->backend = $backend;
		$this->table = $table;
		$this->dataID = $dataID;
		$this->data = array();
		
		return true;
	}
	
	
	function read(){
		$data = array();
		$sql = "SELECT * FROM ".$this->table." WHERE owner='".$this->dataID."'";
		$result = $this->db->query($sql);
		if (($result) && ($this->db->num_rows($result)>0)){
			while ($a = $this->db->fetch_row($result)){
				$id = $a["id"];
				$data[$id] = $a;
			}
		}else{
			$this->error .= $error;
			return false;
		}
		
		return $data;
	}
	
	
	function save(){
		//everything's done in real time anyway
		return true;
	}
	
	
	function delete($id){
		$sql = "DELETE FROM ".$this->table;
		$sql.= " WHERE id='".$id."' and owner='".$this->dataID."'";
		return $this->db->query($sql);
	}
	
	
	function insert($array){
		//get list of fields in table
		$backend_fields = $this->db->list_fields($this->table);
		if (!is_array($backend_fields)){
			$this->error .= "Failed to fetch fields\n";
			$this->error .= $error;
			return false;
		}
		
		//pick out relevant fields
		$insert_data = array();
		while ( list($k,$field) = each($backend_fields) ){
			if (!empty($array[$field])){
				$insert_data[$field] = $array[$field];
			}
		}
		if (empty($insert_data["owner"])) $insert_data["owner"] = $this->dataID;
		
		//$this->error .= "Inserting: ".implode("," $insert_data)."\n";
		
		//insert
		$sql = Array2SQL($this->table, $insert_data, "INSERT");
		$backend_result = $this->db->query($sql);
				
		$this->error = $error;
		
		return $backend_result;
	}
	
	function update($id, $array){
		//get list of fields in table
		$backend_fields = $this->db->list_fields($this->table);
		if (!is_array($backend_fields)){
			$this->error .= "Failed to fetch fields\n";
			$this->error .= $error;
			return false;
		}
		
		//pick out relevant fields
		$insert_data = array();
		while ( list($k,$field) = each($backend_fields) ){
			if (isset($array[$field]))
				$insert_data[$field] = $array[$field];
		}
		
		//insert
		$sql = Array2SQL($this->table, $insert_data, "UPDATE");
		$sql.= " WHERE id='$id' and owner='".$this->dataID."'";
		$this->db->query($sql);
		
		//echo "updating: $sql<br>\n";
		$backend_result = $this->db->query($sql);
		$this->error .= $this->db->error();
		
		return $backend_result;
	}


	function sort($field, $order){
		$data = array();

		$backend_query = "SELECT * FROM ".$this->table;
		$backend_query.=" WHERE owner='".$this->dataID."'";
		$backend_query.=" ORDER BY $field $order";		
		
		$backend_result = $this->db->query($backend_query);
		
		if (($backend_result) && ($this->db->num_rows($backend_result)>0)){
			while ($a = $this->db->fetch_row($backend_result)){
				$data[] = $a;
			}
		}else{
			$this->error .= $this->db->error();
			return false;
		}
		
		return $data;
	}


	function getDistinct($field, $order){
		$data = array();

		$backend_query = "SELECT distinct $field FROM ".$this->table;
		$backend_query.=" WHERE owner='".$this->dataID."'";
		$backend_query.=" ORDER BY $field $order";		
		
		$backend_result = $this->db->query($backend_query);
		
		if (($backend_result) && ($this->db->num_rows($backend_result)>0)){
			while ($a = $this->db->fetch_row($backend_result)){
				$data[] = $a[$field];
			}
		}else{
			$this->error .= $this->db->error();
			return false;
		}
		
		return $data;
	}


	function search($array){
	}
	
	function showError(){
		echo nl2br($this->error);
	}
}