Created
April 22, 2015 17:53
-
-
Save joboscribe/317797763b3681af069a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // get network-related information to determine if it can be upgrated to 5xx firmware | |
| $myquery = <<<SQL | |
| SELECT | |
| COUNT(*) AS NODE_COUNT, | |
| ( | |
| SELECT | |
| COUNT(*) | |
| FROM nodesdb | |
| WHERE | |
| ACCOUNT='$account' | |
| AND TIME > SUBDATE(NOW(),INTERVAL 30 MINUTE) | |
| ) AS UP_COUNT, | |
| ( | |
| SELECT | |
| COUNT(*) | |
| FROM nodesdb | |
| WHERE | |
| ACCOUNT='$account' | |
| AND ( TIME > SUBDATE(NOW(),INTERVAL 30 MINUTE) OR BUILD LIKE 'fw-ng-r481%') | |
| ) AS UP_481_COUNT, | |
| ( | |
| SELECT | |
| COUNT(*) OLD | |
| FROM | |
| ( | |
| SELECT | |
| CAST(CONV(REPLACE(TRIM(LOWER(n.MAC)),':',''),16,10) AS UNSIGNED) AS MAC_INT, | |
| HW | |
| FROM nodesdb n | |
| WHERE | |
| ACCOUNT='$account' | |
| ) nn | |
| WHERE | |
| ( | |
| MAC_INT >= 189693471817728 | |
| AND MAC_INT <= 189693472064256 | |
| ) | |
| OR HW='generic_ap51' | |
| OR HW='OM1P' | |
| OR HW='MR500' | |
| ) AS OLD, | |
| accounts.captive_portal, | |
| accounts.firmware_release | |
| FROM | |
| nodesdb | |
| JOIN | |
| accounts | |
| on | |
| accounts.account = nodesdb.account | |
| WHERE | |
| nodesdb.ACCOUNT = '$account' | |
| SQL; | |
| $upgradeQuery = $db->prepare($myquery); | |
| $upgradeQuery->execute(); | |
| $upgradeInfo = $upgradeQuery->fetch(PDO::FETCH_ASSOC); | |
| // see if network is already set to run latest firmware | |
| $upgraded = false; | |
| if ($upgradeInfo['firmware_release'] === "testing") { | |
| $upgraded = true; | |
| } | |
| // evaluate network information to see if it can be upgraded | |
| $upgradeIssues = []; | |
| if ($upgradeInfo['OLD'] > 1) { | |
| array_push($upgradeIssues, "You have one or more access points that are not upgradeable. These may include generic_ap51, OM1P, MR500 or older OM2P APs. Please try again once these are removed from your network."); | |
| } | |
| if (($upgradeInfo['captive_portal'] == "coova") || ($upgradeInfo['captive_portal'] == "coovaom")) { | |
| array_push($upgradeIssues, "Your current captive portal is CoovaChilli, which is not available in the upgraded firmware. Please select a different captive portal configuration and try again."); | |
| } | |
| if ($upgradeInfo['UP_COUNT'] != $upgradeInfo['UP_481']) { | |
| array_push($upgradeIssues, "Some access points are running an older firmware version that requires them to be online before the upgrade can start. Please bring them online or remove them from the network."); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment