This repository has been archived by the owner on Apr 12, 2019. It is now read-only.
forked from vicenteguerra/git-deploy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Standardize use of ' and " to just " - Standardize spaces in block declerations and function calls - Standardize indentation & line breaks - Line up variable values - Remove closing PHP tag, to match config.sample.php
- Loading branch information
Showing
1 changed file
with
37 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,46 @@ | ||
<?php | ||
require_once("config.php"); | ||
|
||
require_once ('config.php'); | ||
$content = file_get_contents("php://input"); | ||
$json = json_decode($content, true); | ||
$file = fopen(LOGFILE, "a"); | ||
$time = time(); | ||
|
||
$content = file_get_contents('php://input'); | ||
$json = json_decode($content, true); | ||
$file = fopen(LOGFILE, "a"); // Name for you Log File | ||
$time = time(); | ||
date_default_timezone_set("UTC"); | ||
fputs($file, date("d-m-Y (H:i:s)", $time) . "\n"); | ||
|
||
date_default_timezone_set('UTC'); | ||
fputs($file, date("d-m-Y (H:i:s)",$time) . "\n"); | ||
if (!isset($_GET["token"]) || $_GET["token"] !== TOKEN) { | ||
header("HTTP/1.0 403 Forbidden"); | ||
fputs($file, "Access Denied" . "\n"); | ||
exit; | ||
} else { | ||
if ($json["ref"] == BRANCH) { | ||
fputs($file, $content . PHP_EOL); | ||
|
||
if (!isset($_GET['token']) || $_GET['token'] !== TOKEN) { | ||
header('HTTP/1.0 403 Forbidden'); | ||
fputs($file, "Access Denied" . "\n"); | ||
exit; | ||
}else{ | ||
if($json['ref'] == BRANCH){ | ||
fputs($file, $content . PHP_EOL); | ||
if (file_exists(DIR.'.git') && is_dir(DIR)) { | ||
try{ | ||
chdir(DIR); | ||
shell_exec(GIT . ' pull'); | ||
if (!empty(AFTER_PULL)) { | ||
try{ | ||
shell_exec(AFTER_PULL); | ||
}catch (Exception $e) { | ||
fputs($file, $e . "\n"); | ||
} | ||
} | ||
fputs($file, "*** AUTO PULL SUCCESFUL ***" . "\n"); | ||
}catch (Exception $e) { | ||
fputs($file, $e . "\n"); | ||
} | ||
} | ||
else { | ||
fputs($file, "DIR Not Found" . "\n"); | ||
} | ||
} | ||
else{ | ||
fputs($file, "Push in: " . $json['ref'] . "\n"); | ||
} | ||
if (file_exists(DIR . ".git") && is_dir(DIR)) { | ||
try { | ||
chdir(DIR); | ||
shell_exec(GIT . " pull"); | ||
|
||
if (!empty(AFTER_PULL)) { | ||
try { | ||
shell_exec(AFTER_PULL); | ||
} catch (Exception $e) { | ||
fputs($file, $e . "\n"); | ||
} | ||
} | ||
|
||
fputs($file, "*** AUTO PULL SUCCESFUL ***" . "\n"); | ||
} catch (Exception $e) { | ||
fputs($file, $e . "\n"); | ||
} | ||
} else { | ||
fputs($file, "DIR Not Found" . "\n"); | ||
} | ||
} else{ | ||
fputs($file, "Push in: " . $json["ref"] . "\n"); | ||
} | ||
} | ||
|
||
fputs($file, "\n\n" . PHP_EOL); | ||
fclose($file); | ||
?> |