Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 39388dd

Browse files
author
mattpass
committed
array_splice, numPlugins to avoid extending loop cond, use i in array, exit dont die with msg
1 parent f544603 commit 39388dd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/plugins-manager.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@
7474
// ============
7575
// UNINSTALLING
7676
// ============
77-
7877
if ("uninstall" === $_GET['action']) {
7978
// Remove the old plugin
8079
for ($i = 0; $i < count($ICEcoder["plugins"]); $i++) {
8180
if ($ICEcoder["plugins"][$i][0] === $pluginsData[$_GET['plugin']]['name']) {
82-
unset($ICEcoder["plugins"][$i]);
81+
array_splice($ICEcoder["plugins"], $i, 1);
8382
}
8483
}
8584

@@ -95,12 +94,13 @@
9594

9695
if ("update" === $_GET['action']) {
9796
// Redo the arrays using the form data
98-
for ($i = 0; $i < count($ICEcoder["plugins"]); $i++) {
97+
$numPlugins = count($ICEcoder["plugins"]);
98+
for ($i = 0; $i < $numPlugins; $i++) {
9999
$timer = intval($_POST['timer' . $i]);
100-
if ($timer == 0) {
100+
if (0 === $timer) {
101101
$timer = "";
102102
}
103-
$ICEcoder["plugins"][] = [
103+
$ICEcoder["plugins"][$i] = [
104104
$_POST['name' . $i],
105105
$_POST['icon' . $i],
106106
$_POST['style' . $i],
@@ -120,7 +120,8 @@
120120
header("Location: plugins-manager.php?updatedPlugins&csrf=" . $_SESSION["csrf"]);
121121
echo "<script>window.location = 'plugins-manager.php?updatedPlugins&csrf=' + ICEcoder.csrf;</script>";
122122
}
123-
die("<span style='color: #fff'>" . $t['saving plugins'] . "</span>");
123+
exit;
124+
// die("<span style='color: #fff'>" . $t['saving plugins'] . "</span>");
124125
} else {
125126
echo "<script>parent.ICEcoder.message('" . $t['Cannot update config...'] . " data/" . $settingsFile . " " . $t['and try again'] . "');</script>";
126127
}

0 commit comments

Comments
 (0)