2013-10-02 10:21:30 +00:00
|
|
|
<?php
|
|
|
|
|
2013-10-02 12:27:20 +00:00
|
|
|
require_once 'config/config.php';
|
2013-10-02 13:22:31 +00:00
|
|
|
require_once 'config/color.php';
|
|
|
|
require_once 'Net/SSH2.php';
|
2013-10-02 12:27:20 +00:00
|
|
|
global $servers;
|
2013-10-02 14:33:16 +00:00
|
|
|
$gitstatus = 'git fetch && git status';
|
2013-10-02 12:27:20 +00:00
|
|
|
|
|
|
|
if (!empty($_POST['section'])) {
|
|
|
|
foreach ($servers as $ssh) {
|
|
|
|
if (array_key_exists($_POST['section'], $ssh)) {
|
|
|
|
$config = $ssh[$_POST['section']];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST['action'])) {
|
2013-10-02 12:47:25 +00:00
|
|
|
$session = new Net_SSH2($config['host'], $config['port']);
|
2013-10-02 13:22:31 +00:00
|
|
|
if ($session->login($config['user'], $config['pass'])) {
|
2013-10-02 12:47:25 +00:00
|
|
|
if ($_POST['action'] == 'status') {
|
2013-10-02 14:33:16 +00:00
|
|
|
echo ansi2html($session->exec('cd ' . $config['path'] . ' && ' . $gitstatus));
|
2013-10-02 12:47:25 +00:00
|
|
|
} else if ($_POST['action'] == 'push') {
|
|
|
|
$message = empty($_POST['message']) ? 'FTP' : $_POST['message'];
|
2013-10-02 14:46:02 +00:00
|
|
|
echo ansi2html($session->exec('cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push && ' . $gitstatus));
|
2013-10-02 12:47:25 +00:00
|
|
|
} else if ($_POST['action'] == 'pull') {
|
2013-10-02 14:46:02 +00:00
|
|
|
echo ansi2html($session->exec('cd ' . $config['path'] . ' && git pull && ' . $gitstatus));
|
2013-10-02 12:47:25 +00:00
|
|
|
}
|
2013-10-02 12:27:20 +00:00
|
|
|
}
|
|
|
|
}
|