Skip to content

Commit

Permalink
Add Maintenance mode
Browse files Browse the repository at this point in the history
Sometimes we don't want users changing stuff.  We might be upgrading
to a newwer version of PostgreSQL by dumping and loading into another
server.

Setting IN_MAINTANCE_MODE to true, in include/constants.local.php will
enter maintenance mode

If you attempt to visit any of these pages, you will be redirected to
now-in-maintenance-mode.php:

 * bouncing.php
 * customize.php
 * committer-opt-in.php
 * filter-setup.php
 * forgotten-password.php
 * new-user.php
 * password-reset-via-token.php
 * pkg_upload.php
 * port-watch.php
 * report-subscriptions.php
 * watch-categories.php
 * watch-list-maintenance.php
 * watch-list.php

Once at now-in-maintenance-mode.php, the page will reload every MAINTENANCE_MODE_RERESH_TIME_SECONDS
seconds, as defined in include/constants.php
  • Loading branch information
dlangille committed Oct 1, 2018
1 parent bccff05 commit 538d00e
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/constants.local.php.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,22 @@
# constants which

#define('PATH_TO_PORTSDIR', '/usr/local/'); // must have a trailing /

#define('NO_LOGIN', false);

# set this to true to display the now-in-maintenance-mode.php page
# users get redirected there if visit the following pages:
# * bouncing.php
# * customize.php
# * committer-opt-in.php
# * filter-setup.php
# * forgotten-password.php
# * new-user.php
# * password-reset-via-token.php
# * pkg_upload.php
# * port-watch.php
# * report-subscriptions.php
# * watch-categories.php
# * watch-list-maintenance.php
# * watch-list.php
define('IN_MAINTENCE_MODE', true);
3 changes: 3 additions & 0 deletions include/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@

# number of seconds a newsfeed will remain before refreshed.
define('NEWSFEED_REFRESH_SECONDS', 3600);

define('MAINTENANCE_PAGE', 'now-in-maintenance-mode.php');
define('MAINTENANCE_MODE_RERESH_TIME_SECONDS', 180);
4 changes: 4 additions & 0 deletions www/bouncing.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

$Debug = 0;

$origin = $_GET["origin"];
Expand Down
4 changes: 4 additions & 0 deletions www/committer-opt-in.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

freshports_Start('Committer opt-in',
'freshports - new ports, applications',
'FreeBSD, index, applications, ports');
Expand Down
4 changes: 4 additions & 0 deletions www/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/htmlify.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

GLOBAL $User;

Expand Down
4 changes: 4 additions & 0 deletions www/filter-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/watch-lists.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/watch_list_element.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

// if we don't know who they are, we'll make sure they login first
if (!$visitor) {
header("Location: /login.php?origin=" . $_SERVER["PHP_SELF"]); /* Redirect browser to PHP web site */
Expand Down
4 changes: 4 additions & 0 deletions www/forgotten-password.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/freshports.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

$Debug = 0;


Expand Down
4 changes: 4 additions & 0 deletions www/new-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# Copyright (c) 1998-2004 DVL Software Limited
#

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

# for captcha
session_start();

Expand Down
75 changes: 75 additions & 0 deletions www/now-in-maintenance-mode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
#
# $Id: now-in-maintenance-mode.php
#
# Copyright (c) 1998-2006 DVL Software Limited
#

require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/common.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/freshports.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');

freshports_ConditionalGet(freshports_LastModified());

if (IN_MAINTENCE_MODE) {
header('Refresh: ' . MAINTENANCE_MODE_RERESH_TIME_SECONDS);
} else {
header('Location: /', TRUE, 307);
}
freshports_Start('Maintenance Mode',
'freshports - new ports, applications',
'FreeBSD, index, applications, ports');

$ServerName = str_replace('freshports', 'FreshPorts', $_SERVER['HTTP_HOST']);

GLOBAL $FreshPortsName;
GLOBAL $FreshPortsSlogan;


?>
<?php echo freshports_MainTable(); ?>

<tr><td valign="top" width="100%">

<?php echo freshports_MainContentTable(NOBORDER); ?>


<tr>
<?php echo freshports_PageBannerText("Maintenance Mode"); ?>
</tr>
<TR><TD>

<p>
The website is now in maintenance mode. No updates are allowed during this process.
</p>

<p>
This page will reload every <?php echo MAINTENANCE_MODE_RERESH_TIME_SECONDS; ?> seconds. When maintence mode finishes, this page will be redirect to the home page.
</p>

<p align="center">
<img src="images/work-in-progress.jpg" width="640" height="480" alt="work in progress">
</p>

</TD></TR>

</TD>
</TABLE>
</TD>

<TD VALIGN="top" WIDTH="*" ALIGN="center">
<?
echo freshports_SideBar();
?>
</td>

</TR>
</TABLE>

<?php
echo freshports_ShowFooter();
?>

</body>
</html>
4 changes: 4 additions & 0 deletions www/password-reset-via-token.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/htmlify.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

GLOBAL $User;

$origin = '/';
Expand Down
4 changes: 4 additions & 0 deletions www/pkg_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/watch-lists.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

freshports_Start('Uploading pkg_info',
$FreshPortsName . ' - new ports, applications',
'FreeBSD, index, applications, ports');
Expand Down
4 changes: 4 additions & 0 deletions www/port-watch.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/watch_list.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/watch_list_element.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

$Debug = 0;
$submit = 0;
$HTML = '';
Expand Down
4 changes: 4 additions & 0 deletions www/report-subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

$ArticleTitle = 'Report subscriptions';

freshports_Start( $ArticleTitle,
Expand Down
4 changes: 4 additions & 0 deletions www/watch-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/watch-lists.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

// if we don't know who they are, we'll make sure they login first
if (!$visitor) {
header("Location: /login.php?origin=" . $_SERVER["PHP_SELF"]); /* Redirect browser to PHP web site */
Expand Down
4 changes: 4 additions & 0 deletions www/watch-list-maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/watch-lists.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

$visitor = $_COOKIE['visitor'];

unset($add_name);
Expand Down
4 changes: 4 additions & 0 deletions www/watch-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/watch_list_element.php');

if (IN_MAINTENCE_MODE) {
header('Location: /' . MAINTENANCE_PAGE, TRUE, 307);
}

$Debug = 0;

if ($_POST["Origin"]) {
Expand Down

0 comments on commit 538d00e

Please sign in to comment.