Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ec2533

Browse files
Code cleanup
1 parent 3bc027b commit 7ec2533

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

‎deploy.php‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* Documentation: https://github.com/Lyquix/php-git-deploy
66
*/
77

8+
// Measure execution time
9+
$time = -microtime(true);
10+
811
/* Functions */
912

1013
// Output buffering handler
@@ -50,10 +53,7 @@ function endScript() {
5053
if(defined('EMAIL_NOTIFICATIONS') && EMAIL_NOTIFICATIONS !== '') error_log($output, 1, EMAIL_NOTIFICATIONS);
5154
}
5255

53-
/* Begin Script */
54-
55-
// Measure execution time
56-
$time = -microtime(true);
56+
/* Begin Script Execution */
5757

5858
// Prevent caching
5959
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
@@ -64,17 +64,6 @@ function endScript() {
6464
ob_start('obHandler');
6565
$output = '';
6666

67-
// Check if lock file exists
68-
if (file_exists(__DIR__ . '/deploy.lock')) {
69-
errorPage('<h2>File deploy.lock detected, another process already running</h2>');
70-
endScript();
71-
die();
72-
}
73-
74-
// Create lock file
75-
$fh = fopen(__DIR__ . '/deploy.lock', 'w');
76-
fclose($fh);
77-
7867
// Check if there is a configuration file
7968
if (file_exists(__DIR__ . '/deploy-config.php')) {
8069
require_once __DIR__ . '/deploy-config.php';
@@ -93,15 +82,27 @@ function endScript() {
9382
if (!defined('TARGET_DIR') || TARGET_DIR === '') $err[] = 'Target directory is not configured';
9483
if (!defined('TIME_LIMIT')) define('TIME_LIMIT', 60);
9584

96-
// If there's authorization error
97-
if (!isset($_GET['t']) || $_GET['t'] !== ACCESS_TOKEN || DISABLED === true) {
98-
errorPage('<h2>Access Denied</h2>');
85+
// If there is a configuration error
86+
if (count($err)) {
87+
errorPage("<h2>Configuration Error</h2>\n<pre>\n" . implode("\n", $err) . "\n</pre>");
9988
endScript();
10089
die();
10190
}
102-
// If there is a configuration error
103-
if (count($err)) {
104-
errorPage('<h2>Configuration Error</h2>\n<pre>\n" . implode("\n", $err) . "\n</pre>');
91+
92+
// Check if lock file exists
93+
if (file_exists(__DIR__ . '/deploy.lock')) {
94+
errorPage('<h2>File deploy.lock detected, another process already running</h2>');
95+
endScript();
96+
die();
97+
}
98+
99+
// Create lock file
100+
$fh = fopen(__DIR__ . '/deploy.lock', 'w');
101+
fclose($fh);
102+
103+
// If there's authorization error
104+
if (!isset($_GET['t']) || $_GET['t'] !== ACCESS_TOKEN || DISABLED === true) {
105+
errorPage('<h2>Access Denied</h2>');
105106
endScript();
106107
die();
107108
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /