Answer the question
In order to leave comments, you need to log in
ISP Manager 5 API - How to edit a file?
Good afternoon
How to edit a file in ISP Manager 5 via API?
Based on the documentation at: /manager/ispmgr?authinfo=LOGIN:PASS&out=json&func=file.edit
You need to send a GET request:
[sok] => ok
[elid] => test.php
[plid] => /www/folder
[full_filepath] => ~/www/folder/test.php
[encoding] => UTF-8
[fdata] => Содержимое файла
[func] => file.edit
Answer the question
In order to leave comments, you need to log in
Solution:
We get the session number with a GET request:
Sending a POST request:
Content-type: application/x-www-form-urlencoded
Cookie: ispmgrses5=Номер_сессии;
ISP-Client: Web-interface
Referer: https://192.168.1.1:1500/ispmgr
[sok] => ok
[func] => file.edit
[elid] => file.php
[plid] => www
[full_filepath] => www/file.php
[encoding] => UTF-8
[fdata] => FILE CONTENT
// Create a file
$this->queryData([
'func' => 'file.new',
'dataType' => 'JSONdata',
'return_type' => 'ARR2',
'get' => [
'sok' = > 'ok',
'plid' => $site['dirname'].$dir,
'filetype' => 0,
'name' => $file_name,
'dest' => '',
'lang' => ' ru'
]
]);
// Change file
$this->mdl_isp->queryData([
'func' => 'file.edit',
'dataType' => 'JSONdata',
'return_type' => 'ARR2',
'post' => [
'full_filepath' => $site['dirname'].$dir ,
'fdata' => $content,
'elid' => $file_name,
'plid' => $site['dirname'].$dir,
'encoding' => 'UTF-8',
'mode' => ' html',
'lang' => 'ru',
'sok' => 'ok'
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question