@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | */ |
78 | 78 | private function __construct() { |
79 | 79 | $this->type_db = []; |
80 | - debug(3,"--- BEGIN constructing Options instance ---\n"); |
|
80 | + debug(3, "--- BEGIN constructing Options instance ---\n"); |
|
81 | 81 | $options = DBConnection::exec(Options::$DB_TYPE, "SELECT name,type,flag from profile_option_dict ORDER BY name"); |
82 | - while($a = mysqli_fetch_object($options)) |
|
83 | - $this->type_db[$a->name] = ["type" => $a->type, "flag" => $a->flag]; |
|
84 | - $this->type_db["general:logo_url"] = ["type" => "string", "flag" => NULL]; |
|
85 | - $this->type_db["eap:ca_url"] = ["type" => "string", "flag" => NULL]; |
|
86 | - $this->type_db["internal:country"] = ["type" => "string", "flag" => NULL]; |
|
82 | + while ($a = mysqli_fetch_object($options)) |
|
83 | + $this->type_db[$a->name] = ["type" => $a->type, "flag" => $a->flag]; |
|
84 | + $this->type_db["general:logo_url"] = ["type" => "string", "flag" => NULL]; |
|
85 | + $this->type_db["eap:ca_url"] = ["type" => "string", "flag" => NULL]; |
|
86 | + $this->type_db["internal:country"] = ["type" => "string", "flag" => NULL]; |
|
87 | 87 | |
88 | - debug(3,"--- END constructing Options instance ---\n"); |
|
88 | + debug(3, "--- END constructing Options instance ---\n"); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function availableOptions($class_name = 0) { |
101 | 101 | $temporary_array = []; |
102 | - debug(3,"CLASSNAME IS $class_name\n"); |
|
102 | + debug(3, "CLASSNAME IS $class_name\n"); |
|
103 | 103 | |
104 | 104 | foreach (array_keys($this->type_db) as $name) { |
105 | 105 | if ($class_name === 0) { |
106 | 106 | $temporary_array[] = $name; |
107 | 107 | } else { |
108 | - if ( preg_match('/^'.$class_name.':/', $name) > 0 ) { |
|
108 | + if (preg_match('/^' . $class_name . ':/', $name) > 0) { |
|
109 | 109 | $temporary_array[] = $name; |
110 | 110 | } |
111 | 111 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $temparray[] = [ |
121 | 121 | "name" => $a->option_name, |
122 | 122 | "value" => $a->option_value, |
123 | - "level" => ($a->device_id == NULL && $a->method == 0 ? "Profile" : "Method" ), |
|
123 | + "level" => ($a->device_id == NULL && $a->method == 0 ? "Profile" : "Method"), |
|
124 | 124 | "row" => $a->row, |
125 | 125 | "device" => $a->device_id, |
126 | 126 | "flag" => $optinfo['flag'], |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | |
142 | 142 | $temparray[] = [ |
143 | 143 | "name" => $a->option_name, |
144 | - "value" => ( $lang == "" ? $content : serialize(['lang' => $lang, 'content' => $content])), |
|
145 | - "level" => ($a->device_id == NULL && $a->method == 0 ? "Profile" : "Method" ), |
|
144 | + "value" => ($lang == "" ? $content : serialize(['lang' => $lang, 'content' => $content])), |
|
145 | + "level" => ($a->device_id == NULL && $a->method == 0 ? "Profile" : "Method"), |
|
146 | 146 | "row" => $a->row, |
147 | 147 | "flag" => $optinfo['flag'], |
148 | 148 | "device" => $a->device_id, |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | if ($lc = mysqli_fetch_object($exec_update)->last_change) { |
356 | 356 | if ($lc < $cache->tm) { |
357 | 357 | debug(4, "Installer cached:$cache->download_path\n"); |
358 | - return(['cache'=>$cache->download_path,'mime'=>$cache->mime]); |
|
358 | + return(['cache'=>$cache->download_path, 'mime'=>$cache->mime]); |
|
359 | 359 | } |
360 | 360 | else |
361 | 361 | return NULL; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @param string device the device identifier string |
374 | 374 | * @param string path the path where the new installer can be found |
375 | 375 | */ |
376 | - public function updateCache($device, $path,$mime) { |
|
376 | + public function updateCache($device, $path, $mime) { |
|
377 | 377 | $device = DBConnection::escape_value(Profile::$DB_TYPE, $device); |
378 | 378 | $path = DBConnection::escape_value(Profile::$DB_TYPE, $path); |
379 | 379 | DBConnection::exec(Profile::$DB_TYPE, "INSERT INTO downloads (profile_id,device_id,download_path,mime,lang,installer_time) |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | $attr_value = DBConnection::escape_value(Profile::$DB_TYPE, $attr_value); |
472 | 472 | |
473 | 473 | DBConnection::exec(Profile::$DB_TYPE, "INSERT INTO profile_option (profile_id, option_name, option_value, eap_method_id" . ($device !== 0 ? ",device_id" : "") . ") |
474 | - VALUES(". $this->identifier . ", '$attr_name', '$attr_value', $eap_type" . ($device !== 0 ? ",'". DBConnection::escape_value(Profile::$DB_TYPE, $device) . "'" : "" ) . ")"); |
|
474 | + VALUES(". $this->identifier . ", '$attr_name', '$attr_value', $eap_type" . ($device !== 0 ? ",'" . DBConnection::escape_value(Profile::$DB_TYPE, $device) . "'" : "") . ")"); |
|
475 | 475 | $this->updateFreshness(); |
476 | 476 | } |
477 | 477 | |
@@ -524,20 +524,20 @@ discard block |
||
524 | 524 | * @param string $localpart the username |
525 | 525 | * |
526 | 526 | */ |
527 | - public function setRealmCheckUser($shallwe,$localpart = NULL) { |
|
527 | + public function setRealmCheckUser($shallwe, $localpart = NULL) { |
|
528 | 528 | DBConnection::exec(Profile::$DB_TYPE, |
529 | 529 | "UPDATE profile SET checkuser_outer = " . ($shallwe == true ? "1" : "0") . |
530 | - ( $localpart !== NULL ? ", checkuser_value = '$localpart' " : "") . |
|
530 | + ($localpart !== NULL ? ", checkuser_value = '$localpart' " : "") . |
|
531 | 531 | " WHERE profile_id = $this->identifier"); |
532 | 532 | } |
533 | 533 | |
534 | 534 | /** should username be verified or even prefilled? |
535 | 535 | * |
536 | 536 | */ |
537 | - public function setInputVerificationPreference($verify,$hint) { |
|
537 | + public function setInputVerificationPreference($verify, $hint) { |
|
538 | 538 | DBConnection::exec(Profile::$DB_TYPE, |
539 | 539 | "UPDATE profile SET verify_userinput_suffix = " . ($verify == true ? "1" : "0") . |
540 | - ", hint_userinput_suffix = ". ($hint == true ? "1" : "0") . |
|
540 | + ", hint_userinput_suffix = " . ($hint == true ? "1" : "0") . |
|
541 | 541 | " WHERE profile_id = $this->identifier"); |
542 | 542 | } |
543 | 543 | |
@@ -679,15 +679,15 @@ discard block |
||
679 | 679 | $dev = $factory->device; |
680 | 680 | $redirect_url = getLocalisedValue($this->getAttributes("device-specific:redirect", 0, $d), $locale); |
681 | 681 | $dev_status = AVAILABLE; |
682 | - if(isset($D['options']) && isset($D['options']['message']) && $D['options']['message']) |
|
682 | + if (isset($D['options']) && isset($D['options']['message']) && $D['options']['message']) |
|
683 | 683 | $message = $D['options']['message']; |
684 | 684 | else |
685 | 685 | $message = 0; |
686 | 686 | |
687 | 687 | if ($redirect_url === 0) { |
688 | - if(isset($D['options']) && isset($D['options']['redirect']) && $D['options']['redirect']) { |
|
688 | + if (isset($D['options']) && isset($D['options']['redirect']) && $D['options']['redirect']) { |
|
689 | 689 | $dev_status = HIDDEN; |
690 | - } else { |
|
690 | + } else { |
|
691 | 691 | $eap = $dev->getPreferredEapType($preferred_eap); |
692 | 692 | if ($eap) { |
693 | 693 | if (isset($EAP_options["eap-specific:customtext"][serialize($eap)])) |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function pem2der($pem_data) { |
36 | 36 | $begin = "CERTIFICATE-----"; |
37 | 37 | $end = "-----END"; |
38 | - $pem_data = substr($pem_data, strpos($pem_data, $begin)+strlen($begin)); |
|
38 | + $pem_data = substr($pem_data, strpos($pem_data, $begin) + strlen($begin)); |
|
39 | 39 | $pem_data = substr($pem_data, 0, strpos($pem_data, $end)); |
40 | 40 | $der = base64_decode($pem_data); |
41 | 41 | return $der; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | public function der2pem($der_data) { |
45 | 45 | $pem = chunk_split(base64_encode($der_data), 64, "\n"); |
46 | - $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n"; |
|
46 | + $pem = "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n"; |
|
47 | 47 | return $pem; |
48 | 48 | } |
49 | 49 | /** |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | * @param blob $cadata certificate in ether PEM or DER format |
64 | 64 | * @return array |
65 | 65 | */ |
66 | -public function processCertificate ($cadata) { |
|
67 | - $begin_pem = strpos($cadata,"-----BEGIN CERTIFICATE-----"); |
|
68 | - if($begin_pem !== FALSE) { |
|
69 | - $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25; |
|
70 | - if($end_c !== FALSE) { |
|
71 | - $cadata = substr($cadata,$begin_pem,$end_c - $begin_pem); |
|
66 | +public function processCertificate($cadata) { |
|
67 | + $begin_pem = strpos($cadata, "-----BEGIN CERTIFICATE-----"); |
|
68 | + if ($begin_pem !== FALSE) { |
|
69 | + $end_c = strpos($cadata, "-----END CERTIFICATE-----") + 25; |
|
70 | + if ($end_c !== FALSE) { |
|
71 | + $cadata = substr($cadata, $begin_pem, $end_c - $begin_pem); |
|
72 | 72 | } |
73 | 73 | $ca_der = X509::pem2der($cadata); |
74 | 74 | $ca_pem = X509::der2pem($ca_der); |
75 | 75 | // echo "XXXXXXXXXXXXX".$cadata."XXXXXXXXXXXXX"; exit; |
76 | 76 | } else { |
77 | 77 | $ca_der = $cadata; |
78 | - $ca_pem = X509::der2pem($cadata); |
|
78 | + $ca_pem = X509::der2pem($cadata); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | # check that the certificate is OK |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | $mydetails = openssl_x509_parse($myca); |
87 | 87 | if (!isset($mydetails['subject'])) |
88 | 88 | return FALSE; |
89 | - $md5 = openssl_digest($ca_der,'MD5'); |
|
90 | - $sha1 = openssl_digest($ca_der,'SHA1'); |
|
91 | - $out = ["uuid" => uuid(), "pem" => $ca_pem, "der" => $ca_der, "md5"=>$md5, "sha1"=>$sha1, "name"=>$mydetails['name']]; |
|
89 | + $md5 = openssl_digest($ca_der, 'MD5'); |
|
90 | + $sha1 = openssl_digest($ca_der, 'SHA1'); |
|
91 | + $out = ["uuid" => uuid(), "pem" => $ca_pem, "der" => $ca_der, "md5"=>$md5, "sha1"=>$sha1, "name"=>$mydetails['name']]; |
|
92 | 92 | $diff_a = array_diff($mydetails['issuer'], $mydetails['subject']); |
93 | - if(count($diff_a) == 0 ) { |
|
93 | + if (count($diff_a) == 0) { |
|
94 | 94 | $out['root'] = 1; |
95 | 95 | $mydetails['type'] = 'root'; |
96 | 96 | } else { |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | // if no basicContraints are set at all, this is a problem in itself |
100 | 100 | // is this a CA? or not? Treat as server, but add a warning... |
101 | 101 | if (isset($mydetails['extensions']['basicConstraints'])) { |
102 | - $out['ca'] = preg_match('/^CA:TRUE/',$mydetails['extensions']['basicConstraints']); |
|
102 | + $out['ca'] = preg_match('/^CA:TRUE/', $mydetails['extensions']['basicConstraints']); |
|
103 | 103 | $out['basicconstraints_set'] = 1; |
104 | 104 | } else { |
105 | 105 | $out['ca'] = 0; // we need to resolve this ambiguity |
106 | 106 | $out['basicconstraints_set'] = 0; |
107 | 107 | } |
108 | 108 | |
109 | - if( $out['ca'] > 0 && $out['root'] == 0 ) |
|
109 | + if ($out['ca'] > 0 && $out['root'] == 0) |
|
110 | 110 | $mydetails['type'] = 'interm_ca'; |
111 | - if( $out['ca'] == 0 && $out['root'] == 0 ) |
|
111 | + if ($out['ca'] == 0 && $out['root'] == 0) |
|
112 | 112 | $mydetails['type'] = 'server'; |
113 | 113 | $mydetails['sha1'] = $sha1; |
114 | 114 | $out['full_details'] = $mydetails; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | |
119 | 119 | |
120 | 120 | openssl_x509_export($myca, $output, FALSE); |
121 | - if(preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) |
|
121 | + if (preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) |
|
122 | 122 | $out['full_details']['signature_algorithm'] = $match[1]; |
123 | 123 | else |
124 | 124 | $out['full_details']['signature_algorithm'] = $output; |
125 | 125 | |
126 | - if((preg_match('/^\s+Public-Key:\s*\((.*) bit\)\s*$/m', $output, $match)) && is_numeric($match[1])) |
|
126 | + if ((preg_match('/^\s+Public-Key:\s*\((.*) bit\)\s*$/m', $output, $match)) && is_numeric($match[1])) |
|
127 | 127 | $out['full_details']['public_key_length'] = $match[1]; |
128 | 128 | else |
129 | 129 | $out['full_details']['public_key_length'] = $output; |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | // the trivial case: if the file is empty, there's no cert in it |
149 | 149 | if ($cadata == "") |
150 | 150 | return $returnarray; |
151 | - $start_c = strpos($cadata,"-----BEGIN CERTIFICATE-----" ); |
|
152 | - if( $start_c !== FALSE) { |
|
153 | - $cadata = substr($cadata,$start_c); |
|
154 | - $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25; |
|
155 | - $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30); |
|
156 | - while ( $next_c !== FALSE) { |
|
157 | - $returnarray[] = substr($cadata,0,$end_c); |
|
158 | - $cadata = substr($cadata,$next_c); |
|
159 | - $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25; |
|
160 | - $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30); |
|
151 | + $start_c = strpos($cadata, "-----BEGIN CERTIFICATE-----"); |
|
152 | + if ($start_c !== FALSE) { |
|
153 | + $cadata = substr($cadata, $start_c); |
|
154 | + $end_c = strpos($cadata, "-----END CERTIFICATE-----") + 25; |
|
155 | + $next_c = strpos($cadata, "-----BEGIN CERTIFICATE-----", 30); |
|
156 | + while ($next_c !== FALSE) { |
|
157 | + $returnarray[] = substr($cadata, 0, $end_c); |
|
158 | + $cadata = substr($cadata, $next_c); |
|
159 | + $end_c = strpos($cadata, "-----END CERTIFICATE-----") + 25; |
|
160 | + $next_c = strpos($cadata, "-----BEGIN CERTIFICATE-----", 30); |
|
161 | 161 | } |
162 | - $returnarray[] = substr($cadata,0,$end_c); |
|
162 | + $returnarray[] = substr($cadata, 0, $end_c); |
|
163 | 163 | } else { |
164 | 164 | // TODO: before we blindly hand it over to der2pem - is this valid DER |
165 | 165 | // data at all? |
@@ -177,65 +177,65 @@ |
||
177 | 177 | * @param $fail (default true) decides if a creation failure should cause an error |
178 | 178 | * @return - the tupple full directory path, directory name |
179 | 179 | */ |
180 | -function createTemporaryDirectory($purpose = 'installer',$fail = 1) { |
|
181 | - $name = md5(time().rand()); |
|
182 | - switch($purpose) { |
|
180 | +function createTemporaryDirectory($purpose = 'installer', $fail = 1) { |
|
181 | + $name = md5(time() . rand()); |
|
182 | + switch ($purpose) { |
|
183 | 183 | case 'installer': |
184 | - $path = CAT::$root.'/var/installer_cache'; |
|
184 | + $path = CAT::$root . '/var/installer_cache'; |
|
185 | 185 | break; |
186 | 186 | case 'logo': |
187 | - $path = CAT::$root.'/web/downloads/logos'; |
|
187 | + $path = CAT::$root . '/web/downloads/logos'; |
|
188 | 188 | break; |
189 | 189 | case 'test': |
190 | - $path = CAT::$root.'/var/tmp'; |
|
190 | + $path = CAT::$root . '/var/tmp'; |
|
191 | 191 | break; |
192 | 192 | default: |
193 | 193 | error("unable to create temporary directory for unknown purpose: $purpose\n"); |
194 | 194 | exit; |
195 | 195 | } |
196 | - $tmp_dir = $path .'/'. $name; |
|
197 | - debug(4,"temp dir: $purpose : $tmp_dir\n"); |
|
198 | - if(! mkdir($tmp_dir,0700, true)) { |
|
199 | - if($fail) { |
|
196 | + $tmp_dir = $path . '/' . $name; |
|
197 | + debug(4, "temp dir: $purpose : $tmp_dir\n"); |
|
198 | + if (!mkdir($tmp_dir, 0700, true)) { |
|
199 | + if ($fail) { |
|
200 | 200 | error("unable to create temporary directory: $tmp_dir\n"); |
201 | 201 | exit; |
202 | - } else { |
|
202 | + } else { |
|
203 | 203 | debug(4, "Directory creation failed for $tmp_dir\n"); |
204 | - return ['base'=>$path,'dir'=>'',$name=>'']; |
|
204 | + return ['base'=>$path, 'dir'=>'', $name=>'']; |
|
205 | 205 | } |
206 | 206 | } else |
207 | 207 | debug(4, "Directory created: $tmp_dir\n"); |
208 | - return ['base'=>$path,'dir'=>$tmp_dir,'name'=>$name]; |
|
208 | + return ['base'=>$path, 'dir'=>$tmp_dir, 'name'=>$name]; |
|
209 | 209 | } |
210 | 210 | |
211 | -function png_inject_consortium_logo ($inputpngstring, $symbolsize = 12, $marginsymbols = 4) { |
|
211 | +function png_inject_consortium_logo($inputpngstring, $symbolsize = 12, $marginsymbols = 4) { |
|
212 | 212 | $inputgd = imagecreatefromstring($inputpngstring); |
213 | 213 | |
214 | - debug(4,"Consortium logo is at: ".CAT::$root."/web/resources/images/consortium_logo_large.png"); |
|
215 | - $logogd = imagecreatefrompng(CAT::$root."/web/resources/images/consortium_logo_large.png"); |
|
214 | + debug(4, "Consortium logo is at: " . CAT::$root . "/web/resources/images/consortium_logo_large.png"); |
|
215 | + $logogd = imagecreatefrompng(CAT::$root . "/web/resources/images/consortium_logo_large.png"); |
|
216 | 216 | |
217 | - $sizeinput = [imagesx($inputgd),imagesy($inputgd)]; |
|
218 | - $sizelogo = [imagesx($logogd),imagesy($logogd)]; |
|
217 | + $sizeinput = [imagesx($inputgd), imagesy($inputgd)]; |
|
218 | + $sizelogo = [imagesx($logogd), imagesy($logogd)]; |
|
219 | 219 | // Q level QR-codes can sustain 25% "damage" |
220 | 220 | // make our logo cover approx 15% of area to be sure; mind that there's a $symbolsize * $marginsymbols pixel white border around each edge |
221 | - $totalpixels = ($sizeinput[0] - $symbolsize*$marginsymbols) * ($sizeinput[1] - $symbolsize*$marginsymbols); |
|
221 | + $totalpixels = ($sizeinput[0] - $symbolsize * $marginsymbols) * ($sizeinput[1] - $symbolsize * $marginsymbols); |
|
222 | 222 | $totallogopixels = ($sizelogo[0]) * ($sizelogo[1]); |
223 | 223 | $maxoccupy = $totalpixels * 0.04; |
224 | 224 | // find out how much we have to scale down logo to reach 10% QR estate |
225 | 225 | $scale = sqrt($maxoccupy / $totallogopixels); |
226 | - debug(4,"Scaling info: $scale, $maxoccupy, $totallogopixels\n"); |
|
226 | + debug(4, "Scaling info: $scale, $maxoccupy, $totallogopixels\n"); |
|
227 | 227 | // determine final pixel size - round to multitude of $symbolsize to match exact symbol boundary |
228 | 228 | $targetwidth = $symbolsize * round($sizelogo[0] * $scale / $symbolsize); |
229 | 229 | $targetheight = $symbolsize * round($sizelogo[1] * $scale / $symbolsize); |
230 | 230 | // paint white below the logo, in case it has transparencies (looks bad) |
231 | 231 | // have one symbol in each direction extra white space |
232 | - $whiteimage = imagecreate($targetwidth+2*$symbolsize, $targetheight+2*$symbolsize); |
|
233 | - imagecolorallocate($whiteimage, 255,255,255); |
|
232 | + $whiteimage = imagecreate($targetwidth + 2 * $symbolsize, $targetheight + 2 * $symbolsize); |
|
233 | + imagecolorallocate($whiteimage, 255, 255, 255); |
|
234 | 234 | // also make sure the initial placement is a multitude of 12; otherwise "two half" symbols might be affected |
235 | - $targetplacementx = $symbolsize * round(($sizeinput[0] / 2 - ($targetwidth - $symbolsize) / 2)/$symbolsize); |
|
236 | - $targetplacementy = $symbolsize * round(($sizeinput[1] / 2 - ($targetheight - $symbolsize) / 2)/$symbolsize); |
|
237 | - imagecopyresized($inputgd, $whiteimage, $targetplacementx-$symbolsize, $targetplacementy-$symbolsize, 0, 0, $targetwidth+2*$symbolsize, $targetheight+2*$symbolsize, $targetwidth+2*$symbolsize, $targetheight+2*$symbolsize); |
|
238 | - imagecopyresized($inputgd, $logogd, $targetplacementx, $targetplacementy, 0, 0, $targetwidth , $targetheight , $sizelogo[0] , $sizelogo[1]); |
|
235 | + $targetplacementx = $symbolsize * round(($sizeinput[0] / 2 - ($targetwidth - $symbolsize) / 2) / $symbolsize); |
|
236 | + $targetplacementy = $symbolsize * round(($sizeinput[1] / 2 - ($targetheight - $symbolsize) / 2) / $symbolsize); |
|
237 | + imagecopyresized($inputgd, $whiteimage, $targetplacementx - $symbolsize, $targetplacementy - $symbolsize, 0, 0, $targetwidth + 2 * $symbolsize, $targetheight + 2 * $symbolsize, $targetwidth + 2 * $symbolsize, $targetheight + 2 * $symbolsize); |
|
238 | + imagecopyresized($inputgd, $logogd, $targetplacementx, $targetplacementy, 0, 0, $targetwidth, $targetheight, $sizelogo[0], $sizelogo[1]); |
|
239 | 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); |
@@ -52,21 +52,21 @@ 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]; |
59 | - debug(4,"installer:$device:$prof_id\n"); |
|
59 | + debug(4, "installer:$device:$prof_id\n"); |
|
60 | 60 | $profile = new Profile($prof_id); |
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"); |
|
64 | + debug(4, "Attempt to download a non-production ready installer fir profile: $prof_id\n"); |
|
65 | 65 | require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']); |
66 | 66 | $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']); |
67 | - if($as->isAuthenticated()) { |
|
67 | + if ($as->isAuthenticated()) { |
|
68 | 68 | $user_object = new User($_SESSION['user']); |
69 | - if($user_object->isIdPOwner($profile->institution)) { |
|
69 | + if ($user_object->isIdPOwner($profile->institution)) { |
|
70 | 70 | debug(4, "User is the owner - allowing access\n"); |
71 | 71 | } else { |
72 | 72 | debug(2, "User not an owner of a non-production profile - access forbidden\n"); |
@@ -82,38 +82,38 @@ discard block |
||
82 | 82 | $a = []; |
83 | 83 | $a['profile'] = $prof_id; |
84 | 84 | $a['device'] = $device; |
85 | - if( (isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache'] ) || ( isset($Config['options']['no_cache']) && $Config['options']['no_cache'] )) |
|
85 | + if ((isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache']) || (isset($Config['options']['no_cache']) && $Config['options']['no_cache'])) |
|
86 | 86 | $this->i_path = FALSE; |
87 | 87 | else { |
88 | 88 | $cache = $profile->testCache($device); |
89 | 89 | $this->i_path = $cache['cache']; |
90 | 90 | } |
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"; |
|
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 | 94 | $a['mime'] = $cache['mime']; |
95 | 95 | } else { |
96 | 96 | $factory = new DeviceFactory($device); |
97 | 97 | $dev = $factory->device; |
98 | - if(isset($dev)) { |
|
98 | + if (isset($dev)) { |
|
99 | 99 | $dev->setup($profile); |
100 | 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'])) |
|
101 | + $i_path = $dev->FPATH . '/tmp/' . $installer; |
|
102 | + if ($i_path && is_file($i_path)) { |
|
103 | + if (isset($dev->options['mime'])) |
|
104 | 104 | $a['mime'] = $dev->options['mime']; |
105 | 105 | else { |
106 | 106 | $info = new finfo(); |
107 | 107 | $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE); |
108 | 108 | } |
109 | - $this->i_path = $dev->FPATH.'/'.$installer; |
|
109 | + $this->i_path = $dev->FPATH . '/' . $installer; |
|
110 | 110 | rename($i_path, $this->i_path); |
111 | - $profile->updateCache($device,$this->i_path,$a['mime']); |
|
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"; |
|
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 | 115 | } else { |
116 | - debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n"); |
|
116 | + debug(2, "Installer generation failed for: $prof_id:$device:" . CAT::get_lang() . "\n"); |
|
117 | 117 | $a['link'] = 0; |
118 | 118 | } |
119 | 119 | } |
@@ -129,31 +129,31 @@ discard block |
||
129 | 129 | $Dev = Devices::listDevices(); |
130 | 130 | $R = []; |
131 | 131 | $ct = 0; |
132 | - if($show_hidden !== 0 && $show_hidden != 1) |
|
132 | + if ($show_hidden !== 0 && $show_hidden != 1) |
|
133 | 133 | return; |
134 | 134 | foreach ($Dev as $device => $D) { |
135 | - if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
135 | + if (isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
136 | 136 | continue; |
137 | - $ct ++; |
|
138 | - if($this->version == 1) |
|
137 | + $ct++; |
|
138 | + if ($this->version == 1) |
|
139 | 139 | $D['device'] = $device; |
140 | 140 | else |
141 | 141 | $D['device'] = $device; |
142 | 142 | $group = isset($D['group']) ? $D['group'] : 'other'; |
143 | - if (! isset($R[$group])) |
|
143 | + if (!isset($R[$group])) |
|
144 | 144 | $R[$group] = []; |
145 | 145 | $R[$group][$device] = $D; |
146 | 146 | } |
147 | 147 | return $R; |
148 | 148 | } |
149 | 149 | |
150 | - public function deviceInfo($device,$prof_id) { |
|
150 | + public function deviceInfo($device, $prof_id) { |
|
151 | 151 | $this->set_locale("devices"); |
152 | 152 | $out = 0; |
153 | 153 | $profile = new Profile($prof_id); |
154 | 154 | $factory = new DeviceFactory($device); |
155 | 155 | $dev = $factory->device; |
156 | - if(isset($dev)) { |
|
156 | + if (isset($dev)) { |
|
157 | 157 | // $dev->setup($profile); |
158 | 158 | $out = $dev->writeDeviceInfo(); |
159 | 159 | } |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | $profile = new Profile($prof_id); |
179 | 179 | $attr = $profile->getCollapsedAttributes(); |
180 | 180 | $a = []; |
181 | - if(isset($attr['support:email'])) |
|
181 | + if (isset($attr['support:email'])) |
|
182 | 182 | $a['local_email'] = $attr['support:email'][0]; |
183 | - if(isset($attr['support:phone'])) |
|
183 | + if (isset($attr['support:phone'])) |
|
184 | 184 | $a['local_phone'] = $attr['support:phone'][0]; |
185 | - if(isset($attr['support:url'])) |
|
185 | + if (isset($attr['support:url'])) |
|
186 | 186 | $a['local_url'] = $attr['support:url'][0]; |
187 | - if(isset($attr['profile:description'])) |
|
187 | + if (isset($attr['profile:description'])) |
|
188 | 188 | $a['description'] = $attr['profile:description'][0]; |
189 | 189 | $a['devices'] = $profile->listDevices(); |
190 | 190 | $this->set_locale("web_user"); |
@@ -196,30 +196,30 @@ discard block |
||
196 | 196 | cicumstances |
197 | 197 | */ |
198 | 198 | private function GetRootURL() { |
199 | - $backtrace = debug_backtrace(); |
|
199 | + $backtrace = debug_backtrace(); |
|
200 | 200 | $F = array_pop($backtrace); |
201 | - $file= $F['file']; |
|
202 | - $file = substr($file,strlen(dirname(__DIR__))); |
|
203 | - while(substr($file,0,1) == '/') |
|
204 | - $file = substr($file,1); |
|
205 | - $n = count(explode('/',$file)); |
|
201 | + $file = $F['file']; |
|
202 | + $file = substr($file, strlen(dirname(__DIR__))); |
|
203 | + while (substr($file, 0, 1) == '/') |
|
204 | + $file = substr($file, 1); |
|
205 | + $n = count(explode('/', $file)); |
|
206 | 206 | $out = $_SERVER['SCRIPT_NAME']; |
207 | - for ($i= 0; $i < $n; $i++) |
|
207 | + for ($i = 0; $i < $n; $i++) |
|
208 | 208 | $out = dirname($out); |
209 | 209 | if ($out == '/') |
210 | 210 | $out = ''; |
211 | 211 | $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'; |
212 | - $s .= '://'.$_SERVER['HTTP_HOST'] . $out; |
|
212 | + $s .= '://' . $_SERVER['HTTP_HOST'] . $out; |
|
213 | 213 | return $s; |
214 | 214 | } |
215 | 215 | |
216 | 216 | /* JSON functions */ |
217 | 217 | |
218 | - public function return_json($data,$status=1) { |
|
218 | + public function return_json($data, $status = 1) { |
|
219 | 219 | $return_array = []; |
220 | 220 | $return_array['status'] = $status; |
221 | 221 | $return_array['data'] = $data; |
222 | - $return_array['tou'] = "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php"; |
|
222 | + $return_array['tou'] = "Please consult Terms of Use at: " . $this->GetRootURL() . "/tou.php"; |
|
223 | 223 | return(json_encode($return_array)); |
224 | 224 | } |
225 | 225 | |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function JSON_listLanguages() { |
232 | 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']]; |
|
233 | + foreach (Config::$LANGUAGES as $id => $val) { |
|
234 | + if ($this->version == 1) |
|
235 | + $return_array[] = ['id'=>$id, 'display'=>$val['display'], 'locale'=>$val['locale']]; |
|
236 | 236 | else |
237 | - $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
237 | + $return_array[] = ['lang'=>$id, 'display'=>$val['display'], 'locale'=>$val['locale']]; |
|
238 | 238 | } |
239 | 239 | echo $this->return_json($return_array); |
240 | 240 | } |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | $FED = $this->printCountryList(1); |
250 | 250 | $return_array = []; |
251 | 251 | foreach ($FED as $id => $val) { |
252 | - if($this->version == 1) |
|
253 | - $return_array[] = ['id'=>$id,'display'=>$val]; |
|
252 | + if ($this->version == 1) |
|
253 | + $return_array[] = ['id'=>$id, 'display'=>$val]; |
|
254 | 254 | else |
255 | - $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
255 | + $return_array[] = ['federation'=>$id, 'display'=>$val]; |
|
256 | 256 | } |
257 | 257 | echo $this->return_json($return_array); |
258 | 258 | } |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | */ |
266 | 266 | |
267 | 267 | public function JSON_listIdentityProviders($country) { |
268 | - $idps = Federation::listAllIdentityProviders(1,$country); |
|
268 | + $idps = Federation::listAllIdentityProviders(1, $country); |
|
269 | 269 | $return_array = []; |
270 | 270 | foreach ($idps as $idp) { |
271 | - if($this->version == 1) |
|
272 | - $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
271 | + if ($this->version == 1) |
|
272 | + $return_array[] = ['id'=>$idp['entityID'], 'display'=>$idp['title']]; |
|
273 | 273 | else |
274 | - $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
274 | + $return_array[] = ['idp'=>$idp['entityID'], 'display'=>$idp['title']]; |
|
275 | 275 | } |
276 | 276 | echo $this->return_json($return_array); |
277 | 277 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $idps = Federation::listAllIdentityProviders(1); |
288 | 288 | $return_array = []; |
289 | 289 | foreach ($idps as $idp) { |
290 | - if($this->version == 1) |
|
290 | + if ($this->version == 1) |
|
291 | 291 | $idp['id'] = $idp['entityID']; |
292 | 292 | else |
293 | 293 | $idp['idp'] = $idp['entityID']; |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | */ |
307 | 307 | |
308 | 308 | |
309 | - public function JSON_orderIdentityProviders($country,$L=NULL) { |
|
310 | - $idps = $this->orderIdentityProviders($country,$L); |
|
309 | + public function JSON_orderIdentityProviders($country, $L = NULL) { |
|
310 | + $idps = $this->orderIdentityProviders($country, $L); |
|
311 | 311 | $return_array = []; |
312 | 312 | foreach ($idps as $idp) { |
313 | - if($this->version == 1) |
|
314 | - $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
313 | + if ($this->version == 1) |
|
314 | + $return_array[] = ['id'=>$idp['id'], 'display'=>$idp['title']]; |
|
315 | 315 | else |
316 | - $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
316 | + $return_array[] = ['idp'=>$idp['id'], 'display'=>$idp['title']]; |
|
317 | 317 | } |
318 | 318 | echo $this->return_json($return_array); |
319 | 319 | } |
@@ -324,28 +324,28 @@ 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) { |
|
327 | + public function JSON_listProfiles($idp_id, $sort = 0) { |
|
328 | 328 | $this->set_locale("web_user"); |
329 | 329 | $return_array = []; |
330 | 330 | try { |
331 | 331 | $idp = new IdP($idp_id); |
332 | 332 | } |
333 | 333 | catch (Exception $fail) { |
334 | - echo $this->return_json($return_array,0); |
|
334 | + echo $this->return_json($return_array, 0); |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | $l = 0; |
338 | 338 | $logo = $idp->getAttributes('general:logo_file'); |
339 | - if($logo) |
|
339 | + if ($logo) |
|
340 | 340 | $l = 1; |
341 | 341 | $profiles = $idp->listProfiles(1); |
342 | - if($sort == 1) |
|
343 | - usort($profiles,"profile_sort"); |
|
342 | + if ($sort == 1) |
|
343 | + usort($profiles, "profile_sort"); |
|
344 | 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]; |
|
345 | + if ($this->version == 1) |
|
346 | + $return_array[] = ['id'=>$P->identifier, 'display'=>$P->name, 'idp_name'=>$P->inst_name, 'logo'=>$l]; |
|
347 | 347 | else |
348 | - $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
348 | + $return_array[] = ['profile'=>$P->identifier, 'display'=>$P->name, 'idp_name'=>$P->inst_name, 'logo'=>$l]; |
|
349 | 349 | } |
350 | 350 | echo $this->return_json($return_array); |
351 | 351 | } |
@@ -361,20 +361,20 @@ discard block |
||
361 | 361 | $return_array = []; |
362 | 362 | $a = $this->profileAttributes($profile_id); |
363 | 363 | $thedevices = $a['devices']; |
364 | - if(!isset($profile_redirect) || ! $profile_redirect) { |
|
364 | + if (!isset($profile_redirect) || !$profile_redirect) { |
|
365 | 365 | $profile_redirect = 0; |
366 | 366 | foreach ($thedevices as $D) { |
367 | - if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
367 | + if (isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
368 | 368 | continue; |
369 | 369 | $disp = $D['display']; |
370 | - if($this->version == 1) { |
|
371 | - if($D['id'] === '0') { |
|
370 | + if ($this->version == 1) { |
|
371 | + if ($D['id'] === '0') { |
|
372 | 372 | $profile_redirect = 1; |
373 | 373 | $disp = $c; |
374 | 374 | } |
375 | 375 | $return_array[] = ['id'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']]; |
376 | 376 | } else { |
377 | - if($D['device'] === '0') { |
|
377 | + if ($D['device'] === '0') { |
|
378 | 378 | $profile_redirect = 1; |
379 | 379 | $disp = $c; |
380 | 380 | } |
@@ -393,12 +393,12 @@ 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) { |
|
397 | - debug(4,"JSON::generateInstaller arguments: $device,$prof_id\n"); |
|
398 | - $o = $this->generateInstaller($device,$prof_id); |
|
399 | - debug(4,"output from GUI::generateInstaller:"); |
|
400 | - debug(4,$o); |
|
401 | - debug(4,json_encode($o)); |
|
396 | + public function JSON_generateInstaller($device, $prof_id) { |
|
397 | + debug(4, "JSON::generateInstaller arguments: $device,$prof_id\n"); |
|
398 | + $o = $this->generateInstaller($device, $prof_id); |
|
399 | + debug(4, "output from GUI::generateInstaller:"); |
|
400 | + debug(4, $o); |
|
401 | + debug(4, json_encode($o)); |
|
402 | 402 | // header('Content-type: application/json; utf-8'); |
403 | 403 | echo $this->return_json($o); |
404 | 404 | } |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | * @return binary installerFile |
412 | 412 | */ |
413 | 413 | |
414 | - public function downloadInstaller($device,$prof_id,$generated_for='user') { |
|
415 | - debug(4,"downloadInstaller arguments: $device,$prof_id,$generated_for\n"); |
|
416 | - $o = $this->generateInstaller($device,$prof_id); |
|
417 | - debug(4,"output from GUI::generateInstaller:"); |
|
418 | - debug(4,$o); |
|
419 | - if(! $o['link']) { |
|
414 | + public function downloadInstaller($device, $prof_id, $generated_for = 'user') { |
|
415 | + debug(4, "downloadInstaller arguments: $device,$prof_id,$generated_for\n"); |
|
416 | + $o = $this->generateInstaller($device, $prof_id); |
|
417 | + debug(4, "output from GUI::generateInstaller:"); |
|
418 | + debug(4, $o); |
|
419 | + if (!$o['link']) { |
|
420 | 420 | header("HTTP/1.0 404 Not Found"); |
421 | 421 | return; |
422 | 422 | } |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | $profile->incrementDownloadStats($device, $generated_for); |
425 | 425 | $file = $this->i_path; |
426 | 426 | $filetype = $o['mime']; |
427 | - debug(4,"installer MIME type:$filetype\n"); |
|
428 | - header("Content-type: ".$filetype); |
|
429 | - header('Content-Disposition: inline; filename="'.basename($file).'"'); |
|
427 | + debug(4, "installer MIME type:$filetype\n"); |
|
428 | + header("Content-type: " . $filetype); |
|
429 | + header('Content-Disposition: inline; filename="' . basename($file) . '"'); |
|
430 | 430 | header('Content-Length: ' . filesize($file)); |
431 | 431 | ob_clean(); |
432 | 432 | flush(); |
@@ -444,67 +444,67 @@ discard block |
||
444 | 444 | * |
445 | 445 | */ |
446 | 446 | |
447 | - public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) { |
|
447 | + public function sendLogo($idp_id, $disco = FALSE, $width = 0, $height = 0) { |
|
448 | 448 | $ExpStr = ''; |
449 | 449 | $resize = 0; |
450 | - if(($width || $height) && is_numeric($width) && is_numeric($height)) { |
|
450 | + if (($width || $height) && is_numeric($width) && is_numeric($height)) { |
|
451 | 451 | $resize = 1; |
452 | - if($height == 0) |
|
452 | + if ($height == 0) |
|
453 | 453 | $height = 10000; |
454 | - if($width == 0) |
|
454 | + if ($width == 0) |
|
455 | 455 | $width = 10000; |
456 | - $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
457 | - } elseif($disco == 1) { |
|
456 | + $logo_file = CAT::$root . '/web/downloads/logos/' . $idp_id . '_' . $width . '_' . $height . '.png'; |
|
457 | + } elseif ($disco == 1) { |
|
458 | 458 | $width = 120; |
459 | 459 | $height = 40; |
460 | 460 | $resize = 1; |
461 | - $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
461 | + $logo_file = CAT::$root . '/web/downloads/logos/' . $idp_id . '_' . $width . '_' . $height . '.png'; |
|
462 | 462 | } |
463 | 463 | |
464 | - if($resize && is_file($logo_file)){ |
|
465 | - debug(4,"Using cached logo $logo_file for: $idp_id\n"); |
|
464 | + if ($resize && is_file($logo_file)) { |
|
465 | + debug(4, "Using cached logo $logo_file for: $idp_id\n"); |
|
466 | 466 | $blob = file_get_contents($logo_file); |
467 | 467 | $filetype = 'image/png'; |
468 | 468 | } |
469 | 469 | else { |
470 | 470 | $idp = new IdP($idp_id); |
471 | 471 | $at = $idp->getAttributes('general:logo_file'); |
472 | - $blob = $at[0]['value']; |
|
472 | + $blob = $at[0]['value']; |
|
473 | 473 | $info = new finfo(); |
474 | 474 | $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE); |
475 | 475 | $offset = 60 * 60 * 24 * 30; |
476 | - $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT"; |
|
477 | - if($resize) { |
|
476 | + $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"; |
|
477 | + if ($resize) { |
|
478 | 478 | $filetype = 'image/png'; |
479 | 479 | $image = new Imagick(); |
480 | 480 | $image->readImageBlob($blob); |
481 | - if( $image->setImageFormat('PNG')) { |
|
482 | - $image->thumbnailImage($width,$height,1); |
|
481 | + if ($image->setImageFormat('PNG')) { |
|
482 | + $image->thumbnailImage($width, $height, 1); |
|
483 | 483 | $blob = $image->getImageBlob(); |
484 | - debug(4,"Writing cached logo $logo_file for: $idp_id\n"); |
|
485 | - file_put_contents($logo_file,$blob); |
|
484 | + debug(4, "Writing cached logo $logo_file for: $idp_id\n"); |
|
485 | + file_put_contents($logo_file, $blob); |
|
486 | 486 | } |
487 | 487 | else |
488 | 488 | $blob = "XXXXXX"; |
489 | 489 | } |
490 | 490 | } |
491 | - header( "Content-type: ".$filetype ); |
|
492 | - header( "Cache-Control:max-age=36000, must-revalidate" ); |
|
493 | - header( $ExpStr ); |
|
491 | + header("Content-type: " . $filetype); |
|
492 | + header("Cache-Control:max-age=36000, must-revalidate"); |
|
493 | + header($ExpStr); |
|
494 | 494 | echo $blob; |
495 | 495 | } |
496 | 496 | |
497 | 497 | public function locateUser() { |
498 | 498 | $host = $_SERVER['REMOTE_ADDR']; |
499 | 499 | $record = geoip_record_by_name($host); |
500 | - if($record) { |
|
500 | + if ($record) { |
|
501 | 501 | $result = ['status' => 'ok']; |
502 | 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') |
|
504 | + if ($result['country'] == 'GB') |
|
505 | 505 | $result['country'] = 'UK'; |
506 | 506 | $result['region'] = $record['region']; |
507 | - $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']]; |
|
507 | + $result['geo'] = ['lat' => (float) $record['latitude'], 'lon' => (float) $record['longitude']]; |
|
508 | 508 | } else { |
509 | 509 | $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
510 | 510 | } |
@@ -525,22 +525,22 @@ discard block |
||
525 | 525 | $result = ['status' => 'ok']; |
526 | 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') |
|
528 | + if ($result['country'] == 'GB') |
|
529 | 529 | $result['country'] = 'UK'; |
530 | 530 | $result['region'] = $record->continent->name; |
531 | 531 | |
532 | - $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude]; |
|
532 | + $result['geo'] = ['lat' => (float) $record->location->latitude, 'lon' => (float) $record->location->longitude]; |
|
533 | 533 | return($result); |
534 | 534 | } |
535 | 535 | |
536 | 536 | public function JSON_locateUser() { |
537 | 537 | header('Content-type: application/json; utf-8'); |
538 | 538 | |
539 | - if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0) |
|
539 | + if (empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0) |
|
540 | 540 | echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
541 | - if(Config::$GEOIP['version'] == 1) |
|
541 | + if (Config::$GEOIP['version'] == 1) |
|
542 | 542 | echo json_encode($this->locateUser()); |
543 | - if(Config::$GEOIP['version'] == 2) |
|
543 | + if (Config::$GEOIP['version'] == 2) |
|
544 | 544 | echo json_encode($this->locateUser2()); |
545 | 545 | } |
546 | 546 | |
@@ -560,11 +560,11 @@ discard block |
||
560 | 560 | * @param array $P2 - second point as an 'lat', 'lon' array |
561 | 561 | * @return float distance in km |
562 | 562 | */ |
563 | -private function geoDistance($P1,$P2) { |
|
563 | +private function geoDistance($P1, $P2) { |
|
564 | 564 | |
565 | 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 ; |
|
567 | + $dist = rad2deg(acos($dist)) * 60 * 1.1852; |
|
568 | 568 | return(round($dist)); |
569 | 569 | } |
570 | 570 | |
@@ -574,44 +574,44 @@ discard block |
||
574 | 574 | * @return array $IdPs - list of arrays ('id', 'name'); |
575 | 575 | */ |
576 | 576 | |
577 | -public function orderIdentityProviders($country,$L=NULL) { |
|
578 | - $idps = Federation::listAllIdentityProviders(1,$country); |
|
577 | +public function orderIdentityProviders($country, $L = NULL) { |
|
578 | + $idps = Federation::listAllIdentityProviders(1, $country); |
|
579 | 579 | |
580 | - if(is_null($L)) { |
|
580 | + if (is_null($L)) { |
|
581 | 581 | $U = $this->locateUser(); |
582 | - if($U['status'] == 'ok') { |
|
582 | + if ($U['status'] == 'ok') { |
|
583 | 583 | $L = $U['geo']; |
584 | 584 | } else { |
585 | - $L = ['lat'=>"90",'lon'=>"0"]; |
|
585 | + $L = ['lat'=>"90", 'lon'=>"0"]; |
|
586 | 586 | } |
587 | 587 | } |
588 | - $T=[]; |
|
589 | - $R=[]; |
|
588 | + $T = []; |
|
589 | + $R = []; |
|
590 | 590 | foreach ($idps as $idp) { |
591 | 591 | $T[$idp['entityID']] = $idp['title']; |
592 | 592 | $dist = 10000; |
593 | - if(isset($idp['geo'])) { |
|
594 | - $G=$idp['geo']; |
|
595 | - if(isset($G['lon'])) { |
|
596 | - $d1 = $this->geoDistance($L,$G); |
|
597 | - if( $d1 < $dist) |
|
593 | + if (isset($idp['geo'])) { |
|
594 | + $G = $idp['geo']; |
|
595 | + if (isset($G['lon'])) { |
|
596 | + $d1 = $this->geoDistance($L, $G); |
|
597 | + if ($d1 < $dist) |
|
598 | 598 | $dist = $d1; |
599 | 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']; |
|
607 | + if ($dist > 100) |
|
608 | + $dist = 10000; |
|
609 | + $d = sprintf("%06d", $dist); |
|
610 | + $R[$idp['entityID']] = $d . " " . $idp['title']; |
|
611 | 611 | } |
612 | 612 | asort($R); |
613 | 613 | foreach (array_keys($R) as $r) { |
614 | - if($this->version == 1) |
|
614 | + if ($this->version == 1) |
|
615 | 615 | $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
616 | 616 | else |
617 | 617 | $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
@@ -629,44 +629,44 @@ discard block |
||
629 | 629 | |
630 | 630 | public function detectOS() { |
631 | 631 | $Dev = Devices::listDevices(); |
632 | - if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
|
632 | + if (isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
|
633 | 633 | $dev_id = $_REQUEST['device']; |
634 | 634 | $device = $Dev[$dev_id]; |
635 | - if($this->version == 1) |
|
636 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
635 | + if ($this->version == 1) |
|
636 | + return(['id'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]); |
|
637 | 637 | else |
638 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
638 | + return(['device'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]); |
|
639 | 639 | } |
640 | 640 | $browser = $_SERVER['HTTP_USER_AGENT']; |
641 | - debug(4,"HTTP_USER_AGENT=$browser\n"); |
|
641 | + debug(4, "HTTP_USER_AGENT=$browser\n"); |
|
642 | 642 | foreach ($Dev as $dev_id => $device) { |
643 | - if(!isset($device['match'])) |
|
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']]); |
|
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 | 650 | else |
651 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
651 | + return(['device'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]); |
|
652 | 652 | } |
653 | 653 | else { |
654 | - debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
654 | + debug(2, "Unrecognised system: " . $_SERVER['HTTP_USER_AGENT'] . "\n"); |
|
655 | 655 | return(false); |
656 | 656 | } |
657 | 657 | } |
658 | 658 | } |
659 | - debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
659 | + debug(2, "Unrecognised system: " . $_SERVER['HTTP_USER_AGENT'] . "\n"); |
|
660 | 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 | 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 | |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | private $i_path; |
676 | 676 | |
677 | 677 | } |
678 | -function profile_sort($P1,$P2) { |
|
678 | +function profile_sort($P1, $P2) { |
|
679 | 679 | return strcasecmp($P1->name, $P2->name); |
680 | 680 | } |
681 | 681 | ?> |
@@ -253,7 +253,7 @@ |
||
253 | 253 | // who to whom? |
254 | 254 | $mail->From = Config::$APPEARANCE['from-mail']; |
255 | 255 | $mail->FromName = Config::$APPEARANCE['productname'] . " Notification System"; |
256 | - $mail->addReplyTo(Config::$APPEARANCE['support-contact']['mail'], Config::$APPEARANCE['productname'] . " " ._("Feedback")); |
|
256 | + $mail->addReplyTo(Config::$APPEARANCE['support-contact']['mail'], Config::$APPEARANCE['productname'] . " " . _("Feedback")); |
|
257 | 257 | |
258 | 258 | $mailaddr = $this->getAttributes("user:email"); |
259 | 259 | if (count($mailaddr) == 0) // we don't know his mail address |
@@ -14,8 +14,8 @@ |
||
14 | 14 | * @final not to be redefined |
15 | 15 | */ |
16 | 16 | final public function __construct() { |
17 | - $this->supportedEapMethods = [EAP::$EAP_NONE]; |
|
18 | - debug(4,"RedirectEx called"); |
|
17 | + $this->supportedEapMethods = [EAP::$EAP_NONE]; |
|
18 | + debug(4, "RedirectEx called"); |
|
19 | 19 | } |
20 | 20 | public function writeDeviceInfo() { |
21 | 21 | $out = "<p>"; |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | |
33 | 33 | final public function __construct() { |
34 | 34 | // $this->supportedEapMethods = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP); |
35 | - $this->supportedEapMethods = [ EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$TLS ]; |
|
35 | + $this->supportedEapMethods = [EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$TLS]; |
|
36 | 36 | $this->local_dir = '.cat_installer'; |
37 | - $this->conf_file = '$HOME/'.$this->local_dir.'/cat_installer.conf'; |
|
38 | - debug(4,"LINUX: This device supports the following EAP methods: "); |
|
39 | - debug(4,$this->supportedEapMethods); |
|
37 | + $this->conf_file = '$HOME/' . $this->local_dir . '/cat_installer.conf'; |
|
38 | + debug(4, "LINUX: This device supports the following EAP methods: "); |
|
39 | + debug(4, $this->supportedEapMethods); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function writeInstaller() { |
@@ -59,40 +59,40 @@ discard block |
||
59 | 59 | $out_string .= "# save certificates\n"; |
60 | 60 | $out_string .= 'echo "'; |
61 | 61 | foreach ($CAs as $ca) { |
62 | - $out_string .= $ca['pem']."\n"; |
|
62 | + $out_string .= $ca['pem'] . "\n"; |
|
63 | 63 | } |
64 | - $out_string .= '"'." > \$HOME/$this->local_dir/ca.pem\n"; |
|
64 | + $out_string .= '"' . " > \$HOME/$this->local_dir/ca.pem\n"; |
|
65 | 65 | |
66 | 66 | $SSIDs = $this->attributes['internal:SSID']; |
67 | 67 | $delSSIDs = $this->attributes['internal:remove_SSID']; |
68 | 68 | |
69 | - $out_string .= $this->printNMScript($SSIDs,$delSSIDs); |
|
69 | + $out_string .= $this->printNMScript($SSIDs, $delSSIDs); |
|
70 | 70 | $out_string .= $this->writeWpaConf($SSIDs); |
71 | - if($this->selected_eap == EAP::$TLS) |
|
71 | + if ($this->selected_eap == EAP::$TLS) |
|
72 | 72 | $out_string .= $this->printP12Dialog(); |
73 | 73 | else |
74 | 74 | $out_string .= $this->printPasswordDialog(); |
75 | 75 | $out_string .= $this->checkNMResultAndCont(); |
76 | - $installer_path = $this->installerBasename.'.sh'; |
|
76 | + $installer_path = $this->installerBasename . '.sh'; |
|
77 | 77 | file_put_contents($installer_path, $out_string); |
78 | 78 | return($installer_path); |
79 | 79 | } |
80 | 80 | |
81 | 81 | public function writeDeviceInfo() { |
82 | - $ssid_ct=count($this->attributes['internal:SSID']); |
|
82 | + $ssid_ct = count($this->attributes['internal:SSID']); |
|
83 | 83 | $out = ''; |
84 | 84 | |
85 | 85 | $out .= _("The installer is in the form of a bash script. It will try to configure eduroam under Network Manager and if this is either not appropriate for your system or your version of Network Manager is too old, a wpa_supplicant config file will be created instead."); |
86 | 86 | $out .= "<p>"; |
87 | - if($ssid_ct > 1) { |
|
88 | - if($ssid_ct > 2) { |
|
89 | - $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
|
87 | + if ($ssid_ct > 1) { |
|
88 | + if ($ssid_ct > 2) { |
|
89 | + $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"), implode(', ', Config::$CONSORTIUM['ssid'])) . " "; |
|
90 | 90 | } else |
91 | - $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
|
91 | + $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"), implode(', ', Config::$CONSORTIUM['ssid'])) . " "; |
|
92 | 92 | $i = 0; |
93 | 93 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
94 | - if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
95 | - if($i > 0) |
|
94 | + if (!in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
95 | + if ($i > 0) |
|
96 | 96 | $out .= ", "; |
97 | 97 | $i++; |
98 | 98 | $out .= "<strong>$ssid</strong>"; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $out .= "<p>"; |
102 | 102 | } |
103 | 103 | $out .= _("The installer will create .cat_installer sub-directory in your home directory and will copy your server certificates there."); |
104 | -if($this->eap == EAP::$TLS) |
|
104 | +if ($this->eap == EAP::$TLS) |
|
105 | 105 | $out .= _("In order to connect to the network you will need 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. Your p12 file will also be copied to the .cat_installer directory."); |
106 | 106 | else { |
107 | 107 | $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."); |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | |
115 | 115 | |
116 | 116 | private function printCheckDirectory() { |
117 | -$out = 'if [ -d $HOME/'.$this->local_dir.' ] ; then |
|
118 | - if ! ask "'.sprintf(_("Directory %s exists; some of its files may be overwritten."),'$HOME/'.$this->local_dir).'" "'._("Continue").'" 1 ; then exit; fi |
|
117 | +$out = 'if [ -d $HOME/' . $this->local_dir . ' ] ; then |
|
118 | + if ! ask "'.sprintf(_("Directory %s exists; some of its files may be overwritten."), '$HOME/' . $this->local_dir) . '" "' . _("Continue") . '" 1 ; then exit; fi |
|
119 | 119 | else |
120 | - mkdir $HOME/'.$this->local_dir.' |
|
120 | + mkdir $HOME/'.$this->local_dir . ' |
|
121 | 121 | fi |
122 | 122 | '; |
123 | 123 | return $out; |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | |
126 | 126 | private function checkNMResultAndCont() { |
127 | 127 | $out = 'if run_python_script ; then |
128 | - show_info "'._("Installation successful").'" |
|
128 | + show_info "'._("Installation successful") . '" |
|
129 | 129 | else |
130 | - show_info "'._("Network Manager configuration failed, generating wpa_supplicant.conf").'" |
|
131 | - if ! ask "'.("Network Manager configuration failed, but we may generate a wpa_supplicant configuration file if you wish. Be warned that your connection password will be saved in this file as clear text.").'" "'._("Write the file").'" 1 ; then exit ; fi |
|
130 | + show_info "'._("Network Manager configuration failed, generating wpa_supplicant.conf") . '" |
|
131 | + if ! ask "'.("Network Manager configuration failed, but we may generate a wpa_supplicant configuration file if you wish. Be warned that your connection password will be saved in this file as clear text.") . '" "' . _("Write the file") . '" 1 ; then exit ; fi |
|
132 | 132 | |
133 | -if [ -f '.$this->conf_file.' ] ; then |
|
134 | - if ! ask "'.sprintf(_("File %s exists; it will be overwritten."),$this->conf_file).'" "'._("Continue").'" 1 ; then confirm_exit; fi |
|
135 | - rm '.$this->conf_file.' |
|
133 | +if [ -f '.$this->conf_file . ' ] ; then |
|
134 | + if ! ask "'.sprintf(_("File %s exists; it will be overwritten."), $this->conf_file) . '" "' . _("Continue") . '" 1 ; then confirm_exit; fi |
|
135 | + rm '.$this->conf_file . ' |
|
136 | 136 | fi |
137 | 137 | create_wpa_conf |
138 | - show_info "'.sprintf(_("Output written to %s"),$this->conf_file).'" |
|
138 | + show_info "'.sprintf(_("Output written to %s"), $this->conf_file) . '" |
|
139 | 139 | fi |
140 | 140 | '; |
141 | 141 | return $out; |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | |
144 | 144 | private function printStart() { |
145 | 145 | $out = "setup_environment\n"; |
146 | - $out .= 'show_info "'._("This installer has been prepared for \${ORGANISATION}").'\n\n'._("More information and comments:").'\n\nEMAIL: ${SUPPORT}\nWWW: ${URL}\n\n'. |
|
147 | -_("Installer created with software from the GEANT project.").'" |
|
146 | + $out .= 'show_info "' . _("This installer has been prepared for \${ORGANISATION}") . '\n\n' . _("More information and comments:") . '\n\nEMAIL: ${SUPPORT}\nWWW: ${URL}\n\n' . |
|
147 | +_("Installer created with software from the GEANT project.") . '" |
|
148 | 148 | '; |
149 | 149 | return $out; |
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | 153 | private function printProfileConfirmation() { |
154 | - if($this->attributes['internal:profile_count'][0] > 1) |
|
155 | - $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."),'${bf}'.$this->attributes['general:instname'][0].'${n}','${bf}'.$this->attributes['profile:name'][0]).'${n}"'; |
|
154 | + if ($this->attributes['internal:profile_count'][0] > 1) |
|
155 | + $out = 'if ! ask "' . sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."), '${bf}' . $this->attributes['general:instname'][0] . '${n}', '${bf}' . $this->attributes['profile:name'][0]) . '${n}"'; |
|
156 | 156 | else |
157 | - $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."),'${bf}'.$this->attributes['general:instname'][0]).'${n}"'; |
|
158 | - $out .= ' "'._("Continue").'" 1 ; then exit; fi |
|
157 | + $out = 'if ! ask "' . sprintf(_("This installer will only work properly if you are a member of %s."), '${bf}' . $this->attributes['general:instname'][0]) . '${n}"'; |
|
158 | + $out .= ' "' . _("Continue") . '" 1 ; then exit; fi |
|
159 | 159 | '; |
160 | 160 | return $out; |
161 | 161 | |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | |
165 | 165 | private function printUserConsent() { |
166 | 166 | $out = ''; |
167 | - if(isset($this->attributes['support:info_file'])) { |
|
168 | - if( $this->attributes['internal:info_file'][0]['mime'] == 'txt') { |
|
169 | - $handle = fopen($this->attributes['internal:info_file'][0]['name'],"r"); |
|
167 | + if (isset($this->attributes['support:info_file'])) { |
|
168 | + if ($this->attributes['internal:info_file'][0]['mime'] == 'txt') { |
|
169 | + $handle = fopen($this->attributes['internal:info_file'][0]['name'], "r"); |
|
170 | 170 | $consent = ''; |
171 | 171 | while (($buffer = fgets($handle, 4096)) !== false) { |
172 | 172 | $consent .= rtrim($buffer) . '\n'; |
173 | 173 | } |
174 | - $out = 'if ! ask "'.$consent.'${n}" "'._("Continue").'" 1 ; then exit; fi |
|
174 | + $out = 'if ! ask "' . $consent . '${n}" "' . _("Continue") . '" 1 ; then exit; fi |
|
175 | 175 | '; |
176 | 176 | } |
177 | 177 | } |
@@ -182,18 +182,18 @@ discard block |
||
182 | 182 | # if the second argument is 0 then the first element of yes_no array |
183 | 183 | # will be the default value prompted to the user |
184 | 184 | private function printFunctions() { |
185 | -$url = (isset($this->attributes['support:url'][0]) && $this->attributes['support:url'][0] ) ? $this->attributes['support:url'][0] : $this->support_url_substitute; |
|
186 | -$support=(isset($this->attributes['support:email'][0]) && $this->attributes['support:email'][0] ) ? $this->attributes['support:email'][0] : $this->support_email_substitute; |
|
187 | -$out =' |
|
185 | +$url = (isset($this->attributes['support:url'][0]) && $this->attributes['support:url'][0]) ? $this->attributes['support:url'][0] : $this->support_url_substitute; |
|
186 | +$support = (isset($this->attributes['support:email'][0]) && $this->attributes['support:email'][0]) ? $this->attributes['support:email'][0] : $this->support_email_substitute; |
|
187 | +$out = ' |
|
188 | 188 | my_name=$0 |
189 | 189 | |
190 | 190 | |
191 | 191 | function setup_environment { |
192 | 192 | bf="" |
193 | 193 | n="" |
194 | - ORGANISATION="'.$this->attributes['general:instname'][0].'" |
|
195 | - URL="'.$url.'" |
|
196 | - SUPPORT="'.$support.'" |
|
194 | + ORGANISATION="'.$this->attributes['general:instname'][0] . '" |
|
195 | + URL="'.$url . '" |
|
196 | + SUPPORT="'.$support . '" |
|
197 | 197 | if [ ! -z "$DISPLAY" ] ; then |
198 | 198 | if which zenity 1>/dev/null 2>&1 ; then |
199 | 199 | ZENITY=`which zenity` |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | |
234 | 234 | function ask { |
235 | - T="'.Config::$APPEARANCE['productname'].'" |
|
235 | + T="'.Config::$APPEARANCE['productname'] . '" |
|
236 | 236 | # if ! [ -z "$3" ] ; then |
237 | 237 | # T="$T: $3" |
238 | 238 | # fi |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | fi |
253 | 253 | fi |
254 | 254 | |
255 | - yes='._("Y").' |
|
256 | - no='._("N").' |
|
255 | + yes='._("Y") . ' |
|
256 | + no='._("N") . ' |
|
257 | 257 | yes1=`echo $yes | awk \'{ print toupper($0) }\'` |
258 | 258 | no1=`echo $no | awk \'{ print toupper($0) }\'` |
259 | 259 | |
@@ -310,12 +310,12 @@ discard block |
||
310 | 310 | |
311 | 311 | function confirm_exit { |
312 | 312 | if [ ! -z $KDIALOG ] ; then |
313 | - if $KDIALOG --yesno "'._("Really quit?").'" ; then |
|
313 | + if $KDIALOG --yesno "'._("Really quit?") . '" ; then |
|
314 | 314 | exit 1 |
315 | 315 | fi |
316 | 316 | fi |
317 | 317 | if [ ! -z $ZENITY ] ; then |
318 | - if $ZENITY --question --text="'._("Really quit?").'" 2>/dev/null ; then |
|
318 | + if $ZENITY --question --text="'._("Really quit?") . '" 2>/dev/null ; then |
|
319 | 319 | exit 1 |
320 | 320 | fi |
321 | 321 | fi |
@@ -368,20 +368,20 @@ discard block |
||
368 | 368 | PASSWORD="a" |
369 | 369 | PASSWORD1="b" |
370 | 370 | |
371 | - if ! USER_NAME=`prompt_nonempty_string 1 "'._("enter your userid").'"` ; then |
|
371 | + if ! USER_NAME=`prompt_nonempty_string 1 "'._("enter your userid") . '"` ; then |
|
372 | 372 | exit 1 |
373 | 373 | fi |
374 | 374 | |
375 | 375 | while [ "$PASSWORD" != "$PASSWORD1" ] |
376 | 376 | do |
377 | - if ! PASSWORD=`prompt_nonempty_string 0 "'._("enter your password").'"` ; then |
|
377 | + if ! PASSWORD=`prompt_nonempty_string 0 "'._("enter your password") . '"` ; then |
|
378 | 378 | exit 1 |
379 | 379 | fi |
380 | - if ! PASSWORD1=`prompt_nonempty_string 0 "'._("repeat your password").'"` ; then |
|
380 | + if ! PASSWORD1=`prompt_nonempty_string 0 "'._("repeat your password") . '"` ; then |
|
381 | 381 | exit 1 |
382 | 382 | fi |
383 | 383 | if [ "$PASSWORD" != "$PASSWORD1" ] ; then |
384 | - alert "'._("passwords do not match").'" |
|
384 | + alert "'._("passwords do not match") . '" |
|
385 | 385 | fi |
386 | 386 | done |
387 | 387 | } |
@@ -394,38 +394,38 @@ discard block |
||
394 | 394 | private function writeWpaConf($SSIDs) { |
395 | 395 | $e = EAP::eapDisplayName($this->selected_eap); |
396 | 396 | $out = 'function create_wpa_conf { |
397 | -cat << EOFW >> '.$this->conf_file."\n"; |
|
397 | +cat << EOFW >> '.$this->conf_file . "\n"; |
|
398 | 398 | foreach (array_keys($SSIDs) as $ssid) { |
399 | 399 | $out .= ' |
400 | 400 | network={ |
401 | - ssid="'.$ssid.'" |
|
401 | + ssid="'.$ssid . '" |
|
402 | 402 | key_mgmt=WPA-EAP |
403 | 403 | pairwise=CCMP |
404 | 404 | group=CCMP TKIP |
405 | - eap='.$e['OUTER'].' |
|
406 | - ca_cert="${HOME}/'.$this->local_dir.'/ca.pem" |
|
405 | + eap='.$e['OUTER'] . ' |
|
406 | + ca_cert="${HOME}/'.$this->local_dir . '/ca.pem" |
|
407 | 407 | identity="${USER_NAME}"'; |
408 | - if($this->server_name) |
|
408 | + if ($this->server_name) |
|
409 | 409 | $out .= ' |
410 | - domain_suffix_match="'.$this->server_name.'"'; |
|
411 | - if($this->selected_eap == EAP::$TLS) { |
|
410 | + domain_suffix_match="'.$this->server_name . '"'; |
|
411 | + if ($this->selected_eap == EAP::$TLS) { |
|
412 | 412 | $out .= ' |
413 | - private_key="${HOME}/'.$this->local_dir.'/user.p12" |
|
413 | + private_key="${HOME}/'.$this->local_dir . '/user.p12" |
|
414 | 414 | private_key_passwd="${PASSWORD}"'; |
415 | 415 | } else { |
416 | 416 | $out .= ' |
417 | - phase2="auth='.$e['INNER'].'" |
|
417 | + phase2="auth='.$e['INNER'] . '" |
|
418 | 418 | password="${PASSWORD}"'; |
419 | - if($this->attributes['internal:use_anon_outer'][0] == 1) |
|
419 | + if ($this->attributes['internal:use_anon_outer'][0] == 1) |
|
420 | 420 | $out .= ' |
421 | - anonymous_identity="'.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'"'; |
|
421 | + anonymous_identity="'.$this->attributes['internal:anon_local_value'][0] . '@' . $this->attributes['internal:realm'][0] . '"'; |
|
422 | 422 | } |
423 | 423 | $out .= ' |
424 | 424 | }'; |
425 | 425 | } |
426 | 426 | $out .= ' |
427 | 427 | EOFW |
428 | -chmod 600 '.$this->conf_file.' |
|
428 | +chmod 600 '.$this->conf_file . ' |
|
429 | 429 | } |
430 | 430 | '; |
431 | 431 | return $out; |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | return $out; |
441 | 441 | } |
442 | 442 | private function printP12Dialog() { |
443 | - $out ='function p12dialog { |
|
443 | + $out = 'function p12dialog { |
|
444 | 444 | if [ ! -z $ZENITY ] ; then |
445 | - if ! cert=`$ZENITY --file-selection --file-filter="'._("personal certificate file (p12 or pfx)").' | *.p12 *.P12 *.pfx *.PFX" --file-filter="All files | *" --title="'._("personal certificate file (p12 or pfx)").'" 2>/dev/null` ; then |
|
445 | + if ! cert=`$ZENITY --file-selection --file-filter="'._("personal certificate file (p12 or pfx)") . ' | *.p12 *.P12 *.pfx *.PFX" --file-filter="All files | *" --title="' . _("personal certificate file (p12 or pfx)") . '" 2>/dev/null` ; then |
|
446 | 446 | exit |
447 | 447 | fi |
448 | 448 | elif [ ! -z $KDIALOG ] ; then |
449 | - if ! cert=`$KDIALOG --getopenfilename . "*.p12 *.P12 *.pfx *.PFX | '._("personal certificate file (p12 or pfx)").'" --title "'._("personal certificate file (p12 or pfx)").'"` ; then |
|
449 | + if ! cert=`$KDIALOG --getopenfilename . "*.p12 *.P12 *.pfx *.PFX | '._("personal certificate file (p12 or pfx)") . '" --title "' . _("personal certificate file (p12 or pfx)") . '"` ; then |
|
450 | 450 | exit |
451 | 451 | fi |
452 | 452 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | fi |
459 | 459 | |
460 | 460 | while true ; do |
461 | - prompt="'._("personal certificate file (p12 or pfx)").'" |
|
461 | + prompt="'._("personal certificate file (p12 or pfx)") . '" |
|
462 | 462 | read -p "${prompt} [$bf$cert${n}]" cert_f |
463 | 463 | if [ "$cert" -a -z "$cert_f" ] ; then |
464 | 464 | break |
@@ -467,20 +467,20 @@ discard block |
||
467 | 467 | cert=$cert_f |
468 | 468 | break |
469 | 469 | else |
470 | - echo "'._("file not found").'" |
|
470 | + echo "'._("file not found") . '" |
|
471 | 471 | cert="" |
472 | 472 | fi |
473 | 473 | fi |
474 | 474 | done |
475 | 475 | fi |
476 | - cp "$cert" $HOME/'.$this->local_dir.'/user.p12 |
|
477 | - cert=$HOME/'.$this->local_dir.'/user.p12 |
|
476 | + cp "$cert" $HOME/'.$this->local_dir . '/user.p12 |
|
477 | + cert=$HOME/'.$this->local_dir . '/user.p12 |
|
478 | 478 | |
479 | 479 | PASSWORD="" |
480 | - prompt="'._("enter the password for the certificate file").'" |
|
480 | + prompt="'._("enter the password for the certificate file") . '" |
|
481 | 481 | while [ ! "$PASSWORD" ] |
482 | 482 | do |
483 | - if ! PASSWORD=`prompt_nonempty_string 0 "'._("enter the password for the certificate file").'"` ; then |
|
483 | + if ! PASSWORD=`prompt_nonempty_string 0 "'._("enter the password for the certificate file") . '"` ; then |
|
484 | 484 | exit 1 |
485 | 485 | fi |
486 | 486 | if openssl pkcs12 -in $cert -passin pass:"$PASSWORD" -noout 2>/dev/null; then |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | PASSWORD="" |
494 | 494 | fi |
495 | 495 | done |
496 | - if ! USERNAME=`prompt_nonempty_string 1 "'._("enter your userid").'" "$USER_NAME"` ; then |
|
496 | + if ! USERNAME=`prompt_nonempty_string 1 "'._("enter your userid") . '" "$USER_NAME"` ; then |
|
497 | 497 | exit 1 |
498 | 498 | fi |
499 | 499 | } |
@@ -504,31 +504,31 @@ discard block |
||
504 | 504 | |
505 | 505 | |
506 | 506 | private function glueServerNames($server_list) { |
507 | - if(! $server_list) |
|
507 | + if (!$server_list) |
|
508 | 508 | return ''; |
509 | - $A0 = array_reverse(explode('.',array_shift($server_list))); |
|
509 | + $A0 = array_reverse(explode('.', array_shift($server_list))); |
|
510 | 510 | $B = $A0; |
511 | - foreach($server_list as $a) { |
|
512 | - $A= array_reverse(explode('.',$a)); |
|
513 | - $B = array_intersect_assoc($A0,$A); |
|
511 | + foreach ($server_list as $a) { |
|
512 | + $A = array_reverse(explode('.', $a)); |
|
513 | + $B = array_intersect_assoc($A0, $A); |
|
514 | 514 | $A0 = $B; |
515 | 515 | } |
516 | - return(implode('.',array_reverse($B))); |
|
516 | + return(implode('.', array_reverse($B))); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | private function mkSubjectAltNameList($server_list) { |
520 | - if(! $server_list) |
|
520 | + if (!$server_list) |
|
521 | 521 | return ''; |
522 | 522 | $out = ''; |
523 | - foreach($server_list as $a) { |
|
524 | - if($out) |
|
523 | + foreach ($server_list as $a) { |
|
524 | + if ($out) |
|
525 | 525 | $out .= ','; |
526 | 526 | $out .= "'DNS:$a'"; |
527 | 527 | } |
528 | 528 | return $out; |
529 | 529 | } |
530 | 530 | |
531 | -private function printNMScript($SSIDs,$delSSIDs) { |
|
531 | +private function printNMScript($SSIDs, $delSSIDs) { |
|
532 | 532 | $e = EAP::eapDisplayName($this->selected_eap); |
533 | 533 | $out = 'function run_python_script { |
534 | 534 | PASSWORD=$( echo "$PASSWORD" | sed "s/\'/\\\\\\\'/g" ) |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | sys.exit(2) |
589 | 589 | |
590 | 590 | def check_opts(self): |
591 | - self.cacert_file = \'${HOME}/'.$this->local_dir.'/ca.pem\' |
|
592 | - self.pfx_file = \'${HOME}/'.$this->local_dir.'/user.p12\' |
|
591 | + self.cacert_file = \'${HOME}/'.$this->local_dir . '/ca.pem\' |
|
592 | + self.pfx_file = \'${HOME}/'.$this->local_dir . '/user.p12\' |
|
593 | 593 | if not os.path.isfile(self.cacert_file): |
594 | 594 | print("Certificate file not found, looks like a CAT error") |
595 | 595 | sys.exit(2) |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | pass |
639 | 639 | |
640 | 640 | def add_connection(self,ssid): |
641 | - server_alt_subject_name_list = dbus.Array({'.$this->server_alt_subject_name_list.'}) |
|
642 | - server_name = \''.$this->server_name.'\' |
|
641 | + server_alt_subject_name_list = dbus.Array({'.$this->server_alt_subject_name_list . '}) |
|
642 | + server_name = \''.$this->server_name . '\' |
|
643 | 643 | if self.nm_version == "0.9" or self.nm_version == "1.0": |
644 | 644 | match_key = \'altsubject-matches\' |
645 | 645 | match_value = server_alt_subject_name_list |
@@ -664,14 +664,14 @@ discard block |
||
664 | 664 | \'group\': [\'ccmp\', \'tkip\'] |
665 | 665 | }) |
666 | 666 | s_8021x = dbus.Dictionary({ |
667 | - \'eap\': [\''.strtolower($e['OUTER']).'\'], |
|
667 | + \'eap\': [\''.strtolower($e['OUTER']) . '\'], |
|
668 | 668 | \'identity\': \'$USER_NAME\', |
669 | 669 | \'ca-cert\': dbus.ByteArray("file://{0}\0".format(self.cacert_file).encode(\'utf8\')),'; |
670 | - if($this->server_name) { |
|
670 | + if ($this->server_name) { |
|
671 | 671 | $out .= ' |
672 | 672 | match_key: match_value,'; |
673 | 673 | } |
674 | - if($this->selected_eap == EAP::$TLS) { |
|
674 | + if ($this->selected_eap == EAP::$TLS) { |
|
675 | 675 | $out .= ' |
676 | 676 | \'client-cert\': dbus.ByteArray("file://{0}\0".format(self.pfx_file).encode(\'utf8\')), |
677 | 677 | \'private-key\': dbus.ByteArray("file://{0}\0".format(self.pfx_file).encode(\'utf8\')), |
@@ -679,10 +679,10 @@ discard block |
||
679 | 679 | } else { |
680 | 680 | $out .= ' |
681 | 681 | \'password\': \'$PASSWORD\', |
682 | - \'phase2-auth\': \''.strtolower($e['INNER']).'\','; |
|
683 | - if($this->attributes['internal:use_anon_outer'][0] == 1) |
|
682 | + \'phase2-auth\': \''.strtolower($e['INNER']) . '\','; |
|
683 | + if ($this->attributes['internal:use_anon_outer'][0] == 1) |
|
684 | 684 | $out .= ' |
685 | - \'anonymous-identity\': \''.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'\','; |
|
685 | + \'anonymous-identity\': \''.$this->attributes['internal:anon_local_value'][0] . '@' . $this->attributes['internal:realm'][0] . '\','; |
|
686 | 686 | } |
687 | 687 | $out .= ' |
688 | 688 | }) |
@@ -702,18 +702,18 @@ discard block |
||
702 | 702 | self.check_opts() |
703 | 703 | ver = self.connect_to_NM()'; |
704 | 704 | foreach (array_keys($SSIDs) as $ssid) { |
705 | - $out .=' |
|
706 | - self.delete_existing_connections(\''.$ssid.'\') |
|
707 | - self.add_connection(\''.$ssid.'\')'; |
|
705 | + $out .= ' |
|
706 | + self.delete_existing_connections(\''.$ssid . '\') |
|
707 | + self.add_connection(\''.$ssid . '\')'; |
|
708 | 708 | } |
709 | 709 | // create a list of profiles to be deleted after installation |
710 | 710 | foreach ($delSSIDs as $ssid => $cipher) { |
711 | - if($cipher == 'DEL') |
|
712 | - $out .=' |
|
713 | - self.delete_existing_connections(\''.$ssid.'\')'; |
|
711 | + if ($cipher == 'DEL') |
|
712 | + $out .= ' |
|
713 | + self.delete_existing_connections(\''.$ssid . '\')'; |
|
714 | 714 | } |
715 | 715 | |
716 | -$out .=' |
|
716 | +$out .= ' |
|
717 | 717 | |
718 | 718 | if __name__ == "__main__": |
719 | 719 | ENMCT = EduroamNMConfigTool() |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @package ModuleWriting |
21 | 21 | */ |
22 | -class Devices{ |
|
22 | +class Devices { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * This array lists available configuration options for local device management. |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * The default is unset, so it is not listed in the Options array. |
55 | 55 | */ |
56 | 56 | |
57 | -public static $Options=[ |
|
57 | +public static $Options = [ |
|
58 | 58 | 'sign'=>0, |
59 | 59 | 'no_cache'=>0, |
60 | 60 | 'hidden'=>0, |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | "eduroamCAT", |
299 | 299 | "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>", |
300 | 300 | "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>", |
301 | - "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"), |
|
301 | + "<a target='_blank' href='eduroamCAT-stable.apk'>" . _("as local download") . "</a>"), |
|
302 | 302 | ], |
303 | 303 | ], |
304 | 304 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | "eduroamCAT", |
315 | 315 | "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>", |
316 | 316 | "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>", |
317 | - "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"), |
|
317 | + "<a target='_blank' href='eduroamCAT-stable.apk'>" . _("as local download") . "</a>"), |
|
318 | 318 | ], |
319 | 319 | ], |
320 | 320 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | "eduroamCAT", |
331 | 331 | "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>", |
332 | 332 | "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>", |
333 | - "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"), |
|
333 | + "<a target='_blank' href='eduroamCAT-stable.apk'>" . _("as local download") . "</a>"), |
|
334 | 334 | ], |
335 | 335 | ], |
336 | 336 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | "eduroamCAT", |
348 | 348 | "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>", |
349 | 349 | "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>", |
350 | - "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"), |
|
350 | + "<a target='_blank' href='eduroamCAT-stable.apk'>" . _("as local download") . "</a>"), |
|
351 | 351 | ], |
352 | 352 | ], |
353 | 353 |