Les couleurs fonctionnent

This commit is contained in:
Michel Roux 2013-10-02 15:22:31 +02:00
parent 3b1bd49621
commit 11bab4d60b
3 changed files with 24 additions and 6 deletions

View File

@ -1,7 +1,8 @@
<?php <?php
require_once 'config/config.php'; require_once 'config/config.php';
require_once 'lib/Net/SSH2.php'; require_once 'config/color.php';
require_once 'Net/SSH2.php';
global $servers; global $servers;
if (!empty($_POST['section'])) { if (!empty($_POST['section'])) {
@ -15,14 +16,14 @@ if (!empty($_POST['section'])) {
if (!empty($_POST['action'])) { if (!empty($_POST['action'])) {
$session = new Net_SSH2($config['host'], $config['port']); $session = new Net_SSH2($config['host'], $config['port']);
if ($ssh->login($config['user'], $config['pass'])) { if ($session->login($config['user'], $config['pass'])) {
if ($_POST['action'] == 'status') { if ($_POST['action'] == 'status') {
echo $ssh->exec('cd ' . $config['path'] . ' && git fetch && git status'); echo ansi2html($session->exec('cd ' . $config['path'] . ' && git fetch && git status'));
} else if ($_POST['action'] == 'push') { } else if ($_POST['action'] == 'push') {
$message = empty($_POST['message']) ? 'FTP' : $_POST['message']; $message = empty($_POST['message']) ? 'FTP' : $_POST['message'];
//echo $ssh->exec('cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push'); //echo $session->exec('cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push');
} else if ($_POST['action'] == 'pull') { } else if ($_POST['action'] == 'pull') {
//echo $ssh->exec('cd ' . $config['path'] . ' && git pull'); //echo $session->exec('cd ' . $config['path'] . ' && git pull');
} }
} }
} }

17
config/color.php Normal file
View File

@ -0,0 +1,17 @@
<?php
function ansi2html($string) {
$dictionary = array(
'[30m' => '<span style="color:blue">',
'[31m' => '<span style="color:blue">',
'[32m' => '<span style="color:blue">',
'[33m' => '<span style="color:blue">',
'[34m' => '<span style="color:blue">',
'[35m' => '<span style="color:blue">',
'[36m' => '<span style="color:blue">',
'[37m' => '<span style="color:blue">',
'[m' => '</span>',
);
return str_replace(array_keys($dictionary), $dictionary, $string);
}

View File

@ -20,7 +20,7 @@ pre {
} }
.container { .container {
margin-top: 20px; margin: 20px auto;
} }
.nav { .nav {