5
5
* Documentation: https://github.com/Lyquix/php-git-deploy
6
6
*/
7
7
8
+ // Measure execution time
9
+ $ time = -microtime (true );
10
+
8
11
/* Functions */
9
12
10
13
// Output buffering handler
@@ -50,10 +53,7 @@ function endScript() {
50
53
if (defined ('EMAIL_NOTIFICATIONS ' ) && EMAIL_NOTIFICATIONS !== '' ) error_log ($ output , 1 , EMAIL_NOTIFICATIONS );
51
54
}
52
55
53
- /* Begin Script */
54
-
55
- // Measure execution time
56
- $ time = -microtime (true );
56
+ /* Begin Script Execution */
57
57
58
58
// Prevent caching
59
59
header ("Cache-Control: no-store, no-cache, must-revalidate, max-age=0 " );
@@ -64,17 +64,6 @@ function endScript() {
64
64
ob_start ('obHandler ' );
65
65
$ output = '' ;
66
66
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
-
78
67
// Check if there is a configuration file
79
68
if (file_exists (__DIR__ . '/deploy-config.php ' )) {
80
69
require_once __DIR__ . '/deploy-config.php ' ;
@@ -93,15 +82,27 @@ function endScript() {
93
82
if (!defined ('TARGET_DIR ' ) || TARGET_DIR === '' ) $ err [] = 'Target directory is not configured ' ;
94
83
if (!defined ('TIME_LIMIT ' )) define ('TIME_LIMIT ' , 60 );
95
84
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> " );
99
88
endScript ();
100
89
die ();
101
90
}
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> ' );
105
106
endScript ();
106
107
die ();
107
108
}
0 commit comments