Adminer 是一款单文件的 PHP 数据库管理工具,这里列出的 小工具包括 时间错 转本地时间, IP 归属地显示,数据库 结构对比
Adminer 时间戳转日期
javascript:(function(){/*@ Adminer 时间戳转日期 */
/* 获取所有数据单元格 */
var doms = document.getElementsByTagName('td'),
hash = {},
pad = function (value) {
value = String(value);
while (value.length < 2) { value = '0' + value; }
return value;
},
reg = /^\d{10}(\.\d{1,3})?$/;
if(!doms){
return false;
}
for(k in doms){
txt = doms[k].innerHTML;
if(reg.test(txt)){
t = new Date(parseInt(txt) * 1000),
Y = t.getFullYear(),
m = pad(t.getMonth() + 1),
d = pad(t.getDate()),
H = pad(t.getHours()),
i = pad(t.getMinutes()),
s = pad(t.getSeconds()),
doms[k].innerHTML += ' '+ [Y,m,d].join('-') +' '+ [H,i,s].join(':');
}
}
})();
Adminer IP 列增加 归属地信息
javascript:(function(){/*@ Adminer IP 列增加 归属地信息 */
/* 获取所有数据单元格 */
var doms = document.getElementById('table').getElementsByTagName('td'),
hash = {},
ips = [],
ipReg = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/;
if(!doms){
return false;
}
for(k in doms){
txt = doms[k].innerHTML;
if(!hash[txt] && ipReg.test(txt)){
ips.push(txt);
hash[txt] = true;
}
}
var n = 50, l = ips.length / n;
for(i = 0; i < l; i++){
getInfo(ips.slice(n * i, n * (i + 1)));
}
window.showAddressInfo = function(a){
var doms = document.getElementById('table').getElementsByTagName('td');
for(k in doms){
txt = doms[k].innerHTML;
if(ipReg.test(txt) && a[txt]){
i = a[txt];
doms[k].innerHTML += ' ['+ [i.dz, i.wl].join(',') +']';
}
}
};
function getInfo(_ip){
var js = document.createElement("script");
js.src = "https://api.asilu.com/ip/?callback=showAddressInfo&ip="+ _ip.join(',');
js.onload = js.onreadystatechange = function(){
if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
js.parentNode.removeChild(js);
}
};
document.getElementsByTagName("head")[0].appendChild(js);
}
})();
Adminer 数据库 结构对比
javascript:(function(){var driver='adminer';/*@ Adminer 差异对比 **/
var newWindow=window.open('//cdn.asilu.com/ace-merge/?_='+(new Date)/ 1000);function addElement(tag,opt,parent){if(!tag){return;}
var dom=document.createElement(tag);var on=function(d,n,c){if(typeof c=='function'){d.addEventListener(n,c);}else{d.setAttribute(''+n,c);}};if(typeof opt=='object'){for(var k in opt){var _val=opt[k];if(typeof _val=='object'){for(var n in _val){if(k=='on'){on(dom,n,_val[n]);}else{dom[k][n]=_val[n];}}}else{if(k.indexOf('on')==0){on(dom,k.substr(2),opt[k]);}else{dom[k]=opt[k];}}}}
(parent||document.body).appendChild(dom);return dom;}
var ids={};window.addEventListener('beforeunload',function(event){newWindow.postMessage({act:'close'},'*');});window.addEventListener('message',function(a){let data=a.data;if(a.source!==window.self&&data.act){switch(data.act){case'_http':if(data.id&&!ids[data.id]){ids[data.id]=1;let header=new Headers();header.append('Accept-Encoding','deflate, gzip;q=1.0, *;q=0.5');if(data.method=='POST'&&typeof data.body=='object'){if(!(data.body instanceof FormData)){let formData=new FormData();for(let k in data.body){if(data.body[k]instanceof Array){data.body[k].forEach(e=>{formData.append(k,e)});}else{formData.append(k,data.body[k]);}}
data.body=formData;}}else{header.append('Content-Type',/^[\[\{][\S\s]*[\}\]]$/.test(data.body)?'application/json':'application/x-www-form-urlencoded');}
let ts=['text','arrayBuffer','blob','json','formData'];fetch(data.url,{method:data.method,body:data.body,headers:header}).then(e=>e[ts.indexOf(data.type)>-1?data.type:ts[0]]()).then(e=>newWindow.postMessage({id:data.id,act:'proxy',data:e},'*'))}
break;case'load':if(driver){newWindow.postMessage({act:'driver',driver:driver},'*');newWindow.postMessage({act:'set',pos:0,data:''},'*');driver=null;}
break;case'eval':newWindow.postMessage({id:data.id,act:'proxy',data:eval(data.js)},'*');break;case'init':break;default:}}});})();
以上代码复制保存为书签即可在 Adminer 页面使用