diff --git a/mozilla/webtools/addons/public/htaccess.dist b/mozilla/webtools/addons/public/htaccess.dist index c38cfb86376..eb4eeba8e9e 100644 --- a/mozilla/webtools/addons/public/htaccess.dist +++ b/mozilla/webtools/addons/public/htaccess.dist @@ -94,3 +94,8 @@ RewriteRule ^(\w+)/([\w-]+)[/]{0,1}$ $2.php?app=$1 # Example: # /firefox/ -> /?app=firefox RewriteRule ^(\w+)[/]{0,1}$ index.php?app=$1 + +# Rewrite for client blocklist requests. +# Example: +# /blocklist/1/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/1.5 -> blocklist.php?reqVersion=1&appGuid={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=1.5 +RewriteRule ^blocklist/(.+)/(.+)/(.+)[/]{0,1}$ blocklist.php?reqVersion=$1&appGuid=$2&appVersion=$3 diff --git a/mozilla/webtools/addons/public/htdocs/blocklist.php b/mozilla/webtools/addons/public/htdocs/blocklist.php new file mode 100644 index 00000000000..faee244a40a --- /dev/null +++ b/mozilla/webtools/addons/public/htdocs/blocklist.php @@ -0,0 +1,190 @@ +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 ''; + print_r($_GET); + echo ''; + + if (!empty($query)) { + echo '
'; + echo $query; + echo ''; + } + + if (!empty($blocklist)) { + echo '
'; + print_r($blocklist); + echo ''; + } + + if (!empty($errors) && is_array($errors)) { + echo '
'; + print_r($errors); + echo ''; + } else { + echo '