| <?php |
| /******************************************************************************* |
| * Copyright (c) 2007-2015 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Denis Roy (Eclipse Foundation)- initial API and implementation |
| *******************************************************************************/ |
| |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php"); |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php"); |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php"); |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/mirrors/mirror.class.php"); |
| $App = new App(); $Menu = new Menu(); |
| |
| # Require login for this page. |
| $Session = $App->useSession(true); |
| $Mirror = new Mirror(); |
| include("_projectCommon.php"); |
| |
| # Begin buffered output |
| ob_start(); |
| |
| $pageTitle = "Eclipse Download Stats"; |
| $pageKeywords = ""; |
| $pageAuthor = "Eclipse Foundation, Inc."; |
| header("Content-type: text/html; charset=utf-8"); |
| header("Cache-Control: no-cache, must-revalidate"); |
| |
| $_FILENAME = filter_var($App->getHTTPParameter("filename", ""), FILTER_SANITIZE_URL); # /path/to_file/File_name1234.jar |
| $_VIEW_DATE = filter_var($App->getHTTPParameter("view_date", ""), FILTER_SANITIZE_STRING); # L30, L7, TODAY |
| $_VIEW = filter_var($App->getHTTPParameter("view", ""), FILTER_SANITIZE_STRING); # daily, ccode |
| $_GROUP = filter_var($App->getHTTPParameter("group", ""), FILTER_SANITIZE_NUMBER_INT); # 0 or 1 |
| $_DEBUG = filter_var($App->getHTTPParameter("debug", ""), FILTER_SANITIZE_NUMBER_INT); # 0 or 1 |
| $_DATEFROM = filter_var($App->getHTTPParameter("datefrom", ""), FILTER_SANITIZE_STRING); # YYYY-MM-DD |
| $_DATETO = filter_var($App->getHTTPParameter("dateto", ""), FILTER_SANITIZE_STRING); # YYYY-MM-DD |
| $_FORGE = filter_var($App->getHTTPParameter("forge", ""), FILTER_SANITIZE_STRING); # eclipse, polarsys, locationtech |
| |
| if($_FORGE == "eclipse" || $_FORGE == "") { |
| $objJSON = json_decode($Mirror->getStatsJSON($_FILENAME, $_VIEW_DATE, $_VIEW, $_GROUP, $_DATEFROM, $_DATETO)); |
| } |
| if($_FORGE == "polarsys" || $_FORGE == "locationtech") { |
| $rc = $App->RESTClient(); |
| $rc = new RestClient(NULL); |
| // Remote server does not support 'application/json' |
| $rc->unsetHeader('Content-Type'); |
| $rc->setBaseUrl('http://download.' . $_FORGE . '.org/downloads/web-api'); |
| |
| $data = array("filename" => $_FILENAME, |
| "view_date" => $_VIEW_DATE, |
| "view" => $_VIEW, |
| "group" => $_GROUP, |
| "datefrom" => $_DATEFROM, |
| "dateto" => $_DATETO); |
| |
| $rc->post("stats.php", $data); |
| $objJSON = $rc->getRequestBody(); |
| } |
| |
| $inc_file = "inc/en_stats.php"; |
| if($_VIEW == "daily" ) { |
| $inc_file = "inc/en_stats_daily.php"; |
| } |
| if($_VIEW == "ccode") { |
| $inc_file = "inc/en_stats_ccode.php"; |
| } |
| |
| include($inc_file); |
| |
| |
| $html = ob_get_contents(); |
| ob_end_clean(); |
| $App->generatePage($theme, $Menu, null, $pageAuthor, $pageKeywords, $pageTitle, $html); |