|
|
שורה 61: |
שורה 61: |
| $('#refreshRETF').click(RETF.load); | | $('#refreshRETF').click(RETF.load); |
| }); | | }); |
|
| |
| (new mw.Api()).get({
| |
| action: 'query',
| |
| titles: 'מיוחד:רשימת משתמשים',
| |
| prop: 'revisions',
| |
| meta: 'userinfo|siteinfo',
| |
| rvprop: 'content',
| |
| rvlimit: 1,
| |
| uiprop: 'groups',
| |
| siprop: 'namespaces',
| |
| indexpageids: true,
| |
| format: 'json',
| |
| }).done(function(response) {
| |
| if (response.error) {
| |
| alert('API error: ' + response.error.info);
| |
| JWB = false; //preventing further access. No verification => no access.
| |
| return;
| |
| }
| |
| JWB.ns = response.query.namespaces; //saving for later
| |
|
| |
| JWB.username = response.query.userinfo.name; //preventing any "hacks" that change wgUserName or mw.config.wgUserName
| |
| var groups = response.query.userinfo.groups;
| |
| var page = response.query.pages[response.query.pageids[0]];
| |
| var users, bots;
| |
| if (response.query.pageids[0] !== '-1' && /<!--\s*enabledusersbegins\s*-->/.test(page.revisions[0]['*'])) {
| |
| var cont = page.revisions[0]['*'];
| |
| users = cont.substring(
| |
| cont.search(/<!--\s*enabledusersbegins\s*-->/),
| |
| cont.search(/<!--\s*enabledusersends\s*-->/)
| |
| ).split('\n');
| |
| if (/<!--\s*enabledbots\s*-->/.test(cont)) {
| |
| bots = cont.substring(
| |
| cont.search(/<!--\s*enabledbots\s*-->/),
| |
| cont.search(/<!--\s*enabledbotsends\s*-->/)
| |
| ).split('\n');
| |
| } else bots = [];
| |
| var i=0;
| |
| while (i<users.length) {
| |
| if (users[i].charAt(0) !== '*') {
| |
| users.splice(i,1);
| |
| } else {
| |
| users[i] = $.trim(users[i].substr(1));
| |
| i++;
| |
| }
| |
| }
| |
| i=0;
| |
| while (i<bots.length) {
| |
| if (bots[i].charAt(0) !== '*') {
| |
| bots.splice(i,1);
| |
| } else {
| |
| bots[i] = $.trim(bots[i].substr(1));
| |
| i++;
| |
| }
| |
| }
| |
| } else {
| |
| users = false; //fallback when page doesn't exist
| |
| }
| |
| // Temporary global debugging variables
| |
| JWB.debug = [groups.indexOf('bot'), users === false, bots && bots.indexOf(JWB.username)];
| |
| JWB.bot = groups.indexOf('bot') !== -1 && (users === false || bots.indexOf(JWB.username) !== -1);
| |
| JWB.sysop = groups.indexOf('sysop') !== -1;
| |
| if (JWB.username === "Uziel302" && response.query.userinfo.id === 13299994) {//TEMP: Dev full access to entire interface.
| |
| JWB.bot = true;
| |
| users.push("Uziel302");
| |
| }
| |
| if (JWB.sysop || response.query.pageids[0] === '-1' || users.indexOf(JWB.username) !== -1 || users === false) {
| |
| JWB.allowed = true;
| |
| if (JWB.messages.en) JWB.init(); //init if messages have already loaded
| |
| } else {
| |
| if (JWB.messages.en) {
| |
| //run this after messages have loaded, so the message that shows is in the user's language
| |
| alert(JWB.msg('not-on-list'));
| |
| }
| |
| JWB = false; //prevent further access
| |
| }
| |
| }).fail(function(xhr, error) {
| |
| alert(JWB.msg('verify-error') + '\n' + error);
| |
| JWB = false; //preventing further access. No verification => no access.
| |
| });
| |
| })();
| |
|
| |
|
| /***** Global object/variables *****/ | | /***** Global object/variables *****/ |