open($zipFile); // Create all files & dirs, in 1kb chunks for ($i = 0; $i < $zip->numFiles; $i++) { $name = $zip->getNameIndex($i); // Determine output filename $file = $target . $name; // Create the directories if necessary $dir = dirname($file); if (false === is_dir($dir)) mkdir($dir, 0777, true); // Read from zip and write to disk $fpr = $zip->getStream($name); if (false === is_dir($file)) { $fpw = fopen($file, 'w'); while ($data = fread($fpr, 1024)) { fwrite($fpw, $data); } fclose($fpw); } fclose($fpr); } $zip->close(); // Remove the tmp zip file unlink($zipFile); $ICEcoder["plugins"][] = [ $pluginsData[$_GET['plugin']]['name'], str_replace("images/", "plugins/", $pluginsData[$_GET['plugin']]['icon']), $pluginsData[$_GET['plugin']]['style'], $pluginsData[$_GET['plugin']]['URL'], $pluginsData[$_GET['plugin']]['target'], $pluginsData[$_GET['plugin']]['timer'] ]; } // ============ // UNINSTALLING // ============ if ("uninstall" === $_GET['action']) { // Remove the old plugin for ($i = 0; $i < count($ICEcoder["plugins"]); $i++) { if ($ICEcoder["plugins"][$i][0] === $pluginsData[$_GET['plugin']]['name']) { array_splice($ICEcoder["plugins"], $i, 1); } } // Finally, delete the plugin itself $target = '../plugins/'; $dirName = basename($pluginsData[$_GET['plugin']]['zipURL'], ".zip"); deletePlugin($target . $dirName . "/"); } // ======== // UPDATING // ======== if ("update" === $_GET['action']) { // Redo the arrays using the form data $numPlugins = count($ICEcoder["plugins"]); for ($i = 0; $i < $numPlugins; $i++) { $timer = intval($_POST['timer' . $i]); if (0 === $timer) { $timer = ""; } $ICEcoder["plugins"][$i] = [ $_POST['name' . $i], $_POST['icon' . $i], $_POST['style' . $i], $_POST['URL' . $i], $_POST['target' . $i], $timer ]; } } // Now update the config file if (true === $settingsClass->updateConfigUsersSettings($settingsFile, ["plugins" => $ICEcoder['plugins']])) { // Finally, reload ICEcoder itself if plugin requires it or just the iFrame screen for the user if it doesn't if ("install" === $_GET['action'] && "true" === $pluginsData[$_GET['plugin']]['reload']) { echo ""; } else { header("Location: plugins-manager.php?updatedPlugins&csrf=" . $_SESSION["csrf"]); echo ""; } exit; // die("" . $t['saving plugins'] . ""); } else { echo ""; } } // Function to delete the plugin dir & files/dirs inside function deletePlugin($dir) { global $t; $theDir = opendir($dir); while(false !== ($file = readdir($theDir))) { if($file !== "." && $file !== "..") { chmod($dir . $file, 0777); if(is_dir($dir . $file)) { chdir('.'); deletePlugin($dir . $file . '/'); if(is_dir($dir . $file)) { rmdir($dir . $file) or die("" . $t['couldnt delete dir'] . ": $dir$file
"); } } else { unlink($dir . $file) or die("" . $t['couldnt delete file'] . ": $dir$file
"); } } } closedir($theDir); rmdir($dir); } $assetsPath = "assets" === $settingsClass->assetsRoot ? "../" . $settingsClass->assetsRoot : $settingsClass->assetsRoot ?> ICEcoder <?php echo $ICEcoder["versionNo"];?> plugins manager

','plugins')" style="position: absolute; top: 26px; right: 20px">


'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; echo ''; echo ''; ?>
' . $plugins[$i][0] .
                            '' . $plugins[$i][0] . '
' . $t['Update'] . '
">


' . PHP_EOL; } $installUninstallButton = '
' . $t['Install'] . '
'; for ($j = 0; $j < count($plugins); $j++) { if ($pluginsData[$i]['name'] == $plugins[$j][0]) { $installUninstallButton = '
' . $t['Uninstall'] . '
'; } } $reloadExtra = "true" === $pluginsData[$i]['reload'] ? '
' . $t['Reload after install...'] . '' : ''; echo ''; echo ''; $styleExtra = (1 === $i % 2 || $i === count($pluginsData) - 1) ? "0" : "30px"; echo ''; if (1 === $i % 2 || $i == count($pluginsData) - 1) { echo PHP_EOL . '' . PHP_EOL; } } ?>
'.$pluginsData[$i]['name'] . '' . $pluginsData[$i]['name'] . $reloadExtra . '' . $installUninstallButton . '
getDemoModeIndicator(true); ?>