Fixes in dashboard for save php ini in server
This commit is contained in:
parent
05025fbdb5
commit
56157e4adb
3 changed files with 118 additions and 29 deletions
28
dashboard.py
28
dashboard.py
|
|
@ -217,6 +217,8 @@ def get_php_server(php_server_id):
|
|||
|
||||
check_task=True
|
||||
|
||||
result={}
|
||||
|
||||
while check_task:
|
||||
|
||||
with db.query('select * from logtask where task_id=%s order by id DESC limit 1', [task_id]) as cursor:
|
||||
|
|
@ -226,12 +228,32 @@ def get_php_server(php_server_id):
|
|||
if arr_log:
|
||||
|
||||
if arr_log['status']==1:
|
||||
print(arr_log)
|
||||
|
||||
error=arr_log['error']
|
||||
check_task=False
|
||||
|
||||
if not error:
|
||||
with db.query('select * from resulttask where task_id=%s', [task_id]) as cursor:
|
||||
result=cursor.fetchone()
|
||||
|
||||
|
||||
return {'error': error, 'error_form': error_form, 'log': arr_log, 'task_id': task_id}
|
||||
return {'error': error, 'error_form': error_form, 'log': arr_log, 'result': result, 'task_id': task_id}
|
||||
|
||||
@phpserver_app.route('/phpserver/save_php_ini/<int:php_server_id>/')
|
||||
def save_php_ini(php_server_id):
|
||||
|
||||
db=g.connection
|
||||
|
||||
error=1
|
||||
error_form={}
|
||||
task_id=0
|
||||
|
||||
result={}
|
||||
|
||||
with db.query('select serverdbtask.hostname, serverdbtask.ip, serverdbtask.ssh_port, phpserver.version from serverdbtask, phpserver where phpserver.server_id=serverdbtask.id and phpserver.id=%s', [php_server_id]) as cursor:
|
||||
arr_server=cursor.fetchone()
|
||||
|
||||
if arr_server:
|
||||
|
||||
sshtask=SSHTask(db)
|
||||
|
||||
return {'error': error, 'error_form': error_form, 'log': arr_log, 'result': result, 'task_id': task_id}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from pastafariutils import linux
|
|||
import distro
|
||||
import argparse
|
||||
import os
|
||||
import json
|
||||
|
||||
php_versions=['8.2', '8.3', '8.4']
|
||||
|
||||
|
|
@ -18,7 +19,29 @@ args=parser.parse_args()
|
|||
|
||||
version=args.version
|
||||
|
||||
linux.json_log('Getting php.ini from server', error=0, status=0, progress=0, no_progress=1);
|
||||
|
||||
if not version in php_versions:
|
||||
linux.json_log('Error: php version not supported', error=1, status=1, progress=100, no_progress=0);
|
||||
exit(1)
|
||||
|
||||
path_php_ini='/etc/php/php.ini'
|
||||
|
||||
if linux_distro=='debian':
|
||||
path_php_ini='/etc/php/{}/fpm/php.ini'.format(version)
|
||||
|
||||
#print(path_php_ini)
|
||||
|
||||
if not os.path.isfile(path_php_ini):
|
||||
|
||||
linux.json_log('Error: php.ini not found in {}'.path_php_ini(), error=1, status=1, progress=100, no_progress=0);
|
||||
exit(1)
|
||||
|
||||
php_ini_file=''
|
||||
|
||||
with open(path_php_ini) as f:
|
||||
php_ini_file=f.read()
|
||||
|
||||
#print(json.dumps({'error': 0, 'status': 1, 'progress': 100, 'no_progress':0, 'message': '{"distro": "'+distro.id()+'"}', 'result': 1}))
|
||||
|
||||
linux.json_log(json.dumps({'file':php_ini_file}), error=0, status=1, progress=100, no_progress=0, result=1)
|
||||
|
|
|
|||
|
|
@ -5,40 +5,84 @@
|
|||
<%block name="content">
|
||||
<h3>${_('Edit php.ini')}</h3>
|
||||
<div class="form">
|
||||
<div id="php_ini">
|
||||
<div id="php_ini" style="height:600px;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<form method="post" name="save_php_ini" id="save_php_ini">
|
||||
<input type="submit" name="php_ini" value="${_('Save php.ini')}" id="php_ini" />
|
||||
</form>
|
||||
</p>
|
||||
</%block>
|
||||
<%block name="jscript_block">
|
||||
<script src=" https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.3/ace.min.js"></script>
|
||||
<script>
|
||||
|
||||
$.ajax({
|
||||
url: "${url_for('phpserver_app.get_php_server', php_server_id=php_server_id)}",
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
data: {},
|
||||
success: function (data) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
if(data.log.error) {
|
||||
|
||||
$('#php_ini').html(data.log.message);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
alert('Error: '+data.status+' '+data.statusText);
|
||||
|
||||
}
|
||||
});
|
||||
$(document).ready( function (e) {
|
||||
|
||||
$('#layer_loading').show();
|
||||
|
||||
var editor = ace.edit("php_ini");
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
$.ajax({
|
||||
url: "${url_for('phpserver_app.get_php_server', php_server_id=php_server_id)}",
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
data: {},
|
||||
success: function (data) {
|
||||
|
||||
$('#layer_loading').hide();
|
||||
|
||||
console.log(data);
|
||||
|
||||
if(data.log.error) {
|
||||
|
||||
$('#php_ini').html(data.log.message);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
file=JSON.parse(data.result.message);
|
||||
|
||||
//console.log(file);
|
||||
|
||||
//$('#php_ini').html(file.file);
|
||||
//editor.setValue(file.file, -1);
|
||||
editor.session.setValue(file.file);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
$('#layer_loading').hide();
|
||||
|
||||
alert('Error: '+data.status+' '+data.statusText);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editor = ace.edit("php_ini");
|
||||
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.session.setMode("ace/mode/ini");
|
||||
|
||||
});
|
||||
|
||||
options={'url': '${url_for("phpserver_app.save_php_ini", php_server_id=php_server_id)}', 'loading': '#layer_loading', 'success': function (data) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$('#del_phpserver').sendPost(options);
|
||||
|
||||
$('#save_php_ini').click( function (e) {
|
||||
|
||||
//console.log(editor.session.getValue());
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%block>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue