@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * supported EAP types from the DB and stores them in the priv_ arrays. |
| 74 | 74 | * |
| 75 | 75 | * @param int $p_id identifier of the profile in the DB |
| 76 | - * @param IdP $idp_object optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out. |
|
| 76 | + * @param integer $idp_object optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out. |
|
| 77 | 77 | */ |
| 78 | 78 | public function __construct($p_id, $idp_object = 0) { |
| 79 | 79 | debug(3, "--- BEGIN Constructing new Profile object ... ---\n"); |
@@ -372,6 +372,8 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @param string device the device identifier string |
| 374 | 374 | * @param string path the path where the new installer can be found |
| 375 | + * @param string $device |
|
| 376 | + * @param string $path |
|
| 375 | 377 | */ |
| 376 | 378 | public function updateCache($device, $path,$mime) { |
| 377 | 379 | $device = DBConnection::escape_value(Profile::$DB_TYPE, $device); |
@@ -384,9 +386,9 @@ discard block |
||
| 384 | 386 | /** |
| 385 | 387 | * Log a new download for our stats |
| 386 | 388 | * |
| 387 | - * @param device the device id string |
|
| 388 | - * @param area either admin or user |
|
| 389 | - * @return TRUE if incrementing worked, FALSE if not |
|
| 389 | + * @param device string device id string |
|
| 390 | + * @param area string admin or user |
|
| 391 | + * @return boolean if incrementing worked, FALSE if not |
|
| 390 | 392 | */ |
| 391 | 393 | public function incrementDownloadStats($device, $area) { |
| 392 | 394 | $device = DBConnection::escape_value(Profile::$DB_TYPE, $device); |
@@ -399,7 +401,7 @@ discard block |
||
| 399 | 401 | |
| 400 | 402 | /** |
| 401 | 403 | * Retrieve current download stats from database, either for one specific device or for all devices |
| 402 | - * @param string $device the device id string |
|
| 404 | + * @param integer $device the device id string |
|
| 403 | 405 | * @return mixed user downloads of this profile; if device is given, returns the counter as int, otherwise an array with devicename => counter |
| 404 | 406 | */ |
| 405 | 407 | public function getUserDownloadStats($device = 0) { |
@@ -464,7 +466,7 @@ discard block |
||
| 464 | 466 | * @param string $attr_name name of the attribute to set |
| 465 | 467 | * @param string $attr_value value of the attribute to set |
| 466 | 468 | * @param int $eap_type identifier of the EAP type in the database. 0 if the attribute is valid for all EAP types. |
| 467 | - * @param string $device identifier of the device in the databse. Omit the argument if attribute is valid for all devices. |
|
| 469 | + * @param integer $device identifier of the device in the databse. Omit the argument if attribute is valid for all devices. |
|
| 468 | 470 | */ |
| 469 | 471 | public function addAttribute($attr_name, $attr_value, $eap_type, $device = 0) { |
| 470 | 472 | $attr_name = DBConnection::escape_value(Profile::$DB_TYPE, $attr_name); |
@@ -574,7 +576,7 @@ discard block |
||
| 574 | 576 | /** Returns an array of the profile's attributes. |
| 575 | 577 | * |
| 576 | 578 | * @param string option_name the name of a specific option. If set, only returns option values for this option name |
| 577 | - * @param eapmethod the EAP type, in array ("OUTER/INNER") notation. If set, returns only attributes which are specific to that EAP type |
|
| 579 | + * @param eapmethod integer EAP type, in array ("OUTER/INNER") notation. If set, returns only attributes which are specific to that EAP type |
|
| 578 | 580 | * @param string device the device ID string. If set, returns only attributes which are specific to that device |
| 579 | 581 | * @return array attributes of the profile |
| 580 | 582 | */ |
@@ -658,7 +660,7 @@ discard block |
||
| 658 | 660 | /** |
| 659 | 661 | * list all devices marking their availabiblity and possible redirects |
| 660 | 662 | * |
| 661 | - * @param string $locale for text-based attributes, either returns values for the default value, or if specified here, in the locale specified |
|
| 663 | + * @param integer $locale for text-based attributes, either returns values for the default value, or if specified here, in the locale specified |
|
| 662 | 664 | * @return array of device ids display names and their status |
| 663 | 665 | */ |
| 664 | 666 | public function listDevices($locale = 0) { |
@@ -713,7 +715,7 @@ discard block |
||
| 713 | 715 | * as wel as the chosen language. |
| 714 | 716 | * can be called with an optional $eap argument |
| 715 | 717 | * |
| 716 | - * @param array $eap if specified, retrieves attributes specific to the given EAP type |
|
| 718 | + * @param integer $eap if specified, retrieves attributes specific to the given EAP type |
|
| 717 | 719 | * @return array list of attributes in collapsed style (index is the attrib name, value is an array of different values) |
| 718 | 720 | */ |
| 719 | 721 | public function getCollapsedAttributes($eap = 0) { |
@@ -643,8 +643,7 @@ discard block |
||
| 643 | 643 | if ($eap) { |
| 644 | 644 | if (isset($eAPOptions["eap-specific:customtext"][serialize($eap)])) { |
| 645 | 645 | $eap_customtext = $eAPOptions["eap-specific:customtext"][serialize($eap)]; |
| 646 | - } |
|
| 647 | - else { |
|
| 646 | + } else { |
|
| 648 | 647 | $eap_customtext = getLocalisedValue($this->getAttributes("eap-specific:customtext", $eap, 0), $locale); |
| 649 | 648 | $eAPOptions["eap-specific:customtext"][serialize($eap)] = $eap_customtext; |
| 650 | 649 | } |
@@ -711,11 +710,9 @@ discard block |
||
| 711 | 710 | } else { |
| 712 | 711 | if (isset($temp[$name]['Method'])) { |
| 713 | 712 | $out[$name] = $temp[$name]['Method']; |
| 714 | - } |
|
| 715 | - elseif (isset($temp[$name]['Profile'])) { |
|
| 713 | + } elseif (isset($temp[$name]['Profile'])) { |
|
| 716 | 714 | $out[$name] = $temp[$name]['Profile']; |
| 717 | - } |
|
| 718 | - else { |
|
| 715 | + } else { |
|
| 719 | 716 | $out[$name] = $temp[$name]['IdP']; |
| 720 | 717 | } |
| 721 | 718 | } |
@@ -772,8 +769,7 @@ discard block |
||
| 772 | 769 | $properConfig = $this->readyForShowtime(); |
| 773 | 770 | if ($properConfig) { |
| 774 | 771 | DBConnection::exec($this->databaseType, "UPDATE profile SET sufficient_config = TRUE WHERE profile_id = " . $this->identifier); |
| 775 | - } |
|
| 776 | - else { |
|
| 772 | + } else { |
|
| 777 | 773 | DBConnection::exec($this->databaseType, "UPDATE profile SET sufficient_config = FALSE WHERE profile_id = " . $this->identifier); |
| 778 | 774 | } |
| 779 | 775 | $attribs = $this->getCollapsedAttributes(); |
@@ -170,13 +170,13 @@ |
||
| 170 | 170 | // define CA certificates |
| 171 | 171 | foreach ($this->attributes['internal:CAs'][0] as $ca) { |
| 172 | 172 | // strip -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- |
| 173 | - debug(2,$ca['pem']); |
|
| 173 | + debug(2, $ca['pem']); |
|
| 174 | 174 | $caSanitized = substr($ca['pem'], 27, strlen($ca['pem']) - 27 - 25 - 1); |
| 175 | - debug(2,$caSanitized."\n"); |
|
| 175 | + debug(2, $caSanitized . "\n"); |
|
| 176 | 176 | // remove \n |
| 177 | 177 | $caSanitized = str_replace("\n", "", $caSanitized); |
| 178 | 178 | $jsonArray["Certificates"][] = ["GUID" => "{" . $ca['uuid'] . "}", "Type" => "Authority", "X509" => $caSanitized]; |
| 179 | - debug(2,$caSanitized."\n"); |
|
| 179 | + debug(2, $caSanitized . "\n"); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $outputJson = json_encode($jsonArray, JSON_PRETTY_PRINT); |
@@ -108,8 +108,9 @@ discard block |
||
| 108 | 108 | $outerId = 0; |
| 109 | 109 | if (isset($this->attributes['internal:use_anon_outer']) && $this->attributes['internal:use_anon_outer'][0] == "1" && isset($this->attributes['internal:realm'])) { |
| 110 | 110 | $outerId = "@" . $this->attributes['internal:realm'][0]; |
| 111 | - if (isset($this->attributes['internal:anon_local_value'])) |
|
| 112 | - $outerId = $this->attributes['internal:anon_local_value'][0] . $outerId; |
|
| 111 | + if (isset($this->attributes['internal:anon_local_value'])) { |
|
| 112 | + $outerId = $this->attributes['internal:anon_local_value'][0] . $outerId; |
|
| 113 | + } |
|
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | // define networks |
@@ -117,26 +118,30 @@ discard block |
||
| 117 | 118 | $networkUuid = uuid($prefix, $ssid); |
| 118 | 119 | $eapPrettyprint = EAP::eapDisplayName($this->selected_eap); |
| 119 | 120 | // ONC has its own enums, and guess what, they don't always match |
| 120 | - if ($eapPrettyprint["OUTER"] == "PEAP" && $eapPrettyprint["INNER"] == "MSCHAPV2") |
|
| 121 | - // the dictionary entry EAP-MSCHAPv2 does not work. Setting MSCHAPv2 does. (ChromeOS 50) |
|
| 121 | + if ($eapPrettyprint["OUTER"] == "PEAP" && $eapPrettyprint["INNER"] == "MSCHAPV2") { |
|
| 122 | + // the dictionary entry EAP-MSCHAPv2 does not work. Setting MSCHAPv2 does. (ChromeOS 50) |
|
| 122 | 123 | $eapPrettyprint["INNER"] = "MSCHAPv2"; |
| 124 | + } |
|
| 123 | 125 | if ($eapPrettyprint["OUTER"] == "TTLS" && $eapPrettyprint["INNER"] == "MSCHAPV2") { |
| 124 | 126 | $eapPrettyprint["OUTER"] = "EAP-TTLS"; |
| 125 | 127 | $eapPrettyprint["INNER"] = "MSCHAPv2"; |
| 126 | 128 | } |
| 127 | - if ($eapPrettyprint["OUTER"] == "TLS") |
|
| 128 | - $eapPrettyprint["OUTER"] = "EAP-TLS"; |
|
| 129 | + if ($eapPrettyprint["OUTER"] == "TLS") { |
|
| 130 | + $eapPrettyprint["OUTER"] = "EAP-TLS"; |
|
| 131 | + } |
|
| 129 | 132 | // define EAP properties |
| 130 | 133 | |
| 131 | 134 | $eaparray = array("Outer" => $eapPrettyprint["OUTER"]); |
| 132 | - if ($eapPrettyprint["INNER"] == "MSCHAPv2") |
|
| 133 | - $eaparray["Inner"] = $eapPrettyprint["INNER"]; |
|
| 135 | + if ($eapPrettyprint["INNER"] == "MSCHAPv2") { |
|
| 136 | + $eaparray["Inner"] = $eapPrettyprint["INNER"]; |
|
| 137 | + } |
|
| 134 | 138 | $eaparray["SaveCredentials"] = true; |
| 135 | 139 | $eaparray["ServerCARefs"] = $caRefs; // maybe takes just one CA? |
| 136 | 140 | $eaparray["UseSystemCAs"] = false; |
| 137 | 141 | |
| 138 | - if ($outerId) |
|
| 139 | - $eaparray["AnonymousIdentity"] = "$outerId"; |
|
| 142 | + if ($outerId) { |
|
| 143 | + $eaparray["AnonymousIdentity"] = "$outerId"; |
|
| 144 | + } |
|
| 140 | 145 | |
| 141 | 146 | $jsonArray["NetworkConfigurations"][] = [ |
| 142 | 147 | "GUID" => $networkUuid, |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | <key>PayloadIdentifier</key> |
| 130 | 130 | <string>" . mobileconfig_superclass::$iPhonePayloadPrefix . ".$this->massagedConsortium.$this->massagedCountry.$this->massagedInst.$this->massagedProfile.$this->lang</string> |
| 131 | 131 | <key>PayloadOrganization</key> |
| 132 | - <string>" . htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $this->attributes['general:instname'][0]), ENT_XML1, 'UTF-8') . ( $this->attributes['internal:profile_count'][0] > 1 ? " (" . htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $this->attributes['profile:name'][0]), ENT_XML1, 'UTF-8') . ")" : "") . "</string> |
|
| 132 | + <string>" . htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $this->attributes['general:instname'][0]), ENT_XML1, 'UTF-8') . ($this->attributes['internal:profile_count'][0] > 1 ? " (" . htmlspecialchars(iconv("UTF-8", "UTF-8//IGNORE", $this->attributes['profile:name'][0]), ENT_XML1, 'UTF-8') . ")" : "") . "</string> |
|
| 133 | 133 | <key>PayloadType</key> |
| 134 | 134 | <string>Configuration</string> |
| 135 | 135 | <key>PayloadUUID</key> |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } else { |
| 286 | 286 | $retval .= "hs20"; |
| 287 | 287 | } |
| 288 | - $retval .="</string> |
|
| 288 | + $retval .= "</string> |
|
| 289 | 289 | <key>PayloadOrganization</key> |
| 290 | 290 | <string>" . $this->massagedConsortium . ".1x-config.org</string> |
| 291 | 291 | <key>PayloadType</key> |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | $numberQuery = DBConnection::exec("INST", $query); |
| 66 | 66 | while ($queryResult = mysqli_fetch_object($numberQuery)) { |
| 67 | - $dataArray[$deviceArray['display']] = ["ADMIN" => ( $queryResult->admin === NULL ? "0" : $queryResult->admin), "USER" => ($queryResult->user === NULL ? "0" : $queryResult->user)]; |
|
| 67 | + $dataArray[$deviceArray['display']] = ["ADMIN" => ($queryResult->admin === NULL ? "0" : $queryResult->admin), "USER" => ($queryResult->user === NULL ? "0" : $queryResult->user)]; |
|
| 68 | 68 | $grossAdmin = $grossAdmin + $queryResult->admin; |
| 69 | 69 | $grossUser = $grossUser + $queryResult->user; |
| 70 | 70 | } |
@@ -83,19 +83,19 @@ discard block |
||
| 83 | 83 | if ($device == "TOTAL") { |
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | - $retstring .= "<tr><td>$device</td><td>".$numbers['ADMIN']."</td><td>".$numbers['USER']."</td></tr>"; |
|
| 86 | + $retstring .= "<tr><td>$device</td><td>" . $numbers['ADMIN'] . "</td><td>" . $numbers['USER'] . "</td></tr>"; |
|
| 87 | 87 | } |
| 88 | - $retstring .= "<tr><td><strong>TOTAL</strong></td><td><strong>".$data['TOTAL']['ADMIN']."</strong></td><td><strong>".$data['TOTAL']['USER']."</strong></td></tr>"; |
|
| 88 | + $retstring .= "<tr><td><strong>TOTAL</strong></td><td><strong>" . $data['TOTAL']['ADMIN'] . "</strong></td><td><strong>" . $data['TOTAL']['USER'] . "</strong></td></tr>"; |
|
| 89 | 89 | break; |
| 90 | 90 | case "XML": |
| 91 | - $retstring .= "<federation id='" . ( $federationid == NULL ? "ALL" : $federationid ) . "' ts='".date("Y-m-d") . "T" . date("H:i:s")."'>\n"; |
|
| 91 | + $retstring .= "<federation id='" . ($federationid == NULL ? "ALL" : $federationid) . "' ts='" . date("Y-m-d") . "T" . date("H:i:s") . "'>\n"; |
|
| 92 | 92 | foreach ($data as $device => $numbers) { |
| 93 | 93 | if ($device == "TOTAL") { |
| 94 | 94 | continue; |
| 95 | 95 | } |
| 96 | - $retstring .= " <device name='" . $device . "'>\n <downloads group='admin'>".$numbers['ADMIN']."</downloads>\n <downloads group='user'>".$numbers['USER']."</downloads>\n </device>"; |
|
| 96 | + $retstring .= " <device name='" . $device . "'>\n <downloads group='admin'>" . $numbers['ADMIN'] . "</downloads>\n <downloads group='user'>" . $numbers['USER'] . "</downloads>\n </device>"; |
|
| 97 | 97 | } |
| 98 | - $retstring .= "<total>\n <downloads group='admin'>".$data['TOTAL']['ADMIN']."</downloads>\n <downloads group='user'>".$data['TOTAL']['USER']."</downloads>\n</total>\n"; |
|
| 98 | + $retstring .= "<total>\n <downloads group='admin'>" . $data['TOTAL']['ADMIN'] . "</downloads>\n <downloads group='user'>" . $data['TOTAL']['USER'] . "</downloads>\n</total>\n"; |
|
| 99 | 99 | $retstring .= "</federation>"; |
| 100 | 100 | break; |
| 101 | 101 | default: |
@@ -121,16 +121,20 @@ |
||
| 121 | 121 | ]; |
| 122 | 122 | |
| 123 | 123 | $retval = ""; |
| 124 | - if (!$omittabletags) |
|
| 125 | - $retval .= "<tr><td>"; |
|
| 124 | + if (!$omittabletags) { |
|
| 125 | + $retval .= "<tr><td>"; |
|
| 126 | + } |
|
| 126 | 127 | $caption = $caption !== 0 ? $caption : $UI_messages[$level]['text']; |
| 127 | 128 | $retval .= "<img class='icon' src='" . $UI_messages[$level]['icon'] . "' alt='" . $caption . "' title='" . $caption . "'/>"; |
| 128 | - if (!$omittabletags) |
|
| 129 | - $retval .= "</td><td>"; |
|
| 130 | - if ($text !== 0) |
|
| 131 | - $retval .= $text; |
|
| 132 | - if (!$omittabletags) |
|
| 133 | - $retval .= "</td></tr>"; |
|
| 129 | + if (!$omittabletags) { |
|
| 130 | + $retval .= "</td><td>"; |
|
| 131 | + } |
|
| 132 | + if ($text !== 0) { |
|
| 133 | + $retval .= $text; |
|
| 134 | + } |
|
| 135 | + if (!$omittabletags) { |
|
| 136 | + $retval .= "</td></tr>"; |
|
| 137 | + } |
|
| 134 | 138 | return $retval; |
| 135 | 139 | } |
| 136 | 140 | |