PageSourceSearch

https://www.othervoice.org/htm-webaxy/cookies.js

js othervoice.org collected 2026-10-02 07:19:07 UTC 8,082 bytes, 273 lines download raw bytes

1// If const cookie exists and there is no cookie session, restore cookie session
2if (document.cookie && document.cookie.search('webaxyconst_') >= 0) {
3	var allc = document.cookie.toString().split('; ');
4	var webaxy_id = '';
5	for (var a = 0; a < allc.length; a++) {
6		allc[a] = allc[a].replace(/=.*/,"");
7		if (allc[a].search(/webaxyconst_/) >= 0) {
8			webaxy_id = allc[a].replace('webaxyconst_', '');
9			webaxy_id = webaxy_id.replace(/\s+/,'');
10			break;	
11		}
12	}
13	//check if user saved const password in order restore password.
14	var webaxydontCookie = getCookieHash("webaxydontusecont_"+webaxy_id);
15	var webaxyConstCookie = getCookieHash("webaxyconst_"+webaxy_id);
16	//alert(webaxyConstCookie['username'])
17	var webaxyCookie = getCookieHash("webaxylogin_"+webaxy_id);
18	if (!webaxydontCookie['exists'] && webaxyConstCookie['username'] && webaxyConstCookie['password'] && (!webaxyCookie['username'] || !webaxyCookie['password'])) {
19		var xmlHttpRPwd;
20		try {  // Firefox, Opera 8.0+, Safari  
21					xmlHttpRPwd = new XMLHttpRequest(); 
22		}
23		catch (e) {  // Internet Explorer  
24			try {
25				xmlHttpRPwd=new ActiveXObject("Msxml2.XMLHTTP");
26			}
27			catch (e) {   
28				 try {
29			 	   xmlHttpRPwd=new ActiveXObject("Microsoft.XMLHTTP");
30				 }
31			 	 catch (e)  {
32				   	alert("Your browser does not support AJAX!");  
33				}
34			}
35		}
36			 
37		xmlHttpRPwd.onreadystatechange=function() {
38			if(xmlHttpRPwd.readyState == 4) {	  					
39				var resp = xmlHttpRPwd.responseText;
40				cook = resp; 
41			 	cook = cook.replace(/<script>/,'');
42			 	cook = cook.replace(/<\/script>/,'');
43			 	try {
44			 		eval(cook);
45			 		var rc = 1;
46			 		var sid = parseInt(Math.random()*999);
47			 		loc = window.location.href;
48			 		
49			 		//try to get rc (reload counter), in order to avoid infine loop
50			 		if (loc.search(/rc=(\d+)$/) >= 0) {
51			 			try {
52			 				rc = parseInt(RegExp.$1);
53			 				rc++;
54			 				if (rc == 3) {
55			 					if (typeof(lang.general_problem) == 'undefined') {
56			 						alert('There is a general problem with your password. Please contact the site manager.');
57			 					}
58			 					else {
59			 						alert(lang.general_problem);
60			 					}
61			 					clearAllCookies();
62			 					return;
63			 				}
64			 			}
65			 			catch (ex) {
66			 				rc = 1;
67			 			}
68				    loc= loc.replace(/rc=\d+$/, 'rc='+rc);
69					}
70					else if (loc.search(/rc=(\d+)&/) >= 0) {
71			 			try {
72			 				rc = parseInt(RegExp.$1);
73			 				rc++;
74			 				if (rc == 3) {
75			 					if (typeof(lang.general_problem) == 'undefined') {
76			 						alert('There is a general problem with your password. Please contact the site manager.');
77			 					}
78			 					else {
79			 						alert(lang.general_groblem);
80			 					}
81			 					clearAllCookies();
82			 					return;
83			 				}
84			 			}
85			 			catch (ex) {
86			 				rc = 1;
87			 			}
88				    loc= loc.replace(/rc=\d+&/, 'rc='+rc+'&');
89					}
90			 		else {			 		
91						if (loc.search(/\?/) == -1) loc = loc+'?';
92			 			if (loc.search('#') == -1) loc = loc+'&rc='+rc;
93						else {
94							sulamit = loc.search('#');
95							loc = loc.substring(0,sulamit)+'&rc='+1+loc.substring(sulamit);
96						}
97					}
98					
99			 		if (loc.search(/sid=\d+$/) >= 0) {
100				    loc= loc.replace(/sid=\d+$/, 'sid='+sid);
101					}
102					else if (url.search(/sid=\d+&/) >= 0) {
103				    loc = loc.replace(/sid=\d+&/, 'sid='+sid+'&');
104					}
105					else {			 		
106						if (loc.search(/\?/) == -1) loc = loc+'?';
107			 			if (loc.search('#') == -1) loc = loc+'&sid='+sid;
108						else {
109							sulamit = loc.search('#');
110							loc = loc.substring(0,sulamit)+'&sid='+sid+loc.substring(sulamit);
111						}
112					}
113					
114					location.replace(loc);
115			 	} catch(e){}
116			}
117		}
118		 var sid = parseInt(Math.random()*999);
119		 url = '&act=gourl&reloadSaved=1&sid='+sid;//&username='+username+'&password='+password;
120		 xmlHttpRPwd.open("GET","/cgi-webaxy/webaxy_login.pl?ID="+webaxy_id+url,true);
121		 xmlHttpRPwd.send(null);
122	}
123}
124
125// Cookies for webaxy
126function getCookieHash(cookieName) {
127	let search = cookieName + "=";
128	let valueOffset = 0;
129	let valueEnd = 0;
130	let cookieValue = '';
131	let cookie1 = document.cookie;
132	let cookieHash = new Object();
133	valueOffset = cookie1.indexOf(search);
134	
135	if (cookieName.indexOf("webaxy") == -1 && sessionStorage.getItem(cookieName)) {
136		cookieValue = sessionStorage.getItem(cookieName);
137	}
138	else if (valueOffset != -1) {// if cookie exists 
139		valueOffset += search.length;// set index of beginning of value
140		valueEnd = cookie1.indexOf(";", valueOffset);// set index of end of cookie value
141		if (valueEnd == -1) {
142			valueEnd = cookie1.length;
143		}
144		cookieValue = cookie1.substring(valueOffset, valueEnd);
145	}
146	if (cookieValue != '') {
147		let arrTmp = cookieValue.split('&');
148		for (let i = 0; i < arrTmp.length; i+=2) {
149			arrTmp[i  ] = decodeURIComponent(arrTmp[i]  );
150			cookieHash[arrTmp[i]] = '';
151			if (i+1 < arrTmp.length) {
152				arrTmp[i+1] = decodeURIComponent(arrTmp[i+1]);
153				cookieHash[arrTmp[i]] = arrTmp[i+1]; // arrTmp[i+1] ? arrTmp[i+1] : '';
154			}
155		}
156		return cookieHash;
157	}
158	else {
159		return '';
160	}
161}
162
163//=============================================================================
164// Function Name: Name
165// Function Parameter: <Parameter Name>:<parameter description>
166// Function Parameter: 
167// Function Description: <description>
168// Function Results: <return value if any>
169//=============================================================================
170function clearAllCookies() {
171	if (!document.cookie) {
172		return;
173	}
174	let allc = document.cookie.toString().split('; ');
175	for (let a = 0; a < allc.length; a++) {
176		allc[a] = allc[a].replace(/=.*/,"");
177		clearCookie(allc[a]);
178	}
179}
180
181//------------------------------------------------------------
182function clearCookie(cookieName) {
183	if (cookieName.indexOf("webaxy") == -1) {
184		sessionStorage.removeItem(cookieName);
185		try {
186			top.sessionStorage.removeItem(cookieName);
187		}
188		catch(err) {	}
189	}
190	var cookieValue = cookieName+"=null; sameSite=Strict; path=/; expires=Wed, 16 Jan 2008 01:00:00 UTC";
191	document.cookie = cookieValue;
192	try {
193		top.document.cookie = cookieValue;
194	}
195	catch(err) {	}
196}
197//----------------------------------------------------------------------
198function set_cookie(cookieName,cookieVal,expire) {
199	
200	if (cookieName.indexOf("webaxy") == -1 && !expire) {
201		sessionStorage.setItem(cookieName,cookieVal);
202		try {
203			top.sessionStorage.setItem(cookieName,cookieVal);
204		}
205		catch(err) {	}
206		return;
207	}
208  		
209	var sameSiteAttr = "Strict";
210	if (crossOriginFrame()) {
211		sameSiteAttr = "None; secure";
212	}
213	var cookieValue = cookieName+"="+encodeURIComponent(cookieVal)+"; sameSite="+sameSiteAttr+"; path=/"+(((expire==null) || (expire=="")) ? "" : (";expires="+expire.toGMTString()));
214	if (cookieValue.length > 4096) {
215		return;
216	}
217	document.cookie  = cookieValue;
218	try {
219		top.document.cookie = cookieValue;
220	}
221	catch(err) {	}
222}
223//-----------------------------
224function get_cookie(cookieName) {
225  		if (cookieName.indexOf("webaxy") == -1 && sessionStorage.getItem(cookieName)) {
226  			return sessionStorage.getItem(cookieName);
227  		}
228  		var search = cookieName + "=";
229  		if (document.cookie.length > 0) { // if there are any cookies
230			 offset = document.cookie.indexOf(search);
231 			 if (offset != -1) { // if cookie exists 
232    			offset += search.length ;  // set index of beginning of value
233   				end = document.cookie.indexOf(";", offset); // set index of end of cookie value
234    			if (end == -1) 
235       					end = document.cookie.length;
236    			return decodeURIComponent(document.cookie.substring(offset, end))
237		 		}
238  		}
239  		return null;
240}
241//------------------------------
242function checkCookie(cookieName) {
243	var gc = get_cookie(cookieName);
244	if (!gc)
245		return "";
246	return gc;
247}
248//------------------------------
249function userExit(cookieName,loc) {
250	if (!loc) {
251		loc = "/";
252	}
253	try {
254		clearCookie(cookieName);
255		cookieName = cookieName.replace("webaxylogin","webaxyconst");
256		clearCookie(cookieName);
257		top.location.replace(loc);
258	} 
259	catch(e) {
260		self.location.replace(loc);
261	}
262}
263
264function crossOriginFrame() {
265	// 5443
266  try {
267    return (!window.top.location.hostname);
268  } 
269  catch (err) {
270    return true;
271  }
272}		
273				

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.