Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
<SoftKeyItem> <Name>Next Page</Name> <URL>http://webserver/cisco/show_phones.php?from=32</URL> <Position>4</Position> </SoftKeyItem>
<SoftKeyItem> <Name>Select</Name> <URL>SoftKey:Select</URL> <Position>1</Position> </SoftKeyItem>
var myuserid="PhoneOwner";//this is the user object associated to the phone
var mypassword="PhoneOwnerPassword";//this is the user password
//modify the myphonelistr to include a list of phones you want updated, comma separated
//a string value of one IP address is acceptable
var myphoneliststr = "1.1.1.1,1.1.1.2,1.1.1.3"; //"10.3.199.32,10.3.199.33" is another example
var myxmllist="XML=#XML=#XML=#XML=#XML=#XML=#XML=#XML=";
var myxmlarr = myxmllist.split("#");
var myphonearr = myphoneliststr.split(","); //create an array to walk through
var myauth = text2base64(myuserid + ":" + mypassword);//Create HTML basic auth string
var xmlhttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0"); //Object used for client connection
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fl = fso.CreateTextFile("log.txt", true);
// Loop through the phone list
for (var i=0;i<myphonearr.length;i++)
{
fl.WriteLine("---------------" + myphonearr[i] + "----------------------");
for (var j=0;j<myxmlarr.length;j++)
{
var myxml = myxmlarr[j];
fl.WriteLine(myxml);
var WebServer = "http://" + myphonearr[i] + "/CGI/Execute";
xmlhttp.open("POST", WebServer, false);
with (xmlhttp){
setRequestHeader("Man", "POST " + WebServer + " HTTP/1.1");
setRequestHeader("MessageType", "CALL");
setRequestHeader("Content-Type", "text/xml");
setRequestHeader("Host", myphonearr[i] + ":80");
setRequestHeader("Authorization", "Basic " + myauth);
setRequestHeader("Content-length", myxml.length);
}
xmlhttp.send(myxml);
fl.WriteLine("----------->" + xmlhttp.responseText);
sleep(1000);
}
}
fl.Close();
/******************************************************
function text2base64() Used to create hashed string
******************************************************/
function text2base64(text) {
var j = 0;
var i = 0;
var base64 = new Array();
var base64string = "";
var base64key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var text0, text1, text2;
////////////////////////////////////////////////////////////////////////////////////////////////////
// Step thru the input text string 3 characters per loop, creating 4 output characters per loop //
////////////////////////////////////////////////////////////////////////////////////////////////////
for (i=0; i < text.length; )
{
text0 = text.charCodeAt(i);
text1 = text.charCodeAt(i+1);
text2 = text.charCodeAt(i+2);
base64[j] = base64key.charCodeAt((text0 & 252) >> 2);
if ((i+1)<text.length) // i+1 is still part of string
{
base64[j+1] = base64key.charCodeAt(((text0 & 3) << 4)|((text1 & 240) >> 4));
if ((i+2)<text.length) // i+2 is still part of string
{
base64[j+2] = base64key.charCodeAt(((text1 & 15) << 2) | ((text2 & 192) >> 6));
base64[j+3] = base64key.charCodeAt((text2 & 63));
}
else
{
base64[j+2] = base64key.charCodeAt(((text1 & 15) << 2));
base64[j+3] = 61;
}
}
else
{
base64[j+1] = base64key.charCodeAt(((text0 & 3) << 4));
base64[j+2] = 61;
base64[j+3] = 61;
}
i=i+3;
j=j+4;
}
////////////////////////////////////////////
// Create output string from byte array //
////////////////////////////////////////////
for (i=0; i<base64.length; i++)
{
base64string += String.fromCharCode(base64[i]);
}
return base64string;
}
function sleep(milliSeconds){
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}
Создание телефонного справочника для ip-телефонов Cisco