/ip hotspot user set [find name="User_Name"] password=New_Password
$API->write('/ip/hotspot/user/getall');
$API->write('=.proplist=name');
$API->write('?name=ilfeld');
$API->write('/ip/hotspot/user/set');
$API->write('=.id=*5');
$API->write('=password=yoyo');
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
print_r($ARRAY);
$API->write('/ip/hotspot/user/getall',false);
$API->write('=.proplist=name',false);
$API->write('?name=ilfeld');
#you have to read out something at this point
$API->write('/ip/hotspot/user/set',false);
$API->write('=.id=*5',false);
$API->write('=password=yoyo');
<html>
<body>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="hspot1.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>HotSpot Admin Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td width="78">Hotel Username</td>
<td width="6">:</td>
<td width="294"><strong>ilfeld</strong></td>
</tr>
<tr>
<td>New Password</td>
<td>:</td>
<td><input name="guestpassword" type="password" id="guestpassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<script language="JavaScript">
<!--
document.hotspot.myusername.focus();
//-->
</script>
</body>
</html>
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = false;
$myusername = $_POST["myusername"];
$mypassword = $_POST["mypassword"];
$guestpassword = $_POST["guestpassword"];
$cmmnd ="=password=";
$cmmnd .=$guestpassword;
$ipofsvr="111.111.111.111";
if ($API->connect($ipofsvr, $myusername, $mypassword)) {
echo "Password Changed successfully!";
$API->write('/ip/hotspot/user/getall',false);
$API->write('=.proplist=name',false);
$API->write('?name=ilfeld');
$API->write('/ip/hotspot/user/set',false);
$API->write('=.id=*5',false);
$API->write($cmmnd);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->disconnect();
}
else
{
echo "Incorrect Username or Password! Please try again!";
$API->disconnect();
}
?>
<html>
<head>
<title> hotspot > status</title>
<style type="text/css">
<!--
.style1 {
color: #660000;
font-weight: bold;
}
-->
</style>
$(if refresh-timeout)
<meta http-equiv="refresh" content="$(refresh-timeout-secs)">
$(endif)
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<style type="text/css">
<!--
textarea,input,select {
background-color: #FDFBFB;
border: 1px #BBBBBB solid;
padding: 2px;
margin: 1px;
font-size: 14px;
color: #808080;
}
.tabula{
border-width: 1px;
border-collapse: collapse;
border-color: #c1c1c1;
background-color: transparent;
font-family: verdana;
font-size: 11px;
}
body{ color: #737373; font-size: 12px; font-family: verdana; }
a, a:link, a:visited, a:active { color: #AAAAAA; text-decoration: none; font-size: 12px; }
a:hover { border-bottom: 1px dotted #c1c1c1; color: #AAAAAA; }
img {border: none;}
td { font-size: 12px; padding: 4px;}
.style2 {color: #660000}
-->
</style>
<script language="JavaScript">
<!--
$(if advert-pending == 'yes')
var popup = '';
function focusAdvert() {
if (window.focus) popup.focus();
}
function openAdvert() {
popup = open('$(link-advert)', 'hotspot_advert', '');
setTimeout("focusAdvert()", 1000);
}
$(endif)
function openLogout() {
if (window.name != 'hotspot_status') return true;
open('$(link-logout)', 'hotspot_logout', 'toolbar=0,location=0,directories=0,status=0,menubars=0,resizable=1,width=280,height=250');
window.close();
return false;
}
//-->
</script>
</head>
<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0"
$(if advert-pending == 'yes')
onLoad="openAdvert()"
$(endif)
>
<table width="100%" height="100%">
<tr>
<td align="center" valign="middle">
<form action="$(link-logout)" name="logout" onSubmit="return openLogout()">
<table border="1" class="tabula">
$(if login-by == 'trial')
<br><div style="text-align: center;">Welcome trial user!</div><br>
$(elif login-by != 'mac')
<br><div style="text-align: center;">Welcome $(username)!</div><br>
$(endif)
<tr><td align="right">IP address:</td><td>$(ip)</td></tr>
<tr><td align="right">bytes up/down:</td><td>$(bytes-in-nice) / $(bytes-out-nice)</td></tr>
$(if session-time-left)
<tr><td align="right">connected / left:</td><td>$(uptime) / $(session-time-left)</td></tr>
$(else)
<tr><td align="right">connected:</td><td>$(uptime)</td></tr>
$(endif)
$(if blocked == 'yes')
<tr><td align="right">status:</td><td><div style="color: #FF8080">
<a href="$(link-advert)" target="hotspot_advert">advertisement</a> required</div></td>
$(elif refresh-timeout)
<tr><td align="right">status refresh:</td><td>$(refresh-timeout)</td>
$(endif)
</table>
$(if login-by-mac != 'yes')
<br>
<!-- user manager link
<button onclick="document.location='http://$(hostname)/user?subs='">status</button>
<!-- end of user manager link -->
<input type="submit" value="log off">
<label>
/</label>
<p>$(endif)</p>
<p class="style1"><a href="changepass.php">CHANGE PASSWORD</a></p>
</form>
</td>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="hspot1.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>HotSpot User Password change</strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Old Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td width="78"> </td>
<td width="6"> </td>
<td width="294">
</td>
</tr>
<tr>
<td>New Password</td>
<td>:</td>
<td><input name="newpassword" type="password" id="newpassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="submit"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<script language="JavaScript">
<!--
document.hotspot.myusername.focus();
//-->
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = false;
$myusername = $_POST["myusername"];
$mypassword = $_POST["mypassword"];
$newpassword= $_POST["newpassword"]
$cmmnd ="=password=";
$cmmnd .=$newpassword;
$ipofsvr="172.16.1.1";
if ($API->connect($ipofsvr, $myusername, $mypassword)) {
echo "Password Changed successfully!";
$API->write('/ip/hotspot/user/getall',false);
$API->write('=.proplist=name',false);
$API->write('?name=$myusername');
$API->write('/ip/hotspot/user/set',false);
$API->write('=name=$myusername',false);
$API->write($cmmnd);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->disconnect();
}
else
{
echo "Incorrect Username or Password! Please try again!";
$API->disconnect();
}
?>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$myusername = $_POST["myusername"];
$mypassword = $_POST["mypassword"];
$newpassword= $_POST["newpassword"];
$ipofsvr="172.16.1.1";
if ($API->connect($ipofsvr,'admin',"")) {
$API->write('/ip/hotspot/user/getall',false);
$API->write('/ip/hotspot/user/set/',false);
$API->write('=.id='.$myusername,false);
$API->write('=password='.$newpassword);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->disconnect();
echo "Password Changed successfully!";
}
else
{
echo "Incorrect Username or Password! Please try again!";
$API->disconnect();
}
?>
<body>
</body>
</html>
Connection attempt #1 to 172.16.1.1:8728... <<< [6] /login >>> [5, 39] !done >>> [37, 1] =ret=42aa9f5618bbc947415e1a680ee3b2b7 <<< [6] /login <<< [11] =name=admin <<< [44] =response=00b9325a654b8954ac191945f299c4c093 >>> [5, 1] !done Connected... <<< [23] /ip/hotspot/user/getall <<< [21] /ip/hotspot/user/set/ <<< [10] =.id=admin <<< [14] =password=test >>> [3, 189] !re >>> [7, 181] =.id=*1 >>> [11, 169] =name=admin >>> [15, 153] =password=admin >>> [16, 136] =profile=default >>> [16, 119] =uptime=1h30m12s >>> [18, 100] =bytes-in=21293900 >>> [19, 80] =bytes-out=22015929 >>> [17, 62] =packets-in=26375 >>> [18, 43] =packets-out=21254 >>> [11, 31] =dynamic=no >>> [9, 21] =comment= >>> [12, 8] =disabled=no >>> [5, 1] !done Disconnected... Password Changed successfully!
<?php
$username = $_POST['user'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="hspot1.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>HotSpot User Password change</strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><?php echo $username; ?><input name="myusername" type="hidden" id="myusername" value="<?php echo $username; ?>"></td>
</tr>
<tr>
<td>Old Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword" ></td>
</tr>
<tr>
<td width="78"> </td>
<td width="6"> </td>
<td width="294">
</td>
</tr>
<tr>
<td>New Password</td>
<td>:</td>
<td><input name="newpassword" type="password" id="newpassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="submit"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<script language="JavaScript">
<!--
document.hotspot.myusername.focus();
//-->
</script>
</body>
</html>
$API->write('=.id='.$myusername,false);
$API->write('=.id=*1,false);
Connection attempt #1 to 172.16.1.1:8728... <<< [6] /login >>> [5, 39] !done >>> [37, 1] =ret=3c459371715010e0476c6d91d2995876 <<< [6] /login <<< [11] =name=admin <<< [44] =response=00393c8c29e1e089dbbf83a720fc58bcc8 >>> [5, 1] !done Connected... <<< [23] /ip/hotspot/user/getall <<< [21] /ip/hotspot/user/set/ <<< [10] =.id=admin <<< [14] =password=test >>> [5, 35] !trap >>> [26, 8] =message=unknown parameter >>> [5, 1] !done Disconnected... Password Changed successfully!
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$myusername = $_POST["myusername"];
$mypassword = $_POST["mypassword"];
$newpassword= $_POST["newpassword"];
$ipofsvr="172.16.1.1";
if ($API->connect($ipofsvr,'admin',"")) {
$API->write('/ip/hotspot/user/getall');
$API->write('=.proplist=.id',false);
$API->write('?name='.$myusername);
$A = $API->read();
$A = $A[0];
echo "list .id value" .$A;
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->write('/ip/hotspot/user/set/',false);
$API->write('=.id='.$A['.id'],false);
$API->write('=password='.$newpassword);
$API->read();
$API->disconnect();
echo "Password Changed successfully!";
}
else
{
echo "Incorrect Username or Password! Please try again!";
$API->disconnect();
}
?>
Connection attempt #1 to 172.16.1.1:8728... <<< [6] /login >>> [5, 39] !done >>> [37, 1] =ret=c8e0d23ebe4ba26d3143df7ad2ba87a4 <<< [6] /login <<< [11] =name=admin <<< [44] =response=00e6d723bf535a6070e54f046d0acd1f26 >>> [5, 1] !done Connected... <<< [23] /ip/hotspot/user/getall <<< [14] =.proplist=.id <<< [11] ?name=admin >>> [5, 223] !trap >>> [31, 191] =message=no such command prefix >>> [5, 184] !done >>> [3, 179] !re >>> [7, 171] =.id=*1 >>> [9, 161] =comment= >>> [11, 149] =name=admin >>> [15, 133] =password=admin >>> [16, 116] =profile=default >>> [16, 99] =uptime=06:34:31 >>> [18, 80] =bytes-in=67384966 >>> [19, 60] =bytes-out=22911619 >>> [17, 42] =packets-in=63280 >>> [18, 23] =packets-out=29152 >>> [14, 8] =dynamic=false >>> [5, 1] !done list .id valueArray
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
Notice: Undefined variable: _ in C:\wamp\www\hotspot\routeros_api.class.php on line 217
if ((!$this->connected && !$STATUS['unread_bytes']) || ($this->connected && $_ == '!done' && !$STATUS['unread_bytes']))
[admin@test-B] /ip hotspot user> add name=one
[admin@test-B] /ip hotspot user> add name=two
[admin@test-B] /ip hotspot user> add name=three
[admin@test-B] /ip hotspot user> print
Flags: X - disabled, D - dynamic
# SERVER NAME ADDRESS PROFILE UPTIME
0 one default 0s
1 two default 0s
2 three default 0s
[admin@test-B] /ip hotspot user> :put [find]
*1;*2;*3
[admin@test-B] /ip hotspot user> add name=four
[admin@test-B] /ip hotspot user> remove [find where name="two"]
[admin@test-B] /ip hotspot user> add name=two
[admin@test-B] /ip hotspot user> :put [find]
*1;*3;*4;*5
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = false;
$myusername = $_POST["myusername"];
$mypassword = $_POST["mypassword"];
$guestpassword = $_POST["guestpassword"];
$cmmnd ="=password=";
$cmmnd .=$guestpassword;
$ipofsvr1="111.111.111.156";
$ipofsvr2="111.111.111.158";
if ($API->connect($ipofsvr1, $myusername, $mypassword)) {
echo "Password Changed Successfully Site1!<br>";
$API->write('/ip/hotspot/user/getall',false);
$API->write('=.proplist=name',false);
$API->write('?name=rvguest');
$API->write('/ip/hotspot/user/set',false);
$API->write('=.id=*2',false);
$API->write($cmmnd);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->disconnect();
}
else
{
echo "Incorrect Username or Password! Please try again!<br><br>";
$API->disconnect();
}
if ($API->connect($ipofsvr2, $myusername, $mypassword)) {
echo "Password Changed Successfully Site 2!<br>";
$API->write('/ip/hotspot/user/getall',false);
$API->write('=.proplist=name',false);
$API->write('?name=rvguest');
$API->write('/ip/hotspot/user/set',false);
$API->write('=.id=*2',false);
$API->write($cmmnd);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$API->disconnect();
}
else
{
echo "Incorrect Username or Password! Please try again!<BR><BR>";
$API->disconnect();
}
?>
if ($API->connect($ip, $usuario, $senha))
{
$API->write('/user/set',false);
$API->write('=name=teste3',false);
$API->write('=.id=teste4');
}
Script:
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$ip = 'xxx.xxx.xxx.xxx';
$usuario = 'teste4'; // full same admin
$senha = '123456';
if ($API->connect($ip, $usuario, $senha))
{
$API->write('/user/set',false);
$API->write('=name=teste3',false);
$API->write('=.0=teste4'); // Here a tried id, 0 and 1.
$API->disconnect();
$ip = 'xxx.xxx.xxx.xxx';
$usuario = 'teste3';
$senha = '123456';
if ($API->connect($ip, $usuario, $senha))
{
$API->write('/interface/getall');
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
}
}
A can´t login after command. The mikrotik try and try but Error...response received:
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=8441030695fedd9c963c770d925460cd
<<< [6] /login
<<< [12] =name=teste4
<<< [44] =response=000294eb58ca98ef53e55dd28b2ef0acf8
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [9] /user/set
<<< [12] =name=teste3
<<< [10] =.1=teste4
Disconnected...
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=9444b11262d1f06b1a62c81b2ddac860
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=007ed1d4468149966ca2196c4b82af1f16
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #2 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=2226666ebea49c0e354d4d766aa652c4
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=004f8ae6db35b745b8436120bbc8fd18cc
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #3 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=2c232466e70099e1c4d341aae933b386
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00f4461510173f8eae21702d2e626941ad
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #4 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=2128256d5a45199bb248d13db5e7f409
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00d747bd404d71a75980164f245806e96a
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #5 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=1e69034240d80270ae9564a517eba75a
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00b7e4073087bc37edd4d33ace5edb1a38
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Error...
Thank you for support Chupaka!the result:
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=4e210569c6f7eff5da86de598e944cc6
<<< [6] /login
<<< [12] =name=teste4
<<< [44] =response=00faa4671994be671fee69ff191c309311
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [9] /user/set
<<< [10] =.1=teste4
<<< [12] =name=teste3
Disconnected...
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=733e098726650cf35bfb42f6b84e411f
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=0053928d217e06c9d47e45144c7b000adb
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
(...)
the same
(...)
Error!
$API->write('=.id='.$old_name, false);
$API->write('/user/set', false);
$API->write('=.id='.$old_name, false);
$API->write('=name='.$new_name);
withif ($API->connect($ip, $usuario, $senha))
{
$API->write('/user/set',false);
$API->write('=name=teste3',false);
}
or somethingif ($API->connect($ip, $usuario, $senha))
{
$API->write('/user/set', false);
$API->write('=.id='.$old_name, false);
$API->write('=name='.$new_name);
}
[b]CODE:[/b]
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$old_name = 'teste4';
$new_name = 'teste3';
if ($API->connect('xxx.xxx.xxx.xxx', $old_name, '123456'))
{
$API->write('/user/set', false);
$API->write('=.1='.$old_name, false);
$API->write('=name='.$new_name);
$API->disconnect();
if ($API->connect('xxx.xxx.xxx.xxx', $new_name, '123456'))
{
$API->write('/interface/getall');
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
}
}
?>
[b]Result:[/b]
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=1fea1cbb243777b91c39e2619af7a197
<<< [6] /login
<<< [12] =name=teste4
<<< [44] =response=00f629fe98712aa6707d7b2c006ceafa07
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [9] /user/set
<<< [10] =.1=teste4
<<< [12] =name=teste3
Disconnected...
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=5da30379fe51f6c93686570473ab5706
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00a82eb97d3d594bcbe4120bf409f054c3
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #2 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=ea0fe30f2945afd024430890a82df8f5
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00c2d2fa3cdc9ac1697f298523f78f85cb
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #3 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=e8b4fcb738e821b9264db018e6275547
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00b857fba7e1673f062262a541a491442e
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #4 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=6373efc42eeb4c17be9224e3e4b2aeaa
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=001ee80de2577e3cf8942ac56d77c4bbb0
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #5 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=fc80bb852dc8357285bd0feb91471627
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=0096428d9e2f21031d6b264b78e98eaa9b
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Error...
Doubt:
But if I'm not using Winbox (in the real case), how will I know the old user id? Since the script will know what to put in place of 'id'?
$API->write('/user/set', false);
$API->write('=.1='.$old_name, false);
$API->write('=name='.$new_name);
$API->write('/user/set', false);
$API->write('=.id='.$old_name, false);
$API->write('=name='.$new_name);
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=1fb26a805b6554171b758e2e4ebd29dc
<<< [6] /login
<<< [12] =name=teste4
<<< [44] =response=00dc50211d69169a8c5a7efb66df7409e5
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [9] /user/set
<<< [11] =.id=teste4
<<< [12] =name=teste3
Disconnected...
Connection attempt #1 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=a611026006b72b6b16089e0bfd1548a6
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00533eacaa8714ecff1cc266c3b7e9249d
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #2 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=cc8e149aad11f779aa7c60277b4ceca7
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00bc40244f4fa1748c02bf4a5dbd27d25d
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #3 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=ca026c0bf26b706a94959ff95b0fee55
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00066086e924161a180279de2d3b5c7a7f
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #4 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=c598dd21f695386cf18de9ae655032c5
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=006b0b49629aea59dae657b575dfb85d74
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Connection attempt #5 to 192.168.200.221:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=b833b02cc8f5344dcc3a30cea283991b
<<< [6] /login
<<< [12] =name=teste3
<<< [44] =response=00fc0290d1fea1f6487cc25171acd7cec1
>>> [5/5 bytes read.
>>> [5, 31] !trap
>>> [22/22 bytes read.
>>> [22, 8] =message=cannot log in
>>> [5/5 bytes read.
>>> [5, 1] !done
Error...
Connected...
<<< [9] /user/set
<<< [11] =.id=teste4
<<< [12] =name=teste3
Disconnected...
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$ip = 'xxx.xxx.xxx.xxx';
$old_password = '123456';
$old_name = 'testeb';
$new_password = '123456';
$new_name = 'testea';
if ($API->connect($ip, $old_name, $old_password))
{
$API->write('/user/set', false);
$API->write('=.id='.$old_name, false);
$API->write('=name='.$new_name);
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
if ($API->connect($ip, $new_name, $new_password))
{
$API->write('/interface/getall');
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
}
}
?>
Connection attempt #1 to xxx.xxx.xxx.xxx:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=cfc3bb0305947b63aa5cc3c4b068685b
<<< [6] /login
<<< [12] =name=testeb
<<< [44] =response=00ad387bab4a4f1e0e36fecf63a588f7be
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [9] /user/set
<<< [11] =.id=testeb
<<< [12] =name=testea
>>> [5/5 bytes read.
>>> [5, 1] !done
Array
(
)
Disconnected...
Connection attempt #1 to xxx.xxx.xxx.xxx:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=feac54a9279e6b5fc2db16886d3504ff
<<< [6] /login
<<< [12] =name=testea
<<< [44] =response=00f565dbddd9a335bb8559b4c48c32c16c
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [17] /interface/getall
>>> [3/3 bytes read.
>>> [3, 437] !re
>>> [7/7 bytes read.
>>> [7, 429] =.id=*1
>>> [12/12 bytes read.
>>> [12, 416] =name=ether1
>>> [11/11 bytes read.
>>> [11, 404] =type=ether
>>> [9/9 bytes read.
>>> [9, 394] =mtu=1500
>>> [11/11 bytes read.
>>> [11, 382] =l2mtu=1526
>>> [20/20 bytes read.
>>> [20, 361] =bytes=277611/136422
>>> [17/17 bytes read.
>>> [17, 343] =packets=2544/637
>>> [14/14 bytes read.
>>> [14, 328] =dynamic=false
>>> [13/13 bytes read.
>>> [13, 314] =running=true
>>> [15/15 bytes read.
>>> [15, 298] =disabled=false
>>> [9/9 bytes read.
>>> [9, 288] =comment=
>>> [3/3 bytes read.
>>> [3, 283] !re
>>> [7/7 bytes read.
>>> [7, 275] =.id=*2
>>> [12/12 bytes read.
>>> [12, 262] =name=ether2
>>> [11/11 bytes read.
>>> [11, 250] =type=ether
>>> [9/9 bytes read.
>>> [9, 240] =mtu=1500
>>> [11/11 bytes read.
>>> [11, 228] =l2mtu=1522
>>> [10/10 bytes read.
>>> [10, 217] =bytes=0/0
>>> [12/12 bytes read.
>>> [12, 204] =packets=0/0
>>> [14/14 bytes read.
>>> [14, 189] =dynamic=false
>>> [14/14 bytes read.
>>> [14, 174] =running=false
>>> [15/15 bytes read.
>>> [15, 158] =disabled=false
>>> [9/9 bytes read.
>>> [9, 148] =comment=
>>> [3/3 bytes read.
>>> [3, 143] !re
>>> [7/7 bytes read.
>>> [7, 135] =.id=*3
>>> [12/12 bytes read.
>>> [12, 122] =name=ether3
>>> [11/11 bytes read.
>>> [11, 110] =type=ether
>>> [9/9 bytes read.
>>> [9, 100] =mtu=1500
>>> [11/11 bytes read.
>>> [11, 88] =l2mtu=1522
>>> [10/10 bytes read.
>>> [10, 77] =bytes=0/0
>>> [12/12 bytes read.
>>> [12, 64] =packets=0/0
>>> [14/14 bytes read.
>>> [14, 49] =dynamic=false
>>> [14/14 bytes read.
>>> [14, 34] =running=false
>>> [15/15 bytes read.
>>> [15, 18] =disabled=false
>>> [9/9 bytes read.
>>> [9, 8] =comment=
>>> [5/5 bytes read.
>>> [5, 1] !done
Array
(
[0] => Array
(
[.id] => *1
[name] => ether1
[type] => ether
[mtu] => 1500
[l2mtu] => 1526
[bytes] => 277611/136422
[packets] => 2544/637
[dynamic] => false
[running] => true
[disabled] => false
[comment] =>
)
[1] => Array
(
[.id] => *2
[name] => ether2
[type] => ether
[mtu] => 1500
[l2mtu] => 1522
[bytes] => 0/0
[packets] => 0/0
[dynamic] => false
[running] => false
[disabled] => false
[comment] =>
)
[2] => Array
(
[.id] => *3
[name] => ether3
[type] => ether
[mtu] => 1500
[l2mtu] => 1522
[bytes] => 0/0
[packets] => 0/0
[dynamic] => false
[running] => false
[disabled] => false
[comment] =>
)
)
Disconnected...
yep, simply click HEREHow does the karma system you mentioned? Just click on how I want?
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
$ip = 'xxx.xxx.xxx.xxx';
$old_password = '123456';
$old_name = 'testea';
$new_password = '123456';
$new_name = 'testeb';
if ($API->connect($ip, $old_name, $old_password))
{
$API->write('/user/add', false);
$API->write('=group=full', false);
$API->write('=name=zuca', false);
$API->write('=password=123456');
$new_name = 'zuca';
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
if ($API->connect($ip, $new_name, $new_password))
{
$API->write('/interface/getall');
$ARRAY = $API->read();
print_r($ARRAY);
$API->disconnect();
}
}
?>
Connection attempt #1 to xxx.xxx.xxx.xxx:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=7b4519f9cce802b64a4181386154b012
<<< [6] /login
<<< [12] =name=testea
<<< [44] =response=002db108e8acd3b2e230e3b94be5a245ee
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [9] /user/add
<<< [11] =group=full
<<< [10] =name=zuca
<<< [16] =password=123456
>>> [5/5 bytes read.
>>> [5, 9] !done
>>> [7/7 bytes read.
>>> [7, 1] =ret=*6
Array
(
)
Disconnected...
Connection attempt #1 to xxx.xxx.xxx.xxx:8728...
<<< [6] /login
>>> [5/5 bytes read.
>>> [5, 39] !done
>>> [37/37 bytes read.
>>> [37, 1] =ret=17779f55f1437de64473ea814fe411b9
<<< [6] /login
<<< [10] =name=zuca
<<< [44] =response=00ce3d55b646aa538e6b1ebd110900b910
>>> [5/5 bytes read.
>>> [5, 1] !done
Connected...
<<< [17] /interface/getall
>>> [3/3 bytes read.
>>> [3, 438] !re
>>> [7/7 bytes read.
>>> [7, 430] =.id=*1
>>> [12/12 bytes read.
>>> [12, 417] =name=ether1
>>> [11/11 bytes read.
>>> [11, 405] =type=ether
>>> [9/9 bytes read.
>>> [9, 395] =mtu=1500
>>> [11/11 bytes read.
>>> [11, 383] =l2mtu=1526
>>> [20/20 bytes read.
>>> [20, 362] =bytes=898078/202207
>>> [18/18 bytes read.
>>> [18, 343] =packets=7061/1064
>>> [14/14 bytes read.
>>> [14, 328] =dynamic=false
>>> [13/13 bytes read.
>>> [13, 314] =running=true
>>> [15/15 bytes read.
>>> [15, 298] =disabled=false
>>> [9/9 bytes read.
>>> [9, 288] =comment=
>>> [3/3 bytes read.
>>> [3, 283] !re
>>> [7/7 bytes read.
>>> [7, 275] =.id=*2
>>> [12/12 bytes read.
>>> [12, 262] =name=ether2
>>> [11/11 bytes read.
>>> [11, 250] =type=ether
>>> [9/9 bytes read.
>>> [9, 240] =mtu=1500
>>> [11/11 bytes read.
>>> [11, 228] =l2mtu=1522
>>> [10/10 bytes read.
>>> [10, 217] =bytes=0/0
>>> [12/12 bytes read.
>>> [12, 204] =packets=0/0
>>> [14/14 bytes read.
>>> [14, 189] =dynamic=false
>>> [14/14 bytes read.
>>> [14, 174] =running=false
>>> [15/15 bytes read.
>>> [15, 158] =disabled=false
>>> [9/9 bytes read.
>>> [9, 148] =comment=
>>> [3/3 bytes read.
>>> [3, 143] !re
>>> [7/7 bytes read.
>>> [7, 135] =.id=*3
>>> [12/12 bytes read.
>>> [12, 122] =name=ether3
>>> [11/11 bytes read.
>>> [11, 110] =type=ether
>>> [9/9 bytes read.
>>> [9, 100] =mtu=1500
>>> [11/11 bytes read.
>>> [11, 88] =l2mtu=1522
>>> [10/10 bytes read.
>>> [10, 77] =bytes=0/0
>>> [12/12 bytes read.
>>> [12, 64] =packets=0/0
>>> [14/14 bytes read.
>>> [14, 49] =dynamic=false
>>> [14/14 bytes read.
>>> [14, 34] =running=false
>>> [15/15 bytes read.
>>> [15, 18] =disabled=false
>>> [9/9 bytes read.
>>> [9, 8] =comment=
>>> [5/5 bytes read.
>>> [5, 1] !done
Array
(
[0] => Array
(
[.id] => *1
[name] => ether1
[type] => ether
[mtu] => 1500
[l2mtu] => 1526
[bytes] => 898078/202207
[packets] => 7061/1064
[dynamic] => false
[running] => true
[disabled] => false
[comment] =>
)
[1] => Array
(
[.id] => *2
[name] => ether2
[type] => ether
[mtu] => 1500
[l2mtu] => 1522
[bytes] => 0/0
[packets] => 0/0
[dynamic] => false
[running] => false
[disabled] => false
[comment] =>
)
[2] => Array
(
[.id] => *3
[name] => ether3
[type] => ether
[mtu] => 1500
[l2mtu] => 1522
[bytes] => 0/0
[packets] => 0/0
[dynamic] => false
[running] => false
[disabled] => false
[comment] =>
)
)
Disconnected...
Pleaseyou cannot place it in RouterOS - you should use additional webserver with PHP support
$API->write(command,boolean)
i see thanks for it'true' means 'send the command, no more parameters will be added'
'false' means 'there will be additional words (parameters) in the command, send the command when the next call with "true" will be'
AFAIR
can't see anything unusual in v5.8... what's with 5.7? there's no 'up' arrow at the right, or something else?..a bug on winbox, on /ip hotspot user profile outgoing-filter= and incoming-filter=, u can't disable/remove it on GUI once activated(only through terminal command line). i'm running v5.7 ROS.
the GUI showing it is cleared(outgoing filter/incoming filter) but it is actually not, since when a hotspot user login with the profile, the dynamic still created. so i checked the configuration with terminal, and i see the filter still there. i had to clear the incoming/outgoing filter with command line.can't see anything unusual in v5.8... what's with 5.7? there's no 'up' arrow at the right, or something else?..a bug on winbox, on /ip hotspot user profile outgoing-filter= and incoming-filter=, u can't disable/remove it on GUI once activated(only through terminal command line). i'm running v5.7 ROS.
then, the same bug is in v5.8. have you reported it to support@?the GUI showing it is cleared(outgoing filter/incoming filter) but it is actually not, since when a hotspot user login with the profile, the dynamic still created. so i checked the configuration with terminal, and i see the filter still there. i had to clear the incoming/outgoing filter with command line.
not yet, i think it will be better if it is u report it than methen, the same bug is in v5.8. have you reported it to support@?the GUI showing it is cleared(outgoing filter/incoming filter) but it is actually not, since when a hotspot user login with the profile, the dynamic still created. so i checked the configuration with terminal, and i see the filter still there. i had to clear the incoming/outgoing filter with command line.
write to support@! I already have a few open tickets with bugs... errr, featuresnot yet, i think it will be better if it is u report it than me
found similiar bug. still on hotspot user profile, this one is on "Address Pool" field. still haven't written to support :pwrite to support@! I already have a few open tickets with bugs... errr, featuresnot yet, i think it will be better if it is u report it than me
print all your hotspot users - 'password' field should be herebut how to validate the old password?