Кто поможет переписать функцию с js в php?
[SPOILER]
function load_obj2(d, c) {
var b = d.prop("tagName");
var a = rc4(stime, Base64.decode(d.attr("data")));
if (b == "IMG") {
d.attr("src", a)
} else {
if (b == "A") {
d.attr("href", a)
} else {
if (b == "INPUT") {
d.val(a)
}
}
}
d.removeAttr("data").removeClass("obj")
}
function rc4(e, g) {
var f = [],
b = 0,
a, d = "";
for (var c = 0; c < 256; c++) {
f[c] = c
}
for (c = 0; c < 256; c++) {
b = (b + f[c] + e.charCodeAt(c % e.length)) % 256;
a = f[c];
f[c] = f[b];
f[b] = a
}
c = 0;
b = 0;
for (var h = 0; h < g.length; h++) {
c = (c + 1) % 256;
b = (b + f[c]) % 256;
a = f[c];
f[c] = f[b];
f[b] = a;
d += String.fromCharCode(g.charCodeAt(h) ^ f[(f[c] + f[b]) % 256])
}
return d
}
var Base64 = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode: function(c) {
var a = "";
var k, h, f, j, g, e, d;
var b = 0;
c = Base64._utf8_encode(c);
while (b < c.length) {
k = c.charCodeAt(b++);
h = c.charCodeAt(b++);
f = c.charCodeAt(b++);
j = k >> 2;
g = ((k & 3) << 4) | (h >> 4);
e = ((h & 15) << 2) | (f >> 6);
d = f & 63;
if (isNaN(h)) {
e = d = 64
} else {
if (isNaN(f)) {
d = 64
}
}
a = a + this._keyStr.charAt(j) + this._keyStr.charAt(g) + this._keyStr.charAt(e) + this._keyStr.charAt(d)
}
return a
},
decode: function(c) {
var a = "";
var k, h, f;
var j, g, e, d;
var b = 0;
c = c.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (b < c.length) {
j = this._keyStr.indexOf(c.charAt(b++));
g = this._keyStr.indexOf(c.charAt(b++));
e = this._keyStr.indexOf(c.charAt(b++));
d = this._keyStr.indexOf(c.charAt(b++));
k = (j << 2) | (g >> 4);
h = ((g & 15) << 4) | (e >> 2);
f = ((e & 3) << 6) | d;
a = a + String.fromCharCode(k);
if (e != 64) {
a = a + String.fromCharCode(h)
}
if (d != 64) {
a = a + String.fromCharCode(f)
}
}
a = Base64._utf8_decode(a);
return a
},
_utf8_encode: function(b) {
b = b.replace(/\r\n/g, "\n");
var a = "";
for (var e = 0; e < b.length; e++) {
var d = b.charCodeAt(e);
if (d < 128) {
a += String.fromCharCode(d)
} else {
if ((d > 127) && (d < 2048)) {
a += String.fromCharCode((d >> 6) | 192);
a += String.fromCharCode((d & 63) | 128)
} else {
a += String.fromCharCode((d >> 12) | 224);
a += String.fromCharCode(((d >> 6) & 63) | 128);
a += String.fromCharCode((d & 63) | 128)
}
}
}
return a
},
_utf8_decode: function(a) {
var b = "";
var d = 0;
var e = c1 = c2 = 0;
while (d < a.length) {
e = a.charCodeAt(d);
if (e < 128) {
b += String.fromCharCode(e);
d++
} else {
if ((e > 191) && (e < 224)) {
c2 = a.charCodeAt(d + 1);
b += String.fromCharCode(((e & 31) << 6) | (c2 & 63));
d += 2
} else {
c2 = a.charCodeAt(d + 1);
c3 = a.charCodeAt(d + 2);
b += String.fromCharCode(((e & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
d += 3
}
}
}
return b
}
};
[/SPOILER]