summaryrefslogtreecommitdiffstats
path: root/usr/local/www/getserviceproviders.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-04-19 12:23:44 +0545
committerPhil Davis <phil.davis@inf.org>2015-04-19 12:23:44 +0545
commit45b4ffc68fed9e831da10de3b7d2de0c47496d1a (patch)
treeb197e9e651ea5df4f28d33bda408ae8002c38034 /usr/local/www/getserviceproviders.php
parentabaa7feb680dc6f6f9bc79577075c45b3786a061 (diff)
downloadpfsense-45b4ffc68fed9e831da10de3b7d2de0c47496d1a.zip
pfsense-45b4ffc68fed9e831da10de3b7d2de0c47496d1a.tar.gz
Code style usr-local-www back-end
files that do stuff in mostly in the background.
Diffstat (limited to 'usr/local/www/getserviceproviders.php')
-rw-r--r--usr/local/www/getserviceproviders.php91
1 files changed, 46 insertions, 45 deletions
diff --git a/usr/local/www/getserviceproviders.php b/usr/local/www/getserviceproviders.php
index b34e046..40365e6 100644
--- a/usr/local/www/getserviceproviders.php
+++ b/usr/local/www/getserviceproviders.php
@@ -1,30 +1,30 @@
<?php
/*
- getserviceproviders.php
- Copyright (C) 2010 Vinicius Coque <vinicius.coque@bluepex.com>
- Copyright (C) 2013-2015 Electric Sheep Fencing, LP
- All rights reserved.
+ getserviceproviders.php
+ Copyright (C) 2010 Vinicius Coque <vinicius.coque@bluepex.com>
+ Copyright (C) 2013-2015 Electric Sheep Fencing, LP
+ All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_MODULE: ajax
@@ -47,8 +47,8 @@ $serviceproviders = &$serviceproviders_attr['serviceproviders']['country'];
function get_country_providers($country) {
global $serviceproviders;
- foreach($serviceproviders as $sp) {
- if($sp['attr']['code'] == strtolower($country)) {
+ foreach ($serviceproviders as $sp) {
+ if ($sp['attr']['code'] == strtolower($country)) {
return is_array($sp['provider'][0]) ? $sp['provider'] : array($sp['provider']);
}
}
@@ -58,9 +58,9 @@ function get_country_providers($country) {
function country_list() {
global $serviceproviders;
$country_list = get_country_name("ALL");
- foreach($serviceproviders as $sp) {
- foreach($country_list as $country) {
- if(strtoupper($sp['attr']['code']) == $country['code']) {
+ foreach ($serviceproviders as $sp) {
+ foreach ($country_list as $country) {
+ if (strtoupper($sp['attr']['code']) == $country['code']) {
echo $country['name'] . ":" . $country['code'] . "\n";
}
}
@@ -69,7 +69,7 @@ function country_list() {
function providers_list($country) {
$serviceproviders = get_country_providers($country);
- foreach($serviceproviders as $sp) {
+ foreach ($serviceproviders as $sp) {
echo $sp['name']['value'] . "\n";
}
}
@@ -79,29 +79,29 @@ function provider_plan_data($country,$provider,$connection) {
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<connection>\n";
$serviceproviders = get_country_providers($country);
- foreach($serviceproviders as $sp) {
- if(strtolower($sp['name']['value']) == strtolower($provider)) {
- if(strtoupper($connection) == "CDMA") {
+ foreach ($serviceproviders as $sp) {
+ if (strtolower($sp['name']['value']) == strtolower($provider)) {
+ if (strtoupper($connection) == "CDMA") {
$conndata = $sp['cdma'];
} else {
- if(!is_array($sp['gsm']['apn'][0])) {
+ if (!is_array($sp['gsm']['apn'][0])) {
$conndata = $sp['gsm']['apn'];
} else {
- foreach($sp['gsm']['apn'] as $apn) {
- if($apn['attr']['value'] == $connection) {
+ foreach ($sp['gsm']['apn'] as $apn) {
+ if ($apn['attr']['value'] == $connection) {
$conndata = $apn;
break;
}
}
}
}
- if(is_array($conndata)) {
+ if (is_array($conndata)) {
echo "<apn>" . $connection . "</apn>\n";
echo "<username>" . $conndata['username']['value'] . "</username>\n";
echo "<password>" . $conndata['password']['value'] . "</password>\n";
$dns_arr = is_array($conndata['dns'][0]) ? $conndata['dns'] : array( $conndata['dns'] );
- foreach($dns_arr as $dns) {
+ foreach ($dns_arr as $dns) {
echo '<dns>' . $dns['value'] . "</dns>\n";
}
}
@@ -113,20 +113,20 @@ function provider_plan_data($country,$provider,$connection) {
function provider_plans_list($country,$provider) {
$serviceproviders = get_country_providers($country);
- foreach($serviceproviders as $sp) {
- if(strtolower($sp['name']['value']) == strtolower($provider)) {
- if(array_key_exists('gsm',$sp)) {
- if(array_key_exists('attr',$sp['gsm']['apn'])) {
+ foreach ($serviceproviders as $sp) {
+ if (strtolower($sp['name']['value']) == strtolower($provider)) {
+ if (array_key_exists('gsm',$sp)) {
+ if (array_key_exists('attr',$sp['gsm']['apn'])) {
$name = ($sp['gsm']['apn']['name'] ? $sp['gsm']['apn']['name'] : $sp['name']['value']);
echo $name . ":" . $sp['gsm']['apn']['attr']['value'];
} else {
- foreach($sp['gsm']['apn'] as $apn_info) {
+ foreach ($sp['gsm']['apn'] as $apn_info) {
$name = ($apn_info['name']['value'] ? $apn_info['name']['value'] : $apn_info['gsm']['apn']['name']);
echo $name . ":" . $apn_info['attr']['value'] . "\n";
}
}
}
- if(array_key_exists('cdma',$sp)) {
+ if (array_key_exists('cdma',$sp)) {
$name = $sp['cdma']['name']['value'] ? $sp['cdma']['name']['value']:$sp['name']['value'];
echo $name . ":" . "CDMA";
}
@@ -136,13 +136,14 @@ function provider_plans_list($country,$provider) {
$_GET_OR_POST = ($_SERVER['REQUEST_METHOD'] === 'POST') ? $_POST : $_GET;
-if(isset($_GET_OR_POST['country']) && !isset($_GET_OR_POST['provider'])) {
+if (isset($_GET_OR_POST['country']) && !isset($_GET_OR_POST['provider'])) {
providers_list($_GET_OR_POST['country']);
-} elseif(isset($_GET_OR_POST['country']) && isset($_GET_OR_POST['provider'])) {
- if(isset($_GET_OR_POST['plan']))
+} elseif (isset($_GET_OR_POST['country']) && isset($_GET_OR_POST['provider'])) {
+ if (isset($_GET_OR_POST['plan'])) {
provider_plan_data($_GET_OR_POST['country'],$_GET_OR_POST['provider'],$_GET_OR_POST['plan']);
- else
+ } else {
provider_plans_list($_GET_OR_POST['country'],$_GET_OR_POST['provider']);
+ }
} else {
country_list();
}
OpenPOWER on IntegriCloud