@@ -230,7 +230,7 @@ |
||
230 | 230 | * @param string $user persistent identifier of the user who triggered the action |
231 | 231 | * @param string $category type of modification, from the fixed vocabulary: "NEW", "OWN", "MOD", "DEL" |
232 | 232 | * @param string $message message to log into the audit log |
233 | - * @return boolean TRUE if successful. Will terminate script execution on failure. |
|
233 | + * @return boolean|null TRUE if successful. Will terminate script execution on failure. |
|
234 | 234 | */ |
235 | 235 | public static function writeAudit($user, $category, $message) { |
236 | 236 | switch ($category) { |
@@ -191,9 +191,9 @@ |
||
191 | 191 | * gets the language setting in CAT |
192 | 192 | */ |
193 | 193 | static public function get_lang() { |
194 | - if(self::$LANG === '') |
|
195 | - list(self::$LANG, $xx) = self::set_lang(); |
|
196 | - return self::$LANG; |
|
194 | + if(self::$LANG === '') |
|
195 | + list(self::$LANG, $xx) = self::set_lang(); |
|
196 | + return self::$LANG; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * named the same as device_id. The second option takes precedence. |
173 | 173 | * |
174 | 174 | * @param string $source_name The source file name |
175 | - * @param string $output_name The destination file name |
|
175 | + * @param integer $output_name The destination file name |
|
176 | 176 | * |
177 | 177 | * @return bool result of the copy operation |
178 | 178 | * @final not to be redefined |
@@ -216,8 +216,7 @@ discard block |
||
216 | 216 | * named the same as device_id. The second option takes precedence. |
217 | 217 | * |
218 | 218 | * @param string $source_name The source file name |
219 | - * @param string $output_name The destination file name |
|
220 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
219 | + * @param integer $output_name The destination file name |
|
221 | 220 | * |
222 | 221 | * @final not to be redefined |
223 | 222 | */ |
@@ -262,8 +261,6 @@ discard block |
||
262 | 261 | * The second optional parameter, if nonzero, should be the character set understood by iconv |
263 | 262 | * This is required by the Windows installer and is expected to go away in the future. |
264 | 263 | * |
265 | - * @param string $source_name The source file name |
|
266 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
267 | 264 | * |
268 | 265 | * @final not to be redefined |
269 | 266 | */ |
@@ -6,10 +6,10 @@ discard block |
||
6 | 6 | ?> |
7 | 7 | <?php |
8 | 8 | /** |
9 | - * This file defines the abstract Device class |
|
10 | - * |
|
11 | - * @package ModuleWriting |
|
12 | - */ |
|
9 | + * This file defines the abstract Device class |
|
10 | + * |
|
11 | + * @package ModuleWriting |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | |
48 | 48 | abstract class DeviceConfig { |
49 | - /** |
|
50 | - * stores the path to the temporary working directory for a module instance |
|
51 | - * @var string $FPATH |
|
52 | - */ |
|
49 | + /** |
|
50 | + * stores the path to the temporary working directory for a module instance |
|
51 | + * @var string $FPATH |
|
52 | + */ |
|
53 | 53 | public $FPATH; |
54 | 54 | |
55 | 55 | /** |
@@ -58,391 +58,391 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public $specialities; |
60 | 60 | |
61 | - /** |
|
61 | + /** |
|
62 | 62 | * device module constructor should be defined by each module, but if it is not, then here is a default one |
63 | 63 | */ |
64 | 64 | |
65 | - public function __construct() { |
|
66 | - $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP]; |
|
67 | - debug(4,"This device supports the following EAP methods: "); |
|
68 | - debug(4,$this->supportedEapMethods); |
|
65 | + public function __construct() { |
|
66 | + $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP]; |
|
67 | + debug(4,"This device supports the following EAP methods: "); |
|
68 | + debug(4,$this->supportedEapMethods); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Set up working environment for a device module |
|
74 | - * |
|
75 | - * Sets up the device module environment taking into account the actual profile |
|
76 | - * selected by the user in the GUI. The selected profile is passed as the |
|
77 | - * Profile $profile argumant. |
|
78 | - * |
|
79 | - * This method needs to be called after the device instance has been created (the GUI class does that) |
|
80 | - * |
|
81 | - * setup performs the following tasks: |
|
82 | - * - collect profile attributes and pass them as the attributes property; |
|
83 | - * - create the temporary working directory |
|
84 | - * - process CA certificates and store them as 'internal:CAs' attribute |
|
85 | - * - process and save optional info files and store references to them in |
|
86 | - * 'internal:info_file' attribute |
|
87 | - * @param Profile $profile the profile object which will be passed by the caller |
|
88 | - * @final not to be redefined |
|
89 | - */ |
|
72 | + /** |
|
73 | + * Set up working environment for a device module |
|
74 | + * |
|
75 | + * Sets up the device module environment taking into account the actual profile |
|
76 | + * selected by the user in the GUI. The selected profile is passed as the |
|
77 | + * Profile $profile argumant. |
|
78 | + * |
|
79 | + * This method needs to be called after the device instance has been created (the GUI class does that) |
|
80 | + * |
|
81 | + * setup performs the following tasks: |
|
82 | + * - collect profile attributes and pass them as the attributes property; |
|
83 | + * - create the temporary working directory |
|
84 | + * - process CA certificates and store them as 'internal:CAs' attribute |
|
85 | + * - process and save optional info files and store references to them in |
|
86 | + * 'internal:info_file' attribute |
|
87 | + * @param Profile $profile the profile object which will be passed by the caller |
|
88 | + * @final not to be redefined |
|
89 | + */ |
|
90 | 90 | final public function setup(Profile $profile) { |
91 | - debug(4,"module setup start\n"); |
|
92 | - if(! $profile instanceof Profile) { |
|
93 | - debug(2,"No profile has been set\n"); |
|
94 | - error("No profile has been set"); |
|
95 | - exit; |
|
96 | - } |
|
97 | - $this->attributes = $this->getProfileAttributes($profile); |
|
98 | - if(! $this->selected_eap) { |
|
99 | - error("No EAP type specified."); |
|
100 | - exit; |
|
101 | - } |
|
102 | - // create temporary directory, its full path will be saved in $this->FPATH; |
|
103 | - $T = createTemporaryDirectory('installer'); |
|
104 | - $this->FPATH = $T['dir']; |
|
105 | - mkdir($T['dir'].'/tmp'); |
|
106 | - chdir($T['dir'].'/tmp'); |
|
107 | - $CAs = []; |
|
108 | - if(isset($this->attributes['eap:ca_file'])) { |
|
109 | - foreach ($this->attributes['eap:ca_file'] as $ca) { |
|
110 | - if($c = X509::processCertificate($ca)) |
|
111 | - $CAs[] = $c; |
|
112 | - } |
|
113 | - $this->attributes['internal:CAs'][0]=$CAs; |
|
114 | - } |
|
115 | - if(isset($this->attributes['support:info_file'])) { |
|
116 | - $this->attributes['internal:info_file'][0] = |
|
117 | - $this->saveInfoFile($this->attributes['support:info_file'][0]); |
|
118 | - } |
|
119 | - if(isset($this->attributes['general:logo_file'])) |
|
120 | - $this->attributes['internal:logo_file'] = |
|
121 | - $this->saveLogoFile($this->attributes['general:logo_file']); |
|
122 | - $this->attributes['internal:SSID'] = $this->getSSIDs()['add'];; |
|
123 | - $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del'];; |
|
124 | - $this->attributes['internal:consortia'] = $this->getConsortia(); |
|
125 | - $this->lang_index = CAT::get_lang(); |
|
126 | - // phpMD says the below is not needed. Wow. |
|
127 | - // $idp = new IdP($profile->institution); |
|
128 | - $olddomain = CAT::set_locale("core"); |
|
129 | - $this->support_email_substitute = sprintf(_("your local %s support"),Config::$CONSORTIUM['name']); |
|
130 | - $this->support_url_substitute = sprintf(_("your local %s support page"),Config::$CONSORTIUM['name']); |
|
131 | - CAT::set_locale($olddomain); |
|
132 | - |
|
133 | - if($this->signer && $this->options['sign']) |
|
134 | - $this->sign = CAT::$root . '/signer/'. $this->signer; |
|
135 | - $this->installerBasename = $this->getInstallerBasename(); |
|
91 | + debug(4,"module setup start\n"); |
|
92 | + if(! $profile instanceof Profile) { |
|
93 | + debug(2,"No profile has been set\n"); |
|
94 | + error("No profile has been set"); |
|
95 | + exit; |
|
96 | + } |
|
97 | + $this->attributes = $this->getProfileAttributes($profile); |
|
98 | + if(! $this->selected_eap) { |
|
99 | + error("No EAP type specified."); |
|
100 | + exit; |
|
101 | + } |
|
102 | + // create temporary directory, its full path will be saved in $this->FPATH; |
|
103 | + $T = createTemporaryDirectory('installer'); |
|
104 | + $this->FPATH = $T['dir']; |
|
105 | + mkdir($T['dir'].'/tmp'); |
|
106 | + chdir($T['dir'].'/tmp'); |
|
107 | + $CAs = []; |
|
108 | + if(isset($this->attributes['eap:ca_file'])) { |
|
109 | + foreach ($this->attributes['eap:ca_file'] as $ca) { |
|
110 | + if($c = X509::processCertificate($ca)) |
|
111 | + $CAs[] = $c; |
|
112 | + } |
|
113 | + $this->attributes['internal:CAs'][0]=$CAs; |
|
114 | + } |
|
115 | + if(isset($this->attributes['support:info_file'])) { |
|
116 | + $this->attributes['internal:info_file'][0] = |
|
117 | + $this->saveInfoFile($this->attributes['support:info_file'][0]); |
|
118 | + } |
|
119 | + if(isset($this->attributes['general:logo_file'])) |
|
120 | + $this->attributes['internal:logo_file'] = |
|
121 | + $this->saveLogoFile($this->attributes['general:logo_file']); |
|
122 | + $this->attributes['internal:SSID'] = $this->getSSIDs()['add'];; |
|
123 | + $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del'];; |
|
124 | + $this->attributes['internal:consortia'] = $this->getConsortia(); |
|
125 | + $this->lang_index = CAT::get_lang(); |
|
126 | + // phpMD says the below is not needed. Wow. |
|
127 | + // $idp = new IdP($profile->institution); |
|
128 | + $olddomain = CAT::set_locale("core"); |
|
129 | + $this->support_email_substitute = sprintf(_("your local %s support"),Config::$CONSORTIUM['name']); |
|
130 | + $this->support_url_substitute = sprintf(_("your local %s support page"),Config::$CONSORTIUM['name']); |
|
131 | + CAT::set_locale($olddomain); |
|
132 | + |
|
133 | + if($this->signer && $this->options['sign']) |
|
134 | + $this->sign = CAT::$root . '/signer/'. $this->signer; |
|
135 | + $this->installerBasename = $this->getInstallerBasename(); |
|
136 | 136 | } |
137 | 137 | |
138 | - /** |
|
139 | - * Selects the preferred eap method based on profile EAP configuration and device EAP capabilities |
|
140 | - * |
|
141 | - * @param array eap_array an array of eap methods supported by a given device |
|
142 | - * @return the best matching EAP type for the profile; or 0 if no match was found |
|
143 | - */ |
|
144 | - public function getPreferredEapType($eap_array) { |
|
145 | - foreach ($eap_array as $eap) { |
|
146 | - if(in_array($eap,$this->supportedEapMethods)) { |
|
138 | + /** |
|
139 | + * Selects the preferred eap method based on profile EAP configuration and device EAP capabilities |
|
140 | + * |
|
141 | + * @param array eap_array an array of eap methods supported by a given device |
|
142 | + * @return the best matching EAP type for the profile; or 0 if no match was found |
|
143 | + */ |
|
144 | + public function getPreferredEapType($eap_array) { |
|
145 | + foreach ($eap_array as $eap) { |
|
146 | + if(in_array($eap,$this->supportedEapMethods)) { |
|
147 | 147 | $this->selected_eap = $eap; |
148 | 148 | debug(4,"Selected EAP:"); |
149 | 149 | debug(4,$eap); |
150 | 150 | return($eap); |
151 | - } |
|
152 | - } |
|
153 | - return(0); |
|
154 | - } |
|
155 | - /** |
|
156 | - * prepare usage information for the installer |
|
157 | - * every device module should override this method |
|
158 | - * |
|
159 | - * @return String HTML text to be displayed |
|
160 | - */ |
|
161 | - public function writeDeviceInfo() { |
|
162 | - return _("Sorry, this should not happen - no additional information is available"); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Copy a file from the module location to the temporary directory. |
|
167 | - * |
|
168 | - * If the second argument is provided then the file will be saved under the name |
|
169 | - * taken form this argument. If only one parameter is given, source and destination |
|
170 | - * filenames are the same |
|
171 | - * Source file can be located either in the Files subdirectory or in the sibdirectory of Files |
|
172 | - * named the same as device_id. The second option takes precedence. |
|
173 | - * |
|
174 | - * @param string $source_name The source file name |
|
175 | - * @param string $output_name The destination file name |
|
176 | - * |
|
177 | - * @return bool result of the copy operation |
|
178 | - * @final not to be redefined |
|
179 | - */ |
|
180 | - final protected function copyFile($source_name, $output_name = 0) { |
|
181 | - if ( $output_name === 0) |
|
151 | + } |
|
152 | + } |
|
153 | + return(0); |
|
154 | + } |
|
155 | + /** |
|
156 | + * prepare usage information for the installer |
|
157 | + * every device module should override this method |
|
158 | + * |
|
159 | + * @return String HTML text to be displayed |
|
160 | + */ |
|
161 | + public function writeDeviceInfo() { |
|
162 | + return _("Sorry, this should not happen - no additional information is available"); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Copy a file from the module location to the temporary directory. |
|
167 | + * |
|
168 | + * If the second argument is provided then the file will be saved under the name |
|
169 | + * taken form this argument. If only one parameter is given, source and destination |
|
170 | + * filenames are the same |
|
171 | + * Source file can be located either in the Files subdirectory or in the sibdirectory of Files |
|
172 | + * named the same as device_id. The second option takes precedence. |
|
173 | + * |
|
174 | + * @param string $source_name The source file name |
|
175 | + * @param string $output_name The destination file name |
|
176 | + * |
|
177 | + * @return bool result of the copy operation |
|
178 | + * @final not to be redefined |
|
179 | + */ |
|
180 | + final protected function copyFile($source_name, $output_name = 0) { |
|
181 | + if ( $output_name === 0) |
|
182 | 182 | $output_name = $source_name; |
183 | 183 | |
184 | - debug(4,"fileCopy($source_name, $output_name)\n"); |
|
185 | - if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
186 | - $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
187 | - elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
188 | - $source = $this->module_path.'/Files/'.$source_name; |
|
189 | - else { |
|
184 | + debug(4,"fileCopy($source_name, $output_name)\n"); |
|
185 | + if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
186 | + $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
187 | + elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
188 | + $source = $this->module_path.'/Files/'.$source_name; |
|
189 | + else { |
|
190 | 190 | debug(2,"fileCopy:reqested file $source_name does not exist\n"); |
191 | 191 | return(FALSE); |
192 | - } |
|
193 | - debug(4,"Copying $source to $output_name\n"); |
|
194 | - $result = copy($source,"$output_name"); |
|
195 | - if(! $result ) |
|
192 | + } |
|
193 | + debug(4,"Copying $source to $output_name\n"); |
|
194 | + $result = copy($source,"$output_name"); |
|
195 | + if(! $result ) |
|
196 | 196 | debug(2,"fileCopy($source_name, $output_name) failed\n"); |
197 | - return($result); |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * Copy a file from the module location to the temporary directory aplying transcoding. |
|
203 | - * |
|
204 | - * Transcoding is only required for Windows installers, and no Unicode support |
|
205 | - * in NSIS (NSIS version below 3) |
|
206 | - * Trancoding is only applied if the third optional parameter is set and nonzero |
|
207 | - * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied |
|
208 | - * regardless of the third parameter value. |
|
209 | - * If the second argument is provided and is not equal to 0, then the file will be |
|
210 | - * saved under the name taken from this argument. |
|
211 | - * If only one parameter is given or the second is equal to 0, source and destination |
|
212 | - * filenames are the same. |
|
213 | - * The third optional parameter, if nonzero, should be the character set understood by iconv |
|
214 | - * This is required by the Windows installer and is expected to go away in the future. |
|
215 | - * Source file can be located either in the Files subdirectory or in the sibdirectory of Files |
|
216 | - * named the same as device_id. The second option takes precedence. |
|
217 | - * |
|
218 | - * @param string $source_name The source file name |
|
219 | - * @param string $output_name The destination file name |
|
220 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
221 | - * |
|
222 | - * @final not to be redefined |
|
223 | - */ |
|
224 | - |
|
225 | - final protected function translateFile($source_name, $output_name = 0, $encoding = 0) { |
|
226 | - if(Config::$NSIS_VERSION >= 3) |
|
197 | + return($result); |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * Copy a file from the module location to the temporary directory aplying transcoding. |
|
203 | + * |
|
204 | + * Transcoding is only required for Windows installers, and no Unicode support |
|
205 | + * in NSIS (NSIS version below 3) |
|
206 | + * Trancoding is only applied if the third optional parameter is set and nonzero |
|
207 | + * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied |
|
208 | + * regardless of the third parameter value. |
|
209 | + * If the second argument is provided and is not equal to 0, then the file will be |
|
210 | + * saved under the name taken from this argument. |
|
211 | + * If only one parameter is given or the second is equal to 0, source and destination |
|
212 | + * filenames are the same. |
|
213 | + * The third optional parameter, if nonzero, should be the character set understood by iconv |
|
214 | + * This is required by the Windows installer and is expected to go away in the future. |
|
215 | + * Source file can be located either in the Files subdirectory or in the sibdirectory of Files |
|
216 | + * named the same as device_id. The second option takes precedence. |
|
217 | + * |
|
218 | + * @param string $source_name The source file name |
|
219 | + * @param string $output_name The destination file name |
|
220 | + * @param int $use_win_cp Set Windows charset if non-zero |
|
221 | + * |
|
222 | + * @final not to be redefined |
|
223 | + */ |
|
224 | + |
|
225 | + final protected function translateFile($source_name, $output_name = 0, $encoding = 0) { |
|
226 | + if(Config::$NSIS_VERSION >= 3) |
|
227 | 227 | $encoding = 0; |
228 | - if ( $output_name === 0) |
|
228 | + if ( $output_name === 0) |
|
229 | 229 | $output_name = $source_name; |
230 | 230 | |
231 | - debug(4,"translateFile($source_name, $output_name, $encoding)\n"); |
|
232 | - ob_start(); |
|
233 | - debug(4,$this->module_path.'/Files/'.$this->device_id.'/'.$source_name."\n"); |
|
234 | - if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
235 | - $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
236 | - elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
237 | - $source = $this->module_path.'/Files/'.$source_name; |
|
238 | - include($source); |
|
239 | - $output = ob_get_clean(); |
|
240 | - if($encoding) { |
|
231 | + debug(4,"translateFile($source_name, $output_name, $encoding)\n"); |
|
232 | + ob_start(); |
|
233 | + debug(4,$this->module_path.'/Files/'.$this->device_id.'/'.$source_name."\n"); |
|
234 | + if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
235 | + $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
236 | + elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
237 | + $source = $this->module_path.'/Files/'.$source_name; |
|
238 | + include($source); |
|
239 | + $output = ob_get_clean(); |
|
240 | + if($encoding) { |
|
241 | 241 | $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$output); |
242 | 242 | if($output_c) |
243 | - $output = $output_c; |
|
244 | - } |
|
245 | - $f = fopen("$output_name","w"); |
|
246 | - if(! $f) |
|
247 | - debug(2,"translateFile($source, $output_name, $encoding) failed\n"); |
|
248 | - fwrite($f,$output); |
|
249 | - fclose($f); |
|
250 | - debug(4,"translateFile($source, $output_name, $encoding) end\n"); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * Transcode a string adding double quotes escaping |
|
256 | - * |
|
257 | - * Transcoding is only required for Windows installers, and no Unicode support |
|
258 | - * in NSIS (NSIS version below 3) |
|
259 | - * Trancoding is only applied if the third optional parameter is set and nonzero |
|
260 | - * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied |
|
261 | - * regardless of the second parameter value. |
|
262 | - * The second optional parameter, if nonzero, should be the character set understood by iconv |
|
263 | - * This is required by the Windows installer and is expected to go away in the future. |
|
264 | - * |
|
265 | - * @param string $source_name The source file name |
|
266 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
267 | - * |
|
268 | - * @final not to be redefined |
|
269 | - */ |
|
270 | - |
|
271 | - final protected function translateString($source_string,$encoding = 0) { |
|
272 | - if(Config::$NSIS_VERSION >= 3) |
|
243 | + $output = $output_c; |
|
244 | + } |
|
245 | + $f = fopen("$output_name","w"); |
|
246 | + if(! $f) |
|
247 | + debug(2,"translateFile($source, $output_name, $encoding) failed\n"); |
|
248 | + fwrite($f,$output); |
|
249 | + fclose($f); |
|
250 | + debug(4,"translateFile($source, $output_name, $encoding) end\n"); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * Transcode a string adding double quotes escaping |
|
256 | + * |
|
257 | + * Transcoding is only required for Windows installers, and no Unicode support |
|
258 | + * in NSIS (NSIS version below 3) |
|
259 | + * Trancoding is only applied if the third optional parameter is set and nonzero |
|
260 | + * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied |
|
261 | + * regardless of the second parameter value. |
|
262 | + * The second optional parameter, if nonzero, should be the character set understood by iconv |
|
263 | + * This is required by the Windows installer and is expected to go away in the future. |
|
264 | + * |
|
265 | + * @param string $source_name The source file name |
|
266 | + * @param int $use_win_cp Set Windows charset if non-zero |
|
267 | + * |
|
268 | + * @final not to be redefined |
|
269 | + */ |
|
270 | + |
|
271 | + final protected function translateString($source_string,$encoding = 0) { |
|
272 | + if(Config::$NSIS_VERSION >= 3) |
|
273 | 273 | $encoding = 0; |
274 | - if($encoding) |
|
274 | + if($encoding) |
|
275 | 275 | $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string); |
276 | - else |
|
276 | + else |
|
277 | 277 | $output_c = $source_string; |
278 | - if($output_c) |
|
279 | - $source_string = str_replace('"','$\\"',$output_c); |
|
280 | - else |
|
281 | - debug(2,"Failed to convert string $source_string\n"); |
|
282 | - return $source_string; |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * Save certificate files in either DER or PEM format |
|
288 | - * |
|
289 | - * Certificate files will be saved in the module working directory. |
|
290 | - * @param string $format only "der" and "pem" are currently allowed |
|
291 | - * @return array an array of arrays or FALSE on error |
|
292 | - * saved certificate file names are avalable under the 'file' index |
|
293 | - * additional array entries are indexed as 'sha1', 'md5', and 'root'. |
|
294 | - * sha1 and md5 are correcponding certificate hashes |
|
295 | - * root is set to 1 for the CA roor certicicate and 0 otherwise |
|
296 | - */ |
|
297 | - final protected function saveCertificateFiles($format) { |
|
298 | - if($format == 'der' || $format == 'pam') { |
|
299 | - $i = 0; |
|
300 | - $CA_files = []; |
|
301 | - $ca_array = $this->attributes['internal:CAs'][0]; |
|
302 | - if(! $ca_array) |
|
303 | - return(FALSE); |
|
304 | - foreach ($ca_array as $CA) { |
|
305 | - $f = fopen("cert-$i.crt","w"); |
|
306 | - if(! $f) die("problem opening the file\n"); |
|
307 | - if($format == "pem") |
|
278 | + if($output_c) |
|
279 | + $source_string = str_replace('"','$\\"',$output_c); |
|
280 | + else |
|
281 | + debug(2,"Failed to convert string $source_string\n"); |
|
282 | + return $source_string; |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * Save certificate files in either DER or PEM format |
|
288 | + * |
|
289 | + * Certificate files will be saved in the module working directory. |
|
290 | + * @param string $format only "der" and "pem" are currently allowed |
|
291 | + * @return array an array of arrays or FALSE on error |
|
292 | + * saved certificate file names are avalable under the 'file' index |
|
293 | + * additional array entries are indexed as 'sha1', 'md5', and 'root'. |
|
294 | + * sha1 and md5 are correcponding certificate hashes |
|
295 | + * root is set to 1 for the CA roor certicicate and 0 otherwise |
|
296 | + */ |
|
297 | + final protected function saveCertificateFiles($format) { |
|
298 | + if($format == 'der' || $format == 'pam') { |
|
299 | + $i = 0; |
|
300 | + $CA_files = []; |
|
301 | + $ca_array = $this->attributes['internal:CAs'][0]; |
|
302 | + if(! $ca_array) |
|
303 | + return(FALSE); |
|
304 | + foreach ($ca_array as $CA) { |
|
305 | + $f = fopen("cert-$i.crt","w"); |
|
306 | + if(! $f) die("problem opening the file\n"); |
|
307 | + if($format == "pem") |
|
308 | 308 | fwrite($f,$CA['pem']); |
309 | - else |
|
309 | + else |
|
310 | 310 | fwrite($f,$CA['der']); |
311 | - fclose($f); |
|
312 | - $C = []; |
|
313 | - $C['file'] = "cert-$i.crt"; |
|
314 | - $C['sha1'] = $CA['sha1']; |
|
315 | - $C['md5'] = $CA['md5']; |
|
316 | - $C['root'] = $CA['root']; |
|
317 | - $CA_files[] = $C; |
|
318 | - $i++; |
|
319 | - } |
|
320 | - return($CA_files); |
|
321 | - } else { |
|
322 | - debug(2, 'incorrect format value specified'); |
|
323 | - return(FALSE); |
|
324 | - } |
|
311 | + fclose($f); |
|
312 | + $C = []; |
|
313 | + $C['file'] = "cert-$i.crt"; |
|
314 | + $C['sha1'] = $CA['sha1']; |
|
315 | + $C['md5'] = $CA['md5']; |
|
316 | + $C['root'] = $CA['root']; |
|
317 | + $CA_files[] = $C; |
|
318 | + $i++; |
|
319 | + } |
|
320 | + return($CA_files); |
|
321 | + } else { |
|
322 | + debug(2, 'incorrect format value specified'); |
|
323 | + return(FALSE); |
|
324 | + } |
|
325 | 325 | |
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Generate installer filename base. |
|
330 | - * Device module should use this name adding an extension. |
|
331 | - * Normally the device identifier follows the Consortium name. |
|
332 | - * The sting taken for the device identifier equals (by default) to the index in the listDevices array, |
|
333 | - * but can be overriden with the 'device_id' device option. |
|
334 | - */ |
|
335 | - private function getInstallerBasename() { |
|
336 | - $replace_pattern = '/[ ()\/\'"]+/'; |
|
337 | - $lang_pointer = Config::$LANGUAGES[$this->lang_index]['latin_based'] == TRUE ? 0 : 1; |
|
338 | - debug(4,"getInstallerBasename1:".$this->attributes['general:instname'][$lang_pointer]."\n"); |
|
339 | - $inst = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['general:instname'][$lang_pointer])); |
|
340 | - debug(4,"getInstallerBasename2:$inst\n"); |
|
341 | - $Inst_a = explode('_',$inst); |
|
342 | - if(count($Inst_a) > 2) { |
|
343 | - $inst = ''; |
|
344 | - foreach($Inst_a as $i) |
|
345 | - $inst .= $i[0]; |
|
346 | - } |
|
347 | - $c_name = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', Config::$CONSORTIUM['name'])); |
|
348 | - if($this->attributes['internal:profile_count'][0] > 1) { |
|
349 | - if(!empty($this->attributes['profile:name']) && ! empty($this->attributes['profile:name'][$lang_pointer])) { |
|
350 | - $prof = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['profile:name'][$lang_pointer])); |
|
351 | - $prof = preg_replace('/_+$/','',$prof); |
|
352 | - return $c_name. '-'. $this->getDeviceId() . $inst .'-'. $prof; |
|
353 | - } |
|
354 | - } |
|
355 | - return $c_name. '-'. $this->getDeviceId() . $inst; |
|
356 | - } |
|
357 | - |
|
358 | - private function getDeviceId() { |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Generate installer filename base. |
|
330 | + * Device module should use this name adding an extension. |
|
331 | + * Normally the device identifier follows the Consortium name. |
|
332 | + * The sting taken for the device identifier equals (by default) to the index in the listDevices array, |
|
333 | + * but can be overriden with the 'device_id' device option. |
|
334 | + */ |
|
335 | + private function getInstallerBasename() { |
|
336 | + $replace_pattern = '/[ ()\/\'"]+/'; |
|
337 | + $lang_pointer = Config::$LANGUAGES[$this->lang_index]['latin_based'] == TRUE ? 0 : 1; |
|
338 | + debug(4,"getInstallerBasename1:".$this->attributes['general:instname'][$lang_pointer]."\n"); |
|
339 | + $inst = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['general:instname'][$lang_pointer])); |
|
340 | + debug(4,"getInstallerBasename2:$inst\n"); |
|
341 | + $Inst_a = explode('_',$inst); |
|
342 | + if(count($Inst_a) > 2) { |
|
343 | + $inst = ''; |
|
344 | + foreach($Inst_a as $i) |
|
345 | + $inst .= $i[0]; |
|
346 | + } |
|
347 | + $c_name = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', Config::$CONSORTIUM['name'])); |
|
348 | + if($this->attributes['internal:profile_count'][0] > 1) { |
|
349 | + if(!empty($this->attributes['profile:name']) && ! empty($this->attributes['profile:name'][$lang_pointer])) { |
|
350 | + $prof = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['profile:name'][$lang_pointer])); |
|
351 | + $prof = preg_replace('/_+$/','',$prof); |
|
352 | + return $c_name. '-'. $this->getDeviceId() . $inst .'-'. $prof; |
|
353 | + } |
|
354 | + } |
|
355 | + return $c_name. '-'. $this->getDeviceId() . $inst; |
|
356 | + } |
|
357 | + |
|
358 | + private function getDeviceId() { |
|
359 | 359 | $d_id = $this->device_id; |
360 | 360 | if(isset($this->options['device_id'])) |
361 | - $d_id = $this->options['device_id']; |
|
361 | + $d_id = $this->options['device_id']; |
|
362 | 362 | if($d_id !== '') |
363 | - $d_id .= '-'; |
|
363 | + $d_id .= '-'; |
|
364 | 364 | return $d_id; |
365 | - } |
|
365 | + } |
|
366 | 366 | |
367 | 367 | |
368 | - private function getSSIDs() { |
|
368 | + private function getSSIDs() { |
|
369 | 369 | $S['add']=[]; |
370 | 370 | $S['del']=[]; |
371 | 371 | if (isset(Config::$CONSORTIUM['ssid'])) { |
372 | - foreach (Config::$CONSORTIUM['ssid'] as $ssid) { |
|
372 | + foreach (Config::$CONSORTIUM['ssid'] as $ssid) { |
|
373 | 373 | if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE) |
374 | - $S['add'][$ssid] = 'TKIP'; |
|
374 | + $S['add'][$ssid] = 'TKIP'; |
|
375 | 375 | else { |
376 | - $S['add'][$ssid] = 'AES'; |
|
377 | - $S['del'][$ssid] = 'TKIP'; |
|
376 | + $S['add'][$ssid] = 'AES'; |
|
377 | + $S['del'][$ssid] = 'TKIP'; |
|
378 | + } |
|
378 | 379 | } |
379 | - } |
|
380 | 380 | } |
381 | 381 | if(isset($this->attributes['media:SSID'])) { |
382 | - $SSID = $this->attributes['media:SSID']; |
|
382 | + $SSID = $this->attributes['media:SSID']; |
|
383 | 383 | |
384 | - foreach($SSID as $ssid) |
|
385 | - $S['add'][$ssid] = 'AES'; |
|
386 | - } |
|
384 | + foreach($SSID as $ssid) |
|
385 | + $S['add'][$ssid] = 'AES'; |
|
386 | + } |
|
387 | 387 | if(isset($this->attributes['media:SSID_with_legacy'])) { |
388 | - $SSID = $this->attributes['media:SSID_with_legacy']; |
|
389 | - foreach($SSID as $ssid) |
|
390 | - $S['add'][$ssid] = 'TKIP'; |
|
388 | + $SSID = $this->attributes['media:SSID_with_legacy']; |
|
389 | + foreach($SSID as $ssid) |
|
390 | + $S['add'][$ssid] = 'TKIP'; |
|
391 | 391 | } |
392 | 392 | if(isset($this->attributes['media:remove_SSID'])) { |
393 | - $SSID = $this->attributes['media:remove_SSID']; |
|
394 | - foreach($SSID as $ssid) |
|
395 | - $S['del'][$ssid] = 'DEL'; |
|
393 | + $SSID = $this->attributes['media:remove_SSID']; |
|
394 | + foreach($SSID as $ssid) |
|
395 | + $S['del'][$ssid] = 'DEL'; |
|
396 | 396 | } |
397 | 397 | return $S; |
398 | - } |
|
398 | + } |
|
399 | 399 | |
400 | - private function getConsortia() { |
|
401 | - $OIs = []; |
|
402 | - $OIs = array_merge($OIs, Config::$CONSORTIUM['interworking-consortium-oi']); |
|
403 | - if (isset($this->attributes['media:consortium_OI'])) |
|
404 | - foreach ($this->attributes['media:consortium_OI'] as $new_oi) |
|
400 | + private function getConsortia() { |
|
401 | + $OIs = []; |
|
402 | + $OIs = array_merge($OIs, Config::$CONSORTIUM['interworking-consortium-oi']); |
|
403 | + if (isset($this->attributes['media:consortium_OI'])) |
|
404 | + foreach ($this->attributes['media:consortium_OI'] as $new_oi) |
|
405 | 405 | $OIs[] = $new_oi; |
406 | - return $OIs; |
|
407 | - } |
|
406 | + return $OIs; |
|
407 | + } |
|
408 | 408 | |
409 | - /** |
|
410 | - * An array with shorthand definitions for MIME types |
|
411 | - * @var array |
|
412 | - */ |
|
413 | - private $mime_extensions = [ |
|
414 | - 'text/plain' => 'txt', |
|
415 | - 'text/rtf' => 'rtf', |
|
416 | - 'application/pdf' =>'pdf', |
|
417 | - ]; |
|
418 | - |
|
419 | - private function saveLogoFile($Logos) { |
|
409 | + /** |
|
410 | + * An array with shorthand definitions for MIME types |
|
411 | + * @var array |
|
412 | + */ |
|
413 | + private $mime_extensions = [ |
|
414 | + 'text/plain' => 'txt', |
|
415 | + 'text/rtf' => 'rtf', |
|
416 | + 'application/pdf' =>'pdf', |
|
417 | + ]; |
|
418 | + |
|
419 | + private function saveLogoFile($Logos) { |
|
420 | 420 | $i=0; |
421 | 421 | $returnarray= []; |
422 | 422 | foreach ($Logos as $blob) { |
423 | - $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
424 | - $mime = $finfo->buffer($blob); |
|
425 | - if(preg_match('/^image\/(.*)/',$mime,$m)) |
|
423 | + $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
424 | + $mime = $finfo->buffer($blob); |
|
425 | + if(preg_match('/^image\/(.*)/',$mime,$m)) |
|
426 | 426 | $ext = $m[1]; |
427 | - else |
|
427 | + else |
|
428 | 428 | $ext = 'unsupported'; |
429 | - debug(4,"saveLogoFile: $mime : $ext\n"); |
|
430 | - $f_name = 'logo-'.$i.'.'.$ext; |
|
431 | - $f = fopen($f_name,"w"); |
|
432 | - if(! $f) { |
|
433 | - debug(2,"saveLogoFile failed for: $f_name\n"); |
|
434 | - die("problem opening the file\n"); |
|
435 | - } |
|
436 | - fwrite($f,$blob); |
|
437 | - fclose($f); |
|
438 | - $returnarray[]= ['name'=>$f_name,'mime'=>$ext]; |
|
439 | - $i++; |
|
429 | + debug(4,"saveLogoFile: $mime : $ext\n"); |
|
430 | + $f_name = 'logo-'.$i.'.'.$ext; |
|
431 | + $f = fopen($f_name,"w"); |
|
432 | + if(! $f) { |
|
433 | + debug(2,"saveLogoFile failed for: $f_name\n"); |
|
434 | + die("problem opening the file\n"); |
|
435 | + } |
|
436 | + fwrite($f,$blob); |
|
437 | + fclose($f); |
|
438 | + $returnarray[]= ['name'=>$f_name,'mime'=>$ext]; |
|
439 | + $i++; |
|
440 | 440 | } |
441 | 441 | return($returnarray); |
442 | - } |
|
442 | + } |
|
443 | 443 | |
444 | 444 | |
445 | - private function saveInfoFile($blob) { |
|
445 | + private function saveInfoFile($blob) { |
|
446 | 446 | $finfo = new finfo(FILEINFO_MIME_TYPE); |
447 | 447 | $mime = $finfo->buffer($blob); |
448 | 448 | $ext = isset($this->mime_extensions[$mime]) ? $this->mime_extensions[$mime] : 'usupported'; |
@@ -452,43 +452,43 @@ discard block |
||
452 | 452 | fwrite($f,$blob); |
453 | 453 | fclose($f); |
454 | 454 | return(['name'=>'local-info.'.$ext,'mime'=>$ext]); |
455 | - } |
|
456 | - |
|
457 | - private function getProfileAttributes(Profile $profile) { |
|
458 | - $eaps = $profile->getEapMethodsinOrderOfPreference(1); |
|
459 | - if($eap = $this->getPreferredEapType($eaps)) { |
|
460 | - $a = $profile->getCollapsedAttributes($eap); |
|
461 | - $a['eap'] = $eap; |
|
462 | - $a['all_eaps'] = $eaps; |
|
463 | - return($a); |
|
464 | - } else { |
|
465 | - error("No supported eap types found for this profile."); |
|
466 | - return(FALSE); |
|
467 | - } |
|
468 | - } |
|
455 | + } |
|
456 | + |
|
457 | + private function getProfileAttributes(Profile $profile) { |
|
458 | + $eaps = $profile->getEapMethodsinOrderOfPreference(1); |
|
459 | + if($eap = $this->getPreferredEapType($eaps)) { |
|
460 | + $a = $profile->getCollapsedAttributes($eap); |
|
461 | + $a['eap'] = $eap; |
|
462 | + $a['all_eaps'] = $eaps; |
|
463 | + return($a); |
|
464 | + } else { |
|
465 | + error("No supported eap types found for this profile."); |
|
466 | + return(FALSE); |
|
467 | + } |
|
468 | + } |
|
469 | 469 | /** |
470 | - * dumps attributes for debugging purposes |
|
471 | - * |
|
472 | - * dumpAttibutes method is supplied for debuging purposes, it simply dumps the attribute array |
|
473 | - * to a file with name passed in the attribute. |
|
474 | - * @param string $file the output file name |
|
475 | - */ |
|
476 | - protected function dumpAttibutes($file) { |
|
470 | + * dumps attributes for debugging purposes |
|
471 | + * |
|
472 | + * dumpAttibutes method is supplied for debuging purposes, it simply dumps the attribute array |
|
473 | + * to a file with name passed in the attribute. |
|
474 | + * @param string $file the output file name |
|
475 | + */ |
|
476 | + protected function dumpAttibutes($file) { |
|
477 | 477 | ob_start(); |
478 | 478 | print_r($this->attributes); |
479 | 479 | $output = ob_get_clean(); |
480 | 480 | $f = fopen($file,"w"); |
481 | 481 | fwrite($f,$output); |
482 | 482 | fclose($f); |
483 | - } |
|
483 | + } |
|
484 | 484 | /** |
485 | - * placeholder for the main device method |
|
486 | - * |
|
487 | - */ |
|
485 | + * placeholder for the main device method |
|
486 | + * |
|
487 | + */ |
|
488 | 488 | |
489 | - protected function writeInstaller() { |
|
490 | - return("download path"); |
|
491 | - } |
|
489 | + protected function writeInstaller() { |
|
490 | + return("download path"); |
|
491 | + } |
|
492 | 492 | |
493 | 493 | /** |
494 | 494 | * Array passing all options to the device module. |
@@ -522,75 +522,75 @@ discard block |
||
522 | 522 | * @see X509::processCertificate() |
523 | 523 | * @var array $attributes |
524 | 524 | */ |
525 | - public $attributes; |
|
525 | + public $attributes; |
|
526 | 526 | /** |
527 | - * stores the path to the module source location and is used |
|
528 | - * by copyFile and translateFile |
|
529 | - * the only reason for it to be a public variable ies that it is set by the DeviceFactory class |
|
530 | - * module_path should not be used by module drivers. |
|
531 | - * @var string |
|
532 | - */ |
|
533 | - public $module_path; |
|
527 | + * stores the path to the module source location and is used |
|
528 | + * by copyFile and translateFile |
|
529 | + * the only reason for it to be a public variable ies that it is set by the DeviceFactory class |
|
530 | + * module_path should not be used by module drivers. |
|
531 | + * @var string |
|
532 | + */ |
|
533 | + public $module_path; |
|
534 | 534 | |
535 | 535 | /** |
536 | 536 | * The optimal EAP type |
537 | 537 | * |
538 | 538 | */ |
539 | 539 | /** |
540 | - * optimal EAP method selected given profile and device |
|
541 | - * @var EAP::constant |
|
542 | - */ |
|
543 | - public $selected_eap; |
|
540 | + * optimal EAP method selected given profile and device |
|
541 | + * @var EAP::constant |
|
542 | + */ |
|
543 | + public $selected_eap; |
|
544 | 544 | /** |
545 | - * the path to the profile signing program |
|
546 | - * device modules which require signing should use this property to exec the signer |
|
547 | - * the signer program must accept two arguments - input and output file names |
|
548 | - * the signer program mus operate in the local directory and filenames are relative to this |
|
549 | - * directory |
|
550 | - * |
|
551 | - *@var string |
|
552 | - */ |
|
553 | - public $sign; |
|
554 | - public $signer; |
|
545 | + * the path to the profile signing program |
|
546 | + * device modules which require signing should use this property to exec the signer |
|
547 | + * the signer program must accept two arguments - input and output file names |
|
548 | + * the signer program mus operate in the local directory and filenames are relative to this |
|
549 | + * directory |
|
550 | + * |
|
551 | + *@var string |
|
552 | + */ |
|
553 | + public $sign; |
|
554 | + public $signer; |
|
555 | 555 | /** |
556 | - * the string referencing the language (index ot the Config::$LANGUAGES array). |
|
557 | - * It is set to the current language and may be used by the device module to |
|
558 | - * set its language |
|
559 | - * |
|
560 | - *@var string |
|
561 | - */ |
|
562 | - public $lang_index; |
|
563 | - /** |
|
564 | - * The string identifier of the device (don't show this to users) |
|
565 | - * @var string |
|
566 | - */ |
|
567 | - public $device_id; |
|
568 | - |
|
569 | - /** |
|
570 | - * See devices-template.php for a list of available options |
|
571 | - * @var array |
|
572 | - */ |
|
573 | - public $options; |
|
574 | - |
|
575 | - /** |
|
576 | - * This string will be shown if no support email was configured by the admin |
|
577 | - * |
|
578 | - * @var string |
|
579 | - */ |
|
580 | - public static $support_email_substitute; |
|
581 | - |
|
582 | - /** |
|
583 | - * This string will be shown if no support URL was configured by the admin |
|
584 | - * |
|
585 | - * @var string |
|
586 | - */ |
|
587 | - public static $support_url_substitute; |
|
588 | - |
|
589 | - /** |
|
590 | - * This string should be used by all installer modules to set the |
|
591 | - * installer file basename. |
|
592 | - * |
|
593 | - * @var string |
|
594 | - */ |
|
595 | - public static $installerBasename; |
|
556 | + * the string referencing the language (index ot the Config::$LANGUAGES array). |
|
557 | + * It is set to the current language and may be used by the device module to |
|
558 | + * set its language |
|
559 | + * |
|
560 | + *@var string |
|
561 | + */ |
|
562 | + public $lang_index; |
|
563 | + /** |
|
564 | + * The string identifier of the device (don't show this to users) |
|
565 | + * @var string |
|
566 | + */ |
|
567 | + public $device_id; |
|
568 | + |
|
569 | + /** |
|
570 | + * See devices-template.php for a list of available options |
|
571 | + * @var array |
|
572 | + */ |
|
573 | + public $options; |
|
574 | + |
|
575 | + /** |
|
576 | + * This string will be shown if no support email was configured by the admin |
|
577 | + * |
|
578 | + * @var string |
|
579 | + */ |
|
580 | + public static $support_email_substitute; |
|
581 | + |
|
582 | + /** |
|
583 | + * This string will be shown if no support URL was configured by the admin |
|
584 | + * |
|
585 | + * @var string |
|
586 | + */ |
|
587 | + public static $support_url_substitute; |
|
588 | + |
|
589 | + /** |
|
590 | + * This string should be used by all installer modules to set the |
|
591 | + * installer file basename. |
|
592 | + * |
|
593 | + * @var string |
|
594 | + */ |
|
595 | + public static $installerBasename; |
|
596 | 596 | } |
@@ -32,6 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * write debug messages to the log |
34 | 34 | * |
35 | + * @param integer $level |
|
35 | 36 | */ |
36 | 37 | function debug($level, $t) { |
37 | 38 | if (Config::$DEBUG_LEVEL >= $level) { |
@@ -130,7 +131,7 @@ discard block |
||
130 | 131 | * generates a UUID |
131 | 132 | * |
132 | 133 | * @param string $prefix an extra prefix to set before the UUID |
133 | - * @return UUID (possibly prefixed) |
|
134 | + * @return string (possibly prefixed) |
|
134 | 135 | */ |
135 | 136 | function uuid($prefix = '', $deterministic_source = NULL) { |
136 | 137 | if ($deterministic_source === NULL) |
@@ -180,32 +180,32 @@ discard block |
||
180 | 180 | function createTemporaryDirectory($purpose = 'installer',$fail = 1) { |
181 | 181 | $name = md5(time().rand()); |
182 | 182 | switch($purpose) { |
183 | - case 'installer': |
|
183 | + case 'installer': |
|
184 | 184 | $path = CAT::$root.'/var/installer_cache'; |
185 | - break; |
|
186 | - case 'logo': |
|
185 | + break; |
|
186 | + case 'logo': |
|
187 | 187 | $path = CAT::$root.'/web/downloads/logos'; |
188 | - break; |
|
189 | - case 'test': |
|
188 | + break; |
|
189 | + case 'test': |
|
190 | 190 | $path = CAT::$root.'/var/tmp'; |
191 | - break; |
|
192 | - default: |
|
191 | + break; |
|
192 | + default: |
|
193 | 193 | error("unable to create temporary directory for unknown purpose: $purpose\n"); |
194 | - exit; |
|
194 | + exit; |
|
195 | 195 | } |
196 | 196 | $tmp_dir = $path .'/'. $name; |
197 | 197 | debug(4,"temp dir: $purpose : $tmp_dir\n"); |
198 | 198 | if(! mkdir($tmp_dir,0700, true)) { |
199 | - if($fail) { |
|
200 | - error("unable to create temporary directory: $tmp_dir\n"); |
|
201 | - exit; |
|
202 | - } else { |
|
199 | + if($fail) { |
|
200 | + error("unable to create temporary directory: $tmp_dir\n"); |
|
201 | + exit; |
|
202 | + } else { |
|
203 | 203 | debug(4, "Directory creation failed for $tmp_dir\n"); |
204 | 204 | return ['base'=>$path,'dir'=>'',$name=>'']; |
205 | - } |
|
205 | + } |
|
206 | 206 | } else |
207 | - debug(4, "Directory created: $tmp_dir\n"); |
|
208 | - return ['base'=>$path,'dir'=>$tmp_dir,'name'=>$name]; |
|
207 | + debug(4, "Directory created: $tmp_dir\n"); |
|
208 | + return ['base'=>$path,'dir'=>$tmp_dir,'name'=>$name]; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | function png_inject_consortium_logo ($inputpngstring, $symbolsize = 12, $marginsymbols = 4) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $targetplacementy = $symbolsize * round(($sizeinput[1] / 2 - ($targetheight - $symbolsize) / 2)/$symbolsize); |
237 | 237 | imagecopyresized($inputgd, $whiteimage, $targetplacementx-$symbolsize, $targetplacementy-$symbolsize, 0, 0, $targetwidth+2*$symbolsize, $targetheight+2*$symbolsize, $targetwidth+2*$symbolsize, $targetheight+2*$symbolsize); |
238 | 238 | imagecopyresized($inputgd, $logogd, $targetplacementx, $targetplacementy, 0, 0, $targetwidth , $targetheight , $sizelogo[0] , $sizelogo[1]); |
239 | - // imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
|
239 | + // imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
|
240 | 240 | ob_start(); |
241 | 241 | imagepng($inputgd); |
242 | 242 | return ob_get_clean(); |
@@ -96,6 +96,10 @@ discard block |
||
96 | 96 | define('QR_FORMAT_PNG', 1); |
97 | 97 | |
98 | 98 | class qrstr { |
99 | + |
|
100 | + /** |
|
101 | + * @param string $repl |
|
102 | + */ |
|
99 | 103 | public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
100 | 104 | $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
101 | 105 | } |
@@ -231,6 +235,11 @@ discard block |
||
231 | 235 | } |
232 | 236 | |
233 | 237 | //---------------------------------------------------------------------- |
238 | + |
|
239 | + /** |
|
240 | + * @param boolean $outfile |
|
241 | + * @param string $err |
|
242 | + */ |
|
234 | 243 | public static function log($outfile, $err) |
235 | 244 | { |
236 | 245 | if (QR_LOG_DIR !== false) { |
@@ -256,6 +265,10 @@ discard block |
||
256 | 265 | } |
257 | 266 | |
258 | 267 | //---------------------------------------------------------------------- |
268 | + |
|
269 | + /** |
|
270 | + * @param string $markerId |
|
271 | + */ |
|
259 | 272 | public static function markTime($markerId) |
260 | 273 | { |
261 | 274 | list($usec, $sec) = explode(" ", microtime()); |
@@ -410,18 +423,30 @@ discard block |
||
410 | 423 | } |
411 | 424 | |
412 | 425 | //---------------------------------------------------------------------- |
426 | + |
|
427 | + /** |
|
428 | + * @param integer $version |
|
429 | + */ |
|
413 | 430 | public static function getWidth($version) |
414 | 431 | { |
415 | 432 | return self::$capacity[$version][QRCAP_WIDTH]; |
416 | 433 | } |
417 | 434 | |
418 | 435 | //---------------------------------------------------------------------- |
436 | + |
|
437 | + /** |
|
438 | + * @param integer $version |
|
439 | + */ |
|
419 | 440 | public static function getRemainder($version) |
420 | 441 | { |
421 | 442 | return self::$capacity[$version][QRCAP_REMINDER]; |
422 | 443 | } |
423 | 444 | |
424 | 445 | //---------------------------------------------------------------------- |
446 | + |
|
447 | + /** |
|
448 | + * @param integer $size |
|
449 | + */ |
|
425 | 450 | public static function getMinimumVersion($size, $level) |
426 | 451 | { |
427 | 452 | |
@@ -535,6 +560,9 @@ discard block |
||
535 | 560 | //---------------------------------------------------------------------- |
536 | 561 | // CACHEABLE!!! |
537 | 562 | |
563 | + /** |
|
564 | + * @param integer $version |
|
565 | + */ |
|
538 | 566 | public static function getEccSpec($version, $level, array &$spec) |
539 | 567 | { |
540 | 568 | if (count($spec) < 5) { |
@@ -857,12 +885,20 @@ discard block |
||
857 | 885 | } |
858 | 886 | |
859 | 887 | //---------------------------------------------------------------------- |
888 | + |
|
889 | + /** |
|
890 | + * @param string $code |
|
891 | + */ |
|
860 | 892 | public static function unserial($code) |
861 | 893 | { |
862 | 894 | return explode("\n", gzuncompress($code)); |
863 | 895 | } |
864 | 896 | |
865 | 897 | //---------------------------------------------------------------------- |
898 | + |
|
899 | + /** |
|
900 | + * @param integer $version |
|
901 | + */ |
|
866 | 902 | public static function newFrame($version) |
867 | 903 | { |
868 | 904 | if($version < 1 || $version > QRSPEC_VERSION_MAX) |
@@ -1236,6 +1272,10 @@ discard block |
||
1236 | 1272 | } |
1237 | 1273 | |
1238 | 1274 | //---------------------------------------------------------------------- |
1275 | + |
|
1276 | + /** |
|
1277 | + * @param integer $version |
|
1278 | + */ |
|
1239 | 1279 | public function encodeBitStream($version) |
1240 | 1280 | { |
1241 | 1281 | try { |
@@ -1313,6 +1353,10 @@ discard block |
||
1313 | 1353 | } |
1314 | 1354 | |
1315 | 1355 | //---------------------------------------------------------------------- |
1356 | + |
|
1357 | + /** |
|
1358 | + * @param integer $version |
|
1359 | + */ |
|
1316 | 1360 | public function setVersion($version) |
1317 | 1361 | { |
1318 | 1362 | if($version < 0 || $version > QRSPEC_VERSION_MAX) { |
@@ -1351,6 +1395,12 @@ discard block |
||
1351 | 1395 | } |
1352 | 1396 | |
1353 | 1397 | //---------------------------------------------------------------------- |
1398 | + |
|
1399 | + /** |
|
1400 | + * @param QRinput $mode |
|
1401 | + * @param integer $size |
|
1402 | + * @param integer $data |
|
1403 | + */ |
|
1354 | 1404 | public function append($mode, $size, $data) |
1355 | 1405 | { |
1356 | 1406 | try { |
@@ -1446,6 +1496,10 @@ discard block |
||
1446 | 1496 | ]; |
1447 | 1497 | |
1448 | 1498 | //---------------------------------------------------------------------- |
1499 | + |
|
1500 | + /** |
|
1501 | + * @param integer $c |
|
1502 | + */ |
|
1449 | 1503 | public static function lookAnTable($c) |
1450 | 1504 | { |
1451 | 1505 | return (($c > 127)?-1:self::$anTable[$c]); |
@@ -1531,6 +1585,10 @@ discard block |
||
1531 | 1585 | |
1532 | 1586 | |
1533 | 1587 | //---------------------------------------------------------------------- |
1588 | + |
|
1589 | + /** |
|
1590 | + * @param integer $version |
|
1591 | + */ |
|
1534 | 1592 | public function estimateBitStreamSize($version) |
1535 | 1593 | { |
1536 | 1594 | $bits = 0; |
@@ -1648,6 +1706,10 @@ discard block |
||
1648 | 1706 | } |
1649 | 1707 | |
1650 | 1708 | //---------------------------------------------------------------------- |
1709 | + |
|
1710 | + /** |
|
1711 | + * @param QRbitstream $bstream |
|
1712 | + */ |
|
1651 | 1713 | public function appendPaddingBit(&$bstream) |
1652 | 1714 | { |
1653 | 1715 | $bits = $bstream->size(); |
@@ -1977,6 +2039,10 @@ discard block |
||
1977 | 2039 | public $modeHint; |
1978 | 2040 | |
1979 | 2041 | //---------------------------------------------------------------------- |
2042 | + |
|
2043 | + /** |
|
2044 | + * @param QRinput $input |
|
2045 | + */ |
|
1980 | 2046 | public function __construct($dataStr, $input, $modeHint) |
1981 | 2047 | { |
1982 | 2048 | $this->dataStr = $dataStr; |
@@ -1985,6 +2051,10 @@ discard block |
||
1985 | 2051 | } |
1986 | 2052 | |
1987 | 2053 | //---------------------------------------------------------------------- |
2054 | + |
|
2055 | + /** |
|
2056 | + * @param string $str |
|
2057 | + */ |
|
1988 | 2058 | public static function isdigitat($str, $pos) |
1989 | 2059 | { |
1990 | 2060 | if ($pos >= strlen($str)) |
@@ -1994,6 +2064,10 @@ discard block |
||
1994 | 2064 | } |
1995 | 2065 | |
1996 | 2066 | //---------------------------------------------------------------------- |
2067 | + |
|
2068 | + /** |
|
2069 | + * @param string $str |
|
2070 | + */ |
|
1997 | 2071 | public static function isalnumat($str, $pos) |
1998 | 2072 | { |
1999 | 2073 | if ($pos >= strlen($str)) |
@@ -2114,6 +2188,10 @@ discard block |
||
2114 | 2188 | } |
2115 | 2189 | |
2116 | 2190 | //---------------------------------------------------------------------- |
2191 | + |
|
2192 | + /** |
|
2193 | + * @return integer |
|
2194 | + */ |
|
2117 | 2195 | public function eatKanji() |
2118 | 2196 | { |
2119 | 2197 | $p = 0; |
@@ -2447,6 +2525,13 @@ discard block |
||
2447 | 2525 | public static $items = []; |
2448 | 2526 | |
2449 | 2527 | //---------------------------------------------------------------------- |
2528 | + |
|
2529 | + /** |
|
2530 | + * @param integer $symsize |
|
2531 | + * @param integer $gfpoly |
|
2532 | + * @param integer $fcr |
|
2533 | + * @param integer $prim |
|
2534 | + */ |
|
2450 | 2535 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
2451 | 2536 | { |
2452 | 2537 | foreach(self::$items as $rs) { |
@@ -2601,6 +2686,10 @@ discard block |
||
2601 | 2686 | } |
2602 | 2687 | |
2603 | 2688 | //---------------------------------------------------------------------- |
2689 | + |
|
2690 | + /** |
|
2691 | + * @param string $code |
|
2692 | + */ |
|
2604 | 2693 | public static function unserial($code) |
2605 | 2694 | { |
2606 | 2695 | $codeArr = []; |
@@ -2661,6 +2750,10 @@ discard block |
||
2661 | 2750 | } |
2662 | 2751 | |
2663 | 2752 | //---------------------------------------------------------------------- |
2753 | + |
|
2754 | + /** |
|
2755 | + * @param integer $length |
|
2756 | + */ |
|
2664 | 2757 | public function calcN1N3($length) |
2665 | 2758 | { |
2666 | 2759 | $demerit = 0; |
@@ -2971,6 +3064,10 @@ discard block |
||
2971 | 3064 | public $data; |
2972 | 3065 | |
2973 | 3066 | //---------------------------------------------------------------------- |
3067 | + |
|
3068 | + /** |
|
3069 | + * @param integer $mask |
|
3070 | + */ |
|
2974 | 3071 | public function encodeMask(QRinput $input, $mask) |
2975 | 3072 | { |
2976 | 3073 | if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) { |
@@ -3052,6 +3149,11 @@ discard block |
||
3052 | 3149 | } |
3053 | 3150 | |
3054 | 3151 | //---------------------------------------------------------------------- |
3152 | + |
|
3153 | + /** |
|
3154 | + * @param integer $version |
|
3155 | + * @param integer $level |
|
3156 | + */ |
|
3055 | 3157 | public function encodeString8bit($string, $version, $level) |
3056 | 3158 | { |
3057 | 3159 | if(string == NULL) { |
@@ -3071,6 +3173,12 @@ discard block |
||
3071 | 3173 | } |
3072 | 3174 | |
3073 | 3175 | //---------------------------------------------------------------------- |
3176 | + |
|
3177 | + /** |
|
3178 | + * @param integer $version |
|
3179 | + * @param integer $level |
|
3180 | + * @param boolean $casesensitive |
|
3181 | + */ |
|
3074 | 3182 | public function encodeString($string, $version, $level, $hint, $casesensitive) |
3075 | 3183 | { |
3076 | 3184 |
@@ -74,32 +74,32 @@ discard block |
||
74 | 74 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
75 | 75 | */ |
76 | 76 | |
77 | - // Encoding modes |
|
77 | + // Encoding modes |
|
78 | 78 | |
79 | - define('QR_MODE_NUL', -1); |
|
80 | - define('QR_MODE_NUM', 0); |
|
81 | - define('QR_MODE_AN', 1); |
|
82 | - define('QR_MODE_8', 2); |
|
83 | - define('QR_MODE_KANJI', 3); |
|
84 | - define('QR_MODE_STRUCTURE', 4); |
|
85 | - |
|
86 | - // Levels of error correction. |
|
87 | - |
|
88 | - define('QR_ECLEVEL_L', 0); |
|
89 | - define('QR_ECLEVEL_M', 1); |
|
90 | - define('QR_ECLEVEL_Q', 2); |
|
91 | - define('QR_ECLEVEL_H', 3); |
|
79 | + define('QR_MODE_NUL', -1); |
|
80 | + define('QR_MODE_NUM', 0); |
|
81 | + define('QR_MODE_AN', 1); |
|
82 | + define('QR_MODE_8', 2); |
|
83 | + define('QR_MODE_KANJI', 3); |
|
84 | + define('QR_MODE_STRUCTURE', 4); |
|
85 | + |
|
86 | + // Levels of error correction. |
|
87 | + |
|
88 | + define('QR_ECLEVEL_L', 0); |
|
89 | + define('QR_ECLEVEL_M', 1); |
|
90 | + define('QR_ECLEVEL_Q', 2); |
|
91 | + define('QR_ECLEVEL_H', 3); |
|
92 | 92 | |
93 | - // Supported output formats |
|
93 | + // Supported output formats |
|
94 | 94 | |
95 | - define('QR_FORMAT_TEXT', 0); |
|
96 | - define('QR_FORMAT_PNG', 1); |
|
95 | + define('QR_FORMAT_TEXT', 0); |
|
96 | + define('QR_FORMAT_PNG', 1); |
|
97 | 97 | |
98 | - class qrstr { |
|
99 | - public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
|
100 | - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
|
101 | - } |
|
102 | - } |
|
98 | + class qrstr { |
|
99 | + public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
|
100 | + $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | //---------------------------------------------------------------------- |
212 | 212 | public static function buildCache() |
213 | 213 | { |
214 | - QRtools::markTime('before_build_cache'); |
|
214 | + QRtools::markTime('before_build_cache'); |
|
215 | 215 | |
216 | - $mask = new QRmask(); |
|
216 | + $mask = new QRmask(); |
|
217 | 217 | for ($a=1; $a <= QRSPEC_VERSION_MAX; $a++) { |
218 | 218 | $frame = QRspec::newFrame($a); |
219 | 219 | if (QR_IMAGE) { |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | QRimage::png(self::binarize($frame), $fileName, 1, 0); |
222 | 222 | } |
223 | 223 | |
224 | - $width = count($frame); |
|
225 | - $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
|
226 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
224 | + $width = count($frame); |
|
225 | + $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
|
226 | + for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
228 | 228 | } |
229 | 229 | |
230 | - QRtools::markTime('after_build_cache'); |
|
230 | + QRtools::markTime('after_build_cache'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | //---------------------------------------------------------------------- |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | |
648 | 648 | // Version information pattern ----------------------------------------- |
649 | 649 | |
650 | - // Version information pattern (BCH coded). |
|
650 | + // Version information pattern (BCH coded). |
|
651 | 651 | // See Table 1 in Appendix D (pp.68) of JIS X0510:2004. |
652 | 652 | |
653 | - // size: [QRSPEC_VERSION_MAX - 6] |
|
653 | + // size: [QRSPEC_VERSION_MAX - 6] |
|
654 | 654 | |
655 | 655 | public static $versionPattern = [ |
656 | 656 | 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
1439 | 1439 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
1440 | 1440 | 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, |
1441 | - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, |
|
1441 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, |
|
1442 | 1442 | -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
1443 | 1443 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, |
1444 | 1444 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
@@ -2500,17 +2500,17 @@ discard block |
||
2500 | 2500 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2501 | 2501 | */ |
2502 | 2502 | |
2503 | - define('N1', 3); |
|
2504 | - define('N2', 3); |
|
2505 | - define('N3', 40); |
|
2506 | - define('N4', 10); |
|
2503 | + define('N1', 3); |
|
2504 | + define('N2', 3); |
|
2505 | + define('N3', 40); |
|
2506 | + define('N4', 10); |
|
2507 | 2507 | |
2508 | - class QRmask { |
|
2508 | + class QRmask { |
|
2509 | 2509 | |
2510 | - public $runLength = []; |
|
2510 | + public $runLength = []; |
|
2511 | 2511 | |
2512 | - //---------------------------------------------------------------------- |
|
2513 | - public function __construct() |
|
2512 | + //---------------------------------------------------------------------- |
|
2513 | + public function __construct() |
|
2514 | 2514 | { |
2515 | 2515 | $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0); |
2516 | 2516 | } |
@@ -957,6 +957,11 @@ discard block |
||
957 | 957 | return $anon_id; |
958 | 958 | } |
959 | 959 | |
960 | + /** |
|
961 | + * @param string $inner_user |
|
962 | + * @param string $password |
|
963 | + * @param string $clientcertdata |
|
964 | + */ |
|
960 | 965 | public function UDP_login($probeindex, $eaptype, $inner_user, $password, $outer_user = '', $opname_check = TRUE, $frag = TRUE, $clientcertdata = NULL) { |
961 | 966 | if (!isset(Config::$RADIUSTESTS['UDP-hosts'][$probeindex])) { |
962 | 967 | $this->UDP_reachability_executed = RETVAL_NOTCONFIGURED; |
@@ -1478,10 +1483,8 @@ discard block |
||
1478 | 1483 | /** |
1479 | 1484 | * This function executes openssl s_client command |
1480 | 1485 | * |
1481 | - * @param string $key points NAPTR_hostname_records |
|
1482 | - * @param string $bracketaddr IP address |
|
1483 | - * @param int $port |
|
1484 | - * @param string $arg arguments to add to the openssl command |
|
1486 | + * @param string $arg arguments to add to the openssl command |
|
1487 | + * @param string $host |
|
1485 | 1488 | * @return string result of oenssl s_client ... |
1486 | 1489 | */ |
1487 | 1490 | function openssl_s_client($host, $arg, &$testresults) { |
@@ -328,7 +328,6 @@ |
||
328 | 328 | * - RETVAL_NOT_CONFIGURED; needs Config::$RADIUSTESTS['TLS-discoverytag'] |
329 | 329 | * - RETVAL_INVALID (at least one format error) |
330 | 330 | * - RETVAL_OK (all fine) |
331 | - |
|
332 | 331 | * @return int one of two RETVALs above |
333 | 332 | */ |
334 | 333 | public function NAPTR_compliance() { |
@@ -138,6 +138,9 @@ |
||
138 | 138 | $this->test_result['global'] = max($this->test_result['global'],$level); |
139 | 139 | } |
140 | 140 | |
141 | + /** |
|
142 | + * @param string $s |
|
143 | + */ |
|
141 | 144 | private function get_exec_path($s) { |
142 | 145 | $the_path = ""; |
143 | 146 | $exec_is = "UNDEFINED"; |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | |
46 | 46 | /* List all required NSIS modules below */ |
47 | 47 | private $NSIS_Modules = [ |
48 | - "nsArray.nsh", |
|
49 | - "FileFunc.nsh", |
|
50 | - "LogicLib.nsh", |
|
51 | - "WordFunc.nsh", |
|
52 | - "FileFunc.nsh", |
|
53 | - "x64.nsh", |
|
54 | - ]; |
|
48 | + "nsArray.nsh", |
|
49 | + "FileFunc.nsh", |
|
50 | + "LogicLib.nsh", |
|
51 | + "WordFunc.nsh", |
|
52 | + "FileFunc.nsh", |
|
53 | + "x64.nsh", |
|
54 | + ]; |
|
55 | 55 | |
56 | 56 | /* set $profile_option_ct to the number of rows returned by "SELECT * FROM profile_option_dict" */ |
57 | 57 | private $profile_option_ct = 28; |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | public $name; |
65 | 65 | |
66 | 66 | public function __construct() { |
67 | - parent::__construct(); |
|
68 | - $this->test_result = []; |
|
69 | - $this->test_result['global'] = 0; |
|
67 | + parent::__construct(); |
|
68 | + $this->test_result = []; |
|
69 | + $this->test_result['global'] = 0; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * @param string $test the test name |
75 | 75 | */ |
76 | 76 | public function test($test) { |
77 | - $this->out[$test] =[]; |
|
78 | - $this->name = $test; |
|
79 | - $m_name = $test.'_test'; |
|
80 | - $this->test_result[$test] = 0; |
|
81 | - if(! method_exists($this,$m_name)) { |
|
82 | - $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>."); |
|
83 | - return; |
|
84 | - } |
|
85 | - $this->$m_name(); |
|
77 | + $this->out[$test] =[]; |
|
78 | + $this->name = $test; |
|
79 | + $m_name = $test.'_test'; |
|
80 | + $this->test_result[$test] = 0; |
|
81 | + if(! method_exists($this,$m_name)) { |
|
82 | + $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>."); |
|
83 | + return; |
|
84 | + } |
|
85 | + $this->$m_name(); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -95,27 +95,27 @@ discard block |
||
95 | 95 | * and returned a success. |
96 | 96 | */ |
97 | 97 | public function run_tests($Tests) { |
98 | - foreach ($Tests as $t) { |
|
99 | - if(preg_match('/(.+)=>(.+)/',$t,$m)) { |
|
98 | + foreach ($Tests as $t) { |
|
99 | + if(preg_match('/(.+)=>(.+)/',$t,$m)) { |
|
100 | 100 | $tst = $m[1]; |
101 | 101 | $subtst=$m[2]; |
102 | 102 | if($this->test_result[$tst] < L_ERROR) |
103 | - $this->test($subtst); |
|
104 | - } |
|
105 | - else |
|
103 | + $this->test($subtst); |
|
104 | + } |
|
105 | + else |
|
106 | 106 | $this->test($t); |
107 | - } |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | public function get_test_names() { |
111 | - $T = get_class_methods($this); |
|
112 | - $out = []; |
|
113 | - foreach($T as $t) { |
|
114 | - if(preg_match('/^(.*)_test$/',$t,$m)) { |
|
111 | + $T = get_class_methods($this); |
|
112 | + $out = []; |
|
113 | + foreach($T as $t) { |
|
114 | + if(preg_match('/^(.*)_test$/',$t,$m)) { |
|
115 | 115 | $out[] = $m[1]; |
116 | - } |
|
117 | - } |
|
118 | - return $out; |
|
116 | + } |
|
117 | + } |
|
118 | + return $out; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -141,84 +141,84 @@ discard block |
||
141 | 141 | $the_path = ""; |
142 | 142 | $exec_is = "UNDEFINED"; |
143 | 143 | if (!empty(Config::$PATHS[$s])) { |
144 | - preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m); |
|
145 | - $exe = $m[1]; |
|
146 | - $the_path = exec("which " . Config::$PATHS[$s]); |
|
147 | - if ($the_path == $exe) |
|
148 | - $exec_is = "EXPLICIT"; |
|
149 | - else |
|
150 | - $exec_is = "IMPLICIT"; |
|
151 | - } |
|
144 | + preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m); |
|
145 | + $exe = $m[1]; |
|
146 | + $the_path = exec("which " . Config::$PATHS[$s]); |
|
147 | + if ($the_path == $exe) |
|
148 | + $exec_is = "EXPLICIT"; |
|
149 | + else |
|
150 | + $exec_is = "IMPLICIT"; |
|
151 | + } |
|
152 | 152 | return(['exec'=>$the_path,'exec_is'=>$exec_is]); |
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | - * Test for php version |
|
157 | - */ |
|
156 | + * Test for php version |
|
157 | + */ |
|
158 | 158 | private function php_test() { |
159 | - if (version_compare(phpversion(), $this->php_needversion, '>=')) |
|
159 | + if (version_compare(phpversion(), $this->php_needversion, '>=')) |
|
160 | 160 | $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . "."); |
161 | - else |
|
161 | + else |
|
162 | 162 | $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). "."); |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * test for simpleSAMLphp |
|
167 | - */ |
|
166 | + * test for simpleSAMLphp |
|
167 | + */ |
|
168 | 168 | private function ssp_test() { |
169 | - if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader'])) |
|
170 | - $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!"); |
|
171 | - else |
|
172 | - $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found."); |
|
169 | + if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader'])) |
|
170 | + $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!"); |
|
171 | + else |
|
172 | + $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found."); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * test for security setting |
|
177 | - */ |
|
176 | + * test for security setting |
|
177 | + */ |
|
178 | 178 | private function security_test() { |
179 | - if (in_array("I do not care about security!", Config::$SUPERADMINS)) |
|
180 | - $this->test_return(L_WARN,"You do not care about security. This page should be made accessible to the CAT admin only! See config.php 'Superadmins'!"); |
|
179 | + if (in_array("I do not care about security!", Config::$SUPERADMINS)) |
|
180 | + $this->test_return(L_WARN,"You do not care about security. This page should be made accessible to the CAT admin only! See config.php 'Superadmins'!"); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | - * test if zip is available |
|
185 | - */ |
|
184 | + * test if zip is available |
|
185 | + */ |
|
186 | 186 | private function zip_test() { |
187 | - if (exec("which zip") != "") |
|
188 | - $this->test_return(L_OK,"<strong>zip</strong> binary found."); |
|
189 | - else |
|
190 | - $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!"); |
|
187 | + if (exec("which zip") != "") |
|
188 | + $this->test_return(L_OK,"<strong>zip</strong> binary found."); |
|
189 | + else |
|
190 | + $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!"); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | - * test if eapol_test is availabe and reacent enough |
|
195 | - */ |
|
194 | + * test if eapol_test is availabe and reacent enough |
|
195 | + */ |
|
196 | 196 | private function eapol_test_test() { |
197 | - exec(Config::$PATHS['eapol_test'], $out, $retval); |
|
198 | - if($retval == 255 ) { |
|
197 | + exec(Config::$PATHS['eapol_test'], $out, $retval); |
|
198 | + if($retval == 255 ) { |
|
199 | 199 | $o = preg_grep('/-o<server cert/',$out); |
200 | - if(count($o) > 0) |
|
201 | - $this->test_return(L_OK,"<strong>eapol_test</strong> script found."); |
|
202 | - else |
|
203 | - $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!"); |
|
204 | - } |
|
205 | - else |
|
200 | + if(count($o) > 0) |
|
201 | + $this->test_return(L_OK,"<strong>eapol_test</strong> script found."); |
|
202 | + else |
|
203 | + $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!"); |
|
204 | + } |
|
205 | + else |
|
206 | 206 | $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!"); |
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | - * test if logdir exists and is writable |
|
211 | - */ |
|
210 | + * test if logdir exists and is writable |
|
211 | + */ |
|
212 | 212 | private function logdir_test() { |
213 | - if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE) |
|
214 | - $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!"); |
|
215 | - else |
|
216 | - $this->test_return(L_OK,"Log directory is writable."); |
|
213 | + if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE) |
|
214 | + $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!"); |
|
215 | + else |
|
216 | + $this->test_return(L_OK,"Log directory is writable."); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | - * test for required PHP modules |
|
221 | - */ |
|
220 | + * test for required PHP modules |
|
221 | + */ |
|
222 | 222 | private function phpModules_test() { |
223 | 223 | if (function_exists('idn_to_ascii')) |
224 | 224 | $this->test_return(L_OK,"PHP can handle internationalisation."); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | if (function_exists('gettext')) |
229 | 229 | $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed."); |
230 | 230 | else |
231 | - $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!"); |
|
231 | + $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!"); |
|
232 | 232 | |
233 | 233 | if (function_exists('openssl_sign')) |
234 | 234 | $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed."); |
@@ -270,193 +270,193 @@ discard block |
||
270 | 270 | */ |
271 | 271 | |
272 | 272 | private function geoip_test() { |
273 | - $host_4 = '145.0.2.50'; |
|
274 | - $host_6 = '2001:610:188:444::50'; |
|
275 | - switch (Config::$GEOIP['version']) { |
|
276 | - case 0: |
|
273 | + $host_4 = '145.0.2.50'; |
|
274 | + $host_6 = '2001:610:188:444::50'; |
|
275 | + switch (Config::$GEOIP['version']) { |
|
276 | + case 0: |
|
277 | 277 | $this->test_return(L_REMARK,"As set in the config, no geolocation service will be used"); |
278 | - break; |
|
279 | - case 1: |
|
278 | + break; |
|
279 | + case 1: |
|
280 | 280 | if (!function_exists('geoip_record_by_name')) { |
281 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) not found! Get it from your distribution or <a href='http://pecl.php.net/package/geoip'>here</a> or better install GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>."); |
|
282 | - return; |
|
283 | - } |
|
284 | - $record = geoip_record_by_name($host_4); |
|
285 | - if(! $record) { |
|
286 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
287 | - return; |
|
288 | - } |
|
289 | - if($record['city'] != 'Utrecht') { |
|
290 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
291 | - return; |
|
292 | - } |
|
293 | - $this->test_return(L_REMARK,"PHP extension <strong>GeoIP</strong> (legacy) is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly. We stronly advise to replace the legacy GeoIP with GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>."); |
|
294 | - break; |
|
295 | - case 2: |
|
281 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) not found! Get it from your distribution or <a href='http://pecl.php.net/package/geoip'>here</a> or better install GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>."); |
|
282 | + return; |
|
283 | + } |
|
284 | + $record = geoip_record_by_name($host_4); |
|
285 | + if(! $record) { |
|
286 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
287 | + return; |
|
288 | + } |
|
289 | + if($record['city'] != 'Utrecht') { |
|
290 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
291 | + return; |
|
292 | + } |
|
293 | + $this->test_return(L_REMARK,"PHP extension <strong>GeoIP</strong> (legacy) is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly. We stronly advise to replace the legacy GeoIP with GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>."); |
|
294 | + break; |
|
295 | + case 2: |
|
296 | 296 | if(! is_file(Config::$GEOIP['geoip2-path-to-autoloader'])) { |
297 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> not found! Get it from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>."); |
|
298 | - return; |
|
299 | - } |
|
300 | - if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) { |
|
301 | - $this->test_return(L_ERROR,"<strong>GeoIP2 database</strong> not found! See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
302 | - return; |
|
303 | - } |
|
304 | - require_once Config::$GEOIP['geoip2-path-to-autoloader']; |
|
305 | - $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']); |
|
306 | - try { |
|
307 | - $record = $reader->city($host_4); |
|
308 | - } catch (Exception $e) { |
|
309 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
310 | - return; |
|
311 | - } |
|
312 | - if( $record->city->name != 'Utrecht') { |
|
313 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
314 | - return; |
|
315 | - } |
|
316 | - try { |
|
317 | - $record = $reader->city($host_6); |
|
318 | - } catch (Exception $e) { |
|
319 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
320 | - return; |
|
321 | - } |
|
322 | - if( $record->city->name != 'Utrecht') { |
|
323 | - $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
324 | - return; |
|
325 | - } |
|
326 | - $this->test_return(L_OK,"PHP extension <strong>GeoIP2</strong> is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
327 | - break; |
|
328 | - default: |
|
297 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> not found! Get it from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>."); |
|
298 | + return; |
|
299 | + } |
|
300 | + if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) { |
|
301 | + $this->test_return(L_ERROR,"<strong>GeoIP2 database</strong> not found! See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
302 | + return; |
|
303 | + } |
|
304 | + require_once Config::$GEOIP['geoip2-path-to-autoloader']; |
|
305 | + $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']); |
|
306 | + try { |
|
307 | + $record = $reader->city($host_4); |
|
308 | + } catch (Exception $e) { |
|
309 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
310 | + return; |
|
311 | + } |
|
312 | + if( $record->city->name != 'Utrecht') { |
|
313 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
314 | + return; |
|
315 | + } |
|
316 | + try { |
|
317 | + $record = $reader->city($host_6); |
|
318 | + } catch (Exception $e) { |
|
319 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
320 | + return; |
|
321 | + } |
|
322 | + if( $record->city->name != 'Utrecht') { |
|
323 | + $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
324 | + return; |
|
325 | + } |
|
326 | + $this->test_return(L_OK,"PHP extension <strong>GeoIP2</strong> is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly."); |
|
327 | + break; |
|
328 | + default: |
|
329 | 329 | $this->test_return(L_ERROR,'Check Config::$GEOIP[\'version\'], it must be set to either 1 or 2'); |
330 | - break; |
|
331 | - } |
|
330 | + break; |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | - * test if openssl is available |
|
336 | - */ |
|
335 | + * test if openssl is available |
|
336 | + */ |
|
337 | 337 | private function openssl_test() { |
338 | - $A = $this->get_exec_path('openssl'); |
|
339 | - if($A['exec'] != "") { |
|
340 | - $t = exec($A['exec'] . ' version'); |
|
341 | - if($A['exec_is'] == "EXPLICIT") |
|
338 | + $A = $this->get_exec_path('openssl'); |
|
339 | + if($A['exec'] != "") { |
|
340 | + $t = exec($A['exec'] . ' version'); |
|
341 | + if($A['exec_is'] == "EXPLICIT") |
|
342 | 342 | $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config."); |
343 | - else |
|
343 | + else |
|
344 | 344 | $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config."); |
345 | - } else |
|
345 | + } else |
|
346 | 346 | $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!"); |
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | - * test if makensis is available |
|
351 | - */ |
|
350 | + * test if makensis is available |
|
351 | + */ |
|
352 | 352 | private function makensis_test() { |
353 | - if(! is_numeric(Config::$NSIS_VERSION)) { |
|
353 | + if(! is_numeric(Config::$NSIS_VERSION)) { |
|
354 | 354 | $this->test_return(L_ERROR,"NSIS_VERSION needs to be numeric!"); |
355 | 355 | return; |
356 | - } |
|
357 | - if(Config::$NSIS_VERSION < 2) { |
|
356 | + } |
|
357 | + if(Config::$NSIS_VERSION < 2) { |
|
358 | 358 | $this->test_return(L_ERROR,"NSIS_VERSION needs to be at least 2!"); |
359 | 359 | return; |
360 | - } |
|
361 | - $A = $this->get_exec_path('makensis'); |
|
362 | - if($A['exec'] != "") { |
|
363 | - $t = exec($A['exec'] . ' -VERSION'); |
|
364 | - if($A['exec_is'] == "EXPLICIT") |
|
360 | + } |
|
361 | + $A = $this->get_exec_path('makensis'); |
|
362 | + if($A['exec'] != "") { |
|
363 | + $t = exec($A['exec'] . ' -VERSION'); |
|
364 | + if($A['exec_is'] == "EXPLICIT") |
|
365 | 365 | $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config."); |
366 | - else |
|
366 | + else |
|
367 | 367 | $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config."); |
368 | - exec($A['exec'] . ' -HELP',$t); |
|
369 | - $t1 = count(preg_grep('/INPUTCHARSET/',$t)); |
|
370 | - if($t1 == 1 && Config::$NSIS_VERSION == 2) |
|
368 | + exec($A['exec'] . ' -HELP',$t); |
|
369 | + $t1 = count(preg_grep('/INPUTCHARSET/',$t)); |
|
370 | + if($t1 == 1 && Config::$NSIS_VERSION == 2) |
|
371 | 371 | $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
372 | - if($t1 == 0 && Config::$NSIS_VERSION >= 3) |
|
372 | + if($t1 == 0 && Config::$NSIS_VERSION >= 3) |
|
373 | 373 | $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
374 | - } else |
|
374 | + } else |
|
375 | 375 | $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!"); |
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | - * test if all required NSIS modules are available |
|
380 | - */ |
|
379 | + * test if all required NSIS modules are available |
|
380 | + */ |
|
381 | 381 | private function NSISmodules_test() { |
382 | - $tmp_dir = createTemporaryDirectory('installer',0)['dir']; |
|
383 | - if(!chdir($tmp_dir)) { |
|
384 | - debug(2, "Cannot chdir to $tmp_dir\n"); |
|
385 | - $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue"); |
|
386 | - return; |
|
387 | - } |
|
388 | - $exe= 'tt.exe'; |
|
389 | - $NSIS_Module_status = []; |
|
390 | - foreach ($this->NSIS_Modules as $module) { |
|
382 | + $tmp_dir = createTemporaryDirectory('installer',0)['dir']; |
|
383 | + if(!chdir($tmp_dir)) { |
|
384 | + debug(2, "Cannot chdir to $tmp_dir\n"); |
|
385 | + $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue"); |
|
386 | + return; |
|
387 | + } |
|
388 | + $exe= 'tt.exe'; |
|
389 | + $NSIS_Module_status = []; |
|
390 | + foreach ($this->NSIS_Modules as $module) { |
|
391 | 391 | unset($out); |
392 | 392 | exec(Config::$PATHS['makensis']." -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval); |
393 | 393 | if($retval > 0) |
394 | - $NSIS_Module_status[$module] = 0; |
|
394 | + $NSIS_Module_status[$module] = 0; |
|
395 | 395 | else |
396 | - $NSIS_Module_status[$module] = 1; |
|
397 | - } |
|
398 | - if(is_file($exe)) |
|
396 | + $NSIS_Module_status[$module] = 1; |
|
397 | + } |
|
398 | + if(is_file($exe)) |
|
399 | 399 | unlink($exe); |
400 | - foreach ($NSIS_Module_status as $module => $status) { |
|
400 | + foreach ($NSIS_Module_status as $module => $status) { |
|
401 | 401 | if($status == 1) |
402 | - $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found."); |
|
402 | + $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found."); |
|
403 | 403 | else |
404 | - $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly."); |
|
405 | - } |
|
404 | + $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly."); |
|
405 | + } |
|
406 | 406 | } |
407 | 407 | private function NSIS_GetVersion_test() { |
408 | - $tmp_dir = createTemporaryDirectory('installer',0)['dir']; |
|
409 | - if(!chdir($tmp_dir)) { |
|
410 | - debug(2, "Cannot chdir to $tmp_dir\n"); |
|
411 | - $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue"); |
|
412 | - return; |
|
413 | - } |
|
414 | - $exe= 'tt.exe'; |
|
415 | - exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval); |
|
416 | - if($retval > 0) |
|
408 | + $tmp_dir = createTemporaryDirectory('installer',0)['dir']; |
|
409 | + if(!chdir($tmp_dir)) { |
|
410 | + debug(2, "Cannot chdir to $tmp_dir\n"); |
|
411 | + $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue"); |
|
412 | + return; |
|
413 | + } |
|
414 | + $exe= 'tt.exe'; |
|
415 | + exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval); |
|
416 | + if($retval > 0) |
|
417 | 417 | $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly."); |
418 | - else |
|
418 | + else |
|
419 | 419 | $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found."); |
420 | - if(is_file($exe)) |
|
420 | + if(is_file($exe)) |
|
421 | 421 | unlink($exe); |
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
425 | - * test access to dowloads directories |
|
426 | - */ |
|
425 | + * test access to dowloads directories |
|
426 | + */ |
|
427 | 427 | private function directories_test() { |
428 | - $Dir = createTemporaryDirectory('installer',0); |
|
429 | - $dir = $Dir['dir']; |
|
430 | - $base = $Dir['base']; |
|
431 | - if($dir) { |
|
432 | - $this->test_return(L_OK,"Installer cache directory is writable."); |
|
433 | - rrmdir($dir); |
|
434 | - } else { |
|
435 | - $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!"); |
|
436 | - } |
|
437 | - $Dir = createTemporaryDirectory('test',0); |
|
438 | - $dir = $Dir['dir']; |
|
439 | - $base = $Dir['base']; |
|
440 | - if($dir) { |
|
441 | - $this->test_return(L_OK,"Test directory is writable."); |
|
442 | - rrmdir($dir); |
|
443 | - } else { |
|
444 | - $this->test_return(L_ERROR,"Test directory $base does not exist or is not writable!"); |
|
445 | - } |
|
446 | - $Dir = createTemporaryDirectory('logo',0); |
|
447 | - $dir = $Dir['dir']; |
|
448 | - $base = $Dir['base']; |
|
449 | - if($dir) { |
|
450 | - $this->test_return(L_OK,"Logos cache directory is writable."); |
|
451 | - rrmdir($dir); |
|
452 | - } else { |
|
453 | - $this->test_return(L_ERROR,"Logos cache directory $base does not exist or is not writable!"); |
|
454 | - } |
|
428 | + $Dir = createTemporaryDirectory('installer',0); |
|
429 | + $dir = $Dir['dir']; |
|
430 | + $base = $Dir['base']; |
|
431 | + if($dir) { |
|
432 | + $this->test_return(L_OK,"Installer cache directory is writable."); |
|
433 | + rrmdir($dir); |
|
434 | + } else { |
|
435 | + $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!"); |
|
436 | + } |
|
437 | + $Dir = createTemporaryDirectory('test',0); |
|
438 | + $dir = $Dir['dir']; |
|
439 | + $base = $Dir['base']; |
|
440 | + if($dir) { |
|
441 | + $this->test_return(L_OK,"Test directory is writable."); |
|
442 | + rrmdir($dir); |
|
443 | + } else { |
|
444 | + $this->test_return(L_ERROR,"Test directory $base does not exist or is not writable!"); |
|
445 | + } |
|
446 | + $Dir = createTemporaryDirectory('logo',0); |
|
447 | + $dir = $Dir['dir']; |
|
448 | + $base = $Dir['base']; |
|
449 | + if($dir) { |
|
450 | + $this->test_return(L_OK,"Logos cache directory is writable."); |
|
451 | + rrmdir($dir); |
|
452 | + } else { |
|
453 | + $this->test_return(L_ERROR,"Logos cache directory $base does not exist or is not writable!"); |
|
454 | + } |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
458 | - * test if all required locales are enabled |
|
459 | - */ |
|
458 | + * test if all required locales are enabled |
|
459 | + */ |
|
460 | 460 | private function locales_test() { |
461 | 461 | $locales = shell_exec("locale -a"); |
462 | 462 | $allthere = ""; |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | |
480 | 480 | |
481 | 481 | /** |
482 | - * test if detalts in the config have been replaced with some real values |
|
483 | - */ |
|
482 | + * test if detalts in the config have been replaced with some real values |
|
483 | + */ |
|
484 | 484 | private function defaults_test() { |
485 | 485 | $defaultvalues = ""; |
486 | 486 | $missingvalues = ""; |
@@ -531,121 +531,121 @@ discard block |
||
531 | 531 | $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign."); |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
534 | + /** |
|
535 | 535 | * test access to databases |
536 | 536 | */ |
537 | - private function databases_test() { |
|
537 | + private function databases_test() { |
|
538 | 538 | $DB = 'INST'; |
539 | 539 | $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']); |
540 | 540 | if(! $db) { |
541 | - $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
|
541 | + $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
|
542 | 542 | } else { |
543 | - $r = mysqli_query($db,'select * from profile_option_dict'); |
|
544 | - if($r->num_rows == $this->profile_option_ct) |
|
545 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
546 | - else |
|
547 | - $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT."); |
|
543 | + $r = mysqli_query($db,'select * from profile_option_dict'); |
|
544 | + if($r->num_rows == $this->profile_option_ct) |
|
545 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
546 | + else |
|
547 | + $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT."); |
|
548 | 548 | } |
549 | 549 | $DB = 'USER'; |
550 | 550 | $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']); |
551 | 551 | if(! $db) { |
552 | - $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
|
552 | + $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
|
553 | 553 | } else { |
554 | - $r = mysqli_query($db,'desc view_admin'); |
|
555 | - if($r->num_rows == $this->view_admin_ct) |
|
556 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
557 | - else |
|
558 | - $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
554 | + $r = mysqli_query($db,'desc view_admin'); |
|
555 | + if($r->num_rows == $this->view_admin_ct) |
|
556 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
557 | + else |
|
558 | + $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
559 | 559 | } |
560 | 560 | $DB = 'EXTERNAL'; |
561 | 561 | if(! empty(Config::$DB[$DB])) { |
562 | 562 | $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']); |
563 | 563 | if(! $db) { |
564 | - $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
|
564 | + $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
|
565 | 565 | } else { |
566 | - $r = mysqli_query($db,'desc view_admin'); |
|
567 | - if($r->num_rows == $this->view_admin_ct) |
|
568 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
569 | - else |
|
570 | - $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
566 | + $r = mysqli_query($db,'desc view_admin'); |
|
567 | + if($r->num_rows == $this->view_admin_ct) |
|
568 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
569 | + else |
|
570 | + $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
571 | 571 | } |
572 | 572 | } |
573 | - } |
|
573 | + } |
|
574 | 574 | |
575 | 575 | |
576 | - /** |
|
576 | + /** |
|
577 | 577 | * test devices.php for the no_cache option |
578 | 578 | */ |
579 | - private function device_cache_test() { |
|
580 | - if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache']) |
|
581 | - $global_no_cache = 1; |
|
582 | - else |
|
583 | - $global_no_cache = 0; |
|
584 | - |
|
585 | - if($global_no_cache == 1) |
|
586 | - $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n"); |
|
587 | - $Devs = Devices::listDevices(); |
|
588 | - $no_cache_dev = ''; |
|
589 | - $no_cache_dev_count = 0; |
|
590 | - if($global_no_cache) { |
|
591 | - foreach ($Devs as $dev=>$D) { |
|
592 | - if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) { |
|
579 | + private function device_cache_test() { |
|
580 | + if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache']) |
|
581 | + $global_no_cache = 1; |
|
582 | + else |
|
583 | + $global_no_cache = 0; |
|
584 | + |
|
585 | + if($global_no_cache == 1) |
|
586 | + $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n"); |
|
587 | + $Devs = Devices::listDevices(); |
|
588 | + $no_cache_dev = ''; |
|
589 | + $no_cache_dev_count = 0; |
|
590 | + if($global_no_cache) { |
|
591 | + foreach ($Devs as $dev=>$D) { |
|
592 | + if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) { |
|
593 | 593 | $no_cache_dev .= $dev." "; |
594 | 594 | $no_cache_dev_count++; |
595 | - } |
|
596 | - } |
|
597 | - } else { |
|
598 | - foreach ($Devs as $dev=>$D) { |
|
599 | - if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) { |
|
595 | + } |
|
596 | + } |
|
597 | + } else { |
|
598 | + foreach ($Devs as $dev=>$D) { |
|
599 | + if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) { |
|
600 | 600 | $no_cache_dev .= $dev." "; |
601 | 601 | $no_cache_dev_count++; |
602 | - } |
|
603 | - } |
|
604 | - } |
|
602 | + } |
|
603 | + } |
|
604 | + } |
|
605 | 605 | |
606 | 606 | |
607 | - if($no_cache_dev_count > 1 ) |
|
608 | - $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev"); |
|
609 | - if($no_cache_dev_count == 1 ) |
|
610 | - $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev"); |
|
607 | + if($no_cache_dev_count > 1 ) |
|
608 | + $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev"); |
|
609 | + if($no_cache_dev_count == 1 ) |
|
610 | + $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev"); |
|
611 | 611 | |
612 | - } |
|
612 | + } |
|
613 | 613 | |
614 | - /** |
|
614 | + /** |
|
615 | 615 | * test if mailer works |
616 | 616 | */ |
617 | - private function mailer_test() { |
|
618 | - if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") { |
|
619 | - $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests."); |
|
620 | - return; |
|
621 | - } |
|
622 | - $mail = new PHPMailer\PHPMailer\PHPMailer(); |
|
623 | - $mail->isSMTP(); |
|
624 | - $mail->Port = 587; |
|
625 | - $mail->SMTPAuth = true; |
|
626 | - $mail->SMTPSecure = 'tls'; |
|
627 | - $mail->Host = Config::$MAILSETTINGS['host']; |
|
628 | - $mail->Username = Config::$MAILSETTINGS['user']; |
|
629 | - $mail->Password = Config::$MAILSETTINGS['pass']; |
|
630 | - $mail->WordWrap = 72; |
|
631 | - $mail->isHTML(FALSE); |
|
632 | - $mail->CharSet = 'UTF-8'; |
|
633 | - $mail->From = Config::$APPEARANCE['from-mail']; |
|
634 | - $mail->FromName = Config::$APPEARANCE['productname'] . " Invitation System"; |
|
635 | - $mail->addAddress(Config::$APPEARANCE['abuse-mail']); |
|
636 | - $mail->Subject = "testing CAT configuration mail"; |
|
637 | - $mail->Body = "Testing CAT mailing\n"; |
|
638 | - $sent = $mail->send(); |
|
639 | - if($sent) |
|
640 | - $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced."); |
|
641 | - else |
|
642 | - $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS"); |
|
643 | - |
|
644 | - } |
|
617 | + private function mailer_test() { |
|
618 | + if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") { |
|
619 | + $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests."); |
|
620 | + return; |
|
621 | + } |
|
622 | + $mail = new PHPMailer\PHPMailer\PHPMailer(); |
|
623 | + $mail->isSMTP(); |
|
624 | + $mail->Port = 587; |
|
625 | + $mail->SMTPAuth = true; |
|
626 | + $mail->SMTPSecure = 'tls'; |
|
627 | + $mail->Host = Config::$MAILSETTINGS['host']; |
|
628 | + $mail->Username = Config::$MAILSETTINGS['user']; |
|
629 | + $mail->Password = Config::$MAILSETTINGS['pass']; |
|
630 | + $mail->WordWrap = 72; |
|
631 | + $mail->isHTML(FALSE); |
|
632 | + $mail->CharSet = 'UTF-8'; |
|
633 | + $mail->From = Config::$APPEARANCE['from-mail']; |
|
634 | + $mail->FromName = Config::$APPEARANCE['productname'] . " Invitation System"; |
|
635 | + $mail->addAddress(Config::$APPEARANCE['abuse-mail']); |
|
636 | + $mail->Subject = "testing CAT configuration mail"; |
|
637 | + $mail->Body = "Testing CAT mailing\n"; |
|
638 | + $sent = $mail->send(); |
|
639 | + if($sent) |
|
640 | + $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced."); |
|
641 | + else |
|
642 | + $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS"); |
|
643 | + |
|
644 | + } |
|
645 | 645 | |
646 | 646 | /** |
647 | - * TODO test if RADIUS connections work |
|
648 | - */ |
|
647 | + * TODO test if RADIUS connections work |
|
648 | + */ |
|
649 | 649 | private function UDPhosts_test() { |
650 | 650 | // if(empty) |
651 | 651 | } |
@@ -260,7 +260,6 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * Return the list of IdPs in a given country |
262 | 262 | * |
263 | - * @param int $idp_id the IdP identifier |
|
264 | 263 | * @return string JSON encoded data |
265 | 264 | */ |
266 | 265 | |
@@ -301,7 +300,6 @@ discard block |
||
301 | 300 | /** |
302 | 301 | * Return the list of IdPs in a given country ordered with respect to the user location |
303 | 302 | * |
304 | - * @param int $idp_id the IdP identifier |
|
305 | 303 | * @return string JSON encoded data |
306 | 304 | */ |
307 | 305 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * link - the path name of the resulting installer |
53 | 53 | * mime - the mimetype of the installer |
54 | 54 | */ |
55 | - public function generateInstaller($device,$prof_id, $generated_for = "user") { |
|
55 | + public function generateInstaller($device,$prof_id, $generated_for = "user") { |
|
56 | 56 | $this->set_locale("devices"); |
57 | 57 | $Dev = Devices::listDevices(); |
58 | 58 | $Config = $Dev[$device]; |
@@ -61,93 +61,93 @@ discard block |
||
61 | 61 | $attribs = $profile->getCollapsedAttributes(); |
62 | 62 | // test if the profile is production-ready and if not if the authenticated user is an owner |
63 | 63 | if (!isset($attribs['profile:production']) || (isset($attribs['profile:production']) && $attribs['profile:production'][0] != "on")) { |
64 | - debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n"); |
|
65 | - require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']); |
|
66 | - $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']); |
|
67 | - if($as->isAuthenticated()) { |
|
68 | - $user_object = new User($_SESSION['user']); |
|
69 | - if($user_object->isIdPOwner($profile->institution)) { |
|
70 | - debug(4, "User is the owner - allowing access\n"); |
|
71 | - } else { |
|
72 | - debug(2, "User not an owner of a non-production profile - access forbidden\n"); |
|
73 | - header("HTTP/1.0 403 Not Authorized"); |
|
74 | - return; |
|
75 | - } |
|
76 | - } else { |
|
77 | - debug(2, "User NOT authenticated, rejecting request for a non-production installer\n"); |
|
78 | - header("HTTP/1.0 403 Not Authorized"); |
|
79 | - return; |
|
80 | - } |
|
64 | + debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n"); |
|
65 | + require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']); |
|
66 | + $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']); |
|
67 | + if($as->isAuthenticated()) { |
|
68 | + $user_object = new User($_SESSION['user']); |
|
69 | + if($user_object->isIdPOwner($profile->institution)) { |
|
70 | + debug(4, "User is the owner - allowing access\n"); |
|
71 | + } else { |
|
72 | + debug(2, "User not an owner of a non-production profile - access forbidden\n"); |
|
73 | + header("HTTP/1.0 403 Not Authorized"); |
|
74 | + return; |
|
75 | + } |
|
76 | + } else { |
|
77 | + debug(2, "User NOT authenticated, rejecting request for a non-production installer\n"); |
|
78 | + header("HTTP/1.0 403 Not Authorized"); |
|
79 | + return; |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | $a = []; |
83 | 83 | $a['profile'] = $prof_id; |
84 | 84 | $a['device'] = $device; |
85 | 85 | if( (isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache'] ) || ( isset($Config['options']['no_cache']) && $Config['options']['no_cache'] )) |
86 | - $this->i_path = FALSE; |
|
86 | + $this->i_path = FALSE; |
|
87 | 87 | else { |
88 | - $cache = $profile->testCache($device); |
|
89 | - $this->i_path = $cache['cache']; |
|
88 | + $cache = $profile->testCache($device); |
|
89 | + $this->i_path = $cache['cache']; |
|
90 | 90 | } |
91 | 91 | if($this->i_path && is_file($this->i_path)) { |
92 | - debug(4,"Using cached installer for: $device\n"); |
|
93 | - $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
94 | - $a['mime'] = $cache['mime']; |
|
92 | + debug(4,"Using cached installer for: $device\n"); |
|
93 | + $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
94 | + $a['mime'] = $cache['mime']; |
|
95 | 95 | } else { |
96 | - $factory = new DeviceFactory($device); |
|
97 | - $dev = $factory->device; |
|
98 | - if(isset($dev)) { |
|
99 | - $dev->setup($profile); |
|
100 | - $installer = $dev->writeInstaller(); |
|
101 | - $i_path = $dev->FPATH.'/tmp/'.$installer; |
|
102 | - if($i_path && is_file($i_path)) { |
|
103 | - if(isset($dev->options['mime'])) |
|
104 | - $a['mime'] = $dev->options['mime']; |
|
105 | - else { |
|
106 | - $info = new finfo(); |
|
107 | - $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE); |
|
108 | - } |
|
109 | - $this->i_path = $dev->FPATH.'/'.$installer; |
|
110 | - rename($i_path, $this->i_path); |
|
111 | - $profile->updateCache($device,$this->i_path,$a['mime']); |
|
96 | + $factory = new DeviceFactory($device); |
|
97 | + $dev = $factory->device; |
|
98 | + if(isset($dev)) { |
|
99 | + $dev->setup($profile); |
|
100 | + $installer = $dev->writeInstaller(); |
|
101 | + $i_path = $dev->FPATH.'/tmp/'.$installer; |
|
102 | + if($i_path && is_file($i_path)) { |
|
103 | + if(isset($dev->options['mime'])) |
|
104 | + $a['mime'] = $dev->options['mime']; |
|
105 | + else { |
|
106 | + $info = new finfo(); |
|
107 | + $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE); |
|
108 | + } |
|
109 | + $this->i_path = $dev->FPATH.'/'.$installer; |
|
110 | + rename($i_path, $this->i_path); |
|
111 | + $profile->updateCache($device,$this->i_path,$a['mime']); |
|
112 | 112 | // rrmdir($dev->FPATH.'/tmp'); |
113 | - debug(4,"Generated installer: ".$this->i_path.": for: $device\n"); |
|
114 | - $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
115 | - } else { |
|
116 | - debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n"); |
|
117 | - $a['link'] = 0; |
|
118 | - } |
|
119 | - } |
|
113 | + debug(4,"Generated installer: ".$this->i_path.": for: $device\n"); |
|
114 | + $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
115 | + } else { |
|
116 | + debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n"); |
|
117 | + $a['link'] = 0; |
|
118 | + } |
|
119 | + } |
|
120 | 120 | } |
121 | 121 | $this->set_locale("web_user"); |
122 | 122 | return($a); |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * interface to Devices::listDevices() |
|
127 | - */ |
|
128 | - public function listDevices($show_hidden = 0) { |
|
125 | + /** |
|
126 | + * interface to Devices::listDevices() |
|
127 | + */ |
|
128 | + public function listDevices($show_hidden = 0) { |
|
129 | 129 | $Dev = Devices::listDevices(); |
130 | 130 | $R = []; |
131 | 131 | $ct = 0; |
132 | 132 | if($show_hidden !== 0 && $show_hidden != 1) |
133 | - return; |
|
133 | + return; |
|
134 | 134 | foreach ($Dev as $device => $D) { |
135 | - if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
136 | - continue; |
|
137 | - $ct ++; |
|
138 | - if($this->version == 1) |
|
139 | - $D['device'] = $device; |
|
140 | - else |
|
141 | - $D['device'] = $device; |
|
142 | - $group = isset($D['group']) ? $D['group'] : 'other'; |
|
143 | - if (! isset($R[$group])) |
|
144 | - $R[$group] = []; |
|
145 | - $R[$group][$device] = $D; |
|
146 | - } |
|
147 | - return $R; |
|
148 | - } |
|
149 | - |
|
150 | - public function deviceInfo($device,$prof_id) { |
|
135 | + if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
136 | + continue; |
|
137 | + $ct ++; |
|
138 | + if($this->version == 1) |
|
139 | + $D['device'] = $device; |
|
140 | + else |
|
141 | + $D['device'] = $device; |
|
142 | + $group = isset($D['group']) ? $D['group'] : 'other'; |
|
143 | + if (! isset($R[$group])) |
|
144 | + $R[$group] = []; |
|
145 | + $R[$group][$device] = $D; |
|
146 | + } |
|
147 | + return $R; |
|
148 | + } |
|
149 | + |
|
150 | + public function deviceInfo($device,$prof_id) { |
|
151 | 151 | $this->set_locale("devices"); |
152 | 152 | $out = 0; |
153 | 153 | $profile = new Profile($prof_id); |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | $dev = $factory->device; |
156 | 156 | if(isset($dev)) { |
157 | 157 | // $dev->setup($profile); |
158 | - $out = $dev->writeDeviceInfo(); |
|
159 | - } |
|
158 | + $out = $dev->writeDeviceInfo(); |
|
159 | + } |
|
160 | 160 | $this->set_locale("web_user"); |
161 | 161 | echo $out; |
162 | - } |
|
162 | + } |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Prepare the support data for a given profile |
@@ -173,23 +173,23 @@ discard block |
||
173 | 173 | * - description |
174 | 174 | * - devices - an array of device names and their statuses (for a given profile) |
175 | 175 | */ |
176 | - public function profileAttributes($prof_id) { |
|
176 | + public function profileAttributes($prof_id) { |
|
177 | 177 | $this->set_locale("devices"); |
178 | - $profile = new Profile($prof_id); |
|
179 | - $attr = $profile->getCollapsedAttributes(); |
|
180 | - $a = []; |
|
181 | - if(isset($attr['support:email'])) |
|
182 | - $a['local_email'] = $attr['support:email'][0]; |
|
183 | - if(isset($attr['support:phone'])) |
|
184 | - $a['local_phone'] = $attr['support:phone'][0]; |
|
185 | - if(isset($attr['support:url'])) |
|
186 | - $a['local_url'] = $attr['support:url'][0]; |
|
187 | - if(isset($attr['profile:description'])) |
|
188 | - $a['description'] = $attr['profile:description'][0]; |
|
189 | - $a['devices'] = $profile->listDevices(); |
|
190 | - $this->set_locale("web_user"); |
|
191 | - return($a); |
|
192 | - } |
|
178 | + $profile = new Profile($prof_id); |
|
179 | + $attr = $profile->getCollapsedAttributes(); |
|
180 | + $a = []; |
|
181 | + if(isset($attr['support:email'])) |
|
182 | + $a['local_email'] = $attr['support:email'][0]; |
|
183 | + if(isset($attr['support:phone'])) |
|
184 | + $a['local_phone'] = $attr['support:phone'][0]; |
|
185 | + if(isset($attr['support:url'])) |
|
186 | + $a['local_url'] = $attr['support:url'][0]; |
|
187 | + if(isset($attr['profile:description'])) |
|
188 | + $a['description'] = $attr['profile:description'][0]; |
|
189 | + $a['devices'] = $profile->listDevices(); |
|
190 | + $this->set_locale("web_user"); |
|
191 | + return($a); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /* |
195 | 195 | this method needs to be used with care, it could give wrong results in some |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | $file= $F['file']; |
202 | 202 | $file = substr($file,strlen(dirname(__DIR__))); |
203 | 203 | while(substr($file,0,1) == '/') |
204 | - $file = substr($file,1); |
|
204 | + $file = substr($file,1); |
|
205 | 205 | $n = count(explode('/',$file)); |
206 | 206 | $out = $_SERVER['SCRIPT_NAME']; |
207 | 207 | for ($i= 0; $i < $n; $i++) |
208 | - $out = dirname($out); |
|
208 | + $out = dirname($out); |
|
209 | 209 | if ($out == '/') |
210 | - $out = ''; |
|
210 | + $out = ''; |
|
211 | 211 | $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'; |
212 | 212 | $s .= '://'.$_SERVER['HTTP_HOST'] . $out; |
213 | 213 | return $s; |
@@ -215,29 +215,29 @@ discard block |
||
215 | 215 | |
216 | 216 | /* JSON functions */ |
217 | 217 | |
218 | - public function return_json($data,$status=1) { |
|
219 | - $return_array = []; |
|
220 | - $return_array['status'] = $status; |
|
221 | - $return_array['data'] = $data; |
|
222 | - $return_array['tou'] = "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php"; |
|
223 | - return(json_encode($return_array)); |
|
224 | - } |
|
218 | + public function return_json($data,$status=1) { |
|
219 | + $return_array = []; |
|
220 | + $return_array['status'] = $status; |
|
221 | + $return_array['data'] = $data; |
|
222 | + $return_array['tou'] = "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php"; |
|
223 | + return(json_encode($return_array)); |
|
224 | + } |
|
225 | 225 | |
226 | 226 | /** |
227 | - * Return the list of supported languages. |
|
228 | - * |
|
229 | - * |
|
230 | - */ |
|
231 | - public function JSON_listLanguages() { |
|
232 | - $return_array = []; |
|
233 | - foreach(Config::$LANGUAGES as $id => $val){ |
|
234 | - if($this->version == 1) |
|
235 | - $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
236 | - else |
|
237 | - $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
238 | - } |
|
239 | - echo $this->return_json($return_array); |
|
240 | - } |
|
227 | + * Return the list of supported languages. |
|
228 | + * |
|
229 | + * |
|
230 | + */ |
|
231 | + public function JSON_listLanguages() { |
|
232 | + $return_array = []; |
|
233 | + foreach(Config::$LANGUAGES as $id => $val){ |
|
234 | + if($this->version == 1) |
|
235 | + $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
236 | + else |
|
237 | + $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
238 | + } |
|
239 | + echo $this->return_json($return_array); |
|
240 | + } |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * Return the list of countiers with configured IdPs |
@@ -245,17 +245,17 @@ discard block |
||
245 | 245 | * @return string JSON encoded data |
246 | 246 | */ |
247 | 247 | |
248 | - public function JSON_listCountries() { |
|
249 | - $FED = $this->printCountryList(1); |
|
250 | - $return_array = []; |
|
251 | - foreach ($FED as $id => $val) { |
|
252 | - if($this->version == 1) |
|
253 | - $return_array[] = ['id'=>$id,'display'=>$val]; |
|
254 | - else |
|
255 | - $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
256 | - } |
|
257 | - echo $this->return_json($return_array); |
|
258 | - } |
|
248 | + public function JSON_listCountries() { |
|
249 | + $FED = $this->printCountryList(1); |
|
250 | + $return_array = []; |
|
251 | + foreach ($FED as $id => $val) { |
|
252 | + if($this->version == 1) |
|
253 | + $return_array[] = ['id'=>$id,'display'=>$val]; |
|
254 | + else |
|
255 | + $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
256 | + } |
|
257 | + echo $this->return_json($return_array); |
|
258 | + } |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Return the list of IdPs in a given country |
@@ -264,17 +264,17 @@ discard block |
||
264 | 264 | * @return string JSON encoded data |
265 | 265 | */ |
266 | 266 | |
267 | - public function JSON_listIdentityProviders($country) { |
|
268 | - $idps = Federation::listAllIdentityProviders(1,$country); |
|
269 | - $return_array = []; |
|
270 | - foreach ($idps as $idp) { |
|
267 | + public function JSON_listIdentityProviders($country) { |
|
268 | + $idps = Federation::listAllIdentityProviders(1,$country); |
|
269 | + $return_array = []; |
|
270 | + foreach ($idps as $idp) { |
|
271 | 271 | if($this->version == 1) |
272 | - $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
272 | + $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
273 | 273 | else |
274 | - $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
275 | - } |
|
276 | - echo $this->return_json($return_array); |
|
277 | - } |
|
274 | + $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
275 | + } |
|
276 | + echo $this->return_json($return_array); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * return the list of all active IdPs |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | * @return string JSON encoded data |
284 | 284 | */ |
285 | 285 | |
286 | - public function JSON_listIdentityProvidersForDisco() { |
|
287 | - $idps = Federation::listAllIdentityProviders(1); |
|
288 | - $return_array = []; |
|
289 | - foreach ($idps as $idp) { |
|
286 | + public function JSON_listIdentityProvidersForDisco() { |
|
287 | + $idps = Federation::listAllIdentityProviders(1); |
|
288 | + $return_array = []; |
|
289 | + foreach ($idps as $idp) { |
|
290 | 290 | if($this->version == 1) |
291 | - $idp['id'] = $idp['entityID']; |
|
292 | - else |
|
293 | - $idp['idp'] = $idp['entityID']; |
|
291 | + $idp['id'] = $idp['entityID']; |
|
292 | + else |
|
293 | + $idp['idp'] = $idp['entityID']; |
|
294 | 294 | $return_array[] = $idp; |
295 | - } |
|
296 | - echo json_encode($return_array); |
|
297 | - } |
|
295 | + } |
|
296 | + echo json_encode($return_array); |
|
297 | + } |
|
298 | 298 | |
299 | 299 | |
300 | 300 | |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | */ |
307 | 307 | |
308 | 308 | |
309 | - public function JSON_orderIdentityProviders($country,$L=NULL) { |
|
310 | - $idps = $this->orderIdentityProviders($country,$L); |
|
311 | - $return_array = []; |
|
312 | - foreach ($idps as $idp) { |
|
309 | + public function JSON_orderIdentityProviders($country,$L=NULL) { |
|
310 | + $idps = $this->orderIdentityProviders($country,$L); |
|
311 | + $return_array = []; |
|
312 | + foreach ($idps as $idp) { |
|
313 | 313 | if($this->version == 1) |
314 | - $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
314 | + $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
315 | 315 | else |
316 | - $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
317 | - } |
|
318 | - echo $this->return_json($return_array); |
|
319 | - } |
|
316 | + $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
317 | + } |
|
318 | + echo $this->return_json($return_array); |
|
319 | + } |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Produce a list of profiles available for a given IdP |
@@ -324,31 +324,31 @@ discard block |
||
324 | 324 | * @param int $idp_id the IdP identifier |
325 | 325 | * @return string JSON encoded data |
326 | 326 | */ |
327 | - public function JSON_listProfiles($idp_id,$sort = 0) { |
|
328 | - $this->set_locale("web_user"); |
|
329 | - $return_array = []; |
|
330 | - try { |
|
331 | - $idp = new IdP($idp_id); |
|
332 | - } |
|
333 | - catch (Exception $fail) { |
|
327 | + public function JSON_listProfiles($idp_id,$sort = 0) { |
|
328 | + $this->set_locale("web_user"); |
|
329 | + $return_array = []; |
|
330 | + try { |
|
331 | + $idp = new IdP($idp_id); |
|
332 | + } |
|
333 | + catch (Exception $fail) { |
|
334 | 334 | echo $this->return_json($return_array,0); |
335 | 335 | return; |
336 | - } |
|
337 | - $l = 0; |
|
338 | - $logo = $idp->getAttributes('general:logo_file'); |
|
339 | - if($logo) |
|
340 | - $l = 1; |
|
341 | - $profiles = $idp->listProfiles(1); |
|
342 | - if($sort == 1) |
|
336 | + } |
|
337 | + $l = 0; |
|
338 | + $logo = $idp->getAttributes('general:logo_file'); |
|
339 | + if($logo) |
|
340 | + $l = 1; |
|
341 | + $profiles = $idp->listProfiles(1); |
|
342 | + if($sort == 1) |
|
343 | 343 | usort($profiles,"profile_sort"); |
344 | - foreach ($profiles as $P) { |
|
345 | - if($this->version == 1) |
|
346 | - $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
347 | - else |
|
348 | - $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
349 | - } |
|
350 | - echo $this->return_json($return_array); |
|
351 | - } |
|
344 | + foreach ($profiles as $P) { |
|
345 | + if($this->version == 1) |
|
346 | + $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
347 | + else |
|
348 | + $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
349 | + } |
|
350 | + echo $this->return_json($return_array); |
|
351 | + } |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Return the list of devices available for the given profile |
@@ -356,34 +356,34 @@ discard block |
||
356 | 356 | * @param int $profile_id the Profile identifier |
357 | 357 | * @return string JSON encoded data |
358 | 358 | */ |
359 | - public function JSON_listDevices($profile_id) { |
|
360 | - $this->set_locale("web_user"); |
|
361 | - $return_array = []; |
|
362 | - $a = $this->profileAttributes($profile_id); |
|
363 | - $thedevices = $a['devices']; |
|
364 | - if(!isset($profile_redirect) || ! $profile_redirect) { |
|
365 | - $profile_redirect = 0; |
|
366 | - foreach ($thedevices as $D) { |
|
367 | - if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
368 | - continue; |
|
369 | - $disp = $D['display']; |
|
370 | - if($this->version == 1) { |
|
371 | - if($D['id'] === '0') { |
|
372 | - $profile_redirect = 1; |
|
373 | - $disp = $c; |
|
374 | - } |
|
359 | + public function JSON_listDevices($profile_id) { |
|
360 | + $this->set_locale("web_user"); |
|
361 | + $return_array = []; |
|
362 | + $a = $this->profileAttributes($profile_id); |
|
363 | + $thedevices = $a['devices']; |
|
364 | + if(!isset($profile_redirect) || ! $profile_redirect) { |
|
365 | + $profile_redirect = 0; |
|
366 | + foreach ($thedevices as $D) { |
|
367 | + if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
368 | + continue; |
|
369 | + $disp = $D['display']; |
|
370 | + if($this->version == 1) { |
|
371 | + if($D['id'] === '0') { |
|
372 | + $profile_redirect = 1; |
|
373 | + $disp = $c; |
|
374 | + } |
|
375 | 375 | $return_array[] = ['id'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']]; |
376 | - } else { |
|
377 | - if($D['device'] === '0') { |
|
378 | - $profile_redirect = 1; |
|
379 | - $disp = $c; |
|
380 | - } |
|
376 | + } else { |
|
377 | + if($D['device'] === '0') { |
|
378 | + $profile_redirect = 1; |
|
379 | + $disp = $c; |
|
380 | + } |
|
381 | 381 | $return_array[] = ['device'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']]; |
382 | - } |
|
383 | - } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | - } |
|
386 | - echo $this->return_json($return_array); |
|
385 | + } |
|
386 | + echo $this->return_json($return_array); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param int $prof_id profile identifier |
394 | 394 | * @return string JSON encoded data |
395 | 395 | */ |
396 | - public function JSON_generateInstaller($device,$prof_id) { |
|
396 | + public function JSON_generateInstaller($device,$prof_id) { |
|
397 | 397 | debug(4,"JSON::generateInstaller arguments: $device,$prof_id\n"); |
398 | 398 | $o = $this->generateInstaller($device,$prof_id); |
399 | 399 | debug(4,"output from GUI::generateInstaller:"); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | debug(4,json_encode($o)); |
402 | 402 | // header('Content-type: application/json; utf-8'); |
403 | 403 | echo $this->return_json($o); |
404 | - } |
|
404 | + } |
|
405 | 405 | |
406 | 406 | /** |
407 | 407 | * Generate and send the installer |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | * @return binary installerFile |
412 | 412 | */ |
413 | 413 | |
414 | - public function downloadInstaller($device,$prof_id,$generated_for='user') { |
|
414 | + public function downloadInstaller($device,$prof_id,$generated_for='user') { |
|
415 | 415 | debug(4,"downloadInstaller arguments: $device,$prof_id,$generated_for\n"); |
416 | 416 | $o = $this->generateInstaller($device,$prof_id); |
417 | 417 | debug(4,"output from GUI::generateInstaller:"); |
418 | 418 | debug(4,$o); |
419 | 419 | if(! $o['link']) { |
420 | - header("HTTP/1.0 404 Not Found"); |
|
421 | - return; |
|
420 | + header("HTTP/1.0 404 Not Found"); |
|
421 | + return; |
|
422 | 422 | } |
423 | 423 | $profile = new Profile($prof_id); |
424 | 424 | $profile->incrementDownloadStats($device, $generated_for); |
@@ -431,242 +431,242 @@ discard block |
||
431 | 431 | ob_clean(); |
432 | 432 | flush(); |
433 | 433 | readfile($file); |
434 | - } |
|
434 | + } |
|
435 | 435 | /** |
436 | - * Get and prepare logo file |
|
437 | - * |
|
438 | - * When called for DiscoJuice, first check if file cache exists |
|
439 | - * If not then generate the file and save it in the cache |
|
440 | - * @param int $idp_id IdP identifier |
|
441 | - * @param int $disco flag turning on image generation for DiscoJuice |
|
442 | - * @param int $width, $height maximum width and height of the generated image |
|
443 | - * if one of these is 0 then it is treated as no upper bound |
|
444 | - * |
|
445 | - */ |
|
436 | + * Get and prepare logo file |
|
437 | + * |
|
438 | + * When called for DiscoJuice, first check if file cache exists |
|
439 | + * If not then generate the file and save it in the cache |
|
440 | + * @param int $idp_id IdP identifier |
|
441 | + * @param int $disco flag turning on image generation for DiscoJuice |
|
442 | + * @param int $width, $height maximum width and height of the generated image |
|
443 | + * if one of these is 0 then it is treated as no upper bound |
|
444 | + * |
|
445 | + */ |
|
446 | + |
|
447 | + public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) { |
|
448 | + $ExpStr = ''; |
|
449 | + $resize = 0; |
|
450 | + if(($width || $height) && is_numeric($width) && is_numeric($height)) { |
|
451 | + $resize = 1; |
|
452 | + if($height == 0) |
|
453 | + $height = 10000; |
|
454 | + if($width == 0) |
|
455 | + $width = 10000; |
|
456 | + $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
457 | + } elseif($disco == 1) { |
|
458 | + $width = 120; |
|
459 | + $height = 40; |
|
460 | + $resize = 1; |
|
461 | + $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
462 | + } |
|
446 | 463 | |
447 | - public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) { |
|
448 | - $ExpStr = ''; |
|
449 | - $resize = 0; |
|
450 | - if(($width || $height) && is_numeric($width) && is_numeric($height)) { |
|
451 | - $resize = 1; |
|
452 | - if($height == 0) |
|
453 | - $height = 10000; |
|
454 | - if($width == 0) |
|
455 | - $width = 10000; |
|
456 | - $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
457 | - } elseif($disco == 1) { |
|
458 | - $width = 120; |
|
459 | - $height = 40; |
|
460 | - $resize = 1; |
|
461 | - $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
462 | - } |
|
463 | - |
|
464 | - if($resize && is_file($logo_file)){ |
|
465 | - debug(4,"Using cached logo $logo_file for: $idp_id\n"); |
|
466 | - $blob = file_get_contents($logo_file); |
|
467 | - $filetype = 'image/png'; |
|
468 | - } |
|
469 | - else { |
|
470 | - $idp = new IdP($idp_id); |
|
471 | - $at = $idp->getAttributes('general:logo_file'); |
|
472 | - $blob = $at[0]['value']; |
|
473 | - $info = new finfo(); |
|
474 | - $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE); |
|
475 | - $offset = 60 * 60 * 24 * 30; |
|
476 | - $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT"; |
|
477 | - if($resize) { |
|
478 | - $filetype = 'image/png'; |
|
479 | - $image = new Imagick(); |
|
480 | - $image->readImageBlob($blob); |
|
481 | - if( $image->setImageFormat('PNG')) { |
|
482 | - $image->thumbnailImage($width,$height,1); |
|
483 | - $blob = $image->getImageBlob(); |
|
484 | - debug(4,"Writing cached logo $logo_file for: $idp_id\n"); |
|
485 | - file_put_contents($logo_file,$blob); |
|
486 | - } |
|
487 | - else |
|
488 | - $blob = "XXXXXX"; |
|
489 | - } |
|
490 | - } |
|
491 | - header( "Content-type: ".$filetype ); |
|
492 | - header( "Cache-Control:max-age=36000, must-revalidate" ); |
|
493 | - header( $ExpStr ); |
|
494 | - echo $blob; |
|
495 | - } |
|
496 | - |
|
497 | - public function locateUser() { |
|
498 | - $host = $_SERVER['REMOTE_ADDR']; |
|
499 | - $record = geoip_record_by_name($host); |
|
500 | - if($record) { |
|
501 | - $result = ['status' => 'ok']; |
|
502 | - $result['country'] = $record['country_code']; |
|
464 | + if($resize && is_file($logo_file)){ |
|
465 | + debug(4,"Using cached logo $logo_file for: $idp_id\n"); |
|
466 | + $blob = file_get_contents($logo_file); |
|
467 | + $filetype = 'image/png'; |
|
468 | + } |
|
469 | + else { |
|
470 | + $idp = new IdP($idp_id); |
|
471 | + $at = $idp->getAttributes('general:logo_file'); |
|
472 | + $blob = $at[0]['value']; |
|
473 | + $info = new finfo(); |
|
474 | + $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE); |
|
475 | + $offset = 60 * 60 * 24 * 30; |
|
476 | + $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT"; |
|
477 | + if($resize) { |
|
478 | + $filetype = 'image/png'; |
|
479 | + $image = new Imagick(); |
|
480 | + $image->readImageBlob($blob); |
|
481 | + if( $image->setImageFormat('PNG')) { |
|
482 | + $image->thumbnailImage($width,$height,1); |
|
483 | + $blob = $image->getImageBlob(); |
|
484 | + debug(4,"Writing cached logo $logo_file for: $idp_id\n"); |
|
485 | + file_put_contents($logo_file,$blob); |
|
486 | + } |
|
487 | + else |
|
488 | + $blob = "XXXXXX"; |
|
489 | + } |
|
490 | + } |
|
491 | + header( "Content-type: ".$filetype ); |
|
492 | + header( "Cache-Control:max-age=36000, must-revalidate" ); |
|
493 | + header( $ExpStr ); |
|
494 | + echo $blob; |
|
495 | + } |
|
496 | + |
|
497 | + public function locateUser() { |
|
498 | + $host = $_SERVER['REMOTE_ADDR']; |
|
499 | + $record = geoip_record_by_name($host); |
|
500 | + if($record) { |
|
501 | + $result = ['status' => 'ok']; |
|
502 | + $result['country'] = $record['country_code']; |
|
503 | 503 | // the two lines below are a dirty hack to take of the error in naming the UK federation |
504 | - if($result['country'] == 'GB') |
|
505 | - $result['country'] = 'UK'; |
|
506 | - $result['region'] = $record['region']; |
|
507 | - $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']]; |
|
508 | - } else { |
|
509 | - $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
510 | - } |
|
511 | - return($result); |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - public function locateUser2() { |
|
516 | - require_once Config::$GEOIP['geoip2-path-to-autoloader']; |
|
517 | - $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']); |
|
518 | - $host = $_SERVER['REMOTE_ADDR']; |
|
519 | - try { |
|
520 | - $record = $reader->city($host); |
|
521 | - } catch (Exception $e) { |
|
522 | - $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
523 | - return($result); |
|
524 | - } |
|
525 | - $result = ['status' => 'ok']; |
|
526 | - $result['country'] = $record->country->isoCode; |
|
504 | + if($result['country'] == 'GB') |
|
505 | + $result['country'] = 'UK'; |
|
506 | + $result['region'] = $record['region']; |
|
507 | + $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']]; |
|
508 | + } else { |
|
509 | + $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
510 | + } |
|
511 | + return($result); |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + public function locateUser2() { |
|
516 | + require_once Config::$GEOIP['geoip2-path-to-autoloader']; |
|
517 | + $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']); |
|
518 | + $host = $_SERVER['REMOTE_ADDR']; |
|
519 | + try { |
|
520 | + $record = $reader->city($host); |
|
521 | + } catch (Exception $e) { |
|
522 | + $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
523 | + return($result); |
|
524 | + } |
|
525 | + $result = ['status' => 'ok']; |
|
526 | + $result['country'] = $record->country->isoCode; |
|
527 | 527 | // the two lines below are a dirty hack to take of the error in naming the UK federation |
528 | - if($result['country'] == 'GB') |
|
529 | - $result['country'] = 'UK'; |
|
530 | - $result['region'] = $record->continent->name; |
|
528 | + if($result['country'] == 'GB') |
|
529 | + $result['country'] = 'UK'; |
|
530 | + $result['region'] = $record->continent->name; |
|
531 | 531 | |
532 | - $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude]; |
|
533 | - return($result); |
|
534 | - } |
|
532 | + $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude]; |
|
533 | + return($result); |
|
534 | + } |
|
535 | 535 | |
536 | 536 | public function JSON_locateUser() { |
537 | 537 | header('Content-type: application/json; utf-8'); |
538 | 538 | |
539 | 539 | if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0) |
540 | - echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
|
540 | + echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
|
541 | 541 | if(Config::$GEOIP['version'] == 1) |
542 | - echo json_encode($this->locateUser()); |
|
542 | + echo json_encode($this->locateUser()); |
|
543 | 543 | if(Config::$GEOIP['version'] == 2) |
544 | - echo json_encode($this->locateUser2()); |
|
544 | + echo json_encode($this->locateUser2()); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
548 | 548 | * Produce support data prepared within {@link GUI::profileAttributes()} |
549 | 549 | * @return string JSON encoded data |
550 | 550 | */ |
551 | - public function JSON_profileAttributes($prof_id) { |
|
551 | + public function JSON_profileAttributes($prof_id) { |
|
552 | 552 | // header('Content-type: application/json; utf-8'); |
553 | 553 | echo $this->return_json($this->profileAttributes($prof_id)); |
554 | - } |
|
554 | + } |
|
555 | 555 | |
556 | 556 | /** |
557 | - * Calculate the distence in km between two points given their |
|
558 | - * geo coordinates. |
|
559 | - * @param array $P1 - first point as an 'lat', 'lon' array |
|
560 | - * @param array $P2 - second point as an 'lat', 'lon' array |
|
561 | - * @return float distance in km |
|
562 | - */ |
|
557 | + * Calculate the distence in km between two points given their |
|
558 | + * geo coordinates. |
|
559 | + * @param array $P1 - first point as an 'lat', 'lon' array |
|
560 | + * @param array $P2 - second point as an 'lat', 'lon' array |
|
561 | + * @return float distance in km |
|
562 | + */ |
|
563 | 563 | private function geoDistance($P1,$P2) { |
564 | 564 | |
565 | - $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) + |
|
565 | + $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) + |
|
566 | 566 | cos(deg2rad($P1['lat'])) * cos(deg2rad($P2['lat'])) * cos(deg2rad($P1['lon'] - $P2['lon'])); |
567 | - $dist = rad2deg(acos($dist)) * 60 * 1.1852 ; |
|
568 | - return(round($dist)); |
|
567 | + $dist = rad2deg(acos($dist)) * 60 * 1.1852 ; |
|
568 | + return(round($dist)); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | - * Order active identity providers according to their distance and name |
|
573 | - * @param array $L - current location |
|
574 | - * @return array $IdPs - list of arrays ('id', 'name'); |
|
575 | - */ |
|
572 | + * Order active identity providers according to their distance and name |
|
573 | + * @param array $L - current location |
|
574 | + * @return array $IdPs - list of arrays ('id', 'name'); |
|
575 | + */ |
|
576 | 576 | |
577 | 577 | public function orderIdentityProviders($country,$L=NULL) { |
578 | - $idps = Federation::listAllIdentityProviders(1,$country); |
|
579 | - |
|
580 | - if(is_null($L)) { |
|
581 | - $U = $this->locateUser(); |
|
582 | - if($U['status'] == 'ok') { |
|
583 | - $L = $U['geo']; |
|
584 | - } else { |
|
585 | - $L = ['lat'=>"90",'lon'=>"0"]; |
|
586 | - } |
|
587 | - } |
|
588 | - $T=[]; |
|
589 | - $R=[]; |
|
590 | - foreach ($idps as $idp) { |
|
578 | + $idps = Federation::listAllIdentityProviders(1,$country); |
|
579 | + |
|
580 | + if(is_null($L)) { |
|
581 | + $U = $this->locateUser(); |
|
582 | + if($U['status'] == 'ok') { |
|
583 | + $L = $U['geo']; |
|
584 | + } else { |
|
585 | + $L = ['lat'=>"90",'lon'=>"0"]; |
|
586 | + } |
|
587 | + } |
|
588 | + $T=[]; |
|
589 | + $R=[]; |
|
590 | + foreach ($idps as $idp) { |
|
591 | 591 | $T[$idp['entityID']] = $idp['title']; |
592 | 592 | $dist = 10000; |
593 | 593 | if(isset($idp['geo'])) { |
594 | - $G=$idp['geo']; |
|
595 | - if(isset($G['lon'])) { |
|
596 | - $d1 = $this->geoDistance($L,$G); |
|
597 | - if( $d1 < $dist) |
|
594 | + $G=$idp['geo']; |
|
595 | + if(isset($G['lon'])) { |
|
596 | + $d1 = $this->geoDistance($L,$G); |
|
597 | + if( $d1 < $dist) |
|
598 | 598 | $dist = $d1; |
599 | - } else { |
|
599 | + } else { |
|
600 | 600 | foreach ($G as $g) { |
601 | - $d1 = $this->geoDistance($L,$g); |
|
602 | - if( $d1 < $dist) |
|
601 | + $d1 = $this->geoDistance($L,$g); |
|
602 | + if( $d1 < $dist) |
|
603 | 603 | $dist = $d1; |
604 | 604 | } |
605 | - } |
|
605 | + } |
|
606 | 606 | } |
607 | - if($dist > 100) |
|
608 | - $dist=10000; |
|
609 | - $d = sprintf("%06d",$dist); |
|
610 | - $R[$idp['entityID']] = $d." ".$idp['title']; |
|
611 | - } |
|
612 | - asort($R); |
|
613 | - foreach (array_keys($R) as $r) { |
|
614 | - if($this->version == 1) |
|
615 | - $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
|
616 | - else |
|
617 | - $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
|
618 | - } |
|
619 | - return($outarray); |
|
607 | + if($dist > 100) |
|
608 | + $dist=10000; |
|
609 | + $d = sprintf("%06d",$dist); |
|
610 | + $R[$idp['entityID']] = $d." ".$idp['title']; |
|
611 | + } |
|
612 | + asort($R); |
|
613 | + foreach (array_keys($R) as $r) { |
|
614 | + if($this->version == 1) |
|
615 | + $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
|
616 | + else |
|
617 | + $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
|
618 | + } |
|
619 | + return($outarray); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
623 | - * Detect the best device driver form the browser |
|
624 | - * |
|
625 | - * Detects the operating system and returns its id |
|
626 | - * display name and group membership (as in devices.php) |
|
627 | - * @return array indexed by 'id', 'display', 'group' |
|
628 | - */ |
|
623 | + * Detect the best device driver form the browser |
|
624 | + * |
|
625 | + * Detects the operating system and returns its id |
|
626 | + * display name and group membership (as in devices.php) |
|
627 | + * @return array indexed by 'id', 'display', 'group' |
|
628 | + */ |
|
629 | 629 | |
630 | 630 | public function detectOS() { |
631 | - $Dev = Devices::listDevices(); |
|
632 | - if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
|
633 | - $dev_id = $_REQUEST['device']; |
|
634 | - $device = $Dev[$dev_id]; |
|
635 | - if($this->version == 1) |
|
636 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
637 | - else |
|
638 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
639 | - } |
|
640 | - $browser = $_SERVER['HTTP_USER_AGENT']; |
|
641 | - debug(4,"HTTP_USER_AGENT=$browser\n"); |
|
642 | - foreach ($Dev as $dev_id => $device) { |
|
643 | - if(!isset($device['match'])) |
|
631 | + $Dev = Devices::listDevices(); |
|
632 | + if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
|
633 | + $dev_id = $_REQUEST['device']; |
|
634 | + $device = $Dev[$dev_id]; |
|
635 | + if($this->version == 1) |
|
636 | + return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
637 | + else |
|
638 | + return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
639 | + } |
|
640 | + $browser = $_SERVER['HTTP_USER_AGENT']; |
|
641 | + debug(4,"HTTP_USER_AGENT=$browser\n"); |
|
642 | + foreach ($Dev as $dev_id => $device) { |
|
643 | + if(!isset($device['match'])) |
|
644 | 644 | continue; |
645 | - if(preg_match('/'.$device['match'].'/',$browser)) { |
|
646 | - if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) { |
|
647 | - debug(4,"Browser_id: $dev_id\n"); |
|
648 | - if($this->version == 1) |
|
649 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
650 | - else |
|
651 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
652 | - } |
|
653 | - else { |
|
654 | - debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
655 | - return(false); |
|
656 | - } |
|
657 | - } |
|
658 | - } |
|
659 | - debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
660 | - return(false); |
|
645 | + if(preg_match('/'.$device['match'].'/',$browser)) { |
|
646 | + if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) { |
|
647 | + debug(4,"Browser_id: $dev_id\n"); |
|
648 | + if($this->version == 1) |
|
649 | + return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
650 | + else |
|
651 | + return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
652 | + } |
|
653 | + else { |
|
654 | + debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
655 | + return(false); |
|
656 | + } |
|
657 | + } |
|
658 | + } |
|
659 | + debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
660 | + return(false); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | public function JSON_detectOS() { |
664 | - $return_array=$this->detectOS(); |
|
665 | - if($return_array) |
|
664 | + $return_array=$this->detectOS(); |
|
665 | + if($return_array) |
|
666 | 666 | $status = 1; |
667 | - else |
|
667 | + else |
|
668 | 668 | $status = 0; |
669 | - echo $this->return_json($return_array,$status); |
|
669 | + echo $this->return_json($return_array,$status); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -676,5 +676,5 @@ discard block |
||
676 | 676 | |
677 | 677 | } |
678 | 678 | function profile_sort($P1,$P2) { |
679 | - return strcasecmp($P1->name, $P2->name); |
|
679 | + return strcasecmp($P1->name, $P2->name); |
|
680 | 680 | } |
681 | 681 | \ No newline at end of file |
@@ -78,9 +78,6 @@ |
||
78 | 78 | * It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods |
79 | 79 | * available for the particular device. |
80 | 80 | * {@source} |
81 | - * @param string $device a pointer to a device module, which must |
|
82 | - * be an index of one of the devices defined in the {@link Devices} |
|
83 | - * array in {@link devices.php}. |
|
84 | 81 | * @final not to be redefined |
85 | 82 | */ |
86 | 83 | final public function __construct() { |
@@ -308,6 +308,9 @@ |
||
308 | 308 | |
309 | 309 | /** |
310 | 310 | * produce PEAP, TLS and TTLS configuration files for Windows 8 |
311 | + * @param string $auth |
|
312 | + * @param string $encryption |
|
313 | + * @param integer $i |
|
311 | 314 | */ |
312 | 315 | private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
313 | 316 | $profile_file_contents = '<?xml version="1.0"?> |
@@ -26,74 +26,74 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class Device_W8 extends WindowsCommon { |
28 | 28 | final public function __construct() { |
29 | - $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD]; |
|
29 | + $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD]; |
|
30 | 30 | # $this->supportedEapMethods = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$PWD); |
31 | - debug(4,"This device supports the following EAP methods: "); |
|
32 | - debug(4,$this->supportedEapMethods); |
|
33 | - $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
|
31 | + debug(4,"This device supports the following EAP methods: "); |
|
32 | + debug(4,$this->supportedEapMethods); |
|
33 | + $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function writeInstaller() { |
|
37 | - $dom = textdomain(NULL); |
|
38 | - textdomain("devices"); |
|
39 | - // create certificate files and save their names in $CA_files arrary |
|
40 | - $CA_files = $this->saveCertificateFiles('der'); |
|
36 | + public function writeInstaller() { |
|
37 | + $dom = textdomain(NULL); |
|
38 | + textdomain("devices"); |
|
39 | + // create certificate files and save their names in $CA_files arrary |
|
40 | + $CA_files = $this->saveCertificateFiles('der'); |
|
41 | 41 | |
42 | - $SSIDs = $this->attributes['internal:SSID']; |
|
43 | - $delSSIDs = $this->attributes['internal:remove_SSID']; |
|
44 | - $this->prepareInstallerLang(); |
|
45 | - $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
|
42 | + $SSIDs = $this->attributes['internal:SSID']; |
|
43 | + $delSSIDs = $this->attributes['internal:remove_SSID']; |
|
44 | + $this->prepareInstallerLang(); |
|
45 | + $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
|
46 | 46 | // create a list of profiles to be deleted after installation |
47 | - $delProfiles = []; |
|
48 | - foreach ($delSSIDs as $ssid => $cipher) { |
|
49 | - if($cipher == 'DEL') |
|
50 | - $delProfiles[] = $ssid; |
|
51 | - if($cipher == 'TKIP') |
|
52 | - $delProfiles[] = $ssid.' (TKIP)'; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) { |
|
57 | - $WindowsProfile = []; |
|
58 | - $eap_config = $this->prepareEapConfig($this->attributes); |
|
59 | - $i = 0; |
|
60 | - foreach ($SSIDs as $ssid => $cipher) { |
|
61 | - if($cipher == 'TKIP') { |
|
62 | - $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i); |
|
63 | - $i++; |
|
64 | - } |
|
65 | - $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i); |
|
66 | - $i++; |
|
67 | - } |
|
68 | - if($set_wired) { |
|
69 | - $this->writeLANprofile($eap_config); |
|
70 | - } |
|
71 | - } else { |
|
72 | - error(" this EAP type is not handled yet"); |
|
73 | - return; |
|
74 | - } |
|
47 | + $delProfiles = []; |
|
48 | + foreach ($delSSIDs as $ssid => $cipher) { |
|
49 | + if($cipher == 'DEL') |
|
50 | + $delProfiles[] = $ssid; |
|
51 | + if($cipher == 'TKIP') |
|
52 | + $delProfiles[] = $ssid.' (TKIP)'; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) { |
|
57 | + $WindowsProfile = []; |
|
58 | + $eap_config = $this->prepareEapConfig($this->attributes); |
|
59 | + $i = 0; |
|
60 | + foreach ($SSIDs as $ssid => $cipher) { |
|
61 | + if($cipher == 'TKIP') { |
|
62 | + $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i); |
|
63 | + $i++; |
|
64 | + } |
|
65 | + $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i); |
|
66 | + $i++; |
|
67 | + } |
|
68 | + if($set_wired) { |
|
69 | + $this->writeLANprofile($eap_config); |
|
70 | + } |
|
71 | + } else { |
|
72 | + error(" this EAP type is not handled yet"); |
|
73 | + return; |
|
74 | + } |
|
75 | 75 | debug(4,"WindowsProfile"); debug(4,$WindowsProfile); |
76 | 76 | |
77 | 77 | $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired); |
78 | 78 | $this->writeAdditionalDeletes($delProfiles); |
79 | 79 | if(isset($additional_deletes) && count($additional_deletes)) |
80 | - $this->writeAdditionalDeletes($additional_deletes); |
|
80 | + $this->writeAdditionalDeletes($additional_deletes); |
|
81 | 81 | $this->copyFiles($this->selected_eap); |
82 | 82 | if(isset($this->attributes['internal:logo_file'])) |
83 | - $this->combineLogo($this->attributes['internal:logo_file']); |
|
83 | + $this->combineLogo($this->attributes['internal:logo_file']); |
|
84 | 84 | $this->writeMainNSH($this->selected_eap,$this->attributes); |
85 | 85 | $this->compileNSIS(); |
86 | 86 | $installer_path = $this->signInstaller($this->attributes); |
87 | 87 | |
88 | 88 | textdomain($dom); |
89 | 89 | return($installer_path); |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - public function writeDeviceInfo() { |
|
92 | + public function writeDeviceInfo() { |
|
93 | 93 | $ssid_ct=count($this->attributes['internal:SSID']); |
94 | - $out = "<p>"; |
|
95 | - $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']); |
|
96 | - $out .= "<p>"; |
|
94 | + $out = "<p>"; |
|
95 | + $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']); |
|
96 | + $out .= "<p>"; |
|
97 | 97 | if($ssid_ct > 1) { |
98 | 98 | if($ssid_ct > 2) { |
99 | 99 | $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
@@ -101,52 +101,52 @@ discard block |
||
101 | 101 | $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
102 | 102 | $i = 0; |
103 | 103 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
104 | - if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
105 | - if($i > 0) |
|
106 | - $out .= ", "; |
|
107 | - $i++; |
|
108 | - $out .= "<strong>$ssid</strong>"; |
|
109 | - } |
|
104 | + if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
105 | + if($i > 0) |
|
106 | + $out .= ", "; |
|
107 | + $i++; |
|
108 | + $out .= "<strong>$ssid</strong>"; |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | $out .= "<p>"; |
112 | 112 | } |
113 | 113 | |
114 | 114 | if($this->eap == EAP::$TLS) |
115 | - $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process."); |
|
115 | + $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process."); |
|
116 | 116 | else { |
117 | - $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated."); |
|
118 | - $out .= "<p>"; |
|
119 | - $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range."); |
|
117 | + $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated."); |
|
118 | + $out .= "<p>"; |
|
119 | + $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range."); |
|
120 | 120 | if($ssid_ct > 1) { |
121 | - $out .= "<p>"; |
|
122 | - $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
|
123 | - $i = 0; |
|
121 | + $out .= "<p>"; |
|
122 | + $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
|
123 | + $i = 0; |
|
124 | 124 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
125 | - if($i > 0) |
|
126 | - $out .= ", "; |
|
127 | - $i++; |
|
128 | - $out .= "<strong>$ssid</strong>"; |
|
125 | + if($i > 0) |
|
126 | + $out .= ", "; |
|
127 | + $i++; |
|
128 | + $out .= "<strong>$ssid</strong>"; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | 133 | } |
134 | 134 | return $out; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | 138 | private function prepareEapConfig($attr) { |
139 | - $eap = $this->selected_eap; |
|
140 | - $w8_ext = ''; |
|
141 | - $use_anon = $attr['internal:use_anon_outer'] [0]; |
|
142 | - if ($use_anon) { |
|
143 | - $outer_user = $attr['internal:anon_local_value'][0]; |
|
144 | - $outer_id = $outer_user.'@'.$attr['internal:realm'][0]; |
|
145 | - } |
|
139 | + $eap = $this->selected_eap; |
|
140 | + $w8_ext = ''; |
|
141 | + $use_anon = $attr['internal:use_anon_outer'] [0]; |
|
142 | + if ($use_anon) { |
|
143 | + $outer_user = $attr['internal:anon_local_value'][0]; |
|
144 | + $outer_id = $outer_user.'@'.$attr['internal:realm'][0]; |
|
145 | + } |
|
146 | 146 | // $servers = preg_quote(implode(';',$attr['eap:server_name'])); |
147 | - $servers = implode(';',$attr['eap:server_name']); |
|
147 | + $servers = implode(';',$attr['eap:server_name']); |
|
148 | 148 | |
149 | - $ca_array = $attr['internal:CAs'][0]; |
|
149 | + $ca_array = $attr['internal:CAs'][0]; |
|
150 | 150 | |
151 | 151 | |
152 | 152 | $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
163 | 163 | </EapMethod> |
164 | 164 | '; |
165 | - $profile_file_contents .= ' |
|
165 | + $profile_file_contents .= ' |
|
166 | 166 | |
167 | 167 | <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
168 | 168 | xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | if($ca_array) { |
179 | 179 | foreach ($ca_array as $CA) |
180 | 180 | if($CA['root']) |
181 | - $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
|
181 | + $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
|
182 | 182 | } |
183 | 183 | $profile_file_contents .= '</eapTls:ServerValidation> |
184 | 184 | '; |
185 | 185 | if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') |
186 | - $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
|
186 | + $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
|
187 | 187 | else |
188 | - $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
|
188 | + $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
|
189 | 189 | $profile_file_contents .= ' |
190 | 190 | </eapTls:EapType> |
191 | 191 | </baseEap:Eap> |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | '; |
194 | 194 | } elseif ( $eap == EAP::$PEAP_MSCHAP2) { |
195 | 195 | if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') |
196 | - $nea = 'true'; |
|
196 | + $nea = 'true'; |
|
197 | 197 | else |
198 | - $nea = 'false'; |
|
198 | + $nea = 'false'; |
|
199 | 199 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
200 | 200 | </EapMethod> |
201 | 201 | '; |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | <Phase2Authentication> |
261 | 261 | '; |
262 | 262 | if ( $eap == EAP::$TTLS_PAP) { |
263 | - $w8_ext .='<PAPAuthentication /> '; |
|
263 | + $w8_ext .='<PAPAuthentication /> '; |
|
264 | 264 | } |
265 | 265 | if ( $eap == EAP::$TTLS_MSCHAP2) { |
266 | - $w8_ext .='<MSCHAPv2Authentication> |
|
266 | + $w8_ext .='<MSCHAPv2Authentication> |
|
267 | 267 | <UseWinlogonCredentials>false</UseWinlogonCredentials> |
268 | 268 | </MSCHAPv2Authentication> |
269 | 269 | '; |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | <Phase1Identity> |
273 | 273 | '; |
274 | 274 | if($use_anon == 1) { |
275 | - $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> |
|
275 | + $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> |
|
276 | 276 | '; |
277 | - if(isset($outer_id) && $outer_id) |
|
277 | + if(isset($outer_id) && $outer_id) |
|
278 | 278 | $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity> |
279 | 279 | '; |
280 | - else |
|
280 | + else |
|
281 | 281 | $w8_ext .='<AnonymousIdentity/> |
282 | 282 | '; |
283 | 283 | } else { |
284 | - $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy> |
|
284 | + $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy> |
|
285 | 285 | '; |
286 | 286 | } |
287 | 287 | $w8_ext .='</Phase1Identity> |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
293 | 293 | </EapMethod> |
294 | 294 | '; |
295 | - $profile_file_contents .= '<ConfigBlob></ConfigBlob>'; |
|
295 | + $profile_file_contents .= '<ConfigBlob></ConfigBlob>'; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | $profile_file_contents_end = '</EapHostConfig></EAPConfig>'; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * produce PEAP, TLS and TTLS configuration files for Windows 8 |
311 | 311 | */ |
312 | - private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
|
312 | + private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
|
313 | 313 | $profile_file_contents = '<?xml version="1.0"?> |
314 | 314 | <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> |
315 | 315 | <name>'.$wlan_profile_name.'</name> |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | '; |
350 | 350 | |
351 | 351 | if(! is_dir('w8')) |
352 | - mkdir('w8'); |
|
352 | + mkdir('w8'); |
|
353 | 353 | $xml_f_name = "w8/wlan_prof-$i.xml"; |
354 | 354 | $xml_f = fopen($xml_f_name,'w'); |
355 | 355 | fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | '; |
377 | 377 | |
378 | 378 | if(! is_dir('w8')) |
379 | - mkdir('w8'); |
|
379 | + mkdir('w8'); |
|
380 | 380 | $xml_f_name = "w8/lan_prof.xml"; |
381 | 381 | $xml_f = fopen($xml_f_name,'w'); |
382 | 382 | fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ; |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | '; |
436 | 436 | |
437 | 437 | if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') |
438 | - $fcontents .= '!define WIRED |
|
438 | + $fcontents .= '!define WIRED |
|
439 | 439 | '; |
440 | 440 | |
441 | 441 | $f = fopen('main.nsh','w'); |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | debug(4,"writeProfilesNSH"); |
449 | 449 | debug(4,$P); |
450 | 450 | $fcontents = ''; |
451 | - foreach($P as $p) |
|
451 | + foreach($P as $p) |
|
452 | 452 | $fcontents .= "!insertmacro define_wlan_profile $p\n"; |
453 | 453 | |
454 | 454 | $f = fopen('profiles.nsh','w'); |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | $f = fopen('certs.nsh','w'); |
460 | 460 | if($ca_array) { |
461 | 461 | foreach ($ca_array as $CA) { |
462 | - $store = $CA['root'] ? "root" : "ca"; |
|
463 | - $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n"; |
|
462 | + $store = $CA['root'] ? "root" : "ca"; |
|
463 | + $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n"; |
|
464 | 464 | } |
465 | 465 | fwrite($f, $fcontents); |
466 | 466 | } |
@@ -471,26 +471,26 @@ discard block |
||
471 | 471 | |
472 | 472 | private function copyFiles ($eap) { |
473 | 473 | debug(4,"copyFiles start\n"); |
474 | - $result; |
|
475 | - $result = $this->copyFile('wlan_test.exe'); |
|
476 | - $result = $this->copyFile('check_wired.cmd'); |
|
477 | - $result = $this->copyFile('install_wired.cmd'); |
|
478 | - $result = $this->copyFile('setEAPCred.exe'); |
|
479 | - $result = $this->copyFile('cat_bg.bmp'); |
|
480 | - $result = $this->copyFile('base64.nsh'); |
|
481 | - $result = $result && $this->copyFile('cat32.ico'); |
|
482 | - $result = $result && $this->copyFile('cat_150.bmp'); |
|
483 | - $this->translateFile('common.inc','common.nsh',$this->code_page); |
|
484 | - if($eap["OUTER"] == PWD) { |
|
485 | - $this->translateFile('pwd.inc','cat.NSI',$this->code_page); |
|
486 | - $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi'); |
|
487 | - $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'); |
|
488 | - } else { |
|
489 | - $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page); |
|
490 | - $result = 1; |
|
491 | - } |
|
474 | + $result; |
|
475 | + $result = $this->copyFile('wlan_test.exe'); |
|
476 | + $result = $this->copyFile('check_wired.cmd'); |
|
477 | + $result = $this->copyFile('install_wired.cmd'); |
|
478 | + $result = $this->copyFile('setEAPCred.exe'); |
|
479 | + $result = $this->copyFile('cat_bg.bmp'); |
|
480 | + $result = $this->copyFile('base64.nsh'); |
|
481 | + $result = $result && $this->copyFile('cat32.ico'); |
|
482 | + $result = $result && $this->copyFile('cat_150.bmp'); |
|
483 | + $this->translateFile('common.inc','common.nsh',$this->code_page); |
|
484 | + if($eap["OUTER"] == PWD) { |
|
485 | + $this->translateFile('pwd.inc','cat.NSI',$this->code_page); |
|
486 | + $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi'); |
|
487 | + $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'); |
|
488 | + } else { |
|
489 | + $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page); |
|
490 | + $result = 1; |
|
491 | + } |
|
492 | 492 | debug(4,"copyFiles end\n"); |
493 | - return($result); |
|
493 | + return($result); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | } |
497 | 497 | \ No newline at end of file |