Use php for all file system access

Add array for tetra / nano compatability
Clean up string constants
pull/67/head
noncenz 2019-07-24 18:00:50 -04:00
parent 6bcdc90fc6
commit 73c56743be
2 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,9 @@
<?php namespace pineapple; <?php namespace pineapple;
define('__MODULE_LOCATION__', "/pineapple/modules/SSIDManager/");
define('__SSID_FILES__', __MODULE_LOCATION__ . "SSID_Files/");
define('__MODULE_INFO__', __MODULE_LOCATION__ . "module.info");
/* The class name must be the name of your module, without spaces. */ /* The class name must be the name of your module, without spaces. */
/* It must also extend the "Module" class. This gives your module access to API functions */ /* It must also extend the "Module" class. This gives your module access to API functions */
class SSIDManager extends Module class SSIDManager extends Module
@ -36,16 +40,15 @@ class SSIDManager extends Module
private function SSIDDirectoryPath() private function SSIDDirectoryPath()
{ {
$path = '/pineapple/modules/SSIDManager/SSID_Files/'; if (!file_exists(__SSID_FILES__)) {
if (!file_exists($path)) { mkdir(__SSID_FILES__, 0755, true);
exec("mkdir ".$path);
} }
return '/pineapple/modules/SSIDManager/SSID_Files/'; return __SSID_FILES__;
} }
private function getContents() private function getContents()
{ {
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/SSIDManager/module.info")); $moduleInfo = @json_decode(file_get_contents(__MODULE_INFO__));
$this->response = array("success" => true, $this->response = array("success" => true,
"version" => "version " . $moduleInfo->version, "version" => "version " . $moduleInfo->version,
@ -79,7 +82,7 @@ class SSIDManager extends Module
private function deleteSSIDFile() private function deleteSSIDFile()
{ {
exec("rm -rf " . $this->SSIDDirectoryPath() ."'" . $this->request->file . "'"); unlink($this->SSIDDirectoryPath() . $this->request->file);
$this->response = array("success" => true); $this->response = array("success" => true);
} }

View File

@ -2,5 +2,9 @@
"title": "SSID Manager", "title": "SSID Manager",
"description": "Manage SSID Pools for PineAP", "description": "Manage SSID Pools for PineAP",
"version": "1.0", "version": "1.0",
"author": "noncenz" "author": "noncenz",
"devices": [
"nano",
"tetra"
]
} }