49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
set_time_limit(999);
|
|
// Need php with curl extension
|
|
|
|
// Params for request
|
|
$username = 'admin';
|
|
$password = 'Mot de passe';
|
|
|
|
// IP List split by coma ","
|
|
$ips = '192.168.4.10,192.168.4.11';
|
|
|
|
$split = ","; // Split by coma
|
|
//$split = "\n"; // Split by line
|
|
|
|
// Request to change a value
|
|
$request = 'system/web-server/protocols/https';
|
|
|
|
// Change HTTPS Parameters
|
|
$jsonData = '{
|
|
"enabled":true,
|
|
"port":443,
|
|
"tlsProtocol":"TLSv1.2",
|
|
"cipherSuiteGroup":"LEGACY"
|
|
}';
|
|
|
|
// For each IP in the list
|
|
foreach(explode($split,$ips) as $ip) {
|
|
if (trim($ip) == '') continue; // If IP is null don't send request
|
|
|
|
// Prepare Request
|
|
$ch = curl_init( 'https://' . trim($ip) . '/api/rest/v1/' . $request );
|
|
curl_setopt( $ch, CURLOPT_POSTFIELDS, $jsonData );
|
|
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
|
curl_setopt( $ch, CURLOPT_USERPWD, $username . ":" . $password);
|
|
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
|
|
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 1 );
|
|
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, TRUE );
|
|
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
|
|
|
|
// Send request.
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
// Show result
|
|
echo $ip . "\n";
|
|
print_r($result);
|
|
echo "\n";
|
|
}
|