|
|
@@ -2,8 +2,8 @@
|
|
|
|
|
|
function execBackground($command)
|
|
|
{
|
|
|
- exec("echo \"{$command}\" | /usr/bin/at now", $var);
|
|
|
- return $var;
|
|
|
+ exec("echo \"{$command}\" | /usr/bin/at now", $var);
|
|
|
+ return $var;
|
|
|
}
|
|
|
|
|
|
function checkDependency($dependencyName)
|
|
|
@@ -19,127 +19,127 @@ function isSDAvailable()
|
|
|
}
|
|
|
|
|
|
function sdReaderPresent() {
|
|
|
- return file_exists('/sd');
|
|
|
+ return file_exists('/sd');
|
|
|
}
|
|
|
|
|
|
function sdCardPresent() {
|
|
|
- return !file_exists('/sd/NO_SD');
|
|
|
+ return !file_exists('/sd/NO_SD');
|
|
|
}
|
|
|
|
|
|
function checkRunning($processName)
|
|
|
{
|
|
|
- $processName = escapeshellarg($processName);
|
|
|
- exec("/usr/bin/pgrep {$processName}", $output);
|
|
|
- return count($output) > 0;
|
|
|
+ $processName = escapeshellarg($processName);
|
|
|
+ exec("/usr/bin/pgrep {$processName}", $output);
|
|
|
+ return count($output) > 0;
|
|
|
}
|
|
|
|
|
|
function checkRunningFull($processString) {
|
|
|
- $processString = escapeshellarg($processString);
|
|
|
- exec("/usr/bin/pgrep -f {$processString}", $output);
|
|
|
- return count($output) > 0;
|
|
|
+ $processString = escapeshellarg($processString);
|
|
|
+ exec("/usr/bin/pgrep -f {$processString}", $output);
|
|
|
+ return count($output) > 0;
|
|
|
}
|
|
|
|
|
|
function udsSend($path, $message)
|
|
|
{
|
|
|
- $sock = stream_socket_client("unix://{$path}", $errno, $errstr);
|
|
|
- fwrite($sock, $message);
|
|
|
- fclose($sock);
|
|
|
- return true;
|
|
|
+ $sock = stream_socket_client("unix://{$path}", $errno, $errstr);
|
|
|
+ fwrite($sock, $message);
|
|
|
+ fclose($sock);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
function dgramUdsSend($path, $message)
|
|
|
{
|
|
|
- $sock = NULL;
|
|
|
- if(!($sock = socket_create(AF_UNIX, SOCK_DGRAM, 0))) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- socket_sendto($sock, $message, strlen($message), 0, $path);
|
|
|
- return true;
|
|
|
+ $sock = NULL;
|
|
|
+ if(!($sock = socket_create(AF_UNIX, SOCK_DGRAM, 0))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ socket_sendto($sock, $message, strlen($message), 0, $path);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
function uciGet($uciString, $autoBool = true)
|
|
|
{
|
|
|
- $uciString = escapeshellarg($uciString);
|
|
|
- $result = exec("uci get {$uciString}");
|
|
|
- if ($autoBool && ($result === "0" || $result === "1")) {
|
|
|
- return $result === "1";
|
|
|
- }
|
|
|
+ $uciString = escapeshellarg($uciString);
|
|
|
+ $result = exec("uci get {$uciString}");
|
|
|
+ if ($autoBool && ($result === "0" || $result === "1")) {
|
|
|
+ return $result === "1";
|
|
|
+ }
|
|
|
|
|
|
- return $result;
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
function uciSet($settingString, $value)
|
|
|
{
|
|
|
- $settingString = escapeshellarg($settingString);
|
|
|
- if (!empty($value)) {
|
|
|
- $value = escapeshellarg($value);
|
|
|
- }
|
|
|
+ $settingString = escapeshellarg($settingString);
|
|
|
+ if (!empty($value)) {
|
|
|
+ $value = escapeshellarg($value);
|
|
|
+ }
|
|
|
|
|
|
- if ($value === "''" || $value === "") {
|
|
|
- $value = "'0'";
|
|
|
- }
|
|
|
+ if ($value === "''" || $value === "") {
|
|
|
+ $value = "'0'";
|
|
|
+ }
|
|
|
|
|
|
- exec("uci set {$settingString}={$value}");
|
|
|
- exec("uci commit {$settingString}");
|
|
|
+ exec("uci set {$settingString}={$value}");
|
|
|
+ exec("uci commit {$settingString}");
|
|
|
}
|
|
|
|
|
|
function uciAddList($settingString, $value)
|
|
|
{
|
|
|
- $settingString = escapeshellarg($settingString);
|
|
|
- if (!empty($value)) {
|
|
|
- $value = escapeshellarg($value);
|
|
|
- }
|
|
|
+ $settingString = escapeshellarg($settingString);
|
|
|
+ if (!empty($value)) {
|
|
|
+ $value = escapeshellarg($value);
|
|
|
+ }
|
|
|
|
|
|
- if ($value === "''") {
|
|
|
- $value = "'0'";
|
|
|
- }
|
|
|
+ if ($value === "''") {
|
|
|
+ $value = "'0'";
|
|
|
+ }
|
|
|
|
|
|
- exec("uci add_list {$settingString}={$value}");
|
|
|
- exec("uci commit {$settingString}");
|
|
|
+ exec("uci add_list {$settingString}={$value}");
|
|
|
+ exec("uci commit {$settingString}");
|
|
|
}
|
|
|
|
|
|
function downloadFile($file)
|
|
|
{
|
|
|
- $token = hash('sha256', $file . time());
|
|
|
+ $token = hash('sha256', $file . time());
|
|
|
|
|
|
- require_once('DatabaseConnection.php');
|
|
|
- $database = new \pineapple\DatabaseConnection("/etc/pineapple/pineapple.db");
|
|
|
- $database->exec("CREATE TABLE IF NOT EXISTS downloads (token VARCHAR NOT NULL, file VARCHAR NOT NULL, time timestamp default (strftime('%s', 'now')));");
|
|
|
- $database->exec("INSERT INTO downloads (token, file) VALUES ('%s', '%s')", $token, $file);
|
|
|
+ require_once('DatabaseConnection.php');
|
|
|
+ $database = new \pineapple\DatabaseConnection("/etc/pineapple/pineapple.db");
|
|
|
+ $database->exec("CREATE TABLE IF NOT EXISTS downloads (token VARCHAR NOT NULL, file VARCHAR NOT NULL, time timestamp default (strftime('%s', 'now')));");
|
|
|
+ $database->exec("INSERT INTO downloads (token, file) VALUES ('%s', '%s')", $token, $file);
|
|
|
|
|
|
- return $token;
|
|
|
+ return $token;
|
|
|
}
|
|
|
|
|
|
function getFirmwareVersion()
|
|
|
{
|
|
|
- return trim(file_get_contents('/etc/pineapple/pineapple_version'));
|
|
|
+ return trim(file_get_contents('/etc/pineapple/pineapple_version'));
|
|
|
}
|
|
|
|
|
|
function getDevice()
|
|
|
{
|
|
|
- $data = file_get_contents('/proc/cpuinfo');
|
|
|
- if (preg_match('/NANO/', $data)) {
|
|
|
- return 'nano';
|
|
|
- } elseif (preg_match('/TETRA/', $data)) {
|
|
|
- return 'tetra';
|
|
|
- }
|
|
|
- return 'unknown';
|
|
|
+ $data = file_get_contents('/proc/cpuinfo');
|
|
|
+ if (preg_match('/NANO/', $data)) {
|
|
|
+ return 'nano';
|
|
|
+ } elseif (preg_match('/TETRA/', $data)) {
|
|
|
+ return 'tetra';
|
|
|
+ }
|
|
|
+ return 'unknown';
|
|
|
}
|
|
|
|
|
|
function getMacFromInterface($interface)
|
|
|
{
|
|
|
- $interface = escapeshellarg($interface);
|
|
|
- return trim(exec("ifconfig {$interface} | grep HWaddr | awk '{print $5}'"));
|
|
|
+ $interface = escapeshellarg($interface);
|
|
|
+ return trim(exec("ifconfig {$interface} | grep HWaddr | awk '{print $5}'"));
|
|
|
}
|
|
|
|
|
|
function getBoard()
|
|
|
{
|
|
|
- $data = @file_get_contents('/tmp/sysinfo/board_name');
|
|
|
- if (!empty($data)) {
|
|
|
- $parts = explode(',', $data);
|
|
|
+ $data = file_get_contents('/tmp/sysinfo/board_name');
|
|
|
+ if (!empty($data)) {
|
|
|
+ $parts = explode(',', trim($data));
|
|
|
|
|
|
- return isset($parts[1]) ? $parts[1] : $parts[0];
|
|
|
- }
|
|
|
+ return isset($parts[1]) ? $parts[1] : $parts[0];
|
|
|
+ }
|
|
|
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|