1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: 20: 21: 22: 23: 24:
25: function emptyLogFile() {
26: global $cfg, $notification, $auth;
27:
28: if (strpos($auth->auth["perm"], "sysadmin") === false) {
29: return $notification->returnNotification("error", i18n("Can't clear error log : Access is denied!"));
30: }
31:
32: $tmp_notification = false;
33:
34:
35: $filename = $cfg['path']['contenido_logs'] . 'errorlog.txt';
36:
37: if (cFileHandler::exists($filename) && is_writeable($filename)) {
38: cFileHandler::truncate($filename);
39: $tmp_notification = $notification->returnNotification("ok", i18n("Error log successfully cleared!"));
40: } else if (cFileHandler::exists($filename) && !is_writeable($filename)) {
41: $tmp_notification = $notification->returnNotification("error", i18n("Can't clear error log : Access is denied!"));
42: }
43:
44: return $tmp_notification;
45: }
46:
47: 48: 49: 50: 51: 52: 53: 54:
55: function phpInfoToHtml() {
56: cDeprecated('This method is deprecated and is not needed any longer');
57:
58:
59: ob_start();
60: phpinfo();
61: $phpInfoToHtml = ob_get_contents();
62: ob_end_clean();
63:
64: return $phpInfoToHtml;
65: }
66:
67: 68: 69: 70: 71: 72: 73: 74:
75: function systemHavePerm($client) {
76: global $auth;
77:
78: if (!isset($auth->perm['perm'])) {
79: $auth->perm['perm'] = '';
80: }
81:
82: $userPerm = explode(',', $auth->auth['perm']);
83:
84: if (in_array('sysadmin', $userPerm)) {
85: return true;
86: } elseif (in_array('admin[' . $client . ']', $userPerm)) {
87: return true;
88: } elseif (in_array('client[' . $client . ']', $userPerm)) {
89: return true;
90: }
91: return false;
92: }
93:
94: 95: 96: 97: 98: 99: 100: 101:
102: function isIPv4($strHostAdress) {
103:
104: $ipPattern = "([0-9]|1?\d\d|2[0-4]\d|25[0-5])";
105: if (preg_match("/^$ipPattern\.$ipPattern\.$ipPattern\.$ipPattern?$/", $strHostAdress)) {
106: return true;
107: }
108: return false;
109: }
110:
111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122:
123: function checkPathInformation($strConUrl, $strBrowserUrl) {
124: cDeprecated('This method is deprecated and is not needed any longer');
125:
126:
127: $arrConUrl = parse_url($strConUrl);
128: $arrBrowserUrl = parse_url($strBrowserUrl);
129:
130: if (isIPv4($arrConUrl['host'])) {
131: if (isIPv4($arrBrowserUrl['host'])) {
132: if (compareUrlStrings($arrConUrl, $arrBrowserUrl)) {
133: return '1';
134: }
135:
136: return '2';
137: } else {
138: $arrBrowserUrl['host'] = gethostbyname($arrBrowserUrl['host']);
139: if (!isIPv4($arrBrowserUrl['host'])) {
140: return '3';
141: }
142:
143: if (compareUrlStrings($arrConUrl, $arrBrowserUrl)) {
144: return '1';
145: }
146:
147: return '2';
148: }
149: } else {
150: if (isIPv4($arrBrowserUrl['host'])) {
151: $tmpAddr = gethostbyaddr($arrBrowserUrl['host']);
152: $arrBrowserUrl['host'] = str_replace('-', '.', substr($tmpAddr, 0, strpos($tmpAddr, ".")));
153:
154: if (isIPv4($arrBrowserUrl['host'])) {
155: return '3';
156: }
157:
158: if (compareUrlStrings($arrConUrl, $arrBrowserUrl, true)) {
159: return '1';
160: }
161:
162: return '2';
163: } else {
164: if (compareUrlStrings($arrConUrl, $arrBrowserUrl)) {
165: return '1';
166: }
167:
168: return '2';
169: }
170: }
171: }
172:
173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184:
185: function compareUrlStrings($arrConUrl, $arrBrowserUrl, $isIP = false) {
186: cDeprecated('This method is deprecated and is not needed any longer');
187:
188:
189:
190: if (strpos($arrConUrl['host'], 'www.') == 0 || strpos($arrBrowserUrl['host'], 'www.') == 0) {
191: $arrConUrl['host'] = str_replace('www.', '', $arrConUrl);
192: $arrBrowserUrl['host'] = str_replace('www.', '', $arrBrowserUrl);
193: }
194:
195: $strConUrl = $arrConUrl['scheme'] . '://' . $arrConUrl['host'] . $arrConUrl['path'];
196: $strBrowserUrl = $arrBrowserUrl['scheme'] . '://' . $arrBrowserUrl['host'] . $arrBrowserUrl['path'];
197:
198: if (strcmp($strConUrl, $strBrowserUrl) != 0) {
199: return false;
200: }
201: return true;
202: }
203: