1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19:
20:
21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
32: function system_cleanVars(&$global, $key, $default = '', $type = 'int')
33: {
34: switch ($type) {
35: case 'array':
36: $ret = (isset($global[$key]) && is_array($global[$key])) ? $global[$key] : $default;
37: break;
38: case 'date':
39: $ret = (isset($global[$key])) ? strtotime($global[$key]) : $default;
40: break;
41: case 'string':
42: $ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default;
43: break;
44: case 'int':
45: default:
46: $ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default;
47: break;
48: }
49: if ($ret === false) {
50: return $default;
51: }
52: return $ret;
53: }
54:
55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65:
66: function system_loadLanguage($name, $domain = '', $language = null)
67: {
68: $xoops = Xoops::getInstance();
69: 70: 71:
72: if (empty($name)) {
73: return false;
74: }
75:
76: $done = array('preferences', 'blocksadmin', 'extensions', 'modulesadmin', 'groups', 'tplsets', 'users');
77: if (in_array($name, $done)) {
78: return false;
79: }
80: $language = empty($language) ? $xoops->getConfig('language') : $language;
81: $path = 'modules/' . $domain . '/language/';
82: if (XoopsLoad::fileExists($file = $xoops->path($path . $language . '/admin/' . $name . '.php'))) {
83: $ret = include_once $file;
84: } else {
85: $ret = include_once $xoops->path($path . 'english/admin/' . $name . '.php');
86: }
87: return $ret;
88: }
89:
90: 91: 92: 93: 94:
95: function system_adminVersion($version, $value = '')
96: {
97: static $tblVersion = array();
98: if (is_array($tblVersion) && array_key_exists($version . '.' . $value, $tblVersion)) {
99: return $tblVersion[$version . '.' . $value];
100: }
101: $xoops = Xoops::getInstance();
102: $path = $xoops->path('modules/system/admin/' . $version . '/xoops_version.php');
103: if (XoopsLoad::fileExists($path)) {
104: $modversion = array();
105: include $path;
106: $retvalue = $modversion[$value];
107: $tblVersion[$version . '.' . $value] = $retvalue;
108: return $retvalue;
109: }
110: return '';
111: }
112:
113: 114: 115: 116:
117: function system_AdminIcons($img)
118: {
119: $xoops = Xoops::getInstance();
120: $style = 'default';
121:
122: $url = $xoops->url('modules/system/images/icons/' . $style . '/' . $img);
123: return $url;
124: }
125:
126: 127: 128: 129:
130: function system_loadTemplate($name)
131: {
132: $xoops = Xoops::getInstance();
133:
134: $path = $xoops->path('modules/' . $xoops->module->getVar('dirname', 'n') . '/templates/admin/' . $name . '.tpl');
135: if (XoopsLoad::fileExists($path)) {
136: echo $xoops->tpl()->fetch($path);
137: } else {
138: echo "Unable to read " . $name;
139: }
140: }
141:
142: 143: 144: 145: 146: 147:
148: function modify_chmod($value_chmod, $path_file, $id)
149: {
150: $chmod = '<div id="loading_' . $id . '" align="center" style="display:none;">' . '<img src="./images/mimetypes/spinner.gif" title="Loading" alt="Loading" width="12px"/></div>' . '<div id="chmod' . $id . '">' . '<select size="1" onChange="filemanager_modify_chmod(\'' . $path_file . '\', \'' . $id . '\')" name="chmod" id="chmod">';
151: if ($value_chmod == 777) {
152: $chmod .= '<option value="777" selected><span style="color:green">777</span></option>';
153: } else {
154: $chmod .= '<option value="777"><span style="color:green">777</span></option>';
155: }
156:
157: if ($value_chmod == 776) {
158: $chmod .= '<option value="776" selected>776</option>';
159: } else {
160: $chmod .= '<option value="776">776</option>';
161: }
162:
163: if ($value_chmod == 766) {
164: $chmod .= '<option value="766" selected>766</option>';
165: } else {
166: $chmod .= '<option value="766">766</option>';
167: }
168:
169: if ($value_chmod == 666) {
170: $chmod .= '<option value="666" selected>666</option>';
171: } else {
172: $chmod .= '<option value="666">666</option>';
173: }
174:
175: if ($value_chmod == 664) {
176: $chmod .= '<option value="664" selected>664</option>';
177: } else {
178: $chmod .= '<option value="664">664</option>';
179: }
180:
181: if ($value_chmod == 644) {
182: $chmod .= '<option value="644" selected>644</option>';
183: } else {
184: $chmod .= '<option value="644">644</option>';
185: }
186:
187: if ($value_chmod == 444) {
188: $chmod .= '<option value="444" selected><span style="color:red">444</span></option>';
189: } else {
190: $chmod .= '<option value="444">444</option>';
191: }
192:
193: if ($value_chmod == 440) {
194: $chmod .= '<option value="440" selected>440</option>';
195: } else {
196: $chmod .= '<option value="440">440</option>';
197: }
198:
199: if ($value_chmod == 400) {
200: $chmod .= '<option value="400" selected>400</option>';
201: } else {
202: $chmod .= '<option value="400">400</option>';
203: }
204: $chmod .= '</select>';
205:
206: return $chmod;
207: }
208: