From 0d0754c9932f640d7ef1c1f310b2b43c704e37e3 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Sun, 25 Oct 2015 12:01:04 -0400 Subject: [PATCH] basic post commit test --- .gitignore | 2 +- controller/Actions.class.php | 15 +++++++++++++-- controller/Controller.class.php | 7 +++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 137a157a..e9f20eb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /web/.sass-cache /web/css /log -/data/access_list.php +/data/secret /web/zohoverify nbproject diff --git a/controller/Actions.class.php b/controller/Actions.class.php index 2718a7a6..82a509fa 100644 --- a/controller/Actions.class.php +++ b/controller/Actions.class.php @@ -33,9 +33,20 @@ class Actions return ['page/get-denied', ['inviteError' => $inviteError]]; } + public function executePostCommit() + { + $payload = json_decode($_REQUEST['payload']); + $secret = file_get_contents('data/secret/github-secret'); + $isToMaster = $payload->ref === 'refs/heads/master'; + + file_put_contents('github.txt', ($isToMaster ? 'master' : 'apprentince') . "\n$secret\n" . print_r($payload, TRUE), FILE_APPEND); + + return [null, []]; + } + protected function validateDownloadAccess() { - $seshionKey = 'buttsz'; + $seshionKey = 'has-download-access'; if ($this->session->get($seshionKey)) { return true; @@ -43,7 +54,7 @@ class Actions if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $this->accessCodes = include $_SERVER['ROOT_DIR'] . '/data/access_list.php'; + $this->accessCodes = include $_SERVER['ROOT_DIR'] . '/data/secret/access_list.php'; $today = date('Y-m-d H:i:s'); foreach($this->accessCodes as $code => $date) { diff --git a/controller/Controller.class.php b/controller/Controller.class.php index 2f2d4e5c..328ba7f3 100644 --- a/controller/Controller.class.php +++ b/controller/Controller.class.php @@ -13,6 +13,11 @@ class Controller { list($viewTemplate, $viewParameters) = static::execute($uri); + if ($viewTemplate === null) + { + return ''; + } + if (!$viewTemplate) { throw new LogicException('All execute methods must return a template.'); @@ -37,6 +42,8 @@ class Controller return $action->executeHome(); case '/get': return $action->executeGet(); + case '/postcommit': + return $action->executePostCommit(); default: if (View::exists('page/' . ltrim($uri, '/'))) {