diff --git a/.gitignore b/.gitignore index 07267b56..247dda6e 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,9 @@ system/lan/** !system/lan/turkish.json !system/lan/english.json !system/lan/country.json -*.zip \ No newline at end of file +*.zip +system/devices/** +!system/devices/readme.md +!system/devices/Radius.php +!system/devices/MikrotikPppoe.php +!system/devices/MikrotikHotspot.php \ No newline at end of file diff --git a/system/controllers/pluginmanager.php b/system/controllers/pluginmanager.php index a289e0bf..db2d4709 100644 --- a/system/controllers/pluginmanager.php +++ b/system/controllers/pluginmanager.php @@ -33,6 +33,83 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { $json = json_decode($data, true); } switch ($action) { + case 'dlinstall': + if (!is_writeable($CACHE_PATH)) { + r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable'); + } + if (!is_writeable($PLUGIN_PATH)) { + r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); + } + if (!is_writeable($DEVICE_PATH)) { + r2(U . "pluginmanager", 'e', 'Folder devices/ is not writable'); + } + if (!is_writeable($UI_PATH . DIRECTORY_SEPARATOR . 'themes')) { + r2(U . "pluginmanager", 'e', 'Folder themes/ is not writable'); + } + $cache = $CACHE_PATH . DIRECTORY_SEPARATOR . 'installer' . DIRECTORY_SEPARATOR; + if (!file_exists($cache)) { + mkdir($cache); + } + if (file_exists($_FILES['zip_plugin']['tmp_name'])) { + $zip = new ZipArchive(); + $zip->open($_FILES['zip_plugin']['tmp_name']); + $zip->extractTo($cache); + $zip->close(); + unlink($_FILES['zip_plugin']['tmp_name']); + //moving + if (file_exists($cache . 'plugin')) { + File::copyFolder($cache . 'plugin' . DIRECTORY_SEPARATOR, $PLUGIN_PATH . DIRECTORY_SEPARATOR); + } + if (file_exists($cache . 'paymentgateway')) { + File::copyFolder($cache . 'paymentgateway' . DIRECTORY_SEPARATOR, $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR); + } + if (file_exists($cache . 'theme')) { + File::copyFolder($cache . 'theme' . DIRECTORY_SEPARATOR, $UI_PATH . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR); + } + if (file_exists($cache . 'device')) { + File::copyFolder($cache . 'device' . DIRECTORY_SEPARATOR, $DEVICE_PATH . DIRECTORY_SEPARATOR); + } + //Cleaning + File::deleteFolder($cache); + r2(U . "pluginmanager", 's', 'Installation success'); + } else if (_post('gh_url', '') != '') { + $ghUrl = _post('gh_url', ''); + $plugin = basename($ghUrl); + $file = $cache . $plugin . '.zip'; + $fp = fopen($file, 'w+'); + $ch = curl_init($ghUrl . '/archive/refs/heads/master.zip'); + curl_setopt($ch, CURLOPT_POST, 0); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); + curl_setopt($ch, CURLOPT_TIMEOUT, 15); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); + curl_close($ch); + fclose($fp); + $zip = new ZipArchive(); + $zip->open($file); + $zip->extractTo($cache); + $zip->close(); + $folder = $cache . DIRECTORY_SEPARATOR . $plugin . '-main' . DIRECTORY_SEPARATOR; + if (file_exists($folder . 'plugin')) { + File::copyFolder($folder . 'plugin' . DIRECTORY_SEPARATOR, $PLUGIN_PATH . DIRECTORY_SEPARATOR); + } + if (file_exists($folder . 'paymentgateway')) { + File::copyFolder($folder . 'paymentgateway' . DIRECTORY_SEPARATOR, $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR); + } + if (file_exists($folder . 'theme')) { + File::copyFolder($folder . 'theme' . DIRECTORY_SEPARATOR, $UI_PATH . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR); + } + if (file_exists($folder . 'device')) { + File::copyFolder($folder . 'device' . DIRECTORY_SEPARATOR, $DEVICE_PATH . DIRECTORY_SEPARATOR); + } + File::deleteFolder($cache); + r2(U . "pluginmanager", 's', 'Installation success'); + } else { + r2(U . 'pluginmanager', 'e', 'Nothing Installed'); + } + break; case 'delete': if (!is_writeable($CACHE_PATH)) { r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable'); @@ -180,17 +257,17 @@ function scanAndRemovePath($source, $target) $files = scandir($source); foreach ($files as $file) { if (is_file($source . $file)) { - if(file_exists($target.$file)){ + if (file_exists($target . $file)) { unlink($target . $file); } } else if (is_dir($source . $file) && !in_array($file, ['.', '..'])) { - scanAndRemovePath($source. $file. DIRECTORY_SEPARATOR, $target. $file. DIRECTORY_SEPARATOR); - if(file_exists($target.$file)){ + scanAndRemovePath($source . $file . DIRECTORY_SEPARATOR, $target . $file . DIRECTORY_SEPARATOR); + if (file_exists($target . $file)) { rmdir($target . $file); } } } - if(file_exists($target)){ + if (file_exists($target)) { rmdir($target); } -} \ No newline at end of file +} diff --git a/system/lan/english.json b/system/lan/english.json index 22dcb8d8..07b5245f 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -635,5 +635,6 @@ "": "", "Device": "Device", "Expired_Internet_Plan": "Expired Internet Plan", - "When_Expired__customer_will_be_move_to_selected_internet_plan": "When Expired, customer will be move to selected internet plan" + "When_Expired__customer_will_be_move_to_selected_internet_plan": "When Expired, customer will be move to selected internet plan", + "Plugin_Installer": "Plugin Installer" } \ No newline at end of file diff --git a/ui/ui/plugin-manager.tpl b/ui/ui/plugin-manager.tpl index 90ce2d1b..a8015acc 100644 --- a/ui/ui/plugin-manager.tpl +++ b/ui/ui/plugin-manager.tpl @@ -1,72 +1,99 @@ {include file="sections/header.tpl"} -
-
-
-
{Lang::T('Plugin')}
-
- {foreach $plugins as $plugin} -
-
-
-

{$plugin['name']}

-
-
-
{$plugin['description']}
-
- -
-
- {/foreach} + +
+
+
+ {Lang::T('Plugin Installer')} +
+
-
-
{Lang::T('Payment Gateway')}
-
- {foreach $pgs as $pg} -
-
-
-

{$pg['name']}

-
-
-
{$pg['description']}
-
- -
-
- {/foreach} +
+
+ + +
+
+ + +
+
+
+
+ + +
+
{Lang::T('Plugin')}
+
+ {foreach $plugins as $plugin} +
+
+
+

{$plugin['name']}

+
+
+
{$plugin['description']}
+
+ +
+
+ {/foreach} +
+
+
+
{Lang::T('Payment Gateway')}
+
+ {foreach $pgs as $pg} +
+
+
+

{$pg['name']}

+
+
+
{$pg['description']}
+
+ +
+
+ {/foreach} +
+
{include file="sections/footer.tpl"} \ No newline at end of file