Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share the same code with differents methods. #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 20 additions & 40 deletions mmdvmhost/functions.php
Original file line number Diff line number Diff line change
@@ -1,62 +1,42 @@
<?php

/**
* Parses config file into array.
*/
function getConfigFromFile($file) {
$conf = array();
if ($configs = @fopen($file, 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
}

function getMMDVMConfig() {
// loads /etc/mmdvmhost into array for further use
$conf = array();
if ($configs = @fopen(MMDVMINIPATH."/".MMDVMINIFILENAME, 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
return getConfigFromFile(MMDVMINIPATH."/".MMDVMINIFILENAME);
}

function getYSFGatewayConfig() {
// loads /etc/ysfgateway into array for further use
$conf = array();
if ($configs = @fopen(YSFGATEWAYINIPATH."/".YSFGATEWAYINIFILENAME, 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
return getConfigFromFile(YSFGATEWAYINIPATH."/".YSFGATEWAYINIFILENAME);
}

function getP25GatewayConfig() {
// loads /etc/p25gateway into array for further use
$conf = array();
if ($configs = @fopen(P25GATEWAYINIPATH."/".P25GATEWAYINIFILENAME, 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
return getConfigFromFile(P25GATEWAYINIPATH."/".P25GATEWAYINIFILENAME);
}

function getNXDNGatewayConfig() {
// loads /etc/nxdngateway into array for further use
$conf = array();
if ($configs = @fopen('/etc/nxdngateway', 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
return getConfigFromFile('/etc/nxdngateway');
}

function getDAPNETGatewayConfig() {
// loads /etc/dapnetgateway into array for further use
$conf = array();
if ($configs = @fopen('/etc/dapnetgateway', 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
return getConfigFromFile('/etc/dapnetgateway');
}

function getConfigItem($section, $key, $configs) {
Expand Down