From 22353619c2215ad7831d705adead862c9bf788f2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 9 Sep 2006 23:04:41 +0000 Subject: [PATCH] r1138: Changed array casting to be is_array() --- admin/product.php | 27 ++++++++------- attachment.php | 2 +- editreport.php | 14 +++++--- explain.php | 84 +++++++++++++++++++++++++++-------------------- userctrl.php | 16 ++++++--- 5 files changed, 85 insertions(+), 58 deletions(-) diff --git a/admin/product.php b/admin/product.php index 5d42b1f..132b6ae 100755 --- a/admin/product.php +++ b/admin/product.php @@ -352,8 +352,9 @@ EOF; $admin->form_start('product.php', 'displayorder'); - $products = $db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); - while ($prod = $db->fetch_array($products)) + $products_get = $db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); + $products = array(); + while ($prod = $db->fetch_array($products_get)) { if (!$prod['componentmother']) { @@ -365,14 +366,13 @@ EOF; } $version["$prod[productid]"] = array(); } - $products = (array)$product; - $versions = $db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC"); - while ($vers = $db->fetch_array($versions)) + $versions_get = $db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC"); + $versions = array(); + while ($vers = $db->fetch_array($versions_get)) { $version["$vers[productid]"]["$vers[versionid]"] = $vers; } - $versions = (array)$version; $admin->table_start(); $admin->table_head(_('Products / Versions')); @@ -400,14 +400,17 @@ EOF; } // Components - foreach ((array)$component["$product[productid]"] AS $comp) + if (is_array($component["$product[productid]"])) { - $admin->row_text("-- $comp[title]", construct_option_list(_('Component'), $comp['productid'], 1, 0, 1, 1, $comp['displayorder']), 'middle', 2, 'alt1'); - - // Component versions - foreach ($versions["$comp[productid]"] AS $version) + foreach ($component["$product[productid]"] AS $comp) { - $admin->row_text('---- ' . $version['version'], construct_option_list(_('Version'), $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2'); + $admin->row_text("-- $comp[title]", construct_option_list(_('Component'), $comp['productid'], 1, 0, 1, 1, $comp['displayorder']), 'middle', 2, 'alt1'); + + // Component versions + foreach ($versions["$comp[productid]"] AS $version) + { + $admin->row_text('---- ' . $version['version'], construct_option_list(_('Version'), $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2'); + } } } } diff --git a/attachment.php b/attachment.php index 9303412..47899f2 100755 --- a/attachment.php +++ b/attachment.php @@ -183,7 +183,7 @@ if ($_REQUEST['do'] == 'add') while ($obsolete = $db->fetch_array($obsoletes_fetch)) { $show['obsoletes'] = true; - $obsoletes .= "
in['obsoletes']) ? ' checked="checked"' : '') . " /> $obsolete[filename]" . ($obsolete['description'] ? " [$obsolete[description]]" : '') . "
\n"; + $obsoletes .= "
in['obsoletes']) AND in_array($obsolete['attachmentid'], $bugsys->in['obsoletes']) ? ' checked="checked"' : '') . " /> $obsolete[filename]" . ($obsolete['description'] ? " [$obsolete[description]]" : '') . "
\n"; } eval('$template->flush("' . $template->fetch('newattach') . '");'); diff --git a/editreport.php b/editreport.php index 4dbbbb4..d92ed30 100644 --- a/editreport.php +++ b/editreport.php @@ -124,14 +124,20 @@ if ($_POST['do'] == 'update') { $autoaction['fields'] = unserialize($autoaction['fieldchanges']); - foreach ((array)$autoaction['fields']['builtin'] AS $field => $value) + if (is_array($autoaction['fields']['builtin'])) { - $bugsys->in["$field"] = $value; + foreach ($autoaction['fields']['builtin'] AS $field => $value) + { + $bugsys->in["$field"] = $value; + } } - foreach ((array)$autoaction['fields']['custom'] AS $field => $value) + if (is_array($autoaction['fields']['custom'])) { - $bugsys->in["field$field"] = $value; + foreach ($autoaction['fields']['custom'] AS $field => $value) + { + $bugsys->in["field$field"] = $value; + } } } diff --git a/explain.php b/explain.php index 805fca4..8f55147 100644 --- a/explain.php +++ b/explain.php @@ -60,11 +60,14 @@ if ($_REQUEST['do'] == 'products') } // global versions - foreach ($versions['0'] AS $version) + if (is_array($versions['0'])) { - $left = $version['version']; - $right = null; - eval('$globalversions .= "' . $template->fetch('explain_row') . '";'); + foreach ($versions['0'] AS $version) + { + $left = $version['version']; + $right = null; + eval('$globalversions .= "' . $template->fetch('explain_row') . '";'); + } } foreach ($products AS $product) @@ -102,45 +105,54 @@ if ($_REQUEST['do'] == 'autoactions') { $fields["$field[fieldid]"] = $field; } - - foreach ((array)$bugsys->datastore['autoaction'] AS $autoaction) + + if (is_array($bugsys->datastore['autoaction'])) { - $autoaction['fieldchanges'] = unserialize($autoaction['fieldchanges']); - - $left = $autoaction['name']; - $right = $autoaction['description']; - $trextra = ' class="listinghead"'; - - eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); - - if ($autoaction['comment']) + foreach ($bugsys->datastore['autoaction'] AS $autoaction) { - $left = _('Add Comment'); - $right = $autoaction['comment']; - $trextra = ' style="background-color: ' . $stylevar['alt_color'] . '"'; + $autoaction['fieldchanges'] = unserialize($autoaction['fieldchanges']); + + $left = $autoaction['name']; + $right = $autoaction['description']; + $trextra = ' class="listinghead"'; eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); - } - - $trextra = ''; - - foreach ((array)$autoaction['fieldchanges']['builtin'] AS $name => $value) - { - $left = $name; - $right = $bugsys->datastore["$left"]["$value"]["$left"]; - eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); - } - - foreach ((array)$autoaction['fieldchanges']['custom'] AS $id => $value) - { - if (!$fields["$id"]) + + if ($autoaction['comment']) { - continue; + $left = _('Add Comment'); + $right = $autoaction['comment']; + $trextra = ' style="background-color: ' . $stylevar['alt_color'] . '"'; + + eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); } - $left = $fields["$id"]['name'] . ' ' . sprintf(_('(Custom #%1$d, type: %2$s)'), $id, $fields["$id"]['type']); - $right = $value; - eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); + $trextra = ''; + + if (is_array($autoaction['fieldchanges']['builtin'])) + { + foreach ($autoaction['fieldchanges']['builtin'] AS $name => $value) + { + $left = $name; + $right = $bugsys->datastore["$left"]["$value"]["$left"]; + eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); + } + } + + if (is_array($autoaction['fieldchanges']['custom'])) + { + foreach ($autoaction['fieldchanges']['custom'] AS $id => $value) + { + if (!$fields["$id"]) + { + continue; + } + + $left = $fields["$id"]['name'] . ' ' . sprintf(_('(Custom #%1$d, type: %2$s)'), $id, $fields["$id"]['type']); + $right = $value; + eval('$autoactions .= "' . $template->fetch('explain_row') . '";'); + } + } } } diff --git a/userctrl.php b/userctrl.php index 5642abf..14befdc 100644 --- a/userctrl.php +++ b/userctrl.php @@ -154,14 +154,20 @@ if ($_POST['do'] == 'update') $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $bugsys->userinfo['userid']); $bugsys->input_clean('emailopts', TYPE_INT); - foreach ((array)$bugsys->in['emailopts'] AS $relation => $bitarr) + if (is_array($bugsys->in['emailopts'])) { - $bitmask = 0; - foreach ((array)$bitarr AS $option => $yes) + foreach ($bugsys->in['emailopts'] AS $relation => $bitarr) { - $bitmask += $option * $yes; + $bitmask = 0; + if (is_array($bitarr)) + { + foreach ($bitarr AS $option => $yes) + { + $bitmask += $option * $yes; + } + } + $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $bugsys->userinfo['userid'] . ", $relation, $bitmask)"); } - $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $bugsys->userinfo['userid'] . ", $relation, $bitmask)"); } $message->redirect(_('The changes to your account have been made.'), 'userctrl.php'); -- 2.43.5