File: functions.php

package info (click to toggle)
cacti 0.6.7-2.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,000 kB
  • ctags: 1,120
  • sloc: php: 5,059; sql: 922; sh: 302; perl: 81; makefile: 56
file content (75 lines) | stat: -rw-r--r-- 2,634 bytes parent folder | download
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
<?/* 
+-------------------------------------------------------------------------+
| raXnet Authentication Scripts                                           |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any        |
| questions or comments regarding this code should be directed to:        |
| - iberry@raxnet.net                                                     |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/                                       |
+-------------------------------------------------------------------------+
*/?>
<?
function CreateList($dbid,$sql,$name,$value,$prev) {
	$res_id = mysql_query("$sql",$dbid);
	$rows = mysql_num_rows($res_id);
	$i = 0;
	
	while ($i < $rows) { ?>
		<option value="<? print mysql_result($res_id, $i, $value); ?>"<? 
		if ($prev == mysql_result($res_id, $i, $value)) { 
		?> selected <? } ?>><? print mysql_result($res_id, $i, $name); ?></option>
		<?$i++;
	}
}

function GetNextItem($dbid,$tblname,$field,$startid,$lmt_field,$lmt_val) {
	if ($lmt_field!="") {
		$lmt_str1 = "where $lmt_field=$lmt_val";
		$lmt_str2 = "and $lmt_field=$lmt_val";
	}
	
	$sql_id = mysql_query("select max($field) from $tblname $lmt_str1",$dbid);
	$end_seq = mysql_result($sql_id, 0, "max($field)");
	$sql_id = mysql_query("select $field from $tblname where id=$startid",$dbid);
	$start_seq = mysql_result($sql_id, 0, "$field");
	
	$i = $start_seq;
	if ($end_seq!=$start_seq) {
		while ($i < $end_seq) {
			$sql_id = mysql_query("select $field from $tblname where $field=$i+1 $lmt_str2",$dbid);
			if (mysql_num_rows($sql_id)!=0) {
				return mysql_result($sql_id, 0, "$field");
			}
			
			$i++;
		}
	}
	return $start_seq;
}

function GetLastItem($dbid,$tblname,$field,$startid,$lmt_field,$lmt_val) {
	if ($lmt_field!="") {
		$lmt_str1 = "where $lmt_field=$lmt_val";
		$lmt_str2 = "and $lmt_field=$lmt_val";
	}
	
	$sql_id = mysql_query("select min($field) from $tblname $lmt_str1",$dbid);
	$end_seq = mysql_result($sql_id, 0, "min($field)");
	$sql_id = mysql_query("select $field from $tblname where id=$startid",$dbid);
	$start_seq = mysql_result($sql_id, 0, "$field");
	
	$i = $start_seq;
	if ($end_seq!=$start_seq) {
		while ($i > $end_seq) {
			$sql_id = mysql_query("select $field from $tblname where $field=$i-1 $lmt_str2",$dbid);
			if (mysql_num_rows($sql_id)!=0) {
				return mysql_result($sql_id, 0, "$field");
			}
			
			$i--;
		}
	}
	return $start_seq;
}
?>