Lib Mal Foutu D:
This commit is contained in:
parent
0f2e2c6a9f
commit
3b1bd49621
16
ajax.php
16
ajax.php
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'config/config.php';
|
require_once 'config/config.php';
|
||||||
|
require_once 'lib/Net/SSH2.php';
|
||||||
global $servers;
|
global $servers;
|
||||||
|
|
||||||
if (!empty($_POST['section'])) {
|
if (!empty($_POST['section'])) {
|
||||||
@ -13,18 +14,15 @@ if (!empty($_POST['section'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['action'])) {
|
if (!empty($_POST['action'])) {
|
||||||
$session = ssh2_connect($config['host'], $config['port']);
|
$session = new Net_SSH2($config['host'], $config['port']);
|
||||||
ssh2_auth_password($session, $config['user'], $config['pass']);
|
if ($ssh->login($config['user'], $config['pass'])) {
|
||||||
if ($_POST['action'] == 'status') {
|
if ($_POST['action'] == 'status') {
|
||||||
$output = ssh2_exec($session, 'cd ' . $config['path'] . ' && git fetch && git status');
|
echo $ssh->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'];
|
||||||
$output = ssh2_exec($session, 'cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push');
|
//echo $ssh->exec('cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push');
|
||||||
} else if ($_POST['action'] == 'pull') {
|
} else if ($_POST['action'] == 'pull') {
|
||||||
$output = ssh2_exec($session, 'cd ' . $config['path'] . ' && git pull');
|
//echo $ssh->exec('cd ' . $config['path'] . ' && git pull');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pre = stream_get_contents($output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array('pre' => $pre));
|
|
||||||
|
@ -14,8 +14,7 @@ function callRequest(section) {
|
|||||||
xhr.send('action=status§ion=' + section);
|
xhr.send('action=status§ion=' + section);
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {
|
if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {
|
||||||
var data = JSON.parse(xhr.responseText);
|
pre.innerHTML = xhr.responseText;
|
||||||
pre.innerHTML = data['pre'];
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user