blob: de033f8ffe66078bf3c647e4a3fbdd38b65ed6d8 [file] [log] [blame]
<?php
/**
* Copyright (c) 2013-2015, 2018 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* Christopher Guindon (Eclipse Foundation)- initial API and implementation
* Eric Poirier (Eclipse Foundation)
*
* SPDX-License-Identifier: EPL-2.0
*/
require_once ($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
require_once ($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php");
$App = new App();
$Nav = new Nav();
$Theme = $App->getThemeClass();
include ("_projectCommon.php");
$pageTitle = "Eclipse mirror sites";
$Theme->setPageTitle($pageTitle);
$Theme->setPageKeywords('eclipse,download,mirror');
$Theme->setPageAuthor('Eclipse Foundation, Inc.');
require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_rw.class.php";
require_once ($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/mirrors/mirror.class.php");
$_status = $App->getHTTPParameter('status');
$error = 0;
if ($_status == "") {
$_status = "new";
}
$dbc = new DBConnectionRW();
$dbh = $dbc->connect();
$App = new App();
$Mirror = new Mirror();
if ($_status == "save") {
$MIR_REQ = $_COOKIE['MIR_REQ'];
if ($MIR_REQ == "") {
$valid = true;
$errorfield = "";
$alnumspace = "^[][a-zA-Z0-9 .'&,_-]+$";
// validate incoming
if (!eregi($alnumspace, $_POST['organization'])) {
$errorfield .= " Organization";
$valid = false;
}
if (!eregi('^[a-zA-Z]{2}$', $_POST['ccode'])) {
$errorfield .= " Country";
$valid = false;
}
if (!eregi($alnumspace, $_POST['contact'])) {
$errorfield .= " Contact";
$valid = false;
}
if (!eregi("^(http|https):\/\/", $_POST['http_browserlink']) && $_POST['http_browserlink'] != "") {
$errorfield .= " HTTP URL";
$valid = false;
}
if (!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z.]{2,5}$', $_POST['email'])) {
$errorfield .= " E-mail address";
$valid = false;
}
if (!$Mirror->isValidPublicIP($_POST['update_ip_allow'])) {
$errorfield .= " IP Address";
$valid = false;
}
if ($valid) {
$sql = "
INSERT INTO mirrors (
organization,
ccode,
update_ip_allow,
email,
date_enabled,
create_status,
contact)
VALUES (
" . $App->returnQuotedString($_POST['organization']) . ",
" . $App->returnQuotedString($_POST['ccode']) . ",
" . $App->returnQuotedString($_POST['update_ip_allow']) . ",
" . $App->returnQuotedString($_POST['email']) . ",
NOW(),
" . $App->returnQuotedString("approve") . ",
" . $App->returnQuotedString($_POST['contact']) . ")
";
mysql_query($sql, $dbh);
$mirror_id = mysql_insert_id();
// add protocols.
if ($_POST["http_browserlink"] != "") {
$sql = "
INSERT INTO mirror_protocols (
mirror_id,
protocol,
base_path)
VALUES (
" . $mirror_id . ",
" . $App->returnQuotedString("http") . ",
" . $App->returnQuotedString($_POST['http_browserlink']) . ")
";
mysql_query($sql, $dbh);
$drop_list = $_POST["drop_id"];
foreach (split(",", $drop_list) as $drop) {
$sql = "
INSERT INTO mirror_drops (
mirror_id,
drop_id,
protocol)
VALUES (
" . $mirror_id . ",
" . $App->returnQuotedString("EclipseFull") . ",
" . $App->returnQuotedString("http") . ")";
mysql_query($sql, $dbh);
}
}
// Place cookie on browser to avoid having multiple submissions
setcookie("MIR_REQ", "1");
}
else {
$error = 2;
}
}
else {
$error = 1;
}
}
else {
$sql = "SELECT
DRP.drop_id,
DRP.project_id,
DRP.description,
IFNULL((
SELECT
disk_space
FROM project_disk_space_usage AS DSK
WHERE DSK.project_id = DRP.project_id AND DSK.is_quota=1
)
,DRP.size) AS size,
DRP.size_unit,
DRP.is_default_selection,
PRJ.level,
PRJ.sort_order
FROM drops AS DRP
LEFT JOIN projects as PRJ ON PRJ.project_id = DRP.project_ID
ORDER BY DRP.sort_order
";
$rs = mysql_query($sql, $dbh);
$sql = "SELECT
ccode,
en_description
FROM SYS_countries
ORDER BY en_description
";
$rs_country = mysql_query($sql, $dbh);
}
// Place your html content in a file called content/en_pagename.php
include ("content/en_" . $App->getScriptName());
$dbc->disconnect();
$dbc = null;
$Theme->setHtml($html);
$Theme->setNav($Nav);
$Theme->generatePage();