1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: function isWindows()
17: {
18: if (cString::toLowerCase(cString::getPartOfString(PHP_OS, 0, 3)) == "win") {
19: return true;
20: } else {
21: return false;
22: }
23: }
24:
25: function getServerUID()
26: {
27: if (function_exists("posix_getuid")) {
28: return posix_getuid();
29: }
30:
31: $sFilename = md5(mt_rand()) . ".txt";
32:
33: if (is_writeable(".")) {
34: cFileHandler::create($sFilename, "test");
35: $iUserId = fileowner($sFilename);
36: cFileHandler::remove($sFilename);
37:
38: return ($iUserId);
39: } else {
40: if (is_writeable("/tmp/")) {
41: cFileHandler::create("/tmp/".$sFilename, "w");
42: $iUserId = fileowner("/tmp/".$sFilename);
43: cFileHandler::remove("/tmp/".$sFilename);
44:
45: return ($iUserId);
46: }
47: return false;
48: }
49: }
50:
51: function getServerGID() {
52: if (function_exists("posix_getgid")) {
53: return posix_getgid();
54: }
55:
56: $sFilename = md5(mt_rand()) . ".txt";
57:
58: if (is_writeable(".")) {
59: cFileHandler::create($sFilename, "test");
60: $iUserId = filegroup($sFilename);
61: cFileHandler::remove($sFilename);
62:
63: return ($iUserId);
64: } else {
65: return false;
66: }
67: }
68:
69: function getUsernameByUID($iUid)
70: {
71: if (function_exists("posix_getpwuid")) {
72: $aInfo = posix_getpwuid($iUid);
73: return ($aInfo["name"]);
74: } else {
75: return false;
76: }
77: }
78:
79: function getGroupnameByGID($iGid)
80: {
81: if (function_exists("posix_getgrgid")) {
82: $aInfo = posix_getgrgid($iGid);
83: return ($aInfo["name"]);
84: } else {
85: return false;
86: }
87: }
88:
89: ?>