Subversion Repositories ALCASAR

Rev

Rev 1805 | Rev 1846 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1805 Rev 1831
Line 26... Line 26...
26
 
26
 
27
$operators=array( '=','<', '>', '<=', '>=', 'regexp', 'like' );
27
$operators=array( '=','<', '>', '<=', '>=', 'regexp', 'like' );
28
if ($config['sql_type'] == 'pg'){
28
if ($config['sql_type'] == 'pg'){
29
	$operators=array( '=','<', '>', '<=', '>=', '~', 'like', '~*', '~~*', '<<=' );
29
	$operators=array( '=','<', '>', '<=', '>=', '~', 'like', '~*', '~~*', '<<=' );
30
}
30
}
31
 
-
 
32
$link = da_sql_pconnect ($config) or die('cannot connect to sql databse');
31
$link = da_sql_pconnect ($config) or die('cannot connect to sql databse');
33
$fields = da_sql_list_fields($config[sql_accounting_table],$link,$config);
32
$fields = da_sql_list_fields($config['sql_accounting_table'],$link,$config);
34
$no_fields = da_sql_num_fields($fields,$config);
-
 
-
 
33
 
35
 
34
 
36
unset($items);
35
unset($items);
37
 
36
 
38
for($i=0;$i<$no_fields;$i++){
37
while($row = $fields->fetch_array())
-
 
38
{
39
	$key = strtolower(da_sql_field_name($fields,$i,$config));
39
	$key = strtolower($row[0]);
40
	$val = $sql_attrs[$key]['desc'];
40
	$val = $sql_attrs[$key]['desc'];
41
	if ($val == '')
41
	if ($val == '')
42
		continue;
42
		continue;
43
	$show = $sql_attrs[$key]['show'];
43
	$show = $sql_attrs[$key]['show'];
44
	$selected[$key] = ($show == 'yes') ? 'selected' : '';
44
	$selected[$key] = ($show == 'yes') ? 'selected' : '';
Line 118... Line 118...
118
	</td></tr>
118
	</td></tr>
119
</TABLE>
119
</TABLE>
120
<TABLE width="100%" border="1" cellspacing="0" cellpadding="1">
120
<TABLE width="100%" border="1" cellspacing="0" cellpadding="1">
121
<tr><td>
121
<tr><td>
122
<?php
122
<?php
-
 
123
if(!isset($queryflag))
-
 
124
{
-
 
125
	$queryflag = 0;
-
 
126
}
123
if(!$queryflag) {
127
if(!$queryflag) {
124
	echo <<<EOM
128
	echo <<<EOM
125
<form method=post>
129
<form method=post>
126
<table border=0 width=740 cellpadding=1 cellspacing=1>
130
<table border=0 width=740 cellpadding=1 cellspacing=1>
127
<tr>
131
<tr>
Line 176... Line 180...
176
</td></tr>
180
</td></tr>
177
EOM;
181
EOM;
178
 
182
 
179
$number=1;
183
$number=1;
180
$offset=0;
184
$offset=0;
181
while (${"item_of_w$number"}) {
185
while (isset(${"item_of_w$number"}) && ${"item_of_w$number"}) {
182
	if(${"delete_w$number"}==1) {$offset=1;$number++;}
186
	if(${"delete_w$number"}==1) {$offset=1;$number++;}
183
		else {
187
		else {
184
		$designator=$number-$offset;
188
		$designator=$number-$offset;
185
		${"w$designator"} = new Qi("w$designator","","");
189
		${"w$designator"} = new Qi("w$designator","","");
186
		${"w$designator"}->get("w$number");
190
		${"w$designator"}->get("w$number");
187
		${"w$designator"}->show();
191
		${"w$designator"}->show();
188
		$number++;
192
		$number++;
189
		}
193
		}
190
	}
194
	}
191
if($add==1) {
195
if(isset($add) && $add==1) {
192
	${"w$number"} = new Qi("w$number","$item_name","$operators[0]");
196
	${"w$number"} = new Qi("w$number","$item_name","$operators[0]");
193
	${"w$number"}->show();
197
	${"w$number"}->show();
194
	}
198
	}
195
echo <<<EOM
199
echo <<<EOM
196
</table>
200
</table>
Line 209... Line 213...
209
EOM;
213
EOM;
210
 
214
 
211
}
215
}
212
 
216
 
213
if ($queryflag == 1){
217
if ($queryflag == 1){
-
 
218
	if(!isset($where))
-
 
219
		$where = "";
214
$i = 1;
220
$i = 1;
215
while (${"item_of_w$i"}){
221
while (isset(${"item_of_w$i"}) && ${"item_of_w$i"}){
216
	$op_found = 0;
222
	$op_found = 0;
217
	foreach ($operators as $operator){
223
	foreach ($operators as $operator){
218
		if (${"operator_of_w$i"} == $operator){
224
		if (${"operator_of_w$i"} == $operator){
219
			$op_found = 1;
225
			$op_found = 1;
220
			break;
226
			break;
221
		}
227
		}
222
	}
228
	}
223
	if (!$op_found)
229
	if (!$op_found)
224
		die("L'op&eacute;ration demand&eacute; n'est pas valide. Sortie anormale.");
230
		die("L'op&eacute;ration demand&eacute; n'est pas valide. Sortie anormale.");
225
	${"item_of_w$i"} = preg_replace('/\s/','',${"item_of_w$i"});
231
	${"item_of_w$i"} = preg_replace('/\s/','',${"item_of_w$i"});
226
	${"value_of_w$i"} = da_sql_escape_string(${"value_of_w$i"});
232
	${"value_of_w$i"} = da_sql_escape_string($link,${"value_of_w$i"});
227
	$where .= ($i == 1) ? ' WHERE ' . ${"item_of_w$i"} . ' ' . ${"operator_of_w$i"} . " '" . ${"value_of_w$i"} . "'" :
233
	$where .= ($i == 1) ? ' WHERE ' . ${"item_of_w$i"} . ' ' . ${"operator_of_w$i"} . " '" . ${"value_of_w$i"} . "'" :
228
				' AND ' . ${"item_of_w$i"} . ' ' . ${"operator_of_w$i"} . " '" . ${"value_of_w$i"} . "'" ;
234
				' AND ' . ${"item_of_w$i"} . ' ' . ${"operator_of_w$i"} . " '" . ${"value_of_w$i"} . "'" ;
229
	$i++;
235
	$i++;
230
}
236
}
231
 
237
 
Line 235... Line 241...
235
	die("ORDER BY pattern is illegal. Exiting abnornally.");
241
	die("ORDER BY pattern is illegal. Exiting abnornally.");
236
 
242
 
237
if (!is_numeric($maxresults))
243
if (!is_numeric($maxresults))
238
	die("Max Results is not in numeric form. Exiting abnormally.");
244
	die("Max Results is not in numeric form. Exiting abnormally.");
239
 
245
 
240
unset($query_view);
246
$query_view = '';
241
foreach ($accounting_show_attrs as $val)
247
foreach ($accounting_show_attrs as $val)
242
	$query_view .= $val . ',';
248
	$query_view .= $val . ',';
243
$query_view = ereg_replace(',$','',$query_view);
249
$query_view = ereg_replace(',$','',$query_view);
244
unset($sql_extra_query);
250
unset($sql_extra_query);
245
if ($config[sql_accounting_extra_query] != '')
251
if (isset($config['sql_accounting_extra_query'])){
246
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
252
	$sql_extra_query = xlat($config['sql_accounting_extra_query'],$login,$config);
247
	$sql_extra_query = da_sql_escape_string($sql_extra_query);
253
	$sql_extra_query = da_sql_escape_string($link,$sql_extra_query);
-
 
254
}
-
 
255
else
-
 
256
{
-
 
257
	$sql_extra_query = "";
-
 
258
}
-
 
259
 
-
 
260
if(!isset($where))
-
 
261
{
-
 
262
	$where = "";
-
 
263
}
-
 
264
 
248
$query="SELECT " . da_sql_limit($maxresults,0,$config) . " $query_view FROM $config[sql_accounting_table]
265
$query="SELECT " . da_sql_limit($maxresults,0,$config) . " $query_view FROM $config[sql_accounting_table]
249
	$where $sql_extra_query " . da_sql_limit($maxresults,1,$config) .
266
	$where $sql_extra_query " . da_sql_limit($maxresults,1,$config) .
250
	" ORDER BY $order DESC " . da_sql_limit($maxresults,2,$config) . ";";
267
	" ORDER BY $order DESC " . da_sql_limit($maxresults,2,$config) . ";";
251
 
268
 
252
echo <<<EOM
269
echo <<<EOM
Line 255... Line 272...
255
<p>
272
<p>
256
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
273
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
257
	<tr bgcolor="#d0ddb0">
274
	<tr bgcolor="#d0ddb0">
258
	</tr>
275
	</tr>
259
EOM;
276
EOM;
-
 
277
 
-
 
278
 
260
foreach($accounting_show_attrs as $val){
279
foreach($accounting_show_attrs as $val){
261
	$desc = $sql_attrs[$val][desc];
280
	$desc = $sql_attrs[$val]['desc'];
-
 
281
	if($val == 'acctoutputoctets')
-
 
282
		$desc = "Upload";
-
 
283
	if($val == 'acctinputoctets')
-
 
284
		$desc = "Download";
262
	echo "<th>$desc</th>\n";
285
	echo "<th>$desc</th>\n";
263
}
286
}
264
echo "</tr>\n";
287
echo "</tr>\n";
265
 
288
 
266
	$search = da_sql_query($link,$config,$query);
289
	$search = da_sql_query($link,$config,$query);
267
	if ($search){
290
	if ($search){
268
		while( $row = da_sql_fetch_array($search,$config) ){
291
		while( $row = da_sql_fetch_array($search,$config) ){
269
			$num++;
292
			//$num++;
270
			echo "<tr align=center>\n";
293
			echo "<tr align=center>\n";
271
			foreach($accounting_show_attrs as $val){
294
			foreach($accounting_show_attrs as $val){
272
				$info = $row[$val];
295
				$info = $row[$val];
-
 
296
				if($val == "acctoutputoctets" || $val == "acctinputoctets")
-
 
297
					$info = bytes2str($info);
-
 
298
				if($val == "acctsessiontime")
-
 
299
					$info = time2strclock($info);
273
				if ($info == '')
300
				if ($info == '')
274
					$info = '-';
301
					$info = '-';
275
				$info = $sql_attrs[$val][func]($info);
-
 
276
				if ($val == 'username'){
302
				if ($val == 'username'){
277
					$Info = urlencode($info);
303
					$Info = urlencode($info);
278
					$info = "<a href=\"user_admin.php?login=$Info\" title=\"Edit user $info\">$info<a/>";
304
					$info = "<a href=\"user_admin.php?login=$Info\" title=\"Edit user $info\">$info<a/>";
279
				}
305
				}
280
				echo <<<EOM
306
				echo <<<EOM