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