Skip to content

Commit 37508be

Browse files
Add enabled switch to control access to the script
1 parent 7ac653c commit 37508be

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

deploy-config.orig.php

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
* Documentation: https://github.com/Lyquix/php-git-deploy
66
*/
77

8+
/*
9+
* ENABLED
10+
* Set to false to prevent the execution of this script
11+
* Useful to control activation of this script only when needed
12+
*
13+
*/
14+
define('ENABLED', true);
15+
816
/*
917
* REMOTE_REPOSITORY:
1018
* Address of the remote Git repo. For private repos use the SSH address

deploy.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function removeLockFile() {
2929

3030
// Check configuration errors
3131
$err = array();
32+
if (!defined('ENABLED')) $err[] = 'Enabled flag is not configured';
3233
if (!defined('ACCESS_TOKEN')) $err[] = 'Access token is not configured';
3334
if (!defined('REMOTE_REPOSITORY')) $err[] = 'Remote repository is not configured';
3435
if (!defined('BRANCH')) $err[] = 'Branch is not configured';
@@ -37,15 +38,15 @@ function removeLockFile() {
3738
if (!defined('TIME_LIMIT')) define('TIME_LIMIT', 60);
3839

3940
// If there's authorization error, set the correct HTTP header.
40-
if (!isset($_GET['t']) || $_GET['t'] !== ACCESS_TOKEN || ACCESS_TOKEN === '') {
41+
if (!isset($_GET['t']) || $_GET['t'] !== ACCESS_TOKEN || ACCESS_TOKEN === '' || ENABLED !== true) {
4142
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
4243
}
4344

4445
// Prevent caching
4546
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
4647
header("Cache-Control: post-check=0, pre-check=0", false);
4748
header("Pragma: no-cache");
48-
if (!isset($_GET['t']) || $_GET['t'] !== ACCESS_TOKEN) {
49+
if (!isset($_GET['t']) || $_GET['t'] !== ACCESS_TOKEN || ENABLED !== true) {
4950
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
5051
removeLockFile();
5152
echo "<html>\n<body>\n<h2>Access Denied</h2>\n</body>\n</html>\n";

0 commit comments

Comments
 (0)