From 0845bf175dc416cdf107209fc34f7b37bf42b6e6 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 15:17:28 -0400 Subject: data/templates/revision-head.htm - ADD: display commit message --- src/phorkie/Repository.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/phorkie/Repository.php') diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php index 448982b..6ed3807 100644 --- a/src/phorkie/Repository.php +++ b/src/phorkie/Repository.php @@ -32,6 +32,12 @@ class Repository */ public $hash; + /** + * Commit message of the last (or current) revision + * + * @var string + */ + public $message; /** @@ -56,6 +62,7 @@ class Repository $this->id = (int)$_GET['id']; $this->loadDirs(); $this->loadHash(); + $this->loadMessage(); } protected function loadDirs() @@ -97,6 +104,23 @@ class Repository $this->hash = $output; } + public function loadMessage() + { + $rev = (isset($this->hash)) ? $this->hash : 'HEAD'; + $output = $this->getVc()->getCommand('log') + ->setOption('oneline') + ->addArgument('-1') + ->addArgument($rev) + ->execute(); + $output = trim($output); + if (strpos($output, ' ') > 0) { + $output = substr($output, strpos($output, ' '), strlen($output)); + $this->message = trim($output); + } else { + $this->message = "This commit message intentionally left blank."; + } + } + public function loadById($id) { if (!is_numeric($id)) { -- cgit v1.2.3 From 2935763e253c3616d951bc18c7d21a56349531fa Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 15:37:49 -0400 Subject: Updated ChangeLog and README.rst --- ChangeLog | 4 ++++ README.rst | 14 ++++++++++++++ src/phorkie/Repository.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/phorkie/Repository.php') diff --git a/ChangeLog b/ChangeLog index 7e45b7d..35e7456 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-09-16 Justin J. Novack + + * Add OpenID authentication + 2012-09-08 Christian Weiske * Fix bug #11: do not index edit, delete and tool pages diff --git a/README.rst b/README.rst index c94f29e..56bef95 100644 --- a/README.rst +++ b/README.rst @@ -190,6 +190,15 @@ URLs List all pastes, with optional page ``/new`` Shows form for new paste +``/login`` + Login page for protecting site +``/auth`` + Authentication callback url +``/forbidden`` + Access denied page +``/user`` + Edit logged-in user information + Internal directory layout ========================= @@ -227,4 +236,9 @@ If you use nginx, place the following lines into your ``server`` block: rewrite ^/search$ /search.php; rewrite ^/search/([0-9]+)$ /search.php?page=$1; + + rewrite ^/login$ /login.php; + rewrite ^/auth$ /auth.php; + rewrite ^/forbidden$ /forbidden.php; + rewrite ^/user$ /user.php; } diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php index 6ed3807..9f8f264 100644 --- a/src/phorkie/Repository.php +++ b/src/phorkie/Repository.php @@ -118,7 +118,7 @@ class Repository $this->message = trim($output); } else { $this->message = "This commit message intentionally left blank."; - } + } } public function loadById($id) -- cgit v1.2.3 From f9ade082ba49cf487af31339afa7aeeb0653af57 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 13:42:49 -0400 Subject: PEAR Coding Standards intermediate update for files changed --- src/phorkie/Repository.php | 5 +++++ www/auth.php | 11 ++++------- www/delete.php | 2 +- www/display.php | 2 +- www/edit.php | 2 +- www/forbidden.php | 2 +- www/fork.php | 4 ++-- www/list.php | 2 +- www/new.php | 2 +- www/raw.php | 2 +- www/user.php | 2 +- www/www-header.php | 8 ++++++-- 12 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/phorkie/Repository.php') diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php index 995a16d..43f2b23 100644 --- a/src/phorkie/Repository.php +++ b/src/phorkie/Repository.php @@ -104,6 +104,11 @@ class Repository $this->hash = $output; } + /** + * Populates $this->message + * + * @return void + */ public function loadMessage() { $rev = (isset($this->hash)) ? $this->hash : 'HEAD'; diff --git a/www/auth.php b/www/auth.php index b8d08ff..1cafd59 100644 --- a/www/auth.php +++ b/www/auth.php @@ -27,7 +27,7 @@ if (isset($_REQUEST['logout'])) { session_destroy(); $redirect = 'http://' . $_SERVER['HTTP_HOST']; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); - exit; + exit; } if (!count($_GET) && !count($_POST)) { @@ -59,9 +59,7 @@ try { exit; } -if (!empty($_POST['disable_associations']) - || !empty($_SESSION['disable_associations'])) { - +if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associations'])) { $o->disableAssociations(); $_SESSION['disable_associations'] = true; } @@ -159,8 +157,7 @@ if (isset($_POST['start'])) { $mode = $message->get('openid.mode'); try { - $result = $o->verify(new Net_URL2($returnTo . '?' . $queryString), - $message); + $result = $o->verify(new Net_URL2($returnTo . '?' . $queryString), $message); if ($result->success()) { $status = "Status:SUCCESS!"; @@ -202,7 +199,7 @@ if (isset($_POST['start'])) { $openid = $message->getArrayFormat(); - $email = (isset($openid['openid.ext1.value.email'])) ? $openid['openid.ext1.value.email'] : null; + $email = (isset($openid['openid.ext1.value.email'])) ? $openid['openid.ext1.value.email'] : null; $email = (isset($openid['openid.ext2.value.email']) && !isset($email)) ? $openid['openid.ext2.value.email'] : $email; $email = (isset($openid['openid.sreg.email']) && !isset($email)) ? $openid['openid.sreg.email'] : $email; $email = (isset($openid['openid.ax.value.email']) && !isset($email)) ? $openid['openid.ax.value.email'] : $email; diff --git a/www/delete.php b/www/delete.php index f332028..85f6258 100644 --- a/www/delete.php +++ b/www/delete.php @@ -5,7 +5,7 @@ namespace phorkie; */ require_once 'www-header.php'; if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - require_once 'secure.php'; + include_once 'secure.php'; } $repo = new Repository(); diff --git a/www/display.php b/www/display.php index 2376d30..6f754d9 100644 --- a/www/display.php +++ b/www/display.php @@ -5,7 +5,7 @@ namespace phorkie; */ require_once 'www-header.php'; if ($GLOBALS['phorkie']['auth']['secure'] == 2) { - require_once 'secure.php'; + include_once 'secure.php'; } $repo = new Repository(); diff --git a/www/edit.php b/www/edit.php index db4428b..20e7793 100644 --- a/www/edit.php +++ b/www/edit.php @@ -5,7 +5,7 @@ namespace phorkie; */ require_once 'www-header.php'; if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - require_once 'secure.php'; + include_once 'secure.php'; } $repo = new Repository(); diff --git a/www/forbidden.php b/www/forbidden.php index 1f587a2..3646b0a 100644 --- a/www/forbidden.php +++ b/www/forbidden.php @@ -1,6 +1,6 @@ 0) { - require_once 'secure.php'; + include_once 'secure.php'; } if ($_SERVER['REQUEST_METHOD'] !== 'POST') { @@ -33,4 +33,4 @@ foreach (\glob($new->gitDir . '/hooks/*') as $hookfile) { //FIXME: where to put fork source link? redirect($new->getLink('display')); -?> \ No newline at end of file +?> diff --git a/www/list.php b/www/list.php index 17f46b1..5a394eb 100644 --- a/www/list.php +++ b/www/list.php @@ -5,7 +5,7 @@ namespace phorkie; require_once 'www-header.php'; if ($GLOBALS['phorkie']['auth']['secure'] == 2) { - require_once 'secure.php'; + include_once 'secure.php'; } $rs = new Repositories(); diff --git a/www/new.php b/www/new.php index 8d1a231..0675b4d 100644 --- a/www/new.php +++ b/www/new.php @@ -12,7 +12,7 @@ namespace phorkie; */ require_once 'www-header.php'; if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - require_once 'secure.php'; + include_once 'secure.php'; } $repopo = new Repository_Post(); diff --git a/www/raw.php b/www/raw.php index 67a21ee..6b20633 100644 --- a/www/raw.php +++ b/www/raw.php @@ -5,7 +5,7 @@ namespace phorkie; require_once 'www-header.php'; if ($GLOBALS['phorkie']['auth']['secure'] == 2) { - require_once 'secure.php'; + include_once 'secure.php'; } $repo = new Repository(); $repo->loadFromRequest(); diff --git a/www/user.php b/www/user.php index 1cc8aeb..fd851c4 100644 --- a/www/user.php +++ b/www/user.php @@ -5,7 +5,7 @@ namespace phorkie; require_once 'www-header.php'; if (!isset($_SESSION['identity'])) { - require_once 'secure.php'; + include_once 'secure.php'; } if (isset($_POST['name'])) { diff --git a/www/www-header.php b/www/www-header.php index 5785a3e..64dca11 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -50,8 +50,12 @@ if ($GLOBALS['phorkie']['cfg']['setupcheck']) { // Set/Get git commit session variables $_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR']; -if (!isset($_SESSION['name'])) { $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName']; } -if (!isset($_SESSION['email'])) { $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail']; } +if (!isset($_SESSION['name'])) { + $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName']; +} +if (!isset($_SESSION['email'])) { + $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail']; +} \Twig_Autoloader::register(); -- cgit v1.2.3