Subversion Repositories public

Rev

Rev 4 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
<?php
2
function str_wordcount($str, $br=".") {
3
	if (strlen((string)$str) == 0) {
4
	   return 0;
5
	}
6
 
7
	$as = explode($br, $str);
8
	$anz = 0;
9
 
10
	foreach ($as as $tk) {
11
	   $anz++;
12
	}
13
 
14
	return $anz;
15
}
16
 
17
function FormatNum($num, $komma) {
18
	$str = sprintf ("%." . $komma . "f", $num);
19
	$str = str_replace (".", "|", $str);
20
	$str = str_replace (",", ".", $str);
21
	$str = str_replace ("|", ",", $str);
22
	return $str;
23
}
24
 
25
function GetPT($periode) {
26
	$mon = gmdate("n", $periode);
27
	$year = gmdate("Y", $periode);
28
	$days = daysinmonth($mon, $year);
29
	$d = 1;
30
	$wd = 0;
31
 
32
	while ($d <= $days) {
33
	   $ts = gmmktime(0, 0, 0, $mon, $d, $year);
34
	   $dtarr = getdate($ts);
35
	   $wday = $dtarr["wday"];
36
 
37
	   if ($wday > 0 && $wday < 6)
38
	      $wd++;
39
 
40
	   $d++;
41
	}
42
 
43
	return $wd;
44
}
45
 
46
function CheckTrue($var) {
47
	if (!isset($var))
48
	   return false;
49
 
50
	if (is_bool($var) && $var == true)
51
	   return true;
52
 
53
	if (is_string($var) && ($var == "t" || $var == "true" || $var == "on"))
54
	   return true;
55
 
56
	if (is_numeric($var) && $var != 0)
57
	   return true;
58
 
59
	return false;
60
}
61
 
29 andreas 62
function GetBrowserInfo($key) {
63
	$browser = get_browser();
64
 
65
        while (list ($schl, $value) = each ($browser)) {
66
	   if ($schl == $key)
67
	      return $value;
68
	}
69
 
70
	return "";
71
}
72
 
4 andreas 73
function DEBUG($str) {
74
	$fp = fopen("/tmp/debug.txt", "a");
75
	$tm = date("j.n.Y H:i:s", time());
76
	fwrite($fp, "$tm: $str\n");
77
	fclose($fp);
78
}
79
 
80
?>