query($query, SQL_ALL, SQL_ASSOC); if (DB::isError($db->record)) { $errors[] = 'MySQL query for blocklist failed.'; } elseif (empty($db->record)) { $errors[] = 'No matching blocklist for given application GUID.'; } else { $blocklist = array(); foreach ($db->record as $row) { // If we have item itemMin/itemMax values or an appId possible ranges, we create // hashes for each itemId and its related range. // // Since itemGuids can have different itemIds, they are the first hash. Each // itemId is effectively an item's versionRange. For each one of these we create // a corresponding array containing the range values, which could be NULL. if (!empty($row['itemMin']) && !empty($row['itemMax']) || !empty($row['appItemId'])) { $blocklist['items'][$row['itemGuid']][$row['itemId']] = array( 'itemMin' => $row['itemMin'], 'itemMax' => $row['itemMax'] ); // Otherwise, our items array only contains a top-level containing the itemGuid. // // Doing so tells our template to terminate the item with /> because there is // nothing left to display. } else { $blocklist['items'][$row['itemGuid']] = null; } // If we retrieved non-null blapp data, store it in the apps array. // // These are referenced later by their foreign key relationship to items (appItemId). if ($row['appItemId']) { $blocklist['apps'][$row['itemGuid']][$row['appItemId']][$row['appGuid']][] = array( 'appMin' => $row['appMin'], 'appMax' => $row['appMax'] ); } } // Send our array to the template. $tpl->assign('blocklist',$blocklist); } } /* * DEBUG * * If we get here, something went wrong. For testing purposes, we can * optionally display errers based on $_GET['debug']. * * By default, no errors are ever displayed because humans do not read this * script. * * Until there is some sort of API for how clients handle errors, * things should remain this way. */ if ($debug == true) { echo ''; echo ''; echo ''; echo 'blocklist.php Debug Information'; echo ''; echo ''; echo ''; echo '

Parameters

'; echo '
';
    print_r($_GET);
    echo '
'; if (!empty($query)) { echo '

Query

'; echo '
';
        echo $query;
        echo '
'; } if (!empty($blocklist)) { echo '

Result

'; echo '
';
        print_r($blocklist);
        echo '
'; } if (!empty($errors) && is_array($errors)) { echo '

Errors Found

'; echo '
';
        print_r($errors);
        echo '
'; } else { echo '

No Errors Found

'; } echo ''; echo ''; exit; } ?>