Skip to content

Commit

Permalink
Replace potentially dangerous list() = each() constructs with foreach…
Browse files Browse the repository at this point in the history
… to avoid problems like one described in #630.
  • Loading branch information
trustmaster committed Apr 3, 2011
1 parent 254e446 commit 74ec1a4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugins/adminqv/adminqv.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
$tables[] = $status1; $tables[] = $status1;
} }


while(list($i,$dat) = each($tables)) foreach ($tables as $dat)
{ {
$table_length = $dat['Index_length']+$dat['Data_length']; $table_length = $dat['Index_length']+$dat['Data_length'];
$total_length += $table_length; $total_length += $table_length;
Expand Down
6 changes: 3 additions & 3 deletions system/core/admin/admin.plug.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
/* === Hook - Part1 : Set === */ /* === Hook - Part1 : Set === */
$extp = sed_getextplugins('admin.plug.details.part.loop'); $extp = sed_getextplugins('admin.plug.details.part.loop');
/* ===== */ /* ===== */
while(list($i, $x) = each($parts)) foreach ($parts as $i => $x)
{ {
$extplugin_file = $cfg['plugins_dir']."/".$pl."/".$x; $extplugin_file = $cfg['plugins_dir']."/".$pl."/".$x;
$info_file = sed_infoget($extplugin_file, 'SED_EXTPLUGIN'); $info_file = sed_infoget($extplugin_file, 'SED_EXTPLUGIN');
Expand Down Expand Up @@ -288,7 +288,7 @@


if(count($parts) > 0) if(count($parts) > 0)
{ {
while(list($i, $x) = each($parts)) foreach ($parts as $i => $x)
{ {
$extplugin_file = $cfg['plugins_dir']."/".$pl."/".$x; $extplugin_file = $cfg['plugins_dir']."/".$pl."/".$x;
$info_part = sed_infoget($extplugin_file, 'SED_EXTPLUGIN'); $info_part = sed_infoget($extplugin_file, 'SED_EXTPLUGIN');
Expand Down Expand Up @@ -569,7 +569,7 @@
/* === Hook - Part1 : Set === */ /* === Hook - Part1 : Set === */
$extp = sed_getextplugins('admin.plug.list.loop'); $extp = sed_getextplugins('admin.plug.list.loop');
/* ===== */ /* ===== */
while(list($i, $x) = each($extplugins)) foreach($extplugins as $i => $x)
{ {
$extplugin_info = $cfg['plugins_dir']."/".$x."/".$x.".setup.php"; $extplugin_info = $cfg['plugins_dir']."/".$x."/".$x.".setup.php";
if(file_exists($extplugin_info)) if(file_exists($extplugin_info))
Expand Down
2 changes: 1 addition & 1 deletion system/core/admin/admin.tools.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function cmp($a, $b, $k = 1)


usort($plugins, "cmp"); usort($plugins, "cmp");


while(list($i, $x) = each($plugins)) foreach($plugins as $i => $x)
{ {
$extplugin_info = $cfg['plugins_dir']."/".$x[0]."/".$x[0].".setup.php"; $extplugin_info = $cfg['plugins_dir']."/".$x[0]."/".$x[0].".setup.php";


Expand Down
2 changes: 1 addition & 1 deletion system/core/list/list.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
$extp = sed_getextplugins('list.rowcat.loop'); $extp = sed_getextplugins('list.rowcat.loop');
/* ===== */ /* ===== */


while (list($i,$x) = each($sed_cat)) foreach ($sed_cat as $i => $x)
{ {
if(mb_substr($x['path'],0,$mtchlen)==$mtch && mb_substr_count($x['path'],".")==$mtchlvl && $mm<$dc) if(mb_substr($x['path'],0,$mtchlen)==$mtch && mb_substr_count($x['path'],".")==$mtchlvl && $mm<$dc)
{ {
Expand Down
4 changes: 2 additions & 2 deletions system/functions.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ function sed_selectbox_lang($check, $name)
sort($langlist); sort($langlist);


$result = "<select name=\"$name\" size=\"1\">"; $result = "<select name=\"$name\" size=\"1\">";
while(list($i,$x) = each($langlist)) foreach ($langlist as $i => $x)
{ {
$selected = ($x==$check) ? "selected=\"selected\"" : ''; $selected = ($x==$check) ? "selected=\"selected\"" : '';
$lng = (empty($sed_languages[$x])) ? $sed_countries[$x] : $sed_languages[$x]; $lng = (empty($sed_languages[$x])) ? $sed_countries[$x] : $sed_languages[$x];
Expand Down Expand Up @@ -3775,7 +3775,7 @@ function sed_selectbox_skin($check, $name)
sort($skinlist); sort($skinlist);


$result = '<select name="'.$name.'" size="1">'; $result = '<select name="'.$name.'" size="1">';
while(list($i,$x) = each($skinlist)) foreach($skinlist as $i => $x)
{ {
$selected = ($x==$check) ? 'selected="selected"' : ''; $selected = ($x==$check) ? 'selected="selected"' : '';
$skininfo = "skins/$x/$x.php"; $skininfo = "skins/$x/$x.php";
Expand Down

0 comments on commit 74ec1a4

Please sign in to comment.