From 3ce19681c05cdb64931ec270a4c924d225c6c395 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 3 Feb 2015 16:47:23 +0100 Subject: [PATCH] =?UTF-8?q?Suppression=20de=20l'op=C3=A9rateur=20et=20supp?= =?UTF-8?q?ort=20de=20rbash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ajax.php | 25 +++++++++++++++++-------- config-sample.php | 2 -- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ajax.php b/ajax.php index f5dbf5c..e82b93a 100644 --- a/ajax.php +++ b/ajax.php @@ -38,29 +38,38 @@ if (!empty($_POST['action'])) { if ($session->isConnected()) { $operator = !empty($config['operator']) ? ' ' . $config['operator'] . ' ' : ' && '; - $gitstatus = 'git fetch' . $operator . 'git status'; + $gitcommand = 'git --git-dir=' . $config['path'] . '/.git --work-tree=' . $config['path']; if ($_POST['action'] == 'status') { - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . $gitstatus)); + echo ansi2html($session->exec($gitcommand . ' fetch')); + echo ansi2html($session->exec($gitcommand . ' status')); exit; } else if (strpos($_POST['action'], 'push') !== false) { if (strpos($_POST['action'], 'force') !== false) { - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . 'git push' . $operator . $gitstatus)); + echo ansi2html($session->exec($gitcommand . ' push')); + echo ansi2html($session->exec($gitcommand . ' fetch')); + echo ansi2html($session->exec($gitcommand . ' status')); if (!empty($config['after_push'])) { - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . $config['after_push'])); + echo ansi2html($session->exec($config['after_push'])); } } else { $message = empty($_POST['message']) ? 'FTP' : str_replace(array('"', "'"), ' ', stripslashes($_POST['message'])); - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . 'git add -A' . $operator . 'git commit -m "' . $message . '"' . $operator . 'git push' . $operator . $gitstatus)); + echo ansi2html($session->exec($gitcommand . ' add -A')); + echo ansi2html($session->exec($gitcommand . ' commit -m "' . $message . '"')); + echo ansi2html($session->exec($gitcommand . ' push')); + echo ansi2html($session->exec($gitcommand . ' fetch')); + echo ansi2html($session->exec($gitcommand . ' status')); if (!empty($config['after_push'])) { - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . $config['after_push'])); + echo ansi2html($session->exec($config['after_push'])); } } exit; } else if ($_POST['action'] == 'pull') { - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . 'git pull' . $operator . $gitstatus)); + echo ansi2html($session->exec($gitcommand . ' pull')); + echo ansi2html($session->exec($gitcommand . ' fetch')); + echo ansi2html($session->exec($gitcommand . ' status')); if (!empty($config['after_pull'])) { - echo ansi2html($session->exec('cd ' . $config['path'] . $operator . $config['after_pull'])); + echo ansi2html($session->exec($config['after_pull'])); } exit; } else { diff --git a/config-sample.php b/config-sample.php index 00cd4d3..147a545 100644 --- a/config-sample.php +++ b/config-sample.php @@ -22,7 +22,6 @@ $servers = array( 'pass' => 'root', 'path' => '/home/user/root', 'after_push' => 'php -f TAMERE.php', - 'operator' => '&&' # bash style ), 'test1' => array( 'title' => 'Test de la mort', @@ -32,7 +31,6 @@ $servers = array( 'pass' => 'blbl', 'path' => '/home/user/test', 'after_pull' => 'php -f TONPERE.php', - 'operator' => '; and' # fish style ), 'prod2' => array( 'title' => 'Production de la mort',