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