V
V
Vadim2018-01-14 02:19:10
PHP
Vadim, 2018-01-14 02:19:10

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

As a result of the request, the contents of the file are overwritten (if the file was not empty).
I tried to send the same data with a POST request, as a result it gives an authorization page.
How to edit a file correctly?
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
green_goo, 2019-10-31
@krka92

https://www.php.net/manual/en/function.copy.php

V
Vadim, 2018-01-14
@ShVad

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

The file has been edited.

N
Nikolai, 2018-11-07
@nikoniki

// 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 question

Ask a Question

731 491 924 answers to any question