Skip to content

Instantly share code, notes, and snippets.

@0test
Created April 30, 2021 16:35
Show Gist options
  • Save 0test/f27021917e7c9f94459fc938f1bf9933 to your computer and use it in GitHub Desktop.
Save 0test/f27021917e7c9f94459fc938f1bf9933 to your computer and use it in GitHub Desktop.
<?php
date_default_timezone_set('Europe/Moscow');
$host ='http://ursite.ru/manager/';
$auth_fields = [
'username' => 'administrator',
'password' => '******',
];
$header = [
'Accept: */*',
'Accept-Encoding: gzip, deflate',
'Accept-Language: ru,en;q=0.9',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: application/x-www-form-urlencoded;',
'Origin:' . $host,
'Pragma: no-cache',
'Referer: ' . $host,
];
if(file_exists(__DIR__ . '/cookie.txt')){unlink(__DIR__ . '/cookie.txt');}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $host . 'processors/login.processor.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($auth_fields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ .'/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ .'/cookie.txt');
/*
//проксик если надо. Тут для Тора.
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
*/
$answer = curl_exec($ch);
if($answer == 'error'){var_dump($answer);die;}
if (curl_error($ch)) {
echo curl_error($ch);
}
$backup_fields = [
'mode' => 'snapshot',
'backup_title' => 'автокопия от ' . date('d.m.Y_H:s'),
];
curl_setopt($ch, CURLOPT_URL, $host . 'index.php?a=93');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($backup_fields));
$answer = curl_exec($ch);
if (curl_error($ch)) {
echo curl_error($ch);
}
else{
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment